@fleetless/contracts 13.3.0 → 15.0.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 +304 -0
- package/artifacts/openapi.json +20156 -10513
- package/artifacts/routes.json +1429 -292
- package/artifacts/schema/access-warning.schema.json +51 -0
- package/artifacts/schema/action-config.schema.json +35 -0
- package/artifacts/schema/addon-catalogue-entry.schema.json +3 -1
- package/artifacts/schema/admin-plan-change-request.schema.json +26 -0
- package/artifacts/schema/app-access-response.schema.json +136 -0
- package/artifacts/schema/app-access.schema.json +80 -0
- package/artifacts/schema/app-deletion-summary.schema.json +15 -8
- package/artifacts/schema/app-invitation-list-response.schema.json +13 -6
- package/artifacts/schema/app-invitation.schema.json +5 -5
- package/artifacts/schema/app-list-response.schema.json +6 -6
- package/artifacts/schema/app-lock.schema.json +30 -0
- package/artifacts/schema/app-user-list-response.schema.json +13 -6
- package/artifacts/schema/app-user.schema.json +13 -6
- package/artifacts/schema/app.schema.json +6 -6
- package/artifacts/schema/asset-plan-limit-details.schema.json +3 -1
- package/artifacts/schema/auth-ok.schema.json +20 -6
- package/artifacts/schema/camera-list-response.schema.json +1 -1
- package/artifacts/schema/client-identity.schema.json +21 -6
- package/artifacts/schema/cloud-config.schema.json +359 -5
- package/artifacts/schema/collection-actor.schema.json +35 -0
- package/artifacts/schema/collection-definitions-response.schema.json +612 -0
- package/artifacts/schema/collection-event.schema.json +216 -0
- package/artifacts/schema/collection-export-query.schema.json +56 -0
- package/artifacts/schema/collection-filter.schema.json +9 -0
- package/artifacts/schema/collection-import-preview.schema.json +143 -0
- package/artifacts/schema/collection-import-request.schema.json +105 -0
- package/artifacts/schema/collection-import-result.schema.json +38 -0
- package/artifacts/schema/collection-list-response.schema.json +119 -0
- package/artifacts/schema/collection-record-get-query.schema.json +12 -0
- package/artifacts/schema/collection-record-history-query.schema.json +35 -0
- package/artifacts/schema/collection-record-history-response.schema.json +389 -0
- package/artifacts/schema/collection-record-list-query.schema.json +67 -0
- package/artifacts/schema/collection-record-list-response.schema.json +212 -0
- package/artifacts/schema/collection-record-restore-request.schema.json +14 -0
- package/artifacts/schema/collection-record-write.schema.json +31 -0
- package/artifacts/schema/collection-record.schema.json +180 -0
- package/artifacts/schema/collection-revision.schema.json +295 -0
- package/artifacts/schema/collection-subscribe-error.schema.json +31 -0
- package/artifacts/schema/collection-subscribe.schema.json +48 -0
- package/artifacts/schema/collection-subscribed.schema.json +22 -0
- package/artifacts/schema/collection-summary.schema.json +92 -0
- package/artifacts/schema/collection-unsubscribe.schema.json +22 -0
- package/artifacts/schema/collections-access-change.schema.json +34 -0
- package/artifacts/schema/collections-document.schema.json +732 -0
- package/artifacts/schema/collections-draft-response.schema.json +845 -0
- package/artifacts/schema/collections-effect.schema.json +384 -0
- package/artifacts/schema/collections-issue.schema.json +36 -0
- package/artifacts/schema/collections-publish-request.schema.json +18 -0
- package/artifacts/schema/collections-publish-response.schema.json +450 -0
- package/artifacts/schema/collections-purge-preview.schema.json +60 -0
- package/artifacts/schema/collections-purge-request.schema.json +27 -0
- package/artifacts/schema/collections-purge-response.schema.json +30 -0
- package/artifacts/schema/collections-restore-preview-query.schema.json +20 -0
- package/artifacts/schema/collections-restore-preview.schema.json +581 -0
- package/artifacts/schema/collections-restore-request.schema.json +27 -0
- package/artifacts/schema/collections-restore-response.schema.json +455 -0
- package/artifacts/schema/collections-schema-preview.schema.json +519 -0
- package/artifacts/schema/collections-schema-published.schema.json +22 -0
- package/artifacts/schema/collections-version-response.schema.json +869 -0
- package/artifacts/schema/collections-version-summary.schema.json +139 -0
- package/artifacts/schema/collections-versions-response.schema.json +167 -0
- package/artifacts/schema/config-draft-response.schema.json +359 -5
- package/artifacts/schema/config-version-response.schema.json +359 -5
- package/artifacts/schema/confirmation-required-details.schema.json +13 -0
- package/artifacts/schema/create-app-invitation-request.schema.json +4 -4
- package/artifacts/schema/create-app-user-request.schema.json +4 -4
- package/artifacts/schema/create-org-role-request.schema.json +33 -0
- package/artifacts/schema/dangling-reference.schema.json +130 -0
- package/artifacts/schema/datapoint-config.schema.json +35 -0
- package/artifacts/schema/datapoint-list-response.schema.json +2 -2
- package/artifacts/schema/effective-capability.schema.json +104 -0
- package/artifacts/schema/effective-rights-query.schema.json +19 -0
- package/artifacts/schema/effective-rights-response.schema.json +396 -0
- package/artifacts/schema/effective-robot-rights.schema.json +266 -0
- package/artifacts/schema/invoke-or-service-response.schema.json +1 -1
- package/artifacts/schema/invoke-response.schema.json +1 -1
- package/artifacts/schema/journal-intent-v2-body.schema.json +74 -0
- package/artifacts/schema/journal-intent-v2.schema.json +84 -0
- package/artifacts/schema/journal-replay-receipt-body.schema.json +1 -0
- package/artifacts/schema/journal-replay-receipt.schema.json +1 -0
- package/artifacts/schema/mcp-robot-datasheet.schema.json +2 -2
- package/artifacts/schema/org-plan.schema.json +29 -1
- package/artifacts/schema/org-quota-usage-counts.schema.json +18 -0
- package/artifacts/schema/org-quota-usage.schema.json +47 -1
- package/artifacts/schema/org-quotas.schema.json +29 -1
- package/artifacts/schema/org-role-list-response.schema.json +206 -0
- package/artifacts/schema/org-role.schema.json +59 -0
- package/artifacts/schema/patch-app-user-request.schema.json +4 -4
- package/artifacts/schema/patch-org-role-request.schema.json +38 -0
- package/artifacts/schema/plan-catalogue-entry.schema.json +29 -1
- package/artifacts/schema/plan-change-decision-status-response.schema.json +29 -1
- package/artifacts/schema/plan-limit-details.schema.json +3 -1
- package/artifacts/schema/plan-limits.schema.json +29 -1
- package/artifacts/schema/plan-overrides.schema.json +26 -0
- package/artifacts/schema/publish-config-response.schema.json +48 -1
- package/artifacts/schema/publisher-config.schema.json +35 -0
- package/artifacts/schema/put-collections-draft-request.schema.json +16 -0
- package/artifacts/schema/put-role-defaults-request.schema.json +127 -0
- package/artifacts/schema/record-changed-details.schema.json +16 -0
- package/artifacts/schema/record-referenced-details.schema.json +35 -0
- package/artifacts/schema/reference-invalid-details.schema.json +25 -0
- package/artifacts/schema/reference-place.schema.json +112 -0
- package/artifacts/schema/rename-slug-response.schema.json +4 -3
- package/artifacts/schema/required-missing-details.schema.json +19 -0
- package/artifacts/schema/robot-config-doc.schema.json +359 -5
- package/artifacts/schema/robot-deletion-summary.schema.json +33 -1
- package/artifacts/schema/role-collection-rights.schema.json +82 -0
- package/artifacts/schema/role-cycle-details.schema.json +18 -0
- package/artifacts/schema/role-defaults-response.schema.json +59 -0
- package/artifacts/schema/role-rename-preview.schema.json +147 -0
- package/artifacts/schema/service-config.schema.json +35 -0
- package/artifacts/schema/slug-usage-response.schema.json +4 -3
- package/artifacts/schema/update-app-request.schema.json +0 -12
- package/dist/app-users.d.ts +11 -8
- package/dist/app-users.js +18 -10
- package/dist/apps.d.ts +258 -71
- package/dist/apps.js +215 -151
- package/dist/audit.d.ts +35 -5
- package/dist/audit.js +40 -2
- package/dist/billing.d.ts +10 -10
- package/dist/client-auth.d.ts +5 -2
- package/dist/client-auth.js +11 -3
- package/dist/client-robots.d.ts +1 -1
- package/dist/client-robots.js +1 -1
- package/dist/collections-issues.d.ts +67 -0
- package/dist/collections-issues.js +340 -0
- package/dist/collections-records.d.ts +562 -0
- package/dist/collections-records.js +525 -0
- package/dist/collections-rights.d.ts +17 -0
- package/dist/collections-rights.js +41 -0
- package/dist/collections-schema.d.ts +1064 -0
- package/dist/collections-schema.js +386 -0
- package/dist/collections-templates.d.ts +55 -0
- package/dist/collections-templates.js +137 -0
- package/dist/collections-transfer.d.ts +101 -0
- package/dist/collections-transfer.js +206 -0
- package/dist/collections-values.d.ts +67 -0
- package/dist/collections-values.js +284 -0
- package/dist/collections.d.ts +568 -0
- package/dist/collections.js +332 -0
- package/dist/common.d.ts +1 -1
- package/dist/common.js +1 -1
- package/dist/config-issues.d.ts +1 -1
- package/dist/config-issues.js +1 -1
- package/dist/config.d.ts +78 -12
- package/dist/config.js +109 -15
- package/dist/errors.d.ts +63 -5
- package/dist/errors.js +152 -24
- package/dist/index.d.ts +40 -14
- package/dist/index.js +27 -7
- package/dist/journal-intents.d.ts +30 -0
- package/dist/journal-intents.js +3 -0
- package/dist/legal-acceptances.d.ts +2 -2
- package/dist/mcp.d.ts +5 -37
- package/dist/mcp.js +4 -14
- package/dist/org-roles.d.ts +186 -0
- package/dist/org-roles.js +199 -0
- package/dist/plans.d.ts +25 -7
- package/dist/plans.js +21 -1
- package/dist/protocol.d.ts +19 -1
- package/dist/realtime.d.ts +172 -3
- package/dist/realtime.js +164 -1
- package/dist/rest.d.ts +104 -53
- package/dist/rest.js +79 -55
- package/dist/rights.d.ts +197 -0
- package/dist/rights.js +396 -0
- package/dist/routes.d.ts +1 -1
- package/dist/routes.js +675 -150
- package/package.json +1 -1
- package/artifacts/schema/mcp-role-preview-response.schema.json +0 -134
- package/artifacts/schema/put-robot-details-request.schema.json +0 -41
- package/artifacts/schema/put-robot-details-response.schema.json +0 -43
- package/artifacts/schema/robot-details-doc.schema.json +0 -33
- package/artifacts/schema/role-delete-query.schema.json +0 -13
- package/artifacts/schema/role-in-use-details.schema.json +0 -28
- package/artifacts/schema/role-list-response.schema.json +0 -48
- package/artifacts/schema/role-permissions.schema.json +0 -61
- package/artifacts/schema/role-rename-request.schema.json +0 -16
- package/artifacts/schema/role.schema.json +0 -35
package/dist/apps.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { slug } from './common.js';
|
|
4
|
+
import { mcpRobotDatasheet } from './mcp.js';
|
|
5
|
+
import { roleCollectionRights } from './collections-rights.js';
|
|
6
|
+
import { ACCESS_KINDS, accessKind, roleKey } from './rights.js';
|
|
4
7
|
/**
|
|
5
8
|
* Apps, roles and rights.
|
|
6
9
|
*
|
|
7
|
-
* The rule that shapes all of this: **
|
|
8
|
-
* assigned to an app
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* The rule that shapes all of this: **a role is the only thing that grants**.
|
|
11
|
+
* A robot assigned to an app is reachable through it, and what a user may use
|
|
12
|
+
* on that robot is decided by the user's role against what the robot's
|
|
13
|
+
* `fleetless.yaml` and the organization's defaults require; what the role does
|
|
14
|
+
* not grant does not exist for that user. An app can only take rights away: its
|
|
15
|
+
* locks win over every role and never grant anything. So there are two places
|
|
16
|
+
* to look when someone cannot see something, the requirement and the lock, and
|
|
17
|
+
* no third.
|
|
12
18
|
*/
|
|
13
19
|
/**
|
|
14
20
|
* The app identifier a client sends at login. Same rule as a service slug:
|
|
@@ -35,38 +41,26 @@ export const app = z.object({
|
|
|
35
41
|
}),
|
|
36
42
|
/** Robots are referenced individually; tags never grant rights. */
|
|
37
43
|
robot_ids: z.array(z.uuid()).meta({
|
|
38
|
-
description: 'The robots this app may reach, each referenced individually. Tags never grant rights, and a robot absent from this list is invisible to the app
|
|
44
|
+
description: 'The robots this app may reach, each referenced individually. Tags never grant rights, and a robot absent from this list is invisible to the app. What a user of the app may use on an attached robot follows that robot\'s `fleetless.yaml` and the organization\'s defaults, less what the app locks.',
|
|
39
45
|
}),
|
|
40
46
|
/**
|
|
41
|
-
* **The app's default role
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* Through the assignment model this was a console prefill and nothing more:
|
|
45
|
-
* `putAssignmentRequest` always carried the role explicitly, so no part of
|
|
46
|
-
* the cloud authorized anybody with it. Assignments are gone. An app user is
|
|
47
|
-
* created or invited **with** a role, and when the request omits one this is
|
|
48
|
-
* the role they get — so the field now decides access on two write paths
|
|
49
|
-
* (`createAppUserRequest`, `createAppInvitationRequest`) rather than
|
|
50
|
-
* pre-filling a form.
|
|
51
|
-
*
|
|
52
|
-
* Worth saying: it changes what a wrong value costs.
|
|
53
|
-
* A prefill somebody can see and correct became a default applied on the
|
|
54
|
-
* server, and the obvious next question — should it be required instead? —
|
|
55
|
-
* has a deliberate answer: no, because an invitation resolves the role at
|
|
56
|
-
* *creation* time and stores it, so an outstanding invitation is never
|
|
57
|
-
* re-aimed by a later change here.
|
|
47
|
+
* **The app's default role, by key.** An app user created, invited or
|
|
48
|
+
* self-registered without an explicit role gets this one, so the field decides
|
|
49
|
+
* access on those paths rather than pre-filling a form.
|
|
58
50
|
*
|
|
59
51
|
* `null` — and nullable rather than absent — means *this app has not chosen
|
|
60
|
-
* one
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
52
|
+
* one*, the normal state of an app until somebody picks a default. A create or
|
|
53
|
+
* invite that names no role against such an app is refused rather than
|
|
54
|
+
* producing a user with no role. An invitation resolves the role when it is
|
|
55
|
+
* issued, so a later change here never re-aims one already sent.
|
|
64
56
|
*
|
|
65
|
-
* The
|
|
66
|
-
*
|
|
57
|
+
* The key is read as it is stored. It need not name a role: a role deleted
|
|
58
|
+
* since leaves the key behind, which grants nothing and shows up as a warning
|
|
59
|
+
* of the app's access. The field is written by `PUT /api/apps/:id/access`,
|
|
60
|
+
* together with the locks, and by no other route.
|
|
67
61
|
*/
|
|
68
|
-
|
|
69
|
-
description: 'The role an app user gets when created or
|
|
62
|
+
default_role: roleKey.nullable().meta({
|
|
63
|
+
description: 'The role, by key, that an app user gets when created, invited or self-registered without an explicit one. `null` means this app has not chosen a default, the normal state of an app until someone picks one, and then a create or invite that names no role is refused. An invitation resolves the role when issued, so changing this never re-aims an outstanding one. The key is shown as stored and may name no role, which grants nothing; `GET /api/apps/:id/access` warns about it. It is set by `PUT /api/apps/:id/access`, not by `PATCH /api/apps/:id`.',
|
|
70
64
|
}),
|
|
71
65
|
created_at: z.iso.datetime().meta({
|
|
72
66
|
description: 'When the app was created, as an ISO 8601 timestamp. `GET /api/apps` orders by this field.',
|
|
@@ -82,11 +76,14 @@ export const appListResponse = z.object({
|
|
|
82
76
|
* What deleting an app would destroy — read before the irreversible click,
|
|
83
77
|
* and carried again by the `app.deleted` audit event.
|
|
84
78
|
*
|
|
85
|
-
* **
|
|
79
|
+
* **Seven numbers, never a sum**, for the reason `robotDeletionSummary` states
|
|
86
80
|
* at length: the console reads this aloud as one sentence, and a total would
|
|
87
|
-
* describe
|
|
81
|
+
* describe seven unrelated magnitudes with one figure on the one screen whose
|
|
88
82
|
* entire justification is naming what cannot be undone.
|
|
89
83
|
*
|
|
84
|
+
* Roles are not here: they belong to the organization, so deleting an app
|
|
85
|
+
* deletes none of them. What the app locks goes with its settings.
|
|
86
|
+
*
|
|
90
87
|
* Robots are not here because they do not go: they belong to the
|
|
91
88
|
* organization, not to the app. The audit trail is not here either — a record
|
|
92
89
|
* of what happened outlives the thing it happened to.
|
|
@@ -95,9 +92,6 @@ export const appDeletionSummary = z.object({
|
|
|
95
92
|
user_count: z.number().int().nonnegative().meta({
|
|
96
93
|
description: 'App users deleted with the app. They are the developer\'s own customers, not Fleetless users, and exist in no other app.',
|
|
97
94
|
}),
|
|
98
|
-
role_count: z.number().int().nonnegative().meta({
|
|
99
|
-
description: 'Roles deleted with the app, each with its per-robot slug grants.',
|
|
100
|
-
}),
|
|
101
95
|
server_key_count: z.number().int().nonnegative().meta({
|
|
102
96
|
description: 'Server keys deleted with the app. A client still holding one is refused at its next request.',
|
|
103
97
|
}),
|
|
@@ -110,6 +104,12 @@ export const appDeletionSummary = z.object({
|
|
|
110
104
|
mail_template_count: z.number().int().nonnegative().meta({
|
|
111
105
|
description: 'Custom mail templates, of at most three. A kind using the Fleetless default text is not counted — there is no row to lose.',
|
|
112
106
|
}),
|
|
107
|
+
collection_count: z.number().int().nonnegative().meta({
|
|
108
|
+
description: 'Collections of the app\'s latest published schema. They go with the app, together with their records and history.',
|
|
109
|
+
}),
|
|
110
|
+
record_count: z.number().int().nonnegative().meta({
|
|
111
|
+
description: 'Records of the app\'s collections, deleted with the app.',
|
|
112
|
+
}),
|
|
113
113
|
});
|
|
114
114
|
/**
|
|
115
115
|
* **`robot_ids` is accepted here, and `.strict()` catches everything else.**
|
|
@@ -149,6 +149,11 @@ export const createAppRequest = z.object({
|
|
|
149
149
|
* remains only for MCP. `group_id` named a group that owned the app; who may
|
|
150
150
|
* log into an app is the app's own user list.
|
|
151
151
|
*
|
|
152
|
+
* The id-based default role is absent too, and it does have a successor: the
|
|
153
|
+
* default role is part of the app's access, replaced together with its locks by
|
|
154
|
+
* `PUT /api/apps/:id/access` and read as `app.default_role`. A patch that still
|
|
155
|
+
* names the old field is refused rather than dropped.
|
|
156
|
+
*
|
|
152
157
|
* The route keeps its own check as belt-and-braces; a schema and a handler
|
|
153
158
|
* agreeing is not two policies, it is one policy stated where each half can
|
|
154
159
|
* enforce it.
|
|
@@ -156,19 +161,6 @@ export const createAppRequest = z.object({
|
|
|
156
161
|
export const updateAppRequest = z.object({
|
|
157
162
|
name: z.string().min(1).max(120).optional(),
|
|
158
163
|
robot_ids: z.array(z.uuid()).optional(),
|
|
159
|
-
/**
|
|
160
|
-
* `app.default_role_id`'s write half — an app *setting*, which is where the
|
|
161
|
-
* two-identity-space model
|
|
162
|
-
* put the default role, so it belongs on the app's own PATCH and not on a
|
|
163
|
-
* route of its own.
|
|
164
|
-
*
|
|
165
|
-
* **`.nullable().optional()`, and the two mean different things.** Absent
|
|
166
|
-
* leaves the current default alone; an explicit `null` clears it. A field
|
|
167
|
-
* that could only be set and never unset would make "we changed our mind"
|
|
168
|
-
* unreachable through the API — the same silence `.strict()` above exists to
|
|
169
|
-
* avoid, from the other direction.
|
|
170
|
-
*/
|
|
171
|
-
default_role_id: z.uuid().nullable().optional(),
|
|
172
164
|
}).strict();
|
|
173
165
|
/**
|
|
174
166
|
* A server key carries full app rights for server-side code — never for
|
|
@@ -205,128 +197,200 @@ export const createServerKeyResponse = z.object({
|
|
|
205
197
|
key: serverKeyToken,
|
|
206
198
|
});
|
|
207
199
|
/**
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
* from.
|
|
200
|
+
* The most exposures one robot's datasheet lists, so the most slugs a lock on
|
|
201
|
+
* one robot can name. Exported for whoever grows a lock (a slug rename adds
|
|
202
|
+
* the new name beside the old one) and must know when there is no room left.
|
|
212
203
|
*/
|
|
213
|
-
export const
|
|
214
|
-
|
|
215
|
-
|
|
204
|
+
export const MAX_LOCK_SLUGS = 2000;
|
|
205
|
+
/** The most robots one app can lock single exposures on; whole kinds go in `locked_kinds`. */
|
|
206
|
+
const MAX_APP_LOCKS = 1000;
|
|
207
|
+
/** A list names nothing twice. */
|
|
208
|
+
const namedOnce = (items) => new Set(items).size === items.length;
|
|
209
|
+
/**
|
|
210
|
+
* **What an app locks, and what it falls back on.** Roles decide who may use
|
|
211
|
+
* what; an app can only take rights away from them, never add any. A lock wins
|
|
212
|
+
* over every role and over the organization's defaults, and applies to the
|
|
213
|
+
* app's users and to its server keys alike.
|
|
214
|
+
*
|
|
215
|
+
* Two ways to lock: a whole kind of access on every robot the app reaches
|
|
216
|
+
* (`locked_kinds`), or single capabilities of single robots (`locked`). The
|
|
217
|
+
* robot-wide `assets` and `job_history` can only be locked as a kind.
|
|
218
|
+
*/
|
|
219
|
+
export const appLock = z.object({
|
|
220
|
+
robot_id: z.uuid().meta({
|
|
221
|
+
description: 'The robot whose capabilities are locked for this app.',
|
|
216
222
|
}),
|
|
217
|
-
|
|
218
|
-
|
|
223
|
+
slugs: z.array(slug).min(1).max(MAX_LOCK_SLUGS).refine(namedOnce, { message: 'Name each slug once.' }).meta({
|
|
224
|
+
uniqueItems: true,
|
|
225
|
+
description: `The slugs of that robot\'s exposures to lock, at least one and each named once, at most ${MAX_LOCK_SLUGS}. A slug the robot has no exposure for is accepted and warns, and locks nothing.`,
|
|
219
226
|
}),
|
|
220
|
-
|
|
221
|
-
|
|
227
|
+
}).strict();
|
|
228
|
+
/** The three fields `appAccess` and `appAccessResponse` share. */
|
|
229
|
+
const appAccessFields = {
|
|
230
|
+
default_role: roleKey.nullable().meta({
|
|
231
|
+
description: 'The role, by key, that an app user gets when created, invited or self-registered without an explicit one. `null` means the app has none, ' +
|
|
232
|
+
'and a create or invite that names no role is refused. A key that names no role is accepted and warns; it grants nothing.',
|
|
222
233
|
}),
|
|
223
|
-
|
|
224
|
-
|
|
234
|
+
locked_kinds: z.array(accessKind).max(ACCESS_KINDS.length).refine(namedOnce, { message: 'Name each kind once.' }).meta({
|
|
235
|
+
uniqueItems: true,
|
|
236
|
+
description: 'Kinds of access locked for every user and server key of the app, on every robot it reaches: `read`, `invoke`, `publish`, `assets` or ' +
|
|
237
|
+
'`job_history`, each at most once. The only way to lock `assets` or `job_history`, which belong to the robot as a whole.',
|
|
225
238
|
}),
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
239
|
+
locked: z.array(appLock).max(MAX_APP_LOCKS)
|
|
240
|
+
.refine((locks) => namedOnce(locks.map((lock) => lock.robot_id)), { message: 'Give each robot one entry; list all of its slugs in it.' })
|
|
241
|
+
.meta({
|
|
242
|
+
description: `Single exposures locked on single robots, one entry per robot and at most ${MAX_APP_LOCKS}. A lock never grants anything: it only takes ` +
|
|
243
|
+
'away what a role would give.',
|
|
231
244
|
}),
|
|
232
|
-
}
|
|
245
|
+
};
|
|
233
246
|
/**
|
|
234
|
-
*
|
|
247
|
+
* **Which state of the access a write was composed from.** A fingerprint of
|
|
248
|
+
* the stored access that changes whenever the stored access does, whoever
|
|
249
|
+
* changed it: another developer's write, but also a slug rename, which adds the
|
|
250
|
+
* new name to every lock that lists the old one, and a robot detached from the
|
|
251
|
+
* app, which drops its lock. Opaque: compare it, do not compute it.
|
|
235
252
|
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
253
|
+
* It is what keeps a full replacement from silently undoing a lock that
|
|
254
|
+
* landed after the caller read the access.
|
|
238
255
|
*/
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}).strict();
|
|
256
|
+
const appAccessRevision = z.string().regex(/^[0-9a-f]{64}$/).meta({
|
|
257
|
+
description: 'A fingerprint of the stored access, 64 lower-case hexadecimal characters. It changes whenever the stored access changes, by whichever route ' +
|
|
258
|
+
'(a write here, a slug rename that adds the new name to a lock, a robot detached from the app). Treat it as opaque: send back the one you read.',
|
|
259
|
+
});
|
|
244
260
|
/**
|
|
245
|
-
*
|
|
261
|
+
* `PUT /api/apps/:id/access`: the whole access of one app, **replaced**. Every
|
|
262
|
+
* field is named on every write, so the body is exactly what the app has
|
|
263
|
+
* afterwards; strict, so a field this route does not take is refused rather
|
|
264
|
+
* than dropped.
|
|
246
265
|
*
|
|
247
|
-
* `
|
|
248
|
-
*
|
|
249
|
-
* it
|
|
250
|
-
*
|
|
251
|
-
* can ask where they should go instead of guessing.
|
|
266
|
+
* `revision` is the one field that is not part of the access: it says which
|
|
267
|
+
* state this body was composed from. A caller that read before it wrote sends
|
|
268
|
+
* it back, and a write composed from a stale read is refused instead of
|
|
269
|
+
* lifting a lock that landed in between.
|
|
252
270
|
*/
|
|
253
|
-
export const
|
|
254
|
-
|
|
255
|
-
|
|
271
|
+
export const appAccess = z.object({
|
|
272
|
+
...appAccessFields,
|
|
273
|
+
revision: appAccessRevision.optional().meta({
|
|
274
|
+
description: 'The `revision` of the access this body was composed from, as `GET` or `PUT /api/apps/:id/access` answered it. When it is sent and the stored ' +
|
|
275
|
+
'access has changed since, the write is refused with `409 target_state_conflict` naming `revision` (rule `stale`) and nothing is written; read ' +
|
|
276
|
+
'the access again and compose the body anew. Left out, the body replaces whatever is stored: the last writer wins.',
|
|
256
277
|
}),
|
|
257
278
|
}).strict();
|
|
258
279
|
/**
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
* All three are reported, zeros included, so a client renders one sentence
|
|
262
|
-
* from one shape rather than inferring a missing key.
|
|
280
|
+
* Something in an app's access that grants or locks nothing as written. Never
|
|
281
|
+
* a refusal: the access is stored as sent, and these say what is out of step.
|
|
263
282
|
*/
|
|
264
|
-
export const
|
|
265
|
-
|
|
266
|
-
description: '
|
|
283
|
+
export const accessWarning = z.object({
|
|
284
|
+
code: z.enum(['unknown_default_role', 'unknown_lock_slug', 'lock_robot_not_attached']).meta({
|
|
285
|
+
description: '`unknown_default_role`: the default role names no role of the organization. `unknown_lock_slug`: a lock names a slug the robot has no ' +
|
|
286
|
+
'published exposure for. `lock_robot_not_attached`: a lock names a robot that is not attached to the app.',
|
|
267
287
|
}),
|
|
268
|
-
|
|
269
|
-
description: '
|
|
288
|
+
message: z.string().min(1).meta({
|
|
289
|
+
description: 'A sentence a person can read, naming the key, robot or slug.',
|
|
270
290
|
}),
|
|
271
|
-
|
|
272
|
-
description: '
|
|
291
|
+
robot_id: z.uuid().nullable().meta({
|
|
292
|
+
description: 'The robot a lock warning is about; `null` for `unknown_default_role`.',
|
|
273
293
|
}),
|
|
274
|
-
|
|
294
|
+
slug: z.string().nullable().meta({
|
|
295
|
+
description: 'The slug an `unknown_lock_slug` warning is about; `null` for the other warnings.',
|
|
296
|
+
}),
|
|
297
|
+
});
|
|
298
|
+
/** What `GET` and `PUT /api/apps/:id/access` answer: the access as it stands, its revision, and what is out of step in it. */
|
|
299
|
+
export const appAccessResponse = z.object({
|
|
300
|
+
...appAccessFields,
|
|
301
|
+
revision: appAccessRevision.meta({
|
|
302
|
+
description: 'The revision of the access as it stands. Send it back as `revision` of the next `PUT` to have that write refused when the access has changed in between.',
|
|
303
|
+
}),
|
|
304
|
+
warnings: z.array(accessWarning).meta({
|
|
305
|
+
description: 'What the access names that does not exist as written. Empty when nothing is out of step.',
|
|
306
|
+
}),
|
|
307
|
+
});
|
|
275
308
|
/**
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
309
|
+
* `GET /api/apps/:id/effective-rights`: look at the app as one role sees it,
|
|
310
|
+
* or as one app user does. Exactly one of the two.
|
|
311
|
+
*
|
|
312
|
+
* The cross-field rule is a `.refine()`, which JSON Schema cannot express, so
|
|
313
|
+
* `effective-rights-query.schema.json` describes two independent optional
|
|
314
|
+
* parameters; the cloud is the only place both-or-neither is refused.
|
|
280
315
|
*/
|
|
281
|
-
export const
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
})
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
316
|
+
export const effectiveRightsQuery = z.object({
|
|
317
|
+
role: roleKey.optional().meta({
|
|
318
|
+
description: 'A role key to look at the app as. A key that names no role is not an error: the answer says `role_known: false` and grants nothing.',
|
|
319
|
+
}),
|
|
320
|
+
user: z.uuid().optional().meta({
|
|
321
|
+
description: 'An app user of this app, to look at the app as that user\'s role. A user of another app answers `404`.',
|
|
322
|
+
}),
|
|
323
|
+
}).strict().refine((query) => (query.role === undefined) !== (query.user === undefined), {
|
|
324
|
+
message: 'Name exactly one of role and user.',
|
|
325
|
+
});
|
|
326
|
+
/** One capability of one robot as a role sees it: granted or not, and why. */
|
|
327
|
+
export const effectiveCapability = z.object({
|
|
328
|
+
name: slug.meta({
|
|
329
|
+
description: 'The exposure\'s slug, or `assets` or `job_history` for the capabilities that belong to the robot as a whole.',
|
|
330
|
+
}),
|
|
331
|
+
kind: accessKind.meta({
|
|
332
|
+
description: 'The kind of access the capability needs.',
|
|
333
|
+
}),
|
|
334
|
+
granted: z.boolean().meta({
|
|
335
|
+
description: 'Whether the role may use it: its requirement is met and the app has not locked it.',
|
|
336
|
+
}),
|
|
337
|
+
requirement: z.array(z.string()).meta({
|
|
338
|
+
description: 'The role keys that qualify, from the entry, the rule or the default that decided. Holding one of them, or inheriting from one, is enough. Empty when nobody qualifies.',
|
|
339
|
+
}),
|
|
340
|
+
source: z.enum(['entry', 'rule', 'robot', 'org_default']).meta({
|
|
341
|
+
description: 'Where the requirement came from: `entry` is the entry\'s own `role`, `rule` the first matching rule of `access.rules`, `robot` the robot\'s ' +
|
|
342
|
+
'`access.assets` or `access.job_history`, and `org_default` the organization\'s default for the kind.',
|
|
343
|
+
}),
|
|
344
|
+
rule_index: z.number().int().nonnegative().nullable().meta({
|
|
345
|
+
description: 'For `rule`, the position of the deciding rule in `access.rules`, counted from zero; `null` otherwise.',
|
|
346
|
+
}),
|
|
347
|
+
rule_match: z.string().nullable().meta({
|
|
348
|
+
description: 'For `rule`, that rule\'s `match` glob; `null` otherwise.',
|
|
349
|
+
}),
|
|
350
|
+
satisfied_by: z.string().nullable().meta({
|
|
351
|
+
description: 'The key from `requirement` that the role holds through inheritance. `null` when the role is named in the requirement itself, and when it ' +
|
|
352
|
+
'does not meet the requirement at all. Independent of locks.',
|
|
353
|
+
}),
|
|
354
|
+
locked: z.boolean().meta({
|
|
355
|
+
description: 'Whether the app locks this capability, as a kind or as a single lock. A lock wins over the requirement.',
|
|
356
|
+
}),
|
|
357
|
+
unknown_roles: z.array(z.string()).meta({
|
|
358
|
+
description: 'Keys in the requirement that name no role of the organization. They grant nothing.',
|
|
359
|
+
}),
|
|
360
|
+
});
|
|
361
|
+
/** One attached robot as a role sees it. */
|
|
362
|
+
export const effectiveRobotRights = z.object({
|
|
363
|
+
robot_id: z.uuid().meta({ description: 'The robot, one that is attached to the app.' }),
|
|
364
|
+
robot_name: z.string().min(1).max(200).meta({ description: 'The robot\'s name.' }),
|
|
365
|
+
published_version: z.number().int().positive().nullable().meta({
|
|
366
|
+
description: 'The version of the robot\'s published `fleetless.yaml` that the answer was computed from; `null` when nothing is published.',
|
|
367
|
+
}),
|
|
368
|
+
reachable: z.boolean().meta({
|
|
369
|
+
description: 'Whether a session of this role reaches the robot at all: at least one slug or one capability is granted once the locks are applied. When `false`, ' +
|
|
370
|
+
'`robots.describe` answers `not_found` for the robot and `robots.list` leaves it out; `capabilities` says why, and `datasheet` is the empty one.',
|
|
371
|
+
}),
|
|
372
|
+
capabilities: z.array(effectiveCapability).meta({
|
|
373
|
+
description: 'Every capability of the published configuration, and `assets` and `job_history`, each granted or not.',
|
|
374
|
+
}),
|
|
375
|
+
datasheet: mcpRobotDatasheet.meta({
|
|
376
|
+
description: 'The datasheet an MCP session of this role would get for the robot.',
|
|
377
|
+
}),
|
|
378
|
+
});
|
|
379
|
+
/** What `GET /api/apps/:id/effective-rights` answers. */
|
|
380
|
+
export const effectiveRightsResponse = z.object({
|
|
381
|
+
role: z.string().nullable().meta({
|
|
382
|
+
description: 'The role key the answer is for: the one asked about, or the app user\'s own. `null` when the app user holds none.',
|
|
383
|
+
}),
|
|
384
|
+
role_known: z.boolean().meta({
|
|
385
|
+
description: 'Whether the key names a role of the organization. `false` means every capability below is not granted.',
|
|
386
|
+
}),
|
|
387
|
+
user_id: z.uuid().nullable().meta({
|
|
388
|
+
description: 'The app user asked about; `null` when a role was asked about. A user who is not `active` reaches nothing, whatever role they hold: every capability below is not granted.',
|
|
389
|
+
}),
|
|
390
|
+
robots: z.array(effectiveRobotRights).meta({
|
|
391
|
+
description: 'The robots attached to the app, each with what the role may use.',
|
|
392
|
+
}),
|
|
393
|
+
collections: z.array(roleCollectionRights).meta({
|
|
394
|
+
description: 'What the role may do with the records of each collection of the app\'s latest published schema, in the schema\'s order. Empty when the app has no published schema. A role that is no role, and a user who is not `active`, are granted nothing in any row.',
|
|
331
395
|
}),
|
|
332
396
|
});
|
package/dist/audit.d.ts
CHANGED
|
@@ -6,8 +6,9 @@ import { z } from 'zod';
|
|
|
6
6
|
* its actor — never anonymous**. Reads are not audited.
|
|
7
7
|
*
|
|
8
8
|
* What is written: logins, failed logins, user management, configuration
|
|
9
|
-
* publishes, bridge connect and disconnect
|
|
10
|
-
* as CSV, and
|
|
9
|
+
* publishes, bridge connect and disconnect, and the writes of app collections
|
|
10
|
+
* (`COLLECTION_AUDIT_ACTIONS`). The log is filterable, exportable as CSV, and
|
|
11
|
+
* kept for ninety days.
|
|
11
12
|
*/
|
|
12
13
|
/**
|
|
13
14
|
* The kinds of actor the platform knows. `label` is what a human reads in the
|
|
@@ -38,11 +39,11 @@ import { z } from 'zod';
|
|
|
38
39
|
export declare const auditActor: z.ZodObject<{
|
|
39
40
|
kind: z.ZodEnum<{
|
|
40
41
|
developer: "developer";
|
|
42
|
+
fleetless: "fleetless";
|
|
41
43
|
server_key: "server_key";
|
|
42
44
|
bridge: "bridge";
|
|
43
45
|
end_user: "end_user";
|
|
44
46
|
app_user: "app_user";
|
|
45
|
-
fleetless: "fleetless";
|
|
46
47
|
}>;
|
|
47
48
|
id: z.ZodUUID;
|
|
48
49
|
label: z.ZodString;
|
|
@@ -56,11 +57,11 @@ export declare const auditEvent: z.ZodObject<{
|
|
|
56
57
|
actor: z.ZodObject<{
|
|
57
58
|
kind: z.ZodEnum<{
|
|
58
59
|
developer: "developer";
|
|
60
|
+
fleetless: "fleetless";
|
|
59
61
|
server_key: "server_key";
|
|
60
62
|
bridge: "bridge";
|
|
61
63
|
end_user: "end_user";
|
|
62
64
|
app_user: "app_user";
|
|
63
|
-
fleetless: "fleetless";
|
|
64
65
|
}>;
|
|
65
66
|
id: z.ZodUUID;
|
|
66
67
|
label: z.ZodString;
|
|
@@ -95,11 +96,11 @@ export declare const auditListResponse: z.ZodObject<{
|
|
|
95
96
|
actor: z.ZodObject<{
|
|
96
97
|
kind: z.ZodEnum<{
|
|
97
98
|
developer: "developer";
|
|
99
|
+
fleetless: "fleetless";
|
|
98
100
|
server_key: "server_key";
|
|
99
101
|
bridge: "bridge";
|
|
100
102
|
end_user: "end_user";
|
|
101
103
|
app_user: "app_user";
|
|
102
|
-
fleetless: "fleetless";
|
|
103
104
|
}>;
|
|
104
105
|
id: z.ZodUUID;
|
|
105
106
|
label: z.ZodString;
|
|
@@ -135,3 +136,32 @@ export declare const AUDIT_CSV_COLUMNS: readonly ["seq", "at", "actor_kind", "ac
|
|
|
135
136
|
* as `ROBOT_ASSET_STORE_BYTES`.
|
|
136
137
|
*/
|
|
137
138
|
export declare const AUDIT_RETENTION_DAYS = 90;
|
|
139
|
+
/**
|
|
140
|
+
* **The audit actions of app collections.** Each write request writes exactly
|
|
141
|
+
* one entry, whatever it changed: an import of 5,000 rows is one
|
|
142
|
+
* `collection_import.completed`, not 5,000 record entries. Reads and exports
|
|
143
|
+
* are not audited, here as everywhere in this log.
|
|
144
|
+
*
|
|
145
|
+
* - `collection_schema.published`: a schema version was published; the entry
|
|
146
|
+
* names the version and counts the effects it had on data. A role rename
|
|
147
|
+
* that rewrites the key in the `access` of an app's collections also appends
|
|
148
|
+
* a version, which changes no record: its entry has no effects and carries
|
|
149
|
+
* `role_rename` with the `from` and `to` keys, and its actor is the
|
|
150
|
+
* developer who renamed the role.
|
|
151
|
+
* - `collection_schema.restored`: an earlier version was restored; the entry
|
|
152
|
+
* names the version, says whether records were put back too and counts what
|
|
153
|
+
* changed.
|
|
154
|
+
* - `collection_record.created`, `.updated`, `.deleted`, `.restored`: one
|
|
155
|
+
* record write; the entry names the collection, the record and its robot.
|
|
156
|
+
* - `collection_import.completed`: an import was carried out; the entry names
|
|
157
|
+
* the collection and the mode and counts the records created, updated and
|
|
158
|
+
* deleted.
|
|
159
|
+
* - `collection_history.purged`: an organization owner removed history older
|
|
160
|
+
* than a date; the entry names the date, the collection or the whole app,
|
|
161
|
+
* and how many revisions went. The actor is the owner.
|
|
162
|
+
*
|
|
163
|
+
* The strings are stable: filter the log with `action` or with
|
|
164
|
+
* `action_prefix` (`collection_record.`).
|
|
165
|
+
*/
|
|
166
|
+
export declare const COLLECTION_AUDIT_ACTIONS: readonly ["collection_schema.published", "collection_schema.restored", "collection_record.created", "collection_record.updated", "collection_record.deleted", "collection_record.restored", "collection_import.completed", "collection_history.purged"];
|
|
167
|
+
export type CollectionAuditAction = (typeof COLLECTION_AUDIT_ACTIONS)[number];
|
package/dist/audit.js
CHANGED
|
@@ -7,8 +7,9 @@ import { wireSeqCursor, wireTimestampMs } from './common.js';
|
|
|
7
7
|
* its actor — never anonymous**. Reads are not audited.
|
|
8
8
|
*
|
|
9
9
|
* What is written: logins, failed logins, user management, configuration
|
|
10
|
-
* publishes, bridge connect and disconnect
|
|
11
|
-
* as CSV, and
|
|
10
|
+
* publishes, bridge connect and disconnect, and the writes of app collections
|
|
11
|
+
* (`COLLECTION_AUDIT_ACTIONS`). The log is filterable, exportable as CSV, and
|
|
12
|
+
* kept for ninety days.
|
|
12
13
|
*/
|
|
13
14
|
/**
|
|
14
15
|
* The kinds of actor the platform knows. `label` is what a human reads in the
|
|
@@ -226,3 +227,40 @@ export const AUDIT_CSV_COLUMNS = ['seq', 'at', 'actor_kind', 'actor_id', 'action
|
|
|
226
227
|
* as `ROBOT_ASSET_STORE_BYTES`.
|
|
227
228
|
*/
|
|
228
229
|
export const AUDIT_RETENTION_DAYS = 90;
|
|
230
|
+
/**
|
|
231
|
+
* **The audit actions of app collections.** Each write request writes exactly
|
|
232
|
+
* one entry, whatever it changed: an import of 5,000 rows is one
|
|
233
|
+
* `collection_import.completed`, not 5,000 record entries. Reads and exports
|
|
234
|
+
* are not audited, here as everywhere in this log.
|
|
235
|
+
*
|
|
236
|
+
* - `collection_schema.published`: a schema version was published; the entry
|
|
237
|
+
* names the version and counts the effects it had on data. A role rename
|
|
238
|
+
* that rewrites the key in the `access` of an app's collections also appends
|
|
239
|
+
* a version, which changes no record: its entry has no effects and carries
|
|
240
|
+
* `role_rename` with the `from` and `to` keys, and its actor is the
|
|
241
|
+
* developer who renamed the role.
|
|
242
|
+
* - `collection_schema.restored`: an earlier version was restored; the entry
|
|
243
|
+
* names the version, says whether records were put back too and counts what
|
|
244
|
+
* changed.
|
|
245
|
+
* - `collection_record.created`, `.updated`, `.deleted`, `.restored`: one
|
|
246
|
+
* record write; the entry names the collection, the record and its robot.
|
|
247
|
+
* - `collection_import.completed`: an import was carried out; the entry names
|
|
248
|
+
* the collection and the mode and counts the records created, updated and
|
|
249
|
+
* deleted.
|
|
250
|
+
* - `collection_history.purged`: an organization owner removed history older
|
|
251
|
+
* than a date; the entry names the date, the collection or the whole app,
|
|
252
|
+
* and how many revisions went. The actor is the owner.
|
|
253
|
+
*
|
|
254
|
+
* The strings are stable: filter the log with `action` or with
|
|
255
|
+
* `action_prefix` (`collection_record.`).
|
|
256
|
+
*/
|
|
257
|
+
export const COLLECTION_AUDIT_ACTIONS = [
|
|
258
|
+
'collection_schema.published',
|
|
259
|
+
'collection_schema.restored',
|
|
260
|
+
'collection_record.created',
|
|
261
|
+
'collection_record.updated',
|
|
262
|
+
'collection_record.deleted',
|
|
263
|
+
'collection_record.restored',
|
|
264
|
+
'collection_import.completed',
|
|
265
|
+
'collection_history.purged',
|
|
266
|
+
];
|