@go-avro/avro-js 0.0.2-beta.1 → 0.0.2-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/AuthManager.d.ts +3 -1
- package/dist/auth/AuthManager.js +65 -24
- package/dist/client/QueryClient.d.ts +9 -0
- package/dist/client/QueryClient.js +152 -0
- package/dist/types/api.d.ts +497 -10
- package/package.json +1 -1
|
@@ -6,8 +6,10 @@ export declare class AuthManager {
|
|
|
6
6
|
baseUrl: string;
|
|
7
7
|
storage: TokenStorage | TokenStorage[];
|
|
8
8
|
});
|
|
9
|
+
isAuthenticated(): Promise<boolean>;
|
|
9
10
|
fetchNewTokens(): Promise<Tokens>;
|
|
10
11
|
accessToken(): Promise<string | undefined>;
|
|
11
12
|
refreshTokens(): Promise<Tokens | null>;
|
|
12
|
-
|
|
13
|
+
setTokens(tokens: Tokens): Promise<void>;
|
|
14
|
+
clearTokens(): Promise<void>;
|
|
13
15
|
}
|
package/dist/auth/AuthManager.js
CHANGED
|
@@ -11,32 +11,70 @@ export class AuthManager {
|
|
|
11
11
|
});
|
|
12
12
|
this.baseUrl = baseUrl;
|
|
13
13
|
}
|
|
14
|
-
async
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
async isAuthenticated() {
|
|
15
|
+
if (!this.storages.length) {
|
|
16
|
+
throw new Error('No token storages initialized');
|
|
17
|
+
}
|
|
18
|
+
for (const storage of this.storages) {
|
|
19
|
+
const tokens = await storage.get();
|
|
20
|
+
if (tokens && tokens.access_token) {
|
|
21
|
+
try {
|
|
22
|
+
const response = await fetch(`${this.baseUrl}/validate`, {
|
|
23
|
+
method: 'POST',
|
|
24
|
+
headers: {
|
|
25
|
+
'Content-Type': 'application/json',
|
|
26
|
+
'Authorization': `Bearer ${tokens.access_token}`,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
if (response.ok) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// Attempt token refresh if validation fails
|
|
34
|
+
const newTokens = await this.refreshTokens();
|
|
35
|
+
if (newTokens && newTokens.access_token) {
|
|
36
|
+
const retryResponse = await fetch(`${this.baseUrl}/validate`, {
|
|
37
|
+
method: 'POST',
|
|
38
|
+
headers: {
|
|
39
|
+
'Content-Type': 'application/json',
|
|
40
|
+
'Authorization': `Bearer ${newTokens.access_token}`,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
return retryResponse.ok;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
20
46
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
throw new Error('No refresh token available');
|
|
47
|
+
catch (error) {
|
|
48
|
+
console.error('Error validating access token:', error);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
26
51
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
async fetchNewTokens() {
|
|
55
|
+
for (const storage of this.storages) {
|
|
56
|
+
const tokens = await storage.get();
|
|
57
|
+
if (!tokens || !tokens.refresh_token)
|
|
58
|
+
continue;
|
|
59
|
+
try {
|
|
60
|
+
const response = await fetch(`${this.baseUrl}/refresh`, {
|
|
61
|
+
method: 'POST',
|
|
62
|
+
headers: {
|
|
63
|
+
'Content-Type': 'application/json',
|
|
64
|
+
'Accept': 'application/json',
|
|
65
|
+
'Authorization': `Bearer ${tokens.refresh_token}`,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
if (response.ok) {
|
|
69
|
+
const newTokens = await response.json();
|
|
70
|
+
return newTokens;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
storage.clear();
|
|
75
|
+
}
|
|
37
76
|
}
|
|
38
|
-
|
|
39
|
-
return tokens;
|
|
77
|
+
throw new Error('Failed to refresh tokens from all storages');
|
|
40
78
|
}
|
|
41
79
|
async accessToken() {
|
|
42
80
|
if (!this.storages.length) {
|
|
@@ -61,7 +99,10 @@ export class AuthManager {
|
|
|
61
99
|
return null;
|
|
62
100
|
}
|
|
63
101
|
}
|
|
64
|
-
async
|
|
102
|
+
async setTokens(tokens) {
|
|
103
|
+
await Promise.all(this.storages.map(s => s.set(tokens)));
|
|
104
|
+
}
|
|
105
|
+
async clearTokens() {
|
|
65
106
|
await Promise.all(this.storages.map(s => s.clear()));
|
|
66
107
|
}
|
|
67
108
|
}
|
|
@@ -12,8 +12,17 @@ export declare class AvroQueryClient {
|
|
|
12
12
|
constructor(config: AvroQueryClientConfig);
|
|
13
13
|
getDelay(strategy: RetryStrategy, attempt: number): number;
|
|
14
14
|
private _xhr;
|
|
15
|
+
private _fetch;
|
|
15
16
|
get<T>(path: string, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<T>;
|
|
16
17
|
post<T>(path: string, data: any, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<T>;
|
|
17
18
|
put<T>(path: string, data: any, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<T>;
|
|
18
19
|
delete<T>(path: string, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<T>;
|
|
20
|
+
login(data: {
|
|
21
|
+
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, known_ids?: string[], unknown_ids?: string[], keyword?: string, offset?: number, unbilled?: boolean, billed?: boolean, paid?: boolean, 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>;
|
|
19
28
|
}
|
|
@@ -104,6 +104,71 @@ export class AvroQueryClient {
|
|
|
104
104
|
});
|
|
105
105
|
});
|
|
106
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
|
+
console.error(`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
|
+
}
|
|
107
172
|
get(path, cancelToken, headers = {}) {
|
|
108
173
|
return this._xhr('GET', path, null, cancelToken, headers, true);
|
|
109
174
|
}
|
|
@@ -116,4 +181,91 @@ export class AvroQueryClient {
|
|
|
116
181
|
delete(path, cancelToken, headers = {}) {
|
|
117
182
|
return this._xhr('DELETE', path, null, cancelToken, headers, false);
|
|
118
183
|
}
|
|
184
|
+
login(data, cancelToken) {
|
|
185
|
+
return this._fetch('POST', '/login', data, cancelToken)
|
|
186
|
+
.then(tokens => {
|
|
187
|
+
if (!tokens || !tokens.access_token || !tokens.refresh_token) {
|
|
188
|
+
throw new StandardError(401, 'Invalid login response');
|
|
189
|
+
}
|
|
190
|
+
return this.config.authManager.setTokens(tokens).then(() => true);
|
|
191
|
+
})
|
|
192
|
+
.catch(err => {
|
|
193
|
+
console.error('Login failed:', err);
|
|
194
|
+
throw new StandardError(401, 'Login failed');
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
logout(cancelToken) {
|
|
198
|
+
return this._fetch('POST', '/logout', null, cancelToken)
|
|
199
|
+
.then(() => this.config.authManager.clearTokens())
|
|
200
|
+
.catch(err => {
|
|
201
|
+
console.error('Logout failed:', err);
|
|
202
|
+
throw new StandardError(500, 'Logout failed');
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
fetchJobs(companyGuid, amt = 50, knownIds = [], unknownIds = [], keyword = '', offset = 0, cancelToken, headers = {}) {
|
|
206
|
+
const body = {
|
|
207
|
+
amt,
|
|
208
|
+
known_ids: knownIds,
|
|
209
|
+
unknown_ids: unknownIds,
|
|
210
|
+
query: keyword,
|
|
211
|
+
};
|
|
212
|
+
if (!companyGuid) {
|
|
213
|
+
return Promise.reject(new StandardError(400, 'Company GUID is required'));
|
|
214
|
+
}
|
|
215
|
+
return this._fetch('POST', `/company/${companyGuid}/jobs?amt=${amt}&offset=${offset}`, body, cancelToken, headers)
|
|
216
|
+
.then(response => {
|
|
217
|
+
if (!response || !Array.isArray(response)) {
|
|
218
|
+
throw new StandardError(400, 'Invalid jobs response');
|
|
219
|
+
}
|
|
220
|
+
return response;
|
|
221
|
+
})
|
|
222
|
+
.catch(err => {
|
|
223
|
+
console.error('Failed to fetch jobs:', err);
|
|
224
|
+
throw new StandardError(500, 'Failed to fetch jobs');
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
fetchEvents(companyGuid, amt = 50, known_ids = [], unknown_ids = [], keyword = '', offset = 0, unbilled = true, billed = true, paid = true, cancelToken, headers = {}) {
|
|
228
|
+
const body = {
|
|
229
|
+
amt,
|
|
230
|
+
known_ids,
|
|
231
|
+
unknown_ids,
|
|
232
|
+
query: keyword,
|
|
233
|
+
};
|
|
234
|
+
if (!companyGuid) {
|
|
235
|
+
return Promise.reject(new StandardError(400, 'Company GUID is required'));
|
|
236
|
+
}
|
|
237
|
+
return this._fetch('POST', `/company/${companyGuid}/events?amt=${amt}&offset=${offset}&unbilled=${unbilled}&billed=${billed}&paid=${paid}`, body, cancelToken, headers)
|
|
238
|
+
.then(response => {
|
|
239
|
+
if (!response || !Array.isArray(response)) {
|
|
240
|
+
throw new StandardError(400, 'Invalid events response');
|
|
241
|
+
}
|
|
242
|
+
return response;
|
|
243
|
+
})
|
|
244
|
+
.catch(err => {
|
|
245
|
+
console.error('Failed to fetch events:', err);
|
|
246
|
+
throw new StandardError(500, 'Failed to fetch events');
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
fetchBills(companyGuid, amt = 50, known_ids = [], unknown_ids = [], keyword = '', offset = 0, cancelToken, headers = {}) {
|
|
250
|
+
const body = {
|
|
251
|
+
amt,
|
|
252
|
+
known_ids,
|
|
253
|
+
unknown_ids,
|
|
254
|
+
query: keyword,
|
|
255
|
+
};
|
|
256
|
+
if (!companyGuid) {
|
|
257
|
+
return Promise.reject(new StandardError(400, 'Company GUID is required'));
|
|
258
|
+
}
|
|
259
|
+
return this._fetch('POST', `/company/${companyGuid}/bills?amt=${amt}&offset=${offset}`, body, cancelToken, headers)
|
|
260
|
+
.then(response => {
|
|
261
|
+
if (!response || !Array.isArray(response)) {
|
|
262
|
+
throw new StandardError(400, 'Invalid bills response');
|
|
263
|
+
}
|
|
264
|
+
return response;
|
|
265
|
+
})
|
|
266
|
+
.catch(err => {
|
|
267
|
+
console.error('Failed to fetch bills:', err);
|
|
268
|
+
throw new StandardError(500, 'Failed to fetch bills');
|
|
269
|
+
});
|
|
270
|
+
}
|
|
119
271
|
}
|
package/dist/types/api.d.ts
CHANGED
|
@@ -1,19 +1,506 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface PaymentMethod {
|
|
2
|
+
allow_redisplay: string;
|
|
3
|
+
autopay: boolean;
|
|
4
|
+
billing_details: {
|
|
5
|
+
email: string;
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
created: number;
|
|
9
|
+
customer: string;
|
|
10
|
+
id: string;
|
|
11
|
+
type: "us_bank_account" | "card";
|
|
12
|
+
us_bank_account: {
|
|
13
|
+
account_holder_type: string;
|
|
14
|
+
account_type: string;
|
|
15
|
+
bank_name: string;
|
|
16
|
+
financial_connections_account: string;
|
|
17
|
+
fingerprint: string;
|
|
18
|
+
last4: string;
|
|
19
|
+
networks: {
|
|
20
|
+
preferred: string;
|
|
21
|
+
supported: string[];
|
|
22
|
+
};
|
|
23
|
+
routing_number: string;
|
|
24
|
+
status_details: object;
|
|
25
|
+
} | null;
|
|
26
|
+
card: {
|
|
27
|
+
brand: string;
|
|
28
|
+
checks: {
|
|
29
|
+
address_line1_check: string;
|
|
30
|
+
address_postal_code_check: string;
|
|
31
|
+
cvc_check: string;
|
|
32
|
+
};
|
|
33
|
+
country: string;
|
|
34
|
+
exp_month: number;
|
|
35
|
+
exp_year: number;
|
|
36
|
+
fingerprint: string;
|
|
37
|
+
funding: string;
|
|
38
|
+
last4: string;
|
|
39
|
+
networks: {
|
|
40
|
+
preferred: string;
|
|
41
|
+
supported: string[];
|
|
42
|
+
};
|
|
43
|
+
three_d_secure_usage: {
|
|
44
|
+
supported: boolean;
|
|
45
|
+
};
|
|
46
|
+
wallet: {
|
|
47
|
+
type: string;
|
|
48
|
+
} | null;
|
|
49
|
+
} | null;
|
|
50
|
+
}
|
|
51
|
+
export interface Avro {
|
|
52
|
+
id: string;
|
|
53
|
+
name: string;
|
|
54
|
+
time_created: number;
|
|
55
|
+
time_updated: number;
|
|
56
|
+
emails: Email[];
|
|
57
|
+
totp_email_id: string;
|
|
58
|
+
billing_email_id: string;
|
|
59
|
+
join_email_id: string;
|
|
60
|
+
}
|
|
61
|
+
export interface Friendship {
|
|
62
|
+
}
|
|
63
|
+
export interface MemberState {
|
|
64
|
+
id: string;
|
|
65
|
+
state: string;
|
|
66
|
+
friendship: Friendship | null;
|
|
67
|
+
last_message_read_at: number | null;
|
|
68
|
+
}
|
|
69
|
+
export interface LineItem {
|
|
70
|
+
id: string;
|
|
71
|
+
name: string;
|
|
72
|
+
description: string;
|
|
73
|
+
cost: number | null;
|
|
74
|
+
amount: number | null;
|
|
75
|
+
time_created: number;
|
|
76
|
+
}
|
|
77
|
+
export interface Reaction {
|
|
78
|
+
id: string;
|
|
79
|
+
message_id: string;
|
|
80
|
+
sender_id: string;
|
|
81
|
+
reaction: string;
|
|
82
|
+
time_created: number;
|
|
83
|
+
time_updated: number;
|
|
84
|
+
}
|
|
85
|
+
export interface Message {
|
|
86
|
+
id: string;
|
|
87
|
+
chat_id: string;
|
|
88
|
+
sender_id: string;
|
|
89
|
+
reply_to_id: string;
|
|
90
|
+
content: string;
|
|
91
|
+
reactions: Reaction[];
|
|
92
|
+
time_created: number;
|
|
93
|
+
time_updated: number;
|
|
94
|
+
time_sent: number;
|
|
95
|
+
message: string;
|
|
96
|
+
}
|
|
97
|
+
export interface Chat {
|
|
98
|
+
id: string;
|
|
99
|
+
name: string;
|
|
100
|
+
company_id: string;
|
|
101
|
+
time_created: number;
|
|
102
|
+
time_updated: number;
|
|
103
|
+
last_message: Message;
|
|
104
|
+
user_state: MemberState[];
|
|
105
|
+
messages: Message[];
|
|
106
|
+
}
|
|
107
|
+
export interface TeamLocation {
|
|
108
|
+
accuracy: number;
|
|
109
|
+
heading: number;
|
|
110
|
+
id: string;
|
|
111
|
+
latitude: number;
|
|
112
|
+
longitude: number;
|
|
113
|
+
time_collected: number;
|
|
114
|
+
time_created: number;
|
|
115
|
+
time_updated: number | null;
|
|
116
|
+
}
|
|
117
|
+
export interface Team {
|
|
118
|
+
autoconfigure: boolean;
|
|
119
|
+
company_id: string;
|
|
120
|
+
description: string;
|
|
121
|
+
end: number[];
|
|
122
|
+
end_time: number;
|
|
123
|
+
fixed_cost: number;
|
|
124
|
+
hourly_cost: number;
|
|
125
|
+
id: string;
|
|
126
|
+
items: string[];
|
|
127
|
+
km_cost: number;
|
|
128
|
+
max_distance: number;
|
|
129
|
+
max_jobs: number;
|
|
130
|
+
max_travel_time: number;
|
|
131
|
+
color: string;
|
|
132
|
+
name: string;
|
|
133
|
+
profile: string;
|
|
134
|
+
routes: string[];
|
|
135
|
+
skills: string[];
|
|
136
|
+
speed_factor: number;
|
|
137
|
+
start_latitude: number;
|
|
138
|
+
start_longitude: number;
|
|
139
|
+
end_latitude: number;
|
|
140
|
+
end_longitude: number;
|
|
141
|
+
start_time: number;
|
|
142
|
+
users: string[];
|
|
143
|
+
current_location: TeamLocation;
|
|
144
|
+
start_address: string;
|
|
145
|
+
end_address: string;
|
|
146
|
+
}
|
|
147
|
+
export interface Subscription {
|
|
148
|
+
time_created: number;
|
|
149
|
+
time_updated: string;
|
|
150
|
+
user: User;
|
|
151
|
+
user_company_id: string;
|
|
152
|
+
job_id: string;
|
|
153
|
+
id: string;
|
|
154
|
+
notifications: number;
|
|
155
|
+
}
|
|
156
|
+
export interface Plan {
|
|
157
|
+
id: string;
|
|
158
|
+
name: string;
|
|
159
|
+
base_rate: number;
|
|
160
|
+
price_per_job: number;
|
|
161
|
+
description: string;
|
|
162
|
+
referral_codes: string[];
|
|
163
|
+
trial_period_days: number;
|
|
164
|
+
time_created: number;
|
|
165
|
+
time_updated: number;
|
|
166
|
+
}
|
|
167
|
+
export interface BillPayment {
|
|
168
|
+
id: string;
|
|
169
|
+
amount: number;
|
|
170
|
+
stripe_pi_id: string;
|
|
171
|
+
bill_user_id: string;
|
|
172
|
+
status: "created" | "processing" | "succeeded" | "failed" | "canceled" | "requires_action";
|
|
173
|
+
type: "us_bank_account" | "card";
|
|
174
|
+
action_required_at: number;
|
|
175
|
+
time_created: number;
|
|
176
|
+
time_updated: number | null;
|
|
177
|
+
}
|
|
178
|
+
export interface BillUser {
|
|
179
|
+
id: string;
|
|
180
|
+
user_id: string;
|
|
181
|
+
bill_id: string;
|
|
182
|
+
invoice_id: string;
|
|
183
|
+
payment_attempts: BillPayment[];
|
|
184
|
+
time_created: number;
|
|
185
|
+
time_updated: number | null;
|
|
186
|
+
amount: number;
|
|
187
|
+
}
|
|
188
|
+
export interface User {
|
|
189
|
+
id: string;
|
|
190
|
+
username: string;
|
|
191
|
+
name: string;
|
|
192
|
+
verified: boolean;
|
|
193
|
+
companies: UserCompanyAssociation[] | null;
|
|
194
|
+
email: string | null;
|
|
195
|
+
phone_number: string | null;
|
|
196
|
+
time_created: string | null;
|
|
197
|
+
time_updated: string | null;
|
|
198
|
+
can_send_emails: boolean | null;
|
|
199
|
+
payment_methods: PaymentMethod[];
|
|
200
|
+
autopay_payment_types: string[];
|
|
201
|
+
autopay: boolean | null;
|
|
202
|
+
chats: Chat[];
|
|
203
|
+
bills: BillUser[];
|
|
204
|
+
}
|
|
205
|
+
export interface Break {
|
|
206
|
+
id: string;
|
|
207
|
+
time_started: number;
|
|
208
|
+
time_ended: number;
|
|
209
|
+
company_billable: boolean;
|
|
210
|
+
client_billable: boolean;
|
|
211
|
+
}
|
|
212
|
+
export interface ServiceMonth {
|
|
213
|
+
id: string;
|
|
214
|
+
job_name: string;
|
|
215
|
+
job_id: string | null;
|
|
216
|
+
bill_id: string | null;
|
|
217
|
+
cost: number;
|
|
218
|
+
billed: boolean;
|
|
219
|
+
paid: boolean;
|
|
220
|
+
amount: number;
|
|
221
|
+
time_created: number;
|
|
222
|
+
time_updated: number | null;
|
|
223
|
+
}
|
|
224
|
+
export interface Session {
|
|
225
|
+
session_id: string;
|
|
226
|
+
user_id: string;
|
|
227
|
+
company_id: string;
|
|
228
|
+
time_started: number;
|
|
229
|
+
time_ended: number;
|
|
230
|
+
break_id: string;
|
|
231
|
+
is_paused: boolean;
|
|
232
|
+
team_id: string;
|
|
233
|
+
current_route_id: string;
|
|
234
|
+
breaks: Break[];
|
|
235
|
+
}
|
|
236
|
+
export interface Group {
|
|
237
|
+
id: string;
|
|
238
|
+
name: string;
|
|
239
|
+
is_active: boolean;
|
|
240
|
+
is_user_type: boolean;
|
|
241
|
+
users: string[];
|
|
242
|
+
permissions: string[];
|
|
243
|
+
company_id: string;
|
|
244
|
+
time_created: number;
|
|
245
|
+
time_updated: number;
|
|
246
|
+
}
|
|
247
|
+
export interface UserCompanyAssociation {
|
|
248
|
+
id: string;
|
|
249
|
+
user: User;
|
|
250
|
+
company: string;
|
|
251
|
+
permissions: string[];
|
|
252
|
+
effective_permissions: string[];
|
|
253
|
+
time_created: number | null;
|
|
254
|
+
time_updated: number | null;
|
|
255
|
+
notification_setting: number[];
|
|
256
|
+
share_email_company_wide: boolean;
|
|
257
|
+
notifications: number[];
|
|
258
|
+
groups: string[];
|
|
259
|
+
}
|
|
260
|
+
export interface Email {
|
|
261
|
+
id: string;
|
|
262
|
+
company_id: string;
|
|
263
|
+
name: string;
|
|
264
|
+
mail_server: string;
|
|
265
|
+
mail_port: number;
|
|
266
|
+
mail_username: string;
|
|
267
|
+
mail_password: string | null;
|
|
268
|
+
mail_default_sender: string;
|
|
269
|
+
mail_use_tls: boolean;
|
|
270
|
+
mail_use_ssl: boolean;
|
|
271
|
+
mail_api_key: string;
|
|
272
|
+
is_company_wide: boolean;
|
|
273
|
+
users: User[];
|
|
274
|
+
type: "OUTLOOK" | "SMTP" | "GMAIL";
|
|
275
|
+
access_token?: string;
|
|
276
|
+
access_token_expiry?: number;
|
|
277
|
+
refresh_token?: string;
|
|
278
|
+
refresh_token_expiry?: number;
|
|
279
|
+
}
|
|
280
|
+
export interface Label {
|
|
281
|
+
name: string;
|
|
282
|
+
id: string;
|
|
283
|
+
company_id: string;
|
|
284
|
+
color: string;
|
|
285
|
+
jobs: string[];
|
|
286
|
+
}
|
|
287
|
+
export interface Bill {
|
|
288
|
+
id: string;
|
|
289
|
+
invoice_id: number;
|
|
290
|
+
intuit_id: string | null;
|
|
291
|
+
name: string;
|
|
292
|
+
amount: number;
|
|
293
|
+
billed_by: string;
|
|
294
|
+
customer_email: string | null;
|
|
295
|
+
manual_emails: string[][];
|
|
296
|
+
users: BillUser[];
|
|
297
|
+
paid_at: number;
|
|
298
|
+
time_created: number;
|
|
299
|
+
time_updated: number;
|
|
300
|
+
events: string[];
|
|
301
|
+
intent_created_at: number;
|
|
302
|
+
intent_last_created_at: number;
|
|
303
|
+
payment: BillPayment | null;
|
|
304
|
+
line_items: LineItem[];
|
|
305
|
+
months: string[];
|
|
306
|
+
due_date: number;
|
|
307
|
+
}
|
|
308
|
+
export interface Skill {
|
|
2
309
|
id: string;
|
|
3
310
|
name: string;
|
|
311
|
+
company_id: string;
|
|
312
|
+
time_created: number;
|
|
313
|
+
time_updated: number;
|
|
314
|
+
}
|
|
315
|
+
export interface PlanPayment {
|
|
316
|
+
id: string;
|
|
317
|
+
amount: number;
|
|
318
|
+
stripe_pi_id: string;
|
|
319
|
+
company_id: string;
|
|
320
|
+
plan_id: string;
|
|
321
|
+
status: "created" | "processing" | "succeeded" | "failed" | "canceled";
|
|
322
|
+
time_created: number;
|
|
323
|
+
time_updated: number;
|
|
324
|
+
}
|
|
325
|
+
export interface Company {
|
|
326
|
+
events: _Event[];
|
|
327
|
+
months: ServiceMonth[];
|
|
328
|
+
id: string;
|
|
329
|
+
jobs: Job[];
|
|
330
|
+
name: string;
|
|
4
331
|
email: string;
|
|
5
|
-
|
|
332
|
+
routes: Route[];
|
|
333
|
+
teams: Team[];
|
|
334
|
+
emails: Email[];
|
|
335
|
+
skills: Skill[];
|
|
336
|
+
time_created: string;
|
|
337
|
+
time_updated: string | null;
|
|
338
|
+
users: UserCompanyAssociation[];
|
|
339
|
+
use_client_side_customer_start_billing: boolean;
|
|
340
|
+
use_client_side_customer_stop_billing: boolean;
|
|
341
|
+
use_client_side_employee_start_billing: boolean;
|
|
342
|
+
use_client_side_employee_stop_billing: boolean;
|
|
343
|
+
logo_url: string;
|
|
344
|
+
delay_scalar: number;
|
|
345
|
+
incomplete_payments: PlanPayment[];
|
|
346
|
+
overdue_threshold: number;
|
|
347
|
+
stripe_account_id: string;
|
|
348
|
+
is_restricted: false;
|
|
349
|
+
disabled_reason: string;
|
|
350
|
+
completed_onboarding: boolean;
|
|
351
|
+
restricted_soon: boolean;
|
|
352
|
+
service_email_id: string;
|
|
353
|
+
billing_email_id: string;
|
|
354
|
+
num_events: number;
|
|
355
|
+
num_jobs: number;
|
|
356
|
+
bills: Bill[];
|
|
357
|
+
enabled_payment_methods: string[];
|
|
358
|
+
sessions: Session[];
|
|
359
|
+
num_sessions: number;
|
|
360
|
+
labels: Label[];
|
|
361
|
+
groups: Group[];
|
|
362
|
+
indicator_lifetime: number;
|
|
363
|
+
available_plans: Plan[];
|
|
364
|
+
last_payment: number;
|
|
365
|
+
last_charged: number;
|
|
366
|
+
balance: number;
|
|
367
|
+
plan_id: string;
|
|
368
|
+
payment_methods: PaymentMethod[];
|
|
369
|
+
autopay_payment_id: string;
|
|
370
|
+
intuit_connected: boolean;
|
|
371
|
+
}
|
|
372
|
+
export interface RouteJob {
|
|
373
|
+
time_created: number;
|
|
374
|
+
route_id: string;
|
|
375
|
+
job_id: string;
|
|
376
|
+
id: string;
|
|
377
|
+
order: number;
|
|
378
|
+
estimated_arrival_time: number;
|
|
379
|
+
scheduled_arrival_time: number;
|
|
380
|
+
tasks: string[];
|
|
6
381
|
}
|
|
7
|
-
export interface
|
|
382
|
+
export interface Route {
|
|
383
|
+
company: string;
|
|
8
384
|
id: string;
|
|
385
|
+
is_internal: boolean;
|
|
386
|
+
jobs: RouteJob[];
|
|
9
387
|
name: string;
|
|
10
|
-
|
|
388
|
+
time_created: number;
|
|
389
|
+
time_updated: number | null;
|
|
390
|
+
teams: string[];
|
|
391
|
+
polyline: string;
|
|
392
|
+
is_optimized: boolean;
|
|
393
|
+
start_time: number;
|
|
394
|
+
end_time: number;
|
|
395
|
+
start_latitude: number;
|
|
396
|
+
start_longitude: number;
|
|
397
|
+
end_latitude: number;
|
|
398
|
+
end_longitude: number;
|
|
11
399
|
}
|
|
12
|
-
export interface
|
|
400
|
+
export interface Job {
|
|
401
|
+
address: string;
|
|
402
|
+
company: string;
|
|
403
|
+
description: string;
|
|
13
404
|
id: string;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
405
|
+
is_one_time: boolean;
|
|
406
|
+
autostart_radius: number;
|
|
407
|
+
latitude: number;
|
|
408
|
+
longitude: number;
|
|
409
|
+
name: string;
|
|
410
|
+
internal_notes: string;
|
|
411
|
+
external_notes: string;
|
|
412
|
+
priority: number;
|
|
413
|
+
tasks: Task[];
|
|
414
|
+
time_created: number;
|
|
415
|
+
time_updated: number | null;
|
|
416
|
+
routes: RouteJob[];
|
|
417
|
+
subscribers: Subscription[];
|
|
418
|
+
manual_emails: string[][];
|
|
419
|
+
last_completed_event: _Event | null;
|
|
420
|
+
last_event: _Event | null;
|
|
421
|
+
labels: string[];
|
|
422
|
+
owner: string;
|
|
423
|
+
}
|
|
424
|
+
export interface Task {
|
|
425
|
+
enforce_proof_amount: boolean;
|
|
426
|
+
events: _Event[];
|
|
427
|
+
frequency: number;
|
|
428
|
+
id: string;
|
|
429
|
+
job_id: string;
|
|
430
|
+
name: string;
|
|
431
|
+
internal_notes: string;
|
|
432
|
+
external_notes: string;
|
|
433
|
+
proof_amt: number;
|
|
434
|
+
images: string[];
|
|
435
|
+
time_created: number;
|
|
436
|
+
time_updated: number | null;
|
|
437
|
+
status: "PENDING_CUSTOMER" | "PENDING_COMPANY" | "ACTIVE" | "ARCHIVED" | "DRAFT";
|
|
438
|
+
created_by: UserCompanyAssociation | null;
|
|
439
|
+
overdueness: number | null;
|
|
440
|
+
overdue_time: number;
|
|
441
|
+
last_event: _Event | null;
|
|
442
|
+
delay: number;
|
|
443
|
+
skills: string[];
|
|
444
|
+
service: number;
|
|
445
|
+
bill_mode: "MONTH" | "SERVICE" | "NONE";
|
|
446
|
+
price: number;
|
|
447
|
+
services_remaining: number;
|
|
448
|
+
expire_on: number | null;
|
|
449
|
+
bill_day: number | null;
|
|
450
|
+
services_prepaid: number;
|
|
451
|
+
months_prepaid: number;
|
|
452
|
+
priority: boolean;
|
|
453
|
+
}
|
|
454
|
+
export interface TaskWrapper {
|
|
455
|
+
latestEvent: number;
|
|
456
|
+
task: Task;
|
|
457
|
+
}
|
|
458
|
+
export interface JobWrapper {
|
|
459
|
+
latestEvent: number;
|
|
460
|
+
routeIndex: number;
|
|
461
|
+
job: Job;
|
|
462
|
+
frequency: number;
|
|
463
|
+
isOverdue: boolean;
|
|
464
|
+
}
|
|
465
|
+
export interface taskStartInfo {
|
|
466
|
+
name: string;
|
|
467
|
+
start: number;
|
|
468
|
+
}
|
|
469
|
+
export interface taskEndInfo {
|
|
470
|
+
end: number;
|
|
471
|
+
internal_notes: string;
|
|
472
|
+
external_notes: string;
|
|
473
|
+
}
|
|
474
|
+
export interface AdditionalCharge {
|
|
475
|
+
id: string;
|
|
476
|
+
time_created: number;
|
|
477
|
+
time_updated: number | null;
|
|
478
|
+
name: string;
|
|
479
|
+
amount: number;
|
|
480
|
+
}
|
|
481
|
+
export interface _Event {
|
|
482
|
+
breaks: string[];
|
|
483
|
+
id: string;
|
|
484
|
+
name: string;
|
|
485
|
+
internal_notes: string;
|
|
486
|
+
external_notes: string;
|
|
487
|
+
proofs: string[];
|
|
488
|
+
tasks: string[];
|
|
489
|
+
time_created: number;
|
|
490
|
+
time_ended: number;
|
|
491
|
+
time_started: number;
|
|
492
|
+
time_updated: number | null;
|
|
493
|
+
job_id: string;
|
|
494
|
+
job_name: string;
|
|
495
|
+
job_address: string;
|
|
496
|
+
bill_id: string;
|
|
497
|
+
billed_amount: number;
|
|
498
|
+
additional_charges: AdditionalCharge[];
|
|
499
|
+
user_id: string;
|
|
500
|
+
team_id: string;
|
|
501
|
+
cost: number;
|
|
502
|
+
billed: boolean;
|
|
503
|
+
paid: boolean;
|
|
504
|
+
autostart: boolean;
|
|
505
|
+
job_labels: string[];
|
|
19
506
|
}
|