@go-avro/avro-js 1.6.4-rc2 → 1.6.4-rc3
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 +57 -52
- package/dist/client/QueryClient.js +45 -22
- package/dist/client/hooks/audit.js +4 -2
- package/dist/client/hooks/avro.js +6 -2
- package/dist/client/hooks/bills.d.ts +1 -1
- package/dist/client/hooks/bills.js +23 -3
- package/dist/client/hooks/catalog_items.js +4 -1
- package/dist/client/hooks/companies.js +4 -2
- package/dist/client/hooks/events.js +7 -5
- package/dist/client/hooks/jobs.js +26 -3
- package/dist/client/hooks/messages.js +6 -2
- package/dist/client/hooks/plans.js +1 -1
- package/dist/client/hooks/routes.js +31 -1
- package/dist/client/hooks/sessions.js +10 -3
- package/dist/client/hooks/skills.js +1 -1
- package/dist/client/hooks/timecards.js +2 -1
- package/dist/client/hooks/users.js +5 -2
- package/dist/client/realtime.js +8 -3
- package/dist/client/requests.d.ts +221 -0
- package/dist/client/requests.js +5 -0
- package/dist/client/wire.d.ts +7 -0
- package/dist/client/wire.js +14 -0
- package/dist/index.d.ts +1 -0
- package/dist/types/api/AdditionalCharge.d.ts +2 -1
- package/dist/types/api/Avro.d.ts +33 -28
- package/dist/types/api/Bill.d.ts +7 -5
- package/dist/types/api/BillPayment.d.ts +8 -4
- package/dist/types/api/BillUser.d.ts +3 -2
- package/dist/types/api/CatalogItem.d.ts +9 -6
- package/dist/types/api/Chat.d.ts +3 -5
- package/dist/types/api/Company.d.ts +39 -13
- package/dist/types/api/DelayEvent.d.ts +5 -2
- package/dist/types/api/Email.d.ts +14 -3
- package/dist/types/api/Friendship.d.ts +8 -0
- package/dist/types/api/Group.d.ts +3 -2
- package/dist/types/api/Job.d.ts +24 -3
- package/dist/types/api/LineItem.d.ts +3 -2
- package/dist/types/api/MemberState.d.ts +2 -1
- package/dist/types/api/Message.d.ts +4 -3
- package/dist/types/api/Notification.d.ts +26 -0
- package/dist/types/api/PaymentMethod.d.ts +7 -2
- package/dist/types/api/PaymentOption.d.ts +6 -4
- package/dist/types/api/Payout.d.ts +1 -1
- package/dist/types/api/Plan.d.ts +5 -4
- package/dist/types/api/PlanPayment.d.ts +5 -3
- package/dist/types/api/Prepayment.d.ts +2 -1
- package/dist/types/api/Reaction.d.ts +3 -3
- package/dist/types/api/Refund.d.ts +1 -1
- package/dist/types/api/Route.d.ts +11 -10
- package/dist/types/api/Route.js +5 -0
- package/dist/types/api/RouteJob.d.ts +1 -1
- package/dist/types/api/ServiceMonth.d.ts +2 -2
- package/dist/types/api/Session.d.ts +5 -2
- package/dist/types/api/Skill.d.ts +2 -2
- package/dist/types/api/Subscription.d.ts +5 -3
- package/dist/types/api/Task.d.ts +10 -9
- package/dist/types/api/Task.js +3 -1
- package/dist/types/api/TimecardAction.d.ts +2 -2
- package/dist/types/api/User.d.ts +11 -9
- package/dist/types/api/UserCompanyAssociation.d.ts +7 -1
- package/dist/types/api/UserMerge.d.ts +3 -3
- package/dist/types/api/_Event.d.ts +20 -4
- package/dist/types/api/_Event.js +1 -0
- package/dist/types/api.d.ts +45 -28
- 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.js';
|
|
4
|
-
import { _Event, ActiveSessionSummary, AddressFeatureCollection, ApiInfo, Avro, StorageAnalytics, ClientErrorReport, ErrorLogEntry, PerformanceMetrics, AuditLogEntry, AuditQueryParams, Bill, BillInsightData, BillLineItemStatusUpdate, BillStatus, Break, Chat, CheckIn, Company, DelayEventCreatePayload, EventUpdatePayload, LineItemType, FinancialInsightData, RevenueInsightData, Job, JobUpdate, EventInsightData, AppleLinkProof, AppleLoginResult, LoginResponse, Message, Plan, Route, ServiceMonth, Session, Team, User, UserCompanyAssociation, UserMergeSummary, Skill, Group, Label, RouteScheduleConfig, RouteWritePayload, CatalogItem, Device, DeviceInfo, LocationServicesStatus, Payout, Prepayment, Timecard, TimecardActionType, TimecardStatus } from '../types/api.js';
|
|
4
|
+
import { _Event, ActiveSessionSummary, AddressFeatureCollection, ApiInfo, Avro, StorageAnalytics, ClientErrorReport, ErrorLogEntry, PerformanceMetrics, AuditLogEntry, AuditQueryParams, Bill, BillInsightData, BillLineItemStatusUpdate, BillStatus, Break, Chat, CheckIn, Company, CompanySummary, DelayEventCreatePayload, EventUpdatePayload, LineItemType, FinancialInsightData, RevenueInsightData, Job, JobUpdate, EventInsightData, AppleLinkProof, AppleLoginResult, LoginResponse, Message, Plan, Route, ServiceMonth, Session, Team, User, UserCompanyAssociation, UserMergeSummary, Skill, Group, Label, RouteScheduleConfig, RouteWritePayload, CatalogItem, Device, DeviceInfo, LocationServicesStatus, Payout, Prepayment, Timecard, TimecardActionType, TimecardStatus } from '../types/api.js';
|
|
5
5
|
import { AuthState, Tokens } from '../types/auth.js';
|
|
6
6
|
import { CancelToken, ClientId, RetryStrategy } from '../types/client.js';
|
|
7
7
|
import { StandardError } from '../types/error.js';
|
|
@@ -11,6 +11,7 @@ import { Proposal } from '../types/api/Proposal.js';
|
|
|
11
11
|
import { ProposalTerms } from '../types/api/ProposalTerms.js';
|
|
12
12
|
import type { EmailSucceededPayload, EmailFailedPayload, EmailType } from '../types/api/EmailNotification.js';
|
|
13
13
|
import type { BulkDeleteBillsResponse, BulkEmailBillsResponse } from './hooks/bills.js';
|
|
14
|
+
import type { BillWritePayload, CatalogItemCreatePayload, CatalogItemUpdatePayload, CompanyCreatePayload, EventCreatePayload, IntuitImportResult, PayoutStatusFilter, ProposalReviewPayload, ProposalWritePayload, SkillCreatePayload, SkillUpdatePayload, UserCreatePayload, UserUpdatePayload } from './requests.js';
|
|
14
15
|
import { type QueryPersistOptions } from './persist.js';
|
|
15
16
|
export interface TrackEmailOptions {
|
|
16
17
|
emailType?: EmailType;
|
|
@@ -146,7 +147,7 @@ declare module './QueryClient.js' {
|
|
|
146
147
|
useGetPayouts(body: {
|
|
147
148
|
amt?: number;
|
|
148
149
|
query?: string;
|
|
149
|
-
status?:
|
|
150
|
+
status?: PayoutStatusFilter | '';
|
|
150
151
|
known_ids?: string[];
|
|
151
152
|
unknown_ids?: string[];
|
|
152
153
|
created_from?: number;
|
|
@@ -178,14 +179,15 @@ declare module './QueryClient.js' {
|
|
|
178
179
|
offset?: number;
|
|
179
180
|
}, total: number, onProgress?: (fraction: number) => void): UseQueryResult<Group[], StandardError>;
|
|
180
181
|
useGetPlans(code: string): UseQueryResult<Plan[], StandardError>;
|
|
181
|
-
useGetCompanies(options?: {}): UseQueryResult<
|
|
182
|
+
useGetCompanies(options?: {}): UseQueryResult<CompanySummary[], StandardError>;
|
|
182
183
|
generatePDFFromBackend({ billId }: {
|
|
183
184
|
billId: string;
|
|
184
185
|
}): Promise<Blob>;
|
|
185
186
|
sendBillingEmail(options: {
|
|
186
187
|
billId: string;
|
|
187
188
|
subject?: string;
|
|
188
|
-
|
|
189
|
+
/** `[name, email]` pairs; omitted: the bill's own recipients. */
|
|
190
|
+
recipients?: [string, string][];
|
|
189
191
|
request_id?: string;
|
|
190
192
|
}): Promise<{
|
|
191
193
|
msg: string;
|
|
@@ -193,10 +195,12 @@ declare module './QueryClient.js' {
|
|
|
193
195
|
useGetProposal(proposal_id: string): UseQueryResult<Proposal, StandardError>;
|
|
194
196
|
useGetProposalTerms(): UseQueryResult<ProposalTerms[], StandardError>;
|
|
195
197
|
useCreateProposalTerms(): ReturnType<typeof useMutation<{
|
|
198
|
+
msg: string;
|
|
196
199
|
id: string;
|
|
197
200
|
}, StandardError, {
|
|
198
201
|
name: string;
|
|
199
202
|
body: string;
|
|
203
|
+
archived?: boolean;
|
|
200
204
|
}>>;
|
|
201
205
|
useUpdateProposalTerms(): ReturnType<typeof useMutation<{
|
|
202
206
|
msg: string;
|
|
@@ -285,15 +289,7 @@ declare module './QueryClient.js' {
|
|
|
285
289
|
useReviewProposal(proposal_id: string): ReturnType<typeof useMutation<{
|
|
286
290
|
msg: string;
|
|
287
291
|
bill_id?: string;
|
|
288
|
-
}, StandardError,
|
|
289
|
-
tasks: {
|
|
290
|
-
id: string;
|
|
291
|
-
status: string;
|
|
292
|
-
payment_option_id: string;
|
|
293
|
-
}[];
|
|
294
|
-
terms_version_id?: string;
|
|
295
|
-
pay_in_cash?: boolean;
|
|
296
|
-
}>>;
|
|
292
|
+
}, StandardError, ProposalReviewPayload>>;
|
|
297
293
|
useCreateMessage(chatId: string): ReturnType<typeof useMutation<{
|
|
298
294
|
msg?: string;
|
|
299
295
|
id: string;
|
|
@@ -303,36 +299,47 @@ declare module './QueryClient.js' {
|
|
|
303
299
|
id?: string;
|
|
304
300
|
}>>;
|
|
305
301
|
useCreateProposal(): ReturnType<typeof useMutation<{
|
|
302
|
+
msg: string;
|
|
306
303
|
id: string;
|
|
307
304
|
}, StandardError, {
|
|
308
305
|
job_id: string;
|
|
309
|
-
data:
|
|
306
|
+
data: ProposalWritePayload;
|
|
310
307
|
}>>;
|
|
311
308
|
useCreateGroup(): ReturnType<typeof useMutation<{
|
|
309
|
+
msg: string;
|
|
312
310
|
id: string;
|
|
313
311
|
}, StandardError, {
|
|
314
|
-
groupData: Partial<Group
|
|
312
|
+
groupData: Partial<Group> & {
|
|
313
|
+
name: string;
|
|
314
|
+
};
|
|
315
315
|
}>>;
|
|
316
316
|
useCreateWaiver(): ReturnType<typeof useMutation<{
|
|
317
|
+
msg: string;
|
|
317
318
|
id: string;
|
|
318
319
|
}, StandardError, {
|
|
319
|
-
waiverData: Partial<Waiver
|
|
320
|
+
waiverData: Partial<Waiver> & {
|
|
321
|
+
name: string;
|
|
322
|
+
};
|
|
320
323
|
}>>;
|
|
321
324
|
useCreateLabel(): ReturnType<typeof useMutation<{
|
|
325
|
+
msg: string;
|
|
322
326
|
id: string;
|
|
323
327
|
}, StandardError, {
|
|
324
|
-
labelData: Partial<Label
|
|
328
|
+
labelData: Partial<Label> & {
|
|
329
|
+
name: string;
|
|
330
|
+
};
|
|
325
331
|
}>>;
|
|
326
332
|
useCreateSkill(): ReturnType<typeof useMutation<{
|
|
333
|
+
msg: string;
|
|
327
334
|
id: string;
|
|
328
335
|
}, StandardError, {
|
|
329
|
-
skillData:
|
|
336
|
+
skillData: SkillCreatePayload;
|
|
330
337
|
}>>;
|
|
331
338
|
useCreateEvent(): ReturnType<typeof useMutation<{
|
|
332
339
|
id: string;
|
|
333
340
|
msg: string;
|
|
334
341
|
}, StandardError, {
|
|
335
|
-
eventData:
|
|
342
|
+
eventData: EventCreatePayload;
|
|
336
343
|
}>>;
|
|
337
344
|
useCreateDelayEvent(): ReturnType<typeof useMutation<{
|
|
338
345
|
id: string;
|
|
@@ -341,7 +348,8 @@ declare module './QueryClient.js' {
|
|
|
341
348
|
delayData: DelayEventCreatePayload;
|
|
342
349
|
}>>;
|
|
343
350
|
useCreateUserSession(): ReturnType<typeof useMutation<{
|
|
344
|
-
|
|
351
|
+
msg: string;
|
|
352
|
+
id: string | null;
|
|
345
353
|
}, StandardError, {
|
|
346
354
|
sessionData: Partial<Session>;
|
|
347
355
|
}>>;
|
|
@@ -358,61 +366,58 @@ declare module './QueryClient.js' {
|
|
|
358
366
|
};
|
|
359
367
|
}>>;
|
|
360
368
|
useCreateBill(): ReturnType<typeof useMutation<{
|
|
369
|
+
msg: string;
|
|
361
370
|
id: string;
|
|
362
371
|
invoice_id: number;
|
|
363
372
|
}, StandardError, {
|
|
364
|
-
data:
|
|
373
|
+
data: BillWritePayload;
|
|
365
374
|
}>>;
|
|
366
375
|
useCreateCompany(): ReturnType<typeof useMutation<{
|
|
376
|
+
msg: string;
|
|
367
377
|
id: string;
|
|
368
378
|
}, StandardError, {
|
|
369
|
-
companyData:
|
|
370
|
-
logo: File | null;
|
|
371
|
-
}>;
|
|
379
|
+
companyData: CompanyCreatePayload;
|
|
372
380
|
}>>;
|
|
373
381
|
useCreateCatalogItem(): ReturnType<typeof useMutation<{
|
|
382
|
+
msg: string;
|
|
374
383
|
id: string;
|
|
375
384
|
}, StandardError, {
|
|
376
|
-
data:
|
|
385
|
+
data: CatalogItemCreatePayload;
|
|
377
386
|
}>>;
|
|
378
387
|
useCreateJob(): ReturnType<typeof useMutation<{
|
|
388
|
+
msg: string;
|
|
379
389
|
id: string;
|
|
380
390
|
}, StandardError, {
|
|
381
|
-
jobData:
|
|
391
|
+
jobData: JobUpdate;
|
|
382
392
|
}>>;
|
|
383
393
|
useCreateRoute(): ReturnType<typeof useMutation<{
|
|
394
|
+
msg: string;
|
|
384
395
|
id: string;
|
|
385
396
|
}, StandardError, {
|
|
386
397
|
routeData: RouteWritePayload;
|
|
387
398
|
}>>;
|
|
388
399
|
useCreateTeam(): ReturnType<typeof useMutation<{
|
|
400
|
+
msg: string;
|
|
389
401
|
id: string;
|
|
390
402
|
}, StandardError, {
|
|
391
|
-
teamData: Partial<Team
|
|
403
|
+
teamData: Partial<Team> & {
|
|
404
|
+
name: string;
|
|
405
|
+
};
|
|
392
406
|
}>>;
|
|
393
407
|
useCreateSelf(): ReturnType<typeof useMutation<{
|
|
394
408
|
msg: string;
|
|
395
409
|
id?: string;
|
|
396
410
|
access_token?: string;
|
|
397
411
|
refresh_token?: string;
|
|
398
|
-
}, StandardError,
|
|
399
|
-
code?: string;
|
|
400
|
-
invite_token?: string;
|
|
401
|
-
password?: string;
|
|
402
|
-
company_id?: string;
|
|
403
|
-
}>>;
|
|
412
|
+
}, StandardError, UserCreatePayload>>;
|
|
404
413
|
useCreateUser(): ReturnType<typeof useMutation<{
|
|
405
414
|
msg: string;
|
|
406
415
|
id?: string;
|
|
407
416
|
access_token?: string;
|
|
408
417
|
refresh_token?: string;
|
|
409
|
-
}, StandardError,
|
|
410
|
-
code?: string;
|
|
411
|
-
invite_token?: string;
|
|
412
|
-
password?: string;
|
|
413
|
-
company_id?: string;
|
|
414
|
-
}>>;
|
|
418
|
+
}, StandardError, UserCreatePayload>>;
|
|
415
419
|
useCreateSessionBreak(): ReturnType<typeof useMutation<{
|
|
420
|
+
msg: string;
|
|
416
421
|
id: string;
|
|
417
422
|
}, StandardError, {
|
|
418
423
|
sessionId: string;
|
|
@@ -446,7 +451,7 @@ declare module './QueryClient.js' {
|
|
|
446
451
|
}>>;
|
|
447
452
|
useCheckOut(): ReturnType<typeof useMutation<{
|
|
448
453
|
msg: string;
|
|
449
|
-
id: string;
|
|
454
|
+
id: string | null;
|
|
450
455
|
job_id: string | null;
|
|
451
456
|
}, StandardError, {
|
|
452
457
|
checkinId: string;
|
|
@@ -458,14 +463,10 @@ declare module './QueryClient.js' {
|
|
|
458
463
|
}>;
|
|
459
464
|
checkOut(checkinId: string): Promise<{
|
|
460
465
|
msg: string;
|
|
461
|
-
id: string;
|
|
466
|
+
id: string | null;
|
|
462
467
|
job_id: string | null;
|
|
463
468
|
}>;
|
|
464
|
-
useImportBillsFromIntuit(): ReturnType<typeof useMutation<
|
|
465
|
-
msg: string;
|
|
466
|
-
imported: number;
|
|
467
|
-
skipped: number;
|
|
468
|
-
}, StandardError, void>>;
|
|
469
|
+
useImportBillsFromIntuit(): ReturnType<typeof useMutation<IntuitImportResult, StandardError, void>>;
|
|
469
470
|
useSyncBillToIntuit(): ReturnType<typeof useMutation<{
|
|
470
471
|
msg: string;
|
|
471
472
|
}, StandardError, {
|
|
@@ -518,7 +519,7 @@ declare module './QueryClient.js' {
|
|
|
518
519
|
msg: string;
|
|
519
520
|
}, StandardError, {
|
|
520
521
|
catalogItemId: string;
|
|
521
|
-
data:
|
|
522
|
+
data: CatalogItemUpdatePayload;
|
|
522
523
|
}>>;
|
|
523
524
|
useUpdateJob(): ReturnType<typeof useMutation<{
|
|
524
525
|
msg: string;
|
|
@@ -530,13 +531,13 @@ declare module './QueryClient.js' {
|
|
|
530
531
|
msg: string;
|
|
531
532
|
}, StandardError, {
|
|
532
533
|
skillId: string;
|
|
533
|
-
updates:
|
|
534
|
+
updates: SkillUpdatePayload;
|
|
534
535
|
}>>;
|
|
535
536
|
useUpdateBill(): ReturnType<typeof useMutation<{
|
|
536
537
|
msg: string;
|
|
537
538
|
}, StandardError, {
|
|
538
539
|
billId: string;
|
|
539
|
-
updates:
|
|
540
|
+
updates: BillWritePayload;
|
|
540
541
|
}>>;
|
|
541
542
|
useUpdateBillLineItemStatus(): ReturnType<typeof useMutation<{
|
|
542
543
|
msg: string;
|
|
@@ -627,7 +628,7 @@ declare module './QueryClient.js' {
|
|
|
627
628
|
}>>;
|
|
628
629
|
useUpdateUser(userId: string): ReturnType<typeof useMutation<{
|
|
629
630
|
msg: string;
|
|
630
|
-
}, StandardError,
|
|
631
|
+
}, StandardError, UserUpdatePayload>>;
|
|
631
632
|
useDeleteJobs(): ReturnType<typeof useMutation<{
|
|
632
633
|
msg: string;
|
|
633
634
|
}, StandardError, {
|
|
@@ -1003,9 +1004,12 @@ export declare class AvroQueryClient {
|
|
|
1003
1004
|
billed?: boolean;
|
|
1004
1005
|
paid?: boolean;
|
|
1005
1006
|
job_id?: string | null;
|
|
1007
|
+
task_id?: string | null;
|
|
1006
1008
|
sort_by?: 'date' | 'amount' | 'name';
|
|
1007
1009
|
direction?: 'asc' | 'desc';
|
|
1008
1010
|
line_item_types?: LineItemType[];
|
|
1011
|
+
created_from?: number;
|
|
1012
|
+
created_to?: number;
|
|
1009
1013
|
}, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
|
|
1010
1014
|
fetchMonths(body?: {
|
|
1011
1015
|
amt?: number;
|
|
@@ -1042,7 +1046,7 @@ export declare class AvroQueryClient {
|
|
|
1042
1046
|
fetchPayouts(body?: {
|
|
1043
1047
|
amt?: number;
|
|
1044
1048
|
query?: string;
|
|
1045
|
-
status?:
|
|
1049
|
+
status?: PayoutStatusFilter | '';
|
|
1046
1050
|
known_ids?: string[];
|
|
1047
1051
|
unknown_ids?: string[];
|
|
1048
1052
|
offset?: number;
|
|
@@ -1112,7 +1116,8 @@ export declare class AvroQueryClient {
|
|
|
1112
1116
|
sendEmail(emailId: string, formData: FormData, progressUpdateCallback?: (loaded: number, total: number) => void): Promise<void>;
|
|
1113
1117
|
sendBillEmail(billId: string, body?: {
|
|
1114
1118
|
subject?: string;
|
|
1115
|
-
|
|
1119
|
+
/** `[name, email]` pairs; omitted: the bill's own recipients. */
|
|
1120
|
+
recipients?: [string, string][];
|
|
1116
1121
|
base_url?: string;
|
|
1117
1122
|
request_id?: string;
|
|
1118
1123
|
}): Promise<void>;
|
|
@@ -6,6 +6,7 @@ import { fetchCensusFeatures } from '../census.js';
|
|
|
6
6
|
import { LoginResponse, } from '../types/api.js';
|
|
7
7
|
import { AuthState } from '../types/auth.js';
|
|
8
8
|
import { StandardError } from '../types/error.js';
|
|
9
|
+
import { withoutEmpty } from './wire.js';
|
|
9
10
|
import { ChangeApplier, fallbackInvalidate, patchMember, patchMemberLocation, patchTeamLocation, } from './realtime.js';
|
|
10
11
|
import { QueryPersister } from './persist.js';
|
|
11
12
|
/** Keep the original status (401/403/404/0…) when surfacing a list-fetch failure. */
|
|
@@ -40,8 +41,12 @@ function filterLocally(items, body, fields) {
|
|
|
40
41
|
/** Translate a legacy camelCase parent filter to the snake_case the backend reads. */
|
|
41
42
|
function withWireParent(body, legacy, wire) {
|
|
42
43
|
const { [legacy]: legacyValue, ...rest } = body;
|
|
43
|
-
|
|
44
|
+
// The backend's id filters are UUIDs: '' or null means "no filter",
|
|
45
|
+
// so omit the key rather than send a value it rejects.
|
|
46
|
+
return { ...rest, [wire]: rest[wire] || legacyValue || undefined };
|
|
44
47
|
}
|
|
48
|
+
/** `ListMessages.amt` upper bound. */
|
|
49
|
+
const MAX_MESSAGES_PER_PAGE = 100;
|
|
45
50
|
const AUTH_RECHECK_MIN_MS = 2000;
|
|
46
51
|
const AUTH_RECHECK_MAX_MS = 60000;
|
|
47
52
|
const SOCKET_AUTH_RETRY_MS = 10000;
|
|
@@ -353,21 +358,24 @@ export class AvroQueryClient {
|
|
|
353
358
|
this._presencePending.clear();
|
|
354
359
|
if (!this.companyId || userIds.length === 0)
|
|
355
360
|
return;
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
361
|
+
// `ListCompanyUsers.user_ids` holds at most 1000 ids.
|
|
362
|
+
for (let i = 0; i < userIds.length; i += 1000) {
|
|
363
|
+
this.post({
|
|
364
|
+
path: `/company/${this.companyId}/users`,
|
|
365
|
+
data: JSON.stringify({ user_ids: userIds.slice(i, i + 1000) }),
|
|
366
|
+
headers: { 'Content-Type': 'application/json' },
|
|
367
|
+
idempotent: true,
|
|
368
|
+
})
|
|
369
|
+
.then((members) => {
|
|
370
|
+
if (!Array.isArray(members)) {
|
|
371
|
+
markMembersStale();
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
for (const member of members)
|
|
375
|
+
patchMember(queryClient, member);
|
|
376
|
+
})
|
|
377
|
+
.catch(markMembersStale);
|
|
378
|
+
}
|
|
371
379
|
}, PRESENCE_COALESCE_MS);
|
|
372
380
|
});
|
|
373
381
|
on('location_update', (data) => {
|
|
@@ -581,7 +589,7 @@ export class AvroQueryClient {
|
|
|
581
589
|
const queryClient = this.getQueryClient();
|
|
582
590
|
return useMutation({
|
|
583
591
|
mutationFn: async ({ token, cancelToken, }) => {
|
|
584
|
-
const resp = await this._xhr('POST', `/google/authorize?token=${token}`, {}, cancelToken, { 'Content-Type': 'application/json' });
|
|
592
|
+
const resp = await this._xhr('POST', `/google/authorize?token=${encodeURIComponent(token)}`, {}, cancelToken, { 'Content-Type': 'application/json' });
|
|
585
593
|
if (!resp || !('access_token' in resp)) {
|
|
586
594
|
if (resp.msg === 'TOTP required') {
|
|
587
595
|
return LoginResponse.NEEDS_TOTP;
|
|
@@ -898,7 +906,7 @@ export class AvroQueryClient {
|
|
|
898
906
|
if (!companyIdToUse || companyIdToUse.trim() === '') {
|
|
899
907
|
throw new StandardError(400, 'Company ID is required');
|
|
900
908
|
}
|
|
901
|
-
return this._fetch('POST', `/company/${companyIdToUse}/jobs`, JSON.stringify(body), cancelToken, {
|
|
909
|
+
return this._fetch('POST', `/company/${companyIdToUse}/jobs`, JSON.stringify(withoutEmpty(body, 'route_id')), cancelToken, {
|
|
902
910
|
...headers,
|
|
903
911
|
'Content-Type': 'application/json',
|
|
904
912
|
}, true)
|
|
@@ -993,7 +1001,16 @@ export class AvroQueryClient {
|
|
|
993
1001
|
if (!chatId || chatId.trim() === '') {
|
|
994
1002
|
throw new StandardError(400, 'Chat ID is required');
|
|
995
1003
|
}
|
|
996
|
-
|
|
1004
|
+
// `ListMessages`: the keyword field is `keyword`, and `amt` must be 1..100.
|
|
1005
|
+
const { query, amt, ...rest } = body;
|
|
1006
|
+
if (amt !== undefined && amt < 1)
|
|
1007
|
+
return Promise.resolve([]);
|
|
1008
|
+
const wire = {
|
|
1009
|
+
...rest,
|
|
1010
|
+
...(amt !== undefined && { amt: Math.min(Math.floor(amt), MAX_MESSAGES_PER_PAGE) }),
|
|
1011
|
+
...(query && { keyword: query }),
|
|
1012
|
+
};
|
|
1013
|
+
return this._fetch('POST', `/chat/${chatId}/messages`, JSON.stringify(wire), cancelToken, {
|
|
997
1014
|
...headers,
|
|
998
1015
|
'Content-Type': 'application/json',
|
|
999
1016
|
}, true)
|
|
@@ -1050,7 +1067,7 @@ export class AvroQueryClient {
|
|
|
1050
1067
|
if (!this.companyId || this.companyId.trim() === '') {
|
|
1051
1068
|
throw new StandardError(400, 'Company ID is required');
|
|
1052
1069
|
}
|
|
1053
|
-
return this._fetch('POST', `/company/${this.companyId}/events`, JSON.stringify(body), cancelToken, {
|
|
1070
|
+
return this._fetch('POST', `/company/${this.companyId}/events`, JSON.stringify(withoutEmpty(body, 'job_id', 'task_id')), cancelToken, {
|
|
1054
1071
|
...headers,
|
|
1055
1072
|
'Content-Type': 'application/json',
|
|
1056
1073
|
}, true)
|
|
@@ -1069,6 +1086,9 @@ export class AvroQueryClient {
|
|
|
1069
1086
|
if (!this.companyId || this.companyId.trim() === '') {
|
|
1070
1087
|
throw new StandardError(400, 'Company ID is required');
|
|
1071
1088
|
}
|
|
1089
|
+
// `amt` must be >= 1 here (omit it for every row).
|
|
1090
|
+
if (body.amt !== undefined && body.amt < 1)
|
|
1091
|
+
return Promise.resolve([]);
|
|
1072
1092
|
return this._fetch('POST', `/company/${this.companyId}/months`, JSON.stringify(withWireParent(body, 'jobId', 'job_id')), cancelToken, {
|
|
1073
1093
|
...headers,
|
|
1074
1094
|
'Content-Type': 'application/json',
|
|
@@ -1107,7 +1127,10 @@ export class AvroQueryClient {
|
|
|
1107
1127
|
if (!this.companyId || this.companyId.trim() === '') {
|
|
1108
1128
|
throw new StandardError(400, 'Company ID is required');
|
|
1109
1129
|
}
|
|
1110
|
-
|
|
1130
|
+
// `amt` must be >= 1 here (omit it for every row).
|
|
1131
|
+
if (body.amt !== undefined && body.amt < 1)
|
|
1132
|
+
return Promise.resolve([]);
|
|
1133
|
+
return this._fetch('POST', `/company/${this.companyId}/payouts`, JSON.stringify(withoutEmpty(body, 'status')), cancelToken, {
|
|
1111
1134
|
...headers,
|
|
1112
1135
|
'Content-Type': 'application/json',
|
|
1113
1136
|
}, true)
|
|
@@ -1228,7 +1251,7 @@ export class AvroQueryClient {
|
|
|
1228
1251
|
throw new StandardError(400, 'Company ID is required');
|
|
1229
1252
|
}
|
|
1230
1253
|
const amount = body.amt ?? Math.max(body.unknown_ids?.length ?? 0, 50);
|
|
1231
|
-
return this._fetch('POST', `/company/${companyId}/sessions?amount=${amount}`, JSON.stringify({ ...body, amt: amount }), cancelToken, {
|
|
1254
|
+
return this._fetch('POST', `/company/${companyId}/sessions?amount=${amount}`, JSON.stringify(withoutEmpty({ ...body, amt: amount }, 'user_id')), cancelToken, {
|
|
1232
1255
|
...headers,
|
|
1233
1256
|
'Content-Type': 'application/json',
|
|
1234
1257
|
}, true)
|
|
@@ -8,8 +8,10 @@ const buildQuery = (params) => {
|
|
|
8
8
|
search.set('entity_type', params.entityType);
|
|
9
9
|
if (params?.action)
|
|
10
10
|
search.set('action', params.action);
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
// The audit endpoints take an integer `limit` of 1..500.
|
|
12
|
+
if (params?.limit !== undefined) {
|
|
13
|
+
search.set('limit', String(Math.min(Math.max(Math.floor(params.limit), 1), 500)));
|
|
14
|
+
}
|
|
13
15
|
const encoded = search.toString();
|
|
14
16
|
return encoded ? `?${encoded}` : '';
|
|
15
17
|
};
|
|
@@ -18,7 +18,8 @@ AvroQueryClient.prototype.useGetErrorLog = function (limit = 200) {
|
|
|
18
18
|
queryKey: ['avro', 'errors', limit],
|
|
19
19
|
queryFn: async () => {
|
|
20
20
|
const res = await this.get({
|
|
21
|
-
|
|
21
|
+
// `limit` is an integer of 1..1000.
|
|
22
|
+
path: `/avro/errors?limit=${Math.min(Math.max(Math.floor(limit), 1), 1000)}`,
|
|
22
23
|
});
|
|
23
24
|
return res.errors;
|
|
24
25
|
},
|
|
@@ -27,7 +28,10 @@ AvroQueryClient.prototype.useGetErrorLog = function (limit = 200) {
|
|
|
27
28
|
AvroQueryClient.prototype.useGetPerformanceMetrics = function ({ limit = 360, refetchInterval, } = {}) {
|
|
28
29
|
return useQuery({
|
|
29
30
|
queryKey: ['avro', 'performance', limit],
|
|
30
|
-
|
|
31
|
+
// `limit` is an integer of 1..2880.
|
|
32
|
+
queryFn: () => this.get({
|
|
33
|
+
path: `/avro/performance?limit=${Math.min(Math.max(Math.floor(limit), 1), 2880)}`,
|
|
34
|
+
}),
|
|
31
35
|
staleTime: 0,
|
|
32
36
|
refetchInterval,
|
|
33
37
|
});
|
|
@@ -4,6 +4,18 @@ import { seedDetails } from '../cache.js';
|
|
|
4
4
|
import { restoreNs, snapshotNs } from '../cache.js';
|
|
5
5
|
import { keys } from '../realtime.js';
|
|
6
6
|
import { Bill } from '../../types/api.js';
|
|
7
|
+
/**
|
|
8
|
+
* Keep only the `BillLineItemIn` fields, so cached LineItem rows (with
|
|
9
|
+
* `id`, `status`, …) can be passed back as custom items.
|
|
10
|
+
*/
|
|
11
|
+
function toBillLineItemInput(item) {
|
|
12
|
+
return {
|
|
13
|
+
name: item.name,
|
|
14
|
+
description: item.description,
|
|
15
|
+
amount: item.amount,
|
|
16
|
+
cost: item.cost,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
7
19
|
AvroQueryClient.prototype.useGetBills = function (body) {
|
|
8
20
|
const queryClient = this.getQueryClient();
|
|
9
21
|
const result = useInfiniteQuery({
|
|
@@ -47,13 +59,14 @@ AvroQueryClient.prototype.useCreateBill = function () {
|
|
|
47
59
|
const body = {
|
|
48
60
|
events: data.events ?? [],
|
|
49
61
|
months: data.months ?? [],
|
|
50
|
-
line_items: data.line_items ?? [],
|
|
62
|
+
line_items: (data.line_items ?? []).map(toBillLineItemInput),
|
|
51
63
|
manual_emails: data.manual_emails ?? [],
|
|
52
64
|
prepayments: data.prepayments ?? [],
|
|
53
65
|
enabled_payment_methods: data.enabled_payment_methods ?? [],
|
|
54
66
|
pass_on_fees: data.pass_on_fees,
|
|
55
67
|
users: data.users,
|
|
56
68
|
due_date: data.due_date,
|
|
69
|
+
name: data.name,
|
|
57
70
|
};
|
|
58
71
|
return this.post({
|
|
59
72
|
path: `/company/${this.companyId}/bill`,
|
|
@@ -85,15 +98,22 @@ AvroQueryClient.prototype.useUpdateBill = function () {
|
|
|
85
98
|
const queryClient = this.getQueryClient();
|
|
86
99
|
return useMutation({
|
|
87
100
|
mutationFn: ({ billId, updates }) => {
|
|
101
|
+
const body = updates.line_items
|
|
102
|
+
? { ...updates, line_items: updates.line_items.map(toBillLineItemInput) }
|
|
103
|
+
: updates;
|
|
88
104
|
return this.put({
|
|
89
105
|
path: `/bill/${billId}`,
|
|
90
|
-
data: JSON.stringify(
|
|
106
|
+
data: JSON.stringify(body),
|
|
91
107
|
headers: {
|
|
92
108
|
'Content-Type': 'application/json',
|
|
93
109
|
},
|
|
94
110
|
});
|
|
95
111
|
},
|
|
96
|
-
onMutate: async ({ billId, updates }) => {
|
|
112
|
+
onMutate: async ({ billId, updates: wireUpdates }) => {
|
|
113
|
+
// `users`/`line_items` are request-shaped (user ids + amounts,
|
|
114
|
+
// bare custom items), not the cached BillUser/LineItem rows; the
|
|
115
|
+
// echoed change brings the real ones.
|
|
116
|
+
const { users: _users, line_items: _lineItems, ...updates } = wireUpdates;
|
|
97
117
|
await queryClient.cancelQueries({ queryKey: ['bills'] });
|
|
98
118
|
await queryClient.cancelQueries({ queryKey: ['bills', billId] });
|
|
99
119
|
const previousBills = snapshotNs(queryClient, 'bills');
|
|
@@ -43,7 +43,10 @@ AvroQueryClient.prototype.useUpdateCatalogItem = function () {
|
|
|
43
43
|
},
|
|
44
44
|
});
|
|
45
45
|
},
|
|
46
|
-
onMutate: async ({ catalogItemId, data }) => {
|
|
46
|
+
onMutate: async ({ catalogItemId, data: wireData }) => {
|
|
47
|
+
// Enum names and payment options are request-shaped (any case,
|
|
48
|
+
// no ids); only merge the fields stored as sent.
|
|
49
|
+
const { industry: _industry, price_format: _priceFormat, payment_options: _paymentOptions, ...data } = wireData;
|
|
47
50
|
await queryClient.cancelQueries({ queryKey: ['catalog_items'] });
|
|
48
51
|
await queryClient.cancelQueries({
|
|
49
52
|
queryKey: ['catalog_items', catalogItemId],
|
|
@@ -68,7 +68,7 @@ AvroQueryClient.prototype.useGetCurrentCompany = function () {
|
|
|
68
68
|
AvroQueryClient.prototype.useCreateCompany = function () {
|
|
69
69
|
const queryClient = this.getQueryClient();
|
|
70
70
|
return useMutation({
|
|
71
|
-
mutationFn: async ({ companyData
|
|
71
|
+
mutationFn: async ({ companyData }) => {
|
|
72
72
|
return this.post({
|
|
73
73
|
path: `/company`,
|
|
74
74
|
data: JSON.stringify(companyData),
|
|
@@ -101,7 +101,9 @@ AvroQueryClient.prototype.useUpdateCompany = function () {
|
|
|
101
101
|
queryClient.setQueryData(['/company/list'], (oldList) => {
|
|
102
102
|
if (!oldList)
|
|
103
103
|
return oldList;
|
|
104
|
-
|
|
104
|
+
// The list only carries {id, name, plan_id, balance}.
|
|
105
|
+
const { name } = companyData;
|
|
106
|
+
return oldList.map((company) => company?.id === companyId && name ? { ...company, name } : company);
|
|
105
107
|
});
|
|
106
108
|
return { previousCompany, previousCompanyList };
|
|
107
109
|
},
|
|
@@ -2,6 +2,7 @@ import { useInfiniteQuery, useQuery, useMutation } from '@tanstack/react-query';
|
|
|
2
2
|
import { AvroQueryClient } from '../QueryClient.js';
|
|
3
3
|
import { restoreNs, snapshotNs, seedDetails, removeOptimisticRow } from '../cache.js';
|
|
4
4
|
import { keys, matchesList } from '../realtime.js';
|
|
5
|
+
import { withoutEmpty } from '../wire.js';
|
|
5
6
|
import { constructEvent, DelayEvent, Job, LineItemStatus, Task, getTaskOverdueTime, } from '../../types/api.js';
|
|
6
7
|
const isJobsQuery = (q) => q.queryKey[0] === 'jobs';
|
|
7
8
|
const isEventsQuery = (q) => q.queryKey[0] === 'events';
|
|
@@ -64,11 +65,14 @@ AvroQueryClient.prototype.useCreateEvent = function () {
|
|
|
64
65
|
mutationFn: ({ eventData }) => {
|
|
65
66
|
return this.post({
|
|
66
67
|
path: `/company/${this.companyId}/event`,
|
|
67
|
-
|
|
68
|
+
// `team_id` is a UUID: '' (no team picked) is omitted.
|
|
69
|
+
data: JSON.stringify(withoutEmpty(eventData, 'team_id')),
|
|
68
70
|
headers: { 'Content-Type': 'application/json' },
|
|
69
71
|
});
|
|
70
72
|
},
|
|
71
|
-
onMutate: async ({ eventData }) => {
|
|
73
|
+
onMutate: async ({ eventData: wireEventData }) => {
|
|
74
|
+
// Wire-shaped participants must not land in cached _Event.users.
|
|
75
|
+
const { users: _wireUsers, ...eventData } = wireEventData;
|
|
72
76
|
await queryClient.cancelQueries({ queryKey: ['events'] });
|
|
73
77
|
const previousJob = queryClient.getQueryData([
|
|
74
78
|
'jobs',
|
|
@@ -77,7 +81,6 @@ AvroQueryClient.prototype.useCreateEvent = function () {
|
|
|
77
81
|
const optimisticEvent = constructEvent({
|
|
78
82
|
...eventData,
|
|
79
83
|
id: Math.random().toString(36).substring(2, 11),
|
|
80
|
-
company_id: this.companyId,
|
|
81
84
|
});
|
|
82
85
|
if (previousJob) {
|
|
83
86
|
const updatedJob = new Job({
|
|
@@ -159,7 +162,6 @@ AvroQueryClient.prototype.useCreateDelayEvent = function () {
|
|
|
159
162
|
const optimisticEvent = new DelayEvent({
|
|
160
163
|
...delayData,
|
|
161
164
|
id: Math.random().toString(36).substring(2, 11),
|
|
162
|
-
company_id: this.companyId,
|
|
163
165
|
time_started: now,
|
|
164
166
|
time_ended: now,
|
|
165
167
|
cost: 0,
|
|
@@ -244,7 +246,7 @@ AvroQueryClient.prototype.useUpdateEvent = function () {
|
|
|
244
246
|
mutationFn: ({ eventId, updates }) => {
|
|
245
247
|
return this.put({
|
|
246
248
|
path: `/event/${eventId}`,
|
|
247
|
-
data: JSON.stringify(updates),
|
|
249
|
+
data: JSON.stringify(withoutEmpty(updates, 'team_id')),
|
|
248
250
|
headers: { 'Content-Type': 'application/json' },
|
|
249
251
|
});
|
|
250
252
|
},
|