@fleetless/contracts 6.4.0-next.1 → 6.5.0
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/CHANGELOG.md +23 -25
- package/CONTRIBUTING.md +11 -1
- package/README.md +4 -0
- package/artifacts/routes.json +29 -137
- package/dist/app-users.d.ts +3 -3
- package/dist/billing.d.ts +12 -12
- package/dist/errors.d.ts +7 -7
- package/dist/errors.js +0 -14
- package/dist/index.d.ts +2 -8
- package/dist/index.js +1 -5
- package/dist/plans.d.ts +16 -16
- package/dist/routes.d.ts +1 -20
- package/dist/routes.js +29 -79
- package/package.json +2 -2
- package/artifacts/schema/admin-org-detail.schema.json +0 -641
- package/artifacts/schema/admin-search-query.schema.json +0 -14
- package/artifacts/schema/admin-search-response.schema.json +0 -219
- package/artifacts/schema/noop-command-request.schema.json +0 -75
- package/artifacts/schema/noop-command-response.schema.json +0 -134
- package/artifacts/schema/operator-audit-ref.schema.json +0 -28
- package/artifacts/schema/operator-preview.schema.json +0 -66
- package/artifacts/schema/preview-stale-details.schema.json +0 -80
- package/dist/admin.d.ts +0 -217
- package/dist/admin.js +0 -39
- package/dist/operator-commands.d.ts +0 -137
- package/dist/operator-commands.js +0 -51
- package/dist/operator.d.ts +0 -63
- package/dist/operator.js +0 -48
package/dist/admin.d.ts
DELETED
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
/** The kinds `GET /api/admin/search` can answer today (fleetless/fleetless#268). A further kind joins the same union as its data arrives. */
|
|
4
|
-
export declare const ADMIN_SEARCH_KINDS: readonly ["org", "person", "invoice", "payment", "robot"];
|
|
5
|
-
/** The most hits one search answers; past it, `truncated` says so. */
|
|
6
|
-
export declare const ADMIN_SEARCH_LIMIT = 50;
|
|
7
|
-
export declare const adminSearchQuery: z.ZodObject<{
|
|
8
|
-
q: z.ZodString;
|
|
9
|
-
}, z.core.$strip>;
|
|
10
|
-
export type AdminSearchQuery = z.infer<typeof adminSearchQuery>;
|
|
11
|
-
/**
|
|
12
|
-
* One search result. `q` is matched literally, never as a wildcard pattern,
|
|
13
|
-
* and case-insensitively. A `payment` hit's `payment_id` is `null` for a
|
|
14
|
-
* `cst_` or `mdt_` match, which names the account and not a payment.
|
|
15
|
-
*/
|
|
16
|
-
export declare const adminSearchHit: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
17
|
-
kind: z.ZodLiteral<"org">;
|
|
18
|
-
org_id: z.ZodUUID;
|
|
19
|
-
name: z.ZodString;
|
|
20
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
21
|
-
kind: z.ZodLiteral<"person">;
|
|
22
|
-
user_id: z.ZodUUID;
|
|
23
|
-
email: z.ZodString;
|
|
24
|
-
display_name: z.ZodNullable<z.ZodString>;
|
|
25
|
-
org_id: z.ZodUUID;
|
|
26
|
-
org_name: z.ZodString;
|
|
27
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
28
|
-
kind: z.ZodLiteral<"invoice">;
|
|
29
|
-
invoice_id: z.ZodUUID;
|
|
30
|
-
number: z.ZodString;
|
|
31
|
-
org_id: z.ZodNullable<z.ZodUUID>;
|
|
32
|
-
org_name: z.ZodNullable<z.ZodString>;
|
|
33
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
34
|
-
kind: z.ZodLiteral<"payment">;
|
|
35
|
-
payment_id: z.ZodNullable<z.ZodUUID>;
|
|
36
|
-
mollie_id: z.ZodString;
|
|
37
|
-
matched: z.ZodEnum<{
|
|
38
|
-
payment: "payment";
|
|
39
|
-
customer: "customer";
|
|
40
|
-
mandate: "mandate";
|
|
41
|
-
refund: "refund";
|
|
42
|
-
}>;
|
|
43
|
-
org_id: z.ZodUUID;
|
|
44
|
-
org_name: z.ZodString;
|
|
45
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
46
|
-
kind: z.ZodLiteral<"robot">;
|
|
47
|
-
robot_id: z.ZodUUID;
|
|
48
|
-
name: z.ZodString;
|
|
49
|
-
org_id: z.ZodUUID;
|
|
50
|
-
org_name: z.ZodString;
|
|
51
|
-
}, z.core.$strip>], "kind">;
|
|
52
|
-
export type AdminSearchHit = z.infer<typeof adminSearchHit>;
|
|
53
|
-
export declare const adminSearchResponse: z.ZodObject<{
|
|
54
|
-
hits: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
55
|
-
kind: z.ZodLiteral<"org">;
|
|
56
|
-
org_id: z.ZodUUID;
|
|
57
|
-
name: z.ZodString;
|
|
58
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
59
|
-
kind: z.ZodLiteral<"person">;
|
|
60
|
-
user_id: z.ZodUUID;
|
|
61
|
-
email: z.ZodString;
|
|
62
|
-
display_name: z.ZodNullable<z.ZodString>;
|
|
63
|
-
org_id: z.ZodUUID;
|
|
64
|
-
org_name: z.ZodString;
|
|
65
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
66
|
-
kind: z.ZodLiteral<"invoice">;
|
|
67
|
-
invoice_id: z.ZodUUID;
|
|
68
|
-
number: z.ZodString;
|
|
69
|
-
org_id: z.ZodNullable<z.ZodUUID>;
|
|
70
|
-
org_name: z.ZodNullable<z.ZodString>;
|
|
71
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
72
|
-
kind: z.ZodLiteral<"payment">;
|
|
73
|
-
payment_id: z.ZodNullable<z.ZodUUID>;
|
|
74
|
-
mollie_id: z.ZodString;
|
|
75
|
-
matched: z.ZodEnum<{
|
|
76
|
-
payment: "payment";
|
|
77
|
-
customer: "customer";
|
|
78
|
-
mandate: "mandate";
|
|
79
|
-
refund: "refund";
|
|
80
|
-
}>;
|
|
81
|
-
org_id: z.ZodUUID;
|
|
82
|
-
org_name: z.ZodString;
|
|
83
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
84
|
-
kind: z.ZodLiteral<"robot">;
|
|
85
|
-
robot_id: z.ZodUUID;
|
|
86
|
-
name: z.ZodString;
|
|
87
|
-
org_id: z.ZodUUID;
|
|
88
|
-
org_name: z.ZodString;
|
|
89
|
-
}, z.core.$strip>], "kind">>;
|
|
90
|
-
truncated: z.ZodBoolean;
|
|
91
|
-
}, z.core.$strip>;
|
|
92
|
-
export type AdminSearchResponse = z.infer<typeof adminSearchResponse>;
|
|
93
|
-
/**
|
|
94
|
-
* `none` means no `billing_accounts` row; the other values mirror
|
|
95
|
-
* `billingAccountStatus`. The payer, address and payment method never
|
|
96
|
-
* appear here (fleetless/fleetless#268): support may see exactly this
|
|
97
|
-
* billing block, the status chip and next charge only.
|
|
98
|
-
*/
|
|
99
|
-
export declare const adminOrgBillingState: z.ZodEnum<{
|
|
100
|
-
none: "none";
|
|
101
|
-
pending: "pending";
|
|
102
|
-
active: "active";
|
|
103
|
-
past_due: "past_due";
|
|
104
|
-
canceled: "canceled";
|
|
105
|
-
}>;
|
|
106
|
-
export type AdminOrgBillingState = z.infer<typeof adminOrgBillingState>;
|
|
107
|
-
/** `GET /api/admin/orgs/:id`'s response. Locks and plan changes travel in `plan`, which already carries them. */
|
|
108
|
-
export declare const adminOrgDetail: z.ZodObject<{
|
|
109
|
-
id: z.ZodUUID;
|
|
110
|
-
name: z.ZodString;
|
|
111
|
-
created_at: z.ZodISODateTime;
|
|
112
|
-
owner: z.ZodNullable<z.ZodObject<{
|
|
113
|
-
user_id: z.ZodUUID;
|
|
114
|
-
email: z.ZodString;
|
|
115
|
-
display_name: z.ZodNullable<z.ZodString>;
|
|
116
|
-
}, z.core.$strip>>;
|
|
117
|
-
plan: z.ZodObject<{
|
|
118
|
-
plan: z.ZodEnum<{
|
|
119
|
-
basic: "basic";
|
|
120
|
-
plus: "plus";
|
|
121
|
-
pro: "pro";
|
|
122
|
-
enterprise: "enterprise";
|
|
123
|
-
}>;
|
|
124
|
-
currency: z.ZodEnum<{
|
|
125
|
-
eur: "eur";
|
|
126
|
-
usd: "usd";
|
|
127
|
-
}>;
|
|
128
|
-
period_ends_at: z.ZodISODateTime;
|
|
129
|
-
addons: z.ZodObject<{
|
|
130
|
-
seats: z.ZodNumber;
|
|
131
|
-
robots: z.ZodNumber;
|
|
132
|
-
apps: z.ZodNumber;
|
|
133
|
-
app_user_packs: z.ZodNumber;
|
|
134
|
-
live_video_packs: z.ZodNumber;
|
|
135
|
-
}, z.core.$strip>;
|
|
136
|
-
limits: z.ZodObject<{
|
|
137
|
-
seats: z.ZodNullable<z.ZodNumber>;
|
|
138
|
-
robots: z.ZodNullable<z.ZodNumber>;
|
|
139
|
-
apps: z.ZodNullable<z.ZodNumber>;
|
|
140
|
-
app_users: z.ZodNullable<z.ZodNumber>;
|
|
141
|
-
live_video_ms_per_month: z.ZodNullable<z.ZodNumber>;
|
|
142
|
-
asset_bytes_per_robot: z.ZodNullable<z.ZodNumber>;
|
|
143
|
-
history_days: z.ZodNullable<z.ZodNumber>;
|
|
144
|
-
audit_days: z.ZodNullable<z.ZodNumber>;
|
|
145
|
-
}, z.core.$strip>;
|
|
146
|
-
features: z.ZodObject<{
|
|
147
|
-
app_mcp: z.ZodBoolean;
|
|
148
|
-
two_factor: z.ZodBoolean;
|
|
149
|
-
require_two_factor: z.ZodBoolean;
|
|
150
|
-
app_oidc: z.ZodBoolean;
|
|
151
|
-
hosted_logo: z.ZodBoolean;
|
|
152
|
-
audit_export: z.ZodBoolean;
|
|
153
|
-
addons: z.ZodBoolean;
|
|
154
|
-
}, z.core.$strip>;
|
|
155
|
-
usage: z.ZodObject<{
|
|
156
|
-
seats: z.ZodNumber;
|
|
157
|
-
robots: z.ZodNumber;
|
|
158
|
-
apps: z.ZodNumber;
|
|
159
|
-
app_users: z.ZodNumber;
|
|
160
|
-
live_video_ms_this_month: z.ZodNumber;
|
|
161
|
-
asset_bytes: z.ZodNumber;
|
|
162
|
-
}, z.core.$strip>;
|
|
163
|
-
pending_change: z.ZodNullable<z.ZodObject<{
|
|
164
|
-
target_plan: z.ZodEnum<{
|
|
165
|
-
basic: "basic";
|
|
166
|
-
plus: "plus";
|
|
167
|
-
pro: "pro";
|
|
168
|
-
enterprise: "enterprise";
|
|
169
|
-
}>;
|
|
170
|
-
reason: z.ZodEnum<{
|
|
171
|
-
downgrade: "downgrade";
|
|
172
|
-
cancel: "cancel";
|
|
173
|
-
migration: "migration";
|
|
174
|
-
lock: "lock";
|
|
175
|
-
}>;
|
|
176
|
-
effective_at: z.ZodNullable<z.ZodISODateTime>;
|
|
177
|
-
keep: z.ZodNullable<z.ZodObject<{
|
|
178
|
-
robots: z.ZodArray<z.ZodUUID>;
|
|
179
|
-
apps: z.ZodArray<z.ZodUUID>;
|
|
180
|
-
app_users: z.ZodArray<z.ZodUUID>;
|
|
181
|
-
developers: z.ZodArray<z.ZodUUID>;
|
|
182
|
-
}, z.core.$strict>>;
|
|
183
|
-
history_days_after: z.ZodNumber;
|
|
184
|
-
chosen_by: z.ZodUUID;
|
|
185
|
-
chosen_at: z.ZodISODateTime;
|
|
186
|
-
}, z.core.$strip>>;
|
|
187
|
-
lock: z.ZodNullable<z.ZodObject<{
|
|
188
|
-
reason: z.ZodEnum<{
|
|
189
|
-
migration: "migration";
|
|
190
|
-
payment: "payment";
|
|
191
|
-
}>;
|
|
192
|
-
since: z.ZodISODateTime;
|
|
193
|
-
}, z.core.$strip>>;
|
|
194
|
-
switch: z.ZodNullable<z.ZodObject<{
|
|
195
|
-
at: z.ZodNullable<z.ZodISODateTime>;
|
|
196
|
-
needs_choice: z.ZodBoolean;
|
|
197
|
-
}, z.core.$strip>>;
|
|
198
|
-
}, z.core.$strip>;
|
|
199
|
-
billing: z.ZodObject<{
|
|
200
|
-
state: z.ZodEnum<{
|
|
201
|
-
none: "none";
|
|
202
|
-
pending: "pending";
|
|
203
|
-
active: "active";
|
|
204
|
-
past_due: "past_due";
|
|
205
|
-
canceled: "canceled";
|
|
206
|
-
}>;
|
|
207
|
-
next_charge_at: z.ZodNullable<z.ZodISODateTime>;
|
|
208
|
-
}, z.core.$strip>;
|
|
209
|
-
counts: z.ZodObject<{
|
|
210
|
-
members: z.ZodNumber;
|
|
211
|
-
robots: z.ZodNumber;
|
|
212
|
-
robots_online: z.ZodNumber;
|
|
213
|
-
apps: z.ZodNumber;
|
|
214
|
-
}, z.core.$strip>;
|
|
215
|
-
last_activity_at: z.ZodNullable<z.ZodISODateTime>;
|
|
216
|
-
}, z.core.$strip>;
|
|
217
|
-
export type AdminOrgDetail = z.infer<typeof adminOrgDetail>;
|
package/dist/admin.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { orgPlan } from './plans.js';
|
|
4
|
-
/** The kinds `GET /api/admin/search` can answer today (fleetless/fleetless#268). A further kind joins the same union as its data arrives. */
|
|
5
|
-
export const ADMIN_SEARCH_KINDS = ['org', 'person', 'invoice', 'payment', 'robot'];
|
|
6
|
-
/** The most hits one search answers; past it, `truncated` says so. */
|
|
7
|
-
export const ADMIN_SEARCH_LIMIT = 50;
|
|
8
|
-
export const adminSearchQuery = z.object({ q: z.string().trim().min(2).max(200) });
|
|
9
|
-
/**
|
|
10
|
-
* One search result. `q` is matched literally, never as a wildcard pattern,
|
|
11
|
-
* and case-insensitively. A `payment` hit's `payment_id` is `null` for a
|
|
12
|
-
* `cst_` or `mdt_` match, which names the account and not a payment.
|
|
13
|
-
*/
|
|
14
|
-
export const adminSearchHit = z.discriminatedUnion('kind', [
|
|
15
|
-
z.object({ kind: z.literal('org'), org_id: z.uuid(), name: z.string() }),
|
|
16
|
-
z.object({ kind: z.literal('person'), user_id: z.uuid(), email: z.string(), display_name: z.string().nullable(), org_id: z.uuid(), org_name: z.string() }),
|
|
17
|
-
z.object({ kind: z.literal('invoice'), invoice_id: z.uuid(), number: z.string(), org_id: z.uuid().nullable(), org_name: z.string().nullable() }),
|
|
18
|
-
z.object({ kind: z.literal('payment'), payment_id: z.uuid().nullable(), mollie_id: z.string(), matched: z.enum(['payment', 'customer', 'mandate', 'refund']), org_id: z.uuid(), org_name: z.string() }),
|
|
19
|
-
z.object({ kind: z.literal('robot'), robot_id: z.uuid(), name: z.string(), org_id: z.uuid(), org_name: z.string() }),
|
|
20
|
-
]);
|
|
21
|
-
export const adminSearchResponse = z.object({ hits: z.array(adminSearchHit).max(ADMIN_SEARCH_LIMIT), truncated: z.boolean() });
|
|
22
|
-
/**
|
|
23
|
-
* `none` means no `billing_accounts` row; the other values mirror
|
|
24
|
-
* `billingAccountStatus`. The payer, address and payment method never
|
|
25
|
-
* appear here (fleetless/fleetless#268): support may see exactly this
|
|
26
|
-
* billing block, the status chip and next charge only.
|
|
27
|
-
*/
|
|
28
|
-
export const adminOrgBillingState = z.enum(['none', 'pending', 'active', 'past_due', 'canceled']);
|
|
29
|
-
/** `GET /api/admin/orgs/:id`'s response. Locks and plan changes travel in `plan`, which already carries them. */
|
|
30
|
-
export const adminOrgDetail = z.object({
|
|
31
|
-
id: z.uuid(),
|
|
32
|
-
name: z.string(),
|
|
33
|
-
created_at: z.iso.datetime(),
|
|
34
|
-
owner: z.object({ user_id: z.uuid(), email: z.string(), display_name: z.string().nullable() }).nullable(),
|
|
35
|
-
plan: orgPlan,
|
|
36
|
-
billing: z.object({ state: adminOrgBillingState, next_charge_at: z.iso.datetime().nullable() }),
|
|
37
|
-
counts: z.object({ members: z.number().int().min(0), robots: z.number().int().min(0), robots_online: z.number().int().min(0), apps: z.number().int().min(0) }),
|
|
38
|
-
last_activity_at: z.iso.datetime().nullable(),
|
|
39
|
-
});
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
import { z, type ZodType } from 'zod';
|
|
3
|
-
/**
|
|
4
|
-
* One line of a command's preview (fleetless/fleetless#268): `changes`
|
|
5
|
-
* moves a value from `from` to `to`, `triggers` sets something off (a mail,
|
|
6
|
-
* a refund, a document), `keeps` states that something explicitly stays as
|
|
7
|
-
* it is.
|
|
8
|
-
*/
|
|
9
|
-
export declare const previewEffect: z.ZodObject<{
|
|
10
|
-
kind: z.ZodEnum<{
|
|
11
|
-
changes: "changes";
|
|
12
|
-
triggers: "triggers";
|
|
13
|
-
keeps: "keeps";
|
|
14
|
-
}>;
|
|
15
|
-
label: z.ZodString;
|
|
16
|
-
from: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
17
|
-
to: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
18
|
-
amount_cents: z.ZodOptional<z.ZodNumber>;
|
|
19
|
-
}, z.core.$strip>;
|
|
20
|
-
export type PreviewEffect = z.infer<typeof previewEffect>;
|
|
21
|
-
/** What a command's preview answers before an execute: at least one effect. */
|
|
22
|
-
export declare const operatorPreview: z.ZodObject<{
|
|
23
|
-
effects: z.ZodArray<z.ZodObject<{
|
|
24
|
-
kind: z.ZodEnum<{
|
|
25
|
-
changes: "changes";
|
|
26
|
-
triggers: "triggers";
|
|
27
|
-
keeps: "keeps";
|
|
28
|
-
}>;
|
|
29
|
-
label: z.ZodString;
|
|
30
|
-
from: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
31
|
-
to: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
32
|
-
amount_cents: z.ZodOptional<z.ZodNumber>;
|
|
33
|
-
}, z.core.$strip>>;
|
|
34
|
-
}, z.core.$strip>;
|
|
35
|
-
export type OperatorPreview = z.infer<typeof operatorPreview>;
|
|
36
|
-
/**
|
|
37
|
-
* The request body of an operator command, parameterised over its own
|
|
38
|
-
* input shape: a `preview` that only reads, or an `execute` that carries the
|
|
39
|
-
* reason, the preview it confirms and a replay key (fleetless/fleetless#268).
|
|
40
|
-
*/
|
|
41
|
-
export declare function operatorCommandRequest<I extends ZodType>(input: I): z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
42
|
-
mode: z.ZodLiteral<"preview">;
|
|
43
|
-
input: I;
|
|
44
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
45
|
-
mode: z.ZodLiteral<"execute">;
|
|
46
|
-
input: I;
|
|
47
|
-
reason: z.ZodString;
|
|
48
|
-
preview_token: z.ZodString;
|
|
49
|
-
idempotency_key: z.ZodUUID;
|
|
50
|
-
}, z.core.$strip>], "mode">;
|
|
51
|
-
/** The audit rows a command's execute wrote: the operator audit always, the org's audit when the command named one. */
|
|
52
|
-
export declare const operatorAuditRef: z.ZodObject<{
|
|
53
|
-
operator_audit: z.ZodUUID;
|
|
54
|
-
org_audit: z.ZodNullable<z.ZodUUID>;
|
|
55
|
-
}, z.core.$strip>;
|
|
56
|
-
export type OperatorAuditRef = z.infer<typeof operatorAuditRef>;
|
|
57
|
-
/**
|
|
58
|
-
* The response of an operator command, parameterised over its preview and
|
|
59
|
-
* result shapes: a preview mode answers `preview` and a token to confirm it
|
|
60
|
-
* with; an execute answers `result` and the audit rows it wrote.
|
|
61
|
-
*/
|
|
62
|
-
export declare function operatorCommandResponse<P extends ZodType, R extends ZodType>(preview: P, result: R): z.ZodUnion<readonly [z.ZodObject<{
|
|
63
|
-
preview: P;
|
|
64
|
-
preview_token: z.ZodString;
|
|
65
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
66
|
-
result: R;
|
|
67
|
-
audit_ref: z.ZodObject<{
|
|
68
|
-
operator_audit: z.ZodUUID;
|
|
69
|
-
org_audit: z.ZodNullable<z.ZodUUID>;
|
|
70
|
-
}, z.core.$strip>;
|
|
71
|
-
}, z.core.$strip>]>;
|
|
72
|
-
/** `409 preview_stale`'s `details`: a fresh preview and its token, to confirm instead. */
|
|
73
|
-
export declare const previewStaleDetails: z.ZodObject<{
|
|
74
|
-
preview: z.ZodObject<{
|
|
75
|
-
effects: z.ZodArray<z.ZodObject<{
|
|
76
|
-
kind: z.ZodEnum<{
|
|
77
|
-
changes: "changes";
|
|
78
|
-
triggers: "triggers";
|
|
79
|
-
keeps: "keeps";
|
|
80
|
-
}>;
|
|
81
|
-
label: z.ZodString;
|
|
82
|
-
from: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
83
|
-
to: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
84
|
-
amount_cents: z.ZodOptional<z.ZodNumber>;
|
|
85
|
-
}, z.core.$strip>>;
|
|
86
|
-
}, z.core.$strip>;
|
|
87
|
-
preview_token: z.ZodString;
|
|
88
|
-
}, z.core.$strip>;
|
|
89
|
-
export type PreviewStaleDetails = z.infer<typeof previewStaleDetails>;
|
|
90
|
-
/** The no-op command's input: the org whose audit the row proves the protocol against. */
|
|
91
|
-
export declare const noopCommandInput: z.ZodObject<{
|
|
92
|
-
org_id: z.ZodUUID;
|
|
93
|
-
}, z.core.$strip>;
|
|
94
|
-
export type NoopCommandInput = z.infer<typeof noopCommandInput>;
|
|
95
|
-
/** The no-op command's result: it changes nothing, always. */
|
|
96
|
-
export declare const noopCommandResult: z.ZodObject<{
|
|
97
|
-
changed: z.ZodLiteral<false>;
|
|
98
|
-
}, z.core.$strip>;
|
|
99
|
-
export type NoopCommandResult = z.infer<typeof noopCommandResult>;
|
|
100
|
-
export declare const noopCommandRequest: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
101
|
-
mode: z.ZodLiteral<"preview">;
|
|
102
|
-
input: z.ZodObject<{
|
|
103
|
-
org_id: z.ZodUUID;
|
|
104
|
-
}, z.core.$strip>;
|
|
105
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
106
|
-
mode: z.ZodLiteral<"execute">;
|
|
107
|
-
input: z.ZodObject<{
|
|
108
|
-
org_id: z.ZodUUID;
|
|
109
|
-
}, z.core.$strip>;
|
|
110
|
-
reason: z.ZodString;
|
|
111
|
-
preview_token: z.ZodString;
|
|
112
|
-
idempotency_key: z.ZodUUID;
|
|
113
|
-
}, z.core.$strip>], "mode">;
|
|
114
|
-
export declare const noopCommandResponse: z.ZodUnion<readonly [z.ZodObject<{
|
|
115
|
-
preview: z.ZodObject<{
|
|
116
|
-
effects: z.ZodArray<z.ZodObject<{
|
|
117
|
-
kind: z.ZodEnum<{
|
|
118
|
-
changes: "changes";
|
|
119
|
-
triggers: "triggers";
|
|
120
|
-
keeps: "keeps";
|
|
121
|
-
}>;
|
|
122
|
-
label: z.ZodString;
|
|
123
|
-
from: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
124
|
-
to: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
125
|
-
amount_cents: z.ZodOptional<z.ZodNumber>;
|
|
126
|
-
}, z.core.$strip>>;
|
|
127
|
-
}, z.core.$strip>;
|
|
128
|
-
preview_token: z.ZodString;
|
|
129
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
130
|
-
result: z.ZodObject<{
|
|
131
|
-
changed: z.ZodLiteral<false>;
|
|
132
|
-
}, z.core.$strip>;
|
|
133
|
-
audit_ref: z.ZodObject<{
|
|
134
|
-
operator_audit: z.ZodUUID;
|
|
135
|
-
org_audit: z.ZodNullable<z.ZodUUID>;
|
|
136
|
-
}, z.core.$strip>;
|
|
137
|
-
}, z.core.$strip>]>;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import { OPERATOR_REASON_MAX_LENGTH, OPERATOR_REASON_MIN_LENGTH } from './operator.js';
|
|
4
|
-
/**
|
|
5
|
-
* One line of a command's preview (fleetless/fleetless#268): `changes`
|
|
6
|
-
* moves a value from `from` to `to`, `triggers` sets something off (a mail,
|
|
7
|
-
* a refund, a document), `keeps` states that something explicitly stays as
|
|
8
|
-
* it is.
|
|
9
|
-
*/
|
|
10
|
-
export const previewEffect = z.object({
|
|
11
|
-
kind: z.enum(['changes', 'triggers', 'keeps']).meta({ description: '`changes`: a value moves from `from` to `to`. `triggers`: something is set off (a mail, a refund, a document). `keeps`: something explicitly stays as it is.' }),
|
|
12
|
-
label: z.string().min(1).max(300),
|
|
13
|
-
from: z.string().max(300).nullable().optional(),
|
|
14
|
-
to: z.string().max(300).nullable().optional(),
|
|
15
|
-
amount_cents: z.number().int().optional(),
|
|
16
|
-
});
|
|
17
|
-
/** What a command's preview answers before an execute: at least one effect. */
|
|
18
|
-
export const operatorPreview = z.object({ effects: z.array(previewEffect).min(1).max(50) });
|
|
19
|
-
const reason = z.string().trim().min(OPERATOR_REASON_MIN_LENGTH).max(OPERATOR_REASON_MAX_LENGTH);
|
|
20
|
-
/**
|
|
21
|
-
* The request body of an operator command, parameterised over its own
|
|
22
|
-
* input shape: a `preview` that only reads, or an `execute` that carries the
|
|
23
|
-
* reason, the preview it confirms and a replay key (fleetless/fleetless#268).
|
|
24
|
-
*/
|
|
25
|
-
export function operatorCommandRequest(input) {
|
|
26
|
-
return z.discriminatedUnion('mode', [
|
|
27
|
-
z.object({ mode: z.literal('preview'), input }),
|
|
28
|
-
z.object({ mode: z.literal('execute'), input, reason, preview_token: z.string().min(1).max(512), idempotency_key: z.uuid() }),
|
|
29
|
-
]);
|
|
30
|
-
}
|
|
31
|
-
/** The audit rows a command's execute wrote: the operator audit always, the org's audit when the command named one. */
|
|
32
|
-
export const operatorAuditRef = z.object({ operator_audit: z.uuid(), org_audit: z.uuid().nullable() });
|
|
33
|
-
/**
|
|
34
|
-
* The response of an operator command, parameterised over its preview and
|
|
35
|
-
* result shapes: a preview mode answers `preview` and a token to confirm it
|
|
36
|
-
* with; an execute answers `result` and the audit rows it wrote.
|
|
37
|
-
*/
|
|
38
|
-
export function operatorCommandResponse(preview, result) {
|
|
39
|
-
return z.union([
|
|
40
|
-
z.object({ preview, preview_token: z.string().min(1) }),
|
|
41
|
-
z.object({ result, audit_ref: operatorAuditRef }),
|
|
42
|
-
]);
|
|
43
|
-
}
|
|
44
|
-
/** `409 preview_stale`'s `details`: a fresh preview and its token, to confirm instead. */
|
|
45
|
-
export const previewStaleDetails = z.object({ preview: operatorPreview, preview_token: z.string().min(1) });
|
|
46
|
-
/** The no-op command's input: the org whose audit the row proves the protocol against. */
|
|
47
|
-
export const noopCommandInput = z.object({ org_id: z.uuid() });
|
|
48
|
-
/** The no-op command's result: it changes nothing, always. */
|
|
49
|
-
export const noopCommandResult = z.object({ changed: z.literal(false) });
|
|
50
|
-
export const noopCommandRequest = operatorCommandRequest(noopCommandInput);
|
|
51
|
-
export const noopCommandResponse = operatorCommandResponse(operatorPreview, noopCommandResult);
|
package/dist/operator.d.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
/**
|
|
4
|
-
* The three roles an operator assertion may name (fleetless/fleetless#268). The
|
|
5
|
-
* cloud looks up which of them a route needs from `RouteEntry.operator`;
|
|
6
|
-
* a role not listed here makes an assertion malformed (`401`).
|
|
7
|
-
*/
|
|
8
|
-
export declare const OPERATOR_ROLES: readonly ["operator-admin", "operator-finance", "operator-support"];
|
|
9
|
-
export declare const operatorRole: z.ZodEnum<{
|
|
10
|
-
"operator-admin": "operator-admin";
|
|
11
|
-
"operator-finance": "operator-finance";
|
|
12
|
-
"operator-support": "operator-support";
|
|
13
|
-
}>;
|
|
14
|
-
export type OperatorRole = z.infer<typeof operatorRole>;
|
|
15
|
-
/**
|
|
16
|
-
* How the operator app confirms a command's execute (fleetless/fleetless#268).
|
|
17
|
-
* Set only on command routes, never on a read.
|
|
18
|
-
*/
|
|
19
|
-
export declare const CONFIRMATION_LEVELS: readonly ["click", "second_click", "type_to_confirm"];
|
|
20
|
-
export declare const confirmationLevel: z.ZodEnum<{
|
|
21
|
-
click: "click";
|
|
22
|
-
second_click: "second_click";
|
|
23
|
-
type_to_confirm: "type_to_confirm";
|
|
24
|
-
}>;
|
|
25
|
-
export type ConfirmationLevel = z.infer<typeof confirmationLevel>;
|
|
26
|
-
/** The operator assertion's `iss` claim; the cloud refuses any other issuer. */
|
|
27
|
-
export declare const OPERATOR_ASSERTION_ISSUER = "fleetless-operator";
|
|
28
|
-
/** The `Authorization` header scheme the assertion is sent with: `Authorization: Operator <jwt>`. */
|
|
29
|
-
export declare const OPERATOR_AUTH_SCHEME = "Operator";
|
|
30
|
-
/** The longest `exp - iat` the cloud accepts; a longer-lived assertion is malformed (`401`). */
|
|
31
|
-
export declare const OPERATOR_ASSERTION_MAX_LIFETIME_SECONDS = 60;
|
|
32
|
-
/** How far into the future `iat` may lie before the cloud refuses it as malformed (`401`). */
|
|
33
|
-
export declare const OPERATOR_ASSERTION_MAX_FUTURE_SKEW_SECONDS = 30;
|
|
34
|
-
/** How long a `jti` is remembered to refuse a replay, in the cloud process's memory. */
|
|
35
|
-
export declare const OPERATOR_ASSERTION_REPLAY_WINDOW_SECONDS = 120;
|
|
36
|
-
/** The shortest `reason` a command execute may send, after trimming. */
|
|
37
|
-
export declare const OPERATOR_REASON_MIN_LENGTH = 10;
|
|
38
|
-
/** The longest `reason` a command execute may send. */
|
|
39
|
-
export declare const OPERATOR_REASON_MAX_LENGTH = 2000;
|
|
40
|
-
/** How long a preview token stays valid before an execute against it answers `409 preview_stale`. */
|
|
41
|
-
export declare const OPERATOR_PREVIEW_MAX_AGE_MS: number;
|
|
42
|
-
/**
|
|
43
|
-
* The claims of an operator assertion (fleetless/fleetless#268): an EdDSA JWT
|
|
44
|
-
* naming the acting person and their roles. The cloud verifies the
|
|
45
|
-
* signature against `OPERATOR_ASSERTION_KEYS` and this shape against the
|
|
46
|
-
* claims before trusting any of it.
|
|
47
|
-
*/
|
|
48
|
-
export declare const operatorAssertionClaims: z.ZodObject<{
|
|
49
|
-
iss: z.ZodLiteral<"fleetless-operator">;
|
|
50
|
-
aud: z.ZodString;
|
|
51
|
-
sub: z.ZodString;
|
|
52
|
-
name: z.ZodString;
|
|
53
|
-
email: z.ZodEmail;
|
|
54
|
-
roles: z.ZodArray<z.ZodEnum<{
|
|
55
|
-
"operator-admin": "operator-admin";
|
|
56
|
-
"operator-finance": "operator-finance";
|
|
57
|
-
"operator-support": "operator-support";
|
|
58
|
-
}>>;
|
|
59
|
-
iat: z.ZodNumber;
|
|
60
|
-
exp: z.ZodNumber;
|
|
61
|
-
jti: z.ZodString;
|
|
62
|
-
}, z.core.$strip>;
|
|
63
|
-
export type OperatorAssertionClaims = z.infer<typeof operatorAssertionClaims>;
|
package/dist/operator.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
/**
|
|
4
|
-
* The three roles an operator assertion may name (fleetless/fleetless#268). The
|
|
5
|
-
* cloud looks up which of them a route needs from `RouteEntry.operator`;
|
|
6
|
-
* a role not listed here makes an assertion malformed (`401`).
|
|
7
|
-
*/
|
|
8
|
-
export const OPERATOR_ROLES = ['operator-admin', 'operator-finance', 'operator-support'];
|
|
9
|
-
export const operatorRole = z.enum(OPERATOR_ROLES);
|
|
10
|
-
/**
|
|
11
|
-
* How the operator app confirms a command's execute (fleetless/fleetless#268).
|
|
12
|
-
* Set only on command routes, never on a read.
|
|
13
|
-
*/
|
|
14
|
-
export const CONFIRMATION_LEVELS = ['click', 'second_click', 'type_to_confirm'];
|
|
15
|
-
export const confirmationLevel = z.enum(CONFIRMATION_LEVELS);
|
|
16
|
-
/** The operator assertion's `iss` claim; the cloud refuses any other issuer. */
|
|
17
|
-
export const OPERATOR_ASSERTION_ISSUER = 'fleetless-operator';
|
|
18
|
-
/** The `Authorization` header scheme the assertion is sent with: `Authorization: Operator <jwt>`. */
|
|
19
|
-
export const OPERATOR_AUTH_SCHEME = 'Operator';
|
|
20
|
-
/** The longest `exp - iat` the cloud accepts; a longer-lived assertion is malformed (`401`). */
|
|
21
|
-
export const OPERATOR_ASSERTION_MAX_LIFETIME_SECONDS = 60;
|
|
22
|
-
/** How far into the future `iat` may lie before the cloud refuses it as malformed (`401`). */
|
|
23
|
-
export const OPERATOR_ASSERTION_MAX_FUTURE_SKEW_SECONDS = 30;
|
|
24
|
-
/** How long a `jti` is remembered to refuse a replay, in the cloud process's memory. */
|
|
25
|
-
export const OPERATOR_ASSERTION_REPLAY_WINDOW_SECONDS = 120;
|
|
26
|
-
/** The shortest `reason` a command execute may send, after trimming. */
|
|
27
|
-
export const OPERATOR_REASON_MIN_LENGTH = 10;
|
|
28
|
-
/** The longest `reason` a command execute may send. */
|
|
29
|
-
export const OPERATOR_REASON_MAX_LENGTH = 2000;
|
|
30
|
-
/** How long a preview token stays valid before an execute against it answers `409 preview_stale`. */
|
|
31
|
-
export const OPERATOR_PREVIEW_MAX_AGE_MS = 10 * 60 * 1000;
|
|
32
|
-
/**
|
|
33
|
-
* The claims of an operator assertion (fleetless/fleetless#268): an EdDSA JWT
|
|
34
|
-
* naming the acting person and their roles. The cloud verifies the
|
|
35
|
-
* signature against `OPERATOR_ASSERTION_KEYS` and this shape against the
|
|
36
|
-
* claims before trusting any of it.
|
|
37
|
-
*/
|
|
38
|
-
export const operatorAssertionClaims = z.object({
|
|
39
|
-
iss: z.literal(OPERATOR_ASSERTION_ISSUER),
|
|
40
|
-
aud: z.string().min(1),
|
|
41
|
-
sub: z.string().min(1).max(200),
|
|
42
|
-
name: z.string().min(1).max(200),
|
|
43
|
-
email: z.email().max(320),
|
|
44
|
-
roles: z.array(operatorRole).max(OPERATOR_ROLES.length),
|
|
45
|
-
iat: z.number().int(),
|
|
46
|
-
exp: z.number().int(),
|
|
47
|
-
jti: z.string().min(16).max(128),
|
|
48
|
-
});
|