@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.
- package/dist/client/QueryClient.d.ts +150 -60
- package/dist/client/QueryClient.js +175 -27
- package/dist/client/core/xhr.js +2 -1
- package/dist/client/hooks/audit.js +4 -2
- package/dist/client/hooks/avro.js +19 -2
- package/dist/client/hooks/bills.d.ts +1 -1
- package/dist/client/hooks/bills.js +54 -16
- package/dist/client/hooks/catalog_items.js +20 -5
- package/dist/client/hooks/chats.js +33 -1
- package/dist/client/hooks/companies.js +38 -4
- package/dist/client/hooks/events.js +13 -9
- package/dist/client/hooks/jobs.js +29 -3
- package/dist/client/hooks/messages.js +6 -2
- package/dist/client/hooks/plans.js +1 -1
- package/dist/client/hooks/routes.js +55 -5
- package/dist/client/hooks/sessions.js +39 -11
- package/dist/client/hooks/skills.js +1 -1
- package/dist/client/hooks/teams.js +5 -2
- package/dist/client/hooks/timecards.js +2 -1
- package/dist/client/hooks/users.js +21 -3
- package/dist/client/realtime.d.ts +13 -0
- package/dist/client/realtime.js +41 -8
- package/dist/client/requests.d.ts +503 -0
- package/dist/client/requests.js +5 -0
- package/dist/client/wire.d.ts +7 -0
- package/dist/client/wire.js +14 -0
- package/dist/index.d.ts +1 -0
- package/dist/types/api/AdditionalCharge.d.ts +2 -1
- package/dist/types/api/Avro.d.ts +72 -21
- package/dist/types/api/Bill.d.ts +7 -5
- package/dist/types/api/BillPayment.d.ts +8 -4
- package/dist/types/api/BillUser.d.ts +3 -2
- package/dist/types/api/CatalogItem.d.ts +11 -6
- package/dist/types/api/Chat.d.ts +3 -5
- package/dist/types/api/Company.d.ts +41 -15
- package/dist/types/api/DelayEvent.d.ts +5 -2
- package/dist/types/api/Device.d.ts +5 -4
- package/dist/types/api/Email.d.ts +14 -3
- package/dist/types/api/Friendship.d.ts +8 -0
- package/dist/types/api/Group.d.ts +3 -2
- package/dist/types/api/Job.d.ts +55 -5
- package/dist/types/api/LineItem.d.ts +3 -2
- package/dist/types/api/MemberState.d.ts +2 -1
- package/dist/types/api/Message.d.ts +4 -3
- package/dist/types/api/Notification.d.ts +26 -0
- package/dist/types/api/PaymentMethod.d.ts +7 -2
- package/dist/types/api/PaymentOption.d.ts +6 -4
- package/dist/types/api/Payout.d.ts +1 -1
- package/dist/types/api/Plan.d.ts +5 -4
- package/dist/types/api/PlanPayment.d.ts +5 -3
- package/dist/types/api/Prepayment.d.ts +2 -1
- package/dist/types/api/Proposal.d.ts +1 -1
- package/dist/types/api/Reaction.d.ts +3 -3
- package/dist/types/api/Refund.d.ts +1 -1
- package/dist/types/api/Route.d.ts +11 -10
- package/dist/types/api/Route.js +5 -0
- package/dist/types/api/RouteJob.d.ts +1 -1
- package/dist/types/api/ServiceMonth.d.ts +2 -2
- package/dist/types/api/Session.d.ts +5 -2
- package/dist/types/api/Skill.d.ts +2 -2
- package/dist/types/api/Subscription.d.ts +5 -3
- package/dist/types/api/Task.d.ts +10 -9
- package/dist/types/api/Task.js +3 -1
- package/dist/types/api/TimecardAction.d.ts +2 -2
- package/dist/types/api/User.d.ts +11 -9
- package/dist/types/api/UserCompanyAssociation.d.ts +7 -1
- package/dist/types/api/UserMerge.d.ts +3 -3
- package/dist/types/api/_Event.d.ts +20 -4
- package/dist/types/api/_Event.js +1 -0
- package/dist/types/api.d.ts +156 -39
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/client/realtime.js
CHANGED
|
@@ -20,6 +20,12 @@ export function listFilters(key) {
|
|
|
20
20
|
const f = key[3];
|
|
21
21
|
return f && typeof f === 'object' ? f : {};
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* List scope for viewer-scoped lists (e.g. the caller's own open sessions
|
|
25
|
+
* across companies). Not a company id: change batches for any company may
|
|
26
|
+
* touch it, so they're never skipped by the company check.
|
|
27
|
+
*/
|
|
28
|
+
export const VIEWER_SCOPE = 'mine';
|
|
23
29
|
export function listScope(key) {
|
|
24
30
|
return typeof key[2] === 'string' ? key[2] : '';
|
|
25
31
|
}
|
|
@@ -45,13 +51,13 @@ export function constructJob(raw) {
|
|
|
45
51
|
const job = new Job(raw);
|
|
46
52
|
job.current_event = job.tasks.reduce((latest, task) => {
|
|
47
53
|
return task.current_event &&
|
|
48
|
-
(!latest || task.current_event.time_started > latest.time_started)
|
|
54
|
+
(!latest || (task.current_event.time_started ?? 0) > (latest.time_started ?? 0))
|
|
49
55
|
? task.current_event
|
|
50
56
|
: latest;
|
|
51
57
|
}, job.current_event);
|
|
52
58
|
job.last_completed_event = job.tasks.reduce((latest, task) => {
|
|
53
59
|
return task.last_completed_event &&
|
|
54
|
-
(!latest || task.last_completed_event.time_started > latest.time_started)
|
|
60
|
+
(!latest || (task.last_completed_event.time_started ?? 0) > (latest.time_started ?? 0))
|
|
55
61
|
? task.last_completed_event
|
|
56
62
|
: latest;
|
|
57
63
|
}, job.last_completed_event);
|
|
@@ -66,6 +72,15 @@ function matchJobs(filters, item) {
|
|
|
66
72
|
}
|
|
67
73
|
return searchAware(filters);
|
|
68
74
|
}
|
|
75
|
+
function matchCatalogItems(filters, item) {
|
|
76
|
+
if (typeof filters.industry === 'string' && filters.industry !== item.industry) {
|
|
77
|
+
return 'nomatch';
|
|
78
|
+
}
|
|
79
|
+
if (typeof filters.archived === 'boolean' && filters.archived !== item.archived) {
|
|
80
|
+
return 'nomatch';
|
|
81
|
+
}
|
|
82
|
+
return searchAware(filters);
|
|
83
|
+
}
|
|
69
84
|
function isPaidStatus(status) {
|
|
70
85
|
return status === 'PAID' || status === 'PREPAID' || status === 'EXTERNALLY_PAID';
|
|
71
86
|
}
|
|
@@ -126,7 +141,7 @@ function matchBills(filters, item) {
|
|
|
126
141
|
}
|
|
127
142
|
function matchSessions(filters, item, scope) {
|
|
128
143
|
// "mine" comes from GET /session (viewer-scoped): can't tell ownership here.
|
|
129
|
-
if (scope ===
|
|
144
|
+
if (scope === VIEWER_SCOPE)
|
|
130
145
|
return 'unknown';
|
|
131
146
|
// `unknown_ids` on the sessions endpoint means "fetch exactly these".
|
|
132
147
|
const wanted = filters.unknown_ids;
|
|
@@ -176,7 +191,12 @@ function matchPayouts(filters, item) {
|
|
|
176
191
|
return 'unknown';
|
|
177
192
|
return searchAware(filters);
|
|
178
193
|
}
|
|
179
|
-
const bulk = (method, extra = {}) => (client, ids) =>
|
|
194
|
+
const bulk = (method, extra = {}) => (client, ids) =>
|
|
195
|
+
// List endpoints reject `amt: 0` (payouts/months require amt >= 1),
|
|
196
|
+
// and an empty `unknown_ids` would mean "no id filter" anyway.
|
|
197
|
+
ids.length === 0
|
|
198
|
+
? Promise.resolve([])
|
|
199
|
+
: client[method]({ ...extra, unknown_ids: ids, amt: ids.length });
|
|
180
200
|
/** Line-item list endpoints default to unbilled-only: ask for every bucket. */
|
|
181
201
|
const ALL_LINE_ITEM_STATUSES = { unbilled: true, billed: true, paid: true };
|
|
182
202
|
/** Single-entity GET (404/403 is treated as gone by the applier). */
|
|
@@ -222,11 +242,10 @@ export const REGISTRY = {
|
|
|
222
242
|
listMatch: searchAware,
|
|
223
243
|
alsoInvalidate: COMPANY_EMBEDS,
|
|
224
244
|
},
|
|
225
|
-
// No single-item GET exists: catalog items only live on the company.
|
|
226
245
|
catalog_item: {
|
|
227
246
|
ns: 'catalog_items',
|
|
228
|
-
|
|
229
|
-
|
|
247
|
+
fetchMany: bulk('fetchCatalogItems'),
|
|
248
|
+
listMatch: matchCatalogItems,
|
|
230
249
|
},
|
|
231
250
|
proposal: {
|
|
232
251
|
ns: 'proposals',
|
|
@@ -328,7 +347,7 @@ export function upsertEntity(qc, spec, item, company) {
|
|
|
328
347
|
for (const query of lists) {
|
|
329
348
|
const key = query.queryKey;
|
|
330
349
|
const scope = listScope(key);
|
|
331
|
-
if (company && scope && scope !== company)
|
|
350
|
+
if (company && scope && scope !== company && scope !== VIEWER_SCOPE)
|
|
332
351
|
continue;
|
|
333
352
|
const verdict = spec.listMatch
|
|
334
353
|
? spec.listMatch(listFilters(key), item, listScope(key))
|
|
@@ -362,6 +381,18 @@ export function invalidateType(qc, spec) {
|
|
|
362
381
|
qc.invalidateQueries({ queryKey: [spec.ns] });
|
|
363
382
|
spec.alsoInvalidate?.forEach((k) => qc.invalidateQueries({ queryKey: [...k] }));
|
|
364
383
|
}
|
|
384
|
+
/**
|
|
385
|
+
* Refetch every query the server refused with a 403. Called when a
|
|
386
|
+
* membership changes: the viewer may have just been granted the
|
|
387
|
+
* permission, and nothing else would retry a denied list until the next
|
|
388
|
+
* focus, remount, or reload.
|
|
389
|
+
*/
|
|
390
|
+
export function retryDenied(qc) {
|
|
391
|
+
qc.invalidateQueries({
|
|
392
|
+
predicate: (q) => q.state.status === 'error' &&
|
|
393
|
+
q.state.error?.status === 403,
|
|
394
|
+
});
|
|
395
|
+
}
|
|
365
396
|
// ─── Applying batches ───────────────────────────────────────────────
|
|
366
397
|
const FETCH_COALESCE_MS = 50;
|
|
367
398
|
const FETCH_CHUNK = 100;
|
|
@@ -414,6 +445,8 @@ export class ChangeApplier {
|
|
|
414
445
|
continue;
|
|
415
446
|
if (entry.op === 'invalidate' || spec.invalidateOnly) {
|
|
416
447
|
invalidateType(this.qc, spec);
|
|
448
|
+
if (entry.type === 'member')
|
|
449
|
+
retryDenied(this.qc);
|
|
417
450
|
if (spec.ns === 'users' && entry.id) {
|
|
418
451
|
this.qc.invalidateQueries({ queryKey: keys.detail('users', entry.id) });
|
|
419
452
|
}
|
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request bodies and endpoint-specific responses of the REST API, matching
|
|
3
|
+
* the backend's pydantic schemas (`avro/views/<domain>/schemas.py`).
|
|
4
|
+
*/
|
|
5
|
+
import type { CatalogIndustry, CatalogPriceFormat, EventUpdatePayload, LineItemStatus, NotificationLevel, PaymentType, Permission, TaskStatus } from '../types/api.js';
|
|
6
|
+
/** Body of `POST /company/<id>/skill` (backend `CreateSkill`). */
|
|
7
|
+
export interface SkillCreatePayload {
|
|
8
|
+
/** 1–255 characters. */
|
|
9
|
+
name: string;
|
|
10
|
+
/** At most 1023 characters; defaults to `''`. */
|
|
11
|
+
description?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Body of `PUT /skill/<id>` (backend `UpdateSkill`); omitted fields are
|
|
15
|
+
* unchanged and `description: ''` clears the description.
|
|
16
|
+
*/
|
|
17
|
+
export type SkillUpdatePayload = Partial<SkillCreatePayload>;
|
|
18
|
+
/** `status` filter of `POST /company/<id>/payouts` (backend `PayoutsListBody`). */
|
|
19
|
+
export type PayoutStatusFilter = 'paid' | 'pending' | 'in_transit' | 'canceled' | 'failed';
|
|
20
|
+
/**
|
|
21
|
+
* Body of `POST /company/<id>/event` (backend `CreateCompanyEvent`): the
|
|
22
|
+
* `UpdateEvent` fields plus the job. `team_id: ''` is omitted by the SDK.
|
|
23
|
+
*/
|
|
24
|
+
export type EventCreatePayload = EventUpdatePayload & {
|
|
25
|
+
job_id: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Body of `POST /company` (backend `CreateCompany`). `logo` is not read by
|
|
29
|
+
* this endpoint (upload it with `POST /company/<id>/logo`); it is accepted
|
|
30
|
+
* here only so existing callers type-check.
|
|
31
|
+
*/
|
|
32
|
+
export interface CompanyCreatePayload {
|
|
33
|
+
/** 1–256 characters. */
|
|
34
|
+
name: string;
|
|
35
|
+
/** Referral code; unknown codes are ignored. */
|
|
36
|
+
code?: string | null;
|
|
37
|
+
/** IANA zone name; omit for the server's default zone. */
|
|
38
|
+
timezone?: string;
|
|
39
|
+
overdue_threshold?: number;
|
|
40
|
+
/** Rounded to a whole number. */
|
|
41
|
+
delay_scalar?: number;
|
|
42
|
+
/** Plan GUID to subscribe to. */
|
|
43
|
+
plan?: string | null;
|
|
44
|
+
logo?: File | null;
|
|
45
|
+
}
|
|
46
|
+
/** A Stripe payment method kept on a company (backend `PaymentMethodRef`). */
|
|
47
|
+
export interface CompanyPaymentMethodInput {
|
|
48
|
+
/** Stripe payment method id (`pm_...`). */
|
|
49
|
+
id: string;
|
|
50
|
+
autopay: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Body of `PUT /company/<id>` (backend `UpdateCompany`); omitted fields are
|
|
54
|
+
* unchanged. `null` unlinks the mailboxes / clears the plan; it is a 400 on
|
|
55
|
+
* every other field (and `''` is a 400 on the id fields).
|
|
56
|
+
*/
|
|
57
|
+
export interface CompanyUpdatePayload {
|
|
58
|
+
/** 1–256 characters. */
|
|
59
|
+
name?: string;
|
|
60
|
+
email?: string;
|
|
61
|
+
address?: string;
|
|
62
|
+
/** IANA zone name. */
|
|
63
|
+
timezone?: string;
|
|
64
|
+
delay_scalar?: number;
|
|
65
|
+
overdue_threshold?: number;
|
|
66
|
+
completed_onboarding?: boolean;
|
|
67
|
+
/** Unix seconds the first pay period starts. */
|
|
68
|
+
timecard_base?: number;
|
|
69
|
+
/** Pay period length in seconds; at least one day. */
|
|
70
|
+
timecard_length?: number;
|
|
71
|
+
use_client_side_customer_start_billing?: boolean;
|
|
72
|
+
use_client_side_customer_stop_billing?: boolean;
|
|
73
|
+
use_client_side_employee_start_billing?: boolean;
|
|
74
|
+
use_client_side_employee_stop_billing?: boolean;
|
|
75
|
+
indicator_lifetime?: number;
|
|
76
|
+
/** One of the company's mailboxes; null unsets it. */
|
|
77
|
+
service_email_id?: string | null;
|
|
78
|
+
/** One of the company's mailboxes; null unsets it. */
|
|
79
|
+
billing_email_id?: string | null;
|
|
80
|
+
/** In cents; only applied for root. */
|
|
81
|
+
balance?: number;
|
|
82
|
+
/** Null clears the plan. Ignored while the balance is negative. */
|
|
83
|
+
plan_id?: string | null;
|
|
84
|
+
enabled_payment_methods?: PaymentType[];
|
|
85
|
+
require_team_for_clock_in?: boolean;
|
|
86
|
+
accepts_cash_payments?: boolean;
|
|
87
|
+
default_pass_on_fees?: boolean;
|
|
88
|
+
/** Replaces the company's payment methods (detaching the rest). */
|
|
89
|
+
payment_methods?: CompanyPaymentMethodInput[];
|
|
90
|
+
/** `false` force-releases the scheduling lock; `true` is ignored. */
|
|
91
|
+
schedule_locked?: boolean;
|
|
92
|
+
/** Not read by this endpoint (upload with `POST /company/<id>/logo`). */
|
|
93
|
+
logo?: File | null;
|
|
94
|
+
}
|
|
95
|
+
/** Body of `POST /company/<id>/user/<user_id>` (backend `AddMember`). */
|
|
96
|
+
export interface MemberAddPayload {
|
|
97
|
+
/** `is_root` is dropped. */
|
|
98
|
+
permissions?: Permission[];
|
|
99
|
+
notification_setting?: NotificationLevel[];
|
|
100
|
+
/** A group of the company for the new member to join; null for none. */
|
|
101
|
+
group?: string | null;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Body of `PUT /company/<id>/user/<user_id>` (backend `UpdateMember`);
|
|
105
|
+
* omitted fields are unchanged and nothing is nullable.
|
|
106
|
+
*/
|
|
107
|
+
export interface MemberUpdatePayload {
|
|
108
|
+
/** `is_root` is dropped. */
|
|
109
|
+
permissions?: Permission[];
|
|
110
|
+
hourly_rate?: number;
|
|
111
|
+
salary_rate?: number;
|
|
112
|
+
bill_rate?: number;
|
|
113
|
+
pto_rate?: number;
|
|
114
|
+
sick_rate?: number;
|
|
115
|
+
accrued_pto?: number;
|
|
116
|
+
accrued_sick?: number;
|
|
117
|
+
pto_accrual_rate?: number;
|
|
118
|
+
sick_accrual_rate?: number;
|
|
119
|
+
notification_setting?: NotificationLevel[];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Body of `POST /user` (backend `CreateUser`). `password` and `last_name`
|
|
123
|
+
* may be empty; `email` must look like an address; `phone_number` must be a
|
|
124
|
+
* real number with country code (e.g. `+1 616-555-0100`).
|
|
125
|
+
*/
|
|
126
|
+
export interface UserCreatePayload {
|
|
127
|
+
/** 1–150 characters. */
|
|
128
|
+
username: string;
|
|
129
|
+
/** At most 100 characters. */
|
|
130
|
+
first_name: string;
|
|
131
|
+
/** At most 100 characters. */
|
|
132
|
+
last_name: string;
|
|
133
|
+
password: string;
|
|
134
|
+
email: string;
|
|
135
|
+
phone_number?: string | null;
|
|
136
|
+
/** Referral code. */
|
|
137
|
+
code?: string | null;
|
|
138
|
+
/** Company GUID to join as a customer. */
|
|
139
|
+
company_id?: string | null;
|
|
140
|
+
invite_token?: string | null;
|
|
141
|
+
share_location?: boolean;
|
|
142
|
+
share_email?: boolean;
|
|
143
|
+
share_phone?: boolean;
|
|
144
|
+
share_with_public?: boolean;
|
|
145
|
+
}
|
|
146
|
+
/** A saved Stripe payment method on a user write (backend `PaymentMethodIn`). */
|
|
147
|
+
export interface UserPaymentMethodInput {
|
|
148
|
+
/** Stripe payment method id (`pm_...`). */
|
|
149
|
+
id: string;
|
|
150
|
+
/** Omitted keeps the current setting (off for a newly saved method). */
|
|
151
|
+
autopay?: boolean;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Body of `PUT /user/<id>` (backend `UpdateUser`): profile fields plus the
|
|
155
|
+
* credentials a password/email change needs. Omitted fields are unchanged;
|
|
156
|
+
* only `phone_number` is nullable (null removes the number, `''` is a 400).
|
|
157
|
+
* A new `password` must be non-empty.
|
|
158
|
+
*/
|
|
159
|
+
export interface UserUpdatePayload {
|
|
160
|
+
/** 1–150 characters; stored lowercased. */
|
|
161
|
+
username?: string;
|
|
162
|
+
/** At most 100 characters. */
|
|
163
|
+
first_name?: string;
|
|
164
|
+
/** At most 100 characters. */
|
|
165
|
+
last_name?: string;
|
|
166
|
+
/** Changing your own password needs `current_password` (or an Apple re-sign-in). */
|
|
167
|
+
password?: string;
|
|
168
|
+
/** Changing your own email needs `current_password` (or an Apple re-sign-in). */
|
|
169
|
+
email?: string;
|
|
170
|
+
current_password?: string;
|
|
171
|
+
/** A fresh Apple identity token, instead of `current_password`. */
|
|
172
|
+
apple_token?: string;
|
|
173
|
+
/** The raw nonce `apple_token` was requested with. */
|
|
174
|
+
apple_nonce?: string;
|
|
175
|
+
/** A real number with country code; null removes it. */
|
|
176
|
+
phone_number?: string | null;
|
|
177
|
+
notification_setting?: NotificationLevel[];
|
|
178
|
+
/** Replaces the saved payment methods (`[]` detaches all). */
|
|
179
|
+
payment_methods?: UserPaymentMethodInput[];
|
|
180
|
+
share_location?: boolean;
|
|
181
|
+
share_email?: boolean;
|
|
182
|
+
share_phone?: boolean;
|
|
183
|
+
share_with_public?: boolean;
|
|
184
|
+
}
|
|
185
|
+
/** A custom line item on a bill write (backend `BillLineItemIn`). */
|
|
186
|
+
export interface BillLineItemInput {
|
|
187
|
+
name?: string;
|
|
188
|
+
description?: string;
|
|
189
|
+
/** Quantity (default 1); may be fractional (e.g. hours). */
|
|
190
|
+
amount?: number;
|
|
191
|
+
/** Unit price in integer cents (default 0). */
|
|
192
|
+
cost?: number;
|
|
193
|
+
}
|
|
194
|
+
/** A member recipient on a bill write (backend `BillUserIn`). */
|
|
195
|
+
export interface BillUserInput {
|
|
196
|
+
/** The member's user GUID. */
|
|
197
|
+
id: string;
|
|
198
|
+
/**
|
|
199
|
+
* Create only: charge up to this many integer cents (>= 0) to the
|
|
200
|
+
* user's autopay method. Fractional values are rejected.
|
|
201
|
+
*/
|
|
202
|
+
amt?: number | null;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Body of `POST /company/<id>/bill` and `PUT /bill/<id>` (backend
|
|
206
|
+
* `CreateBill` / `UpdateBill`); omitted fields are unchanged. Only `name`
|
|
207
|
+
* and `due_date` are nullable (null clears them); null elsewhere is a 400.
|
|
208
|
+
*/
|
|
209
|
+
export interface BillWritePayload {
|
|
210
|
+
/** Event GUIDs; replaces the bill's events. */
|
|
211
|
+
events?: string[];
|
|
212
|
+
/** Service month GUIDs; replaces the bill's months. */
|
|
213
|
+
months?: string[];
|
|
214
|
+
/** Prepayment GUIDs; replaces the bill's prepayments. */
|
|
215
|
+
prepayments?: string[];
|
|
216
|
+
/** Replaces the bill's custom line items. */
|
|
217
|
+
line_items?: BillLineItemInput[];
|
|
218
|
+
/** Extra recipients as `[name, email]` pairs; replaces them. */
|
|
219
|
+
manual_emails?: [string, string][];
|
|
220
|
+
/** Replaces the member recipients. */
|
|
221
|
+
users?: BillUserInput[];
|
|
222
|
+
/** At most 256 characters; null clears it. */
|
|
223
|
+
name?: string | null;
|
|
224
|
+
/** Marks every item paid outside Avro. */
|
|
225
|
+
status?: 'MANUALLY_PAID';
|
|
226
|
+
/** Unix seconds; null clears it. */
|
|
227
|
+
due_date?: number | null;
|
|
228
|
+
/** Empty means the company's defaults. */
|
|
229
|
+
enabled_payment_methods?: PaymentType[];
|
|
230
|
+
pass_on_fees?: boolean;
|
|
231
|
+
}
|
|
232
|
+
/** Counts a finished QuickBooks sync reports (the `intuit_sync_complete` payload). */
|
|
233
|
+
export interface IntuitImportResult {
|
|
234
|
+
msg: string;
|
|
235
|
+
imported: number;
|
|
236
|
+
skipped: number;
|
|
237
|
+
payments_imported: number;
|
|
238
|
+
payments_skipped: number;
|
|
239
|
+
/** Avro bills sent to QuickBooks as new invoices. */
|
|
240
|
+
pushed: number;
|
|
241
|
+
/** Avro payments sent to QuickBooks. */
|
|
242
|
+
payments_pushed: number;
|
|
243
|
+
/** Bills QuickBooks refused; they retry on the next sync. */
|
|
244
|
+
push_failed: number;
|
|
245
|
+
}
|
|
246
|
+
/** A sync's phases, in order: send to QuickBooks, import invoices, import payments. */
|
|
247
|
+
export type IntuitSyncPhase = 'push' | 'import' | 'payments';
|
|
248
|
+
/** An `intuit_sync_progress` payload: `done` of `total` items in `phase`. */
|
|
249
|
+
export interface IntuitSyncProgress {
|
|
250
|
+
phase: IntuitSyncPhase;
|
|
251
|
+
done: number;
|
|
252
|
+
total: number;
|
|
253
|
+
}
|
|
254
|
+
/** The company's QuickBooks sync as its socket events report it. */
|
|
255
|
+
export type IntuitSyncStatus = {
|
|
256
|
+
state: 'idle';
|
|
257
|
+
} | {
|
|
258
|
+
state: 'running';
|
|
259
|
+
progress?: IntuitSyncProgress;
|
|
260
|
+
} | {
|
|
261
|
+
state: 'complete';
|
|
262
|
+
result: IntuitImportResult;
|
|
263
|
+
} | {
|
|
264
|
+
state: 'error';
|
|
265
|
+
message: string;
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* A payment option on a catalog item write (backend `CreatePaymentOption`).
|
|
269
|
+
* Prices are integer cents.
|
|
270
|
+
*/
|
|
271
|
+
export interface PaymentOptionInput {
|
|
272
|
+
/** 1–64 characters. */
|
|
273
|
+
name: string;
|
|
274
|
+
is_prepay?: boolean;
|
|
275
|
+
price_under_prepay?: number | null;
|
|
276
|
+
price?: number;
|
|
277
|
+
recommended_prepay_count?: number | null;
|
|
278
|
+
/** Case-insensitive; defaults to `NONE`. */
|
|
279
|
+
mode?: 'NONE' | 'MONTH' | 'SERVICE' | Lowercase<'NONE' | 'MONTH' | 'SERVICE'>;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Body of `PUT /catalog_item/<id>` (backend `UpdateCatalogItem`); omitted
|
|
283
|
+
* fields are unchanged and `null` clears the `recommended_*` fields.
|
|
284
|
+
*/
|
|
285
|
+
export interface CatalogItemUpdatePayload {
|
|
286
|
+
/** 1–256 characters. */
|
|
287
|
+
name?: string;
|
|
288
|
+
description?: string;
|
|
289
|
+
/**
|
|
290
|
+
* A `CatalogIndustry` name, matched case-insensitively with spaces for
|
|
291
|
+
* underscores (`'Snow Removal'`).
|
|
292
|
+
*/
|
|
293
|
+
industry?: CatalogIndustry | (string & {});
|
|
294
|
+
/** A `CatalogPriceFormat` name, matched like `industry`. */
|
|
295
|
+
price_format?: CatalogPriceFormat | (string & {});
|
|
296
|
+
archived?: boolean;
|
|
297
|
+
/** Integer seconds between services; null clears it. */
|
|
298
|
+
recommended_frequency?: number | null;
|
|
299
|
+
/** Unix seconds (>= 0); null clears it. */
|
|
300
|
+
recommended_activate_on?: number | null;
|
|
301
|
+
/** Unix seconds (>= 0); null clears it. */
|
|
302
|
+
recommended_expire_on?: number | null;
|
|
303
|
+
/** Skill GUIDs; replaces the item's skills. */
|
|
304
|
+
skills?: string[];
|
|
305
|
+
/** ProposalTerms GUIDs; replaces the item's suggested terms. */
|
|
306
|
+
terms?: string[];
|
|
307
|
+
/** Replaces the item's payment options. */
|
|
308
|
+
payment_options?: PaymentOptionInput[];
|
|
309
|
+
}
|
|
310
|
+
/** Body of `POST /company/<id>/catalog_item` (backend `CreateCatalogItem`). */
|
|
311
|
+
export type CatalogItemCreatePayload = CatalogItemUpdatePayload & {
|
|
312
|
+
name: string;
|
|
313
|
+
};
|
|
314
|
+
/**
|
|
315
|
+
* Body of `POST /job/<id>/proposal` and `PUT /proposal/<id>` (backend
|
|
316
|
+
* `CreateProposal` / `UpdateProposal`); omitted fields are unchanged, and
|
|
317
|
+
* null clears `expire_on` / `prepay_due_date`.
|
|
318
|
+
*/
|
|
319
|
+
export interface ProposalWritePayload {
|
|
320
|
+
/**
|
|
321
|
+
* Unix seconds (>= 0) after which the customer can no longer review;
|
|
322
|
+
* null means never.
|
|
323
|
+
*/
|
|
324
|
+
expire_on?: number | null;
|
|
325
|
+
/** Terms version GUIDs; replaces the attached terms (`[]` detaches all). */
|
|
326
|
+
terms_version_ids?: string[];
|
|
327
|
+
/** Unix seconds (>= 0); null clears. */
|
|
328
|
+
prepay_due_date?: number | null;
|
|
329
|
+
/** Replaces the proposal's tasks (only `id` is read). */
|
|
330
|
+
tasks?: {
|
|
331
|
+
id: string;
|
|
332
|
+
}[];
|
|
333
|
+
}
|
|
334
|
+
/** A prepayment a customer commits to when accepting a task (backend `AcceptPrepayment`). */
|
|
335
|
+
export interface ProposalReviewPrepayment {
|
|
336
|
+
/** Unit price in integer cents (>= 0). */
|
|
337
|
+
cost?: number;
|
|
338
|
+
/** Integer count (>= 1). */
|
|
339
|
+
amount?: number;
|
|
340
|
+
type?: 'SERVICE' | 'MONTH';
|
|
341
|
+
description?: string;
|
|
342
|
+
name?: string;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* The customer's decision on one proposal task (backend `ReviewTask`).
|
|
346
|
+
* Omit a choice to not make it; null is a 400.
|
|
347
|
+
*/
|
|
348
|
+
export interface ProposalReviewTask {
|
|
349
|
+
id: string;
|
|
350
|
+
/** `ARCHIVED` rejects the task; anything else (or omitting it) accepts it. */
|
|
351
|
+
status?: TaskStatus;
|
|
352
|
+
prepayments?: ProposalReviewPrepayment[];
|
|
353
|
+
bill_mode?: 'NONE' | 'MONTH' | 'SERVICE';
|
|
354
|
+
/** Chosen price in integer cents. */
|
|
355
|
+
price?: number;
|
|
356
|
+
/** @deprecated Not read by the backend. */
|
|
357
|
+
payment_option_id?: string;
|
|
358
|
+
}
|
|
359
|
+
/** Body of `POST /proposal/<id>/review` (backend `ReviewProposal`). */
|
|
360
|
+
export interface ProposalReviewPayload {
|
|
361
|
+
tasks?: ProposalReviewTask[];
|
|
362
|
+
/**
|
|
363
|
+
* The terms version GUIDs agreed to; must be exactly the proposal's when
|
|
364
|
+
* it has terms and any task is accepted.
|
|
365
|
+
*/
|
|
366
|
+
terms_version_ids?: string[];
|
|
367
|
+
pay_in_cash?: boolean;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* A prepayment on a task write (backend `TaskPrepaymentIn`), matched to an
|
|
371
|
+
* existing one by `id`; omitted fields keep an existing prepayment's values.
|
|
372
|
+
*/
|
|
373
|
+
export interface TaskPrepaymentInput {
|
|
374
|
+
/** An existing prepayment of the task; omit to create one. */
|
|
375
|
+
id?: string;
|
|
376
|
+
/** Unit price in integer cents; defaults to 0. */
|
|
377
|
+
cost?: number;
|
|
378
|
+
/** Defaults to 1. */
|
|
379
|
+
amount?: number;
|
|
380
|
+
/** Defaults to `SERVICE`. */
|
|
381
|
+
type?: 'SERVICE' | 'MONTH';
|
|
382
|
+
/** Defaults to `EXTERNALLY_PAID`. */
|
|
383
|
+
status?: LineItemStatus;
|
|
384
|
+
description?: string;
|
|
385
|
+
name?: string;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* A task inside a job write (backend `JobTaskIn` / `UpdateTask`), matched
|
|
389
|
+
* to the job's tasks by `id`. Omitted fields are unchanged; null clears
|
|
390
|
+
* `expire_on`, `activate_on`, `bill_day`, `enforce_image_amount` and
|
|
391
|
+
* `catalog_item_id` and is a 400 on every other field.
|
|
392
|
+
*/
|
|
393
|
+
export interface TaskWritePayload {
|
|
394
|
+
/** An existing task of the job; omit (or `''`) to create one. */
|
|
395
|
+
id?: string;
|
|
396
|
+
/** Required unless the task already has a name. */
|
|
397
|
+
name?: string;
|
|
398
|
+
/** Replaces the task's prepayments. */
|
|
399
|
+
prepayments?: TaskPrepaymentInput[];
|
|
400
|
+
/** Unix seconds, truncated to UTC midnight; null means never. */
|
|
401
|
+
expire_on?: number | null;
|
|
402
|
+
/** Unix seconds, truncated to UTC midnight; null means right away. */
|
|
403
|
+
activate_on?: number | null;
|
|
404
|
+
/** Day of month to bill; null means the month's last day. */
|
|
405
|
+
bill_day?: number | null;
|
|
406
|
+
services_remaining?: number;
|
|
407
|
+
/** Seconds between services; <= 0 means not recurring. */
|
|
408
|
+
frequency?: number;
|
|
409
|
+
internal_notes?: string;
|
|
410
|
+
external_notes?: string;
|
|
411
|
+
/** Proof images expected per service. */
|
|
412
|
+
image_amt?: number;
|
|
413
|
+
enforce_image_amount?: boolean | null;
|
|
414
|
+
status?: TaskStatus;
|
|
415
|
+
/** Email the other party when `status` moves to a pending state. */
|
|
416
|
+
send_email?: boolean;
|
|
417
|
+
/** With an accepting `status`, settle a cash proposal's unbilled prepayments. */
|
|
418
|
+
cash_received?: boolean;
|
|
419
|
+
/** Service duration in seconds. */
|
|
420
|
+
service?: number;
|
|
421
|
+
autobill?: boolean;
|
|
422
|
+
bill_mode?: 'NONE' | 'MONTH' | 'SERVICE';
|
|
423
|
+
/** Replaces the task's payment options. */
|
|
424
|
+
payment_options?: PaymentOptionInput[];
|
|
425
|
+
/** Price in integer cents; -1 means unset. */
|
|
426
|
+
price?: number;
|
|
427
|
+
priority?: boolean;
|
|
428
|
+
/** Null unlinks the catalog item. */
|
|
429
|
+
catalog_item_id?: string | null;
|
|
430
|
+
/** Skill GUIDs; replaces the task's skills. */
|
|
431
|
+
skills?: string[];
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Body of `POST /company/<id>/team` and `PUT /team/<id>` (backend
|
|
435
|
+
* `CreateTeam` / `UpdateTeam`); omitted fields are unchanged. A start or
|
|
436
|
+
* end point is sent whole: both halves as numbers, or both null to clear
|
|
437
|
+
* it (one half alone is a 400). Null is a 400 on every other field.
|
|
438
|
+
*/
|
|
439
|
+
export interface TeamWritePayload {
|
|
440
|
+
name?: string;
|
|
441
|
+
description?: string;
|
|
442
|
+
start_latitude?: number | null;
|
|
443
|
+
start_longitude?: number | null;
|
|
444
|
+
start_address?: string;
|
|
445
|
+
end_latitude?: number | null;
|
|
446
|
+
end_longitude?: number | null;
|
|
447
|
+
end_address?: string;
|
|
448
|
+
/** -1 for no limit. */
|
|
449
|
+
max_jobs?: number;
|
|
450
|
+
speed_factor?: number;
|
|
451
|
+
/** Seconds; -1 for no limit. */
|
|
452
|
+
max_travel_time?: number;
|
|
453
|
+
/** Meters; -1 for no limit. */
|
|
454
|
+
max_distance?: number;
|
|
455
|
+
/** Seconds after midnight the shift starts; -1 for none. */
|
|
456
|
+
start_time?: number;
|
|
457
|
+
/** Seconds after midnight the shift ends; -1 for none. */
|
|
458
|
+
end_time?: number;
|
|
459
|
+
fixed_cost?: number;
|
|
460
|
+
hourly_cost?: number;
|
|
461
|
+
km_cost?: number;
|
|
462
|
+
autoconfigure?: boolean;
|
|
463
|
+
/** `#RRGGBB`. */
|
|
464
|
+
color?: string;
|
|
465
|
+
/** Route GUIDs; replaces the team's routes (`[]` clears them). */
|
|
466
|
+
routes?: string[];
|
|
467
|
+
/** User GUIDs; replaces the team's members. */
|
|
468
|
+
users?: string[];
|
|
469
|
+
/** Skill GUIDs; replaces the team's skills. */
|
|
470
|
+
skills?: string[];
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Body of `PUT /session/<id>` (backend `UpdateSession`); omitted fields are
|
|
474
|
+
* unchanged. Null clears the team / route, and `time_ended: null` re-opens
|
|
475
|
+
* the session; `time_started` is not nullable.
|
|
476
|
+
*/
|
|
477
|
+
export interface SessionUpdatePayload {
|
|
478
|
+
team_id?: string | null;
|
|
479
|
+
route_id?: string | null;
|
|
480
|
+
/** Alias of `route_id`. */
|
|
481
|
+
current_route_id?: string | null;
|
|
482
|
+
/** Unix seconds; restarts the clock. */
|
|
483
|
+
time_started?: number;
|
|
484
|
+
/** Unix seconds, or `true` for now; null re-opens the session. */
|
|
485
|
+
time_ended?: number | true | null;
|
|
486
|
+
}
|
|
487
|
+
/** Body of `POST /company/<id>/session` (backend `StartSession`). */
|
|
488
|
+
export interface SessionCreatePayload extends SessionUpdatePayload {
|
|
489
|
+
/** Member to clock in; defaults to the caller. */
|
|
490
|
+
user_id?: string | null;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Body of `POST /session/<id>/break` and `PUT /break/<id>` (backend
|
|
494
|
+
* `CreateSessionBreak` / `UpdateBreak`); nothing is nullable.
|
|
495
|
+
*/
|
|
496
|
+
export interface BreakWritePayload {
|
|
497
|
+
/** Unix seconds. */
|
|
498
|
+
time_started?: number;
|
|
499
|
+
/** Unix seconds. */
|
|
500
|
+
time_ended?: number;
|
|
501
|
+
company_billable?: boolean;
|
|
502
|
+
client_billable?: boolean;
|
|
503
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Helpers that shape request bodies to what the backend schemas accept. */
|
|
2
|
+
/**
|
|
3
|
+
* Drop optional keys holding `''`. The backend schemas type these as UUIDs
|
|
4
|
+
* or enums, so an empty string is a 400, while an omitted key means "no
|
|
5
|
+
* filter" (lists) or "unchanged" (updates).
|
|
6
|
+
*/
|
|
7
|
+
export declare function withoutEmpty<T extends object>(body: T, ...keys: string[]): T;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Helpers that shape request bodies to what the backend schemas accept. */
|
|
2
|
+
/**
|
|
3
|
+
* Drop optional keys holding `''`. The backend schemas type these as UUIDs
|
|
4
|
+
* or enums, so an empty string is a 400, while an omitted key means "no
|
|
5
|
+
* filter" (lists) or "unchanged" (updates).
|
|
6
|
+
*/
|
|
7
|
+
export function withoutEmpty(body, ...keys) {
|
|
8
|
+
const out = { ...body };
|
|
9
|
+
for (const key of keys) {
|
|
10
|
+
if (out[key] === '')
|
|
11
|
+
delete out[key];
|
|
12
|
+
}
|
|
13
|
+
return out;
|
|
14
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { AvroQueryClientProvider, useAvroQueryClient, useSocketEvent, } from './
|
|
|
3
3
|
export { useEmailStatus } from './client/hooks/email.js';
|
|
4
4
|
export type { EmailResult, EmailResultStatus, UseEmailStatusOptions } from './client/hooks/email.js';
|
|
5
5
|
export type { BulkBillError, BulkDeleteBillsResponse, BulkEmailBillsResponse, } from './client/hooks/bills.js';
|
|
6
|
+
export type * from './client/requests.js';
|
|
6
7
|
export { AuthManager } from './auth/AuthManager.js';
|
|
7
8
|
export { MemoryStorage, LocalStorage } from './auth/storage.js';
|
|
8
9
|
export { QueryPersister, IndexedDBStore, MemoryKeyValueStore, defaultKeyValueStore, PERSISTED_NAMESPACES, } from './client/persist.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LineItem } from './LineItem.js';
|
|
2
2
|
export interface AdditionalCharge extends LineItem {
|
|
3
3
|
line_item_type: 'ADDITIONAL_CHARGE';
|
|
4
|
-
|
|
4
|
+
/** GUID of the event the charge belongs to. */
|
|
5
|
+
parent_id: string;
|
|
5
6
|
earned_revenue: number;
|
|
6
7
|
}
|