@go-avro/avro-js 0.0.2-beta.1 → 0.0.2-beta.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +1 -0
  2. package/dist/auth/AuthManager.d.ts +13 -3
  3. package/dist/auth/AuthManager.js +102 -28
  4. package/dist/auth/storage.d.ts +8 -8
  5. package/dist/auth/storage.js +12 -10
  6. package/dist/client/QueryClient.d.ts +372 -7
  7. package/dist/client/QueryClient.js +381 -96
  8. package/dist/client/core/fetch.d.ts +1 -0
  9. package/dist/client/core/fetch.js +62 -0
  10. package/dist/client/core/utils.d.ts +1 -0
  11. package/dist/client/core/utils.js +14 -0
  12. package/dist/client/core/xhr.d.ts +1 -0
  13. package/dist/client/core/xhr.js +84 -0
  14. package/dist/client/hooks/analytics.d.ts +1 -0
  15. package/dist/client/hooks/analytics.js +10 -0
  16. package/dist/client/hooks/avro.d.ts +1 -0
  17. package/dist/client/hooks/avro.js +9 -0
  18. package/dist/client/hooks/bills.d.ts +1 -0
  19. package/dist/client/hooks/bills.js +141 -0
  20. package/dist/client/hooks/chats.d.ts +1 -0
  21. package/dist/client/hooks/chats.js +37 -0
  22. package/dist/client/hooks/companies.d.ts +1 -0
  23. package/dist/client/hooks/companies.js +90 -0
  24. package/dist/client/hooks/events.d.ts +1 -0
  25. package/dist/client/hooks/events.js +307 -0
  26. package/dist/client/hooks/jobs.d.ts +1 -0
  27. package/dist/client/hooks/jobs.js +178 -0
  28. package/dist/client/hooks/messages.d.ts +1 -0
  29. package/dist/client/hooks/messages.js +30 -0
  30. package/dist/client/hooks/months.d.ts +1 -0
  31. package/dist/client/hooks/months.js +92 -0
  32. package/dist/client/hooks/plans.d.ts +1 -0
  33. package/dist/client/hooks/plans.js +9 -0
  34. package/dist/client/hooks/root.d.ts +1 -0
  35. package/dist/client/hooks/root.js +8 -0
  36. package/dist/client/hooks/routes.d.ts +1 -0
  37. package/dist/client/hooks/routes.js +168 -0
  38. package/dist/client/hooks/sessions.d.ts +1 -0
  39. package/dist/client/hooks/sessions.js +175 -0
  40. package/dist/client/hooks/teams.d.ts +1 -0
  41. package/dist/client/hooks/teams.js +116 -0
  42. package/dist/client/hooks/users.d.ts +1 -0
  43. package/dist/client/hooks/users.js +104 -0
  44. package/dist/index.d.ts +19 -0
  45. package/dist/index.js +19 -0
  46. package/dist/types/api.d.ts +588 -9
  47. package/dist/types/api.js +10 -1
  48. package/dist/types/auth.d.ts +0 -5
  49. package/dist/types/cache.d.ts +9 -0
  50. package/dist/types/cache.js +1 -0
  51. package/package.json +6 -4
@@ -1,19 +1,598 @@
1
- export interface AvroUser {
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 PaymentMethod {
11
+ allow_redisplay: string;
12
+ autopay: boolean;
13
+ billing_details: {
14
+ email: string;
15
+ name: string;
16
+ };
17
+ created: number;
18
+ customer: string;
19
+ id: string;
20
+ type: "us_bank_account" | "card";
21
+ us_bank_account: {
22
+ account_holder_type: string;
23
+ account_type: string;
24
+ bank_name: string;
25
+ financial_connections_account: string;
26
+ fingerprint: string;
27
+ last4: string;
28
+ networks: {
29
+ preferred: string;
30
+ supported: string[];
31
+ };
32
+ routing_number: string;
33
+ status_details: object;
34
+ } | null;
35
+ card: {
36
+ brand: string;
37
+ checks: {
38
+ address_line1_check: string;
39
+ address_postal_code_check: string;
40
+ cvc_check: string;
41
+ };
42
+ country: string;
43
+ exp_month: number;
44
+ exp_year: number;
45
+ fingerprint: string;
46
+ funding: string;
47
+ last4: string;
48
+ networks: {
49
+ preferred: string;
50
+ supported: string[];
51
+ };
52
+ three_d_secure_usage: {
53
+ supported: boolean;
54
+ };
55
+ wallet: {
56
+ type: string;
57
+ } | null;
58
+ } | null;
59
+ }
60
+ export interface Avro {
61
+ id: string;
62
+ name: string;
63
+ time_created: number;
64
+ time_updated: number;
65
+ emails: Email[];
66
+ totp_email_id: string;
67
+ billing_email_id: string;
68
+ join_email_id: string;
69
+ }
70
+ export interface Friendship {
71
+ }
72
+ export interface MemberState {
73
+ id: string;
74
+ state: string;
75
+ friendship: Friendship | null;
76
+ last_message_read_at: number | null;
77
+ }
78
+ export interface LineItem {
79
+ id: string;
80
+ line_item_type: "CUSTOM" | "ADDITIONAL_CHARGE" | "EVENT" | "SERVICE_MONTH";
81
+ name: string;
82
+ description: string;
83
+ cost: number | null;
84
+ amount: number | null;
85
+ time_created: number;
86
+ }
87
+ export interface CustomLineItem extends LineItem {
88
+ line_item_type: "CUSTOM";
89
+ }
90
+ export interface Reaction {
91
+ id: string;
92
+ message_id: string;
93
+ sender_id: string;
94
+ reaction: string;
95
+ time_created: number;
96
+ time_updated: number;
97
+ }
98
+ export interface Message {
99
+ id: string;
100
+ chat_id: string;
101
+ sender_id: string;
102
+ reply_to_id: string;
103
+ content: string;
104
+ reactions: Reaction[];
105
+ time_created: number;
106
+ time_updated: number;
107
+ time_sent: number;
108
+ message: string;
109
+ }
110
+ export interface Chat {
111
+ id: string;
112
+ name: string;
113
+ company_id: string;
114
+ time_created: number;
115
+ time_updated: number;
116
+ last_message: Message;
117
+ user_state: MemberState[];
118
+ messages: Message[];
119
+ }
120
+ export interface TeamLocation {
121
+ accuracy: number;
122
+ heading: number;
123
+ id: string;
124
+ latitude: number;
125
+ longitude: number;
126
+ time_collected: number;
127
+ time_created: number;
128
+ time_updated: number | null;
129
+ }
130
+ export interface Team {
131
+ autoconfigure: boolean;
132
+ company_id: string;
133
+ description: string;
134
+ end: number[];
135
+ end_time: number;
136
+ fixed_cost: number;
137
+ hourly_cost: number;
138
+ id: string;
139
+ items: string[];
140
+ km_cost: number;
141
+ max_distance: number;
142
+ max_jobs: number;
143
+ max_travel_time: number;
144
+ color: string;
145
+ name: string;
146
+ profile: string;
147
+ routes: string[];
148
+ skills: string[];
149
+ speed_factor: number;
150
+ start_latitude: number;
151
+ start_longitude: number;
152
+ end_latitude: number;
153
+ end_longitude: number;
154
+ start_time: number;
155
+ users: string[];
156
+ current_location: TeamLocation;
157
+ start_address: string;
158
+ end_address: string;
159
+ }
160
+ export interface Subscription {
161
+ time_created: number;
162
+ time_updated: string;
163
+ user: User;
164
+ user_company_id: string;
165
+ job_id: string;
166
+ id: string;
167
+ notifications: number;
168
+ }
169
+ export interface Plan {
170
+ id: string;
171
+ name: string;
172
+ base_rate: number;
173
+ price_per_job: number;
174
+ description: string;
175
+ referral_codes: string[];
176
+ trial_period_days: number;
177
+ time_created: number;
178
+ time_updated: number;
179
+ available_to_new_companies?: boolean;
180
+ available_to?: string[];
181
+ }
182
+ export interface BillPayment {
183
+ id: string;
184
+ amount: number;
185
+ avro_fees: number;
186
+ stripe_fees: number;
187
+ stripe_pi_id: string;
188
+ bill_user_id: string;
189
+ status: "created" | "processing" | "succeeded" | "failed" | "canceled" | "requires_action";
190
+ type: "us_bank_account" | "card";
191
+ action_required_at: number;
192
+ time_created: number;
193
+ time_updated: number | null;
194
+ }
195
+ export interface BillUser {
196
+ id: string;
197
+ user_id: string;
198
+ bill_id: string;
199
+ invoice_id: string;
200
+ payment_attempts: BillPayment[];
201
+ time_created: number;
202
+ time_updated: number | null;
203
+ amount: number;
204
+ }
205
+ export interface User {
206
+ id: string;
207
+ username: string;
208
+ name: string;
209
+ verified: boolean;
210
+ companies: UserCompanyAssociation[] | null;
211
+ email: string | null;
212
+ phone_number: string | null;
213
+ time_created: number;
214
+ time_updated: number | null;
215
+ can_send_emails: boolean | null;
216
+ payment_methods: PaymentMethod[];
217
+ autopay_payment_types: string[];
218
+ autopay: boolean | null;
219
+ chats: Chat[];
220
+ bills: BillUser[];
221
+ is_root: boolean;
222
+ }
223
+ export interface Break {
224
+ id: string;
225
+ time_started: number;
226
+ time_ended: number;
227
+ company_billable: boolean;
228
+ client_billable: boolean;
229
+ }
230
+ export interface ServiceMonth extends LineItem {
231
+ line_item_type: "SERVICE_MONTH";
232
+ job_name: string;
233
+ job_id: string | null;
234
+ job_address: string;
235
+ job_labels: string[];
236
+ bill_id: string | null;
237
+ billed: boolean;
238
+ paid: boolean;
239
+ tasks: string[];
240
+ time_updated: number | null;
241
+ }
242
+ export interface Session {
243
+ id: string;
244
+ user_id: string;
245
+ company_id: string;
246
+ time_started: number;
247
+ time_ended: number;
248
+ break_id: string;
249
+ is_paused: boolean;
250
+ team_id: string;
251
+ route_id: string;
252
+ breaks: Break[];
253
+ }
254
+ export interface Group {
255
+ id: string;
256
+ name: string;
257
+ is_active: boolean;
258
+ is_user_type: boolean;
259
+ users: string[];
260
+ permissions: string[];
261
+ company_id: string;
262
+ time_created: number;
263
+ time_updated: number;
264
+ }
265
+ export declare const NotificationLevel: {
266
+ readonly IN_APP: 0;
267
+ readonly EMAIL: 1;
268
+ readonly SMS: 2;
269
+ readonly PUSH: 3;
270
+ };
271
+ export type NotificationLevel = typeof NotificationLevel[keyof typeof NotificationLevel];
272
+ export declare const LoginResponse: {
273
+ readonly SUCCESS: "SUCCESS";
274
+ readonly NEEDS_TOTP: "NEEDS_TOTP";
275
+ };
276
+ export type LoginResponse = typeof LoginResponse[keyof typeof LoginResponse];
277
+ export interface UserCompanyAssociation {
278
+ id: string;
279
+ user: User;
280
+ company: string;
281
+ permissions: string[];
282
+ effective_permissions: string[];
283
+ time_created: number | null;
284
+ time_updated: number | null;
285
+ notification_setting: NotificationLevel[];
286
+ share_email_company_wide: boolean;
287
+ notifications: Notification[];
288
+ groups: string[];
289
+ }
290
+ export interface Email {
291
+ id: string;
292
+ company_id: string;
293
+ name: string;
294
+ mail_server: string;
295
+ mail_port: number;
296
+ mail_username: string;
297
+ mail_password: string | null;
298
+ mail_default_sender: string;
299
+ mail_use_tls: boolean;
300
+ mail_use_ssl: boolean;
301
+ mail_api_key: string;
302
+ is_company_wide: boolean;
303
+ users: User[];
304
+ type: "OUTLOOK" | "SMTP" | "GMAIL";
305
+ access_token?: string;
306
+ access_token_expiry?: number;
307
+ refresh_token?: string;
308
+ refresh_token_expiry?: number;
309
+ }
310
+ export interface Label {
311
+ name: string;
312
+ id: string;
313
+ company_id: string;
314
+ color: string;
315
+ jobs: string[];
316
+ }
317
+ export interface Bill {
318
+ id: string;
319
+ invoice_id: number;
320
+ intuit_id: string | null;
321
+ name: string;
322
+ amount: number;
323
+ billed_by: string;
324
+ customer_email: string | null;
325
+ manual_emails: string[][];
326
+ users: BillUser[];
327
+ paid: boolean;
328
+ paid_at: number;
329
+ time_created: number;
330
+ time_updated: number;
331
+ events: string[];
332
+ intent_created_at: number;
333
+ intent_last_created_at: number;
334
+ payment: BillPayment | null;
335
+ line_items: CustomLineItem[];
336
+ months: string[];
337
+ due_date: number;
338
+ }
339
+ export interface Skill {
340
+ id: string;
341
+ name: string;
342
+ company_id: string;
343
+ time_created: number;
344
+ time_updated: number;
345
+ }
346
+ export interface PlanPayment {
347
+ id: string;
348
+ amount: number;
349
+ stripe_pi_id: string;
350
+ company_id: string;
351
+ plan_id: string;
352
+ status: "created" | "processing" | "succeeded" | "failed" | "canceled";
353
+ time_created: number;
354
+ time_updated: number;
355
+ }
356
+ export interface Company {
2
357
  id: string;
3
358
  name: string;
4
359
  email: string;
5
- teams: AvroTeam[];
360
+ emails: Email[];
361
+ skills: Skill[];
362
+ time_created: number;
363
+ time_updated: number | null;
364
+ users: UserCompanyAssociation[];
365
+ use_client_side_customer_start_billing: boolean;
366
+ use_client_side_customer_stop_billing: boolean;
367
+ use_client_side_employee_start_billing: boolean;
368
+ use_client_side_employee_stop_billing: boolean;
369
+ logo_url: string;
370
+ delay_scalar: number;
371
+ incomplete_payments: PlanPayment[];
372
+ overdue_threshold: number;
373
+ stripe_account_id: string;
374
+ is_restricted: false;
375
+ disabled_reason: string;
376
+ completed_onboarding: boolean;
377
+ restricted_soon: boolean;
378
+ service_email_id: string;
379
+ billing_email_id: string;
380
+ num_events: number;
381
+ num_jobs: number;
382
+ num_routes: number;
383
+ num_teams: number;
384
+ bills: Bill[];
385
+ enabled_payment_methods: string[];
386
+ sessions: Session[];
387
+ num_sessions: number;
388
+ labels: Label[];
389
+ groups: Group[];
390
+ indicator_lifetime: number;
391
+ available_plans: Plan[];
392
+ last_payment: number;
393
+ last_charged: number;
394
+ balance: number;
395
+ plan_id: string;
396
+ payment_methods: PaymentMethod[];
397
+ autopay_payment_id: string;
398
+ intuit_connected: boolean;
399
+ }
400
+ export interface RouteJob {
401
+ time_created: number;
402
+ route_id: string;
403
+ job_id: string;
404
+ id: string;
405
+ order: number;
406
+ estimated_arrival_time: number;
407
+ scheduled_arrival_time: number;
408
+ tasks: string[];
409
+ }
410
+ export interface Route {
411
+ company: string;
412
+ id: string;
413
+ is_internal: boolean;
414
+ jobs: RouteJob[];
415
+ name: string;
416
+ time_created: number;
417
+ time_updated: number | null;
418
+ teams: string[];
419
+ polyline: string;
420
+ is_optimized: boolean;
421
+ start_time: number;
422
+ end_time: number;
423
+ start_latitude: number;
424
+ start_longitude: number;
425
+ end_latitude: number;
426
+ end_longitude: number;
6
427
  }
7
- export interface AvroTeam {
428
+ export interface Job {
429
+ address: string;
430
+ company: string;
431
+ description: string;
8
432
  id: string;
433
+ is_one_time: boolean;
434
+ autostart_radius: number;
435
+ latitude: number;
436
+ longitude: number;
9
437
  name: string;
10
- members: AvroUser[];
438
+ internal_notes: string;
439
+ external_notes: string;
440
+ priority: number;
441
+ tasks: Task[];
442
+ time_created: number;
443
+ time_updated: number | null;
444
+ routes: RouteJob[];
445
+ subscribers: Subscription[];
446
+ manual_emails: string[][];
447
+ overdue_time: number;
448
+ last_completed_event: _Event | null;
449
+ last_event: _Event | null;
450
+ labels: string[];
451
+ owner: string;
11
452
  }
12
- export interface AvroJob {
453
+ export interface Task {
454
+ enforce_proof_amount: boolean;
455
+ events: _Event[];
456
+ frequency: number;
13
457
  id: string;
14
- location: {
15
- lat: number;
16
- lng: number;
458
+ job_id: string;
459
+ name: string;
460
+ internal_notes: string;
461
+ external_notes: string;
462
+ proof_amt: number;
463
+ images: string[];
464
+ time_created: number;
465
+ time_updated: number | null;
466
+ status: "PENDING_CUSTOMER" | "PENDING_COMPANY" | "ACTIVE" | "ARCHIVED" | "DRAFT";
467
+ created_by: UserCompanyAssociation | null;
468
+ overdueness: number | null;
469
+ overdue_time: number;
470
+ last_completed_event: _Event | null;
471
+ last_event: _Event | null;
472
+ delay: number;
473
+ skills: string[];
474
+ service: number;
475
+ bill_mode: "MONTH" | "SERVICE" | "NONE";
476
+ price: number;
477
+ services_remaining: number;
478
+ expire_on: number | null;
479
+ bill_day: number | null;
480
+ services_prepaid: number;
481
+ months_prepaid: number;
482
+ priority: boolean;
483
+ route_ids: string[];
484
+ }
485
+ export interface TaskWrapper {
486
+ latestEvent: number;
487
+ task: Task;
488
+ }
489
+ export interface JobWrapper {
490
+ latestEvent: number;
491
+ routeIndex: number;
492
+ job: Job;
493
+ frequency: number;
494
+ isOverdue: boolean;
495
+ }
496
+ export interface taskStartInfo {
497
+ name: string;
498
+ start: number;
499
+ }
500
+ export interface taskEndInfo {
501
+ end: number;
502
+ internal_notes: string;
503
+ external_notes: string;
504
+ }
505
+ export interface AdditionalCharge extends LineItem {
506
+ line_item_type: "ADDITIONAL_CHARGE";
507
+ time_updated: number | null;
508
+ }
509
+ export interface _Event extends LineItem {
510
+ breaks: string[];
511
+ line_item_type: "EVENT";
512
+ internal_notes: string;
513
+ external_notes: string;
514
+ proofs: string[];
515
+ tasks: string[];
516
+ time_ended: number;
517
+ time_started: number;
518
+ time_updated: number | null;
519
+ job_id: string;
520
+ job_name: string;
521
+ job_address: string;
522
+ bill_id: string;
523
+ billed_amount: number;
524
+ additional_charges: AdditionalCharge[];
525
+ user_id: string;
526
+ team_id: string;
527
+ billed: boolean;
528
+ paid: boolean;
529
+ autostart: boolean;
530
+ job_labels: string[];
531
+ }
532
+ export interface FinancialInsightData {
533
+ start: number;
534
+ end: number;
535
+ unbilled: {
536
+ events: {
537
+ count: number;
538
+ amount: number;
539
+ };
540
+ service_months: {
541
+ count: number;
542
+ amount: number;
543
+ };
544
+ total: number;
17
545
  };
18
- status: 'active' | 'pending' | 'complete';
546
+ billed_unbilled: {
547
+ events: {
548
+ count: number;
549
+ amount: number;
550
+ };
551
+ service_months: {
552
+ count: number;
553
+ amount: number;
554
+ };
555
+ total: number;
556
+ };
557
+ paid_unbilled: {
558
+ events: {
559
+ count: number;
560
+ amount: number;
561
+ };
562
+ service_months: {
563
+ count: number;
564
+ amount: number;
565
+ };
566
+ total: number;
567
+ };
568
+ prepaid: {
569
+ events: {
570
+ count: number;
571
+ amount: number;
572
+ };
573
+ service_months: {
574
+ count: number;
575
+ amount: number;
576
+ };
577
+ total: number;
578
+ };
579
+ accounts_receivable: {
580
+ overdue: number;
581
+ not_overdue: number;
582
+ };
583
+ cash: number;
584
+ }
585
+ export interface EventInsightData {
586
+ start: number;
587
+ end: number;
588
+ events_per_job: {
589
+ id: string;
590
+ name: string;
591
+ event_count: number;
592
+ }[];
593
+ events_per_team: {
594
+ team_id: string;
595
+ event_count: number;
596
+ }[];
597
+ total_events: number;
19
598
  }
package/dist/types/api.js CHANGED
@@ -1 +1,10 @@
1
- export {};
1
+ export const NotificationLevel = {
2
+ IN_APP: 0,
3
+ EMAIL: 1,
4
+ SMS: 2,
5
+ PUSH: 3
6
+ };
7
+ export const LoginResponse = {
8
+ SUCCESS: "SUCCESS",
9
+ NEEDS_TOTP: "NEEDS_TOTP",
10
+ };
@@ -2,8 +2,3 @@ export interface Tokens {
2
2
  access_token: string;
3
3
  refresh_token: string;
4
4
  }
5
- export interface TokenStorage {
6
- get(): Promise<Tokens | null>;
7
- set(tokens: Tokens): Promise<void>;
8
- clear(): Promise<void>;
9
- }
@@ -0,0 +1,9 @@
1
+ import { Tokens } from "../types/auth";
2
+ export interface CacheData extends Tokens {
3
+ companyId: string;
4
+ }
5
+ export interface Cache {
6
+ get(key?: keyof CacheData): Promise<CacheData | string | null>;
7
+ set(data: Partial<CacheData>): Promise<void>;
8
+ clear(): Promise<void>;
9
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "0.0.2-beta.1",
3
+ "version": "0.0.2-beta.100",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -32,15 +32,13 @@
32
32
  "author": "Avro <info@goavro.com>",
33
33
  "license": "CC-BY-SA-4.0",
34
34
  "devDependencies": {
35
- "@types/jest": "^29.0.0",
35
+ "@types/react": "^19.2.2",
36
36
  "@typescript-eslint/eslint-plugin": "^8.38.0",
37
37
  "@typescript-eslint/parser": "^8.38.0",
38
38
  "eslint": "^8.57.1",
39
39
  "eslint-plugin-import": "^2.32.0",
40
40
  "eslint-plugin-jsx-a11y": "^6.10.2",
41
41
  "eslint-plugin-react": "^7.37.5",
42
- "jest": "^29.0.0",
43
- "ts-jest": "^29.0.0",
44
42
  "tsc-alias": "^1.8.16",
45
43
  "typescript": "^5.8.3",
46
44
  "typescript-eslint": "^8.38.0"
@@ -50,5 +48,9 @@
50
48
  ],
51
49
  "publishConfig": {
52
50
  "access": "public"
51
+ },
52
+ "dependencies": {
53
+ "@tanstack/react-query": "^5.90.2",
54
+ "socket.io-client": "^4.8.1"
53
55
  }
54
56
  }