@go-avro/avro-js 0.0.2-beta.35 → 0.0.2-beta.37
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/README.md +1 -0
- package/dist/client/QueryClient.d.ts +70 -5
- package/dist/client/QueryClient.js +0 -160
- package/dist/client/core/fetch.d.ts +1 -0
- package/dist/client/core/fetch.js +67 -0
- package/dist/client/core/utils.d.ts +1 -0
- package/dist/client/core/utils.js +13 -0
- package/dist/client/core/xhr.d.ts +1 -0
- package/dist/client/core/xhr.js +80 -0
- package/dist/client/hooks/bills.d.ts +1 -0
- package/dist/client/hooks/bills.js +37 -0
- package/dist/client/hooks/companies.d.ts +1 -0
- package/dist/client/hooks/companies.js +16 -0
- package/dist/client/hooks/events.d.ts +1 -0
- package/dist/client/hooks/events.js +41 -0
- package/dist/client/hooks/jobs.d.ts +1 -0
- package/dist/client/hooks/jobs.js +184 -0
- package/dist/client/hooks/months.d.ts +1 -0
- package/dist/client/hooks/months.js +34 -0
- package/dist/client/hooks/root.d.ts +1 -0
- package/dist/client/hooks/root.js +8 -0
- package/dist/client/hooks/routes.d.ts +1 -0
- package/dist/client/hooks/routes.js +31 -0
- package/dist/client/hooks/users.d.ts +1 -0
- package/dist/client/hooks/users.js +16 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/types/api.d.ts +1 -0
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ This SDK provides:
|
|
|
10
10
|
- Typed API interfaces for Avro entities (users, jobs, teams, etc.)
|
|
11
11
|
- Pluggable token storage (in-memory, localStorage, SecureStore, etc.)
|
|
12
12
|
- XHR-based requests for compatibility with React Native WebViews and older environments
|
|
13
|
+
- Mutation and Data Hooks for easy plug-in use in React and React Native projects.
|
|
13
14
|
|
|
14
15
|
## Installation
|
|
15
16
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { AuthManager } from '../auth/AuthManager';
|
|
2
|
-
import { LineItem } from '../types/api';
|
|
2
|
+
import { _Event, Bill, Company, Job, LineItem, ServiceMonth, User } from '../types/api';
|
|
3
3
|
import { CancelToken, RetryStrategy } from '../types/client';
|
|
4
|
+
import { StandardError } from '../types/error';
|
|
5
|
+
import { InfiniteData, UseInfiniteQueryResult, useMutation, useQuery, UseQueryResult } from '@tanstack/react-query';
|
|
4
6
|
export interface AvroQueryClientConfig {
|
|
5
7
|
baseUrl: string;
|
|
6
8
|
authManager: AuthManager;
|
|
@@ -8,12 +10,75 @@ export interface AvroQueryClientConfig {
|
|
|
8
10
|
retryStrategy?: RetryStrategy;
|
|
9
11
|
timeout?: number;
|
|
10
12
|
}
|
|
13
|
+
declare module '../client/QueryClient' {
|
|
14
|
+
interface AvroQueryClient {
|
|
15
|
+
_xhr<T>(method: string, path: string, body: any, cancelToken?: CancelToken, headers?: Record<string, string>, isIdempotent?: boolean, retryCount?: number): Promise<T>;
|
|
16
|
+
_fetch<T>(method: string, path: string, body: any, cancelToken?: CancelToken, headers?: Record<string, string>, isIdempotent?: boolean, retryCount?: number): Promise<T>;
|
|
17
|
+
getDelay(strategy: RetryStrategy, attempt: number): number;
|
|
18
|
+
useGetRoot(): ReturnType<typeof useQuery>;
|
|
19
|
+
useGetJobs(companyGuid: string, body: {
|
|
20
|
+
amt?: number;
|
|
21
|
+
query?: string;
|
|
22
|
+
}, total: number, onProgress?: (fraction: number) => void, isMainLoad?: boolean): UseQueryResult<Job[], StandardError>;
|
|
23
|
+
useGetRoutes(companyGuid: string, body: {
|
|
24
|
+
amt?: number;
|
|
25
|
+
query?: string;
|
|
26
|
+
}, total: number, onProgress?: (fraction: number) => void): UseQueryResult<any[], StandardError>;
|
|
27
|
+
useGetEvents(companyGuid: string, body: {
|
|
28
|
+
amt?: number;
|
|
29
|
+
known_ids?: string[];
|
|
30
|
+
unknown_ids?: string[];
|
|
31
|
+
query?: string;
|
|
32
|
+
unbilled?: boolean;
|
|
33
|
+
billed?: boolean;
|
|
34
|
+
paid?: boolean;
|
|
35
|
+
jobId?: string;
|
|
36
|
+
}): UseInfiniteQueryResult<InfiniteData<_Event[], unknown>, Error>;
|
|
37
|
+
useGetMonths(companyGuid: string, body: {
|
|
38
|
+
amt?: number;
|
|
39
|
+
known_ids?: string[];
|
|
40
|
+
unknown_ids?: string[];
|
|
41
|
+
query?: string;
|
|
42
|
+
unbilled?: boolean;
|
|
43
|
+
billed?: boolean;
|
|
44
|
+
paid?: boolean;
|
|
45
|
+
jobId?: string;
|
|
46
|
+
}): UseInfiniteQueryResult<InfiniteData<ServiceMonth[], unknown>, Error>;
|
|
47
|
+
useGetBills(companyGuid: string, body: {
|
|
48
|
+
amt?: number;
|
|
49
|
+
known_ids?: string[];
|
|
50
|
+
unknown_ids?: string[];
|
|
51
|
+
query?: string;
|
|
52
|
+
paid?: boolean;
|
|
53
|
+
}): UseInfiniteQueryResult<InfiniteData<Bill[], unknown>, Error>;
|
|
54
|
+
useGetCompanies(options?: {}): UseQueryResult<{
|
|
55
|
+
name: string;
|
|
56
|
+
id: string;
|
|
57
|
+
}[], StandardError>;
|
|
58
|
+
useGetCompany(companyId: string): UseQueryResult<Company, StandardError>;
|
|
59
|
+
useGetJob(jobId: string): UseQueryResult<Job, StandardError>;
|
|
60
|
+
useGetEvent(eventId: string): UseQueryResult<_Event, StandardError>;
|
|
61
|
+
useGetUser(userId: string): UseQueryResult<User, StandardError>;
|
|
62
|
+
useGetSelf(): UseQueryResult<User, StandardError>;
|
|
63
|
+
useGetBill(billId: string): UseQueryResult<Bill, StandardError>;
|
|
64
|
+
useUpdateJob(): ReturnType<typeof useMutation<unknown, unknown, {
|
|
65
|
+
jobId: string;
|
|
66
|
+
updates: Partial<Job>;
|
|
67
|
+
}, unknown>>;
|
|
68
|
+
useDeleteJob(): ReturnType<typeof useMutation<unknown, unknown, {
|
|
69
|
+
jobId: string;
|
|
70
|
+
}, unknown>>;
|
|
71
|
+
useCreateJob(): ReturnType<typeof useMutation<{
|
|
72
|
+
id: string;
|
|
73
|
+
}, unknown, {
|
|
74
|
+
companyId: string;
|
|
75
|
+
jobData: Partial<Job>;
|
|
76
|
+
}, unknown>>;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
11
79
|
export declare class AvroQueryClient {
|
|
12
|
-
|
|
80
|
+
protected config: Required<AvroQueryClientConfig>;
|
|
13
81
|
constructor(config: AvroQueryClientConfig);
|
|
14
|
-
getDelay(strategy: RetryStrategy, attempt: number): number;
|
|
15
|
-
private _xhr;
|
|
16
|
-
private _fetch;
|
|
17
82
|
get<T>(path: string, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<T>;
|
|
18
83
|
post<T>(path: string, data: any, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<T>;
|
|
19
84
|
put<T>(path: string, data: any, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<T>;
|
|
@@ -9,166 +9,6 @@ export class AvroQueryClient {
|
|
|
9
9
|
timeout: config.timeout ?? 0,
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
getDelay(strategy, attempt) {
|
|
13
|
-
if (typeof strategy === 'function') {
|
|
14
|
-
return strategy(attempt);
|
|
15
|
-
}
|
|
16
|
-
else if (strategy === 'fixed') {
|
|
17
|
-
return 1000;
|
|
18
|
-
}
|
|
19
|
-
else if (strategy === 'exponential') {
|
|
20
|
-
return Math.pow(2, attempt) * 100;
|
|
21
|
-
}
|
|
22
|
-
throw new Error(`Invalid retry strategy: ${strategy}`);
|
|
23
|
-
}
|
|
24
|
-
_xhr(method, path, body, cancelToken, headers = {}, isIdempotent = false, retryCount = 0) {
|
|
25
|
-
const checkCancelled = () => {
|
|
26
|
-
if (cancelToken?.isCancelled()) {
|
|
27
|
-
return new StandardError(0, 'Request cancelled');
|
|
28
|
-
}
|
|
29
|
-
return null;
|
|
30
|
-
};
|
|
31
|
-
return new Promise((resolve, reject) => {
|
|
32
|
-
this.config.authManager.accessToken().then(token => {
|
|
33
|
-
const cancelErr = checkCancelled();
|
|
34
|
-
if (cancelErr)
|
|
35
|
-
return reject(cancelErr);
|
|
36
|
-
const xhr = new XMLHttpRequest();
|
|
37
|
-
const url = this.config.baseUrl + path;
|
|
38
|
-
xhr.open(method, url, true);
|
|
39
|
-
if (token) {
|
|
40
|
-
xhr.setRequestHeader('Authorization', `Bearer ${token}`);
|
|
41
|
-
}
|
|
42
|
-
Object.entries(headers).forEach(([key, value]) => {
|
|
43
|
-
xhr.setRequestHeader(key, value);
|
|
44
|
-
});
|
|
45
|
-
xhr.onload = () => {
|
|
46
|
-
const cancelErr = checkCancelled();
|
|
47
|
-
if (cancelErr)
|
|
48
|
-
return reject(cancelErr);
|
|
49
|
-
if (xhr.status === 401 && this.config.authManager.refreshTokens && retryCount === 0) {
|
|
50
|
-
this.config.authManager
|
|
51
|
-
.refreshTokens()
|
|
52
|
-
.then(() => {
|
|
53
|
-
this._xhr(method, path, body, cancelToken, headers, isIdempotent, retryCount + 1).then(resolve, reject);
|
|
54
|
-
})
|
|
55
|
-
.catch(() => {
|
|
56
|
-
reject(new StandardError(401, 'Unauthorized (refresh failed)'));
|
|
57
|
-
});
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
if (xhr.status >= 200 && xhr.status < 300) {
|
|
61
|
-
try {
|
|
62
|
-
resolve(JSON.parse(xhr.responseText));
|
|
63
|
-
}
|
|
64
|
-
catch {
|
|
65
|
-
resolve(xhr.responseText);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
if (retryCount < this.config.maxRetries) {
|
|
70
|
-
const delay = this.getDelay(this.config.retryStrategy, retryCount);
|
|
71
|
-
setTimeout(() => {
|
|
72
|
-
this._xhr(method, path, body, cancelToken, headers, isIdempotent, retryCount + 1).then(resolve, reject);
|
|
73
|
-
}, delay);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
let msg = xhr.statusText;
|
|
77
|
-
try {
|
|
78
|
-
const parsed = JSON.parse(xhr.responseText);
|
|
79
|
-
msg = parsed.msg || msg;
|
|
80
|
-
}
|
|
81
|
-
catch {
|
|
82
|
-
console.warn('Failed to parse error response:', xhr.responseText);
|
|
83
|
-
}
|
|
84
|
-
reject(new StandardError(xhr.status, msg));
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
xhr.onerror = () => {
|
|
89
|
-
if (retryCount < this.config.maxRetries) {
|
|
90
|
-
const delay = this.getDelay(this.config.retryStrategy, retryCount);
|
|
91
|
-
setTimeout(() => {
|
|
92
|
-
this._xhr(method, path, body, cancelToken, headers, isIdempotent, retryCount + 1).then(resolve, reject);
|
|
93
|
-
}, delay);
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
reject(new StandardError(0, 'Network Error'));
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
if (this.config.timeout) {
|
|
100
|
-
xhr.timeout = this.config.timeout;
|
|
101
|
-
xhr.ontimeout = () => reject(new StandardError(0, 'Request timed out'));
|
|
102
|
-
}
|
|
103
|
-
xhr.send(body);
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
_fetch(method, path, body, cancelToken, headers = {}, isIdempotent = false, retryCount = 0) {
|
|
108
|
-
const checkCancelled = () => {
|
|
109
|
-
try {
|
|
110
|
-
if (cancelToken?.isCancelled()) {
|
|
111
|
-
return new StandardError(0, 'Request cancelled');
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
catch (error) {
|
|
115
|
-
throw new StandardError(0, `Error checking cancellation (${typeof cancelToken}): ${error}`);
|
|
116
|
-
}
|
|
117
|
-
return null;
|
|
118
|
-
};
|
|
119
|
-
return this.config.authManager.accessToken().then(token => {
|
|
120
|
-
const cancelErr = checkCancelled();
|
|
121
|
-
if (cancelErr)
|
|
122
|
-
return Promise.reject(cancelErr);
|
|
123
|
-
const url = this.config.baseUrl + path;
|
|
124
|
-
const requestHeaders = {
|
|
125
|
-
'Content-Type': 'application/json',
|
|
126
|
-
...headers,
|
|
127
|
-
};
|
|
128
|
-
if (token) {
|
|
129
|
-
requestHeaders['Authorization'] = `Bearer ${token}`;
|
|
130
|
-
}
|
|
131
|
-
const options = {
|
|
132
|
-
method,
|
|
133
|
-
headers: requestHeaders,
|
|
134
|
-
body: body ? JSON.stringify(body) : null,
|
|
135
|
-
};
|
|
136
|
-
return fetch(url, options).then(response => {
|
|
137
|
-
if (response.status === 401 && this.config.authManager.refreshTokens && retryCount === 0) {
|
|
138
|
-
return this.config.authManager
|
|
139
|
-
.refreshTokens()
|
|
140
|
-
.then(() => this._fetch(method, path, body, cancelToken, headers, isIdempotent, retryCount + 1))
|
|
141
|
-
.catch(() => Promise.reject(new StandardError(401, 'Unauthorized (refresh failed)')));
|
|
142
|
-
}
|
|
143
|
-
if (!response.ok) {
|
|
144
|
-
if (retryCount < this.config.maxRetries) {
|
|
145
|
-
const delay = this.getDelay(this.config.retryStrategy, retryCount);
|
|
146
|
-
return new Promise((resolve, reject) => {
|
|
147
|
-
setTimeout(() => {
|
|
148
|
-
this._fetch(method, path, body, cancelToken, headers, isIdempotent, retryCount + 1)
|
|
149
|
-
.then(resolve)
|
|
150
|
-
.catch(reject);
|
|
151
|
-
}, delay);
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
return response.text().then(text => {
|
|
156
|
-
let msg = response.statusText;
|
|
157
|
-
try {
|
|
158
|
-
const parsed = JSON.parse(text);
|
|
159
|
-
msg = parsed.message || msg;
|
|
160
|
-
}
|
|
161
|
-
catch {
|
|
162
|
-
console.warn('Failed to parse error response:', text);
|
|
163
|
-
}
|
|
164
|
-
throw new StandardError(response.status, msg);
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
return response.json();
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
12
|
get(path, cancelToken, headers = {}) {
|
|
173
13
|
return this._xhr('GET', path, null, cancelToken, headers, true);
|
|
174
14
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { AvroQueryClient } from '../../client/QueryClient';
|
|
2
|
+
import { StandardError } from '../../types/error';
|
|
3
|
+
AvroQueryClient.prototype._fetch = function (method, path, body, cancelToken, headers = {}, isIdempotent = false, retryCount = 0) {
|
|
4
|
+
const checkCancelled = () => {
|
|
5
|
+
try {
|
|
6
|
+
if (cancelToken?.isCancelled()) {
|
|
7
|
+
return new StandardError(0, 'Request cancelled');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
throw new StandardError(0, `Error checking cancellation (${typeof cancelToken}): ${error}`);
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
};
|
|
15
|
+
return this.config.authManager.accessToken().then(token => {
|
|
16
|
+
const cancelErr = checkCancelled();
|
|
17
|
+
if (cancelErr)
|
|
18
|
+
return Promise.reject(cancelErr);
|
|
19
|
+
const url = this.config.baseUrl + path;
|
|
20
|
+
const requestHeaders = {
|
|
21
|
+
'Content-Type': 'application/json',
|
|
22
|
+
...headers,
|
|
23
|
+
};
|
|
24
|
+
if (token) {
|
|
25
|
+
requestHeaders['Authorization'] = `Bearer ${token}`;
|
|
26
|
+
}
|
|
27
|
+
const options = {
|
|
28
|
+
method,
|
|
29
|
+
headers: requestHeaders,
|
|
30
|
+
body: body ? JSON.stringify(body) : null,
|
|
31
|
+
};
|
|
32
|
+
return fetch(url, options).then(response => {
|
|
33
|
+
if (response.status === 401 && this.config.authManager.refreshTokens && retryCount === 0) {
|
|
34
|
+
return this.config.authManager
|
|
35
|
+
.refreshTokens()
|
|
36
|
+
.then(() => this._fetch(method, path, body, cancelToken, headers, isIdempotent, retryCount + 1))
|
|
37
|
+
.catch(() => Promise.reject(new StandardError(401, 'Unauthorized (refresh failed)')));
|
|
38
|
+
}
|
|
39
|
+
if (!response.ok) {
|
|
40
|
+
if (retryCount < this.config.maxRetries) {
|
|
41
|
+
const delay = this.getDelay(this.config.retryStrategy, retryCount);
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
setTimeout(() => {
|
|
44
|
+
this._fetch(method, path, body, cancelToken, headers, isIdempotent, retryCount + 1)
|
|
45
|
+
.then(resolve)
|
|
46
|
+
.catch(reject);
|
|
47
|
+
}, delay);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return response.text().then(text => {
|
|
52
|
+
let msg = response.statusText;
|
|
53
|
+
try {
|
|
54
|
+
const parsed = JSON.parse(text);
|
|
55
|
+
msg = parsed.message || msg;
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
console.warn('Failed to parse error response:', text);
|
|
59
|
+
}
|
|
60
|
+
throw new StandardError(response.status, msg);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return response.json();
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AvroQueryClient } from '../../client/QueryClient';
|
|
2
|
+
AvroQueryClient.prototype.getDelay = function (strategy, attempt) {
|
|
3
|
+
if (typeof strategy === 'function') {
|
|
4
|
+
return strategy(attempt);
|
|
5
|
+
}
|
|
6
|
+
else if (strategy === 'fixed') {
|
|
7
|
+
return 1000;
|
|
8
|
+
}
|
|
9
|
+
else if (strategy === 'exponential') {
|
|
10
|
+
return Math.pow(2, attempt) * 100;
|
|
11
|
+
}
|
|
12
|
+
throw new Error(`Invalid retry strategy: ${strategy}`);
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { AvroQueryClient } from '../../client/QueryClient';
|
|
2
|
+
import { StandardError } from '../../types/error';
|
|
3
|
+
AvroQueryClient.prototype._xhr = function (method, path, body, cancelToken, headers = {}, isIdempotent = false, retryCount = 0) {
|
|
4
|
+
const checkCancelled = () => {
|
|
5
|
+
if (cancelToken?.isCancelled()) {
|
|
6
|
+
return new StandardError(0, 'Request cancelled');
|
|
7
|
+
}
|
|
8
|
+
return null;
|
|
9
|
+
};
|
|
10
|
+
return new Promise((resolve, reject) => {
|
|
11
|
+
this.config.authManager.accessToken().then(token => {
|
|
12
|
+
const cancelErr = checkCancelled();
|
|
13
|
+
if (cancelErr)
|
|
14
|
+
return reject(cancelErr);
|
|
15
|
+
const xhr = new XMLHttpRequest();
|
|
16
|
+
const url = this.config.baseUrl + path;
|
|
17
|
+
xhr.open(method, url, true);
|
|
18
|
+
if (token)
|
|
19
|
+
xhr.setRequestHeader('Authorization', `Bearer ${token}`);
|
|
20
|
+
Object.entries(headers).forEach(([key, value]) => xhr.setRequestHeader(key, value));
|
|
21
|
+
xhr.onload = () => {
|
|
22
|
+
const cancelErr = checkCancelled();
|
|
23
|
+
if (cancelErr)
|
|
24
|
+
return reject(cancelErr);
|
|
25
|
+
if (xhr.status === 401 && this.config.authManager.refreshTokens && retryCount === 0) {
|
|
26
|
+
this.config.authManager
|
|
27
|
+
.refreshTokens()
|
|
28
|
+
.then(() => {
|
|
29
|
+
this._xhr(method, path, body, cancelToken, headers, isIdempotent, retryCount + 1).then(resolve, reject);
|
|
30
|
+
})
|
|
31
|
+
.catch(() => reject(new StandardError(401, 'Unauthorized (refresh failed)')));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
35
|
+
try {
|
|
36
|
+
resolve(JSON.parse(xhr.responseText));
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
resolve(xhr.responseText);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
if (retryCount < this.config.maxRetries) {
|
|
44
|
+
const delay = this.getDelay(this.config.retryStrategy, retryCount);
|
|
45
|
+
setTimeout(() => {
|
|
46
|
+
this._xhr(method, path, body, cancelToken, headers, isIdempotent, retryCount + 1).then(resolve, reject);
|
|
47
|
+
}, delay);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
let msg = xhr.statusText;
|
|
51
|
+
try {
|
|
52
|
+
const parsed = JSON.parse(xhr.responseText);
|
|
53
|
+
msg = parsed.msg || msg;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
console.warn('Failed to parse error response:', xhr.responseText);
|
|
57
|
+
}
|
|
58
|
+
reject(new StandardError(xhr.status, msg));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
xhr.onerror = () => {
|
|
63
|
+
if (retryCount < this.config.maxRetries) {
|
|
64
|
+
const delay = this.getDelay(this.config.retryStrategy, retryCount);
|
|
65
|
+
setTimeout(() => {
|
|
66
|
+
this._xhr(method, path, body, cancelToken, headers, isIdempotent, retryCount + 1).then(resolve, reject);
|
|
67
|
+
}, delay);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
reject(new StandardError(0, 'Network Error'));
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
if (this.config.timeout) {
|
|
74
|
+
xhr.timeout = this.config.timeout;
|
|
75
|
+
xhr.ontimeout = () => reject(new StandardError(0, 'Request timed out'));
|
|
76
|
+
}
|
|
77
|
+
xhr.send(body);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AvroQueryClient } from '../../client/QueryClient';
|
|
2
|
+
import { useQueryClient, useInfiniteQuery, useQuery } from '@tanstack/react-query';
|
|
3
|
+
AvroQueryClient.prototype.useGetBills = function (companyGuid, body) {
|
|
4
|
+
const queryClient = useQueryClient();
|
|
5
|
+
const result = useInfiniteQuery({
|
|
6
|
+
queryKey: [
|
|
7
|
+
'bills',
|
|
8
|
+
companyGuid,
|
|
9
|
+
body.query ?? "",
|
|
10
|
+
body.known_ids ?? [],
|
|
11
|
+
body.unknown_ids ?? [],
|
|
12
|
+
body.paid ?? false,
|
|
13
|
+
],
|
|
14
|
+
initialPageParam: 0,
|
|
15
|
+
getNextPageParam: (lastPage, allPages) => {
|
|
16
|
+
if (lastPage.length < (body.amt ?? 50))
|
|
17
|
+
return undefined;
|
|
18
|
+
return allPages.flat().length; // next offset
|
|
19
|
+
},
|
|
20
|
+
queryFn: ({ pageParam = 0 }) => this.fetchBills(companyGuid, { ...body, offset: pageParam }),
|
|
21
|
+
});
|
|
22
|
+
if (result.data) {
|
|
23
|
+
result.data.pages.forEach((data_page) => {
|
|
24
|
+
data_page.forEach((bill) => {
|
|
25
|
+
queryClient.setQueryData(['bill', bill.id], bill);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
31
|
+
AvroQueryClient.prototype.useGetBill = function (billId) {
|
|
32
|
+
return useQuery({
|
|
33
|
+
queryKey: ['bill', billId],
|
|
34
|
+
queryFn: () => this.get(`/bill/${billId}`),
|
|
35
|
+
enabled: Boolean(billId),
|
|
36
|
+
});
|
|
37
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AvroQueryClient } from '../../client/QueryClient';
|
|
2
|
+
import { useQuery } from '@tanstack/react-query';
|
|
3
|
+
AvroQueryClient.prototype.useGetCompanies = function (options = {}) {
|
|
4
|
+
return useQuery({
|
|
5
|
+
queryKey: ['/company/list'],
|
|
6
|
+
queryFn: () => this.get('/company/list'),
|
|
7
|
+
...options,
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
AvroQueryClient.prototype.useGetCompany = function (companyId) {
|
|
11
|
+
return useQuery({
|
|
12
|
+
queryKey: ['company', companyId],
|
|
13
|
+
queryFn: () => this.get(`/company/${companyId}`),
|
|
14
|
+
enabled: Boolean(companyId),
|
|
15
|
+
});
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AvroQueryClient } from '../../client/QueryClient';
|
|
2
|
+
import { useQueryClient, useInfiniteQuery, useQuery } from '@tanstack/react-query';
|
|
3
|
+
AvroQueryClient.prototype.useGetEvents = function (companyGuid, body) {
|
|
4
|
+
const queryClient = useQueryClient();
|
|
5
|
+
const result = useInfiniteQuery({
|
|
6
|
+
queryKey: [
|
|
7
|
+
'events',
|
|
8
|
+
companyGuid,
|
|
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.jobId ?? '',
|
|
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.fetchEvents(companyGuid, { ...body, offset: pageParam }),
|
|
25
|
+
});
|
|
26
|
+
if (result.data) {
|
|
27
|
+
result.data.pages.forEach((data_page) => {
|
|
28
|
+
data_page.forEach((event) => {
|
|
29
|
+
queryClient.setQueryData(['event', event.id], event);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
AvroQueryClient.prototype.useGetEvent = function (eventId) {
|
|
36
|
+
return useQuery({
|
|
37
|
+
queryKey: ['event', eventId],
|
|
38
|
+
queryFn: () => this.get(`/event/${eventId}`),
|
|
39
|
+
enabled: Boolean(eventId),
|
|
40
|
+
});
|
|
41
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { AvroQueryClient } from '../../client/QueryClient';
|
|
2
|
+
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
3
|
+
AvroQueryClient.prototype.useGetJobs = function (companyGuid, body, total = 0, onProgress, isMainLoad = false) {
|
|
4
|
+
const queryClient = useQueryClient();
|
|
5
|
+
return useQuery({
|
|
6
|
+
queryKey: [isMainLoad ? 'main' : 'jobs', companyGuid, body.amt ?? 50, body.query ?? ""],
|
|
7
|
+
queryFn: async () => {
|
|
8
|
+
if (total === 0) {
|
|
9
|
+
onProgress?.(1);
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
onProgress?.(0);
|
|
13
|
+
const pageCount = body.amt ? Math.ceil(total / body.amt) : 0;
|
|
14
|
+
let completed = 0;
|
|
15
|
+
const promises = Array.from({ length: pageCount }, (_, i) => this.fetchJobs(companyGuid, {
|
|
16
|
+
...body,
|
|
17
|
+
offset: i * (body.amt ?? 0),
|
|
18
|
+
}));
|
|
19
|
+
const trackedPromises = promises.map((promise) => promise.then((result) => {
|
|
20
|
+
completed++;
|
|
21
|
+
const fraction = completed / pageCount;
|
|
22
|
+
onProgress?.(fraction);
|
|
23
|
+
return result;
|
|
24
|
+
}));
|
|
25
|
+
const pages = await Promise.all(trackedPromises);
|
|
26
|
+
const jobs = pages.flat();
|
|
27
|
+
jobs.forEach((job) => {
|
|
28
|
+
job.last_event = job.tasks.reduce((latest, task) => {
|
|
29
|
+
return task.last_event && (!latest || task.last_event.time_started > latest.time_started) ? task.last_event : latest;
|
|
30
|
+
}, null);
|
|
31
|
+
job.last_completed_event = job.tasks.reduce((latest, task) => {
|
|
32
|
+
return task.last_completed_event && (!latest || task.last_completed_event.time_started > latest.time_started) ? task.last_completed_event : latest;
|
|
33
|
+
}, null);
|
|
34
|
+
job.overdue_time = job.tasks.reduce((maxOverdue, task) => {
|
|
35
|
+
return task.overdue_time && task.overdue_time > maxOverdue ? task.overdue_time : maxOverdue;
|
|
36
|
+
}, 0);
|
|
37
|
+
queryClient.setQueryData(['job', job.id], job);
|
|
38
|
+
});
|
|
39
|
+
if (isMainLoad) {
|
|
40
|
+
queryClient.setQueryData(['jobs', companyGuid, body.amt ?? 50, body.query ?? ""], jobs);
|
|
41
|
+
}
|
|
42
|
+
return jobs;
|
|
43
|
+
},
|
|
44
|
+
enabled: Boolean(companyGuid) && companyGuid.length > 0 && Boolean(total) && total >= 0,
|
|
45
|
+
...isMainLoad ? { staleTime: Infinity, cacheTime: Infinity } : {},
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
AvroQueryClient.prototype.useGetJob = function (jobId) {
|
|
49
|
+
return useQuery({
|
|
50
|
+
queryKey: ['job', jobId],
|
|
51
|
+
queryFn: () => this.get(`/job/${jobId}`),
|
|
52
|
+
enabled: Boolean(jobId),
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
AvroQueryClient.prototype.useCreateJob = function () {
|
|
56
|
+
const queryClient = useQueryClient();
|
|
57
|
+
return useMutation({
|
|
58
|
+
mutationFn: ({ companyId, jobData }) => {
|
|
59
|
+
return this.post(`/company/${companyId}/job`, JSON.stringify(jobData), undefined, {
|
|
60
|
+
"Content-Type": "application/json",
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
onMutate: async ({ companyId, jobData }) => {
|
|
64
|
+
await queryClient.cancelQueries({ queryKey: ['jobs'] });
|
|
65
|
+
const previousJobs = queryClient.getQueryData(['jobs']);
|
|
66
|
+
queryClient.setQueryData(['jobs'], (oldData) => {
|
|
67
|
+
if (!oldData)
|
|
68
|
+
return [jobData];
|
|
69
|
+
if (oldData.pages) {
|
|
70
|
+
const firstPage = oldData.pages[0] || [];
|
|
71
|
+
return {
|
|
72
|
+
...oldData,
|
|
73
|
+
pages: [[jobData, ...firstPage], ...oldData.pages.slice(1)],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
if (Array.isArray(oldData)) {
|
|
77
|
+
return [jobData, ...oldData];
|
|
78
|
+
}
|
|
79
|
+
return oldData;
|
|
80
|
+
});
|
|
81
|
+
return { previousJobs };
|
|
82
|
+
},
|
|
83
|
+
onError: (err, variables, context) => {
|
|
84
|
+
if (context?.previousJobs) {
|
|
85
|
+
queryClient.setQueryData(['jobs'], context.previousJobs);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
onSettled: (data, error, variables) => {
|
|
89
|
+
const { id: jobId } = data ?? {};
|
|
90
|
+
queryClient.invalidateQueries({ queryKey: ['jobs'] });
|
|
91
|
+
queryClient.invalidateQueries({ queryKey: ['job', jobId] });
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
AvroQueryClient.prototype.useUpdateJob = function () {
|
|
96
|
+
const queryClient = useQueryClient();
|
|
97
|
+
return useMutation({
|
|
98
|
+
mutationFn: ({ jobId, updates }) => {
|
|
99
|
+
return this.put(`/job/${jobId}`, JSON.stringify(updates), undefined, {
|
|
100
|
+
"Content-Type": "application/json",
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
onMutate: async ({ jobId, updates }) => {
|
|
104
|
+
await queryClient.cancelQueries({ queryKey: ['jobs'] });
|
|
105
|
+
await queryClient.cancelQueries({ queryKey: ['job', jobId] });
|
|
106
|
+
const previousJobs = queryClient.getQueryData(['jobs']);
|
|
107
|
+
const previousJob = queryClient.getQueryData(['job', jobId]);
|
|
108
|
+
queryClient.setQueryData(['job', jobId], (oldData) => oldData ? { ...oldData, ...updates } : undefined);
|
|
109
|
+
queryClient.setQueriesData({ queryKey: ['jobs'] }, (oldData) => {
|
|
110
|
+
if (!oldData)
|
|
111
|
+
return oldData;
|
|
112
|
+
if (oldData.pages) {
|
|
113
|
+
return {
|
|
114
|
+
...oldData,
|
|
115
|
+
pages: oldData.pages.map((page) => page.map((job) => job.id === jobId ? { ...job, ...updates } : job)),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
if (Array.isArray(oldData)) {
|
|
119
|
+
return oldData.map((job) => job.id === jobId ? { ...job, ...updates } : job);
|
|
120
|
+
}
|
|
121
|
+
return oldData;
|
|
122
|
+
});
|
|
123
|
+
return { previousJobs, previousJob };
|
|
124
|
+
},
|
|
125
|
+
onError: (err, variables, context) => {
|
|
126
|
+
const { jobId } = variables;
|
|
127
|
+
if (context?.previousJobs) {
|
|
128
|
+
queryClient.setQueryData(['jobs'], context.previousJobs);
|
|
129
|
+
}
|
|
130
|
+
if (context?.previousJob) {
|
|
131
|
+
queryClient.setQueryData(['job', jobId], context.previousJob);
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
onSettled: (data, error, variables) => {
|
|
135
|
+
const { jobId } = variables;
|
|
136
|
+
queryClient.invalidateQueries({ queryKey: ['jobs'] });
|
|
137
|
+
queryClient.invalidateQueries({ queryKey: ['job', jobId] });
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
AvroQueryClient.prototype.useDeleteJob = function () {
|
|
142
|
+
const queryClient = useQueryClient();
|
|
143
|
+
return useMutation({
|
|
144
|
+
mutationFn: async ({ jobId }) => {
|
|
145
|
+
return this.delete(`/job/${jobId}`, undefined, {
|
|
146
|
+
"Content-Type": "application/json",
|
|
147
|
+
});
|
|
148
|
+
},
|
|
149
|
+
onMutate: async ({ jobId }) => {
|
|
150
|
+
await queryClient.cancelQueries({ queryKey: ['jobs'] });
|
|
151
|
+
await queryClient.cancelQueries({ queryKey: ['job', jobId] });
|
|
152
|
+
const previousJobs = queryClient.getQueryData(['jobs']);
|
|
153
|
+
const previousJob = queryClient.getQueryData(['job', jobId]);
|
|
154
|
+
queryClient.setQueryData(['job', jobId], undefined);
|
|
155
|
+
queryClient.setQueriesData({ queryKey: ['jobs'] }, (oldData) => {
|
|
156
|
+
if (!oldData)
|
|
157
|
+
return oldData;
|
|
158
|
+
if (oldData.pages) {
|
|
159
|
+
const updatedPages = oldData.pages.map((page) => page.filter((job) => job.id !== jobId));
|
|
160
|
+
return { ...oldData, pages: updatedPages };
|
|
161
|
+
}
|
|
162
|
+
if (Array.isArray(oldData)) {
|
|
163
|
+
return oldData.filter((job) => job.id !== jobId);
|
|
164
|
+
}
|
|
165
|
+
return oldData;
|
|
166
|
+
});
|
|
167
|
+
return { previousJobs, previousJob };
|
|
168
|
+
},
|
|
169
|
+
onError: (_err, variables, context) => {
|
|
170
|
+
const { jobId } = variables;
|
|
171
|
+
if (context?.previousJobs) {
|
|
172
|
+
queryClient.setQueryData(['jobs'], context.previousJobs);
|
|
173
|
+
}
|
|
174
|
+
if (context?.previousJob) {
|
|
175
|
+
queryClient.setQueryData(['job', jobId], context.previousJob);
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
onSettled: (_data, _error, variables) => {
|
|
179
|
+
const { jobId } = variables;
|
|
180
|
+
queryClient.invalidateQueries({ queryKey: ['jobs'] });
|
|
181
|
+
queryClient.invalidateQueries({ queryKey: ['job', jobId] });
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { AvroQueryClient } from '../../client/QueryClient';
|
|
2
|
+
import { useQueryClient, useInfiniteQuery } from '@tanstack/react-query';
|
|
3
|
+
AvroQueryClient.prototype.useGetMonths = function (companyGuid, body) {
|
|
4
|
+
const queryClient = useQueryClient();
|
|
5
|
+
const result = useInfiniteQuery({
|
|
6
|
+
queryKey: [
|
|
7
|
+
'months',
|
|
8
|
+
companyGuid,
|
|
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.jobId ?? '',
|
|
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.fetchMonths(companyGuid, { ...body, offset: pageParam }),
|
|
25
|
+
});
|
|
26
|
+
if (result.data) {
|
|
27
|
+
result.data.pages.forEach((data_page) => {
|
|
28
|
+
data_page.forEach((month) => {
|
|
29
|
+
queryClient.setQueryData(['month', month.id], month);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AvroQueryClient } from '../../client/QueryClient';
|
|
2
|
+
import { useQuery } from '@tanstack/react-query';
|
|
3
|
+
AvroQueryClient.prototype.useGetRoot = function () {
|
|
4
|
+
return useQuery({
|
|
5
|
+
queryKey: ['health'],
|
|
6
|
+
queryFn: () => this.get('/', undefined) // your async fetch function
|
|
7
|
+
});
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AvroQueryClient } from '../../client/QueryClient';
|
|
2
|
+
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
3
|
+
AvroQueryClient.prototype.useGetRoutes = function (companyGuid, body, total = 0, onProgress) {
|
|
4
|
+
const queryClient = useQueryClient();
|
|
5
|
+
return useQuery({
|
|
6
|
+
queryKey: ['routes', companyGuid, body.amt ?? 50, body.query ?? ""],
|
|
7
|
+
queryFn: async () => {
|
|
8
|
+
if (total === 0) {
|
|
9
|
+
onProgress?.(1);
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
onProgress?.(0);
|
|
13
|
+
const pageCount = body.amt ? Math.ceil(total / body.amt) : 0;
|
|
14
|
+
let completed = 0;
|
|
15
|
+
const promises = Array.from({ length: pageCount }, (_, i) => this.fetchRoutes(companyGuid, {
|
|
16
|
+
...body,
|
|
17
|
+
offset: i * (body.amt ?? 0),
|
|
18
|
+
}));
|
|
19
|
+
const trackedPromises = promises.map((promise) => promise.then((result) => {
|
|
20
|
+
completed++;
|
|
21
|
+
const fraction = completed / pageCount;
|
|
22
|
+
onProgress?.(fraction);
|
|
23
|
+
return result;
|
|
24
|
+
}));
|
|
25
|
+
const pages = await Promise.all(trackedPromises);
|
|
26
|
+
const routes = pages.flat();
|
|
27
|
+
return routes;
|
|
28
|
+
},
|
|
29
|
+
enabled: Boolean(companyGuid) && companyGuid.length > 0 && Boolean(total) && total >= 0,
|
|
30
|
+
});
|
|
31
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AvroQueryClient } from "../../client/QueryClient";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
AvroQueryClient.prototype.useGetUser = function (userId) {
|
|
4
|
+
return useQuery({
|
|
5
|
+
queryKey: ['user', userId],
|
|
6
|
+
queryFn: () => this.get(`/user/${userId}`),
|
|
7
|
+
enabled: Boolean(userId),
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
AvroQueryClient.prototype.useGetSelf = function () {
|
|
11
|
+
return useQuery({
|
|
12
|
+
queryKey: ['user'],
|
|
13
|
+
queryFn: () => this.get(`/user`),
|
|
14
|
+
enabled: Boolean(this),
|
|
15
|
+
});
|
|
16
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
export { AvroQueryClientConfig, AvroQueryClient } from './client/QueryClient';
|
|
2
2
|
export { AuthManager } from './auth/AuthManager';
|
|
3
3
|
export { MemoryStorage, LocalStorage } from './auth/storage';
|
|
4
|
+
import './client/core/xhr';
|
|
5
|
+
import './client/core/fetch';
|
|
6
|
+
import './client/core/utils';
|
|
7
|
+
import './client/hooks/root';
|
|
8
|
+
import './client/hooks/jobs';
|
|
9
|
+
import './client/hooks/routes';
|
|
10
|
+
import './client/hooks/events';
|
|
11
|
+
import './client/hooks/months';
|
|
12
|
+
import './client/hooks/bills';
|
|
13
|
+
import './client/hooks/companies';
|
|
4
14
|
export * from './types/api';
|
|
5
15
|
export * from './types/error';
|
|
6
16
|
export * from './types/client';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
export { AvroQueryClient } from './client/QueryClient';
|
|
2
2
|
export { AuthManager } from './auth/AuthManager';
|
|
3
3
|
export { MemoryStorage, LocalStorage } from './auth/storage';
|
|
4
|
+
import './client/core/xhr';
|
|
5
|
+
import './client/core/fetch';
|
|
6
|
+
import './client/core/utils';
|
|
7
|
+
import './client/hooks/root';
|
|
8
|
+
import './client/hooks/jobs';
|
|
9
|
+
import './client/hooks/routes';
|
|
10
|
+
import './client/hooks/events';
|
|
11
|
+
import './client/hooks/months';
|
|
12
|
+
import './client/hooks/bills';
|
|
13
|
+
import './client/hooks/companies';
|
|
4
14
|
export * from './types/api';
|
|
5
15
|
export * from './types/error';
|
|
6
16
|
export * from './types/client';
|
package/dist/types/api.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@go-avro/avro-js",
|
|
3
|
-
"version": "0.0.2-beta.
|
|
3
|
+
"version": "0.0.2-beta.37",
|
|
4
4
|
"description": "JS client for Avro backend integration.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"license": "CC-BY-SA-4.0",
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/jest": "^29.0.0",
|
|
36
|
+
"@types/react": "^19.2.2",
|
|
36
37
|
"@typescript-eslint/eslint-plugin": "^8.38.0",
|
|
37
38
|
"@typescript-eslint/parser": "^8.38.0",
|
|
38
39
|
"eslint": "^8.57.1",
|
|
@@ -50,5 +51,8 @@
|
|
|
50
51
|
],
|
|
51
52
|
"publishConfig": {
|
|
52
53
|
"access": "public"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@tanstack/react-query": "^5.90.2"
|
|
53
57
|
}
|
|
54
58
|
}
|