@go-avro/avro-js 1.6.4-rc2 → 1.6.4-rc3

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 (67) hide show
  1. package/dist/client/QueryClient.d.ts +57 -52
  2. package/dist/client/QueryClient.js +45 -22
  3. package/dist/client/hooks/audit.js +4 -2
  4. package/dist/client/hooks/avro.js +6 -2
  5. package/dist/client/hooks/bills.d.ts +1 -1
  6. package/dist/client/hooks/bills.js +23 -3
  7. package/dist/client/hooks/catalog_items.js +4 -1
  8. package/dist/client/hooks/companies.js +4 -2
  9. package/dist/client/hooks/events.js +7 -5
  10. package/dist/client/hooks/jobs.js +26 -3
  11. package/dist/client/hooks/messages.js +6 -2
  12. package/dist/client/hooks/plans.js +1 -1
  13. package/dist/client/hooks/routes.js +31 -1
  14. package/dist/client/hooks/sessions.js +10 -3
  15. package/dist/client/hooks/skills.js +1 -1
  16. package/dist/client/hooks/timecards.js +2 -1
  17. package/dist/client/hooks/users.js +5 -2
  18. package/dist/client/realtime.js +8 -3
  19. package/dist/client/requests.d.ts +221 -0
  20. package/dist/client/requests.js +5 -0
  21. package/dist/client/wire.d.ts +7 -0
  22. package/dist/client/wire.js +14 -0
  23. package/dist/index.d.ts +1 -0
  24. package/dist/types/api/AdditionalCharge.d.ts +2 -1
  25. package/dist/types/api/Avro.d.ts +33 -28
  26. package/dist/types/api/Bill.d.ts +7 -5
  27. package/dist/types/api/BillPayment.d.ts +8 -4
  28. package/dist/types/api/BillUser.d.ts +3 -2
  29. package/dist/types/api/CatalogItem.d.ts +9 -6
  30. package/dist/types/api/Chat.d.ts +3 -5
  31. package/dist/types/api/Company.d.ts +39 -13
  32. package/dist/types/api/DelayEvent.d.ts +5 -2
  33. package/dist/types/api/Email.d.ts +14 -3
  34. package/dist/types/api/Friendship.d.ts +8 -0
  35. package/dist/types/api/Group.d.ts +3 -2
  36. package/dist/types/api/Job.d.ts +24 -3
  37. package/dist/types/api/LineItem.d.ts +3 -2
  38. package/dist/types/api/MemberState.d.ts +2 -1
  39. package/dist/types/api/Message.d.ts +4 -3
  40. package/dist/types/api/Notification.d.ts +26 -0
  41. package/dist/types/api/PaymentMethod.d.ts +7 -2
  42. package/dist/types/api/PaymentOption.d.ts +6 -4
  43. package/dist/types/api/Payout.d.ts +1 -1
  44. package/dist/types/api/Plan.d.ts +5 -4
  45. package/dist/types/api/PlanPayment.d.ts +5 -3
  46. package/dist/types/api/Prepayment.d.ts +2 -1
  47. package/dist/types/api/Reaction.d.ts +3 -3
  48. package/dist/types/api/Refund.d.ts +1 -1
  49. package/dist/types/api/Route.d.ts +11 -10
  50. package/dist/types/api/Route.js +5 -0
  51. package/dist/types/api/RouteJob.d.ts +1 -1
  52. package/dist/types/api/ServiceMonth.d.ts +2 -2
  53. package/dist/types/api/Session.d.ts +5 -2
  54. package/dist/types/api/Skill.d.ts +2 -2
  55. package/dist/types/api/Subscription.d.ts +5 -3
  56. package/dist/types/api/Task.d.ts +10 -9
  57. package/dist/types/api/Task.js +3 -1
  58. package/dist/types/api/TimecardAction.d.ts +2 -2
  59. package/dist/types/api/User.d.ts +11 -9
  60. package/dist/types/api/UserCompanyAssociation.d.ts +7 -1
  61. package/dist/types/api/UserMerge.d.ts +3 -3
  62. package/dist/types/api/_Event.d.ts +20 -4
  63. package/dist/types/api/_Event.js +1 -0
  64. package/dist/types/api.d.ts +45 -28
  65. package/dist/version.d.ts +1 -1
  66. package/dist/version.js +1 -1
  67. package/package.json +1 -1
@@ -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
  }
@@ -82,52 +82,63 @@ export type AppleLinkProof = {
82
82
  appleToken: string;
83
83
  authorizationCode?: string | null;
84
84
  };
85
+ /** Health of one backend dependency, as `GET /` reports it. */
86
+ export type ServiceStatusValue = 'ready' | 'starting' | 'dead' | 'unknown';
85
87
  export interface ApiInfo {
88
+ /** App versions this backend supports, e.g. `>=1.5.0`. */
86
89
  app_semver: string;
87
90
  build_time: string;
88
91
  commit: string;
89
- db_status: string;
92
+ db_status: ServiceStatusValue;
93
+ /** The caller's full name, or `anonymous user`. */
90
94
  logged_in_as: string;
91
95
  max_images: number;
92
- ors_status: string;
93
- pelias_status: string;
96
+ ors_status: ServiceStatusValue;
97
+ pelias_status: ServiceStatusValue;
94
98
  version: string;
95
- vroom_status: string;
99
+ vroom_status: ServiceStatusValue;
96
100
  }
101
+ /**
102
+ * One stop of a team's schedule (`POST /company/<id>/schedule`).
103
+ * `location` is `[latitude, longitude]`; `time_window` is a
104
+ * `[start, end]` pair of integer Unix seconds (fractions are rejected).
105
+ */
97
106
  export type ScheduleItem = {
98
107
  type: 'location';
99
108
  location: [number, number];
100
109
  time_window: [number, number];
101
- } | {
102
- type: 'break';
103
- start: [number, number];
104
- time_window: [number, number];
105
110
  } | {
106
111
  type: 'job';
107
- job_id: string;
112
+ /** Echoed back in `schedule_adjustments`; not read. */
113
+ job_id?: string | null;
108
114
  task_ids: string[];
109
115
  location: [number, number];
110
116
  time_window: [number, number];
111
117
  };
112
118
  export type TeamSchedule = {
113
119
  team_id: string;
114
- schedule: ScheduleItem[];
115
- name: string;
116
- optimize: boolean;
117
- frequency: FrequencyType;
120
+ /** Ordered by start time; defaults to `[]`. */
121
+ schedule?: ScheduleItem[];
122
+ /** 1–255 characters; omit for `Route for <team name>`. */
123
+ name?: string | null;
124
+ /** Defaults to true. */
125
+ optimize?: boolean;
126
+ /** Upper-case `FrequencyType`; defaults to `ONCE`. */
127
+ frequency?: FrequencyType;
118
128
  };
119
129
  export type RouteScheduleConfig = {
120
- schedules: TeamSchedule[];
121
- whitelist: string[];
122
- blacklist: string[];
123
- tasks: {
130
+ schedules?: TeamSchedule[];
131
+ whitelist?: string[];
132
+ blacklist?: string[];
133
+ /** Task ids, or `{task, depends_on}` entries. */
134
+ tasks?: (string | {
124
135
  task: string;
125
- depends_on: string[];
126
- }[];
136
+ depends_on?: string[];
137
+ })[];
127
138
  };
128
139
  export interface Location {
129
- accuracy: number;
130
- heading: number;
140
+ accuracy: number | null;
141
+ heading: number | null;
131
142
  id: string;
132
143
  team_id: string | null;
133
144
  user_company_id: string;
@@ -136,30 +147,29 @@ export interface Location {
136
147
  version: string | null;
137
148
  latitude: number;
138
149
  longitude: number;
139
- time_collected: number;
140
- time_created: number;
150
+ time_collected: number | null;
151
+ time_created: number | null;
141
152
  time_updated: number | null;
142
153
  }
143
154
  export interface Team {
144
155
  autoconfigure: boolean;
145
- company_id: string;
146
156
  description: string;
147
- end: number[];
148
157
  end_time: number;
149
158
  fixed_cost: number;
150
159
  hourly_cost: number;
151
160
  id: string;
152
- items: string[];
153
161
  km_cost: number;
154
162
  max_distance: number;
155
163
  max_jobs: number;
156
164
  max_travel_time: number;
157
165
  color: string;
158
166
  name: string;
159
- profile: string;
167
+ /** Route ids; empty unless the viewer can read routes. */
160
168
  routes: string[];
169
+ /** Skill ids; empty unless the viewer can read skills. */
161
170
  skills: string[];
162
171
  speed_factor: number;
172
+ /** 0 when the team has no start point. */
163
173
  start_latitude: number;
164
174
  start_longitude: number;
165
175
  end_latitude: number;
@@ -169,6 +179,8 @@ export interface Team {
169
179
  current_location: Location | null;
170
180
  start_address: string;
171
181
  end_address: string;
182
+ time_created: number | null;
183
+ time_updated: number | null;
172
184
  }
173
185
  export interface taskStartInfo {
174
186
  name: string;
@@ -225,7 +237,7 @@ export interface CheckIn {
225
237
  team_id: string | null;
226
238
  company_id: string;
227
239
  event_id: string | null;
228
- time_checked_in: number;
240
+ time_checked_in: number | null;
229
241
  time_checked_out: number | null;
230
242
  time_created: number | null;
231
243
  time_updated: number | null;
@@ -259,11 +271,15 @@ export interface DelayEventCreatePayload {
259
271
  job_id: string;
260
272
  /** Task ids (guids) whose schedule this delay pushes back. */
261
273
  tasks: string[];
274
+ /** Whole seconds, 1 to 366 days. */
262
275
  delay_seconds: number;
276
+ /** 1–254 characters when sent. */
263
277
  name?: string;
264
278
  internal_notes?: string;
265
279
  external_notes?: string;
266
280
  description?: string;
281
+ /** Names of existing images to copy onto the delay. */
282
+ images?: string[];
267
283
  }
268
284
  export interface EventInsightData {
269
285
  start: number;
@@ -273,6 +289,7 @@ export interface EventInsightData {
273
289
  name: string;
274
290
  event_count: number;
275
291
  }[];
292
+ /** `team_id` is the string `"None"` for sessions without a team. */
276
293
  events_per_team: {
277
294
  team_id: string;
278
295
  event_count: number;
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const AVRO_JS_VERSION = "1.6.4-rc2";
1
+ export declare const AVRO_JS_VERSION = "1.6.4-rc3";
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // AUTO-GENERATED by scripts/gen-version.js — do not edit by hand.
2
2
  // Regenerated from package.json by the `prebuild` npm hook.
3
- export const AVRO_JS_VERSION = '1.6.4-rc2';
3
+ export const AVRO_JS_VERSION = '1.6.4-rc3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "1.6.4-rc2",
3
+ "version": "1.6.4-rc3",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",