@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.
- package/dist/client/QueryClient.d.ts +57 -52
- package/dist/client/QueryClient.js +45 -22
- package/dist/client/hooks/audit.js +4 -2
- package/dist/client/hooks/avro.js +6 -2
- package/dist/client/hooks/bills.d.ts +1 -1
- package/dist/client/hooks/bills.js +23 -3
- package/dist/client/hooks/catalog_items.js +4 -1
- package/dist/client/hooks/companies.js +4 -2
- package/dist/client/hooks/events.js +7 -5
- package/dist/client/hooks/jobs.js +26 -3
- package/dist/client/hooks/messages.js +6 -2
- package/dist/client/hooks/plans.js +1 -1
- package/dist/client/hooks/routes.js +31 -1
- package/dist/client/hooks/sessions.js +10 -3
- package/dist/client/hooks/skills.js +1 -1
- package/dist/client/hooks/timecards.js +2 -1
- package/dist/client/hooks/users.js +5 -2
- package/dist/client/realtime.js +8 -3
- package/dist/client/requests.d.ts +221 -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 +33 -28
- 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 +9 -6
- package/dist/types/api/Chat.d.ts +3 -5
- package/dist/types/api/Company.d.ts +39 -13
- package/dist/types/api/DelayEvent.d.ts +5 -2
- 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 +24 -3
- 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/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 +45 -28
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import { AvroQueryClient } from '../QueryClient.js';
|
|
|
3
3
|
import { seedDetails } from '../cache.js';
|
|
4
4
|
import { keys, constructJob } from '../realtime.js';
|
|
5
5
|
import { Job } from '../../types/api.js';
|
|
6
|
+
import { withoutEmpty } from '../wire.js';
|
|
6
7
|
AvroQueryClient.prototype.getJobsFromCache = function (queryClient) {
|
|
7
8
|
const client = queryClient ?? this.peekQueryClient();
|
|
8
9
|
if (!client) {
|
|
@@ -10,6 +11,28 @@ AvroQueryClient.prototype.getJobsFromCache = function (queryClient) {
|
|
|
10
11
|
}
|
|
11
12
|
return client.getQueryData(keys.list('jobs', this.companyId)) ?? [];
|
|
12
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Omit blank ids from a job write. `UpdateJob`/`ManagedJob` type the job,
|
|
16
|
+
* task, prepayment, owner and catalog item ids as UUIDs; a blank id means
|
|
17
|
+
* "new row" / "none", which is what omitting it says.
|
|
18
|
+
*/
|
|
19
|
+
function toJobWire(job) {
|
|
20
|
+
const wire = withoutEmpty(job, 'id', 'owner_id');
|
|
21
|
+
if (!wire.tasks)
|
|
22
|
+
return wire;
|
|
23
|
+
return {
|
|
24
|
+
...wire,
|
|
25
|
+
tasks: wire.tasks.map((task) => {
|
|
26
|
+
const wireTask = withoutEmpty(task, 'id', 'catalog_item_id');
|
|
27
|
+
return wireTask.prepayments
|
|
28
|
+
? {
|
|
29
|
+
...wireTask,
|
|
30
|
+
prepayments: wireTask.prepayments.map((p) => withoutEmpty(p, 'id')),
|
|
31
|
+
}
|
|
32
|
+
: wireTask;
|
|
33
|
+
}),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
13
36
|
const JOBS_SYNC_CHUNK = 50;
|
|
14
37
|
const JOBS_SYNC_CONCURRENCY = 3;
|
|
15
38
|
async function runLimited(items, limit, worker) {
|
|
@@ -108,7 +131,7 @@ AvroQueryClient.prototype.useCreateJob = function () {
|
|
|
108
131
|
mutationFn: ({ jobData }) => {
|
|
109
132
|
return this.post({
|
|
110
133
|
path: `/company/${this.companyId}/job`,
|
|
111
|
-
data: JSON.stringify(jobData),
|
|
134
|
+
data: JSON.stringify(toJobWire(jobData)),
|
|
112
135
|
headers: { 'Content-Type': 'application/json' },
|
|
113
136
|
});
|
|
114
137
|
},
|
|
@@ -123,7 +146,7 @@ AvroQueryClient.prototype.useManageJobs = function () {
|
|
|
123
146
|
mutationFn: ({ jobs }) => {
|
|
124
147
|
return this.post({
|
|
125
148
|
path: `/company/${this.companyId}/jobs/manage`,
|
|
126
|
-
data: JSON.stringify({ jobs }),
|
|
149
|
+
data: JSON.stringify({ jobs: jobs.map(toJobWire) }),
|
|
127
150
|
headers: { 'Content-Type': 'application/json' },
|
|
128
151
|
});
|
|
129
152
|
},
|
|
@@ -138,7 +161,7 @@ AvroQueryClient.prototype.useUpdateJob = function () {
|
|
|
138
161
|
mutationFn: ({ jobId, updates }) => {
|
|
139
162
|
return this.put({
|
|
140
163
|
path: `/job/${jobId}`,
|
|
141
|
-
data: JSON.stringify(updates),
|
|
164
|
+
data: JSON.stringify(toJobWire(updates)),
|
|
142
165
|
headers: { 'Content-Type': 'application/json' },
|
|
143
166
|
});
|
|
144
167
|
},
|
|
@@ -4,21 +4,25 @@ import { seedDetails } from '../cache.js';
|
|
|
4
4
|
import { keys } from '../realtime.js';
|
|
5
5
|
AvroQueryClient.prototype.useGetMessages = function (chatId, body) {
|
|
6
6
|
const queryClient = this.getQueryClient();
|
|
7
|
+
// The backend pages messages 1..100 at a time (default 10); send the
|
|
8
|
+
// page size explicitly so `getNextPageParam` compares against it.
|
|
9
|
+
const amt = Math.min(Math.max(body.amt ?? 50, 1), 100);
|
|
7
10
|
const result = useInfiniteQuery({
|
|
8
11
|
queryKey: keys.infinite('messages', chatId, {
|
|
9
|
-
amt
|
|
12
|
+
amt,
|
|
10
13
|
known_ids: body.known_ids ?? [],
|
|
11
14
|
unknown_ids: body.unknown_ids ?? [],
|
|
12
15
|
query: body.query ?? '',
|
|
13
16
|
}),
|
|
14
17
|
initialPageParam: 0,
|
|
15
18
|
getNextPageParam: (lastPage, allPages) => {
|
|
16
|
-
if (lastPage.length <
|
|
19
|
+
if (lastPage.length < amt)
|
|
17
20
|
return undefined;
|
|
18
21
|
return allPages.flat().length; // next offset
|
|
19
22
|
},
|
|
20
23
|
queryFn: ({ pageParam = 0 }) => this.fetchMessages(chatId, {
|
|
21
24
|
...body,
|
|
25
|
+
amt,
|
|
22
26
|
offset: pageParam,
|
|
23
27
|
}).then((messages) => seedDetails(queryClient, 'message', messages)),
|
|
24
28
|
enabled: Boolean(chatId),
|
|
@@ -3,6 +3,6 @@ import { AvroQueryClient } from '../QueryClient.js';
|
|
|
3
3
|
AvroQueryClient.prototype.useGetPlans = function (code) {
|
|
4
4
|
return useQuery({
|
|
5
5
|
queryKey: ['plans', code],
|
|
6
|
-
queryFn: async () => this.get({ path: `/plans${code ? `?code=${code}` : ''}` }),
|
|
6
|
+
queryFn: async () => this.get({ path: `/plans${code ? `?code=${encodeURIComponent(code)}` : ''}` }),
|
|
7
7
|
});
|
|
8
8
|
};
|
|
@@ -14,6 +14,36 @@ const dedupeJobTasks = (payload) => payload.jobs
|
|
|
14
14
|
: job),
|
|
15
15
|
}
|
|
16
16
|
: payload;
|
|
17
|
+
/**
|
|
18
|
+
* Drop `''` task ids from a schedule request: `ScheduleRoutes` types every
|
|
19
|
+
* task id as a UUID, so one blank id (e.g. an unsaved task) would 400 the
|
|
20
|
+
* whole request instead of being skipped.
|
|
21
|
+
*/
|
|
22
|
+
const withoutBlankTaskIds = (schedule) => {
|
|
23
|
+
const ids = (list) => list?.filter((id) => id !== '');
|
|
24
|
+
return {
|
|
25
|
+
...schedule,
|
|
26
|
+
...(schedule.whitelist && { whitelist: ids(schedule.whitelist) }),
|
|
27
|
+
...(schedule.blacklist && { blacklist: ids(schedule.blacklist) }),
|
|
28
|
+
...(schedule.tasks && {
|
|
29
|
+
tasks: schedule.tasks
|
|
30
|
+
.filter((entry) => (typeof entry === 'string' ? entry : entry.task) !== '')
|
|
31
|
+
.map((entry) => typeof entry === 'string'
|
|
32
|
+
? entry
|
|
33
|
+
: { ...entry, depends_on: ids(entry.depends_on) }),
|
|
34
|
+
}),
|
|
35
|
+
...(schedule.schedules && {
|
|
36
|
+
schedules: schedule.schedules.map((team) => team.schedule
|
|
37
|
+
? {
|
|
38
|
+
...team,
|
|
39
|
+
schedule: team.schedule.map((stop) => stop.type === 'job'
|
|
40
|
+
? { ...stop, task_ids: ids(stop.task_ids) ?? [] }
|
|
41
|
+
: stop),
|
|
42
|
+
}
|
|
43
|
+
: team),
|
|
44
|
+
}),
|
|
45
|
+
};
|
|
46
|
+
};
|
|
17
47
|
AvroQueryClient.prototype.useGetRoutes = function (body, total, onProgress) {
|
|
18
48
|
return useQuery({
|
|
19
49
|
queryKey: keys.list('routes', this.companyId, {
|
|
@@ -128,7 +158,7 @@ AvroQueryClient.prototype.useScheduleRoutes = function () {
|
|
|
128
158
|
mutationFn: async ({ schedule }) => {
|
|
129
159
|
return this.post({
|
|
130
160
|
path: `/company/${this.companyId}/schedule`,
|
|
131
|
-
data: JSON.stringify(schedule),
|
|
161
|
+
data: JSON.stringify(withoutBlankTaskIds(schedule)),
|
|
132
162
|
headers: { 'Content-Type': 'application/json' },
|
|
133
163
|
});
|
|
134
164
|
},
|
|
@@ -3,6 +3,7 @@ import { AvroQueryClient } from '../QueryClient.js';
|
|
|
3
3
|
import { keys, isListKey } from '../realtime.js';
|
|
4
4
|
import { removeOptimisticRow, seedDetails } from '../cache.js';
|
|
5
5
|
import { Session } from '../../types/api.js';
|
|
6
|
+
import { withoutEmpty } from '../wire.js';
|
|
6
7
|
const NS = 'sessions';
|
|
7
8
|
function listFilters(body) {
|
|
8
9
|
return {
|
|
@@ -89,13 +90,19 @@ AvroQueryClient.prototype.useGetActiveCompanySessions = function (params = {}) {
|
|
|
89
90
|
// Optimistic patch on every cached sessions list; the echoed `changes`
|
|
90
91
|
// batch settles the cache when the socket is up, else syncAfterMutation
|
|
91
92
|
// falls back to a refetch.
|
|
93
|
+
/**
|
|
94
|
+
* Session id fields the backend types as UUIDs (`StartSession` /
|
|
95
|
+
* `UpdateSession`); `''` is omitted rather than sent.
|
|
96
|
+
*/
|
|
97
|
+
const SESSION_ID_FIELDS = ['team_id', 'route_id', 'current_route_id', 'user_id'];
|
|
92
98
|
AvroQueryClient.prototype.useCreateUserSession = function () {
|
|
93
99
|
const queryClient = this.getQueryClient();
|
|
94
100
|
return useMutation({
|
|
95
101
|
mutationFn: ({ sessionData }) => {
|
|
102
|
+
// `id` is null only when an already-open session closed mid-request.
|
|
96
103
|
return this.post({
|
|
97
104
|
path: `/company/${this.companyId}/session`,
|
|
98
|
-
data: JSON.stringify(sessionData),
|
|
105
|
+
data: JSON.stringify(withoutEmpty(sessionData, ...SESSION_ID_FIELDS)),
|
|
99
106
|
headers: { 'Content-Type': 'application/json' },
|
|
100
107
|
});
|
|
101
108
|
},
|
|
@@ -167,7 +174,7 @@ AvroQueryClient.prototype.useUpdateUserSession = function () {
|
|
|
167
174
|
mutationFn: ({ sessionId, updates }) => {
|
|
168
175
|
return this.put({
|
|
169
176
|
path: `/session/${sessionId}`,
|
|
170
|
-
data: JSON.stringify(updates),
|
|
177
|
+
data: JSON.stringify(withoutEmpty(updates, ...SESSION_ID_FIELDS)),
|
|
171
178
|
headers: { 'Content-Type': 'application/json' },
|
|
172
179
|
});
|
|
173
180
|
},
|
|
@@ -225,7 +232,7 @@ AvroQueryClient.prototype.useUpdateCompanySession = function () {
|
|
|
225
232
|
mutationFn: ({ sessionId, updates, companyId, }) => {
|
|
226
233
|
return this.put({
|
|
227
234
|
path: `/company/${companyId ?? this.companyId}/session/${sessionId}`,
|
|
228
|
-
data: JSON.stringify(updates),
|
|
235
|
+
data: JSON.stringify(withoutEmpty(updates, ...SESSION_ID_FIELDS)),
|
|
229
236
|
headers: { 'Content-Type': 'application/json' },
|
|
230
237
|
});
|
|
231
238
|
},
|
|
@@ -51,7 +51,7 @@ AvroQueryClient.prototype.useGetSkills = function (body, total, onProgress) {
|
|
|
51
51
|
AvroQueryClient.prototype.useUpdateSkill = function () {
|
|
52
52
|
const queryClient = this.getQueryClient();
|
|
53
53
|
return useMutation({
|
|
54
|
-
mutationFn: async ({ skillId, updates }) => {
|
|
54
|
+
mutationFn: async ({ skillId, updates, }) => {
|
|
55
55
|
return this.put({
|
|
56
56
|
path: `/skill/${skillId}`,
|
|
57
57
|
data: JSON.stringify(updates),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useMutation, useQuery } from '@tanstack/react-query';
|
|
2
2
|
import { AvroQueryClient } from '../QueryClient.js';
|
|
3
3
|
import { keys } from '../realtime.js';
|
|
4
|
+
import { withoutEmpty } from '../wire.js';
|
|
4
5
|
AvroQueryClient.prototype.useGetCompanyTimecards = function (params = {}) {
|
|
5
6
|
const companyId = params.companyId ?? this.companyId;
|
|
6
7
|
return useQuery({
|
|
@@ -48,7 +49,7 @@ AvroQueryClient.prototype.useCreateTimecard = function () {
|
|
|
48
49
|
const targetCompanyId = companyId ?? this.companyId;
|
|
49
50
|
return this.post({
|
|
50
51
|
path: `/company/${targetCompanyId}/timecard`,
|
|
51
|
-
data: JSON.stringify(data),
|
|
52
|
+
data: JSON.stringify(withoutEmpty(data, 'user_company_id')),
|
|
52
53
|
headers: { 'Content-Type': 'application/json' },
|
|
53
54
|
});
|
|
54
55
|
},
|
|
@@ -108,7 +108,9 @@ AvroQueryClient.prototype.useUpdateUser = function (userId) {
|
|
|
108
108
|
headers: { 'Content-Type': 'application/json' },
|
|
109
109
|
});
|
|
110
110
|
},
|
|
111
|
-
onMutate: async (
|
|
111
|
+
onMutate: async (wireData) => {
|
|
112
|
+
// Credentials are request-only; keep them out of the cache.
|
|
113
|
+
const { password: _password, current_password: _currentPassword, apple_token: _appleToken, apple_nonce: _appleNonce, ...data } = wireData;
|
|
112
114
|
await queryClient.cancelQueries({ queryKey: ['user'] });
|
|
113
115
|
await queryClient.cancelQueries({ queryKey: ['users', userId] });
|
|
114
116
|
const previousSelf = queryClient.getQueryData(['user']);
|
|
@@ -213,7 +215,8 @@ AvroQueryClient.prototype.useGetCompanyUsers = function (body = {}) {
|
|
|
213
215
|
queryKey: ['users', 'company', this.companyId, body.query ?? '', body.user_ids ?? null],
|
|
214
216
|
queryFn: () => this.post({
|
|
215
217
|
path: `/company/${this.companyId}/users`,
|
|
216
|
-
|
|
218
|
+
// `enabled` is a hook option, not a `ListCompanyUsers` field.
|
|
219
|
+
data: JSON.stringify({ query: body.query, user_ids: body.user_ids }),
|
|
217
220
|
headers: { 'Content-Type': 'application/json' },
|
|
218
221
|
}),
|
|
219
222
|
enabled: Boolean(this.companyId) && (body.enabled ?? true),
|
package/dist/client/realtime.js
CHANGED
|
@@ -45,13 +45,13 @@ export function constructJob(raw) {
|
|
|
45
45
|
const job = new Job(raw);
|
|
46
46
|
job.current_event = job.tasks.reduce((latest, task) => {
|
|
47
47
|
return task.current_event &&
|
|
48
|
-
(!latest || task.current_event.time_started > latest.time_started)
|
|
48
|
+
(!latest || (task.current_event.time_started ?? 0) > (latest.time_started ?? 0))
|
|
49
49
|
? task.current_event
|
|
50
50
|
: latest;
|
|
51
51
|
}, job.current_event);
|
|
52
52
|
job.last_completed_event = job.tasks.reduce((latest, task) => {
|
|
53
53
|
return task.last_completed_event &&
|
|
54
|
-
(!latest || task.last_completed_event.time_started > latest.time_started)
|
|
54
|
+
(!latest || (task.last_completed_event.time_started ?? 0) > (latest.time_started ?? 0))
|
|
55
55
|
? task.last_completed_event
|
|
56
56
|
: latest;
|
|
57
57
|
}, job.last_completed_event);
|
|
@@ -176,7 +176,12 @@ function matchPayouts(filters, item) {
|
|
|
176
176
|
return 'unknown';
|
|
177
177
|
return searchAware(filters);
|
|
178
178
|
}
|
|
179
|
-
const bulk = (method, extra = {}) => (client, ids) =>
|
|
179
|
+
const bulk = (method, extra = {}) => (client, ids) =>
|
|
180
|
+
// List endpoints reject `amt: 0` (payouts/months require amt >= 1),
|
|
181
|
+
// and an empty `unknown_ids` would mean "no id filter" anyway.
|
|
182
|
+
ids.length === 0
|
|
183
|
+
? Promise.resolve([])
|
|
184
|
+
: client[method]({ ...extra, unknown_ids: ids, amt: ids.length });
|
|
180
185
|
/** Line-item list endpoints default to unbilled-only: ask for every bucket. */
|
|
181
186
|
const ALL_LINE_ITEM_STATUSES = { unbilled: true, billed: true, paid: true };
|
|
182
187
|
/** Single-entity GET (404/403 is treated as gone by the applier). */
|
|
@@ -0,0 +1,221 @@
|
|
|
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, PaymentType, TaskStatus, User } 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. */
|
|
11
|
+
description?: string | null;
|
|
12
|
+
}
|
|
13
|
+
/** Body of `PUT /skill/<id>` (backend `UpdateSkill`); omitted fields are unchanged. */
|
|
14
|
+
export type SkillUpdatePayload = Partial<SkillCreatePayload>;
|
|
15
|
+
/** `status` filter of `POST /company/<id>/payouts` (backend `PayoutsListBody`). */
|
|
16
|
+
export type PayoutStatusFilter = 'paid' | 'pending' | 'in_transit' | 'canceled' | 'failed';
|
|
17
|
+
/**
|
|
18
|
+
* Body of `POST /company/<id>/event` (backend `CreateCompanyEvent`): the
|
|
19
|
+
* `UpdateEvent` fields plus the job. `team_id: ''` is omitted by the SDK.
|
|
20
|
+
*/
|
|
21
|
+
export type EventCreatePayload = EventUpdatePayload & {
|
|
22
|
+
job_id: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Body of `POST /company` (backend `CreateCompany`). `logo` is not read by
|
|
26
|
+
* this endpoint (upload it with `POST /company/<id>/logo`); it is accepted
|
|
27
|
+
* here only so existing callers type-check.
|
|
28
|
+
*/
|
|
29
|
+
export interface CompanyCreatePayload {
|
|
30
|
+
/** 1–256 characters. */
|
|
31
|
+
name: string;
|
|
32
|
+
/** Referral code; unknown codes are ignored. */
|
|
33
|
+
code?: string | null;
|
|
34
|
+
/** IANA zone name. */
|
|
35
|
+
timezone?: string | null;
|
|
36
|
+
overdue_threshold?: number | null;
|
|
37
|
+
delay_scalar?: number | null;
|
|
38
|
+
/** Plan GUID to subscribe to. */
|
|
39
|
+
plan?: string | null;
|
|
40
|
+
logo?: File | null;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Body of `POST /user` (backend `CreateUser`). `password` and `last_name`
|
|
44
|
+
* may be empty; `email` must look like an address; `phone_number` must be a
|
|
45
|
+
* real number with country code (e.g. `+1 616-555-0100`).
|
|
46
|
+
*/
|
|
47
|
+
export interface UserCreatePayload {
|
|
48
|
+
/** 1–150 characters. */
|
|
49
|
+
username: string;
|
|
50
|
+
/** At most 100 characters. */
|
|
51
|
+
first_name: string;
|
|
52
|
+
/** At most 100 characters. */
|
|
53
|
+
last_name: string;
|
|
54
|
+
password: string;
|
|
55
|
+
email: string;
|
|
56
|
+
phone_number?: string | null;
|
|
57
|
+
/** Referral code. */
|
|
58
|
+
code?: string | null;
|
|
59
|
+
/** Company GUID to join as a customer. */
|
|
60
|
+
company_id?: string | null;
|
|
61
|
+
invite_token?: string | null;
|
|
62
|
+
share_location?: boolean | null;
|
|
63
|
+
share_email?: boolean | null;
|
|
64
|
+
share_phone?: boolean | null;
|
|
65
|
+
share_with_public?: boolean | null;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Body of `PUT /user/<id>` (backend `UpdateUser`): profile fields plus the
|
|
69
|
+
* credentials a password/email change needs. `phone_number: ''` leaves the
|
|
70
|
+
* number unchanged; a new `password` must be non-empty.
|
|
71
|
+
*/
|
|
72
|
+
export type UserUpdatePayload = Partial<User> & {
|
|
73
|
+
password?: string;
|
|
74
|
+
current_password?: string;
|
|
75
|
+
/** A fresh Apple identity token, instead of `current_password`. */
|
|
76
|
+
apple_token?: string;
|
|
77
|
+
apple_nonce?: string;
|
|
78
|
+
};
|
|
79
|
+
/** A custom line item on a bill write (backend `BillLineItemIn`). */
|
|
80
|
+
export interface BillLineItemInput {
|
|
81
|
+
name?: string;
|
|
82
|
+
description?: string;
|
|
83
|
+
/** Quantity; may be fractional (e.g. hours). */
|
|
84
|
+
amount?: number;
|
|
85
|
+
/** Unit price in integer cents. */
|
|
86
|
+
cost?: number;
|
|
87
|
+
}
|
|
88
|
+
/** A member recipient on a bill write (backend `BillUserIn`). */
|
|
89
|
+
export interface BillUserInput {
|
|
90
|
+
/** The member's user GUID. */
|
|
91
|
+
id: string;
|
|
92
|
+
/**
|
|
93
|
+
* Create only: charge up to this many integer cents (>= 0) to the
|
|
94
|
+
* user's autopay method. Fractional values are rejected.
|
|
95
|
+
*/
|
|
96
|
+
amt?: number | null;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Body of `POST /company/<id>/bill` and `PUT /bill/<id>` (backend
|
|
100
|
+
* `CreateBill` / `UpdateBill`); omitted or null fields are unchanged.
|
|
101
|
+
*/
|
|
102
|
+
export interface BillWritePayload {
|
|
103
|
+
/** Event GUIDs; replaces the bill's events. */
|
|
104
|
+
events?: string[] | null;
|
|
105
|
+
/** Service month GUIDs. */
|
|
106
|
+
months?: string[] | null;
|
|
107
|
+
/** Prepayment GUIDs. */
|
|
108
|
+
prepayments?: string[] | null;
|
|
109
|
+
/** Replaces the bill's custom line items. */
|
|
110
|
+
line_items?: BillLineItemInput[] | null;
|
|
111
|
+
/** Extra recipients as `[name, email]` pairs. */
|
|
112
|
+
manual_emails?: [string, string][] | null;
|
|
113
|
+
users?: BillUserInput[] | null;
|
|
114
|
+
/** At most 256 characters. */
|
|
115
|
+
name?: string | null;
|
|
116
|
+
/** Marks every item paid outside Avro. */
|
|
117
|
+
status?: 'MANUALLY_PAID' | null;
|
|
118
|
+
/** Unix seconds. */
|
|
119
|
+
due_date?: number | null;
|
|
120
|
+
/** Empty means the company's defaults. */
|
|
121
|
+
enabled_payment_methods?: PaymentType[] | null;
|
|
122
|
+
pass_on_fees?: boolean | null;
|
|
123
|
+
}
|
|
124
|
+
/** Response of `POST /company/<id>/intuit/import` (backend `IntuitImportResult`). */
|
|
125
|
+
export interface IntuitImportResult {
|
|
126
|
+
msg: string;
|
|
127
|
+
imported: number;
|
|
128
|
+
skipped: number;
|
|
129
|
+
payments_imported: number;
|
|
130
|
+
payments_skipped: number;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* A payment option on a catalog item write (backend `CreatePaymentOption`).
|
|
134
|
+
* Prices are integer cents.
|
|
135
|
+
*/
|
|
136
|
+
export interface PaymentOptionInput {
|
|
137
|
+
/** 1–64 characters. */
|
|
138
|
+
name: string;
|
|
139
|
+
is_prepay?: boolean;
|
|
140
|
+
price_under_prepay?: number | null;
|
|
141
|
+
price?: number;
|
|
142
|
+
recommended_prepay_count?: number | null;
|
|
143
|
+
/** Case-insensitive; defaults to `NONE`. */
|
|
144
|
+
mode?: 'NONE' | 'MONTH' | 'SERVICE' | Lowercase<'NONE' | 'MONTH' | 'SERVICE'>;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Body of `PUT /catalog_item/<id>` (backend `UpdateCatalogItem`); omitted
|
|
148
|
+
* fields are unchanged and `null` clears the `recommended_*` fields.
|
|
149
|
+
*/
|
|
150
|
+
export interface CatalogItemUpdatePayload {
|
|
151
|
+
/** 1–256 characters. */
|
|
152
|
+
name?: string | null;
|
|
153
|
+
description?: string | null;
|
|
154
|
+
/**
|
|
155
|
+
* A `CatalogIndustry` name, matched case-insensitively with spaces for
|
|
156
|
+
* underscores (`'Snow Removal'`).
|
|
157
|
+
*/
|
|
158
|
+
industry?: CatalogIndustry | (string & {}) | null;
|
|
159
|
+
/** A `CatalogPriceFormat` name, matched like `industry`. */
|
|
160
|
+
price_format?: CatalogPriceFormat | (string & {}) | null;
|
|
161
|
+
/** Integer seconds between services. */
|
|
162
|
+
recommended_frequency?: number | null;
|
|
163
|
+
/** Unix seconds (>= 0). */
|
|
164
|
+
recommended_activate_on?: number | null;
|
|
165
|
+
/** Unix seconds (>= 0). */
|
|
166
|
+
recommended_expire_on?: number | null;
|
|
167
|
+
/** Skill GUIDs; replaces the item's skills. */
|
|
168
|
+
skills?: string[] | null;
|
|
169
|
+
/** Replaces the item's payment options. */
|
|
170
|
+
payment_options?: PaymentOptionInput[] | null;
|
|
171
|
+
}
|
|
172
|
+
/** Body of `POST /company/<id>/catalog_item` (backend `CreateCatalogItem`). */
|
|
173
|
+
export type CatalogItemCreatePayload = CatalogItemUpdatePayload & {
|
|
174
|
+
name: string;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Body of `POST /job/<id>/proposal` and `PUT /proposal/<id>` (backend
|
|
178
|
+
* `CreateProposal` / `UpdateProposal`); omitted fields are unchanged, and
|
|
179
|
+
* null clears `terms_version_id` / `prepay_due_date`.
|
|
180
|
+
*/
|
|
181
|
+
export interface ProposalWritePayload {
|
|
182
|
+
/** Unix seconds (>= 0) after which the customer can no longer review. */
|
|
183
|
+
expire_on?: number | null;
|
|
184
|
+
/** Terms version GUID; null detaches. */
|
|
185
|
+
terms_version_id?: string | null;
|
|
186
|
+
/** Unix seconds (>= 0); null clears. */
|
|
187
|
+
prepay_due_date?: number | null;
|
|
188
|
+
/** Replaces the proposal's tasks (only `id` is read). */
|
|
189
|
+
tasks?: {
|
|
190
|
+
id: string;
|
|
191
|
+
}[] | null;
|
|
192
|
+
}
|
|
193
|
+
/** A prepayment a customer commits to when accepting a task (backend `AcceptPrepayment`). */
|
|
194
|
+
export interface ProposalReviewPrepayment {
|
|
195
|
+
/** Unit price in integer cents (>= 0). */
|
|
196
|
+
cost?: number;
|
|
197
|
+
/** Integer count (>= 1). */
|
|
198
|
+
amount?: number;
|
|
199
|
+
type?: 'SERVICE' | 'MONTH';
|
|
200
|
+
description?: string;
|
|
201
|
+
name?: string;
|
|
202
|
+
}
|
|
203
|
+
/** The customer's decision on one proposal task (backend `ReviewTask`). */
|
|
204
|
+
export interface ProposalReviewTask {
|
|
205
|
+
id: string;
|
|
206
|
+
/** `ARCHIVED` rejects the task; anything else accepts it. */
|
|
207
|
+
status?: TaskStatus | null;
|
|
208
|
+
prepayments?: ProposalReviewPrepayment[] | null;
|
|
209
|
+
bill_mode?: 'NONE' | 'MONTH' | 'SERVICE' | null;
|
|
210
|
+
/** Chosen price in integer cents. */
|
|
211
|
+
price?: number | null;
|
|
212
|
+
/** @deprecated Not read by the backend. */
|
|
213
|
+
payment_option_id?: string;
|
|
214
|
+
}
|
|
215
|
+
/** Body of `POST /proposal/<id>/review` (backend `ReviewProposal`). */
|
|
216
|
+
export interface ProposalReviewPayload {
|
|
217
|
+
tasks?: ProposalReviewTask[];
|
|
218
|
+
/** Required when the proposal has terms and any task is accepted. */
|
|
219
|
+
terms_version_id?: string | null;
|
|
220
|
+
pay_in_cash?: boolean;
|
|
221
|
+
}
|
|
@@ -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
|
}
|
package/dist/types/api/Avro.d.ts
CHANGED
|
@@ -2,15 +2,15 @@ import { Email } from './Email.js';
|
|
|
2
2
|
export interface Avro {
|
|
3
3
|
id: string;
|
|
4
4
|
name: string;
|
|
5
|
-
time_created: number;
|
|
6
|
-
time_updated: number;
|
|
5
|
+
time_created: number | null;
|
|
6
|
+
time_updated: number | null;
|
|
7
7
|
emails: Email[];
|
|
8
|
-
totp_email_id: string;
|
|
9
|
-
billing_email_id: string;
|
|
10
|
-
join_email_id: string;
|
|
8
|
+
totp_email_id: string | null;
|
|
9
|
+
billing_email_id: string | null;
|
|
10
|
+
join_email_id: string | null;
|
|
11
11
|
}
|
|
12
12
|
export interface StorageByType {
|
|
13
|
-
type:
|
|
13
|
+
type: 'TASK' | 'EVENT' | 'NOTIFICATION' | 'COMPANY_LOGO' | 'USER_PROFILE';
|
|
14
14
|
count: number;
|
|
15
15
|
bytes: number;
|
|
16
16
|
}
|
|
@@ -112,28 +112,33 @@ export interface ClientErrorReport {
|
|
|
112
112
|
export interface ErrorLogEntry {
|
|
113
113
|
id: string;
|
|
114
114
|
time: number;
|
|
115
|
-
source: 'backend' | 'app' | 'web'
|
|
116
|
-
status
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
115
|
+
source: 'backend' | 'app' | 'web';
|
|
116
|
+
/** HTTP status; absent from client reports. */
|
|
117
|
+
status?: number | null;
|
|
118
|
+
message: string | null;
|
|
119
|
+
traceback?: string | null;
|
|
120
|
+
stack?: string | null;
|
|
121
|
+
fatal?: boolean | null;
|
|
122
|
+
platform?: string | null;
|
|
123
|
+
app_version?: string | null;
|
|
124
|
+
update_id?: string | null;
|
|
125
|
+
route?: string | null;
|
|
126
|
+
method: string;
|
|
127
|
+
path: string;
|
|
128
|
+
endpoint: string | null;
|
|
129
|
+
client_id: string | null;
|
|
130
|
+
client_version: string | null;
|
|
131
|
+
js_version: string | null;
|
|
132
|
+
user_agent: string | null;
|
|
133
|
+
remote_addr: string | null;
|
|
134
|
+
forwarded_for: string | null;
|
|
135
|
+
source_ip: string | null;
|
|
136
|
+
/** A string when the stored value was too long and was truncated to its JSON text. */
|
|
137
|
+
user: {
|
|
135
138
|
id: string;
|
|
136
139
|
username: string;
|
|
137
|
-
|
|
138
|
-
|
|
140
|
+
is_paying?: boolean | null;
|
|
141
|
+
} | string | null;
|
|
142
|
+
/** A string when the stored value was too long and was truncated to its JSON text. */
|
|
143
|
+
extra?: Record<string, unknown> | string | null;
|
|
139
144
|
}
|
package/dist/types/api/Bill.d.ts
CHANGED
|
@@ -18,24 +18,26 @@ declare module './Bill.js' {
|
|
|
18
18
|
id: string;
|
|
19
19
|
invoice_id: number;
|
|
20
20
|
intuit_id: string | null;
|
|
21
|
-
name: string;
|
|
21
|
+
name: string | null;
|
|
22
|
+
/** Creator's user GUID; the string "None" for automatically created bills. */
|
|
22
23
|
billed_by: string;
|
|
23
|
-
customer_email: string | null;
|
|
24
24
|
manual_emails: string[][];
|
|
25
25
|
users: BillUser[];
|
|
26
26
|
status: BillStatus;
|
|
27
27
|
enabled_payment_methods: PaymentType[];
|
|
28
|
-
time_created: number;
|
|
29
|
-
time_updated: number;
|
|
28
|
+
time_created: number | null;
|
|
29
|
+
time_updated: number | null;
|
|
30
30
|
events: string[];
|
|
31
|
+
/** Unix time of the first PaymentIntent; -1 when none. */
|
|
31
32
|
intent_created_at: number;
|
|
33
|
+
/** Unix time of the latest PaymentIntent; -1 when none. */
|
|
32
34
|
intent_last_created_at: number;
|
|
33
35
|
payments: BillPayment[];
|
|
34
36
|
refunds: Refund[];
|
|
35
37
|
line_items: LineItem[];
|
|
36
38
|
prepayments: string[];
|
|
37
39
|
months: string[];
|
|
38
|
-
due_date: number;
|
|
40
|
+
due_date: number | null;
|
|
39
41
|
pass_on_fees: boolean;
|
|
40
42
|
}
|
|
41
43
|
}
|