@go-avro/avro-js 0.0.113 → 0.0.115
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.js +39 -3
- package/dist/types/api/Task.d.ts +13 -1
- package/dist/types/api/Task.js +23 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -365,6 +365,9 @@ const SOCKET_EVENT_CONFIG = {
|
|
|
365
365
|
invalidateKeys: [['companies'], ['/company/list']],
|
|
366
366
|
},
|
|
367
367
|
// ── Location ──
|
|
368
|
+
// Handled surgically in setupSocketInvalidation (patches
|
|
369
|
+
// `current_location` / `last_location` in place); these keys are
|
|
370
|
+
// only the fallback for malformed payloads.
|
|
368
371
|
location_update: { invalidateKeys: [['teams']] },
|
|
369
372
|
// ── Prepayments ──
|
|
370
373
|
update_prepayments: { invalidateKeys: [['prepayments']] },
|
|
@@ -531,13 +534,46 @@ export class AvroQueryClient {
|
|
|
531
534
|
};
|
|
532
535
|
queryClient.setQueriesData({ queryKey: ['users', 'company'] }, (old) => Array.isArray(old) ? patchMembers(old) : old);
|
|
533
536
|
};
|
|
537
|
+
const patchTeamLocation = (data) => {
|
|
538
|
+
const teamId = data.team_id;
|
|
539
|
+
if (!teamId || typeof teamId !== 'string')
|
|
540
|
+
return;
|
|
541
|
+
const patchTeams = (teams) => {
|
|
542
|
+
let changed = false;
|
|
543
|
+
const next = teams.map((t) => {
|
|
544
|
+
if (t?.id !== teamId)
|
|
545
|
+
return t;
|
|
546
|
+
changed = true;
|
|
547
|
+
return { ...t, current_location: data };
|
|
548
|
+
});
|
|
549
|
+
return changed ? next : teams;
|
|
550
|
+
};
|
|
551
|
+
queryClient.setQueriesData({ queryKey: ['teams'] }, (old) => {
|
|
552
|
+
if (Array.isArray(old))
|
|
553
|
+
return patchTeams(old);
|
|
554
|
+
if (old?.pages) {
|
|
555
|
+
return {
|
|
556
|
+
...old,
|
|
557
|
+
pages: old.pages.map((page) => Array.isArray(page) ? patchTeams(page) : page),
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
if (old?.id === teamId)
|
|
561
|
+
return { ...old, current_location: data };
|
|
562
|
+
return old;
|
|
563
|
+
});
|
|
564
|
+
};
|
|
534
565
|
for (const [event, config] of Object.entries(SOCKET_EVENT_CONFIG)) {
|
|
535
566
|
if (event === 'location_update' && isBulkEvent(config)) {
|
|
536
567
|
const handler = (data) => {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
568
|
+
if (!data || typeof data.latitude !== 'number') {
|
|
569
|
+
for (const key of config.invalidateKeys) {
|
|
570
|
+
queryClient.invalidateQueries({ queryKey: key });
|
|
571
|
+
}
|
|
540
572
|
}
|
|
573
|
+
else {
|
|
574
|
+
patchTeamLocation(data);
|
|
575
|
+
}
|
|
576
|
+
patchMemberLocation(data);
|
|
541
577
|
};
|
|
542
578
|
this.socket.on(event, handler);
|
|
543
579
|
handlers.push({ event, handler });
|
package/dist/types/api/Task.d.ts
CHANGED
|
@@ -13,6 +13,17 @@ export declare const TaskStatus: {
|
|
|
13
13
|
readonly PENDING_ACTIVATION: "PENDING_ACTIVATION";
|
|
14
14
|
};
|
|
15
15
|
export type TaskStatus = (typeof TaskStatus)[keyof typeof TaskStatus];
|
|
16
|
+
export declare const UnroutedReason: {
|
|
17
|
+
readonly NOT_DUE: "NOT_DUE";
|
|
18
|
+
readonly DEPENDENCY_UNMET: "DEPENDENCY_UNMET";
|
|
19
|
+
readonly MISSING_SKILLS: "MISSING_SKILLS";
|
|
20
|
+
readonly OVER_CAPACITY: "OVER_CAPACITY";
|
|
21
|
+
readonly TRAVEL_TIME: "TRAVEL_TIME";
|
|
22
|
+
readonly LOW_PRIORITY: "LOW_PRIORITY";
|
|
23
|
+
readonly DID_NOT_FIT: "DID_NOT_FIT";
|
|
24
|
+
};
|
|
25
|
+
export type UnroutedReason = (typeof UnroutedReason)[keyof typeof UnroutedReason];
|
|
26
|
+
export declare const UNROUTED_REASON_LABELS: Record<UnroutedReason, string>;
|
|
16
27
|
declare module '../../types/api/Task' {
|
|
17
28
|
interface Task {
|
|
18
29
|
enforce_image_amount: boolean;
|
|
@@ -40,7 +51,7 @@ declare module '../../types/api/Task' {
|
|
|
40
51
|
bill_mode: 'MONTH' | 'SERVICE' | 'NONE';
|
|
41
52
|
autobill: boolean;
|
|
42
53
|
price: number;
|
|
43
|
-
last_unrouted_reason:
|
|
54
|
+
last_unrouted_reason: UnroutedReason | null;
|
|
44
55
|
services_remaining: number;
|
|
45
56
|
activate_on: number | null;
|
|
46
57
|
expire_on: number | null;
|
|
@@ -54,6 +65,7 @@ declare module '../../types/api/Task' {
|
|
|
54
65
|
export declare class Task {
|
|
55
66
|
constructor(init?: Partial<Task>);
|
|
56
67
|
getStatusLabel: () => "Active" | "Draft" | "Archived" | "Pending Customer Approval" | "Pending Company Approval" | "Pending Payment" | "Pending Activation";
|
|
68
|
+
getUnroutedReasonLabel: () => string | null;
|
|
57
69
|
isOverdue: () => boolean;
|
|
58
70
|
getOverdueLabel: () => string;
|
|
59
71
|
getNextDue: () => number | null;
|
package/dist/types/api/Task.js
CHANGED
|
@@ -8,6 +8,24 @@ export const TaskStatus = {
|
|
|
8
8
|
PENDING_PAYMENT: 'PENDING_PAYMENT',
|
|
9
9
|
PENDING_ACTIVATION: 'PENDING_ACTIVATION',
|
|
10
10
|
};
|
|
11
|
+
export const UnroutedReason = {
|
|
12
|
+
NOT_DUE: 'NOT_DUE',
|
|
13
|
+
DEPENDENCY_UNMET: 'DEPENDENCY_UNMET',
|
|
14
|
+
MISSING_SKILLS: 'MISSING_SKILLS',
|
|
15
|
+
OVER_CAPACITY: 'OVER_CAPACITY',
|
|
16
|
+
TRAVEL_TIME: 'TRAVEL_TIME',
|
|
17
|
+
LOW_PRIORITY: 'LOW_PRIORITY',
|
|
18
|
+
DID_NOT_FIT: 'DID_NOT_FIT',
|
|
19
|
+
};
|
|
20
|
+
export const UNROUTED_REASON_LABELS = {
|
|
21
|
+
NOT_DUE: 'Not due yet',
|
|
22
|
+
DEPENDENCY_UNMET: 'Depends on an unrouted task',
|
|
23
|
+
MISSING_SKILLS: 'No available team has the required skills',
|
|
24
|
+
OVER_CAPACITY: 'Exceeds remaining team capacity',
|
|
25
|
+
TRAVEL_TIME: 'Too much travel time to reach',
|
|
26
|
+
LOW_PRIORITY: 'Crowded out by higher-priority tasks',
|
|
27
|
+
DID_NOT_FIT: 'Did not fit any schedule',
|
|
28
|
+
};
|
|
11
29
|
export class Task {
|
|
12
30
|
constructor(init) {
|
|
13
31
|
this.getStatusLabel = () => {
|
|
@@ -30,6 +48,11 @@ export class Task {
|
|
|
30
48
|
return this.status;
|
|
31
49
|
}
|
|
32
50
|
};
|
|
51
|
+
this.getUnroutedReasonLabel = () => {
|
|
52
|
+
if (!this.last_unrouted_reason)
|
|
53
|
+
return null;
|
|
54
|
+
return UNROUTED_REASON_LABELS[this.last_unrouted_reason] ?? this.last_unrouted_reason;
|
|
55
|
+
};
|
|
33
56
|
this.isOverdue = () => {
|
|
34
57
|
return (this.status === TaskStatus.ACTIVE &&
|
|
35
58
|
this.overdue_time !== undefined &&
|
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.115";
|
package/dist/version.js
CHANGED