@go-avro/avro-js 1.6.5 → 1.6.6-rc10

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 (73) hide show
  1. package/dist/client/QueryClient.d.ts +150 -60
  2. package/dist/client/QueryClient.js +175 -27
  3. package/dist/client/core/xhr.js +2 -1
  4. package/dist/client/hooks/audit.js +4 -2
  5. package/dist/client/hooks/avro.js +19 -2
  6. package/dist/client/hooks/bills.d.ts +1 -1
  7. package/dist/client/hooks/bills.js +54 -16
  8. package/dist/client/hooks/catalog_items.js +20 -5
  9. package/dist/client/hooks/chats.js +33 -1
  10. package/dist/client/hooks/companies.js +38 -4
  11. package/dist/client/hooks/events.js +13 -9
  12. package/dist/client/hooks/jobs.js +29 -3
  13. package/dist/client/hooks/messages.js +6 -2
  14. package/dist/client/hooks/plans.js +1 -1
  15. package/dist/client/hooks/routes.js +55 -5
  16. package/dist/client/hooks/sessions.js +39 -11
  17. package/dist/client/hooks/skills.js +1 -1
  18. package/dist/client/hooks/teams.js +5 -2
  19. package/dist/client/hooks/timecards.js +2 -1
  20. package/dist/client/hooks/users.js +21 -3
  21. package/dist/client/realtime.d.ts +13 -0
  22. package/dist/client/realtime.js +41 -8
  23. package/dist/client/requests.d.ts +503 -0
  24. package/dist/client/requests.js +5 -0
  25. package/dist/client/wire.d.ts +7 -0
  26. package/dist/client/wire.js +14 -0
  27. package/dist/index.d.ts +1 -0
  28. package/dist/types/api/AdditionalCharge.d.ts +2 -1
  29. package/dist/types/api/Avro.d.ts +72 -21
  30. package/dist/types/api/Bill.d.ts +7 -5
  31. package/dist/types/api/BillPayment.d.ts +8 -4
  32. package/dist/types/api/BillUser.d.ts +3 -2
  33. package/dist/types/api/CatalogItem.d.ts +11 -6
  34. package/dist/types/api/Chat.d.ts +3 -5
  35. package/dist/types/api/Company.d.ts +41 -15
  36. package/dist/types/api/DelayEvent.d.ts +5 -2
  37. package/dist/types/api/Device.d.ts +5 -4
  38. package/dist/types/api/Email.d.ts +14 -3
  39. package/dist/types/api/Friendship.d.ts +8 -0
  40. package/dist/types/api/Group.d.ts +3 -2
  41. package/dist/types/api/Job.d.ts +55 -5
  42. package/dist/types/api/LineItem.d.ts +3 -2
  43. package/dist/types/api/MemberState.d.ts +2 -1
  44. package/dist/types/api/Message.d.ts +4 -3
  45. package/dist/types/api/Notification.d.ts +26 -0
  46. package/dist/types/api/PaymentMethod.d.ts +7 -2
  47. package/dist/types/api/PaymentOption.d.ts +6 -4
  48. package/dist/types/api/Payout.d.ts +1 -1
  49. package/dist/types/api/Plan.d.ts +5 -4
  50. package/dist/types/api/PlanPayment.d.ts +5 -3
  51. package/dist/types/api/Prepayment.d.ts +2 -1
  52. package/dist/types/api/Proposal.d.ts +1 -1
  53. package/dist/types/api/Reaction.d.ts +3 -3
  54. package/dist/types/api/Refund.d.ts +1 -1
  55. package/dist/types/api/Route.d.ts +11 -10
  56. package/dist/types/api/Route.js +5 -0
  57. package/dist/types/api/RouteJob.d.ts +1 -1
  58. package/dist/types/api/ServiceMonth.d.ts +2 -2
  59. package/dist/types/api/Session.d.ts +5 -2
  60. package/dist/types/api/Skill.d.ts +2 -2
  61. package/dist/types/api/Subscription.d.ts +5 -3
  62. package/dist/types/api/Task.d.ts +10 -9
  63. package/dist/types/api/Task.js +3 -1
  64. package/dist/types/api/TimecardAction.d.ts +2 -2
  65. package/dist/types/api/User.d.ts +11 -9
  66. package/dist/types/api/UserCompanyAssociation.d.ts +7 -1
  67. package/dist/types/api/UserMerge.d.ts +3 -3
  68. package/dist/types/api/_Event.d.ts +20 -4
  69. package/dist/types/api/_Event.js +1 -0
  70. package/dist/types/api.d.ts +156 -39
  71. package/dist/version.d.ts +1 -1
  72. package/dist/version.js +1 -1
  73. package/package.json +1 -1
@@ -2,9 +2,11 @@ export interface PlanPayment {
2
2
  id: string;
3
3
  amount: number;
4
4
  stripe_pi_id: string;
5
+ /** The string "None" once the company is deleted. */
5
6
  company_id: string;
7
+ /** The string "None" once the plan is deleted. */
6
8
  plan_id: string;
7
- status: 'created' | 'processing' | 'succeeded' | 'failed' | 'canceled';
8
- time_created: number;
9
- time_updated: number;
9
+ status: 'created' | 'processing' | 'in_transit' | 'deposited' | 'succeeded' | 'failed' | 'canceled' | 'requires_action';
10
+ time_created: number | null;
11
+ time_updated: number | null;
10
12
  }
@@ -7,7 +7,8 @@ declare module './Prepayment.js' {
7
7
  job_name: string;
8
8
  job_address: string;
9
9
  type: 'SERVICE' | 'MONTH';
10
- time_updated: number | null;
10
+ /** Same as `type`. */
11
+ prepayment_type: 'SERVICE' | 'MONTH';
11
12
  num_events: number;
12
13
  num_service_months: number;
13
14
  }
@@ -6,7 +6,7 @@ export interface Proposal {
6
6
  job_id: string;
7
7
  expire_on: number | null;
8
8
  expired: boolean;
9
- terms: ProposalTermsVersion | null;
9
+ terms: ProposalTermsVersion[];
10
10
  accepted_at: number | null;
11
11
  tasks: Task[];
12
12
  }
@@ -2,7 +2,7 @@ export interface Reaction {
2
2
  id: string;
3
3
  message_id: string;
4
4
  sender_id: string;
5
- reaction: string;
6
- time_created: number;
7
- time_updated: number;
5
+ reaction: number;
6
+ time_created: number | null;
7
+ time_updated: number | null;
8
8
  }
@@ -8,6 +8,6 @@ export interface Refund {
8
8
  amount: number;
9
9
  stripe_pi_id: string;
10
10
  status: 'created' | 'processing' | 'succeeded' | 'failed' | 'canceled' | 'requires_action' | 'in_transit' | 'deposited';
11
- time_created: number;
11
+ time_created: number | null;
12
12
  time_updated: number | null;
13
13
  }
@@ -13,21 +13,22 @@ declare module './Route.js' {
13
13
  interface Route {
14
14
  company: string;
15
15
  id: string;
16
- is_internal: boolean;
16
+ /** Empty unless the viewer can read jobs. */
17
17
  jobs: RouteJob[];
18
18
  name: string;
19
- time_created: number;
19
+ time_created: number | null;
20
20
  time_updated: number | null;
21
+ /** Team GUIDs. */
21
22
  teams: string[];
22
- polyline: string;
23
+ polyline: string | null;
23
24
  is_optimized: boolean;
24
- start_time: number;
25
- end_time: number;
26
- start_latitude: number;
27
- start_longitude: number;
28
- end_latitude: number;
29
- end_longitude: number;
30
- frequency: (typeof FrequencyType)[keyof typeof FrequencyType];
25
+ start_time: number | null;
26
+ end_time: number | null;
27
+ start_latitude: number | null;
28
+ start_longitude: number | null;
29
+ end_latitude: number | null;
30
+ end_longitude: number | null;
31
+ frequency: FrequencyType | null;
31
32
  }
32
33
  }
33
34
  export declare class Route {
@@ -29,6 +29,8 @@ export class Route {
29
29
  return next_occurrences;
30
30
  };
31
31
  this.getNextOccurrence = (after = new Date()) => {
32
+ if (this.start_time == null)
33
+ return null;
32
34
  let next_occurrence = new Date(this.start_time * 1000);
33
35
  while (next_occurrence <= after) {
34
36
  switch (this.frequency) {
@@ -49,6 +51,9 @@ export class Route {
49
51
  case FrequencyType.YEARLY:
50
52
  next_occurrence.setFullYear(next_occurrence.getFullYear() + 1);
51
53
  break;
54
+ default:
55
+ // No frequency: a one-off route that has already started.
56
+ return null;
52
57
  }
53
58
  }
54
59
  return next_occurrence;
@@ -1,6 +1,6 @@
1
1
  declare module './RouteJob.js' {
2
2
  interface RouteJob {
3
- time_created: number;
3
+ time_created: number | null;
4
4
  route_id: string;
5
5
  job_id: string;
6
6
  id: string;
@@ -5,7 +5,7 @@ export interface ServiceMonth extends LineItem {
5
5
  job_name: string;
6
6
  job_address: string;
7
7
  bill_id: string | null;
8
- tasks: string[];
8
+ /** Task GUIDs; null where the task was deleted. */
9
+ tasks: (string | null)[];
9
10
  task_names: string[];
10
- time_updated: number | null;
11
11
  }
@@ -2,15 +2,18 @@ import { Break } from './Break.js';
2
2
  declare module './Session.js' {
3
3
  interface Session {
4
4
  id: string;
5
+ /** Same as `id`. */
6
+ session_id: string;
5
7
  user_id: string;
6
8
  company_id: string;
7
- time_started: number;
9
+ time_started: number | null;
8
10
  time_ended: number | null;
9
11
  break_id: string | null;
10
12
  is_paused: boolean;
11
13
  team_id: string | null;
14
+ /** Same as `current_route_id`. */
12
15
  route_id: string | null;
13
- current_route_id?: string | null;
16
+ current_route_id: string | null;
14
17
  breaks: Break[];
15
18
  }
16
19
  }
@@ -2,6 +2,6 @@ export interface Skill {
2
2
  id: string;
3
3
  name: string;
4
4
  company_id: string;
5
- time_created: number;
6
- time_updated: number;
5
+ time_created: number | null;
6
+ time_updated: number | null;
7
7
  }
@@ -1,8 +1,10 @@
1
+ import type { NotificationLevel } from './UserCompanyAssociation.js';
1
2
  export interface Subscription {
2
- time_created: number;
3
- time_updated: string;
3
+ time_created: number | null;
4
+ time_updated: number | null;
5
+ /** The subscribed membership; the string "None" for a group subscription. */
4
6
  user_company_id: string;
5
7
  job_id: string;
6
8
  id: string;
7
- notifications: number;
9
+ notifications: NotificationLevel[];
8
10
  }
@@ -1,4 +1,3 @@
1
- import { UserCompanyAssociation } from './UserCompanyAssociation.js';
2
1
  import { Prepayment } from './Prepayment.js';
3
2
  import { PaymentOption } from './PaymentOption.js';
4
3
  import { _Event } from './_Event.js';
@@ -30,8 +29,9 @@ export type UnroutedReason = (typeof UnroutedReason)[keyof typeof UnroutedReason
30
29
  export declare const UNROUTED_REASON_LABELS: Record<UnroutedReason, string>;
31
30
  declare module './Task.js' {
32
31
  interface Task {
33
- enforce_image_amount: boolean;
34
- events: _Event[];
32
+ enforce_image_amount: boolean | null;
33
+ /** Legacy key; always empty. */
34
+ events: never[];
35
35
  payment_options: PaymentOption[];
36
36
  frequency: number;
37
37
  id: string;
@@ -41,16 +41,15 @@ declare module './Task.js' {
41
41
  external_notes: string;
42
42
  image_amt: number;
43
43
  images: string[];
44
- time_created: number;
44
+ time_created: number | null;
45
45
  time_updated: number | null;
46
46
  status: TaskStatus;
47
- created_by: UserCompanyAssociation | null;
48
47
  /**
49
- * Overdueness as of `overdue_at`. It grows with time while nothing
50
- * in the database changes, so no realtime event refreshes it:
51
- * prefer `getOverdueness()`.
48
+ * Overdueness as of `overdue_at` (-1 when the task isn't active). It
49
+ * grows with time while nothing in the database changes, so no
50
+ * realtime event refreshes it: prefer `getOverdueness()`.
52
51
  */
53
- overdueness: number | null;
52
+ overdueness: number;
54
53
  /** Seconds overdue as of `overdue_at`; prefer `getOverdueTime()`. */
55
54
  overdue_time: number;
56
55
  /**
@@ -86,6 +85,8 @@ declare module './Task.js' {
86
85
  pay_in_cash: boolean;
87
86
  priority: boolean;
88
87
  route_ids: string[];
88
+ /** Fraction of routing runs that put the task on a route. */
89
+ favorability: number;
89
90
  }
90
91
  }
91
92
  /**
@@ -123,6 +123,8 @@ export class Task {
123
123
  this.getNextDue = () => {
124
124
  if (this.frequency > 0 && this.status === TaskStatus.ACTIVE) {
125
125
  const lastEventTime = this.last_completed_event?.time_ended ?? this.activate_on ?? this.time_created;
126
+ if (lastEventTime == null)
127
+ return null;
126
128
  const due = lastEventTime + this.frequency;
127
129
  // A delay holds the task off until it ends, then lapses.
128
130
  return Math.max(due, this.getDelayUntil() ?? due);
@@ -180,7 +182,7 @@ export class Task {
180
182
  // an early-started visit that finishes a few minutes before
181
183
  // route.start_time) while still rejecting stale events from previous
182
184
  // occurrences. Applies to both recurring and one-shot tasks.
183
- const routeDay = new Date(route.start_time * 1000);
185
+ const routeDay = new Date((route.start_time ?? 0) * 1000);
184
186
  routeDay.setHours(0, 0, 0, 0);
185
187
  const cutoff = Math.floor(routeDay.getTime() / 1000);
186
188
  return (this.last_completed_event?.time_ended ?? 0) >= cutoff;
@@ -10,8 +10,8 @@ export type TimecardActionType = (typeof TimecardActionType)[keyof typeof Timeca
10
10
  export interface TimecardAction {
11
11
  id: string;
12
12
  action_type: TimecardActionType;
13
- first_name: string | null;
14
- last_name: string | null;
13
+ first_name: string;
14
+ last_name: string;
15
15
  details: string | null;
16
16
  time_created: number | null;
17
17
  time_updated: number | null;
@@ -1,6 +1,7 @@
1
1
  import { BillUser } from './BillUser.js';
2
2
  import { Device } from './Device.js';
3
3
  import { Chat } from './Chat.js';
4
+ import { Friendship } from './Friendship.js';
4
5
  import { PaymentMethod } from './PaymentMethod.js';
5
6
  import { PaymentType } from './PaymentType.js';
6
7
  import { NotificationLevel } from './UserCompanyAssociation.js';
@@ -13,18 +14,19 @@ export interface User {
13
14
  verified: boolean;
14
15
  email: string | null;
15
16
  phone_number: string | null;
16
- time_created: number;
17
+ time_created: number | null;
17
18
  time_updated: number | null;
18
- share_location: boolean;
19
+ share_location: boolean | null;
19
20
  devices: Device[] | null;
20
21
  notification_setting: NotificationLevel[] | null;
21
- can_send_emails: boolean | null;
22
- payment_methods: PaymentMethod[];
23
- autopay_payment_types: PaymentType[];
24
- autopay: boolean | null;
25
- chats: Chat[];
26
- bills: BillUser[];
27
- is_root: boolean;
22
+ friends: Friendship[] | null;
23
+ autopay_payment_types: PaymentType[] | null;
24
+ payment_methods: PaymentMethod[] | null;
25
+ chats: Chat[] | null;
26
+ bills: BillUser[] | null;
27
+ /** Legacy key, always empty. */
28
+ companies: never[];
29
+ is_root: boolean | null;
28
30
  apple: {
29
31
  linked: boolean;
30
32
  email_forwarding: boolean | null;
@@ -1,5 +1,6 @@
1
1
  import { User } from './User.js';
2
2
  import { Location } from '../api.js';
3
+ import { NotificationUserCompany } from './Notification.js';
3
4
  export declare const Permission: {
4
5
  readonly CAN_WRITE_COMPANY: "can_write_company";
5
6
  readonly CAN_READ_GROUPS: "can_read_groups";
@@ -70,7 +71,12 @@ export declare const LocationServicesStatus: {
70
71
  export type LocationServicesStatus = (typeof LocationServicesStatus)[keyof typeof LocationServicesStatus];
71
72
  export interface UserCompanyAssociation {
72
73
  id: string;
74
+ /**
75
+ * The member's user. The backend's schema also allows their internal
76
+ * integer id (serialized without `recurse`), but no endpoint sends that.
77
+ */
73
78
  user: User;
79
+ /** The viewer's company id. */
74
80
  company: string;
75
81
  hourly_rate: number;
76
82
  salary_rate: number;
@@ -87,7 +93,7 @@ export interface UserCompanyAssociation {
87
93
  time_updated: number | null;
88
94
  notification_setting: NotificationLevel[];
89
95
  share_email_company_wide: boolean;
90
- notifications: Notification[];
96
+ notifications: NotificationUserCompany[];
91
97
  groups: string[];
92
98
  last_location: Location | null;
93
99
  }
@@ -3,12 +3,12 @@
3
3
  * /user/{keepId}/merge`). The same shape answers the dry-run preview.
4
4
  */
5
5
  export interface UserMergeSummary {
6
- msg: string;
6
+ msg: 'Users merged' | 'Merge preview';
7
7
  /** Rows moved per table, keyed by table name; tables with none are left out. */
8
8
  rows: Record<string, number>;
9
- /** Companies only the duplicate belonged to; the kept account joins them. */
9
+ /** Names of companies only the duplicate belonged to; the kept account joins them. */
10
10
  companies_moved: string[];
11
- /** Companies both belonged to; the duplicate's membership is folded in. */
11
+ /** Names of companies both belonged to; the duplicate's membership is folded in. */
12
12
  companies_folded: string[];
13
13
  /** Saved payment methods removed with the duplicate's Stripe customer. */
14
14
  payment_methods_dropped: number;
@@ -1,6 +1,7 @@
1
1
  import { LineItem } from './LineItem.js';
2
2
  import { AdditionalCharge } from './AdditionalCharge.js';
3
3
  import { UserEvent } from './UserEvent.js';
4
+ import type { NotificationLevel } from './UserCompanyAssociation.js';
4
5
  declare module './_Event.js' {
5
6
  interface _Event extends LineItem {
6
7
  breaks: string[];
@@ -14,16 +15,31 @@ declare module './_Event.js' {
14
15
  tasks: string[];
15
16
  task_names: string[];
16
17
  time_ended: number | null;
17
- time_started: number;
18
- time_updated: number | null;
19
- bill_id: string;
20
- billed_amount: number;
18
+ time_started: number | null;
19
+ bill_id: string | null;
21
20
  earned_revenue: number;
22
21
  additional_charges: AdditionalCharge[];
23
22
  users: UserEvent[];
24
23
  team_id: string | null;
24
+ team_name: string | null;
25
+ /** Notifications sent about this event. */
26
+ alerts: EventAlert[];
25
27
  }
26
28
  }
29
+ /** A notification attached to an event (`_Event.alerts`). */
30
+ export interface EventAlert {
31
+ id: string;
32
+ subject: string;
33
+ body: string;
34
+ is_offer: boolean;
35
+ offer_amt: number;
36
+ accepted: boolean;
37
+ /** Event GUID; the string "None" when not tied to an event. */
38
+ event_id: string;
39
+ notification_levels: NotificationLevel[];
40
+ time_created: number | null;
41
+ time_updated: number | null;
42
+ }
27
43
  export declare class _Event extends LineItem {
28
44
  constructor(init?: Partial<_Event>);
29
45
  getCost: () => number;
@@ -14,5 +14,6 @@ export class _Event extends LineItem {
14
14
  this.task_names = init?.task_names ?? [];
15
15
  this.additional_charges = init?.additional_charges ?? [];
16
16
  this.users = init?.users ?? [];
17
+ this.alerts = init?.alerts ?? [];
17
18
  }
18
19
  }