@go-avro/avro-js 0.0.119 → 0.1.0

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.
@@ -1,26 +1,25 @@
1
1
  import { useInfiniteQuery, useQuery, useMutation } from '@tanstack/react-query';
2
2
  import { AvroQueryClient } from '../../client/QueryClient';
3
+ import { keys } from '../../client/realtime';
3
4
  import { Bill } from '../../types/api';
4
5
  AvroQueryClient.prototype.useGetBills = function (body) {
5
6
  const queryClient = this.getQueryClient();
6
7
  const result = useInfiniteQuery({
7
- queryKey: [
8
- 'bills',
9
- this.companyId,
10
- body.query ?? '',
11
- body.known_ids ?? [],
12
- body.unknown_ids ?? [],
13
- body.paid ?? false,
14
- body.created_from ?? null,
15
- body.created_to ?? null,
16
- body.paid_from ?? null,
17
- body.paid_to ?? null,
18
- body.amount_min ?? null,
19
- body.amount_max ?? null,
20
- body.labels ?? [],
21
- body.sort_by ?? null,
22
- body.direction ?? null,
23
- ],
8
+ queryKey: keys.infinite('bills', this.companyId, {
9
+ query: body.query ?? '',
10
+ known_ids: body.known_ids ?? [],
11
+ unknown_ids: body.unknown_ids ?? [],
12
+ paid: body.paid ?? false,
13
+ created_from: body.created_from ?? null,
14
+ created_to: body.created_to ?? null,
15
+ paid_from: body.paid_from ?? null,
16
+ paid_to: body.paid_to ?? null,
17
+ amount_min: body.amount_min ?? null,
18
+ amount_max: body.amount_max ?? null,
19
+ labels: body.labels ?? [],
20
+ sort_by: body.sort_by ?? null,
21
+ direction: body.direction ?? null,
22
+ }),
24
23
  initialPageParam: 0,
25
24
  getNextPageParam: (lastPage, allPages) => {
26
25
  if (lastPage.length < (body.amt ?? 50))
@@ -76,14 +75,8 @@ AvroQueryClient.prototype.useCreateBill = function () {
76
75
  // TODO: Create a fake bill object for optimistic update and update events and months accordingly
77
76
  return { previousBills };
78
77
  },
79
- onSuccess: async (result) => {
80
- await this._syncEntity(queryClient, {
81
- action: 'create',
82
- entityKey: 'bills',
83
- id: result.id,
84
- fetchPath: `/bill/${result.id}`,
85
- construct: (d) => new Bill(d),
86
- });
78
+ onSuccess: () => {
79
+ this.syncAfterMutation('bill');
87
80
  },
88
81
  onError: (_err, _variables, context) => {
89
82
  if (context?.previousBills) {
@@ -126,14 +119,8 @@ AvroQueryClient.prototype.useUpdateBill = function () {
126
119
  });
127
120
  return { previousBills, previousBill };
128
121
  },
129
- onSuccess: async (_result, { billId }) => {
130
- await this._syncEntity(queryClient, {
131
- action: 'update',
132
- entityKey: 'bills',
133
- id: billId,
134
- fetchPath: `/bill/${billId}`,
135
- construct: (d) => new Bill(d),
136
- });
122
+ onSuccess: () => {
123
+ this.syncAfterMutation('bill');
137
124
  },
138
125
  onError: (err, variables, context) => {
139
126
  const { billId } = variables;
@@ -158,19 +145,8 @@ AvroQueryClient.prototype.useUpdateBillLineItemStatus = function () {
158
145
  },
159
146
  });
160
147
  },
161
- onSuccess: async (_result, { billId }) => {
162
- await this._syncEntity(queryClient, {
163
- action: 'update',
164
- entityKey: 'bills',
165
- id: billId,
166
- fetchPath: `/bill/${billId}`,
167
- construct: (d) => new Bill(d),
168
- });
169
- // Item paid state also lives on the underlying events,
170
- // service months and prepayments
171
- await queryClient.invalidateQueries({ queryKey: ['events'] });
172
- await queryClient.invalidateQueries({ queryKey: ['months'] });
173
- await queryClient.invalidateQueries({ queryKey: ['prepayments'] });
148
+ onSuccess: () => {
149
+ this.syncAfterMutation('bill', 'event', 'month', 'prepayment');
174
150
  },
175
151
  });
176
152
  };
@@ -186,12 +162,8 @@ AvroQueryClient.prototype.useDeleteBill = function () {
186
162
  // TODO: Create a fake bill object for optimistic update and update events and months accordingly
187
163
  return { previousBills };
188
164
  },
189
- onSuccess: async (_result, { billId }) => {
190
- await this._syncEntity(queryClient, {
191
- action: 'delete',
192
- entityKey: 'bills',
193
- id: billId,
194
- });
165
+ onSuccess: () => {
166
+ this.syncAfterMutation('bill');
195
167
  },
196
168
  onError: (_err, _variables, context) => {
197
169
  if (context?.previousBills) {
@@ -209,7 +181,7 @@ AvroQueryClient.prototype.useCancelBillPayment = function () {
209
181
  });
210
182
  },
211
183
  onSuccess: () => {
212
- queryClient.invalidateQueries({ queryKey: ['bills'] });
184
+ this.syncAfterMutation('bill');
213
185
  },
214
186
  });
215
187
  };
@@ -227,7 +199,7 @@ AvroQueryClient.prototype.useSyncBillToIntuit = function () {
227
199
  return { previousBill };
228
200
  },
229
201
  onSuccess: () => {
230
- queryClient.invalidateQueries({ queryKey: ['bills'] });
202
+ this.syncAfterMutation('bill');
231
203
  },
232
204
  onError: (_err, variables, context) => {
233
205
  const { billId } = variables;
@@ -246,7 +218,7 @@ AvroQueryClient.prototype.useImportBillsFromIntuit = function () {
246
218
  });
247
219
  },
248
220
  onSuccess: () => {
249
- queryClient.invalidateQueries({ queryKey: ['bills'] });
221
+ this.syncAfterMutation('bill');
250
222
  },
251
223
  });
252
224
  };
@@ -269,23 +241,8 @@ AvroQueryClient.prototype.useBulkDeleteBills = function () {
269
241
  },
270
242
  });
271
243
  },
272
- onSuccess: async (result, { billIds }) => {
273
- // Sync each deleted bill out of cache. Any bills the server
274
- // refused to delete (returned in `errors`) stay in cache.
275
- const failedIds = new Set(result.errors.map((e) => e.bill_id));
276
- const deletedIds = billIds.filter((id) => !failedIds.has(id));
277
- for (const id of deletedIds) {
278
- await this._syncEntity(queryClient, {
279
- action: 'delete',
280
- entityKey: 'bills',
281
- id,
282
- });
283
- }
284
- // Backend also emits update_events / update_months — but be
285
- // defensive in case the socket round-trip is slow.
286
- queryClient.invalidateQueries({ queryKey: ['events'] });
287
- queryClient.invalidateQueries({ queryKey: ['months'] });
288
- queryClient.invalidateQueries({ queryKey: ['prepayments'] });
244
+ onSuccess: () => {
245
+ this.syncAfterMutation('bill', 'event', 'month', 'prepayment');
289
246
  },
290
247
  });
291
248
  };
@@ -19,13 +19,8 @@ AvroQueryClient.prototype.useCreateCatalogItem = function () {
19
19
  const previousItems = queryClient.getQueryData(['catalog_items', this.companyId]);
20
20
  return { previousItems };
21
21
  },
22
- onSuccess: async (result) => {
23
- await this._syncEntity(queryClient, {
24
- action: 'create',
25
- entityKey: 'catalog_items',
26
- id: result.id,
27
- fetchPath: `/catalog_item/${result.id}`,
28
- });
22
+ onSuccess: () => {
23
+ this.syncAfterMutation('catalog_item');
29
24
  },
30
25
  onError: (_err, _variables, context) => {
31
26
  if (context?.previousItems) {
@@ -70,13 +65,8 @@ AvroQueryClient.prototype.useUpdateCatalogItem = function () {
70
65
  });
71
66
  return { previousItems, previousItem };
72
67
  },
73
- onSuccess: async (_result, { catalogItemId }) => {
74
- await this._syncEntity(queryClient, {
75
- action: 'update',
76
- entityKey: 'catalog_items',
77
- id: catalogItemId,
78
- fetchPath: `/catalog_item/${catalogItemId}`,
79
- });
68
+ onSuccess: () => {
69
+ this.syncAfterMutation('catalog_item');
80
70
  },
81
71
  onError: (err, variables, context) => {
82
72
  const { catalogItemId } = variables;
@@ -109,12 +99,8 @@ AvroQueryClient.prototype.useDeleteCatalogItem = function () {
109
99
  const previousItems = queryClient.getQueryData(['catalog_items']);
110
100
  return { previousItems };
111
101
  },
112
- onSuccess: async (_result, { catalogItemId }) => {
113
- await this._syncEntity(queryClient, {
114
- action: 'delete',
115
- entityKey: 'catalog_items',
116
- id: catalogItemId,
117
- });
102
+ onSuccess: () => {
103
+ this.syncAfterMutation('catalog_item');
118
104
  },
119
105
  onError: (_err, _variables, context) => {
120
106
  if (context?.previousItems) {
@@ -1,16 +1,15 @@
1
1
  import { useInfiniteQuery, useQuery } from '@tanstack/react-query';
2
2
  import { AvroQueryClient } from '../../client/QueryClient';
3
+ import { keys } from '../../client/realtime';
3
4
  AvroQueryClient.prototype.useGetChats = function (body) {
4
5
  const queryClient = this.getQueryClient();
5
6
  const result = useInfiniteQuery({
6
- queryKey: [
7
- 'chats',
8
- this.companyId,
9
- body.amt ?? 50,
10
- body.known_ids ?? [],
11
- body.unknown_ids ?? [],
12
- body.query ?? '',
13
- ],
7
+ queryKey: keys.infinite('chats', this.companyId, {
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,6 +1,5 @@
1
1
  import { useMutation, useQuery } from '@tanstack/react-query';
2
2
  import { AvroQueryClient } from '../../client/QueryClient';
3
- import { Job } from '../../types/api/Job';
4
3
  /**
5
4
  * Refresh the caches a check-in mutation touches. Socket events cover
6
5
  * connected clients, but the raw helpers run headless (background
@@ -10,21 +9,10 @@ const syncCheckinCaches = async (client, jobId) => {
10
9
  const queryClient = client.peekQueryClient();
11
10
  if (!queryClient)
12
11
  return;
12
+ // Headless path (background location task) has no live socket.
13
13
  queryClient.invalidateQueries({ queryKey: ['checkins'] });
14
- if (!jobId)
15
- return;
16
- try {
17
- await client._syncEntity(queryClient, {
18
- action: 'update',
19
- entityKey: 'jobs',
20
- id: jobId,
21
- fetchPath: `/job/${jobId}`,
22
- construct: (d) => new Job(d),
23
- });
24
- }
25
- catch {
26
- // Cache sync is best-effort; the mutation itself succeeded
27
- }
14
+ if (jobId)
15
+ queryClient.invalidateQueries({ queryKey: ['jobs', jobId] });
28
16
  };
29
17
  AvroQueryClient.prototype.useJobCheckins = function (jobId, params) {
30
18
  return useQuery({
@@ -74,13 +74,8 @@ AvroQueryClient.prototype.useCreateCompany = function () {
74
74
  headers: { 'Content-Type': 'application/json' },
75
75
  });
76
76
  },
77
- onSuccess: async (result) => {
78
- await this._syncEntity(queryClient, {
79
- action: 'create',
80
- entityKey: 'companies',
81
- id: result.id,
82
- fetchPath: `/company/${result.id}`,
83
- });
77
+ onSuccess: () => {
78
+ this.syncAfterMutation('company');
84
79
  },
85
80
  });
86
81
  };
@@ -109,13 +104,8 @@ AvroQueryClient.prototype.useUpdateCompany = function () {
109
104
  });
110
105
  return { previousCompany, previousCompanyList };
111
106
  },
112
- onSuccess: async (_result, { companyId }) => {
113
- await this._syncEntity(queryClient, {
114
- action: 'update',
115
- entityKey: 'companies',
116
- id: companyId,
117
- fetchPath: `/company/${companyId}`,
118
- });
107
+ onSuccess: () => {
108
+ this.syncAfterMutation('company');
119
109
  },
120
110
  onError: (_err, variables, context) => {
121
111
  const { companyId } = variables;
@@ -151,8 +141,7 @@ AvroQueryClient.prototype.useCreateUserCompany = function () {
151
141
  return { previousCompany };
152
142
  },
153
143
  onSuccess: () => {
154
- queryClient.invalidateQueries({ queryKey: ['companies'] });
155
- queryClient.invalidateQueries({ queryKey: ['users'] });
144
+ this.syncAfterMutation('member', 'company');
156
145
  },
157
146
  onError: (err, variables, context) => {
158
147
  if (context?.previousCompany) {
@@ -178,8 +167,7 @@ AvroQueryClient.prototype.useRemoveUserCompany = function () {
178
167
  return { previousCompany };
179
168
  },
180
169
  onSuccess: () => {
181
- queryClient.invalidateQueries({ queryKey: ['companies'] });
182
- queryClient.invalidateQueries({ queryKey: ['users'] });
170
+ this.syncAfterMutation('member', 'company');
183
171
  },
184
172
  onError: (err, variables, context) => {
185
173
  if (context?.previousCompany) {
@@ -209,12 +197,8 @@ AvroQueryClient.prototype.useDeleteCompany = function () {
209
197
  });
210
198
  return { previousCompanyList };
211
199
  },
212
- onSuccess: async (_result, { companyId }) => {
213
- await this._syncEntity(queryClient, {
214
- action: 'delete',
215
- entityKey: 'companies',
216
- id: companyId,
217
- });
200
+ onSuccess: () => {
201
+ this.syncAfterMutation('company');
218
202
  },
219
203
  onError: (err, companyId, context) => {
220
204
  if (context?.previousCompanyList) {
@@ -1,29 +1,26 @@
1
1
  import { useInfiniteQuery, useQuery, useMutation } from '@tanstack/react-query';
2
- import { AvroQueryClient, matchesEventsListQuery } from '../../client/QueryClient';
2
+ import { AvroQueryClient } from '../../client/QueryClient';
3
+ import { keys, matchesList } from '../../client/realtime';
3
4
  import { constructEvent, DelayEvent, Job, LineItemStatus, } from '../../types/api';
4
5
  const isJobsQuery = (q) => q.queryKey[0] === 'jobs';
5
6
  const isEventsQuery = (q) => q.queryKey[0] === 'events';
6
- const isEventsQueryFor = (item) => (q) => q.queryKey[0] === 'events' && matchesEventsListQuery(q.queryKey, item) === 'match';
7
+ const isEventsQueryFor = (item) => (q) => q.queryKey[0] === 'events' && matchesList('event', q.queryKey, item) === 'match';
7
8
  AvroQueryClient.prototype.useGetEvents = function (body) {
8
9
  const queryClient = this.getQueryClient();
9
10
  const result = useInfiniteQuery({
10
- queryKey: [
11
- 'events',
12
- this.companyId,
13
- body.amt ?? 50,
14
- body.known_ids ?? [],
15
- body.unknown_ids ?? [],
16
- body.query ?? '',
17
- body.unbilled ?? true,
18
- body.billed ?? true,
19
- body.paid ?? true,
20
- body.jobId ?? '',
21
- body.enabled ?? true,
22
- body.sort_by ?? null,
23
- body.direction ?? null,
24
- // Index 13 — read positionally by matchesEventsListQuery.
25
- body.line_item_types ?? null,
26
- ],
11
+ queryKey: keys.infinite('events', this.companyId, {
12
+ amt: body.amt ?? 50,
13
+ known_ids: body.known_ids ?? [],
14
+ unknown_ids: body.unknown_ids ?? [],
15
+ query: body.query ?? '',
16
+ unbilled: body.unbilled ?? true,
17
+ billed: body.billed ?? true,
18
+ paid: body.paid ?? true,
19
+ jobId: body.jobId ?? '',
20
+ sort_by: body.sort_by ?? null,
21
+ direction: body.direction ?? null,
22
+ line_item_types: body.line_item_types ?? null,
23
+ }),
27
24
  initialPageParam: 0,
28
25
  getNextPageParam: (lastPage, allPages) => {
29
26
  if (lastPage.length < (body.amt ?? 50))
@@ -122,22 +119,8 @@ AvroQueryClient.prototype.useCreateEvent = function () {
122
119
  });
123
120
  return { previousJob };
124
121
  },
125
- onSuccess: async (result, { eventData }) => {
126
- const item = await this._syncEntity(queryClient, {
127
- action: 'create',
128
- entityKey: 'events',
129
- id: result.id,
130
- fetchPath: `/event/${result.id}`,
131
- });
132
- if (eventData.job_id) {
133
- await this._syncEntity(queryClient, {
134
- action: 'update',
135
- entityKey: 'jobs',
136
- id: eventData.job_id,
137
- fetchPath: `/job/${eventData.job_id}`,
138
- construct: (d) => new Job(d),
139
- });
140
- }
122
+ onSuccess: () => {
123
+ this.syncAfterMutation('event', 'job');
141
124
  },
142
125
  onError: (err, variables, context) => {
143
126
  // Restore individual job; invalidate lists to refetch clean state
@@ -220,22 +203,8 @@ AvroQueryClient.prototype.useCreateDelayEvent = function () {
220
203
  });
221
204
  return { previousJob };
222
205
  },
223
- onSuccess: async (result, { delayData }) => {
224
- await this._syncEntity(queryClient, {
225
- action: 'create',
226
- entityKey: 'events',
227
- id: result.id,
228
- fetchPath: `/event/${result.id}`,
229
- construct: (d) => constructEvent(d),
230
- matchesQuery: matchesEventsListQuery,
231
- });
232
- await this._syncEntity(queryClient, {
233
- action: 'update',
234
- entityKey: 'jobs',
235
- id: delayData.job_id,
236
- fetchPath: `/job/${delayData.job_id}`,
237
- construct: (d) => new Job(d),
238
- });
206
+ onSuccess: () => {
207
+ this.syncAfterMutation('event', 'job');
239
208
  },
240
209
  onError: (_err, _variables, context) => {
241
210
  if (context?.previousJob) {
@@ -343,22 +312,8 @@ AvroQueryClient.prototype.useUpdateEvent = function () {
343
312
  });
344
313
  return { previousEvent, previousJob };
345
314
  },
346
- onSuccess: async (_result, { eventId }) => {
347
- const item = await this._syncEntity(queryClient, {
348
- action: 'update',
349
- entityKey: 'events',
350
- id: eventId,
351
- fetchPath: `/event/${eventId}`,
352
- });
353
- if (item?.job_id) {
354
- await this._syncEntity(queryClient, {
355
- action: 'update',
356
- entityKey: 'jobs',
357
- id: item.job_id,
358
- fetchPath: `/job/${item.job_id}`,
359
- construct: (d) => new Job(d),
360
- });
361
- }
315
+ onSuccess: () => {
316
+ this.syncAfterMutation('event', 'job');
362
317
  },
363
318
  onError: (_err, variables, context) => {
364
319
  const { eventId } = variables;
@@ -447,7 +402,7 @@ AvroQueryClient.prototype.useUpdateEvents = function () {
447
402
  return { previousEvents, previousEventObjs };
448
403
  },
449
404
  onSuccess: () => {
450
- queryClient.invalidateQueries({ queryKey: ['events'] });
405
+ this.syncAfterMutation('event');
451
406
  },
452
407
  onError: (err, variables, context) => {
453
408
  if (context?.previousEvents) {
@@ -490,23 +445,8 @@ AvroQueryClient.prototype.useDeleteEvent = function () {
490
445
  });
491
446
  return { previousEvents, previousEvent };
492
447
  },
493
- onSuccess: async (_result, { eventId }, context) => {
494
- await this._syncEntity(queryClient, {
495
- action: 'delete',
496
- entityKey: 'events',
497
- id: eventId,
498
- });
499
- const jobId = context?.previousEvent
500
- ?.job_id;
501
- if (jobId) {
502
- await this._syncEntity(queryClient, {
503
- action: 'update',
504
- entityKey: 'jobs',
505
- id: jobId,
506
- fetchPath: `/job/${jobId}`,
507
- construct: (d) => new Job(d),
508
- });
509
- }
448
+ onSuccess: () => {
449
+ this.syncAfterMutation('event', 'job');
510
450
  },
511
451
  onError: (_err, variables, context) => {
512
452
  const { eventId } = variables;
@@ -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.useGetGroups = function (body, total, onProgress) {
4
5
  return useQuery({
5
- queryKey: ['groups', this.companyId, body.amt ?? 50, body.query ?? '', total ?? 'all'],
6
+ queryKey: keys.list('groups', 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.fetchGroups({ ...body, offset: 0 });
@@ -37,7 +42,7 @@ AvroQueryClient.prototype.useCreateGroup = function () {
37
42
  });
38
43
  },
39
44
  onSuccess: () => {
40
- queryClient.invalidateQueries({ queryKey: ['groups'] });
45
+ this.syncAfterMutation('group');
41
46
  },
42
47
  });
43
48
  };
@@ -76,7 +81,7 @@ AvroQueryClient.prototype.useUpdateGroup = function () {
76
81
  return { previousGroups, previousGroup };
77
82
  },
78
83
  onSuccess: () => {
79
- queryClient.invalidateQueries({ queryKey: ['groups'] });
84
+ this.syncAfterMutation('group');
80
85
  },
81
86
  onError: (_err, variables, context) => {
82
87
  const { groupId } = variables;
@@ -118,7 +123,7 @@ AvroQueryClient.prototype.useDeleteGroup = function () {
118
123
  return { previousGroups, previousGroup };
119
124
  },
120
125
  onSuccess: () => {
121
- queryClient.invalidateQueries({ queryKey: ['groups'] });
126
+ this.syncAfterMutation('group');
122
127
  },
123
128
  onError: (_err, variables, context) => {
124
129
  const { groupId } = variables;
@@ -1,5 +1,6 @@
1
1
  import { useMutation, useQuery, useInfiniteQuery } from '@tanstack/react-query';
2
2
  import { AvroQueryClient } from '../../client/QueryClient';
3
+ import { keys } from '../../client/realtime';
3
4
  import { Job } from '../../types/api';
4
5
  AvroQueryClient.prototype.getJobsFromCache = function (queryClient) {
5
6
  const client = queryClient ?? this.peekQueryClient();
@@ -14,7 +15,7 @@ AvroQueryClient.prototype.useGetJobs = function (params) {
14
15
  const company_id = params?.companyId ?? this.companyId;
15
16
  const num_jobs = params?.numJobs ?? this.company?.num_jobs ?? 0;
16
17
  return useQuery({
17
- queryKey: ['jobs', company_id, num_jobs],
18
+ queryKey: keys.list('jobs', company_id, { numJobs: num_jobs }),
18
19
  queryFn: async () => {
19
20
  params?.onProgress?.(0);
20
21
  const pageCount = amt ? Math.ceil((num_jobs ?? 0) / amt) + 1 : 1;
@@ -51,14 +52,11 @@ AvroQueryClient.prototype.useGetJobs = function (params) {
51
52
  AvroQueryClient.prototype.useGetInfiniteJobs = function (body, onProgress) {
52
53
  const queryClient = this.getQueryClient();
53
54
  const result = useInfiniteQuery({
54
- queryKey: [
55
- 'infinite',
56
- 'jobs',
57
- this.companyId,
58
- body.amt ?? 50,
59
- body.query ?? '',
60
- body.routeId ?? '',
61
- ],
55
+ queryKey: keys.infinite('jobs', this.companyId, {
56
+ amt: body.amt ?? 50,
57
+ query: body.query ?? '',
58
+ routeId: body.routeId ?? '',
59
+ }),
62
60
  initialPageParam: 0,
63
61
  getNextPageParam: (lastPage, allPages) => {
64
62
  if (lastPage.length < (body.amt ?? 50))
@@ -105,14 +103,8 @@ AvroQueryClient.prototype.useCreateJob = function () {
105
103
  headers: { 'Content-Type': 'application/json' },
106
104
  });
107
105
  },
108
- onSuccess: async (result) => {
109
- await this._syncEntity(queryClient, {
110
- action: 'create',
111
- entityKey: 'jobs',
112
- id: result.id,
113
- fetchPath: `/job/${result.id}`,
114
- construct: (d) => new Job(d),
115
- });
106
+ onSuccess: () => {
107
+ this.syncAfterMutation('job');
116
108
  },
117
109
  });
118
110
  };
@@ -127,8 +119,7 @@ AvroQueryClient.prototype.useManageJobs = function () {
127
119
  });
128
120
  },
129
121
  onSuccess: () => {
130
- queryClient.invalidateQueries({ queryKey: ['jobs'] });
131
- queryClient.invalidateQueries({ queryKey: ['infinite', 'jobs'] });
122
+ this.syncAfterMutation('job');
132
123
  },
133
124
  });
134
125
  };
@@ -142,14 +133,8 @@ AvroQueryClient.prototype.useUpdateJob = function () {
142
133
  headers: { 'Content-Type': 'application/json' },
143
134
  });
144
135
  },
145
- onSuccess: async (_result, { jobId }) => {
146
- await this._syncEntity(queryClient, {
147
- action: 'update',
148
- entityKey: 'jobs',
149
- id: jobId,
150
- fetchPath: `/job/${jobId}`,
151
- construct: (d) => new Job(d),
152
- });
136
+ onSuccess: () => {
137
+ this.syncAfterMutation('job');
153
138
  },
154
139
  });
155
140
  };
@@ -164,8 +149,7 @@ AvroQueryClient.prototype.useDeleteJobs = function () {
164
149
  });
165
150
  },
166
151
  onSuccess: () => {
167
- queryClient.invalidateQueries({ queryKey: ['jobs'] });
168
- queryClient.invalidateQueries({ queryKey: ['infinite', 'jobs'] });
152
+ this.syncAfterMutation('job');
169
153
  },
170
154
  });
171
155
  };
@@ -180,12 +164,8 @@ AvroQueryClient.prototype.useDeleteJob = function () {
180
164
  },
181
165
  });
182
166
  },
183
- onSuccess: async (_result, { jobId }) => {
184
- await this._syncEntity(queryClient, {
185
- action: 'delete',
186
- entityKey: 'jobs',
187
- id: jobId,
188
- });
167
+ onSuccess: () => {
168
+ this.syncAfterMutation('job');
189
169
  },
190
170
  });
191
171
  };