@go-avro/avro-js 0.0.85 → 0.0.86
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 +19 -3
- package/dist/client/QueryClient.js +3 -1
- package/dist/client/hooks/bills.js +3 -2
- package/dist/client/hooks/months.js +15 -0
- package/dist/types/api/Bill.d.ts +38 -23
- package/dist/types/api/Bill.js +19 -0
- package/dist/types/api/Job.d.ts +3 -0
- package/dist/types/api/LineItem.d.ts +2 -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, AddressFeatureCollection, ApiInfo, Avro, Bill, BillInsightData, BillLineItemStatusUpdate, BillStatus, Break, Chat, CheckIn, Company, EventUpdatePayload, FinancialInsightData, RevenueInsightData, Job, EventInsightData, LoginResponse, Message, Plan, Route, ServiceMonth, Session, Team, User, UserCompanyAssociation, Skill, Group, Label, RouteScheduleConfig, RouteWritePayload, CatalogItem, Payout, Prepayment, Timecard, TimecardActionType, TimecardStatus } from '../types/api';
|
|
4
|
+
import { _Event, ActiveSessionSummary, AddressFeatureCollection, ApiInfo, Avro, Bill, BillInsightData, BillLineItemStatusUpdate, BillStatus, Break, Chat, CheckIn, Company, EventUpdatePayload, FinancialInsightData, RevenueInsightData, Job, JobUpdate, EventInsightData, LoginResponse, Message, Plan, Route, ServiceMonth, Session, Team, User, UserCompanyAssociation, Skill, Group, Label, RouteScheduleConfig, RouteWritePayload, 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';
|
|
@@ -65,6 +65,8 @@ declare module '../client/QueryClient' {
|
|
|
65
65
|
billed?: boolean;
|
|
66
66
|
paid?: boolean;
|
|
67
67
|
jobId?: string;
|
|
68
|
+
sort_by?: 'date' | 'amount' | 'name';
|
|
69
|
+
direction?: 'asc' | 'desc';
|
|
68
70
|
enabled?: boolean;
|
|
69
71
|
}): UseInfiniteQueryResult<InfiniteData<_Event[], unknown>, StandardError>;
|
|
70
72
|
useGetSessions(body: {
|
|
@@ -86,6 +88,8 @@ declare module '../client/QueryClient' {
|
|
|
86
88
|
billed?: boolean;
|
|
87
89
|
paid?: boolean;
|
|
88
90
|
taskId?: string;
|
|
91
|
+
sort_by?: 'date' | 'amount' | 'name';
|
|
92
|
+
direction?: 'asc' | 'desc';
|
|
89
93
|
enabled?: boolean;
|
|
90
94
|
}): UseInfiniteQueryResult<InfiniteData<Prepayment[], unknown>, StandardError>;
|
|
91
95
|
useGetMessages(chatId: string, body: {
|
|
@@ -103,6 +107,8 @@ declare module '../client/QueryClient' {
|
|
|
103
107
|
billed?: boolean;
|
|
104
108
|
paid?: boolean;
|
|
105
109
|
jobId?: string;
|
|
110
|
+
sort_by?: 'date' | 'amount' | 'name';
|
|
111
|
+
direction?: 'asc' | 'desc';
|
|
106
112
|
enabled?: boolean;
|
|
107
113
|
}): UseInfiniteQueryResult<InfiniteData<ServiceMonth[], unknown>, StandardError>;
|
|
108
114
|
useGetBills(body: {
|
|
@@ -117,6 +123,10 @@ declare module '../client/QueryClient' {
|
|
|
117
123
|
paid_to?: number;
|
|
118
124
|
amount_min?: number;
|
|
119
125
|
amount_max?: number;
|
|
126
|
+
/** Label guids; bills match via their events'/months' jobs. */
|
|
127
|
+
labels?: string[];
|
|
128
|
+
sort_by?: 'date' | 'amount' | 'number';
|
|
129
|
+
direction?: 'asc' | 'desc';
|
|
120
130
|
}): UseInfiniteQueryResult<InfiniteData<Bill[], unknown>, StandardError>;
|
|
121
131
|
useGetPayouts(body: {
|
|
122
132
|
amt?: number;
|
|
@@ -352,7 +362,7 @@ declare module '../client/QueryClient' {
|
|
|
352
362
|
breakData: Partial<Break>;
|
|
353
363
|
}>>;
|
|
354
364
|
useManageJobs(): ReturnType<typeof useMutation<void, StandardError, {
|
|
355
|
-
jobs:
|
|
365
|
+
jobs: JobUpdate[];
|
|
356
366
|
}>>;
|
|
357
367
|
useScheduleRoutes(): ReturnType<typeof useMutation<{
|
|
358
368
|
msg: string;
|
|
@@ -457,7 +467,7 @@ declare module '../client/QueryClient' {
|
|
|
457
467
|
msg: string;
|
|
458
468
|
}, StandardError, {
|
|
459
469
|
jobId: string;
|
|
460
|
-
updates:
|
|
470
|
+
updates: JobUpdate;
|
|
461
471
|
}>>;
|
|
462
472
|
useUpdateSkill(): ReturnType<typeof useMutation<{
|
|
463
473
|
msg: string;
|
|
@@ -496,6 +506,12 @@ declare module '../client/QueryClient' {
|
|
|
496
506
|
teamId: string;
|
|
497
507
|
teamData: Partial<Team>;
|
|
498
508
|
}>>;
|
|
509
|
+
useUpdateMonth(): ReturnType<typeof useMutation<{
|
|
510
|
+
msg: string;
|
|
511
|
+
}, StandardError, {
|
|
512
|
+
monthId: string;
|
|
513
|
+
updates: Partial<ServiceMonth>;
|
|
514
|
+
}>>;
|
|
499
515
|
useUpdateMonths(): ReturnType<typeof useMutation<void, StandardError, {
|
|
500
516
|
months: (ServiceMonth & {
|
|
501
517
|
page?: number;
|
|
@@ -2,7 +2,7 @@ import io from 'socket.io-client';
|
|
|
2
2
|
import { useMutation, useQueryClient, } from '@tanstack/react-query';
|
|
3
3
|
import { v4 as uuidv4 } from 'uuid';
|
|
4
4
|
import { fetchCensusFeatures } from '../census';
|
|
5
|
-
import { _Event, Job, LoginResponse, Route, } from '../types/api';
|
|
5
|
+
import { _Event, Bill, Job, LoginResponse, Route, } from '../types/api';
|
|
6
6
|
import { AuthState } from '../types/auth';
|
|
7
7
|
import { StandardError } from '../types/error';
|
|
8
8
|
function isBulkEvent(c) {
|
|
@@ -217,6 +217,7 @@ const SOCKET_EVENT_CONFIG = {
|
|
|
217
217
|
entityKey: 'bills',
|
|
218
218
|
action: 'create',
|
|
219
219
|
fetchPath: (id) => `/bill/${id}`,
|
|
220
|
+
construct: (d) => new Bill(d),
|
|
220
221
|
matchesQuery: matchesBillsListQuery,
|
|
221
222
|
},
|
|
222
223
|
delete_bill: { entityKey: 'bills', action: 'delete', fetchPath: null },
|
|
@@ -312,6 +313,7 @@ const SOCKET_EVENT_CONFIG = {
|
|
|
312
313
|
},
|
|
313
314
|
// ── Service Months ──
|
|
314
315
|
create_month: { entityKey: 'months', action: 'create', fetchPath: null },
|
|
316
|
+
update_month: { invalidateKeys: [['months']] },
|
|
315
317
|
update_months: { invalidateKeys: [['months']] },
|
|
316
318
|
delete_months: { invalidateKeys: [['months']] },
|
|
317
319
|
// ── Tasks (nested under jobs — target the parent job) ──
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useInfiniteQuery, useQuery, useMutation } from '@tanstack/react-query';
|
|
2
2
|
import { AvroQueryClient } from '../../client/QueryClient';
|
|
3
|
+
import { Bill } from '../../types/api';
|
|
3
4
|
AvroQueryClient.prototype.useGetBills = function (body) {
|
|
4
5
|
const queryClient = this.getQueryClient();
|
|
5
6
|
const result = useInfiniteQuery({
|
|
@@ -26,7 +27,7 @@ AvroQueryClient.prototype.useGetBills = function (body) {
|
|
|
26
27
|
return undefined;
|
|
27
28
|
return allPages.flat().length; // next offset
|
|
28
29
|
},
|
|
29
|
-
queryFn: ({ pageParam = 0 }) => this.fetchBills({ ...body, offset: pageParam }),
|
|
30
|
+
queryFn: ({ pageParam = 0 }) => this.fetchBills({ ...body, offset: pageParam }).then((bills) => bills.map((bill) => new Bill(bill))),
|
|
30
31
|
});
|
|
31
32
|
if (result.data) {
|
|
32
33
|
result.data.pages.forEach((data_page) => {
|
|
@@ -40,7 +41,7 @@ AvroQueryClient.prototype.useGetBills = function (body) {
|
|
|
40
41
|
AvroQueryClient.prototype.useGetBill = function (billId) {
|
|
41
42
|
return useQuery({
|
|
42
43
|
queryKey: ['bills', billId],
|
|
43
|
-
queryFn: () => this.get({ path: `/bill/${billId}` }),
|
|
44
|
+
queryFn: () => this.get({ path: `/bill/${billId}` }).then((bill) => new Bill(bill)),
|
|
44
45
|
enabled: Boolean(billId),
|
|
45
46
|
});
|
|
46
47
|
};
|
|
@@ -37,6 +37,21 @@ AvroQueryClient.prototype.useGetMonths = function (body) {
|
|
|
37
37
|
}
|
|
38
38
|
return result;
|
|
39
39
|
};
|
|
40
|
+
AvroQueryClient.prototype.useUpdateMonth = function () {
|
|
41
|
+
const queryClient = this.getQueryClient();
|
|
42
|
+
return useMutation({
|
|
43
|
+
mutationFn: async ({ monthId, updates, }) => {
|
|
44
|
+
return this.put({
|
|
45
|
+
path: `/month/${monthId}`,
|
|
46
|
+
data: JSON.stringify(updates),
|
|
47
|
+
headers: { 'Content-Type': 'application/json' },
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
onSuccess: () => {
|
|
51
|
+
queryClient.invalidateQueries({ queryKey: ['months'] });
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
};
|
|
40
55
|
AvroQueryClient.prototype.useUpdateMonths = function () {
|
|
41
56
|
const queryClient = this.getQueryClient();
|
|
42
57
|
return useMutation({
|
package/dist/types/api/Bill.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BillPayment } from '../../types/api/BillPayment';
|
|
2
2
|
import { BillUser } from '../../types/api/BillUser';
|
|
3
3
|
import { CustomLineItem } from '../../types/api/CustomLineItem';
|
|
4
|
+
import { LineItem } from '../../types/api/LineItem';
|
|
4
5
|
import { PaymentType } from '../../types/api/PaymentType';
|
|
5
6
|
import { ProcessingFeeLineItem } from '../../types/api/ProcessingFeeLineItem';
|
|
6
7
|
export type BillLineItem = CustomLineItem | ProcessingFeeLineItem;
|
|
@@ -11,29 +12,43 @@ export declare const BillStatus: {
|
|
|
11
12
|
readonly MANUALLY_PAID: "MANUALLY_PAID";
|
|
12
13
|
};
|
|
13
14
|
export type BillStatus = (typeof BillStatus)[keyof typeof BillStatus];
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
15
|
+
declare module '../../types/api/Bill' {
|
|
16
|
+
interface Bill {
|
|
17
|
+
id: string;
|
|
18
|
+
invoice_id: number;
|
|
19
|
+
intuit_id: string | null;
|
|
20
|
+
name: string;
|
|
21
|
+
amount: number;
|
|
22
|
+
billed_by: string;
|
|
23
|
+
customer_email: string | null;
|
|
24
|
+
manual_emails: string[][];
|
|
25
|
+
users: BillUser[];
|
|
26
|
+
status: BillStatus;
|
|
27
|
+
enabled_payment_methods: PaymentType[];
|
|
28
|
+
time_created: number;
|
|
29
|
+
time_updated: number;
|
|
30
|
+
events: string[];
|
|
31
|
+
intent_created_at: number;
|
|
32
|
+
intent_last_created_at: number;
|
|
33
|
+
payments: BillPayment[];
|
|
34
|
+
/** Every billable item on the bill, discriminated by line_item_type. */
|
|
35
|
+
line_items: LineItem[];
|
|
36
|
+
prepayments: string[];
|
|
37
|
+
months: string[];
|
|
38
|
+
due_date: number;
|
|
39
|
+
pass_on_fees: boolean;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export declare class Bill {
|
|
43
|
+
constructor(init?: Partial<Bill>);
|
|
44
|
+
/** Every distinct job label across the bill's line items. */
|
|
45
|
+
labels: () => string[];
|
|
46
|
+
/** Custom (and fee) rows only — the classic pre-unified view. */
|
|
47
|
+
customItems: () => BillLineItem[];
|
|
48
|
+
/** Top-level rows (parent_id null), in server order. */
|
|
49
|
+
topLevelItems: () => LineItem[];
|
|
50
|
+
/** Child rows of one line item, e.g. an event's additional charges. */
|
|
51
|
+
childItems: (parentId: string) => LineItem[];
|
|
37
52
|
}
|
|
38
53
|
/** Line-item kinds addressable by PUT /bill/<id>/line-items/status. */
|
|
39
54
|
export type BillLineItemStatusKind = 'event' | 'service_month' | 'prepayment' | 'line_item';
|
package/dist/types/api/Bill.js
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
|
+
import { LineItem } from '../../types/api/LineItem';
|
|
1
2
|
export const BillStatus = {
|
|
2
3
|
SENT: 'SENT',
|
|
3
4
|
PAID: 'PAID',
|
|
4
5
|
PARTIALLY_PAID: 'PARTIALLY_PAID',
|
|
5
6
|
MANUALLY_PAID: 'MANUALLY_PAID',
|
|
6
7
|
};
|
|
8
|
+
export class Bill {
|
|
9
|
+
constructor(init) {
|
|
10
|
+
/** Every distinct job label across the bill's line items. */
|
|
11
|
+
this.labels = () => [
|
|
12
|
+
...new Set((this.line_items ?? []).flatMap((item) => item.job_labels ?? [])),
|
|
13
|
+
];
|
|
14
|
+
/** Custom (and fee) rows only — the classic pre-unified view. */
|
|
15
|
+
this.customItems = () => (this.line_items ?? []).filter((item) => item.line_item_type === 'CUSTOM' || item.line_item_type === 'PROCESSING_FEE');
|
|
16
|
+
/** Top-level rows (parent_id null), in server order. */
|
|
17
|
+
this.topLevelItems = () => (this.line_items ?? []).filter((item) => !item.parent_id);
|
|
18
|
+
/** Child rows of one line item, e.g. an event's additional charges. */
|
|
19
|
+
this.childItems = (parentId) => (this.line_items ?? []).filter((item) => item.parent_id === parentId);
|
|
20
|
+
Object.assign(this, init);
|
|
21
|
+
if (init?.line_items) {
|
|
22
|
+
this.line_items = init.line_items.map((item) => new LineItem(item));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
package/dist/types/api/Job.d.ts
CHANGED
|
@@ -31,6 +31,9 @@ declare module '../../types/api/Job' {
|
|
|
31
31
|
owner: string | null;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
+
export type JobUpdate = Partial<Omit<Job, 'subscribers'>> & {
|
|
35
|
+
subscribers?: string[];
|
|
36
|
+
};
|
|
34
37
|
export declare class Job {
|
|
35
38
|
constructor(init?: Partial<Job>);
|
|
36
39
|
isOverdue: () => boolean;
|
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.86";
|
package/dist/version.js
CHANGED