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