@go-avro/avro-js 1.6.6-rc9 → 1.7.1
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/chat.d.ts +25 -0
- package/dist/chat.js +47 -0
- package/dist/client/QueryClient.d.ts +135 -26
- package/dist/client/QueryClient.js +115 -59
- package/dist/client/cache.d.ts +4 -0
- package/dist/client/cache.js +19 -0
- package/dist/client/core/uploads.js +226 -0
- package/dist/client/hooks/accounts.js +52 -0
- package/dist/client/hooks/bills.js +19 -17
- package/dist/client/hooks/catalog_items.js +16 -4
- package/dist/client/hooks/chats.js +26 -0
- package/dist/client/hooks/devices.js +17 -3
- package/dist/client/hooks/messages.js +54 -1
- package/dist/client/hooks/routes.js +4 -1
- package/dist/client/hooks/teams.js +4 -1
- package/dist/client/hooks/{proposal_terms.js → terms.js} +14 -14
- package/dist/client/realtime.d.ts +26 -3
- package/dist/client/realtime.js +94 -16
- package/dist/client/requests.d.ts +16 -11
- package/dist/index.d.ts +5 -1
- package/dist/index.js +4 -1
- package/dist/types/api/Account.d.ts +61 -0
- package/dist/types/api/Account.js +38 -0
- package/dist/types/api/AuditLog.d.ts +1 -1
- package/dist/types/api/Avro.d.ts +5 -0
- package/dist/types/api/Bill.d.ts +2 -2
- package/dist/types/api/BillPayment.d.ts +2 -2
- package/dist/types/api/CatalogItem.d.ts +3 -1
- package/dist/types/api/Company.d.ts +0 -2
- package/dist/types/api/Job.d.ts +4 -4
- package/dist/types/api/Job.js +11 -2
- package/dist/types/api/MemberState.d.ts +3 -0
- package/dist/types/api/Notification.d.ts +39 -0
- package/dist/types/api/Proposal.d.ts +2 -2
- package/dist/types/api/Task.d.ts +16 -0
- package/dist/types/api/Task.js +30 -3
- package/dist/types/api/{ProposalTerms.d.ts → Terms.d.ts} +3 -3
- package/dist/types/api/Terms.js +1 -0
- package/dist/types/api.d.ts +2 -2
- package/dist/types/api.js +2 -2
- package/dist/types/client.d.ts +125 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/types/api/Subscription.d.ts +0 -10
- /package/dist/client/{hooks/proposal_terms.d.ts → core/uploads.d.ts} +0 -0
- /package/dist/{types/api/ProposalTerms.js → client/hooks/accounts.d.ts} +0 -0
- /package/dist/{types/api/Subscription.js → client/hooks/terms.d.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TermsVersion } from './Terms.js';
|
|
2
2
|
import { Task } from './Task.js';
|
|
3
3
|
export interface Proposal {
|
|
4
4
|
id: string;
|
|
@@ -6,7 +6,7 @@ export interface Proposal {
|
|
|
6
6
|
job_id: string;
|
|
7
7
|
expire_on: number | null;
|
|
8
8
|
expired: boolean;
|
|
9
|
-
terms:
|
|
9
|
+
terms: TermsVersion[];
|
|
10
10
|
accepted_at: number | null;
|
|
11
11
|
tasks: Task[];
|
|
12
12
|
}
|
package/dist/types/api/Task.d.ts
CHANGED
|
@@ -75,6 +75,14 @@ declare module './Task.js' {
|
|
|
75
75
|
bill_mode: 'MONTH' | 'SERVICE' | 'NONE';
|
|
76
76
|
autobill: boolean;
|
|
77
77
|
price: number;
|
|
78
|
+
/**
|
|
79
|
+
* Units (or square feet) priced into `price` and the payment options,
|
|
80
|
+
* for `PER_UNIT` / `PER_SQFT` catalog items; null otherwise. Prices are
|
|
81
|
+
* already totals, so never multiply by this.
|
|
82
|
+
*/
|
|
83
|
+
quantity: number | null;
|
|
84
|
+
/** What `quantity` counts; null when there is no quantity. */
|
|
85
|
+
quantity_unit: 'UNIT' | 'SQFT' | null;
|
|
78
86
|
last_unrouted_reason: UnroutedReason | null;
|
|
79
87
|
services_remaining: number;
|
|
80
88
|
activate_on: number | null;
|
|
@@ -123,5 +131,13 @@ export declare class Task {
|
|
|
123
131
|
getPrepaidEventsRemaining: () => number;
|
|
124
132
|
getPrepaidMonthsRemaining: () => number;
|
|
125
133
|
isDone: (route: Route) => boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Whether this visit of `route` should do the task: it's active and
|
|
136
|
+
* either done on the route's day or due before the route's next visit.
|
|
137
|
+
* A task repeating less often than its route (biweekly edging on a
|
|
138
|
+
* weekly route) is not due on its off-weeks, so a stop's progress
|
|
139
|
+
* leaves it out instead of showing the stop as partly done.
|
|
140
|
+
*/
|
|
141
|
+
isDueOn: (route: Route) => boolean;
|
|
126
142
|
}
|
|
127
143
|
export {};
|
package/dist/types/api/Task.js
CHANGED
|
@@ -66,6 +66,12 @@ export const getTaskOverdueness = (task, now = Date.now() / 1000) => {
|
|
|
66
66
|
}
|
|
67
67
|
return overdueTime / (86400 * (task.priority ? 1 : 7));
|
|
68
68
|
};
|
|
69
|
+
/** Local midnight starting the day of the route's current occurrence. */
|
|
70
|
+
function routeDayStart(route) {
|
|
71
|
+
const day = new Date((route.start_time ?? 0) * 1000);
|
|
72
|
+
day.setHours(0, 0, 0, 0);
|
|
73
|
+
return day;
|
|
74
|
+
}
|
|
69
75
|
export class Task {
|
|
70
76
|
constructor(init) {
|
|
71
77
|
this.getStatusLabel = () => {
|
|
@@ -182,11 +188,32 @@ export class Task {
|
|
|
182
188
|
// an early-started visit that finishes a few minutes before
|
|
183
189
|
// route.start_time) while still rejecting stale events from previous
|
|
184
190
|
// occurrences. Applies to both recurring and one-shot tasks.
|
|
185
|
-
const
|
|
186
|
-
routeDay.setHours(0, 0, 0, 0);
|
|
187
|
-
const cutoff = Math.floor(routeDay.getTime() / 1000);
|
|
191
|
+
const cutoff = Math.floor(routeDayStart(route).getTime() / 1000);
|
|
188
192
|
return (this.last_completed_event?.time_ended ?? 0) >= cutoff;
|
|
189
193
|
};
|
|
194
|
+
/**
|
|
195
|
+
* Whether this visit of `route` should do the task: it's active and
|
|
196
|
+
* either done on the route's day or due before the route's next visit.
|
|
197
|
+
* A task repeating less often than its route (biweekly edging on a
|
|
198
|
+
* weekly route) is not due on its off-weeks, so a stop's progress
|
|
199
|
+
* leaves it out instead of showing the stop as partly done.
|
|
200
|
+
*/
|
|
201
|
+
this.isDueOn = (route) => {
|
|
202
|
+
if (this.status !== TaskStatus.ACTIVE)
|
|
203
|
+
return false;
|
|
204
|
+
if (this.isDone(route))
|
|
205
|
+
return true;
|
|
206
|
+
const nextDue = this.getNextDue();
|
|
207
|
+
if (nextDue == null)
|
|
208
|
+
return true;
|
|
209
|
+
const routeDayEnd = routeDayStart(route);
|
|
210
|
+
routeDayEnd.setDate(routeDayEnd.getDate() + 1);
|
|
211
|
+
const nextVisit = route.getNextOccurrence(routeDayEnd);
|
|
212
|
+
// One-off routes have no next visit: then only the route's day counts.
|
|
213
|
+
const horizon = nextVisit ? new Date(nextVisit) : routeDayEnd;
|
|
214
|
+
horizon.setHours(0, 0, 0, 0);
|
|
215
|
+
return nextDue < Math.floor(horizon.getTime() / 1000);
|
|
216
|
+
};
|
|
190
217
|
assignData(this, init);
|
|
191
218
|
// Payloads from the server carry no timestamp: they were computed
|
|
192
219
|
// just now. Copies keep the one they were made with.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface TermsVersion {
|
|
2
2
|
id: string;
|
|
3
3
|
terms_id: string;
|
|
4
4
|
name: string;
|
|
@@ -6,12 +6,12 @@ export interface ProposalTermsVersion {
|
|
|
6
6
|
body: string;
|
|
7
7
|
time_created: number | null;
|
|
8
8
|
}
|
|
9
|
-
export interface
|
|
9
|
+
export interface Terms {
|
|
10
10
|
id: string;
|
|
11
11
|
company_id: string;
|
|
12
12
|
name: string | null;
|
|
13
13
|
archived: boolean;
|
|
14
|
-
current_version:
|
|
14
|
+
current_version: TermsVersion | null;
|
|
15
15
|
time_created: number | null;
|
|
16
16
|
time_updated: number | null;
|
|
17
17
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/api.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FrequencyType } from '..';
|
|
2
2
|
import type { LineItemStatus } from './api/LineItem.js';
|
|
3
3
|
export * from './api/_Event.js';
|
|
4
|
+
export * from './api/Account.js';
|
|
4
5
|
export * from './api/AdditionalCharge.js';
|
|
5
6
|
export * from './api/DelayEvent.js';
|
|
6
7
|
export * from './api/Device.js';
|
|
@@ -36,14 +37,13 @@ export * from './api/PlanPayment.js';
|
|
|
36
37
|
export * from './api/Prepayment.js';
|
|
37
38
|
export * from './api/ProcessingFeeLineItem.js';
|
|
38
39
|
export * from './api/Proposal.js';
|
|
39
|
-
export * from './api/
|
|
40
|
+
export * from './api/Terms.js';
|
|
40
41
|
export * from './api/Reaction.js';
|
|
41
42
|
export * from './api/Route.js';
|
|
42
43
|
export * from './api/RouteJob.js';
|
|
43
44
|
export * from './api/ServiceMonth.js';
|
|
44
45
|
export * from './api/Session.js';
|
|
45
46
|
export * from './api/Skill.js';
|
|
46
|
-
export * from './api/Subscription.js';
|
|
47
47
|
export * from './api/Task.js';
|
|
48
48
|
export * from './api/Timecard.js';
|
|
49
49
|
export * from './api/TimecardAction.js';
|
package/dist/types/api.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './api/_Event.js';
|
|
2
|
+
export * from './api/Account.js';
|
|
2
3
|
export * from './api/AdditionalCharge.js';
|
|
3
4
|
export * from './api/DelayEvent.js';
|
|
4
5
|
export * from './api/Device.js';
|
|
@@ -34,14 +35,13 @@ export * from './api/PlanPayment.js';
|
|
|
34
35
|
export * from './api/Prepayment.js';
|
|
35
36
|
export * from './api/ProcessingFeeLineItem.js';
|
|
36
37
|
export * from './api/Proposal.js';
|
|
37
|
-
export * from './api/
|
|
38
|
+
export * from './api/Terms.js';
|
|
38
39
|
export * from './api/Reaction.js';
|
|
39
40
|
export * from './api/Route.js';
|
|
40
41
|
export * from './api/RouteJob.js';
|
|
41
42
|
export * from './api/ServiceMonth.js';
|
|
42
43
|
export * from './api/Session.js';
|
|
43
44
|
export * from './api/Skill.js';
|
|
44
|
-
export * from './api/Subscription.js';
|
|
45
45
|
export * from './api/Task.js';
|
|
46
46
|
export * from './api/Timecard.js';
|
|
47
47
|
export * from './api/TimecardAction.js';
|
package/dist/types/client.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CreateNotificationPayload, SendEmailPayload } from './api.js';
|
|
1
2
|
export type RetryStrategy = 'fixed' | 'exponential' | ((attempt: number) => number);
|
|
2
3
|
export interface CancelToken {
|
|
3
4
|
isCancelled(): boolean;
|
|
@@ -11,3 +12,127 @@ export declare const ClientId: {
|
|
|
11
12
|
readonly DEV_APP: "dev-app";
|
|
12
13
|
};
|
|
13
14
|
export type ClientId = (typeof ClientId)[keyof typeof ClientId];
|
|
15
|
+
/**
|
|
16
|
+
* A photo file to upload: a browser `Blob`/`File`, or React Native's
|
|
17
|
+
* `{ uri, name, type }` file reference.
|
|
18
|
+
*/
|
|
19
|
+
export type UploadFile = Blob | {
|
|
20
|
+
uri: string;
|
|
21
|
+
name: string;
|
|
22
|
+
type: string;
|
|
23
|
+
};
|
|
24
|
+
/** One photo for `uploadImages` / `useUploadImages`. */
|
|
25
|
+
export interface UploadImage {
|
|
26
|
+
file: UploadFile;
|
|
27
|
+
/** MIME type (`image/jpeg`, `image/png`, …); S3 enforces it. */
|
|
28
|
+
type: string;
|
|
29
|
+
/** Size in bytes; the upload may not exceed it. */
|
|
30
|
+
size: number;
|
|
31
|
+
/** File name sent with the upload (defaults to a `File`'s own name). */
|
|
32
|
+
name?: string;
|
|
33
|
+
/**
|
|
34
|
+
* The name the server gave this photo on an earlier try (from
|
|
35
|
+
* `UploadImageFailure.upload`). Sending it back resends the same photo,
|
|
36
|
+
* so one resent after a lost response, or from an offline queue, is
|
|
37
|
+
* never stored twice.
|
|
38
|
+
*/
|
|
39
|
+
upload?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface UploadImagesOptions {
|
|
42
|
+
/** Progress in photos: `sent` of `total`, fractional mid-upload. */
|
|
43
|
+
onProgress?: (sent: number, total: number) => void;
|
|
44
|
+
/** Tries per photo upload to S3 before it counts as failed. */
|
|
45
|
+
attempts?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Each S3 upload try as it starts, with when the whole upload will give
|
|
48
|
+
* up (and report the rest retryable) if the connection stays stalled,
|
|
49
|
+
* e.g. to show a countdown on a slow connection.
|
|
50
|
+
*/
|
|
51
|
+
onAttempt?: (attempt: {
|
|
52
|
+
startedAt: number;
|
|
53
|
+
giveUpAt: number;
|
|
54
|
+
}) => void;
|
|
55
|
+
/** Cancelling aborts the upload in flight too (e.g. "Try later"). */
|
|
56
|
+
cancelToken?: CancelToken;
|
|
57
|
+
}
|
|
58
|
+
/** The event or task photos are uploaded to. */
|
|
59
|
+
export type ImageTarget = {
|
|
60
|
+
eventId: string;
|
|
61
|
+
} | {
|
|
62
|
+
taskId: string;
|
|
63
|
+
};
|
|
64
|
+
/** Variables of `useUploadImages`. */
|
|
65
|
+
export interface UploadImagesVars {
|
|
66
|
+
target: ImageTarget;
|
|
67
|
+
images: UploadImage[];
|
|
68
|
+
options?: UploadImagesOptions;
|
|
69
|
+
}
|
|
70
|
+
/** Variables of `useSendNotification`. */
|
|
71
|
+
export interface SendNotificationVars {
|
|
72
|
+
body: CreateNotificationPayload;
|
|
73
|
+
/** Defaults to the current company. */
|
|
74
|
+
companyId?: string;
|
|
75
|
+
/** Resending with the same key never sends twice (see `useSendEmailMessage`). */
|
|
76
|
+
idempotencyKey?: string;
|
|
77
|
+
}
|
|
78
|
+
/** Variables of `useSendEmailMessage`. */
|
|
79
|
+
export interface SendEmailMessageVars {
|
|
80
|
+
emailId: string;
|
|
81
|
+
body: SendEmailPayload;
|
|
82
|
+
/** Echoed in the `email_succeeded`/`email_failed` events. */
|
|
83
|
+
requestId?: string;
|
|
84
|
+
/** Attach this proposal's PDF (rendered server-side). */
|
|
85
|
+
proposalId?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Any unique string (e.g. a UUID) kept with the message: resending with
|
|
88
|
+
* the same key replays the first send's result instead of emailing
|
|
89
|
+
* again, so a send can be retried after a lost response.
|
|
90
|
+
*/
|
|
91
|
+
idempotencyKey?: string;
|
|
92
|
+
}
|
|
93
|
+
/** Variables of `useSendBillEmail`. */
|
|
94
|
+
export interface SendBillEmailVars {
|
|
95
|
+
billId: string;
|
|
96
|
+
/** Defaults to `Invoice (<number>): <company>`. */
|
|
97
|
+
subject?: string;
|
|
98
|
+
/** `[name, email]` pairs; omitted: the bill's own recipients. */
|
|
99
|
+
recipients?: [string, string][];
|
|
100
|
+
request_id?: string;
|
|
101
|
+
}
|
|
102
|
+
/** Permanent, signed links to an event's photos (`useEventPhotoLinks`). */
|
|
103
|
+
export interface EventPhotoLinks {
|
|
104
|
+
/**
|
|
105
|
+
* One URL per photo position, for `<img>` tags in an email. Each
|
|
106
|
+
* redirects to the photo, including photos still uploading when the
|
|
107
|
+
* email is sent (they appear once stored).
|
|
108
|
+
*/
|
|
109
|
+
images: string[];
|
|
110
|
+
/** A page showing every photo the event has ("View photos"). */
|
|
111
|
+
page: string;
|
|
112
|
+
}
|
|
113
|
+
/** Variables of `useEventPhotoLinks`. */
|
|
114
|
+
export interface EventPhotoLinksVars {
|
|
115
|
+
eventId: string;
|
|
116
|
+
/** How many photo positions to link (photos taken, stored or queued). */
|
|
117
|
+
count: number;
|
|
118
|
+
}
|
|
119
|
+
/** What `generatePDFFromBackend` renders. */
|
|
120
|
+
export type PdfSource = {
|
|
121
|
+
billId: string;
|
|
122
|
+
} | {
|
|
123
|
+
timecardsPeriodStart: number;
|
|
124
|
+
};
|
|
125
|
+
/** A photo that wasn't stored. */
|
|
126
|
+
export interface UploadImageFailure {
|
|
127
|
+
image: UploadImage;
|
|
128
|
+
msg: string;
|
|
129
|
+
/** Worth sending again later (e.g. it never reached S3). */
|
|
130
|
+
retryable: boolean;
|
|
131
|
+
/** The name the server gave it: keep it as `UploadImage.upload`. */
|
|
132
|
+
upload?: string;
|
|
133
|
+
}
|
|
134
|
+
export interface UploadImagesResult {
|
|
135
|
+
/** Stored name per photo, in order; `null` where it failed. */
|
|
136
|
+
names: (string | null)[];
|
|
137
|
+
failed: UploadImageFailure[];
|
|
138
|
+
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AVRO_JS_VERSION = "1.
|
|
1
|
+
export declare const AVRO_JS_VERSION = "1.7.1";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { NotificationLevel } from './UserCompanyAssociation.js';
|
|
2
|
-
export interface Subscription {
|
|
3
|
-
time_created: number | null;
|
|
4
|
-
time_updated: number | null;
|
|
5
|
-
/** The subscribed membership; the string "None" for a group subscription. */
|
|
6
|
-
user_company_id: string;
|
|
7
|
-
job_id: string;
|
|
8
|
-
id: string;
|
|
9
|
-
notifications: NotificationLevel[];
|
|
10
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|