@go-avro/avro-js 0.0.2-beta.12 → 0.0.2-beta.120
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 +12 -3
- package/dist/auth/AuthManager.js +56 -12
- package/dist/auth/storage.d.ts +8 -8
- package/dist/auth/storage.js +12 -10
- package/dist/client/QueryClient.d.ts +385 -15
- package/dist/client/QueryClient.js +323 -203
- 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 +26 -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 +164 -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 +138 -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 +219 -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 +8 -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 +167 -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 +127 -0
- package/dist/client/hooks/users.d.ts +1 -0
- package/dist/client/hooks/users.js +104 -0
- package/dist/index.d.ts +21 -1
- package/dist/index.js +21 -1
- package/dist/types/api.d.ts +123 -32
- 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,15 +1,24 @@
|
|
|
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
|
});
|
|
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
|
-
|
|
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
|
}
|
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');
|
|
@@ -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
|
|
20
|
-
if (
|
|
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 ${
|
|
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
|
|
57
|
-
if (!
|
|
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 ${
|
|
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
|
|
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
|
|
85
|
-
if (
|
|
86
|
-
return
|
|
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
|
-
|
|
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
|
|
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
|
}
|
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,28 +1,398 @@
|
|
|
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 } 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(total: number, 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
|
+
useGetEvents(body: {
|
|
40
|
+
amt?: number;
|
|
41
|
+
known_ids?: string[];
|
|
42
|
+
unknown_ids?: string[];
|
|
43
|
+
query?: string;
|
|
44
|
+
unbilled?: boolean;
|
|
45
|
+
billed?: boolean;
|
|
46
|
+
paid?: boolean;
|
|
47
|
+
jobId?: string;
|
|
48
|
+
}): UseInfiniteQueryResult<InfiniteData<_Event[], unknown>, StandardError>;
|
|
49
|
+
useGetSessions(body: {
|
|
50
|
+
amt?: number;
|
|
51
|
+
query?: string;
|
|
52
|
+
}): UseInfiniteQueryResult<InfiniteData<Session[], unknown>, StandardError>;
|
|
53
|
+
useGetChats(body: {
|
|
54
|
+
amt?: number;
|
|
55
|
+
known_ids?: string[];
|
|
56
|
+
unknown_ids?: string[];
|
|
57
|
+
query?: string;
|
|
58
|
+
}): UseInfiniteQueryResult<InfiniteData<Chat[], unknown>, StandardError>;
|
|
59
|
+
useGetMessages(chatId: string, body: {
|
|
60
|
+
amt?: number;
|
|
61
|
+
known_ids?: string[];
|
|
62
|
+
unknown_ids?: string[];
|
|
63
|
+
query?: string;
|
|
64
|
+
unbilled?: boolean;
|
|
65
|
+
billed?: boolean;
|
|
66
|
+
paid?: boolean;
|
|
67
|
+
jobId?: string;
|
|
68
|
+
}): UseInfiniteQueryResult<InfiniteData<Message[], unknown>, StandardError>;
|
|
69
|
+
useGetMonths(body: {
|
|
70
|
+
amt?: number;
|
|
71
|
+
known_ids?: string[];
|
|
72
|
+
unknown_ids?: string[];
|
|
73
|
+
query?: string;
|
|
74
|
+
unbilled?: boolean;
|
|
75
|
+
billed?: boolean;
|
|
76
|
+
paid?: boolean;
|
|
77
|
+
jobId?: string;
|
|
78
|
+
}): UseInfiniteQueryResult<InfiniteData<ServiceMonth[], unknown>, StandardError>;
|
|
79
|
+
useGetBills(body: {
|
|
80
|
+
amt?: number;
|
|
81
|
+
known_ids?: string[];
|
|
82
|
+
unknown_ids?: string[];
|
|
83
|
+
query?: string;
|
|
84
|
+
paid?: boolean;
|
|
85
|
+
}): UseInfiniteQueryResult<InfiniteData<Bill[], unknown>, StandardError>;
|
|
86
|
+
useGetPlans(code: string): UseQueryResult<Plan[], StandardError>;
|
|
87
|
+
useGetCompanies(options?: {}): UseQueryResult<{
|
|
88
|
+
name: string;
|
|
89
|
+
id: string;
|
|
90
|
+
}[], StandardError>;
|
|
91
|
+
useGetAnalytics(): UseQueryResult<any, StandardError>;
|
|
92
|
+
useFinanceAnalytics({ periods, cumulative }: {
|
|
93
|
+
periods: number[][];
|
|
94
|
+
cumulative: boolean;
|
|
95
|
+
}): UseQueryResult<FinancialInsightData[], StandardError>;
|
|
96
|
+
useEventAnalytics({ periods }: {
|
|
97
|
+
periods: number[][];
|
|
98
|
+
}): UseQueryResult<EventInsightData[], StandardError>;
|
|
99
|
+
useGetCompany(companyId: string): UseQueryResult<Company, StandardError>;
|
|
100
|
+
useGetCurrentCompany(): UseQueryResult<Company, StandardError>;
|
|
101
|
+
useGetJob(jobId: string): UseQueryResult<Job, StandardError>;
|
|
102
|
+
useGetEvent(eventId: string): UseQueryResult<_Event, StandardError>;
|
|
103
|
+
useGetUser(userId: string): UseQueryResult<User, StandardError>;
|
|
104
|
+
useGetSelf(): UseQueryResult<User, StandardError>;
|
|
105
|
+
useGetBill(billId: string): UseQueryResult<Bill, StandardError>;
|
|
106
|
+
useGetRoute(routeId: string): UseQueryResult<Route, StandardError>;
|
|
107
|
+
useGetChat(chatId: string): UseQueryResult<Chat, StandardError>;
|
|
108
|
+
useGetUserSessions(): UseQueryResult<Session[], StandardError>;
|
|
109
|
+
useGetAvro(): UseQueryResult<Avro, StandardError>;
|
|
110
|
+
useSearchUsers(searchUsername: string): UseQueryResult<User[], StandardError>;
|
|
111
|
+
useCreateEvent(): ReturnType<typeof useMutation<{
|
|
112
|
+
id: string;
|
|
113
|
+
}, StandardError, {
|
|
114
|
+
eventData: Partial<_Event>;
|
|
115
|
+
}>>;
|
|
116
|
+
useCreateUserSession(): ReturnType<typeof useMutation<{
|
|
117
|
+
id: string;
|
|
118
|
+
}, StandardError, {
|
|
119
|
+
sessionData: Partial<Session>;
|
|
120
|
+
}>>;
|
|
121
|
+
useCreateBill(): ReturnType<typeof useMutation<{
|
|
122
|
+
id: string;
|
|
123
|
+
invoice_id: number;
|
|
124
|
+
}, StandardError, {
|
|
125
|
+
data: Partial<Bill>;
|
|
126
|
+
}>>;
|
|
127
|
+
useCreateCompany(): ReturnType<typeof useMutation<{
|
|
128
|
+
id: string;
|
|
129
|
+
}, StandardError, {
|
|
130
|
+
companyData: Partial<Company | {
|
|
131
|
+
logo: File | null;
|
|
132
|
+
}>;
|
|
133
|
+
}>>;
|
|
134
|
+
useCreateJob(): ReturnType<typeof useMutation<{
|
|
135
|
+
id: string;
|
|
136
|
+
}, StandardError, {
|
|
137
|
+
jobData: Partial<Job>;
|
|
138
|
+
}>>;
|
|
139
|
+
useCreateRoute(): ReturnType<typeof useMutation<{
|
|
140
|
+
id: string;
|
|
141
|
+
}, StandardError, {
|
|
142
|
+
routeData: Partial<Route>;
|
|
143
|
+
}>>;
|
|
144
|
+
useCreateTeam(): ReturnType<typeof useMutation<{
|
|
145
|
+
id: string;
|
|
146
|
+
}, StandardError, {
|
|
147
|
+
teamData: Partial<Team>;
|
|
148
|
+
}>>;
|
|
149
|
+
useCreateSelf(): ReturnType<typeof useMutation<{
|
|
150
|
+
msg: string;
|
|
151
|
+
}, StandardError, {
|
|
152
|
+
username: string;
|
|
153
|
+
name: string;
|
|
154
|
+
email: string;
|
|
155
|
+
password: string;
|
|
156
|
+
phone_number: string;
|
|
157
|
+
code?: string;
|
|
158
|
+
invite_token?: string;
|
|
159
|
+
}>>;
|
|
160
|
+
useCreateSessionBreak(): ReturnType<typeof useMutation<{
|
|
161
|
+
id: string;
|
|
162
|
+
}, StandardError, {
|
|
163
|
+
sessionId: string;
|
|
164
|
+
breakData: Partial<Break>;
|
|
165
|
+
}>>;
|
|
166
|
+
useUpdateEvent(): ReturnType<typeof useMutation<{
|
|
167
|
+
msg: string;
|
|
168
|
+
}, StandardError, {
|
|
169
|
+
eventId: string;
|
|
170
|
+
updates: Partial<_Event>;
|
|
171
|
+
}>>;
|
|
172
|
+
useSyncBillToIntuit(): ReturnType<typeof useMutation<{
|
|
173
|
+
msg: string;
|
|
174
|
+
}, StandardError, {
|
|
175
|
+
billId: string;
|
|
176
|
+
}>>;
|
|
177
|
+
useUpdateUserSession(): ReturnType<typeof useMutation<{
|
|
178
|
+
msg: string;
|
|
179
|
+
}, StandardError, {
|
|
180
|
+
sessionId: string;
|
|
181
|
+
updates: Partial<Session>;
|
|
182
|
+
}>>;
|
|
183
|
+
useUpdateJob(): ReturnType<typeof useMutation<{
|
|
184
|
+
msg: string;
|
|
185
|
+
}, StandardError, {
|
|
186
|
+
jobId: string;
|
|
187
|
+
updates: Partial<Job>;
|
|
188
|
+
}>>;
|
|
189
|
+
useUpdateBill(): ReturnType<typeof useMutation<{
|
|
190
|
+
msg: string;
|
|
191
|
+
}, StandardError, {
|
|
192
|
+
billId: string;
|
|
193
|
+
updates: Partial<Bill>;
|
|
194
|
+
}>>;
|
|
195
|
+
useUpdateRoute(): ReturnType<typeof useMutation<{
|
|
196
|
+
msg: string;
|
|
197
|
+
}, StandardError, {
|
|
198
|
+
routeId: string;
|
|
199
|
+
updates: Partial<Route>;
|
|
200
|
+
}>>;
|
|
201
|
+
useUpdateEvents(): ReturnType<typeof useMutation<void, StandardError, {
|
|
202
|
+
events: (_Event & {
|
|
203
|
+
page?: number;
|
|
204
|
+
})[];
|
|
205
|
+
action: "billed" | "paid";
|
|
206
|
+
}>>;
|
|
207
|
+
useUpdateTeam(): ReturnType<typeof useMutation<{
|
|
208
|
+
msg: string;
|
|
209
|
+
}, StandardError, {
|
|
210
|
+
teamId: string;
|
|
211
|
+
teamData: Partial<Team>;
|
|
212
|
+
}>>;
|
|
213
|
+
useUpdateMonths(): ReturnType<typeof useMutation<void, StandardError, {
|
|
214
|
+
months: (ServiceMonth & {
|
|
215
|
+
page?: number;
|
|
216
|
+
})[];
|
|
217
|
+
action: "billed" | "paid";
|
|
218
|
+
}>>;
|
|
219
|
+
useUpdateUserCompany(): ReturnType<typeof useMutation<{
|
|
220
|
+
msg: string;
|
|
221
|
+
}, StandardError, {
|
|
222
|
+
user_id: string;
|
|
223
|
+
data: Partial<UserCompanyAssociation>;
|
|
224
|
+
}>>;
|
|
225
|
+
useUpdateSessionBreak(): ReturnType<typeof useMutation<{
|
|
226
|
+
msg: string;
|
|
227
|
+
}, StandardError, {
|
|
228
|
+
breakId: string;
|
|
229
|
+
updates: Partial<Break>;
|
|
230
|
+
}>>;
|
|
231
|
+
useDeleteJob(): ReturnType<typeof useMutation<{
|
|
232
|
+
msg: string;
|
|
233
|
+
}, StandardError, {
|
|
234
|
+
jobId: string;
|
|
235
|
+
}>>;
|
|
236
|
+
useUpdateCompany(): ReturnType<typeof useMutation<{
|
|
237
|
+
msg: string;
|
|
238
|
+
}, StandardError, {
|
|
239
|
+
companyId: string;
|
|
240
|
+
companyData: Partial<Company | {
|
|
241
|
+
logo: File | null;
|
|
242
|
+
}>;
|
|
243
|
+
}>>;
|
|
244
|
+
useRemoveUserCompany(): ReturnType<typeof useMutation<{
|
|
245
|
+
msg: string;
|
|
246
|
+
}, StandardError, {
|
|
247
|
+
companyId: string;
|
|
248
|
+
userId: string;
|
|
249
|
+
}>>;
|
|
250
|
+
useDeleteEvent(): ReturnType<typeof useMutation<{
|
|
251
|
+
msg: string;
|
|
252
|
+
}, StandardError, {
|
|
253
|
+
eventId: string;
|
|
254
|
+
}>>;
|
|
255
|
+
useDeleteBill(): ReturnType<typeof useMutation<{
|
|
256
|
+
msg: string;
|
|
257
|
+
}, StandardError, {
|
|
258
|
+
billId: string;
|
|
259
|
+
}>>;
|
|
260
|
+
useDeleteRoute(): ReturnType<typeof useMutation<{
|
|
261
|
+
msg: string;
|
|
262
|
+
}, StandardError, {
|
|
263
|
+
routeId: string;
|
|
264
|
+
}>>;
|
|
265
|
+
useDeleteSelf(): ReturnType<typeof useMutation<{
|
|
266
|
+
msg: string;
|
|
267
|
+
}, StandardError, void>>;
|
|
268
|
+
useDeleteCompany(): ReturnType<typeof useMutation<{
|
|
269
|
+
msg: string;
|
|
270
|
+
}, StandardError, {
|
|
271
|
+
companyId: string;
|
|
272
|
+
}>>;
|
|
273
|
+
useDeleteTeam(): ReturnType<typeof useMutation<{
|
|
274
|
+
msg: string;
|
|
275
|
+
}, StandardError, {
|
|
276
|
+
teamId: string;
|
|
277
|
+
}>>;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
10
280
|
export declare class AvroQueryClient {
|
|
11
|
-
|
|
281
|
+
protected config: Required<AvroQueryClientConfig>;
|
|
282
|
+
readonly socket: Socket;
|
|
283
|
+
_isAuthenticated: boolean;
|
|
284
|
+
companyId: string | null;
|
|
12
285
|
constructor(config: AvroQueryClientConfig);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
get<T>(path: string, cancelToken?: CancelToken, headers?: Record<string, string
|
|
17
|
-
post<T>(path: string, data: any, cancelToken?: CancelToken, headers?: Record<string, string
|
|
18
|
-
put<T>(path: string, data: any, cancelToken?: CancelToken, headers?: Record<string, string
|
|
19
|
-
delete<T>(path: string, cancelToken?: CancelToken, headers?: Record<string, string
|
|
20
|
-
|
|
286
|
+
emit(eventName: string, data: unknown): void;
|
|
287
|
+
on<T>(eventName: string, callback: (data: T) => void): void;
|
|
288
|
+
off(eventName: string, callback?: Function): void;
|
|
289
|
+
get<T>(path: string, cancelToken?: CancelToken, headers?: Record<string, string>, progressUpdateCallback?: (loaded: number, total: number) => void): Promise<T>;
|
|
290
|
+
post<T>(path: string, data: any, cancelToken?: CancelToken, headers?: Record<string, string>, progressUpdateCallback?: (loaded: number, total: number) => void): Promise<T>;
|
|
291
|
+
put<T>(path: string, data: any, cancelToken?: CancelToken, headers?: Record<string, string>, progressUpdateCallback?: (loaded: number, total: number) => void): Promise<T>;
|
|
292
|
+
delete<T>(path: string, cancelToken?: CancelToken, headers?: Record<string, string>, progressUpdateCallback?: (loaded: number, total: number) => void): Promise<T>;
|
|
293
|
+
useLogin(): ReturnType<typeof useMutation<LoginResponse, StandardError, {
|
|
21
294
|
username: string;
|
|
22
|
-
password
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
295
|
+
password?: string;
|
|
296
|
+
code?: string;
|
|
297
|
+
cancelToken?: CancelToken;
|
|
298
|
+
}>>;
|
|
299
|
+
useRequestCode(): ReturnType<typeof useMutation<{
|
|
300
|
+
msg: string;
|
|
301
|
+
}, StandardError, {
|
|
302
|
+
username?: string;
|
|
303
|
+
email?: string;
|
|
304
|
+
cancelToken?: CancelToken;
|
|
305
|
+
}>>;
|
|
306
|
+
useUpdatePassword(): ReturnType<typeof useMutation<void, StandardError, {
|
|
307
|
+
username?: string;
|
|
308
|
+
email?: string;
|
|
309
|
+
code: string;
|
|
310
|
+
newPassword: string;
|
|
311
|
+
cancelToken?: CancelToken;
|
|
312
|
+
}>>;
|
|
313
|
+
useGoogleLogin(): ReturnType<typeof useMutation<LoginResponse, StandardError, {
|
|
314
|
+
token: string;
|
|
315
|
+
cancelToken?: CancelToken;
|
|
316
|
+
}>>;
|
|
317
|
+
setTokens(tokens: Tokens): Promise<void>;
|
|
318
|
+
setCache(data: Partial<CacheData>): Promise<void>;
|
|
319
|
+
getCache(key?: keyof CacheData | undefined): Promise<CacheData | string | null>;
|
|
320
|
+
setCompanyId(companyId: string): Promise<void[]>;
|
|
321
|
+
clearCache(): Promise<void>;
|
|
322
|
+
isAuthenticated(): boolean;
|
|
323
|
+
isAuthenticatedAsync(): Promise<boolean>;
|
|
324
|
+
getQueryClient(): QueryClient;
|
|
325
|
+
useLogout(): ReturnType<typeof useMutation<void, StandardError, CancelToken | undefined>>;
|
|
326
|
+
fetchJobs(body?: {
|
|
327
|
+
amt?: number;
|
|
328
|
+
known_ids?: string[];
|
|
329
|
+
unknown_ids?: string[];
|
|
330
|
+
query?: string;
|
|
331
|
+
offset?: number;
|
|
332
|
+
route_id?: string;
|
|
333
|
+
}, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
|
|
334
|
+
fetchChats(body?: {
|
|
335
|
+
amt?: number;
|
|
336
|
+
known_ids?: string[];
|
|
337
|
+
unknown_ids?: string[];
|
|
338
|
+
query?: string;
|
|
339
|
+
offset?: number;
|
|
340
|
+
}, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
|
|
341
|
+
fetchMessages(chatId: string, body?: {
|
|
342
|
+
amt?: number;
|
|
343
|
+
known_ids?: string[];
|
|
344
|
+
unknown_ids?: string[];
|
|
345
|
+
query?: string;
|
|
346
|
+
offset?: number;
|
|
347
|
+
}, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
|
|
348
|
+
fetchEvents(body?: {
|
|
349
|
+
amt?: number;
|
|
350
|
+
known_ids?: string[];
|
|
351
|
+
unknown_ids?: string[];
|
|
352
|
+
query?: string;
|
|
353
|
+
offset?: number;
|
|
354
|
+
unbilled?: boolean;
|
|
355
|
+
billed?: boolean;
|
|
356
|
+
paid?: boolean;
|
|
357
|
+
jobId?: string | null;
|
|
358
|
+
}, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
|
|
359
|
+
fetchMonths(body?: {
|
|
360
|
+
amt?: number;
|
|
361
|
+
known_ids?: string[];
|
|
362
|
+
unknown_ids?: string[];
|
|
363
|
+
query?: string;
|
|
364
|
+
offset?: number;
|
|
365
|
+
unbilled?: boolean;
|
|
366
|
+
billed?: boolean;
|
|
367
|
+
paid?: boolean;
|
|
368
|
+
jobId?: string | null;
|
|
369
|
+
}, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
|
|
370
|
+
fetchBills(body?: {
|
|
371
|
+
amt?: number;
|
|
372
|
+
known_ids?: string[];
|
|
373
|
+
unknown_ids?: string[];
|
|
374
|
+
query?: string;
|
|
375
|
+
offset?: number;
|
|
376
|
+
paid?: boolean;
|
|
377
|
+
}, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
|
|
378
|
+
fetchRoutes(body?: {
|
|
379
|
+
amt?: number;
|
|
380
|
+
known_ids?: string[];
|
|
381
|
+
unknown_ids?: string[];
|
|
382
|
+
query?: string;
|
|
383
|
+
offset?: number;
|
|
384
|
+
}, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
|
|
385
|
+
fetchTeams(body?: {
|
|
386
|
+
amt?: number;
|
|
387
|
+
known_ids?: string[];
|
|
388
|
+
unknown_ids?: string[];
|
|
389
|
+
query?: string;
|
|
390
|
+
offset?: number;
|
|
391
|
+
}, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
|
|
392
|
+
fetchSessions(body?: {
|
|
393
|
+
amt?: number;
|
|
394
|
+
query?: string;
|
|
395
|
+
offset?: number;
|
|
396
|
+
}, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
|
|
397
|
+
sendEmail(emailId: string, formData: FormData, progressUpdateCallback?: (loaded: number, total: number) => void): Promise<void>;
|
|
28
398
|
}
|