@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.
@@ -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) => {
@@ -19,6 +19,8 @@ AvroQueryClient.prototype.useGetEvents = function (body) {
19
19
  body.paid ?? true,
20
20
  body.jobId ?? '',
21
21
  body.enabled ?? true,
22
+ body.sort_by ?? null,
23
+ body.direction ?? null,
22
24
  ],
23
25
  initialPageParam: 0,
24
26
  getNextPageParam: (lastPage, allPages) => {
@@ -16,6 +16,8 @@ AvroQueryClient.prototype.useGetMonths = function (body) {
16
16
  body.paid ?? true,
17
17
  body.jobId ?? '',
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) => {
@@ -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.60";
1
+ export declare const AVRO_JS_VERSION = "0.0.62";
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // AUTO-GENERATED by scripts/gen-version.js — do not edit by hand.
2
2
  // Regenerated from package.json by the `prebuild` npm hook.
3
- export const AVRO_JS_VERSION = '0.0.60';
3
+ export const AVRO_JS_VERSION = '0.0.62';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "0.0.60",
3
+ "version": "0.0.62",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",