@go-avro/avro-js 0.0.64 → 0.0.65
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 +27 -2
- package/dist/client/QueryClient.js +3 -0
- package/dist/client/hooks/checkins.d.ts +1 -0
- package/dist/client/hooks/checkins.js +46 -0
- package/dist/client/hooks/events.js +5 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/types/api.d.ts +24 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Socket } from 'socket.io-client';
|
|
2
2
|
import { InfiniteData, QueryClient, UseInfiniteQueryResult, useMutation, UseQueryResult } from '@tanstack/react-query';
|
|
3
3
|
import { AuthManager } from '../auth/AuthManager';
|
|
4
|
-
import { _Event, ActiveSessionSummary, ApiInfo, Avro, Bill, BillInsightData, Break, Chat, Company, FinancialInsightData, RevenueInsightData, Job, EventInsightData, LoginResponse, Message, Plan, Route, ServiceMonth, Session, Team, User, UserCompanyAssociation, Skill, Group, Label, RouteScheduleConfig, CatalogItem, Payout, Prepayment, Timecard, TimecardActionType, TimecardStatus } from '../types/api';
|
|
4
|
+
import { _Event, ActiveSessionSummary, ApiInfo, Avro, Bill, BillInsightData, Break, Chat, CheckIn, Company, EventUpdatePayload, FinancialInsightData, RevenueInsightData, Job, EventInsightData, LoginResponse, Message, Plan, Route, ServiceMonth, Session, Team, User, UserCompanyAssociation, Skill, Group, Label, RouteScheduleConfig, CatalogItem, Payout, Prepayment, Timecard, TimecardActionType, TimecardStatus } from '../types/api';
|
|
5
5
|
import { AuthState, Tokens } from '../types/auth';
|
|
6
6
|
import { CancelToken, ClientId, RetryStrategy } from '../types/client';
|
|
7
7
|
import { StandardError } from '../types/error';
|
|
@@ -351,8 +351,33 @@ declare module '../client/QueryClient' {
|
|
|
351
351
|
msg: string;
|
|
352
352
|
}, StandardError, {
|
|
353
353
|
eventId: string;
|
|
354
|
-
updates:
|
|
354
|
+
updates: EventUpdatePayload;
|
|
355
355
|
}>>;
|
|
356
|
+
useJobCheckins(jobId: string, params?: {
|
|
357
|
+
since?: number;
|
|
358
|
+
enabled?: boolean;
|
|
359
|
+
}): UseQueryResult<CheckIn[], StandardError>;
|
|
360
|
+
useCheckIn(): ReturnType<typeof useMutation<{
|
|
361
|
+
msg: string;
|
|
362
|
+
id: string;
|
|
363
|
+
}, StandardError, {
|
|
364
|
+
jobId: string;
|
|
365
|
+
teamId?: string | null;
|
|
366
|
+
}>>;
|
|
367
|
+
useCheckOut(): ReturnType<typeof useMutation<{
|
|
368
|
+
msg: string;
|
|
369
|
+
id: string;
|
|
370
|
+
}, StandardError, {
|
|
371
|
+
checkinId: string;
|
|
372
|
+
}>>;
|
|
373
|
+
checkInToJob(jobId: string, teamId?: string | null): Promise<{
|
|
374
|
+
msg: string;
|
|
375
|
+
id: string;
|
|
376
|
+
}>;
|
|
377
|
+
checkOut(checkinId: string): Promise<{
|
|
378
|
+
msg: string;
|
|
379
|
+
id: string;
|
|
380
|
+
}>;
|
|
356
381
|
useImportBillsFromIntuit(): ReturnType<typeof useMutation<{
|
|
357
382
|
msg: string;
|
|
358
383
|
imported: number;
|
|
@@ -213,6 +213,9 @@ const SOCKET_EVENT_CONFIG = {
|
|
|
213
213
|
},
|
|
214
214
|
delete_bill: { entityKey: 'bills', action: 'delete', fetchPath: null },
|
|
215
215
|
update_bills: { invalidateKeys: [['bills']] },
|
|
216
|
+
// ── Check-ins ──
|
|
217
|
+
create_checkin: { invalidateKeys: [['checkins']] },
|
|
218
|
+
update_checkin: { invalidateKeys: [['checkins']] },
|
|
216
219
|
// ── Sessions ──
|
|
217
220
|
create_session: {
|
|
218
221
|
entityKey: 'sessions',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useMutation, useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { AvroQueryClient } from '../../client/QueryClient';
|
|
3
|
+
AvroQueryClient.prototype.useJobCheckins = function (jobId, params) {
|
|
4
|
+
return useQuery({
|
|
5
|
+
queryKey: ['checkins', jobId, params?.since ?? 'today'],
|
|
6
|
+
queryFn: () => this.post({
|
|
7
|
+
path: `/job/${jobId}/checkins`,
|
|
8
|
+
data: JSON.stringify(params?.since != null ? { since: params.since } : {}),
|
|
9
|
+
headers: { 'Content-Type': 'application/json' },
|
|
10
|
+
}),
|
|
11
|
+
enabled: Boolean(jobId) && (params?.enabled ?? true),
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
AvroQueryClient.prototype.useCheckIn = function () {
|
|
15
|
+
const queryClient = this.getQueryClient();
|
|
16
|
+
return useMutation({
|
|
17
|
+
mutationFn: ({ jobId, teamId }) => this.checkInToJob(jobId, teamId),
|
|
18
|
+
onSettled: () => {
|
|
19
|
+
queryClient.invalidateQueries({ queryKey: ['checkins'] });
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
AvroQueryClient.prototype.useCheckOut = function () {
|
|
24
|
+
const queryClient = this.getQueryClient();
|
|
25
|
+
return useMutation({
|
|
26
|
+
mutationFn: ({ checkinId }) => this.checkOut(checkinId),
|
|
27
|
+
onSettled: () => {
|
|
28
|
+
queryClient.invalidateQueries({ queryKey: ['checkins'] });
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
// Raw helpers, safe outside React (headless background location task)
|
|
33
|
+
AvroQueryClient.prototype.checkInToJob = function (jobId, teamId) {
|
|
34
|
+
return this.post({
|
|
35
|
+
path: `/job/${jobId}/checkin`,
|
|
36
|
+
data: JSON.stringify(teamId ? { team_id: teamId } : {}),
|
|
37
|
+
headers: { 'Content-Type': 'application/json' },
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
AvroQueryClient.prototype.checkOut = function (checkinId) {
|
|
41
|
+
return this.post({
|
|
42
|
+
path: `/checkin/${checkinId}/checkout`,
|
|
43
|
+
data: JSON.stringify({}),
|
|
44
|
+
headers: { 'Content-Type': 'application/json' },
|
|
45
|
+
});
|
|
46
|
+
};
|
|
@@ -157,7 +157,11 @@ AvroQueryClient.prototype.useUpdateEvent = function () {
|
|
|
157
157
|
headers: { 'Content-Type': 'application/json' },
|
|
158
158
|
});
|
|
159
159
|
},
|
|
160
|
-
onMutate: async ({ eventId, updates }) => {
|
|
160
|
+
onMutate: async ({ eventId, updates: wireUpdates }) => {
|
|
161
|
+
// The wire `users` shape ({user_id, time_*}) must not land in
|
|
162
|
+
// cached _Event.users (UserEvent rows) — exclude it from the
|
|
163
|
+
// optimistic merge; invalidation on settle refreshes real rows.
|
|
164
|
+
const { users: _wireUsers, ...updates } = wireUpdates;
|
|
161
165
|
await queryClient.cancelQueries({ queryKey: ['events', eventId] });
|
|
162
166
|
await queryClient.cancelQueries({ queryKey: ['events'] });
|
|
163
167
|
// Try individual cache first; fall back to scanning all active events queries
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ import './client/hooks/payouts';
|
|
|
18
18
|
import './client/hooks/companies';
|
|
19
19
|
import './client/hooks/users';
|
|
20
20
|
import './client/hooks/sessions';
|
|
21
|
+
import './client/hooks/checkins';
|
|
21
22
|
import './client/hooks/chats';
|
|
22
23
|
import './client/hooks/catalog_items';
|
|
23
24
|
import './client/hooks/messages';
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import './client/hooks/payouts';
|
|
|
16
16
|
import './client/hooks/companies';
|
|
17
17
|
import './client/hooks/users';
|
|
18
18
|
import './client/hooks/sessions';
|
|
19
|
+
import './client/hooks/checkins';
|
|
19
20
|
import './client/hooks/chats';
|
|
20
21
|
import './client/hooks/catalog_items';
|
|
21
22
|
import './client/hooks/messages';
|
package/dist/types/api.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FrequencyType } from '..';
|
|
2
|
+
import { _Event } from '../types/api/_Event';
|
|
2
3
|
export * from '../types/api/_Event';
|
|
3
4
|
export * from '../types/api/AdditionalCharge';
|
|
4
5
|
export * from '../types/api/Avro';
|
|
@@ -220,6 +221,29 @@ export interface ActiveSessionSummary {
|
|
|
220
221
|
team_id: string | null;
|
|
221
222
|
time_started: number;
|
|
222
223
|
}
|
|
224
|
+
export interface CheckIn {
|
|
225
|
+
id: string;
|
|
226
|
+
user_id: string;
|
|
227
|
+
user_name: string | null;
|
|
228
|
+
job_id: string;
|
|
229
|
+
session_id: string;
|
|
230
|
+
team_id: string | null;
|
|
231
|
+
company_id: string;
|
|
232
|
+
time_checked_in: number;
|
|
233
|
+
time_checked_out: number | null;
|
|
234
|
+
time_created: number | null;
|
|
235
|
+
time_updated: number | null;
|
|
236
|
+
}
|
|
237
|
+
/** Wire shape for per-participant entries on an event update. */
|
|
238
|
+
export interface EventUserUpdate {
|
|
239
|
+
user_id: string;
|
|
240
|
+
time_started?: number;
|
|
241
|
+
time_ended?: number;
|
|
242
|
+
}
|
|
243
|
+
/** Event update payload: _Event fields, but users use the wire shape. */
|
|
244
|
+
export type EventUpdatePayload = Partial<Omit<_Event, 'users'>> & {
|
|
245
|
+
users?: EventUserUpdate[];
|
|
246
|
+
};
|
|
223
247
|
export interface EventInsightData {
|
|
224
248
|
start: number;
|
|
225
249
|
end: number;
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AVRO_JS_VERSION = "0.0.
|
|
1
|
+
export declare const AVRO_JS_VERSION = "0.0.65";
|
package/dist/version.js
CHANGED