@go-avro/avro-js 0.0.2-beta.9 → 0.0.2-beta.90

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +1 -0
  2. package/dist/auth/AuthManager.d.ts +4 -0
  3. package/dist/auth/AuthManager.js +18 -2
  4. package/dist/client/QueryClient.d.ts +349 -15
  5. package/dist/client/QueryClient.js +302 -195
  6. package/dist/client/core/fetch.d.ts +1 -0
  7. package/dist/client/core/fetch.js +62 -0
  8. package/dist/client/core/utils.d.ts +1 -0
  9. package/dist/client/core/utils.js +14 -0
  10. package/dist/client/core/xhr.d.ts +1 -0
  11. package/dist/client/core/xhr.js +84 -0
  12. package/dist/client/hooks/analytics.d.ts +1 -0
  13. package/dist/client/hooks/analytics.js +10 -0
  14. package/dist/client/hooks/avro.d.ts +1 -0
  15. package/dist/client/hooks/avro.js +9 -0
  16. package/dist/client/hooks/bills.d.ts +1 -0
  17. package/dist/client/hooks/bills.js +141 -0
  18. package/dist/client/hooks/chats.d.ts +1 -0
  19. package/dist/client/hooks/chats.js +37 -0
  20. package/dist/client/hooks/companies.d.ts +1 -0
  21. package/dist/client/hooks/companies.js +79 -0
  22. package/dist/client/hooks/events.d.ts +1 -0
  23. package/dist/client/hooks/events.js +307 -0
  24. package/dist/client/hooks/jobs.d.ts +1 -0
  25. package/dist/client/hooks/jobs.js +185 -0
  26. package/dist/client/hooks/messages.d.ts +1 -0
  27. package/dist/client/hooks/messages.js +30 -0
  28. package/dist/client/hooks/months.d.ts +1 -0
  29. package/dist/client/hooks/months.js +92 -0
  30. package/dist/client/hooks/plans.d.ts +1 -0
  31. package/dist/client/hooks/plans.js +9 -0
  32. package/dist/client/hooks/root.d.ts +1 -0
  33. package/dist/client/hooks/root.js +8 -0
  34. package/dist/client/hooks/routes.d.ts +1 -0
  35. package/dist/client/hooks/routes.js +123 -0
  36. package/dist/client/hooks/sessions.d.ts +1 -0
  37. package/dist/client/hooks/sessions.js +154 -0
  38. package/dist/client/hooks/teams.d.ts +1 -0
  39. package/dist/client/hooks/teams.js +117 -0
  40. package/dist/client/hooks/users.d.ts +1 -0
  41. package/dist/client/hooks/users.js +104 -0
  42. package/dist/index.d.ts +19 -0
  43. package/dist/index.js +19 -0
  44. package/dist/types/api.d.ts +118 -29
  45. package/dist/types/api.js +10 -1
  46. package/package.json +6 -1
@@ -0,0 +1,123 @@
1
+ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
2
+ import { AvroQueryClient } from '../../client/QueryClient';
3
+ AvroQueryClient.prototype.useGetRoutes = function (companyGuid, body, total, onProgress) {
4
+ return useQuery({
5
+ queryKey: ['routes', companyGuid, body.amt ?? 50, body.query ?? ""],
6
+ queryFn: async () => {
7
+ if (typeof total !== "number") {
8
+ return this.fetchRoutes(companyGuid, { ...body, offset: 0 });
9
+ }
10
+ onProgress?.(0);
11
+ const pageCount = body.amt ? Math.ceil(total / body.amt) : 0;
12
+ let completed = 0;
13
+ const promises = Array.from({ length: pageCount }, (_, i) => this.fetchRoutes(companyGuid, {
14
+ ...body,
15
+ offset: i * (body.amt ?? 0),
16
+ }));
17
+ const trackedPromises = promises.map((promise) => promise.then((result) => {
18
+ completed++;
19
+ const fraction = completed / pageCount;
20
+ onProgress?.(fraction);
21
+ return result;
22
+ }));
23
+ const pages = await Promise.all(trackedPromises);
24
+ const routes = pages.flat();
25
+ return routes;
26
+ },
27
+ enabled: Boolean(companyGuid) && companyGuid.length > 0,
28
+ });
29
+ };
30
+ AvroQueryClient.prototype.useGetRoute = function (routeId) {
31
+ const queryClient = useQueryClient();
32
+ return useQuery({
33
+ queryKey: ['route', routeId],
34
+ queryFn: () => this.get(`/route/${routeId}`),
35
+ enabled: Boolean(routeId) && routeId.length > 0,
36
+ });
37
+ };
38
+ AvroQueryClient.prototype.useUpdateRoute = function () {
39
+ const queryClient = useQueryClient();
40
+ return useMutation({
41
+ mutationFn: async ({ routeId, updates, }) => {
42
+ return this.put(`/route/${routeId}`, JSON.stringify(updates), undefined, { "Content-Type": "application/json" });
43
+ },
44
+ onMutate: async ({ routeId, updates }) => {
45
+ await queryClient.cancelQueries({ queryKey: ['route', routeId] });
46
+ await queryClient.cancelQueries({ queryKey: ['routes'] });
47
+ const previousRoute = queryClient.getQueryData(['route', routeId]);
48
+ const previousRoutes = queryClient.getQueryData(['routes']);
49
+ queryClient.setQueryData(['route', routeId], (oldData) => oldData ? { ...oldData, ...updates } : undefined);
50
+ queryClient.setQueriesData({ queryKey: ['routes'] }, (oldData) => {
51
+ if (!oldData)
52
+ return oldData;
53
+ if (oldData.pages) {
54
+ return {
55
+ ...oldData,
56
+ pages: oldData.pages.map((page) => page.map((route) => route.id === routeId ? { ...route, ...updates } : route)),
57
+ };
58
+ }
59
+ if (Array.isArray(oldData)) {
60
+ return oldData.map((route) => route.id === routeId ? { ...route, ...updates } : route);
61
+ }
62
+ return oldData;
63
+ });
64
+ return { previousRoute, previousRoutes };
65
+ },
66
+ onError: (_err, variables, context) => {
67
+ const { routeId } = variables;
68
+ if (context?.previousRoute) {
69
+ queryClient.setQueryData(['route', routeId], context.previousRoute);
70
+ }
71
+ if (context?.previousRoutes) {
72
+ queryClient.setQueryData(['routes'], context.previousRoutes);
73
+ }
74
+ },
75
+ onSettled: (_data, _error, variables) => {
76
+ const { routeId } = variables;
77
+ queryClient.invalidateQueries({ queryKey: ['route', routeId] });
78
+ queryClient.invalidateQueries({ queryKey: ['routes'] });
79
+ },
80
+ });
81
+ };
82
+ AvroQueryClient.prototype.useDeleteRoute = function () {
83
+ const queryClient = useQueryClient();
84
+ return useMutation({
85
+ mutationFn: async ({ routeId, }) => {
86
+ return this.delete(`/route/${routeId}`);
87
+ },
88
+ onMutate: async ({ routeId }) => {
89
+ await queryClient.cancelQueries({ queryKey: ['routes'] });
90
+ await queryClient.cancelQueries({ queryKey: ['route', routeId] });
91
+ const previousRoutes = queryClient.getQueryData(['routes']);
92
+ const previousRoute = queryClient.getQueryData(['route', routeId]);
93
+ queryClient.setQueryData(['route', routeId], undefined);
94
+ queryClient.setQueriesData({ queryKey: ['routes'] }, (oldData) => {
95
+ if (!oldData)
96
+ return oldData;
97
+ if (oldData.pages) {
98
+ const updatedPages = oldData.pages.map((page) => page.filter((route) => route.id !== routeId));
99
+ return { ...oldData, pages: updatedPages };
100
+ }
101
+ if (Array.isArray(oldData)) {
102
+ return oldData.filter((route) => route.id !== routeId);
103
+ }
104
+ return oldData;
105
+ });
106
+ return { previousRoutes, previousRoute };
107
+ },
108
+ onError: (_err, variables, context) => {
109
+ const { routeId } = variables;
110
+ if (context?.previousRoutes) {
111
+ queryClient.setQueryData(['routes'], context.previousRoutes);
112
+ }
113
+ if (context?.previousRoute) {
114
+ queryClient.setQueryData(['route', routeId], context.previousRoute);
115
+ }
116
+ },
117
+ onSettled: (_data, _error, variables) => {
118
+ const { routeId } = variables;
119
+ queryClient.invalidateQueries({ queryKey: ['routes'] });
120
+ queryClient.invalidateQueries({ queryKey: ['route', routeId] });
121
+ },
122
+ });
123
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,154 @@
1
+ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
2
+ import { AvroQueryClient } from "../../client/QueryClient";
3
+ AvroQueryClient.prototype.useGetUserSessions = function () {
4
+ return useQuery({
5
+ queryKey: ['sessions'],
6
+ queryFn: () => this.get('/session'),
7
+ });
8
+ };
9
+ AvroQueryClient.prototype.useCreateUserSession = function () {
10
+ const queryClient = useQueryClient();
11
+ return useMutation({
12
+ mutationFn: ({ companyId, sessionData }) => {
13
+ return this.post(`/company/${companyId}/session`, JSON.stringify(sessionData), undefined, {
14
+ "Content-Type": "application/json",
15
+ });
16
+ },
17
+ onMutate: async ({ companyId, sessionData }) => {
18
+ await queryClient.cancelQueries({ queryKey: ['sessions'] });
19
+ const previousSessions = queryClient.getQueryData(['sessions']);
20
+ queryClient.setQueryData(['sessions'], (oldData) => {
21
+ if (!oldData)
22
+ return [];
23
+ if (Array.isArray(oldData)) {
24
+ return [
25
+ ...oldData,
26
+ {
27
+ ...sessionData,
28
+ id: Math.random().toString(36).substr(2, 9),
29
+ company_id: companyId,
30
+ }
31
+ ];
32
+ }
33
+ return oldData;
34
+ });
35
+ return { previousSessions };
36
+ },
37
+ onError: (err, variables, context) => {
38
+ if (context?.previousSessions) {
39
+ queryClient.setQueryData(['sessions'], context.previousSessions);
40
+ }
41
+ },
42
+ onSettled: () => {
43
+ queryClient.invalidateQueries({ queryKey: ['sessions'] });
44
+ },
45
+ });
46
+ };
47
+ AvroQueryClient.prototype.useCreateSessionBreak = function () {
48
+ const queryClient = useQueryClient();
49
+ return useMutation({
50
+ mutationFn: ({ sessionId, breakData }) => {
51
+ return this.post(`/session/${sessionId}/break`, JSON.stringify(breakData), undefined, {
52
+ "Content-Type": "application/json",
53
+ });
54
+ },
55
+ onMutate: async ({ sessionId, breakData }) => {
56
+ await queryClient.cancelQueries({ queryKey: ['sessions'] });
57
+ const previousSessions = queryClient.getQueryData(['sessions']);
58
+ queryClient.setQueryData(['sessions'], (oldData) => {
59
+ if (!oldData)
60
+ return oldData;
61
+ if (Array.isArray(oldData)) {
62
+ return oldData.map((session) => session.id === sessionId
63
+ ? {
64
+ ...session,
65
+ breaks: [
66
+ ...(session.breaks || []),
67
+ {
68
+ ...breakData,
69
+ id: Math.random().toString(36).substr(2, 9),
70
+ session_id: sessionId,
71
+ }
72
+ ]
73
+ }
74
+ : session);
75
+ }
76
+ return oldData;
77
+ });
78
+ return { previousSessions };
79
+ },
80
+ onError: (err, variables, context) => {
81
+ if (context?.previousSessions) {
82
+ queryClient.setQueryData(['sessions'], context.previousSessions);
83
+ }
84
+ },
85
+ onSettled: () => {
86
+ queryClient.invalidateQueries({ queryKey: ['sessions'] });
87
+ },
88
+ });
89
+ };
90
+ AvroQueryClient.prototype.useUpdateUserSession = function () {
91
+ const queryClient = useQueryClient();
92
+ return useMutation({
93
+ mutationFn: ({ sessionId, updates }) => {
94
+ return this.put(`/session/${sessionId}`, JSON.stringify(updates), undefined, {
95
+ "Content-Type": "application/json",
96
+ });
97
+ },
98
+ onMutate: async ({ sessionId, updates }) => {
99
+ await queryClient.cancelQueries({ queryKey: ['sessions'] });
100
+ const previousSessions = queryClient.getQueryData(['sessions']);
101
+ queryClient.setQueryData(['sessions'], (oldData) => {
102
+ if (!oldData)
103
+ return oldData;
104
+ if (Array.isArray(oldData)) {
105
+ return oldData.map((session) => session.id === sessionId ? { ...session, ...updates } : session);
106
+ }
107
+ return oldData;
108
+ });
109
+ return { previousSessions };
110
+ },
111
+ onError: (err, variables, context) => {
112
+ if (context?.previousSessions) {
113
+ queryClient.setQueryData(['sessions'], context.previousSessions);
114
+ }
115
+ },
116
+ onSettled: () => {
117
+ queryClient.invalidateQueries({ queryKey: ['sessions'] });
118
+ },
119
+ });
120
+ };
121
+ AvroQueryClient.prototype.useUpdateSessionBreak = function () {
122
+ const queryClient = useQueryClient();
123
+ return useMutation({
124
+ mutationFn: ({ breakId, updates }) => {
125
+ return this.put(`/break/${breakId}`, JSON.stringify(updates), undefined, {
126
+ "Content-Type": "application/json",
127
+ });
128
+ },
129
+ onMutate: async ({ breakId, updates }) => {
130
+ await queryClient.cancelQueries({ queryKey: ['sessions'] });
131
+ const previousSessions = queryClient.getQueryData(['sessions']);
132
+ queryClient.setQueryData(['sessions'], (oldData) => {
133
+ if (!oldData)
134
+ return oldData;
135
+ if (Array.isArray(oldData)) {
136
+ return oldData.map((session) => ({
137
+ ...session,
138
+ breaks: session.breaks?.map(b => b.id === breakId ? { ...b, ...updates } : b)
139
+ }));
140
+ }
141
+ return oldData;
142
+ });
143
+ return { previousSessions };
144
+ },
145
+ onError: (err, variables, context) => {
146
+ if (context?.previousSessions) {
147
+ queryClient.setQueryData(['sessions'], context.previousSessions);
148
+ }
149
+ },
150
+ onSettled: () => {
151
+ queryClient.invalidateQueries({ queryKey: ['sessions'] });
152
+ },
153
+ });
154
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,117 @@
1
+ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
2
+ import { AvroQueryClient } from "../../client/QueryClient";
3
+ AvroQueryClient.prototype.useGetTeams = function (companyGuid, body, total, onProgress) {
4
+ return useQuery({
5
+ queryKey: ['teams', companyGuid, body.amt ?? 50, body.query ?? ""],
6
+ queryFn: async () => {
7
+ if (typeof total !== "number") {
8
+ return this.fetchTeams(companyGuid, { ...body, offset: 0 });
9
+ }
10
+ onProgress?.(0);
11
+ const pageCount = body.amt ? Math.ceil(total / body.amt) : 0;
12
+ let completed = 0;
13
+ const promises = Array.from({ length: pageCount }, (_, i) => this.fetchTeams(companyGuid, {
14
+ ...body,
15
+ offset: i * (body.amt ?? 0),
16
+ }));
17
+ const trackedPromises = promises.map((promise) => promise.then((result) => {
18
+ completed++;
19
+ const fraction = completed / pageCount;
20
+ onProgress?.(fraction);
21
+ return result;
22
+ }));
23
+ const pages = await Promise.all(trackedPromises);
24
+ const teams = pages.flat();
25
+ return teams;
26
+ },
27
+ enabled: Boolean(companyGuid) && companyGuid.length > 0,
28
+ });
29
+ };
30
+ AvroQueryClient.prototype.useUpdateTeam = function () {
31
+ const queryClient = useQueryClient();
32
+ return useMutation({
33
+ mutationFn: async ({ teamId, teamData }) => {
34
+ return this.put(`/team/${teamId}`, JSON.stringify(teamData), undefined, { "Content-Type": "application/json" });
35
+ },
36
+ onMutate: async ({ teamId, teamData }) => {
37
+ await queryClient.cancelQueries({ queryKey: ['teams'] });
38
+ await queryClient.cancelQueries({ queryKey: ['team', teamId] });
39
+ const previousTeams = queryClient.getQueryData(['teams']);
40
+ const previousTeam = queryClient.getQueryData(['team', teamId]);
41
+ queryClient.setQueryData(['team', teamId], (oldData) => {
42
+ if (!oldData)
43
+ return oldData;
44
+ return { ...oldData, ...teamData };
45
+ });
46
+ queryClient.setQueriesData({ queryKey: ['teams'] }, (oldData) => {
47
+ if (!oldData)
48
+ return oldData;
49
+ if (oldData.pages) {
50
+ const updatedPages = oldData.pages.map((page) => page.map((team) => team.id === teamId ? { ...team, ...teamData } : team));
51
+ return { ...oldData, pages: updatedPages };
52
+ }
53
+ if (Array.isArray(oldData)) {
54
+ return oldData.map((team) => team.id === teamId ? { ...team, ...teamData } : team);
55
+ }
56
+ return oldData;
57
+ });
58
+ return { previousTeams, previousTeam };
59
+ },
60
+ onError: (_err, variables, context) => {
61
+ const { teamId } = variables;
62
+ if (context?.previousTeams) {
63
+ queryClient.setQueryData(['teams'], context.previousTeams);
64
+ }
65
+ if (context?.previousTeam) {
66
+ queryClient.setQueryData(['team', teamId], context.previousTeam);
67
+ }
68
+ },
69
+ onSettled: (_data, _error, variables) => {
70
+ const { teamId } = variables;
71
+ queryClient.invalidateQueries({ queryKey: ['teams'] });
72
+ queryClient.invalidateQueries({ queryKey: ['team', teamId] });
73
+ },
74
+ });
75
+ };
76
+ AvroQueryClient.prototype.useDeleteTeam = function () {
77
+ const queryClient = useQueryClient();
78
+ return useMutation({
79
+ mutationFn: async ({ teamId, }) => {
80
+ return this.delete(`/team/${teamId}`);
81
+ },
82
+ onMutate: async ({ teamId }) => {
83
+ await queryClient.cancelQueries({ queryKey: ['teams'] });
84
+ await queryClient.cancelQueries({ queryKey: ['team', teamId] });
85
+ const previousRoutes = queryClient.getQueryData(['teams']);
86
+ const previousRoute = queryClient.getQueryData(['team', teamId]);
87
+ queryClient.setQueryData(['team', teamId], undefined);
88
+ queryClient.setQueriesData({ queryKey: ['teams'] }, (oldData) => {
89
+ if (!oldData)
90
+ return oldData;
91
+ if (oldData.pages) {
92
+ const updatedPages = oldData.pages.map((page) => page.filter((team) => team.id !== teamId));
93
+ return { ...oldData, pages: updatedPages };
94
+ }
95
+ if (Array.isArray(oldData)) {
96
+ return oldData.filter((team) => team.id !== teamId);
97
+ }
98
+ return oldData;
99
+ });
100
+ return { previousRoutes, previousRoute };
101
+ },
102
+ onError: (_err, variables, context) => {
103
+ const { teamId } = variables;
104
+ if (context?.previousRoutes) {
105
+ queryClient.setQueryData(['teams'], context.previousRoutes);
106
+ }
107
+ if (context?.previousRoute) {
108
+ queryClient.setQueryData(['team', teamId], context.previousRoute);
109
+ }
110
+ },
111
+ onSettled: (_data, _error, variables) => {
112
+ const { teamId } = variables;
113
+ queryClient.invalidateQueries({ queryKey: ['teams'] });
114
+ queryClient.invalidateQueries({ queryKey: ['team', teamId] });
115
+ },
116
+ });
117
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,104 @@
1
+ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
2
+ import { AvroQueryClient } from "../../client/QueryClient";
3
+ AvroQueryClient.prototype.useGetUser = function (userId) {
4
+ return useQuery({
5
+ queryKey: ['user', userId],
6
+ queryFn: () => this.get(`/user/${userId}`),
7
+ enabled: Boolean(userId),
8
+ });
9
+ };
10
+ AvroQueryClient.prototype.useSearchUsers = function (searchUsername) {
11
+ return useQuery({
12
+ queryKey: ['user', 'search', searchUsername],
13
+ queryFn: () => {
14
+ if (!searchUsername)
15
+ return Promise.resolve([]);
16
+ return this.get(`/user/search/${searchUsername}`);
17
+ },
18
+ enabled: Boolean(searchUsername),
19
+ });
20
+ };
21
+ AvroQueryClient.prototype.useGetSelf = function () {
22
+ return useQuery({
23
+ queryKey: ['user'],
24
+ queryFn: () => this.get(`/user`),
25
+ enabled: Boolean(this),
26
+ });
27
+ };
28
+ AvroQueryClient.prototype.useCreateSelf = function () {
29
+ const queryClient = useQueryClient();
30
+ return useMutation({
31
+ mutationFn: async (data) => {
32
+ return this.post('/user', JSON.stringify(data), undefined, { "Content-Type": "application/json" });
33
+ },
34
+ onSettled: () => {
35
+ queryClient.invalidateQueries({ queryKey: ['user'] });
36
+ },
37
+ });
38
+ };
39
+ AvroQueryClient.prototype.useUpdateUserCompany = function () {
40
+ const queryClient = useQueryClient();
41
+ return useMutation({
42
+ mutationFn: async ({ company_id, user_id, data }) => {
43
+ return this.put(`/company/${company_id}/user/${user_id}`, JSON.stringify(data), undefined, { "Content-Type": "application/json" });
44
+ },
45
+ // Optimistically update the user data and company data in the cache
46
+ onMutate: async (data) => {
47
+ await queryClient.cancelQueries({ queryKey: ['user'] });
48
+ await queryClient.cancelQueries({ queryKey: ['company', data.company_id] });
49
+ const previousUser = queryClient.getQueryData(['user']);
50
+ const previousCompany = queryClient.getQueryData(['company', data.company_id]);
51
+ if (previousUser) {
52
+ let oldUserCompany = previousUser.companies?.find(c => c.company === data.company_id);
53
+ if (oldUserCompany) {
54
+ oldUserCompany = { ...oldUserCompany, ...data.data };
55
+ const newCompanies = previousUser.companies?.map(c => c.company === data.company_id ? oldUserCompany : c) ?? [];
56
+ queryClient.setQueryData(['user'], { ...previousUser, companies: newCompanies });
57
+ }
58
+ }
59
+ if (previousCompany) {
60
+ let oldCompanyUser = previousCompany.users?.find((u) => u.user.id === data.user_id);
61
+ if (oldCompanyUser) {
62
+ oldCompanyUser = { ...oldCompanyUser, ...data.data };
63
+ const newUsers = previousCompany.users?.map((u) => u.user.id === data.user_id ? oldCompanyUser : u) ?? [];
64
+ queryClient.setQueryData(['company', data.company_id], { ...previousCompany, users: newUsers });
65
+ }
66
+ }
67
+ return { previousUser, previousCompany };
68
+ },
69
+ onError: (err, _, context) => {
70
+ if (context?.previousUser) {
71
+ queryClient.setQueryData(['user'], context.previousUser);
72
+ }
73
+ if (context?.previousCompany) {
74
+ queryClient.setQueryData(['company'], context.previousCompany);
75
+ }
76
+ },
77
+ onSettled: (data, error, variables) => {
78
+ queryClient.invalidateQueries({ queryKey: ['user'] });
79
+ queryClient.invalidateQueries({ queryKey: ['company', variables.company_id] });
80
+ },
81
+ });
82
+ };
83
+ AvroQueryClient.prototype.useDeleteSelf = function () {
84
+ const queryClient = useQueryClient();
85
+ return useMutation({
86
+ mutationFn: async () => {
87
+ return this.delete(`/user`);
88
+ },
89
+ onMutate: async () => {
90
+ await queryClient.cancelQueries({ queryKey: ['user'] });
91
+ const previousUser = queryClient.getQueryData(['user']);
92
+ queryClient.removeQueries({ queryKey: ['user'] });
93
+ return { previousUser };
94
+ },
95
+ onError: (err, _, context) => {
96
+ if (context?.previousUser) {
97
+ queryClient.setQueryData(['user'], context.previousUser);
98
+ }
99
+ },
100
+ onSettled: () => {
101
+ queryClient.invalidateQueries({ queryKey: ['user'] });
102
+ },
103
+ });
104
+ };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,25 @@
1
1
  export { AvroQueryClientConfig, AvroQueryClient } from './client/QueryClient';
2
2
  export { AuthManager } from './auth/AuthManager';
3
3
  export { MemoryStorage, LocalStorage } from './auth/storage';
4
+ import './client/core/xhr';
5
+ import './client/core/fetch';
6
+ import './client/core/utils';
7
+ import './client/hooks/root';
8
+ import './client/hooks/jobs';
9
+ import './client/hooks/routes';
10
+ import './client/hooks/events';
11
+ import './client/hooks/months';
12
+ import './client/hooks/bills';
13
+ import './client/hooks/companies';
14
+ import './client/hooks/users';
15
+ import './client/hooks/sessions';
16
+ import './client/hooks/chats';
17
+ import './client/hooks/messages';
18
+ import './client/hooks/plans';
19
+ import './client/hooks/analytics';
20
+ import './client/hooks/avro';
21
+ import './client/hooks/teams';
4
22
  export * from './types/api';
23
+ export * from './types/auth';
5
24
  export * from './types/error';
6
25
  export * from './types/client';
package/dist/index.js CHANGED
@@ -1,6 +1,25 @@
1
1
  export { AvroQueryClient } from './client/QueryClient';
2
2
  export { AuthManager } from './auth/AuthManager';
3
3
  export { MemoryStorage, LocalStorage } from './auth/storage';
4
+ import './client/core/xhr';
5
+ import './client/core/fetch';
6
+ import './client/core/utils';
7
+ import './client/hooks/root';
8
+ import './client/hooks/jobs';
9
+ import './client/hooks/routes';
10
+ import './client/hooks/events';
11
+ import './client/hooks/months';
12
+ import './client/hooks/bills';
13
+ import './client/hooks/companies';
14
+ import './client/hooks/users';
15
+ import './client/hooks/sessions';
16
+ import './client/hooks/chats';
17
+ import './client/hooks/messages';
18
+ import './client/hooks/plans';
19
+ import './client/hooks/analytics';
20
+ import './client/hooks/avro';
21
+ import './client/hooks/teams';
4
22
  export * from './types/api';
23
+ export * from './types/auth';
5
24
  export * from './types/error';
6
25
  export * from './types/client';