@go-avro/avro-js 0.0.2-beta.13 → 0.0.2-beta.131

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.
Files changed (53) hide show
  1. package/README.md +1 -0
  2. package/dist/auth/AuthManager.d.ts +12 -3
  3. package/dist/auth/AuthManager.js +56 -12
  4. package/dist/auth/storage.d.ts +8 -8
  5. package/dist/auth/storage.js +12 -10
  6. package/dist/client/QueryClient.d.ts +409 -15
  7. package/dist/client/QueryClient.js +343 -203
  8. package/dist/client/core/fetch.d.ts +1 -0
  9. package/dist/client/core/fetch.js +62 -0
  10. package/dist/client/core/utils.d.ts +1 -0
  11. package/dist/client/core/utils.js +14 -0
  12. package/dist/client/core/xhr.d.ts +1 -0
  13. package/dist/client/core/xhr.js +84 -0
  14. package/dist/client/hooks/analytics.d.ts +1 -0
  15. package/dist/client/hooks/analytics.js +26 -0
  16. package/dist/client/hooks/avro.d.ts +1 -0
  17. package/dist/client/hooks/avro.js +9 -0
  18. package/dist/client/hooks/bills.d.ts +1 -0
  19. package/dist/client/hooks/bills.js +165 -0
  20. package/dist/client/hooks/chats.d.ts +1 -0
  21. package/dist/client/hooks/chats.js +37 -0
  22. package/dist/client/hooks/companies.d.ts +1 -0
  23. package/dist/client/hooks/companies.js +137 -0
  24. package/dist/client/hooks/events.d.ts +1 -0
  25. package/dist/client/hooks/events.js +308 -0
  26. package/dist/client/hooks/jobs.d.ts +1 -0
  27. package/dist/client/hooks/jobs.js +215 -0
  28. package/dist/client/hooks/messages.d.ts +1 -0
  29. package/dist/client/hooks/messages.js +30 -0
  30. package/dist/client/hooks/months.d.ts +1 -0
  31. package/dist/client/hooks/months.js +93 -0
  32. package/dist/client/hooks/plans.d.ts +1 -0
  33. package/dist/client/hooks/plans.js +8 -0
  34. package/dist/client/hooks/root.d.ts +1 -0
  35. package/dist/client/hooks/root.js +8 -0
  36. package/dist/client/hooks/routes.d.ts +1 -0
  37. package/dist/client/hooks/routes.js +167 -0
  38. package/dist/client/hooks/sessions.d.ts +1 -0
  39. package/dist/client/hooks/sessions.js +175 -0
  40. package/dist/client/hooks/skills.d.ts +1 -0
  41. package/dist/client/hooks/skills.js +123 -0
  42. package/dist/client/hooks/teams.d.ts +1 -0
  43. package/dist/client/hooks/teams.js +128 -0
  44. package/dist/client/hooks/users.d.ts +1 -0
  45. package/dist/client/hooks/users.js +104 -0
  46. package/dist/index.d.ts +22 -1
  47. package/dist/index.js +22 -1
  48. package/dist/types/api.d.ts +124 -32
  49. package/dist/types/api.js +10 -1
  50. package/dist/types/auth.d.ts +0 -5
  51. package/dist/types/cache.d.ts +9 -0
  52. package/dist/types/cache.js +1 -0
  53. package/package.json +6 -4
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,15 +1,24 @@
1
- import { TokenStorage, Tokens } from '../types/auth';
1
+ import { Tokens } from '../types/auth';
2
+ import { Cache, CacheData } from '../types/cache';
2
3
  export declare class AuthManager {
3
4
  private storages;
4
5
  private baseUrl;
6
+ private tokenRefreshedCallbacks;
7
+ private tokenRefreshFailedCallbacks;
5
8
  constructor({ baseUrl, storage, }: {
6
9
  baseUrl: string;
7
- storage: TokenStorage | TokenStorage[];
10
+ storage: Cache | Cache[];
8
11
  });
9
12
  isAuthenticated(): Promise<boolean>;
10
13
  fetchNewTokens(): Promise<Tokens>;
11
14
  accessToken(): Promise<string | undefined>;
15
+ onTokenRefreshed(callback: (accessToken: string) => void): void;
16
+ onTokenRefreshFailed(callback: () => void): void;
12
17
  refreshTokens(): Promise<Tokens | null>;
13
18
  setTokens(tokens: Tokens): Promise<void>;
14
- clearTokens(): Promise<void>;
19
+ setCache(data: Partial<CacheData>): Promise<void>;
20
+ getCache(key?: keyof CacheData): Promise<CacheData | string | null>;
21
+ clearCache(): Promise<void>;
22
+ getCompanyId(): Promise<string | null>;
23
+ setCompanyId(companyId: string): Promise<void[]>;
15
24
  }
@@ -1,5 +1,8 @@
1
+ import { StandardError } from '../types/error';
1
2
  export class AuthManager {
2
3
  constructor({ baseUrl, storage, }) {
4
+ this.tokenRefreshedCallbacks = [];
5
+ this.tokenRefreshFailedCallbacks = [];
3
6
  this.storages = Array.isArray(storage) ? storage : [storage];
4
7
  if (this.storages.length === 0) {
5
8
  throw new Error('At least one token storage must be provided');
@@ -16,14 +19,14 @@ export class AuthManager {
16
19
  throw new Error('No token storages initialized');
17
20
  }
18
21
  for (const storage of this.storages) {
19
- const tokens = await storage.get();
20
- if (tokens && tokens.access_token) {
22
+ const cache = await storage.get();
23
+ if (cache && typeof cache !== 'string' && cache.access_token) {
21
24
  try {
22
25
  const response = await fetch(`${this.baseUrl}/validate`, {
23
26
  method: 'POST',
24
27
  headers: {
25
28
  'Content-Type': 'application/json',
26
- 'Authorization': `Bearer ${tokens.access_token}`,
29
+ 'Authorization': `Bearer ${cache.access_token}`,
27
30
  },
28
31
  });
29
32
  if (response.ok) {
@@ -53,8 +56,8 @@ export class AuthManager {
53
56
  }
54
57
  async fetchNewTokens() {
55
58
  for (const storage of this.storages) {
56
- const tokens = await storage.get();
57
- if (!tokens || !tokens.refresh_token)
59
+ const cache = await storage.get();
60
+ if (!cache || typeof cache === 'string' || !cache.refresh_token)
58
61
  continue;
59
62
  try {
60
63
  const response = await fetch(`${this.baseUrl}/refresh`, {
@@ -62,7 +65,7 @@ export class AuthManager {
62
65
  headers: {
63
66
  'Content-Type': 'application/json',
64
67
  'Accept': 'application/json',
65
- 'Authorization': `Bearer ${tokens.refresh_token}`,
68
+ 'Authorization': `Bearer ${cache.refresh_token}`,
66
69
  },
67
70
  });
68
71
  if (response.ok) {
@@ -74,35 +77,76 @@ export class AuthManager {
74
77
  storage.clear();
75
78
  }
76
79
  }
77
- throw new Error('Failed to refresh tokens from all storages');
80
+ throw new StandardError(410, 'Failed to refresh tokens from all storages');
78
81
  }
79
82
  async accessToken() {
80
83
  if (!this.storages.length) {
81
84
  throw new Error('No token storages initialized');
82
85
  }
83
86
  for (const storage of this.storages) {
84
- const token = await storage.get();
85
- if (token)
86
- return token.access_token;
87
+ const cache = await storage.get();
88
+ if (cache && typeof cache !== 'string' && cache.access_token)
89
+ return cache.access_token;
87
90
  }
88
91
  const newToken = await this.refreshTokens();
89
92
  return newToken?.access_token;
90
93
  }
94
+ onTokenRefreshed(callback) {
95
+ this.tokenRefreshedCallbacks.push(callback);
96
+ }
97
+ onTokenRefreshFailed(callback) {
98
+ this.tokenRefreshFailedCallbacks.push(callback);
99
+ }
91
100
  async refreshTokens() {
92
101
  try {
93
102
  const newToken = await this.fetchNewTokens();
94
103
  await Promise.all(this.storages.map(s => s.set(newToken)));
104
+ this.tokenRefreshedCallbacks.forEach(cb => {
105
+ if (newToken?.access_token)
106
+ cb(newToken.access_token);
107
+ });
95
108
  return newToken;
96
109
  }
97
110
  catch (error) {
98
- console.error('Failed to refresh tokens:', error);
111
+ this.tokenRefreshFailedCallbacks.forEach(cb => cb());
112
+ if (error?.status !== 410) {
113
+ console.error('Failed to refresh tokens:', error);
114
+ }
99
115
  return null;
100
116
  }
101
117
  }
102
118
  async setTokens(tokens) {
103
119
  await Promise.all(this.storages.map(s => s.set(tokens)));
104
120
  }
105
- async clearTokens() {
121
+ async setCache(data) {
122
+ await Promise.all(this.storages.map(s => s.set(data)));
123
+ }
124
+ async getCache(key) {
125
+ if (!this.storages.length) {
126
+ return null;
127
+ }
128
+ for (const storage of this.storages) {
129
+ const cache = await storage.get(key);
130
+ if (cache)
131
+ return cache;
132
+ }
133
+ return null;
134
+ }
135
+ async clearCache() {
106
136
  await Promise.all(this.storages.map(s => s.clear()));
107
137
  }
138
+ async getCompanyId() {
139
+ if (!this.storages.length) {
140
+ return null;
141
+ }
142
+ for (const storage of this.storages) {
143
+ const companyId = await storage.get('companyId');
144
+ if (companyId && typeof companyId === 'string')
145
+ return companyId;
146
+ }
147
+ return null;
148
+ }
149
+ async setCompanyId(companyId) {
150
+ return Promise.all(this.storages.map(s => s.set({ companyId })));
151
+ }
108
152
  }
@@ -1,13 +1,13 @@
1
- import { Tokens, TokenStorage } from '../types/auth';
2
- export declare class MemoryStorage implements TokenStorage {
3
- private tokens;
4
- get(): Promise<Tokens | null>;
5
- set(tokens: Tokens): Promise<void>;
1
+ import { Cache, CacheData } from '../types/cache';
2
+ export declare class MemoryStorage implements Cache {
3
+ private data;
4
+ get(key?: keyof CacheData): Promise<CacheData | string | null>;
5
+ set(data: Partial<CacheData>): Promise<void>;
6
6
  clear(): Promise<void>;
7
7
  }
8
- export declare class LocalStorage implements TokenStorage {
8
+ export declare class LocalStorage implements Cache {
9
9
  private key;
10
- get(): Promise<Tokens | null>;
11
- set(tokens: Tokens): Promise<void>;
10
+ get(key?: string): Promise<CacheData | null>;
11
+ set(data: Partial<CacheData>): Promise<void>;
12
12
  clear(): Promise<void>;
13
13
  }
@@ -1,27 +1,29 @@
1
1
  export class MemoryStorage {
2
2
  constructor() {
3
- this.tokens = null;
3
+ this.data = null;
4
4
  }
5
- async get() {
6
- return this.tokens ? this.tokens : null;
5
+ async get(key) {
6
+ return this.data ? key ? this.data[key] ?? null : this.data : null;
7
7
  }
8
- async set(tokens) {
9
- this.tokens = tokens;
8
+ async set(data) {
9
+ this.data = { ...this.data, ...data };
10
10
  }
11
11
  async clear() {
12
- this.tokens = null;
12
+ this.data = null;
13
13
  }
14
14
  }
15
15
  export class LocalStorage {
16
16
  constructor() {
17
- this.key = 'auth_tokens';
17
+ this.key = 'cache_data';
18
18
  }
19
- async get() {
19
+ async get(key) {
20
20
  const item = localStorage.getItem(this.key);
21
21
  return item ? JSON.parse(item) : null;
22
22
  }
23
- async set(tokens) {
24
- localStorage.setItem(this.key, JSON.stringify(tokens));
23
+ async set(data) {
24
+ const current = await this.get() || {};
25
+ const updated = { ...current, ...data };
26
+ localStorage.setItem(this.key, JSON.stringify(updated));
25
27
  }
26
28
  async clear() {
27
29
  localStorage.removeItem(this.key);
@@ -1,28 +1,422 @@
1
+ import { Socket } from 'socket.io-client';
2
+ import { InfiniteData, QueryClient, UseInfiniteQueryResult, useMutation, UseQueryResult } from '@tanstack/react-query';
1
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 } from '../types/api';
5
+ import { Tokens } from '../types/auth';
2
6
  import { CancelToken, RetryStrategy } from '../types/client';
7
+ import { StandardError } from '../types/error';
8
+ import { CacheData } from '../types/cache';
3
9
  export interface AvroQueryClientConfig {
4
10
  baseUrl: string;
5
11
  authManager: AuthManager;
12
+ queryClient: QueryClient;
6
13
  maxRetries?: number;
7
14
  retryStrategy?: RetryStrategy;
8
15
  timeout?: number;
9
16
  }
17
+ declare module '../client/QueryClient' {
18
+ interface AvroQueryClient {
19
+ _xhr<T>(method: string, path: string, body: any, cancelToken?: CancelToken, headers?: Record<string, string>, isIdempotent?: boolean, retryCount?: number, progressUpdateCallback?: (loaded: number, total: number) => void): Promise<T>;
20
+ _fetch<T>(method: string, path: string, body: any, cancelToken?: CancelToken, headers?: Record<string, string>, isIdempotent?: boolean, retryCount?: number): Promise<T>;
21
+ getDelay(strategy: RetryStrategy, attempt: number): number;
22
+ sleep(ms: number): Promise<void>;
23
+ useGetRoot(): UseQueryResult<ApiInfo, StandardError>;
24
+ useGetJobs(onProgress?: (fraction: number) => void): UseQueryResult<Job[], StandardError>;
25
+ getJobsFromCache(): Job[];
26
+ useGetInfiniteJobs(body: {
27
+ amt?: number;
28
+ query?: string;
29
+ routeId?: string;
30
+ }): UseInfiniteQueryResult<InfiniteData<Job[], unknown>, StandardError>;
31
+ useGetRoutes(body: {
32
+ amt?: number;
33
+ query?: string;
34
+ }, total: number, onProgress?: (fraction: number) => void): UseQueryResult<Route[], StandardError>;
35
+ useGetTeams(body: {
36
+ amt?: number;
37
+ query?: string;
38
+ }, total: number, onProgress?: (fraction: number) => void): UseQueryResult<Team[], StandardError>;
39
+ useGetSkills(body: {
40
+ amt?: number;
41
+ query?: string;
42
+ }, total: number, onProgress?: (fraction: number) => void): UseQueryResult<Skill[], StandardError>;
43
+ useGetEvents(body: {
44
+ amt?: number;
45
+ known_ids?: string[];
46
+ unknown_ids?: string[];
47
+ query?: string;
48
+ unbilled?: boolean;
49
+ billed?: boolean;
50
+ paid?: boolean;
51
+ jobId?: string;
52
+ }): UseInfiniteQueryResult<InfiniteData<_Event[], unknown>, StandardError>;
53
+ useGetSessions(body: {
54
+ amt?: number;
55
+ query?: string;
56
+ }): UseInfiniteQueryResult<InfiniteData<Session[], unknown>, StandardError>;
57
+ useGetChats(body: {
58
+ amt?: number;
59
+ known_ids?: string[];
60
+ unknown_ids?: string[];
61
+ query?: string;
62
+ }): UseInfiniteQueryResult<InfiniteData<Chat[], unknown>, StandardError>;
63
+ useGetMessages(chatId: string, body: {
64
+ amt?: number;
65
+ known_ids?: string[];
66
+ unknown_ids?: string[];
67
+ query?: string;
68
+ unbilled?: boolean;
69
+ billed?: boolean;
70
+ paid?: boolean;
71
+ jobId?: string;
72
+ }): UseInfiniteQueryResult<InfiniteData<Message[], unknown>, StandardError>;
73
+ useGetMonths(body: {
74
+ amt?: number;
75
+ known_ids?: string[];
76
+ unknown_ids?: string[];
77
+ query?: string;
78
+ unbilled?: boolean;
79
+ billed?: boolean;
80
+ paid?: boolean;
81
+ jobId?: string;
82
+ }): UseInfiniteQueryResult<InfiniteData<ServiceMonth[], unknown>, StandardError>;
83
+ useGetBills(body: {
84
+ amt?: number;
85
+ known_ids?: string[];
86
+ unknown_ids?: string[];
87
+ query?: string;
88
+ paid?: boolean;
89
+ }): UseInfiniteQueryResult<InfiniteData<Bill[], unknown>, StandardError>;
90
+ useGetPlans(code: string): UseQueryResult<Plan[], StandardError>;
91
+ useGetCompanies(options?: {}): UseQueryResult<Company[], StandardError>;
92
+ useGetAnalytics(): UseQueryResult<any, StandardError>;
93
+ useFinanceAnalytics({ periods, cumulative }: {
94
+ periods: number[][];
95
+ cumulative: boolean;
96
+ }): UseQueryResult<FinancialInsightData[], StandardError>;
97
+ useEventAnalytics({ periods }: {
98
+ periods: number[][];
99
+ }): UseQueryResult<EventInsightData[], StandardError>;
100
+ useGetCompany(companyId: string): UseQueryResult<Company, StandardError>;
101
+ useGetCurrentCompany(): UseQueryResult<Company, StandardError>;
102
+ useGetJob(jobId: string): UseQueryResult<Job, StandardError>;
103
+ useGetEvent(eventId: string): UseQueryResult<_Event, StandardError>;
104
+ useGetUser(userId: string): UseQueryResult<User, StandardError>;
105
+ useGetSelf(): UseQueryResult<User, StandardError>;
106
+ useGetBill(billId: string): UseQueryResult<Bill, StandardError>;
107
+ useGetRoute(routeId: string): UseQueryResult<Route, StandardError>;
108
+ useGetChat(chatId: string): UseQueryResult<Chat, StandardError>;
109
+ useGetUserSessions(): UseQueryResult<Session[], StandardError>;
110
+ useGetAvro(): UseQueryResult<Avro, StandardError>;
111
+ useSearchUsers(searchUsername: string): UseQueryResult<User[], StandardError>;
112
+ useCreateSkill(): ReturnType<typeof useMutation<{
113
+ id: string;
114
+ }, StandardError, {
115
+ skillData: Partial<Skill>;
116
+ }>>;
117
+ useCreateEvent(): ReturnType<typeof useMutation<{
118
+ id: string;
119
+ }, StandardError, {
120
+ eventData: Partial<_Event>;
121
+ }>>;
122
+ useCreateUserSession(): ReturnType<typeof useMutation<{
123
+ id: string;
124
+ }, StandardError, {
125
+ sessionData: Partial<Session>;
126
+ }>>;
127
+ useCreateBill(): ReturnType<typeof useMutation<{
128
+ id: string;
129
+ invoice_id: number;
130
+ }, StandardError, {
131
+ data: Partial<Bill>;
132
+ }>>;
133
+ useCreateCompany(): ReturnType<typeof useMutation<{
134
+ id: string;
135
+ }, StandardError, {
136
+ companyData: Partial<Company | {
137
+ logo: File | null;
138
+ }>;
139
+ }>>;
140
+ useCreateJob(): ReturnType<typeof useMutation<{
141
+ id: string;
142
+ }, StandardError, {
143
+ jobData: Partial<Job>;
144
+ }>>;
145
+ useCreateRoute(): ReturnType<typeof useMutation<{
146
+ id: string;
147
+ }, StandardError, {
148
+ routeData: Partial<Route>;
149
+ }>>;
150
+ useCreateTeam(): ReturnType<typeof useMutation<{
151
+ id: string;
152
+ }, StandardError, {
153
+ teamData: Partial<Team>;
154
+ }>>;
155
+ useCreateSelf(): ReturnType<typeof useMutation<{
156
+ msg: string;
157
+ }, StandardError, {
158
+ username: string;
159
+ name: string;
160
+ email: string;
161
+ password: string;
162
+ phone_number: string;
163
+ code?: string;
164
+ invite_token?: string;
165
+ }>>;
166
+ useCreateSessionBreak(): ReturnType<typeof useMutation<{
167
+ id: string;
168
+ }, StandardError, {
169
+ sessionId: string;
170
+ breakData: Partial<Break>;
171
+ }>>;
172
+ useUpdateEvent(): ReturnType<typeof useMutation<{
173
+ msg: string;
174
+ }, StandardError, {
175
+ eventId: string;
176
+ updates: Partial<_Event>;
177
+ }>>;
178
+ useSyncBillToIntuit(): ReturnType<typeof useMutation<{
179
+ msg: string;
180
+ }, StandardError, {
181
+ billId: string;
182
+ }>>;
183
+ useUpdateUserSession(): ReturnType<typeof useMutation<{
184
+ msg: string;
185
+ }, StandardError, {
186
+ sessionId: string;
187
+ updates: Partial<Session>;
188
+ }>>;
189
+ useUpdateJob(): ReturnType<typeof useMutation<{
190
+ msg: string;
191
+ }, StandardError, {
192
+ jobId: string;
193
+ updates: Partial<Job>;
194
+ }>>;
195
+ useUpdateSkill(): ReturnType<typeof useMutation<{
196
+ msg: string;
197
+ }, StandardError, {
198
+ skillId: string;
199
+ updates: Partial<Skill>;
200
+ }>>;
201
+ useUpdateBill(): ReturnType<typeof useMutation<{
202
+ msg: string;
203
+ }, StandardError, {
204
+ billId: string;
205
+ updates: Partial<Bill>;
206
+ }>>;
207
+ useUpdateRoute(): ReturnType<typeof useMutation<{
208
+ msg: string;
209
+ }, StandardError, {
210
+ routeId: string;
211
+ updates: Partial<Route>;
212
+ }>>;
213
+ useUpdateEvents(): ReturnType<typeof useMutation<void, StandardError, {
214
+ events: (_Event & {
215
+ page?: number;
216
+ })[];
217
+ action: "billed" | "paid";
218
+ }>>;
219
+ useUpdateTeam(): ReturnType<typeof useMutation<{
220
+ msg: string;
221
+ }, StandardError, {
222
+ teamId: string;
223
+ teamData: Partial<Team>;
224
+ }>>;
225
+ useUpdateMonths(): ReturnType<typeof useMutation<void, StandardError, {
226
+ months: (ServiceMonth & {
227
+ page?: number;
228
+ })[];
229
+ action: "billed" | "paid";
230
+ }>>;
231
+ useUpdateUserCompany(): ReturnType<typeof useMutation<{
232
+ msg: string;
233
+ }, StandardError, {
234
+ user_id: string;
235
+ data: Partial<UserCompanyAssociation>;
236
+ }>>;
237
+ useUpdateSessionBreak(): ReturnType<typeof useMutation<{
238
+ msg: string;
239
+ }, StandardError, {
240
+ breakId: string;
241
+ updates: Partial<Break>;
242
+ }>>;
243
+ useDeleteJob(): ReturnType<typeof useMutation<{
244
+ msg: string;
245
+ }, StandardError, {
246
+ jobId: string;
247
+ }>>;
248
+ useUpdateCompany(): ReturnType<typeof useMutation<{
249
+ msg: string;
250
+ }, StandardError, {
251
+ companyId: string;
252
+ companyData: Partial<Company | {
253
+ logo: File | null;
254
+ }>;
255
+ }>>;
256
+ useRemoveUserCompany(): ReturnType<typeof useMutation<{
257
+ msg: string;
258
+ }, StandardError, {
259
+ userId: string;
260
+ }>>;
261
+ useDeleteEvent(): ReturnType<typeof useMutation<{
262
+ msg: string;
263
+ }, StandardError, {
264
+ eventId: string;
265
+ }>>;
266
+ useDeleteBill(): ReturnType<typeof useMutation<{
267
+ msg: string;
268
+ }, StandardError, {
269
+ billId: string;
270
+ }>>;
271
+ useDeleteRoute(): ReturnType<typeof useMutation<{
272
+ msg: string;
273
+ }, StandardError, {
274
+ routeId: string;
275
+ }>>;
276
+ useDeleteSkill(): ReturnType<typeof useMutation<{
277
+ msg: string;
278
+ }, StandardError, {
279
+ skillId: string;
280
+ }>>;
281
+ useDeleteSelf(): ReturnType<typeof useMutation<{
282
+ msg: string;
283
+ }, StandardError, void>>;
284
+ useDeleteCompany(): ReturnType<typeof useMutation<{
285
+ msg: string;
286
+ }, StandardError, {
287
+ companyId: string;
288
+ }>>;
289
+ useDeleteTeam(): ReturnType<typeof useMutation<{
290
+ msg: string;
291
+ }, StandardError, {
292
+ teamId: string;
293
+ }>>;
294
+ }
295
+ }
10
296
  export declare class AvroQueryClient {
11
- private config;
297
+ protected config: Required<AvroQueryClientConfig>;
298
+ readonly socket: Socket;
299
+ _isAuthenticated: boolean;
300
+ companyId: string | null;
301
+ company: Company | null;
12
302
  constructor(config: AvroQueryClientConfig);
13
- getDelay(strategy: RetryStrategy, attempt: number): number;
14
- private _xhr;
15
- private _fetch;
16
- get<T>(path: string, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<T>;
17
- post<T>(path: string, data: any, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<T>;
18
- put<T>(path: string, data: any, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<T>;
19
- delete<T>(path: string, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<T>;
20
- login(data: {
303
+ emit(eventName: string, data: unknown): void;
304
+ on<T>(eventName: string, callback: (data: T) => void): void;
305
+ off(eventName: string, callback?: Function): void;
306
+ get<T>(path: string, cancelToken?: CancelToken, headers?: Record<string, string>, progressUpdateCallback?: (loaded: number, total: number) => void): Promise<T>;
307
+ post<T>(path: string, data: any, cancelToken?: CancelToken, headers?: Record<string, string>, progressUpdateCallback?: (loaded: number, total: number) => void): Promise<T>;
308
+ put<T>(path: string, data: any, cancelToken?: CancelToken, headers?: Record<string, string>, progressUpdateCallback?: (loaded: number, total: number) => void): Promise<T>;
309
+ delete<T>(path: string, cancelToken?: CancelToken, headers?: Record<string, string>, progressUpdateCallback?: (loaded: number, total: number) => void): Promise<T>;
310
+ useLogin(): ReturnType<typeof useMutation<LoginResponse, StandardError, {
21
311
  username: string;
22
- password: string;
23
- }, cancelToken?: CancelToken): Promise<Boolean>;
24
- logout(cancelToken?: CancelToken): Promise<void>;
25
- fetchJobs(companyGuid: string, amt?: number, knownIds?: string[], unknownIds?: string[], keyword?: string, offset?: number, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
26
- fetchEvents(companyGuid: string, amt?: number, knownIds?: string[], unknownIds?: string[], keyword?: string, offset?: number, unbilled?: boolean, billed?: boolean, paid?: boolean, jobId?: string | null, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
27
- fetchBills(companyGuid: string, amt?: number, known_ids?: string[], unknown_ids?: string[], keyword?: string, offset?: number, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
312
+ password?: string;
313
+ code?: string;
314
+ cancelToken?: CancelToken;
315
+ }>>;
316
+ useRequestCode(): ReturnType<typeof useMutation<{
317
+ msg: string;
318
+ }, StandardError, {
319
+ username?: string;
320
+ email?: string;
321
+ cancelToken?: CancelToken;
322
+ }>>;
323
+ useUpdatePassword(): ReturnType<typeof useMutation<void, StandardError, {
324
+ username?: string;
325
+ email?: string;
326
+ code: string;
327
+ newPassword: string;
328
+ cancelToken?: CancelToken;
329
+ }>>;
330
+ useGoogleLogin(): ReturnType<typeof useMutation<LoginResponse, StandardError, {
331
+ token: string;
332
+ cancelToken?: CancelToken;
333
+ }>>;
334
+ setTokens(tokens: Tokens): Promise<void>;
335
+ setCache(data: Partial<CacheData>): Promise<void>;
336
+ getCache(key?: keyof CacheData | undefined): Promise<CacheData | string | null>;
337
+ setCompanyId(companyId: string): Promise<void[]>;
338
+ clearCache(): Promise<void>;
339
+ isAuthenticated(): boolean;
340
+ isAuthenticatedAsync(): Promise<boolean>;
341
+ getQueryClient(): QueryClient;
342
+ useLogout(): ReturnType<typeof useMutation<void, StandardError, CancelToken | undefined>>;
343
+ fetchJobs(body?: {
344
+ amt?: number;
345
+ known_ids?: string[];
346
+ unknown_ids?: string[];
347
+ query?: string;
348
+ offset?: number;
349
+ route_id?: string;
350
+ }, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
351
+ fetchChats(body?: {
352
+ amt?: number;
353
+ known_ids?: string[];
354
+ unknown_ids?: string[];
355
+ query?: string;
356
+ offset?: number;
357
+ }, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
358
+ fetchMessages(chatId: string, body?: {
359
+ amt?: number;
360
+ known_ids?: string[];
361
+ unknown_ids?: string[];
362
+ query?: string;
363
+ offset?: number;
364
+ }, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
365
+ fetchEvents(body?: {
366
+ amt?: number;
367
+ known_ids?: string[];
368
+ unknown_ids?: string[];
369
+ query?: string;
370
+ offset?: number;
371
+ unbilled?: boolean;
372
+ billed?: boolean;
373
+ paid?: boolean;
374
+ jobId?: string | null;
375
+ }, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
376
+ fetchMonths(body?: {
377
+ amt?: number;
378
+ known_ids?: string[];
379
+ unknown_ids?: string[];
380
+ query?: string;
381
+ offset?: number;
382
+ unbilled?: boolean;
383
+ billed?: boolean;
384
+ paid?: boolean;
385
+ jobId?: string | null;
386
+ }, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
387
+ fetchBills(body?: {
388
+ amt?: number;
389
+ known_ids?: string[];
390
+ unknown_ids?: string[];
391
+ query?: string;
392
+ offset?: number;
393
+ paid?: boolean;
394
+ }, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
395
+ fetchRoutes(body?: {
396
+ amt?: number;
397
+ known_ids?: string[];
398
+ unknown_ids?: string[];
399
+ query?: string;
400
+ offset?: number;
401
+ }, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
402
+ fetchTeams(body?: {
403
+ amt?: number;
404
+ known_ids?: string[];
405
+ unknown_ids?: string[];
406
+ query?: string;
407
+ offset?: number;
408
+ }, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
409
+ fetchSkills(body?: {
410
+ amt?: number;
411
+ known_ids?: string[];
412
+ unknown_ids?: string[];
413
+ query?: string;
414
+ offset?: number;
415
+ }, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
416
+ fetchSessions(body?: {
417
+ amt?: number;
418
+ query?: string;
419
+ offset?: number;
420
+ }, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
421
+ sendEmail(emailId: string, formData: FormData, progressUpdateCallback?: (loaded: number, total: number) => void): Promise<void>;
28
422
  }