@go-avro/avro-js 0.0.119 → 0.0.120
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.
- package/dist/client/QueryClient.d.ts +7 -37
- package/dist/client/QueryClient.js +67 -750
- package/dist/client/hooks/bills.js +29 -72
- package/dist/client/hooks/catalog_items.js +6 -20
- package/dist/client/hooks/chats.js +7 -8
- package/dist/client/hooks/checkins.js +3 -15
- package/dist/client/hooks/companies.js +8 -24
- package/dist/client/hooks/events.js +25 -85
- package/dist/client/hooks/groups.js +9 -4
- package/dist/client/hooks/jobs.js +15 -35
- package/dist/client/hooks/labels.js +9 -4
- package/dist/client/hooks/messages.js +7 -8
- package/dist/client/hooks/months.js +13 -15
- package/dist/client/hooks/payouts.js +13 -14
- package/dist/client/hooks/prepayments.js +13 -15
- package/dist/client/hooks/proposal.js +3 -9
- package/dist/client/hooks/routes.js +13 -38
- package/dist/client/hooks/skills.js +9 -4
- package/dist/client/hooks/teams.js +9 -4
- package/dist/client/hooks/waivers.js +12 -13
- package/dist/client/realtime.d.ts +64 -0
- package/dist/client/realtime.js +470 -0
- package/dist/types/api/Job.d.ts +1 -1
- package/dist/types/api/Task.d.ts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { useMutation, useQuery } from '@tanstack/react-query';
|
|
2
2
|
import { AvroQueryClient } from '../../client/QueryClient';
|
|
3
|
+
import { keys } from '../../client/realtime';
|
|
3
4
|
AvroQueryClient.prototype.useGetLabels = function (body, total, onProgress) {
|
|
4
5
|
return useQuery({
|
|
5
|
-
queryKey:
|
|
6
|
+
queryKey: keys.list('labels', this.companyId, {
|
|
7
|
+
amt: body.amt ?? 50,
|
|
8
|
+
query: body.query ?? '',
|
|
9
|
+
total: total ?? 'all',
|
|
10
|
+
}),
|
|
6
11
|
queryFn: async () => {
|
|
7
12
|
if (typeof total !== 'number') {
|
|
8
13
|
return this.fetchLabels({ ...body, offset: 0 });
|
|
@@ -37,7 +42,7 @@ AvroQueryClient.prototype.useCreateLabel = function () {
|
|
|
37
42
|
});
|
|
38
43
|
},
|
|
39
44
|
onSuccess: () => {
|
|
40
|
-
|
|
45
|
+
this.syncAfterMutation('label');
|
|
41
46
|
},
|
|
42
47
|
});
|
|
43
48
|
};
|
|
@@ -76,7 +81,7 @@ AvroQueryClient.prototype.useUpdateLabel = function () {
|
|
|
76
81
|
return { previousLabels, previousLabel };
|
|
77
82
|
},
|
|
78
83
|
onSuccess: () => {
|
|
79
|
-
|
|
84
|
+
this.syncAfterMutation('label');
|
|
80
85
|
},
|
|
81
86
|
onError: (_err, variables, context) => {
|
|
82
87
|
const { labelId } = variables;
|
|
@@ -116,7 +121,7 @@ AvroQueryClient.prototype.useDeleteLabel = function () {
|
|
|
116
121
|
return { previousLabels, previousLabel };
|
|
117
122
|
},
|
|
118
123
|
onSuccess: () => {
|
|
119
|
-
|
|
124
|
+
this.syncAfterMutation('label');
|
|
120
125
|
},
|
|
121
126
|
onError: (_err, variables, context) => {
|
|
122
127
|
const { labelId } = variables;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { useInfiniteQuery, useMutation } from '@tanstack/react-query';
|
|
2
2
|
import { AvroQueryClient } from '../../client/QueryClient';
|
|
3
|
+
import { keys } from '../../client/realtime';
|
|
3
4
|
AvroQueryClient.prototype.useGetMessages = function (chatId, body) {
|
|
4
5
|
const queryClient = this.getQueryClient();
|
|
5
6
|
const result = useInfiniteQuery({
|
|
6
|
-
queryKey:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
body.
|
|
10
|
-
body.
|
|
11
|
-
|
|
12
|
-
body.query ?? '',
|
|
13
|
-
],
|
|
7
|
+
queryKey: keys.infinite('messages', chatId, {
|
|
8
|
+
amt: body.amt ?? 50,
|
|
9
|
+
known_ids: body.known_ids ?? [],
|
|
10
|
+
unknown_ids: body.unknown_ids ?? [],
|
|
11
|
+
query: body.query ?? '',
|
|
12
|
+
}),
|
|
14
13
|
initialPageParam: 0,
|
|
15
14
|
getNextPageParam: (lastPage, allPages) => {
|
|
16
15
|
if (lastPage.length < (body.amt ?? 50))
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { useInfiniteQuery, useMutation } from '@tanstack/react-query';
|
|
2
2
|
import { AvroQueryClient } from '../../client/QueryClient';
|
|
3
|
+
import { keys } from '../../client/realtime';
|
|
3
4
|
import { LineItemStatus } from '../../types/api';
|
|
4
5
|
AvroQueryClient.prototype.useGetMonths = function (body) {
|
|
5
6
|
const queryClient = this.getQueryClient();
|
|
6
7
|
const result = useInfiniteQuery({
|
|
7
|
-
queryKey:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
body.
|
|
11
|
-
body.
|
|
12
|
-
body.
|
|
13
|
-
body.
|
|
14
|
-
body.
|
|
15
|
-
body.
|
|
16
|
-
body.
|
|
17
|
-
body.
|
|
18
|
-
|
|
19
|
-
body.sort_by ?? null,
|
|
20
|
-
body.direction ?? null,
|
|
21
|
-
],
|
|
8
|
+
queryKey: keys.infinite('months', this.companyId, {
|
|
9
|
+
amt: body.amt ?? 50,
|
|
10
|
+
known_ids: body.known_ids ?? [],
|
|
11
|
+
unknown_ids: body.unknown_ids ?? [],
|
|
12
|
+
query: body.query ?? '',
|
|
13
|
+
unbilled: body.unbilled ?? true,
|
|
14
|
+
billed: body.billed ?? true,
|
|
15
|
+
paid: body.paid ?? true,
|
|
16
|
+
jobId: body.jobId ?? '',
|
|
17
|
+
sort_by: body.sort_by ?? null,
|
|
18
|
+
direction: body.direction ?? null,
|
|
19
|
+
}),
|
|
22
20
|
initialPageParam: 0,
|
|
23
21
|
getNextPageParam: (lastPage, allPages) => {
|
|
24
22
|
if (lastPage.length < (body.amt ?? 50))
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import { useInfiniteQuery } from '@tanstack/react-query';
|
|
2
2
|
import { AvroQueryClient } from '../../client/QueryClient';
|
|
3
|
+
import { keys } from '../../client/realtime';
|
|
3
4
|
AvroQueryClient.prototype.useGetPayouts = function (body) {
|
|
4
5
|
const queryClient = this.getQueryClient();
|
|
5
6
|
const result = useInfiniteQuery({
|
|
6
|
-
queryKey:
|
|
7
|
-
'
|
|
8
|
-
|
|
9
|
-
body.
|
|
10
|
-
body.
|
|
11
|
-
body.
|
|
12
|
-
body.
|
|
13
|
-
body.
|
|
14
|
-
body.
|
|
15
|
-
body.
|
|
16
|
-
body.
|
|
17
|
-
|
|
18
|
-
body.amount_max ?? null,
|
|
19
|
-
],
|
|
7
|
+
queryKey: keys.infinite('payouts', this.companyId, {
|
|
8
|
+
query: body.query ?? '',
|
|
9
|
+
status: body.status ?? '',
|
|
10
|
+
known_ids: body.known_ids ?? [],
|
|
11
|
+
unknown_ids: body.unknown_ids ?? [],
|
|
12
|
+
created_from: body.created_from ?? null,
|
|
13
|
+
created_to: body.created_to ?? null,
|
|
14
|
+
arrival_from: body.arrival_from ?? null,
|
|
15
|
+
arrival_to: body.arrival_to ?? null,
|
|
16
|
+
amount_min: body.amount_min ?? null,
|
|
17
|
+
amount_max: body.amount_max ?? null,
|
|
18
|
+
}),
|
|
20
19
|
initialPageParam: 0,
|
|
21
20
|
getNextPageParam: (lastPage, allPages) => {
|
|
22
21
|
if (lastPage.length < (body.amt ?? 50))
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { useInfiniteQuery, useMutation } from '@tanstack/react-query';
|
|
2
2
|
import { AvroQueryClient } from '../../client/QueryClient';
|
|
3
|
+
import { keys } from '../../client/realtime';
|
|
3
4
|
import { LineItemStatus } from '../../types/api';
|
|
4
5
|
AvroQueryClient.prototype.useGetPrepayments = function (body) {
|
|
5
6
|
const queryClient = this.getQueryClient();
|
|
6
7
|
const result = useInfiniteQuery({
|
|
7
|
-
queryKey:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
body.
|
|
11
|
-
body.
|
|
12
|
-
body.
|
|
13
|
-
body.
|
|
14
|
-
body.
|
|
15
|
-
body.
|
|
16
|
-
body.
|
|
17
|
-
body.
|
|
18
|
-
|
|
19
|
-
body.sort_by ?? null,
|
|
20
|
-
body.direction ?? null,
|
|
21
|
-
],
|
|
8
|
+
queryKey: keys.infinite('prepayments', this.companyId, {
|
|
9
|
+
amt: body.amt ?? 50,
|
|
10
|
+
known_ids: body.known_ids ?? [],
|
|
11
|
+
unknown_ids: body.unknown_ids ?? [],
|
|
12
|
+
query: body.query ?? '',
|
|
13
|
+
unbilled: body.unbilled ?? true,
|
|
14
|
+
billed: body.billed ?? true,
|
|
15
|
+
paid: body.paid ?? true,
|
|
16
|
+
taskId: body.taskId ?? '',
|
|
17
|
+
sort_by: body.sort_by ?? null,
|
|
18
|
+
direction: body.direction ?? null,
|
|
19
|
+
}),
|
|
22
20
|
initialPageParam: 0,
|
|
23
21
|
getNextPageParam: (lastPage, allPages) => {
|
|
24
22
|
if (lastPage.length < (body.amt ?? 50))
|
|
@@ -11,13 +11,8 @@ AvroQueryClient.prototype.useCreateProposal = function () {
|
|
|
11
11
|
headers: { 'Content-Type': 'application/json' },
|
|
12
12
|
});
|
|
13
13
|
},
|
|
14
|
-
onSuccess:
|
|
15
|
-
|
|
16
|
-
action: 'create',
|
|
17
|
-
entityKey: 'proposals',
|
|
18
|
-
id: result.id,
|
|
19
|
-
fetchPath: `/proposal/${result.id}`,
|
|
20
|
-
});
|
|
14
|
+
onSuccess: () => {
|
|
15
|
+
this.syncAfterMutation('proposal');
|
|
21
16
|
},
|
|
22
17
|
});
|
|
23
18
|
};
|
|
@@ -32,8 +27,7 @@ AvroQueryClient.prototype.useReviewProposal = function (proposal_id) {
|
|
|
32
27
|
});
|
|
33
28
|
},
|
|
34
29
|
onSuccess: () => {
|
|
35
|
-
|
|
36
|
-
queryClient.invalidateQueries({ queryKey: ['jobs'] });
|
|
30
|
+
this.syncAfterMutation('proposal', 'job');
|
|
37
31
|
},
|
|
38
32
|
});
|
|
39
33
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useMutation, useQuery } from '@tanstack/react-query';
|
|
2
2
|
import { AvroQueryClient } from '../../client/QueryClient';
|
|
3
|
+
import { keys } from '../../client/realtime';
|
|
3
4
|
import { Route } from '../../types/api';
|
|
4
5
|
const dedupeJobTasks = (payload) => payload.jobs
|
|
5
6
|
? {
|
|
@@ -14,7 +15,11 @@ const dedupeJobTasks = (payload) => payload.jobs
|
|
|
14
15
|
: payload;
|
|
15
16
|
AvroQueryClient.prototype.useGetRoutes = function (body, total, onProgress) {
|
|
16
17
|
return useQuery({
|
|
17
|
-
queryKey:
|
|
18
|
+
queryKey: keys.list('routes', this.companyId, {
|
|
19
|
+
amt: body.amt ?? 50,
|
|
20
|
+
query: body.query ?? '',
|
|
21
|
+
total: total ?? 'all',
|
|
22
|
+
}),
|
|
18
23
|
queryFn: async () => {
|
|
19
24
|
if (typeof total !== 'number') {
|
|
20
25
|
const routes = await this.fetchRoutes({ ...body, offset: 0 });
|
|
@@ -87,17 +92,8 @@ AvroQueryClient.prototype.useCreateRoute = function () {
|
|
|
87
92
|
});
|
|
88
93
|
return { previousRoutes };
|
|
89
94
|
},
|
|
90
|
-
onSuccess:
|
|
91
|
-
|
|
92
|
-
action: 'create',
|
|
93
|
-
entityKey: 'routes',
|
|
94
|
-
id: result.id,
|
|
95
|
-
fetchPath: `/route/${result.id}`,
|
|
96
|
-
construct: (d) => new Route(d),
|
|
97
|
-
});
|
|
98
|
-
// task.route_ids lives in the jobs caches
|
|
99
|
-
queryClient.invalidateQueries({ queryKey: ['jobs'] });
|
|
100
|
-
queryClient.invalidateQueries({ queryKey: ['infinite', 'jobs'] });
|
|
95
|
+
onSuccess: () => {
|
|
96
|
+
this.syncAfterMutation('route', 'job');
|
|
101
97
|
},
|
|
102
98
|
onError: (_err, _variables, context) => {
|
|
103
99
|
if (context?.previousRoutes) {
|
|
@@ -135,10 +131,7 @@ AvroQueryClient.prototype.useScheduleRoutes = function () {
|
|
|
135
131
|
});
|
|
136
132
|
},
|
|
137
133
|
onSuccess: () => {
|
|
138
|
-
|
|
139
|
-
queryClient.invalidateQueries({ queryKey: ['jobs'] });
|
|
140
|
-
queryClient.invalidateQueries({ queryKey: ['infinite', 'jobs'] });
|
|
141
|
-
queryClient.invalidateQueries({ queryKey: ['companies'] });
|
|
134
|
+
this.syncAfterMutation('route', 'job', 'company');
|
|
142
135
|
},
|
|
143
136
|
});
|
|
144
137
|
};
|
|
@@ -174,17 +167,8 @@ AvroQueryClient.prototype.useUpdateRoute = function () {
|
|
|
174
167
|
});
|
|
175
168
|
return { previousRoute, previousRoutes };
|
|
176
169
|
},
|
|
177
|
-
onSuccess:
|
|
178
|
-
|
|
179
|
-
action: 'update',
|
|
180
|
-
entityKey: 'routes',
|
|
181
|
-
id: routeId,
|
|
182
|
-
fetchPath: `/route/${routeId}`,
|
|
183
|
-
construct: (d) => new Route(d),
|
|
184
|
-
});
|
|
185
|
-
// task.route_ids lives in the jobs caches
|
|
186
|
-
queryClient.invalidateQueries({ queryKey: ['jobs'] });
|
|
187
|
-
queryClient.invalidateQueries({ queryKey: ['infinite', 'jobs'] });
|
|
170
|
+
onSuccess: () => {
|
|
171
|
+
this.syncAfterMutation('route', 'job');
|
|
188
172
|
},
|
|
189
173
|
onError: (_err, variables, context) => {
|
|
190
174
|
const { routeId } = variables;
|
|
@@ -223,17 +207,8 @@ AvroQueryClient.prototype.useDeleteRoute = function () {
|
|
|
223
207
|
});
|
|
224
208
|
return { previousRoutes, previousRoute };
|
|
225
209
|
},
|
|
226
|
-
onSuccess:
|
|
227
|
-
|
|
228
|
-
action: 'delete',
|
|
229
|
-
entityKey: 'routes',
|
|
230
|
-
id: routeId,
|
|
231
|
-
});
|
|
232
|
-
// task.route_ids lives in the jobs caches — without this,
|
|
233
|
-
// freed tasks still look routed and get excluded from the
|
|
234
|
-
// next scheduling attempt.
|
|
235
|
-
queryClient.invalidateQueries({ queryKey: ['jobs'] });
|
|
236
|
-
queryClient.invalidateQueries({ queryKey: ['infinite', 'jobs'] });
|
|
210
|
+
onSuccess: () => {
|
|
211
|
+
this.syncAfterMutation('route', 'job');
|
|
237
212
|
},
|
|
238
213
|
onError: (_err, variables, context) => {
|
|
239
214
|
const { routeId } = variables;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useMutation, useQuery } from '@tanstack/react-query';
|
|
2
2
|
import { AvroQueryClient } from '../../client/QueryClient';
|
|
3
|
+
import { keys } from '../../client/realtime';
|
|
3
4
|
AvroQueryClient.prototype.useCreateSkill = function () {
|
|
4
5
|
const queryClient = this.getQueryClient();
|
|
5
6
|
return useMutation({
|
|
@@ -11,13 +12,17 @@ AvroQueryClient.prototype.useCreateSkill = function () {
|
|
|
11
12
|
});
|
|
12
13
|
},
|
|
13
14
|
onSuccess: () => {
|
|
14
|
-
|
|
15
|
+
this.syncAfterMutation('skill');
|
|
15
16
|
},
|
|
16
17
|
});
|
|
17
18
|
};
|
|
18
19
|
AvroQueryClient.prototype.useGetSkills = function (body, total, onProgress) {
|
|
19
20
|
return useQuery({
|
|
20
|
-
queryKey:
|
|
21
|
+
queryKey: keys.list('skills', this.companyId, {
|
|
22
|
+
amt: body.amt ?? 50,
|
|
23
|
+
query: body.query ?? '',
|
|
24
|
+
total: total ?? 'all',
|
|
25
|
+
}),
|
|
21
26
|
queryFn: async () => {
|
|
22
27
|
if (typeof total !== 'number') {
|
|
23
28
|
return this.fetchSkills({ ...body, offset: 0 });
|
|
@@ -76,7 +81,7 @@ AvroQueryClient.prototype.useUpdateSkill = function () {
|
|
|
76
81
|
return { previousSkills, previousSkill };
|
|
77
82
|
},
|
|
78
83
|
onSuccess: () => {
|
|
79
|
-
|
|
84
|
+
this.syncAfterMutation('skill');
|
|
80
85
|
},
|
|
81
86
|
onError: (_err, variables, context) => {
|
|
82
87
|
const { skillId } = variables;
|
|
@@ -113,7 +118,7 @@ AvroQueryClient.prototype.useDeleteSkill = function () {
|
|
|
113
118
|
return { previousSkills };
|
|
114
119
|
},
|
|
115
120
|
onSuccess: () => {
|
|
116
|
-
|
|
121
|
+
this.syncAfterMutation('skill');
|
|
117
122
|
},
|
|
118
123
|
onError: (_err, variables, context) => {
|
|
119
124
|
if (context?.previousSkills) {
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { useMutation, useQuery } from '@tanstack/react-query';
|
|
2
2
|
import { AvroQueryClient } from '../../client/QueryClient';
|
|
3
|
+
import { keys } from '../../client/realtime';
|
|
3
4
|
AvroQueryClient.prototype.useGetTeams = function (body, total, onProgress) {
|
|
4
5
|
return useQuery({
|
|
5
|
-
queryKey:
|
|
6
|
+
queryKey: keys.list('teams', this.companyId, {
|
|
7
|
+
amt: body.amt ?? 50,
|
|
8
|
+
query: body.query ?? '',
|
|
9
|
+
total: total ?? 'all',
|
|
10
|
+
}),
|
|
6
11
|
queryFn: async () => {
|
|
7
12
|
if (typeof total !== 'number') {
|
|
8
13
|
return this.fetchTeams({ ...body, offset: 0 });
|
|
@@ -37,7 +42,7 @@ AvroQueryClient.prototype.useCreateTeam = function () {
|
|
|
37
42
|
});
|
|
38
43
|
},
|
|
39
44
|
onSuccess: () => {
|
|
40
|
-
|
|
45
|
+
this.syncAfterMutation('team');
|
|
41
46
|
},
|
|
42
47
|
});
|
|
43
48
|
};
|
|
@@ -76,7 +81,7 @@ AvroQueryClient.prototype.useUpdateTeam = function () {
|
|
|
76
81
|
return { previousTeams, previousTeam };
|
|
77
82
|
},
|
|
78
83
|
onSuccess: () => {
|
|
79
|
-
|
|
84
|
+
this.syncAfterMutation('team');
|
|
80
85
|
},
|
|
81
86
|
onError: (_err, variables, context) => {
|
|
82
87
|
const { teamId } = variables;
|
|
@@ -116,7 +121,7 @@ AvroQueryClient.prototype.useDeleteTeam = function () {
|
|
|
116
121
|
return { previousRoutes, previousRoute };
|
|
117
122
|
},
|
|
118
123
|
onSuccess: () => {
|
|
119
|
-
|
|
124
|
+
this.syncAfterMutation('team');
|
|
120
125
|
},
|
|
121
126
|
onError: (_err, variables, context) => {
|
|
122
127
|
const { teamId } = variables;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useMutation, useQuery } from '@tanstack/react-query';
|
|
2
2
|
import { AvroQueryClient } from '../../client/QueryClient';
|
|
3
|
+
import { keys } from '../../client/realtime';
|
|
3
4
|
AvroQueryClient.prototype.useCreateWaiver = function () {
|
|
4
5
|
const queryClient = this.getQueryClient();
|
|
5
6
|
return useMutation({
|
|
@@ -11,22 +12,20 @@ AvroQueryClient.prototype.useCreateWaiver = function () {
|
|
|
11
12
|
});
|
|
12
13
|
},
|
|
13
14
|
onSuccess: () => {
|
|
14
|
-
|
|
15
|
+
this.syncAfterMutation('waiver');
|
|
15
16
|
},
|
|
16
17
|
});
|
|
17
18
|
};
|
|
18
19
|
AvroQueryClient.prototype.useGetWaivers = function (body, total, onProgress) {
|
|
19
20
|
return useQuery({
|
|
20
|
-
queryKey:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
body.
|
|
24
|
-
body.
|
|
25
|
-
body.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
total ?? 'all',
|
|
29
|
-
],
|
|
21
|
+
queryKey: keys.list('waivers', this.companyId, {
|
|
22
|
+
amt: body.amt ?? 50,
|
|
23
|
+
known_ids: body.known_ids ?? [],
|
|
24
|
+
unknown_ids: body.unknown_ids ?? [],
|
|
25
|
+
offset: body.offset ?? 0,
|
|
26
|
+
query: body.query ?? '',
|
|
27
|
+
total: total ?? 'all',
|
|
28
|
+
}),
|
|
30
29
|
queryFn: async () => {
|
|
31
30
|
if (typeof total !== 'number') {
|
|
32
31
|
return this.fetchWaivers({ ...body, offset: 0 });
|
|
@@ -87,7 +86,7 @@ AvroQueryClient.prototype.useUpdateWaiver = function () {
|
|
|
87
86
|
return { previousWaivers, previousWaiver };
|
|
88
87
|
},
|
|
89
88
|
onSuccess: () => {
|
|
90
|
-
|
|
89
|
+
this.syncAfterMutation('waiver');
|
|
91
90
|
},
|
|
92
91
|
onError: (_err, variables, context) => {
|
|
93
92
|
const { waiverId } = variables;
|
|
@@ -126,7 +125,7 @@ AvroQueryClient.prototype.useDeleteWaiver = function () {
|
|
|
126
125
|
return { previousWaivers };
|
|
127
126
|
},
|
|
128
127
|
onSuccess: () => {
|
|
129
|
-
|
|
128
|
+
this.syncAfterMutation('waiver');
|
|
130
129
|
},
|
|
131
130
|
onError: (_err, variables, context) => {
|
|
132
131
|
if (context?.previousWaivers) {
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Realtime cache sync. Applies backend `changes` batches (id-only) to
|
|
3
|
+
* the TanStack cache: id entries coalesce into one bulk fetch per type,
|
|
4
|
+
* `delete` removes, `invalidate` refetches. Query keys: `[ns, id]`
|
|
5
|
+
* detail, `keys.list/keys.infinite(ns, scope, filters)` for lists.
|
|
6
|
+
*/
|
|
7
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
8
|
+
import type { AvroQueryClient } from '../client/QueryClient';
|
|
9
|
+
import { Job } from '../types/api';
|
|
10
|
+
export type Filters = Record<string, unknown>;
|
|
11
|
+
export declare const keys: {
|
|
12
|
+
detail: (ns: string, id: string) => readonly [string, string];
|
|
13
|
+
list: (ns: string, scope: string | undefined, filters?: Filters) => readonly [string, "list", string, Filters];
|
|
14
|
+
infinite: (ns: string, scope: string | undefined, filters?: Filters) => readonly [string, "infinite", string, Filters];
|
|
15
|
+
};
|
|
16
|
+
export declare function isListKey(key: readonly unknown[]): boolean;
|
|
17
|
+
export declare function isDetailKey(key: readonly unknown[]): boolean;
|
|
18
|
+
export declare function listFilters(key: readonly unknown[]): Filters;
|
|
19
|
+
export declare function listScope(key: readonly unknown[]): string;
|
|
20
|
+
export type ChangeOp = 'create' | 'update' | 'delete' | 'invalidate';
|
|
21
|
+
export interface ChangeEntry {
|
|
22
|
+
type: string;
|
|
23
|
+
op: ChangeOp;
|
|
24
|
+
id?: string;
|
|
25
|
+
data?: any;
|
|
26
|
+
}
|
|
27
|
+
export interface ChangesPayload {
|
|
28
|
+
version: number | null;
|
|
29
|
+
company: string | null;
|
|
30
|
+
origin: string | null;
|
|
31
|
+
changes: ChangeEntry[];
|
|
32
|
+
}
|
|
33
|
+
export type ListMatch = 'match' | 'nomatch' | 'unknown';
|
|
34
|
+
export interface EntitySpec {
|
|
35
|
+
ns: string;
|
|
36
|
+
construct?: (raw: any) => any;
|
|
37
|
+
fetchMany?: (client: AvroQueryClient, ids: string[]) => Promise<any[]>;
|
|
38
|
+
fetchOne?: (client: AvroQueryClient, id: string) => Promise<any>;
|
|
39
|
+
listMatch?: (filters: Filters, item: any, scope: string) => ListMatch;
|
|
40
|
+
alsoInvalidate?: readonly (readonly unknown[])[];
|
|
41
|
+
invalidateOnly?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export declare function constructJob(raw: any): Job;
|
|
44
|
+
export declare const REGISTRY: Record<string, EntitySpec>;
|
|
45
|
+
export declare function removeEntity(qc: QueryClient, ns: string, id: string): void;
|
|
46
|
+
export declare function upsertEntity(qc: QueryClient, spec: EntitySpec, item: any): void;
|
|
47
|
+
export declare function matchesList(type: string, key: readonly unknown[], item: any): ListMatch;
|
|
48
|
+
export declare function invalidateType(qc: QueryClient, spec: EntitySpec): void;
|
|
49
|
+
export declare class ChangeApplier {
|
|
50
|
+
private client;
|
|
51
|
+
private qc;
|
|
52
|
+
private pending;
|
|
53
|
+
private timer;
|
|
54
|
+
constructor(client: AvroQueryClient, qc: QueryClient);
|
|
55
|
+
apply(payload: ChangesPayload): void;
|
|
56
|
+
private enqueue;
|
|
57
|
+
flush(): Promise<void>;
|
|
58
|
+
private fetchAndApply;
|
|
59
|
+
dispose(): void;
|
|
60
|
+
}
|
|
61
|
+
/** Namespaces a mutation should refetch when no socket can deliver the change. */
|
|
62
|
+
export declare function fallbackInvalidate(qc: QueryClient, types: string[]): void;
|
|
63
|
+
export declare function patchMemberLocation(qc: QueryClient, data: Record<string, any>): void;
|
|
64
|
+
export declare function patchTeamLocation(qc: QueryClient, data: Record<string, any>): void;
|