@go-avro/avro-js 0.0.2-beta.17 → 0.0.2-beta.170

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