@go-avro/avro-js 0.0.2-beta.17 → 0.0.2-beta.171
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 +14 -5
- package/dist/auth/AuthManager.js +59 -23
- package/dist/auth/storage.d.ts +8 -8
- package/dist/auth/storage.js +19 -14
- package/dist/client/AvroQueryClientProvider.d.ts +14 -0
- package/dist/client/AvroQueryClientProvider.js +32 -0
- package/dist/client/QueryClient.d.ts +529 -16
- package/dist/client/QueryClient.js +397 -214
- package/dist/client/core/fetch.d.ts +1 -0
- package/dist/client/core/fetch.js +64 -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 +90 -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 +165 -0
- package/dist/client/hooks/catalog_items.d.ts +1 -0
- package/dist/client/hooks/catalog_items.js +90 -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 +185 -0
- package/dist/client/hooks/events.d.ts +1 -0
- package/dist/client/hooks/events.js +308 -0
- package/dist/client/hooks/groups.d.ts +1 -0
- package/dist/client/hooks/groups.js +130 -0
- package/dist/client/hooks/jobs.d.ts +1 -0
- package/dist/client/hooks/jobs.js +296 -0
- package/dist/client/hooks/labels.d.ts +1 -0
- package/dist/client/hooks/labels.js +130 -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 +93 -0
- package/dist/client/hooks/plans.d.ts +1 -0
- package/dist/client/hooks/plans.js +8 -0
- package/dist/client/hooks/proposal.d.ts +1 -0
- package/dist/client/hooks/proposal.js +22 -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 +174 -0
- package/dist/client/hooks/sessions.d.ts +1 -0
- package/dist/client/hooks/sessions.js +175 -0
- package/dist/client/hooks/skills.d.ts +1 -0
- package/dist/client/hooks/skills.js +123 -0
- package/dist/client/hooks/teams.d.ts +1 -0
- package/dist/client/hooks/teams.js +128 -0
- package/dist/client/hooks/users.d.ts +1 -0
- package/dist/client/hooks/users.js +118 -0
- package/dist/index.d.ts +27 -1
- package/dist/index.js +27 -1
- package/dist/types/api.d.ts +245 -53
- package/dist/types/api.js +57 -1
- package/dist/types/auth.d.ts +6 -5
- package/dist/types/auth.js +5 -1
- package/dist/types/cache.d.ts +9 -0
- package/dist/types/cache.js +1 -0
- package/package.json +6 -4
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { AvroQueryClient } from "../../client/QueryClient";
|
|
3
|
+
import { AuthState } from "../../types/auth";
|
|
4
|
+
AvroQueryClient.prototype.useGetUser = function (userId) {
|
|
5
|
+
return useQuery({
|
|
6
|
+
queryKey: ['user', userId],
|
|
7
|
+
queryFn: () => this.get(`/user/${userId}`),
|
|
8
|
+
enabled: Boolean(userId),
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
AvroQueryClient.prototype.useSearchUsers = function (searchUsername) {
|
|
12
|
+
return useQuery({
|
|
13
|
+
queryKey: ['user', 'search', searchUsername],
|
|
14
|
+
queryFn: () => {
|
|
15
|
+
if (!searchUsername)
|
|
16
|
+
return Promise.resolve([]);
|
|
17
|
+
return this.get(`/user/search/${searchUsername}`);
|
|
18
|
+
},
|
|
19
|
+
enabled: Boolean(searchUsername),
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
AvroQueryClient.prototype.useGetSelf = function () {
|
|
23
|
+
return useQuery({
|
|
24
|
+
queryKey: ['user'],
|
|
25
|
+
queryFn: () => this.get(`/user`),
|
|
26
|
+
enabled: this.getAuthState() === AuthState.AUTHENTICATED,
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
AvroQueryClient.prototype.useCreateSelf = function () {
|
|
30
|
+
const queryClient = this.getQueryClient();
|
|
31
|
+
return useMutation({
|
|
32
|
+
mutationFn: async (data) => {
|
|
33
|
+
return this.post('/user', JSON.stringify(data), undefined, { "Content-Type": "application/json" });
|
|
34
|
+
},
|
|
35
|
+
onSettled: () => {
|
|
36
|
+
queryClient.invalidateQueries({ queryKey: ['user'] });
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
AvroQueryClient.prototype.useUpdateSelf = function () {
|
|
41
|
+
const queryClient = this.getQueryClient();
|
|
42
|
+
return useMutation({
|
|
43
|
+
mutationFn: async (data) => {
|
|
44
|
+
return this.put(`/user`, JSON.stringify(data), undefined, { "Content-Type": "application/json" });
|
|
45
|
+
},
|
|
46
|
+
// Optimistically update the user data in the cache
|
|
47
|
+
onMutate: async (data) => {
|
|
48
|
+
await queryClient.cancelQueries({ queryKey: ['user'] });
|
|
49
|
+
const previousUser = queryClient.getQueryData(['user']);
|
|
50
|
+
if (previousUser) {
|
|
51
|
+
queryClient.setQueryData(['user'], { ...previousUser, ...data });
|
|
52
|
+
}
|
|
53
|
+
return { previousUser };
|
|
54
|
+
},
|
|
55
|
+
onError: (err, _, context) => {
|
|
56
|
+
if (context?.previousUser) {
|
|
57
|
+
queryClient.setQueryData(['user'], context.previousUser);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
onSettled: () => {
|
|
61
|
+
queryClient.invalidateQueries({ queryKey: ['user'] });
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
AvroQueryClient.prototype.useUpdateUserCompany = function () {
|
|
66
|
+
const queryClient = this.getQueryClient();
|
|
67
|
+
return useMutation({
|
|
68
|
+
mutationFn: async ({ user_id, data }) => {
|
|
69
|
+
return this.put(`/company/${this.companyId}/user/${user_id}`, JSON.stringify(data), undefined, { "Content-Type": "application/json" });
|
|
70
|
+
},
|
|
71
|
+
// Optimistically update the user data and company data in the cache
|
|
72
|
+
onMutate: async (data) => {
|
|
73
|
+
await queryClient.cancelQueries({ queryKey: ['user'] });
|
|
74
|
+
await queryClient.cancelQueries({ queryKey: ['company', this.companyId] });
|
|
75
|
+
const previousCompany = queryClient.getQueryData(['company', this.companyId]);
|
|
76
|
+
if (previousCompany) {
|
|
77
|
+
let oldCompanyUser = previousCompany.users?.find((u) => u.user.id === data.user_id);
|
|
78
|
+
if (oldCompanyUser) {
|
|
79
|
+
oldCompanyUser = { ...oldCompanyUser, ...data.data };
|
|
80
|
+
const newUsers = previousCompany.users?.map((u) => u.user.id === data.user_id ? oldCompanyUser : u) ?? [];
|
|
81
|
+
queryClient.setQueryData(['company', this.companyId], { ...previousCompany, users: newUsers });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return { previousCompany };
|
|
85
|
+
},
|
|
86
|
+
onError: (err, _, context) => {
|
|
87
|
+
if (context?.previousCompany) {
|
|
88
|
+
queryClient.setQueryData(['company', this.companyId], context.previousCompany);
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
onSettled: (data, error, variables) => {
|
|
92
|
+
queryClient.invalidateQueries({ queryKey: ['user'] });
|
|
93
|
+
queryClient.invalidateQueries({ queryKey: ['company', this.companyId] });
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
AvroQueryClient.prototype.useDeleteSelf = function () {
|
|
98
|
+
const queryClient = this.getQueryClient();
|
|
99
|
+
return useMutation({
|
|
100
|
+
mutationFn: async () => {
|
|
101
|
+
return this.delete(`/user`);
|
|
102
|
+
},
|
|
103
|
+
onMutate: async () => {
|
|
104
|
+
await queryClient.cancelQueries({ queryKey: ['user'] });
|
|
105
|
+
const previousUser = queryClient.getQueryData(['user']);
|
|
106
|
+
queryClient.removeQueries({ queryKey: ['user'] });
|
|
107
|
+
return { previousUser };
|
|
108
|
+
},
|
|
109
|
+
onError: (err, _, context) => {
|
|
110
|
+
if (context?.previousUser) {
|
|
111
|
+
queryClient.setQueryData(['user'], context.previousUser);
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
onSettled: () => {
|
|
115
|
+
queryClient.invalidateQueries({ queryKey: ['user'] });
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
export { AvroQueryClientConfig, AvroQueryClient } from './client/QueryClient';
|
|
2
|
+
export { AvroQueryClientProvider, useAvroQueryClient } from './client/AvroQueryClientProvider';
|
|
2
3
|
export { AuthManager } from './auth/AuthManager';
|
|
3
4
|
export { MemoryStorage, LocalStorage } from './auth/storage';
|
|
5
|
+
import './client/core/xhr';
|
|
6
|
+
import './client/core/fetch';
|
|
7
|
+
import './client/core/utils';
|
|
8
|
+
import './client/hooks/root';
|
|
9
|
+
import './client/hooks/jobs';
|
|
10
|
+
import './client/hooks/routes';
|
|
11
|
+
import './client/hooks/events';
|
|
12
|
+
import './client/hooks/months';
|
|
13
|
+
import './client/hooks/bills';
|
|
14
|
+
import './client/hooks/companies';
|
|
15
|
+
import './client/hooks/users';
|
|
16
|
+
import './client/hooks/sessions';
|
|
17
|
+
import './client/hooks/chats';
|
|
18
|
+
import './client/hooks/catalog_items';
|
|
19
|
+
import './client/hooks/messages';
|
|
20
|
+
import './client/hooks/plans';
|
|
21
|
+
import './client/hooks/analytics';
|
|
22
|
+
import './client/hooks/avro';
|
|
23
|
+
import './client/hooks/teams';
|
|
24
|
+
import './client/hooks/labels';
|
|
25
|
+
import './client/hooks/groups';
|
|
26
|
+
import './client/hooks/skills';
|
|
27
|
+
import './client/hooks/proposal';
|
|
4
28
|
export * from './types/api';
|
|
5
|
-
export * from './types/
|
|
29
|
+
export * from './types/auth';
|
|
30
|
+
export * from './types/cache';
|
|
6
31
|
export * from './types/client';
|
|
32
|
+
export * from './types/error';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
export { AvroQueryClient } from './client/QueryClient';
|
|
2
|
+
export { AvroQueryClientProvider, useAvroQueryClient } from './client/AvroQueryClientProvider';
|
|
2
3
|
export { AuthManager } from './auth/AuthManager';
|
|
3
4
|
export { MemoryStorage, LocalStorage } from './auth/storage';
|
|
5
|
+
import './client/core/xhr';
|
|
6
|
+
import './client/core/fetch';
|
|
7
|
+
import './client/core/utils';
|
|
8
|
+
import './client/hooks/root';
|
|
9
|
+
import './client/hooks/jobs';
|
|
10
|
+
import './client/hooks/routes';
|
|
11
|
+
import './client/hooks/events';
|
|
12
|
+
import './client/hooks/months';
|
|
13
|
+
import './client/hooks/bills';
|
|
14
|
+
import './client/hooks/companies';
|
|
15
|
+
import './client/hooks/users';
|
|
16
|
+
import './client/hooks/sessions';
|
|
17
|
+
import './client/hooks/chats';
|
|
18
|
+
import './client/hooks/catalog_items';
|
|
19
|
+
import './client/hooks/messages';
|
|
20
|
+
import './client/hooks/plans';
|
|
21
|
+
import './client/hooks/analytics';
|
|
22
|
+
import './client/hooks/avro';
|
|
23
|
+
import './client/hooks/teams';
|
|
24
|
+
import './client/hooks/labels';
|
|
25
|
+
import './client/hooks/groups';
|
|
26
|
+
import './client/hooks/skills';
|
|
27
|
+
import './client/hooks/proposal';
|
|
4
28
|
export * from './types/api';
|
|
5
|
-
export * from './types/
|
|
29
|
+
export * from './types/auth';
|
|
30
|
+
export * from './types/cache';
|
|
6
31
|
export * from './types/client';
|
|
32
|
+
export * from './types/error';
|
package/dist/types/api.d.ts
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
export interface ApiInfo {
|
|
2
|
+
app_semver: string;
|
|
3
|
+
db_healthy: boolean;
|
|
4
|
+
logged_in_as: string;
|
|
5
|
+
ors_healthy: string;
|
|
6
|
+
pelias_healthy: boolean;
|
|
7
|
+
version: string;
|
|
8
|
+
vroom_healthy: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface CatalogItem {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
company_id: string;
|
|
14
|
+
description: string;
|
|
15
|
+
industry: string;
|
|
16
|
+
price_format: string;
|
|
17
|
+
payment_options: PaymentOption[];
|
|
18
|
+
recommended_frequency?: number | null;
|
|
19
|
+
recommended_activate_on?: number | null;
|
|
20
|
+
recommended_expire_on?: number | null;
|
|
21
|
+
time_created: number;
|
|
22
|
+
time_updated: number | null;
|
|
23
|
+
skills: string[];
|
|
24
|
+
}
|
|
25
|
+
export interface PaymentOption {
|
|
26
|
+
name: string;
|
|
27
|
+
id: string;
|
|
28
|
+
is_prepay: boolean;
|
|
29
|
+
price_under_prepay?: number;
|
|
30
|
+
price: number;
|
|
31
|
+
recommended_prepay_count?: number;
|
|
32
|
+
mode: "MONTH" | "SERVICE";
|
|
33
|
+
}
|
|
1
34
|
export interface PaymentMethod {
|
|
2
35
|
allow_redisplay: string;
|
|
3
36
|
autopay: boolean;
|
|
@@ -48,6 +81,33 @@ export interface PaymentMethod {
|
|
|
48
81
|
} | null;
|
|
49
82
|
} | null;
|
|
50
83
|
}
|
|
84
|
+
export type ScheduleItem = {
|
|
85
|
+
type: "location";
|
|
86
|
+
location: [number, number];
|
|
87
|
+
time_window: [number, number];
|
|
88
|
+
} | {
|
|
89
|
+
type: "break";
|
|
90
|
+
start: [number, number];
|
|
91
|
+
time_window: [number, number];
|
|
92
|
+
} | {
|
|
93
|
+
type: "job";
|
|
94
|
+
job_id: string;
|
|
95
|
+
task_ids: string[];
|
|
96
|
+
location: [number, number];
|
|
97
|
+
time_window: [number, number];
|
|
98
|
+
};
|
|
99
|
+
export type TeamSchedule = {
|
|
100
|
+
team_id: string;
|
|
101
|
+
schedule: ScheduleItem[];
|
|
102
|
+
name: string;
|
|
103
|
+
optimize: boolean;
|
|
104
|
+
};
|
|
105
|
+
export type RouteScheduleConfig = {
|
|
106
|
+
schedules: TeamSchedule[];
|
|
107
|
+
whitelist: string[];
|
|
108
|
+
blacklist: string[];
|
|
109
|
+
tasks: string[];
|
|
110
|
+
};
|
|
51
111
|
export interface Avro {
|
|
52
112
|
id: string;
|
|
53
113
|
name: string;
|
|
@@ -75,14 +135,8 @@ export interface LineItem {
|
|
|
75
135
|
amount: number | null;
|
|
76
136
|
time_created: number;
|
|
77
137
|
}
|
|
78
|
-
export interface CustomLineItem {
|
|
79
|
-
id: string;
|
|
138
|
+
export interface CustomLineItem extends LineItem {
|
|
80
139
|
line_item_type: "CUSTOM";
|
|
81
|
-
name: string;
|
|
82
|
-
description: string;
|
|
83
|
-
cost: number | null;
|
|
84
|
-
amount: number | null;
|
|
85
|
-
time_created: number;
|
|
86
140
|
}
|
|
87
141
|
export interface Reaction {
|
|
88
142
|
id: string;
|
|
@@ -114,10 +168,13 @@ export interface Chat {
|
|
|
114
168
|
user_state: MemberState[];
|
|
115
169
|
messages: Message[];
|
|
116
170
|
}
|
|
117
|
-
export interface
|
|
171
|
+
export interface Location {
|
|
118
172
|
accuracy: number;
|
|
119
173
|
heading: number;
|
|
120
174
|
id: string;
|
|
175
|
+
team_id: string | null;
|
|
176
|
+
user_company_id: string;
|
|
177
|
+
user_id: string;
|
|
121
178
|
latitude: number;
|
|
122
179
|
longitude: number;
|
|
123
180
|
time_collected: number;
|
|
@@ -150,14 +207,13 @@ export interface Team {
|
|
|
150
207
|
end_longitude: number;
|
|
151
208
|
start_time: number;
|
|
152
209
|
users: string[];
|
|
153
|
-
current_location:
|
|
210
|
+
current_location: Location | null;
|
|
154
211
|
start_address: string;
|
|
155
212
|
end_address: string;
|
|
156
213
|
}
|
|
157
214
|
export interface Subscription {
|
|
158
215
|
time_created: number;
|
|
159
216
|
time_updated: string;
|
|
160
|
-
user: User;
|
|
161
217
|
user_company_id: string;
|
|
162
218
|
job_id: string;
|
|
163
219
|
id: string;
|
|
@@ -173,10 +229,14 @@ export interface Plan {
|
|
|
173
229
|
trial_period_days: number;
|
|
174
230
|
time_created: number;
|
|
175
231
|
time_updated: number;
|
|
232
|
+
available_to_new_companies?: boolean;
|
|
233
|
+
available_to?: string[];
|
|
176
234
|
}
|
|
177
235
|
export interface BillPayment {
|
|
178
236
|
id: string;
|
|
179
237
|
amount: number;
|
|
238
|
+
avro_fees: number;
|
|
239
|
+
stripe_fees: number;
|
|
180
240
|
stripe_pi_id: string;
|
|
181
241
|
bill_user_id: string;
|
|
182
242
|
status: "created" | "processing" | "succeeded" | "failed" | "canceled" | "requires_action";
|
|
@@ -198,19 +258,21 @@ export interface BillUser {
|
|
|
198
258
|
export interface User {
|
|
199
259
|
id: string;
|
|
200
260
|
username: string;
|
|
201
|
-
|
|
261
|
+
first_name: string;
|
|
262
|
+
last_name: string;
|
|
202
263
|
verified: boolean;
|
|
203
|
-
companies: UserCompanyAssociation[] | null;
|
|
204
264
|
email: string | null;
|
|
205
265
|
phone_number: string | null;
|
|
206
|
-
time_created:
|
|
207
|
-
time_updated:
|
|
266
|
+
time_created: number;
|
|
267
|
+
time_updated: number | null;
|
|
268
|
+
share_location: boolean;
|
|
208
269
|
can_send_emails: boolean | null;
|
|
209
270
|
payment_methods: PaymentMethod[];
|
|
210
271
|
autopay_payment_types: string[];
|
|
211
272
|
autopay: boolean | null;
|
|
212
273
|
chats: Chat[];
|
|
213
274
|
bills: BillUser[];
|
|
275
|
+
is_root: boolean;
|
|
214
276
|
}
|
|
215
277
|
export interface Break {
|
|
216
278
|
id: string;
|
|
@@ -219,24 +281,20 @@ export interface Break {
|
|
|
219
281
|
company_billable: boolean;
|
|
220
282
|
client_billable: boolean;
|
|
221
283
|
}
|
|
222
|
-
export interface ServiceMonth {
|
|
223
|
-
id: string;
|
|
284
|
+
export interface ServiceMonth extends LineItem {
|
|
224
285
|
line_item_type: "SERVICE_MONTH";
|
|
225
286
|
job_name: string;
|
|
226
287
|
job_id: string | null;
|
|
227
288
|
job_address: string;
|
|
228
289
|
job_labels: string[];
|
|
229
290
|
bill_id: string | null;
|
|
230
|
-
cost: number;
|
|
231
291
|
billed: boolean;
|
|
232
292
|
paid: boolean;
|
|
233
|
-
amount: number;
|
|
234
293
|
tasks: string[];
|
|
235
|
-
time_created: number;
|
|
236
294
|
time_updated: number | null;
|
|
237
295
|
}
|
|
238
296
|
export interface Session {
|
|
239
|
-
|
|
297
|
+
id: string;
|
|
240
298
|
user_id: string;
|
|
241
299
|
company_id: string;
|
|
242
300
|
time_started: number;
|
|
@@ -244,7 +302,7 @@ export interface Session {
|
|
|
244
302
|
break_id: string;
|
|
245
303
|
is_paused: boolean;
|
|
246
304
|
team_id: string;
|
|
247
|
-
|
|
305
|
+
route_id: string;
|
|
248
306
|
breaks: Break[];
|
|
249
307
|
}
|
|
250
308
|
export interface Group {
|
|
@@ -253,23 +311,84 @@ export interface Group {
|
|
|
253
311
|
is_active: boolean;
|
|
254
312
|
is_user_type: boolean;
|
|
255
313
|
users: string[];
|
|
256
|
-
permissions:
|
|
314
|
+
permissions: Permission[];
|
|
257
315
|
company_id: string;
|
|
258
316
|
time_created: number;
|
|
259
317
|
time_updated: number;
|
|
260
318
|
}
|
|
319
|
+
export declare const NotificationLevel: {
|
|
320
|
+
readonly IN_APP: 0;
|
|
321
|
+
readonly EMAIL: 1;
|
|
322
|
+
readonly SMS: 2;
|
|
323
|
+
readonly PUSH: 3;
|
|
324
|
+
};
|
|
325
|
+
export type NotificationLevel = typeof NotificationLevel[keyof typeof NotificationLevel];
|
|
326
|
+
export declare const LoginResponse: {
|
|
327
|
+
readonly SUCCESS: "SUCCESS";
|
|
328
|
+
readonly NEEDS_TOTP: "NEEDS_TOTP";
|
|
329
|
+
};
|
|
330
|
+
export type LoginResponse = typeof LoginResponse[keyof typeof LoginResponse];
|
|
331
|
+
export declare const Permission: {
|
|
332
|
+
readonly CAN_WRITE_COMPANY: "can_write_company";
|
|
333
|
+
readonly CAN_READ_GROUPS: "can_read_groups";
|
|
334
|
+
readonly CAN_WRITE_PROPOSALS: "can_write_proposals";
|
|
335
|
+
readonly CAN_READ_PROPOSALS: "can_read_proposals";
|
|
336
|
+
readonly CAN_WRITE_GROUPS: "can_write_groups";
|
|
337
|
+
readonly CAN_WRITE_ROUTES: "can_write_routes";
|
|
338
|
+
readonly CAN_WRITE_SUBSCRIPTIONS: "can_write_subscriptions";
|
|
339
|
+
readonly CAN_READ_SUBSCRIPTIONS: "can_read_subscriptions";
|
|
340
|
+
readonly CAN_WRITE_TEAMS: "can_write_teams";
|
|
341
|
+
readonly CAN_WRITE_JOBS: "can_write_jobs";
|
|
342
|
+
readonly CAN_WRITE_TASKS: "can_write_tasks";
|
|
343
|
+
readonly CAN_WRITE_ITEMS: "can_write_items";
|
|
344
|
+
readonly CAN_WRITE_SKILLS: "can_write_skills";
|
|
345
|
+
readonly CAN_WRITE_EMAILS: "can_write_emails";
|
|
346
|
+
readonly CAN_WRITE_OTHERS_SESSIONS: "can_write_others_sessions";
|
|
347
|
+
readonly CAN_READ_OTHERS_SESSIONS: "can_read_others_sessions";
|
|
348
|
+
readonly CAN_READ_SESSIONS: "can_read_sessions";
|
|
349
|
+
readonly CAN_WRITE_LABELS: "can_write_labels";
|
|
350
|
+
readonly CAN_READ_LABELS: "can_read_labels";
|
|
351
|
+
readonly CAN_READ_ROUTES: "can_read_routes";
|
|
352
|
+
readonly CAN_READ_TEAMS: "can_read_teams";
|
|
353
|
+
readonly CAN_READ_JOBS: "can_read_jobs";
|
|
354
|
+
readonly CAN_WRITE_EVENTS: "can_write_events";
|
|
355
|
+
readonly CAN_READ_TASKS: "can_read_tasks";
|
|
356
|
+
readonly CAN_READ_ITEMS: "can_read_items";
|
|
357
|
+
readonly CAN_READ_SKILLS: "can_read_skills";
|
|
358
|
+
readonly CAN_WRITE_SESSIONS: "can_write_sessions";
|
|
359
|
+
readonly CAN_READ_EMAILS: "can_read_emails";
|
|
360
|
+
readonly CAN_WRITE_SMS: "can_write_sms";
|
|
361
|
+
readonly CAN_READ_SMS: "can_read_sms";
|
|
362
|
+
readonly CAN_WRITE_NOTIFICATIONS: "can_write_notifications";
|
|
363
|
+
readonly CAN_READ_EVENTS: "can_read_events";
|
|
364
|
+
readonly CAN_READ_MONTHS: "can_read_months";
|
|
365
|
+
readonly CAN_WRITE_MONTHS: "can_write_months";
|
|
366
|
+
readonly CAN_WRITE_BILLS: "can_write_bills";
|
|
367
|
+
readonly CAN_READ_BILLS: "can_read_bills";
|
|
368
|
+
readonly CAN_OPTIMIZE: "can_optimize";
|
|
369
|
+
readonly CAN_READ_COMPANY: "can_read_company";
|
|
370
|
+
readonly CAN_WRITE_OTHERS_TIMECARDS: "can_write_others_timecards";
|
|
371
|
+
readonly CAN_READ_OTHERS_TIMECARDS: "can_read_others_timecards";
|
|
372
|
+
readonly CAN_WRITE_TIMECARDS: "can_write_timecards";
|
|
373
|
+
readonly CAN_READ_TIMECARDS: "can_read_timecards";
|
|
374
|
+
readonly CAN_APPROVE_TIME_OFF: "can_approve_time_off";
|
|
375
|
+
readonly IS_ROOT: "is_root";
|
|
376
|
+
readonly IS_CUSTOMER: "is_customer";
|
|
377
|
+
};
|
|
378
|
+
export type Permission = typeof Permission[keyof typeof Permission];
|
|
261
379
|
export interface UserCompanyAssociation {
|
|
262
380
|
id: string;
|
|
263
381
|
user: User;
|
|
264
382
|
company: string;
|
|
265
|
-
permissions:
|
|
266
|
-
effective_permissions:
|
|
383
|
+
permissions: Permission[];
|
|
384
|
+
effective_permissions: Permission[];
|
|
267
385
|
time_created: number | null;
|
|
268
386
|
time_updated: number | null;
|
|
269
|
-
notification_setting:
|
|
387
|
+
notification_setting: NotificationLevel[];
|
|
270
388
|
share_email_company_wide: boolean;
|
|
271
|
-
notifications:
|
|
389
|
+
notifications: Notification[];
|
|
272
390
|
groups: string[];
|
|
391
|
+
last_location: Location | null;
|
|
273
392
|
}
|
|
274
393
|
export interface Email {
|
|
275
394
|
id: string;
|
|
@@ -308,13 +427,13 @@ export interface Bill {
|
|
|
308
427
|
customer_email: string | null;
|
|
309
428
|
manual_emails: string[][];
|
|
310
429
|
users: BillUser[];
|
|
311
|
-
|
|
430
|
+
status: "SENT" | "PAID" | "PARTIALLY_PAID" | "MANUALLY_PAID";
|
|
312
431
|
time_created: number;
|
|
313
432
|
time_updated: number;
|
|
314
433
|
events: string[];
|
|
315
434
|
intent_created_at: number;
|
|
316
435
|
intent_last_created_at: number;
|
|
317
|
-
|
|
436
|
+
payments: BillPayment[];
|
|
318
437
|
line_items: CustomLineItem[];
|
|
319
438
|
months: string[];
|
|
320
439
|
due_date: number;
|
|
@@ -337,18 +456,14 @@ export interface PlanPayment {
|
|
|
337
456
|
time_updated: number;
|
|
338
457
|
}
|
|
339
458
|
export interface Company {
|
|
340
|
-
events: _Event[];
|
|
341
|
-
months: ServiceMonth[];
|
|
342
459
|
id: string;
|
|
343
|
-
jobs: Job[];
|
|
344
460
|
name: string;
|
|
345
461
|
email: string;
|
|
346
|
-
routes: Route[];
|
|
347
|
-
teams: Team[];
|
|
348
462
|
emails: Email[];
|
|
349
463
|
skills: Skill[];
|
|
350
|
-
|
|
351
|
-
|
|
464
|
+
catalog_items: CatalogItem[];
|
|
465
|
+
time_created: number;
|
|
466
|
+
time_updated: number | null;
|
|
352
467
|
users: UserCompanyAssociation[];
|
|
353
468
|
use_client_side_customer_start_billing: boolean;
|
|
354
469
|
use_client_side_customer_stop_billing: boolean;
|
|
@@ -356,10 +471,10 @@ export interface Company {
|
|
|
356
471
|
use_client_side_employee_stop_billing: boolean;
|
|
357
472
|
logo_url: string;
|
|
358
473
|
delay_scalar: number;
|
|
359
|
-
|
|
474
|
+
payments: PlanPayment[];
|
|
360
475
|
overdue_threshold: number;
|
|
361
476
|
stripe_account_id: string;
|
|
362
|
-
is_restricted:
|
|
477
|
+
is_restricted: boolean;
|
|
363
478
|
disabled_reason: string;
|
|
364
479
|
completed_onboarding: boolean;
|
|
365
480
|
restricted_soon: boolean;
|
|
@@ -367,6 +482,9 @@ export interface Company {
|
|
|
367
482
|
billing_email_id: string;
|
|
368
483
|
num_events: number;
|
|
369
484
|
num_jobs: number;
|
|
485
|
+
num_routes: number;
|
|
486
|
+
num_teams: number;
|
|
487
|
+
num_skills: number;
|
|
370
488
|
bills: Bill[];
|
|
371
489
|
enabled_payment_methods: string[];
|
|
372
490
|
sessions: Session[];
|
|
@@ -380,8 +498,8 @@ export interface Company {
|
|
|
380
498
|
balance: number;
|
|
381
499
|
plan_id: string;
|
|
382
500
|
payment_methods: PaymentMethod[];
|
|
383
|
-
autopay_payment_id: string;
|
|
384
501
|
intuit_connected: boolean;
|
|
502
|
+
next_payment_due: number | null;
|
|
385
503
|
}
|
|
386
504
|
export interface RouteJob {
|
|
387
505
|
time_created: number;
|
|
@@ -430,8 +548,9 @@ export interface Job {
|
|
|
430
548
|
routes: RouteJob[];
|
|
431
549
|
subscribers: Subscription[];
|
|
432
550
|
manual_emails: string[][];
|
|
551
|
+
overdue_time: number;
|
|
433
552
|
last_completed_event: _Event | null;
|
|
434
|
-
|
|
553
|
+
current_event: _Event | null;
|
|
435
554
|
labels: string[];
|
|
436
555
|
owner: string;
|
|
437
556
|
}
|
|
@@ -452,7 +571,8 @@ export interface Task {
|
|
|
452
571
|
created_by: UserCompanyAssociation | null;
|
|
453
572
|
overdueness: number | null;
|
|
454
573
|
overdue_time: number;
|
|
455
|
-
|
|
574
|
+
last_completed_event: _Event | null;
|
|
575
|
+
current_event: _Event | null;
|
|
456
576
|
delay: number;
|
|
457
577
|
skills: string[];
|
|
458
578
|
service: number;
|
|
@@ -464,6 +584,7 @@ export interface Task {
|
|
|
464
584
|
services_prepaid: number;
|
|
465
585
|
months_prepaid: number;
|
|
466
586
|
priority: boolean;
|
|
587
|
+
route_ids: string[];
|
|
467
588
|
}
|
|
468
589
|
export interface TaskWrapper {
|
|
469
590
|
latestEvent: number;
|
|
@@ -485,25 +606,31 @@ export interface taskEndInfo {
|
|
|
485
606
|
internal_notes: string;
|
|
486
607
|
external_notes: string;
|
|
487
608
|
}
|
|
488
|
-
export interface AdditionalCharge {
|
|
489
|
-
id: string;
|
|
609
|
+
export interface AdditionalCharge extends LineItem {
|
|
490
610
|
line_item_type: "ADDITIONAL_CHARGE";
|
|
491
|
-
time_created: number;
|
|
492
611
|
time_updated: number | null;
|
|
493
|
-
name: string;
|
|
494
|
-
amount: number;
|
|
495
612
|
}
|
|
496
|
-
export interface
|
|
497
|
-
breaks: string[];
|
|
613
|
+
export interface UserEvent {
|
|
498
614
|
id: string;
|
|
615
|
+
session_id: string;
|
|
616
|
+
event_id: string;
|
|
617
|
+
user_id: string | null;
|
|
618
|
+
team_id: string | null;
|
|
619
|
+
user_name: string | null;
|
|
620
|
+
team_name: string | null;
|
|
621
|
+
time_started: number | null;
|
|
622
|
+
time_ended: number | null;
|
|
623
|
+
time_created: number | null;
|
|
624
|
+
time_updated: number | null;
|
|
625
|
+
}
|
|
626
|
+
export interface _Event extends LineItem {
|
|
627
|
+
breaks: string[];
|
|
499
628
|
line_item_type: "EVENT";
|
|
500
|
-
name: string;
|
|
501
629
|
internal_notes: string;
|
|
502
630
|
external_notes: string;
|
|
503
631
|
proofs: string[];
|
|
504
632
|
tasks: string[];
|
|
505
|
-
|
|
506
|
-
time_ended: number;
|
|
633
|
+
time_ended: number | null;
|
|
507
634
|
time_started: number;
|
|
508
635
|
time_updated: number | null;
|
|
509
636
|
job_id: string;
|
|
@@ -512,11 +639,76 @@ export interface _Event {
|
|
|
512
639
|
bill_id: string;
|
|
513
640
|
billed_amount: number;
|
|
514
641
|
additional_charges: AdditionalCharge[];
|
|
515
|
-
|
|
516
|
-
team_id: string;
|
|
517
|
-
cost: number;
|
|
642
|
+
users: UserEvent[];
|
|
518
643
|
billed: boolean;
|
|
519
644
|
paid: boolean;
|
|
520
645
|
autostart: boolean;
|
|
521
646
|
job_labels: string[];
|
|
522
647
|
}
|
|
648
|
+
export interface FinancialInsightData {
|
|
649
|
+
start: number;
|
|
650
|
+
end: number;
|
|
651
|
+
unbilled: {
|
|
652
|
+
events: {
|
|
653
|
+
count: number;
|
|
654
|
+
amount: number;
|
|
655
|
+
};
|
|
656
|
+
service_months: {
|
|
657
|
+
count: number;
|
|
658
|
+
amount: number;
|
|
659
|
+
};
|
|
660
|
+
total: number;
|
|
661
|
+
};
|
|
662
|
+
billed_unbilled: {
|
|
663
|
+
events: {
|
|
664
|
+
count: number;
|
|
665
|
+
amount: number;
|
|
666
|
+
};
|
|
667
|
+
service_months: {
|
|
668
|
+
count: number;
|
|
669
|
+
amount: number;
|
|
670
|
+
};
|
|
671
|
+
total: number;
|
|
672
|
+
};
|
|
673
|
+
paid_unbilled: {
|
|
674
|
+
events: {
|
|
675
|
+
count: number;
|
|
676
|
+
amount: number;
|
|
677
|
+
};
|
|
678
|
+
service_months: {
|
|
679
|
+
count: number;
|
|
680
|
+
amount: number;
|
|
681
|
+
};
|
|
682
|
+
total: number;
|
|
683
|
+
};
|
|
684
|
+
prepaid: {
|
|
685
|
+
events: {
|
|
686
|
+
count: number;
|
|
687
|
+
amount: number;
|
|
688
|
+
};
|
|
689
|
+
service_months: {
|
|
690
|
+
count: number;
|
|
691
|
+
amount: number;
|
|
692
|
+
};
|
|
693
|
+
total: number;
|
|
694
|
+
};
|
|
695
|
+
accounts_receivable: {
|
|
696
|
+
overdue: number;
|
|
697
|
+
not_overdue: number;
|
|
698
|
+
};
|
|
699
|
+
cash: number;
|
|
700
|
+
}
|
|
701
|
+
export interface EventInsightData {
|
|
702
|
+
start: number;
|
|
703
|
+
end: number;
|
|
704
|
+
events_per_job: {
|
|
705
|
+
id: string;
|
|
706
|
+
name: string;
|
|
707
|
+
event_count: number;
|
|
708
|
+
}[];
|
|
709
|
+
events_per_team: {
|
|
710
|
+
team_id: string;
|
|
711
|
+
event_count: number;
|
|
712
|
+
}[];
|
|
713
|
+
total_events: number;
|
|
714
|
+
}
|