@go-avro/avro-js 0.0.2-beta.174 → 0.0.2-beta.176
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 +20 -3
- package/dist/client/QueryClient.js +19 -0
- package/dist/client/hooks/messages.js +2 -2
- package/dist/client/hooks/prepayments.d.ts +1 -0
- package/dist/client/hooks/prepayments.js +34 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- 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, ApiInfo, Avro, Bill, Break, Chat, Company, FinancialInsightData, Job, EventInsightData, LoginResponse, Message, Plan, Route, ServiceMonth, Session, Team, User, UserCompanyAssociation, Skill, Group, Label, RouteScheduleConfig, CatalogItem } from '../types/api';
|
|
4
|
+
import { _Event, ApiInfo, Avro, Bill, Break, Chat, Company, FinancialInsightData, Job, EventInsightData, LoginResponse, Message, Plan, Route, ServiceMonth, Session, Team, User, UserCompanyAssociation, Skill, Group, Label, RouteScheduleConfig, CatalogItem, Prepayment } from '../types/api';
|
|
5
5
|
import { AuthState, Tokens } from '../types/auth';
|
|
6
6
|
import { CancelToken, RetryStrategy } from '../types/client';
|
|
7
7
|
import { StandardError } from '../types/error';
|
|
@@ -63,7 +63,7 @@ declare module '../client/QueryClient' {
|
|
|
63
63
|
unknown_ids?: string[];
|
|
64
64
|
query?: string;
|
|
65
65
|
}): UseInfiniteQueryResult<InfiniteData<Chat[], unknown>, StandardError>;
|
|
66
|
-
|
|
66
|
+
useGetPrepayments(body: {
|
|
67
67
|
amt?: number;
|
|
68
68
|
known_ids?: string[];
|
|
69
69
|
unknown_ids?: string[];
|
|
@@ -71,7 +71,13 @@ declare module '../client/QueryClient' {
|
|
|
71
71
|
unbilled?: boolean;
|
|
72
72
|
billed?: boolean;
|
|
73
73
|
paid?: boolean;
|
|
74
|
-
|
|
74
|
+
taskId?: string;
|
|
75
|
+
}): UseInfiniteQueryResult<InfiniteData<Prepayment[], unknown>, StandardError>;
|
|
76
|
+
useGetMessages(chatId: string, body: {
|
|
77
|
+
amt?: number;
|
|
78
|
+
known_ids?: string[];
|
|
79
|
+
unknown_ids?: string[];
|
|
80
|
+
query?: string;
|
|
75
81
|
}): UseInfiniteQueryResult<InfiniteData<Message[], unknown>, StandardError>;
|
|
76
82
|
useGetMonths(body: {
|
|
77
83
|
amt?: number;
|
|
@@ -468,6 +474,17 @@ export declare class AvroQueryClient {
|
|
|
468
474
|
query?: string;
|
|
469
475
|
offset?: number;
|
|
470
476
|
}, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
|
|
477
|
+
fetchPrepayments(body?: {
|
|
478
|
+
amt?: number;
|
|
479
|
+
known_ids?: string[];
|
|
480
|
+
unknown_ids?: string[];
|
|
481
|
+
query?: string;
|
|
482
|
+
offset?: number;
|
|
483
|
+
unbilled?: boolean;
|
|
484
|
+
billed?: boolean;
|
|
485
|
+
paid?: boolean;
|
|
486
|
+
taskId?: string | null;
|
|
487
|
+
}, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
|
|
471
488
|
fetchEvents(body?: {
|
|
472
489
|
amt?: number;
|
|
473
490
|
known_ids?: string[];
|
|
@@ -296,6 +296,25 @@ export class AvroQueryClient {
|
|
|
296
296
|
throw new StandardError(500, 'Failed to fetch messages');
|
|
297
297
|
});
|
|
298
298
|
}
|
|
299
|
+
async fetchPrepayments(body = {}, cancelToken, headers = {}) {
|
|
300
|
+
if (!this.companyId || this.companyId.trim() === '') {
|
|
301
|
+
throw new StandardError(400, 'Company ID is required');
|
|
302
|
+
}
|
|
303
|
+
return this._fetch('POST', `/company/${this.companyId}/prepayments`, JSON.stringify(body), cancelToken, {
|
|
304
|
+
...headers,
|
|
305
|
+
'Content-Type': 'application/json',
|
|
306
|
+
})
|
|
307
|
+
.then(response => {
|
|
308
|
+
if (!response || !Array.isArray(response)) {
|
|
309
|
+
throw new StandardError(400, 'Invalid prepayments response');
|
|
310
|
+
}
|
|
311
|
+
return response;
|
|
312
|
+
})
|
|
313
|
+
.catch(err => {
|
|
314
|
+
console.error('Failed to fetch prepayments:', err);
|
|
315
|
+
throw new StandardError(500, 'Failed to fetch prepayments');
|
|
316
|
+
});
|
|
317
|
+
}
|
|
299
318
|
async fetchEvents(body = {}, cancelToken, headers = {}) {
|
|
300
319
|
if (!this.companyId || this.companyId.trim() === '') {
|
|
301
320
|
throw new StandardError(400, 'Company ID is required');
|
|
@@ -21,8 +21,8 @@ AvroQueryClient.prototype.useGetMessages = function (chatId, body) {
|
|
|
21
21
|
});
|
|
22
22
|
if (result.data) {
|
|
23
23
|
result.data.pages.forEach((data_page) => {
|
|
24
|
-
data_page.forEach((
|
|
25
|
-
queryClient.setQueryData(['
|
|
24
|
+
data_page.forEach((message) => {
|
|
25
|
+
queryClient.setQueryData(['message', message.id], message);
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
28
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useInfiniteQuery } from '@tanstack/react-query';
|
|
2
|
+
import { AvroQueryClient } from '../../client/QueryClient';
|
|
3
|
+
AvroQueryClient.prototype.useGetPrepayments = function (body) {
|
|
4
|
+
const queryClient = this.getQueryClient();
|
|
5
|
+
const result = useInfiniteQuery({
|
|
6
|
+
queryKey: [
|
|
7
|
+
'prepayments',
|
|
8
|
+
this.companyId,
|
|
9
|
+
body.amt ?? 50,
|
|
10
|
+
body.known_ids ?? [],
|
|
11
|
+
body.unknown_ids ?? [],
|
|
12
|
+
body.query ?? '',
|
|
13
|
+
body.unbilled ?? true,
|
|
14
|
+
body.billed ?? true,
|
|
15
|
+
body.paid ?? true,
|
|
16
|
+
body.taskId ?? '',
|
|
17
|
+
],
|
|
18
|
+
initialPageParam: 0,
|
|
19
|
+
getNextPageParam: (lastPage, allPages) => {
|
|
20
|
+
if (lastPage.length < (body.amt ?? 50))
|
|
21
|
+
return undefined;
|
|
22
|
+
return allPages.flat().length; // next offset
|
|
23
|
+
},
|
|
24
|
+
queryFn: ({ pageParam = 0 }) => this.fetchPrepayments({ ...body, offset: pageParam }),
|
|
25
|
+
});
|
|
26
|
+
if (result.data) {
|
|
27
|
+
result.data.pages.forEach((data_page) => {
|
|
28
|
+
data_page.forEach((prepayment) => {
|
|
29
|
+
queryClient.setQueryData(['prepayment', prepayment.id], prepayment);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ import './client/hooks/chats';
|
|
|
18
18
|
import './client/hooks/catalog_items';
|
|
19
19
|
import './client/hooks/messages';
|
|
20
20
|
import './client/hooks/plans';
|
|
21
|
+
import './client/hooks/prepayments';
|
|
21
22
|
import './client/hooks/analytics';
|
|
22
23
|
import './client/hooks/avro';
|
|
23
24
|
import './client/hooks/teams';
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,7 @@ import './client/hooks/chats';
|
|
|
18
18
|
import './client/hooks/catalog_items';
|
|
19
19
|
import './client/hooks/messages';
|
|
20
20
|
import './client/hooks/plans';
|
|
21
|
+
import './client/hooks/prepayments';
|
|
21
22
|
import './client/hooks/analytics';
|
|
22
23
|
import './client/hooks/avro';
|
|
23
24
|
import './client/hooks/teams';
|