@go-avro/avro-js 0.0.60 → 0.0.62
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 +16 -0
- package/dist/client/hooks/bills.js +2 -0
- package/dist/client/hooks/events.js +2 -0
- package/dist/client/hooks/months.js +2 -0
- package/dist/client/hooks/prepayments.js +2 -0
- package/dist/client/hooks/sessions.js +50 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -188,6 +188,14 @@ declare module '../client/QueryClient' {
|
|
|
188
188
|
useGetChat(chatId: string): UseQueryResult<Chat, StandardError>;
|
|
189
189
|
useGetCatalogItem(catalogItemId: string): UseQueryResult<CatalogItem, StandardError>;
|
|
190
190
|
useGetUserSessions(): UseQueryResult<Session[], StandardError>;
|
|
191
|
+
useGetCompanySessionsByIds(sessionIds: string[], params?: {
|
|
192
|
+
companyId?: string;
|
|
193
|
+
enabled?: boolean;
|
|
194
|
+
}): UseQueryResult<Session[], StandardError>;
|
|
195
|
+
useGetActiveCompanySessions(params?: {
|
|
196
|
+
companyId?: string;
|
|
197
|
+
enabled?: boolean;
|
|
198
|
+
}): UseQueryResult<Session[], StandardError>;
|
|
191
199
|
useGetCompanyTimecards(params?: {
|
|
192
200
|
companyId?: string;
|
|
193
201
|
periodStart?: number;
|
|
@@ -692,6 +700,8 @@ export declare class AvroQueryClient {
|
|
|
692
700
|
billed?: boolean;
|
|
693
701
|
paid?: boolean;
|
|
694
702
|
taskId?: string | null;
|
|
703
|
+
sort_by?: 'date' | 'amount' | 'name';
|
|
704
|
+
direction?: 'asc' | 'desc';
|
|
695
705
|
}, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
|
|
696
706
|
fetchWaivers(body?: {
|
|
697
707
|
amt?: number;
|
|
@@ -710,6 +720,8 @@ export declare class AvroQueryClient {
|
|
|
710
720
|
billed?: boolean;
|
|
711
721
|
paid?: boolean;
|
|
712
722
|
job_id?: string | null;
|
|
723
|
+
sort_by?: 'date' | 'amount' | 'name';
|
|
724
|
+
direction?: 'asc' | 'desc';
|
|
713
725
|
}, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
|
|
714
726
|
fetchMonths(body?: {
|
|
715
727
|
amt?: number;
|
|
@@ -721,6 +733,8 @@ export declare class AvroQueryClient {
|
|
|
721
733
|
billed?: boolean;
|
|
722
734
|
paid?: boolean;
|
|
723
735
|
jobId?: string | null;
|
|
736
|
+
sort_by?: 'date' | 'amount' | 'name';
|
|
737
|
+
direction?: 'asc' | 'desc';
|
|
724
738
|
}, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
|
|
725
739
|
fetchBills(body?: {
|
|
726
740
|
amt?: number;
|
|
@@ -735,6 +749,8 @@ export declare class AvroQueryClient {
|
|
|
735
749
|
paid_to?: number;
|
|
736
750
|
amount_min?: number;
|
|
737
751
|
amount_max?: number;
|
|
752
|
+
sort_by?: 'date' | 'amount' | 'number';
|
|
753
|
+
direction?: 'asc' | 'desc';
|
|
738
754
|
}, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
|
|
739
755
|
fetchPayouts(body?: {
|
|
740
756
|
amt?: number;
|
|
@@ -16,6 +16,8 @@ AvroQueryClient.prototype.useGetBills = function (body) {
|
|
|
16
16
|
body.paid_to ?? null,
|
|
17
17
|
body.amount_min ?? null,
|
|
18
18
|
body.amount_max ?? null,
|
|
19
|
+
body.sort_by ?? null,
|
|
20
|
+
body.direction ?? null,
|
|
19
21
|
],
|
|
20
22
|
initialPageParam: 0,
|
|
21
23
|
getNextPageParam: (lastPage, allPages) => {
|
|
@@ -16,6 +16,8 @@ AvroQueryClient.prototype.useGetPrepayments = function (body) {
|
|
|
16
16
|
body.paid ?? true,
|
|
17
17
|
body.taskId ?? '',
|
|
18
18
|
body.enabled ?? true,
|
|
19
|
+
body.sort_by ?? null,
|
|
20
|
+
body.direction ?? null,
|
|
19
21
|
],
|
|
20
22
|
initialPageParam: 0,
|
|
21
23
|
getNextPageParam: (lastPage, allPages) => {
|
|
@@ -7,6 +7,56 @@ AvroQueryClient.prototype.useGetUserSessions = function () {
|
|
|
7
7
|
enabled: Boolean(this.companyId),
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
AvroQueryClient.prototype.useGetCompanySessionsByIds = function (sessionIds, params = {}) {
|
|
11
|
+
const companyId = params.companyId ?? this.companyId;
|
|
12
|
+
const sortedIds = [...sessionIds].sort();
|
|
13
|
+
return useQuery({
|
|
14
|
+
queryKey: ['sessions', companyId, 'by-ids', sortedIds],
|
|
15
|
+
queryFn: async () => {
|
|
16
|
+
const amount = Math.max(sortedIds.length, 50);
|
|
17
|
+
const sessions = await this.post({
|
|
18
|
+
path: `/company/${companyId}/sessions?amount=${amount}`,
|
|
19
|
+
data: JSON.stringify({ unknown_ids: sortedIds }),
|
|
20
|
+
headers: { 'Content-Type': 'application/json' },
|
|
21
|
+
});
|
|
22
|
+
return Array.isArray(sessions) ? sessions : [];
|
|
23
|
+
},
|
|
24
|
+
enabled: Boolean(companyId) && sortedIds.length > 0 && (params.enabled ?? true),
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
AvroQueryClient.prototype.useGetActiveCompanySessions = function (params = {}) {
|
|
28
|
+
const companyId = params.companyId ?? this.companyId;
|
|
29
|
+
return useQuery({
|
|
30
|
+
queryKey: ['sessions', companyId, 'active'],
|
|
31
|
+
queryFn: async () => {
|
|
32
|
+
const pageSize = 100;
|
|
33
|
+
const maxPages = 10;
|
|
34
|
+
const knownIds = [];
|
|
35
|
+
const openSessions = [];
|
|
36
|
+
for (let page = 0; page < maxPages; page += 1) {
|
|
37
|
+
const pageSessions = await this.post({
|
|
38
|
+
path: `/company/${companyId}/sessions?amount=${pageSize}`,
|
|
39
|
+
data: JSON.stringify({ known_ids: knownIds }),
|
|
40
|
+
headers: { 'Content-Type': 'application/json' },
|
|
41
|
+
});
|
|
42
|
+
if (!Array.isArray(pageSessions) || pageSessions.length === 0)
|
|
43
|
+
break;
|
|
44
|
+
for (const session of pageSessions) {
|
|
45
|
+
const isOpen = session.time_ended == null ||
|
|
46
|
+
session.time_ended <= 0 ||
|
|
47
|
+
session.time_ended <= session.time_started;
|
|
48
|
+
if (isOpen)
|
|
49
|
+
openSessions.push(session);
|
|
50
|
+
}
|
|
51
|
+
knownIds.push(...pageSessions.map((s) => s.id).filter(Boolean));
|
|
52
|
+
if (pageSessions.length < pageSize)
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
return openSessions;
|
|
56
|
+
},
|
|
57
|
+
enabled: Boolean(companyId) && (params.enabled ?? true),
|
|
58
|
+
});
|
|
59
|
+
};
|
|
10
60
|
AvroQueryClient.prototype.useCreateUserSession = function () {
|
|
11
61
|
const queryClient = this.getQueryClient();
|
|
12
62
|
return useMutation({
|
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.62";
|
package/dist/version.js
CHANGED