@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/rest.js
CHANGED
|
@@ -81,19 +81,19 @@ export const jointStatePutResponse = z.object({
|
|
|
81
81
|
* same call for the same reason: fold cameras in and the sentence "this deletes
|
|
82
82
|
* N slugs and M cameras" counts them twice. A list row has the same problem.
|
|
83
83
|
*
|
|
84
|
-
* **Counted from the published configuration, and excluding the built-
|
|
84
|
+
* **Counted from the published configuration, and excluding the built-in datapoint.**
|
|
85
85
|
* `GET /api/robots/:id/exposures` answers *which* slugs and prepends the
|
|
86
|
-
* built-in
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* The number was "three" while `bridge_pressure` existed and
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
86
|
+
* built-in datapoint, `bridge_state`, as `builtin: true`; this answers *how
|
|
87
|
+
* many* and counts only what somebody configured. So a robot with an empty
|
|
88
|
+
* published config reports `datapoints: 0` here and one entry there. That is
|
|
89
|
+
* intentional, and it is written on both sides so the disagreement is never
|
|
90
|
+
* mistaken for a bug.
|
|
91
|
+
*
|
|
92
|
+
* The number was "three" while `bridge_pressure` existed and has only gone
|
|
93
|
+
* down since; the cloud builds that prefix from its own built-in set rather
|
|
94
|
+
* than a literal, so the next built-in moves this count again. Read the count
|
|
95
|
+
* off that set, not off this sentence, before filing the bug this comment
|
|
96
|
+
* exists to prevent.
|
|
97
97
|
*/
|
|
98
98
|
export const exposureCounts = z.object({
|
|
99
99
|
datapoints: z.number().int().nonnegative(),
|
|
@@ -255,6 +255,9 @@ export const putConfigDraftRequest = z.object({ source: z.string().max(1_000_000
|
|
|
255
255
|
export const publishConfigResponse = z.object({
|
|
256
256
|
version: z.number().int().positive(),
|
|
257
257
|
published_at: z.iso.datetime(),
|
|
258
|
+
warnings: z.array(validationIssue).meta({
|
|
259
|
+
description: 'Every `warning` of the published document — an unknown topic, a role key that names no role of the organization, a rule that fits nothing. A warning never blocks a publish; it is here so the author does not have to go looking for it. `[]` for a document with none.',
|
|
260
|
+
}),
|
|
258
261
|
});
|
|
259
262
|
export const configVersionsResponse = z.object({
|
|
260
263
|
versions: z.array(z.object({
|
|
@@ -304,7 +307,7 @@ export const fetchTypesResponse = z.object({
|
|
|
304
307
|
unresolved: z.array(z.string()),
|
|
305
308
|
});
|
|
306
309
|
/**
|
|
307
|
-
* What a client can read on this robot: the built-
|
|
310
|
+
* What a client can read on this robot: the built-in plus everything the
|
|
308
311
|
* published configuration exposes. This is the seed of the generated
|
|
309
312
|
* per-robot API.
|
|
310
313
|
*
|
|
@@ -315,7 +318,7 @@ export const fetchTypesResponse = z.object({
|
|
|
315
318
|
export const datapointDescriptor = z.object({
|
|
316
319
|
slug: slug.meta({ description: 'The name a client reads this datapoint by.' }),
|
|
317
320
|
builtin: z.boolean().meta({
|
|
318
|
-
description: '`true` for the
|
|
321
|
+
description: '`true` for the datapoint every robot has, `bridge_state`, and `false` for everything the published configuration adds.',
|
|
319
322
|
}),
|
|
320
323
|
unit: z.string().nullable().meta({
|
|
321
324
|
description: 'The unit the value carries **after** any scale and offset, shown beside the number so nobody has to guess whether `15` means percent, volts or minutes. `null` when the configuration names none.',
|
|
@@ -333,23 +336,11 @@ export const datapointDescriptor = z.object({
|
|
|
333
336
|
});
|
|
334
337
|
export const datapointListResponse = z.object({
|
|
335
338
|
datapoints: z.array(datapointDescriptor).meta({
|
|
336
|
-
description: 'Everything a client may read on this robot: the
|
|
337
|
-
}),
|
|
338
|
-
});
|
|
339
|
-
/**
|
|
340
|
-
* The built-in `robot_details` datapoint: static properties the developer
|
|
341
|
-
* maintains. Bounded so one robot cannot become a document store.
|
|
342
|
-
*/
|
|
343
|
-
export const robotDetailsDoc = z.record(z.string().regex(/^[a-z][a-z0-9_-]{0,63}$/), z.union([z.string().max(4096), z.number(), z.boolean(), z.array(z.unknown()), z.record(z.string(), z.unknown())]));
|
|
344
|
-
/** What `PUT /api/robots/:id/details` answers: the stored document, which is the one that was sent. */
|
|
345
|
-
export const putRobotDetailsResponse = z.object({
|
|
346
|
-
details: robotDetailsDoc.meta({
|
|
347
|
-
description: 'The stored `robot_details` document, which is the one that was just sent — this route **replaces** the document rather than merging into it. Keys are the developer\'s own, lowercase and at most 64 characters; a value is a string of at most 4096 characters, a number, a boolean, an array or an object.',
|
|
339
|
+
description: 'Everything a client may read on this robot: the built-in `bridge_state`, plus every datapoint the published configuration exposes and the caller\'s role may read.',
|
|
348
340
|
}),
|
|
349
341
|
});
|
|
350
|
-
export const putRobotDetailsRequest = z.object({ details: robotDetailsDoc });
|
|
351
342
|
/* ------------------------------------------------------------------------
|
|
352
|
-
* The command surface, and what a role may be
|
|
343
|
+
* The command surface, and what a role may be required to use.
|
|
353
344
|
*
|
|
354
345
|
* The routes, written down because cloud, console and SDK each need them and
|
|
355
346
|
* a body schema does not imply a path:
|
|
@@ -364,9 +355,9 @@ export const putRobotDetailsRequest = z.object({ details: robotDetailsDoc });
|
|
|
364
355
|
* | `GET /api/robots/:id/exposures` | — | `exposureListResponse` |
|
|
365
356
|
*
|
|
366
357
|
* **Commands are addressed by slug, never by kind.** Slugs are one namespace
|
|
367
|
-
* across all kinds and a
|
|
368
|
-
* it — so a path segment naming the kind would demand a fact
|
|
369
|
-
* model deliberately does not carry. The cloud already knows from the
|
|
358
|
+
* across all kinds, and a requirement, a rule and a lock all name a slug
|
|
359
|
+
* with no kind in it — so a path segment naming the kind would demand a fact
|
|
360
|
+
* the rights model deliberately does not carry. The cloud already knows from the
|
|
370
361
|
* published configuration whether a slug is an action or a service; a caller
|
|
371
362
|
* who wants to know asks `/exposures`.
|
|
372
363
|
*
|
|
@@ -488,7 +479,7 @@ export const invokeResponse = z.object({
|
|
|
488
479
|
}),
|
|
489
480
|
/** The slug's kind — see `commandResult.kind` for why the caller needs it. */
|
|
490
481
|
kind: z.enum(['action', 'service']).meta({
|
|
491
|
-
description: 'Always `action` in this shape. A caller sends the same request for both kinds and cannot tell from
|
|
482
|
+
description: 'Always `action` in this shape. A caller sends the same request for both kinds and cannot tell from the slug alone which it invoked, so the answer says which it was rather than leaving it to be inferred from the shape.',
|
|
492
483
|
}),
|
|
493
484
|
});
|
|
494
485
|
/** A service call answers with its result directly — no job to observe. */
|
|
@@ -502,7 +493,7 @@ export const serviceCallResponse = z.object({
|
|
|
502
493
|
* shapes.**
|
|
503
494
|
*
|
|
504
495
|
* One route serves both kinds, because a path segment naming the kind would
|
|
505
|
-
* demand a fact
|
|
496
|
+
* demand a fact the rights model does not carry. **The slug's kind decides, and
|
|
506
497
|
* nothing in the request does**: an *action* answers `202` with an
|
|
507
498
|
* `invokeResponse` the moment the job exists, a *service* answers `200` with
|
|
508
499
|
* a `serviceCallResponse` once the result is in. They differ only in what the
|
|
@@ -681,7 +672,7 @@ export const jobResponse = z.object({
|
|
|
681
672
|
* audience the asset store exists for.
|
|
682
673
|
*
|
|
683
674
|
* So: a developer reaches the robot because it belongs to their org; an end
|
|
684
|
-
* user reaches it when their role
|
|
675
|
+
* user reaches it when their role satisfies the robot's `assets` requirement.
|
|
685
676
|
*
|
|
686
677
|
* **The rewritten mesh URIs in a served URDF are absolute, not
|
|
687
678
|
* root-relative.** A relative URL resolves against *the consumer's* origin,
|
|
@@ -789,11 +780,12 @@ export const robotJobsResponse = z.object({
|
|
|
789
780
|
}),
|
|
790
781
|
});
|
|
791
782
|
/**
|
|
792
|
-
* Every slug of a robot that a role can be
|
|
783
|
+
* Every slug of a robot that a role can be required to use or an app can lock,
|
|
784
|
+
* **with its kind**.
|
|
793
785
|
*
|
|
794
|
-
* A
|
|
795
|
-
*
|
|
796
|
-
*
|
|
786
|
+
* A rights view built against the datapoint list alone cannot show an action,
|
|
787
|
+
* a service or a publisher. One list that names every kind, with its kind, is
|
|
788
|
+
* what such a view needs.
|
|
797
789
|
*/
|
|
798
790
|
export const exposure = z.object({
|
|
799
791
|
slug,
|
|
@@ -930,7 +922,7 @@ export const cameraDescriptor = z.object({
|
|
|
930
922
|
});
|
|
931
923
|
export const cameraListResponse = z.object({
|
|
932
924
|
cameras: z.array(cameraDescriptor).meta({
|
|
933
|
-
description: 'Every camera the published configuration exposes on this robot **and** the caller\'s role
|
|
925
|
+
description: 'Every camera the published configuration exposes on this robot **and** the caller\'s role may use. A developer sees all of them; an end user sees what their role allows.',
|
|
934
926
|
}),
|
|
935
927
|
});
|
|
936
928
|
/**
|
|
@@ -1382,6 +1374,15 @@ export const robotDeletionSummary = z.object({
|
|
|
1382
1374
|
* was there at all.
|
|
1383
1375
|
*/
|
|
1384
1376
|
had_unpublished_draft: z.boolean(),
|
|
1377
|
+
collection_records: z
|
|
1378
|
+
.array(z.object({
|
|
1379
|
+
app_id: z.uuid().meta({ description: 'The app whose collections hold records of the robot.' }),
|
|
1380
|
+
app_name: z.string().meta({ description: 'The app\'s name.' }),
|
|
1381
|
+
records: z.number().int().nonnegative().meta({ description: 'How many records of the robot the app\'s collections hold, deleted with the robot.' }),
|
|
1382
|
+
}))
|
|
1383
|
+
.meta({
|
|
1384
|
+
description: 'App collection records that go with the robot, per app. A robot\'s records are kept in every app it was attached to, also in one it was detached from, and are deleted with their history when the robot is; apps without records of this robot are left out.',
|
|
1385
|
+
}),
|
|
1385
1386
|
});
|
|
1386
1387
|
/**
|
|
1387
1388
|
* The query of `DELETE /api/robots/:id`.
|
|
@@ -1551,6 +1552,12 @@ export const orgQuotas = z.object({
|
|
|
1551
1552
|
max_retention_bytes: z.number().int().nonnegative(),
|
|
1552
1553
|
max_retention_writes_per_minute: z.number().int().nonnegative(),
|
|
1553
1554
|
max_realtime_connections: z.number().int().positive(),
|
|
1555
|
+
collection_records: z.number().int().positive().nullable().meta({
|
|
1556
|
+
description: 'The most records the app collections of all the org\'s apps may hold together: the plan limit `collection_records`, or the operator\'s override of it. `null` is by contract (Enterprise).',
|
|
1557
|
+
}),
|
|
1558
|
+
collection_bytes: z.number().int().positive().nullable().meta({
|
|
1559
|
+
description: 'The most bytes the current records of the org\'s app collections may occupy together: the plan limit `collection_bytes`, or the operator\'s override of it. `null` is by contract (Enterprise).',
|
|
1560
|
+
}),
|
|
1554
1561
|
});
|
|
1555
1562
|
/**
|
|
1556
1563
|
* What an org is **actually using**, per quota.
|
|
@@ -1574,6 +1581,15 @@ export const orgQuotaUsageCounts = z.object({
|
|
|
1574
1581
|
max_retention_bytes: z.number().int().nonnegative(),
|
|
1575
1582
|
max_retention_writes_per_minute: z.number().int().nonnegative(),
|
|
1576
1583
|
max_realtime_connections: z.number().int().nonnegative(),
|
|
1584
|
+
collection_records: z.number().int().nonnegative().meta({
|
|
1585
|
+
description: 'Current records in the app collections of all the org\'s apps. Deleted records do not count.',
|
|
1586
|
+
}),
|
|
1587
|
+
collection_bytes: z.number().int().nonnegative().meta({
|
|
1588
|
+
description: 'Bytes the current records of the org\'s app collections occupy, as stored JSON.',
|
|
1589
|
+
}),
|
|
1590
|
+
collection_history_bytes: z.number().int().nonnegative().meta({
|
|
1591
|
+
description: 'Bytes the history of the org\'s app collections occupies: revisions of current and deleted records. Information only; no limit applies to it.',
|
|
1592
|
+
}),
|
|
1577
1593
|
}).partial();
|
|
1578
1594
|
/** Limits beside what is actually used — a limit alone tells nobody where they stand. */
|
|
1579
1595
|
export const orgQuotaUsage = z.object({ quotas: orgQuotas, usage: orgQuotaUsageCounts });
|
|
@@ -1619,11 +1635,12 @@ export const BRIDGE_LATENCY_RETENTION_DAYS = 7;
|
|
|
1619
1635
|
* `GET /api/robots/:id/jobs/history`** — robot-scoped, one route for
|
|
1620
1636
|
* developers and clients like every other robot-scoped read (`.../jobs`,
|
|
1621
1637
|
* `.../assets`, `.../datapoints`), never a parallel `/api/client/…` twin. An
|
|
1622
|
-
* end user reaches it only when their role's
|
|
1623
|
-
*
|
|
1624
|
-
* sees only runs on slugs their role
|
|
1625
|
-
* not a filter: the path already names the robot, and a query
|
|
1626
|
-
* different one is refused rather than quietly answered about the
|
|
1638
|
+
* end user reaches it only when their role satisfies the robot's
|
|
1639
|
+
* `job_history` requirement — otherwise `403 capability_required`, naming the
|
|
1640
|
+
* capability — and sees only runs on slugs their role may use. On this route
|
|
1641
|
+
* `?robot_id=` is not a filter: the path already names the robot, and a query
|
|
1642
|
+
* naming a different one is refused rather than quietly answered about the
|
|
1643
|
+
* path's.
|
|
1627
1644
|
*
|
|
1628
1645
|
* **It discloses the actor, and that is what a developer weighs before
|
|
1629
1646
|
* granting the capability.** A `jobRun` names who invoked it — `jobActor`
|
|
@@ -1893,27 +1910,30 @@ export const orgUsageResponse = z.object({
|
|
|
1893
1910
|
export const patchRobotRequest = z.object({ name: z.string().min(1).max(63) }).strict();
|
|
1894
1911
|
/**
|
|
1895
1912
|
* `POST /api/robots/:id/config/rename-slug` — atomic server-side rename:
|
|
1896
|
-
* rewrites the **draft** config and every app
|
|
1913
|
+
* rewrites the **draft** config and every app lock naming
|
|
1897
1914
|
* `{robot_id, from}`, and moves the recorded history with the name, in one
|
|
1898
1915
|
* transaction, without rewriting stored samples. Job runs and audit events
|
|
1899
1916
|
* keep the old slug as historical fact. The published config is immutable,
|
|
1900
1917
|
* so the caller must publish afterwards (`requires_publish`); samples the
|
|
1901
1918
|
* robot sends under the old slug between the rename and the publish join the
|
|
1902
1919
|
* renamed history.
|
|
1903
|
-
*
|
|
1904
|
-
*
|
|
1905
|
-
*
|
|
1906
|
-
*
|
|
1907
|
-
*
|
|
1908
|
-
*
|
|
1909
|
-
*
|
|
1920
|
+
*
|
|
1921
|
+
* **Locks follow the rename, and keep the old name.** A lock that lists
|
|
1922
|
+
* `from` lists `to` as well afterwards: until the publish lands, the
|
|
1923
|
+
* published config still exposes only `from`, and dropping it from the lock
|
|
1924
|
+
* would open the capability in that gap. Once the publish has landed, the old
|
|
1925
|
+
* name is an `unknown_lock_slug` warning in the app's access and is removed
|
|
1926
|
+
* with its next `PUT`. A rename that would push a lock past the most slugs
|
|
1927
|
+
* one lock can hold is refused and writes nothing.
|
|
1910
1928
|
* This schema only enforces slug *shape*; whether `to` is reserved or
|
|
1911
1929
|
* already in use on this robot is checked once, behind the cloud's
|
|
1912
1930
|
* `validation.ts` door — one door, not a second copy of that rule here.
|
|
1913
1931
|
*/
|
|
1914
1932
|
export const renameSlugRequest = z.object({ from: slug, to: slug }).strict();
|
|
1915
1933
|
export const renameSlugResponse = z.object({
|
|
1916
|
-
|
|
1934
|
+
rewritten_locks: z.number().int().nonnegative().meta({
|
|
1935
|
+
description: 'The app locks that listed the old slug and now list the new one as well. Locks follow a rename, in every app of the organization, so a renamed capability stays locked.',
|
|
1936
|
+
}),
|
|
1917
1937
|
history_moved: z.boolean(),
|
|
1918
1938
|
requires_publish: z.literal(true)
|
|
1919
1939
|
});
|
|
@@ -1921,13 +1941,17 @@ export const renameSlugResponse = z.object({
|
|
|
1921
1941
|
* `GET /api/robots/:id/config/slug-usage/:slug` — what a rename would touch;
|
|
1922
1942
|
* feeds the console's confirm dialog.
|
|
1923
1943
|
*
|
|
1924
|
-
* `alert_count` is part of the atomic rename transaction alongside
|
|
1944
|
+
* `alert_count` is part of the atomic rename transaction alongside locks and
|
|
1925
1945
|
* history: alerts are keyed by `(robot_id, slug)` too, and a rename that
|
|
1926
1946
|
* silently moved the alert row while the usage preview stayed silent about it
|
|
1927
1947
|
* would show a developer a smaller blast radius than the rename actually has.
|
|
1948
|
+
* `lock_count` is the same promise for the locks: it counts every lock the
|
|
1949
|
+
* rename would rewrite.
|
|
1928
1950
|
*/
|
|
1929
1951
|
export const slugUsageResponse = z.object({
|
|
1930
|
-
|
|
1952
|
+
lock_count: z.number().int().nonnegative().meta({
|
|
1953
|
+
description: 'The app locks that list this slug, which a rename would extend with the new name. The count is what the rename rewrites, in every app of the organization.',
|
|
1954
|
+
}),
|
|
1931
1955
|
app_identifiers: z.array(z.string()),
|
|
1932
1956
|
has_recorded_history: z.boolean(),
|
|
1933
1957
|
alert_count: z.number().int().nonnegative(),
|
package/dist/rights.d.ts
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import type { RobotConfigDoc, ValidationIssue } from './config.js';
|
|
4
|
+
import type { ExposureSection } from './config-issues.js';
|
|
5
|
+
/**
|
|
6
|
+
* Roles and the rights they resolve to — the part that has to be one piece of
|
|
7
|
+
* code for every layer that asks.
|
|
8
|
+
*
|
|
9
|
+
* A role is a key in the organization. Which role may use which capability of
|
|
10
|
+
* a robot is written in that robot's `fleetless.yaml` (`role` on an entry,
|
|
11
|
+
* `access.rules`, `access.assets`, `access.job_history`) and falls back to a
|
|
12
|
+
* default per kind that the organization sets. The cloud answers "may this
|
|
13
|
+
* caller do that?" from these functions, the console editor answers "what
|
|
14
|
+
* does this document say about roles?" from the same ones, and an assistant
|
|
15
|
+
* can read the same sentences back — a second implementation would be a
|
|
16
|
+
* second account of who may do what, which is the one thing that must not
|
|
17
|
+
* drift.
|
|
18
|
+
*
|
|
19
|
+
* **A leaf module on purpose.** It imports only types from `config.ts` and
|
|
20
|
+
* `config-issues.ts`, so `config.ts` can import the zod parts below (`roleRef`)
|
|
21
|
+
* without a cycle. Nothing here parses a document; every function takes one
|
|
22
|
+
* the caller has already validated, or `null` for none.
|
|
23
|
+
*
|
|
24
|
+
* **Lenient by construction.** A role key that names no role is never an
|
|
25
|
+
* error: it grants nothing, and `roleIssues` says so as a warning. Inheritance
|
|
26
|
+
* through a missing parent lapses; the role's other parents still count.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* A role key: lower-case, letter-initial, letters, digits and underscores, at
|
|
30
|
+
* most 63 characters. `defaults` is reserved: it is the path segment of the
|
|
31
|
+
* organization's defaults (`/api/org/roles/defaults`), and a role with that
|
|
32
|
+
* key would sit next to it. The rule is in the pattern, so the JSON Schema
|
|
33
|
+
* artifacts state it too.
|
|
34
|
+
*/
|
|
35
|
+
export declare const ROLE_KEY_PATTERN: RegExp;
|
|
36
|
+
export declare const ROLE_KEY_RULE = "A role key is lower-case: it starts with a letter and continues with letters, digits and underscores, up to 63 characters in all \u2014 `operate`, `night_shift`. A capital, a dash, a dot, a space or a leading digit is refused, and `defaults` is reserved.";
|
|
37
|
+
/** The most roles one organization holds, and the most keys a single `role` list names. */
|
|
38
|
+
export declare const MAX_ORG_ROLES = 50;
|
|
39
|
+
/** The longest display name of a role. */
|
|
40
|
+
export declare const ROLE_NAME_MAX = 60;
|
|
41
|
+
/**
|
|
42
|
+
* One role key. The sentence is both what the parser says and the
|
|
43
|
+
* `patternErrorMessage` of the exported JSON Schema: one rule, one wording.
|
|
44
|
+
*/
|
|
45
|
+
export declare const roleKey: z.ZodString;
|
|
46
|
+
export type RoleKey = z.infer<typeof roleKey>;
|
|
47
|
+
/**
|
|
48
|
+
* The value of a `role` in `fleetless.yaml`: one key, or a list of keys when
|
|
49
|
+
* several roles qualify. A list is non-empty — an empty one would say "nobody",
|
|
50
|
+
* which is what leaving the role out of every rule and default already does.
|
|
51
|
+
*/
|
|
52
|
+
export declare const roleRef: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
53
|
+
export type RoleRef = z.infer<typeof roleRef>;
|
|
54
|
+
/**
|
|
55
|
+
* The kinds of access a default or a lock can name. `read` covers datapoints
|
|
56
|
+
* and cameras, `invoke` services and actions, `publish` publishers (driving);
|
|
57
|
+
* `assets` and `job_history` belong to the robot as a whole.
|
|
58
|
+
*/
|
|
59
|
+
export declare const ACCESS_KINDS: readonly ["read", "invoke", "publish", "assets", "job_history"];
|
|
60
|
+
export type AccessKind = (typeof ACCESS_KINDS)[number];
|
|
61
|
+
export declare const accessKind: z.ZodEnum<{
|
|
62
|
+
read: "read";
|
|
63
|
+
invoke: "invoke";
|
|
64
|
+
publish: "publish";
|
|
65
|
+
assets: "assets";
|
|
66
|
+
job_history: "job_history";
|
|
67
|
+
}>;
|
|
68
|
+
/** The kinds an entry of `fleetless.yaml` has, and the only ones a rule can filter by. */
|
|
69
|
+
export declare const ENTRY_KINDS: readonly ["read", "invoke", "publish"];
|
|
70
|
+
export type EntryKind = (typeof ENTRY_KINDS)[number];
|
|
71
|
+
/** What a new organization starts with. Roles are ordinary rows from then on. */
|
|
72
|
+
export declare const SEED_ROLES: readonly {
|
|
73
|
+
key: string;
|
|
74
|
+
name: string;
|
|
75
|
+
inherits: readonly string[];
|
|
76
|
+
}[];
|
|
77
|
+
/** The defaults a new organization starts with: who holds each kind when a robot's document says nothing. */
|
|
78
|
+
export declare const SEED_DEFAULTS: Record<AccessKind, readonly string[]>;
|
|
79
|
+
/** One role as the resolver needs it. `inherits` may name keys that are no role; those lapse. */
|
|
80
|
+
export interface RoleNode {
|
|
81
|
+
name: string;
|
|
82
|
+
inherits: readonly string[];
|
|
83
|
+
}
|
|
84
|
+
/** The roles of one organization, by key. */
|
|
85
|
+
export type RoleGraph = ReadonlyMap<string, RoleNode>;
|
|
86
|
+
/** The organization's default per kind. A missing kind, or an empty list, means nobody holds it. */
|
|
87
|
+
export type RoleDefaults = Partial<Record<AccessKind, readonly string[]>>;
|
|
88
|
+
/**
|
|
89
|
+
* The key and every role it inherits from, transitively. Parents that are no
|
|
90
|
+
* role are skipped, and so is whatever only they would have led to. `[]` for a
|
|
91
|
+
* key that is no role. A cycle in the graph ends the walk; each key appears once.
|
|
92
|
+
*/
|
|
93
|
+
export declare function roleClosure(graph: RoleGraph, key: string): string[];
|
|
94
|
+
/**
|
|
95
|
+
* Whether the held role meets a requirement: it, or any role it inherits from,
|
|
96
|
+
* is named. `via` is the required key that was met when that is not the held
|
|
97
|
+
* role itself, so a caller can say "admin, through operate": `null` when the
|
|
98
|
+
* held role is named, otherwise the nearest required ancestor, in the order
|
|
99
|
+
* `roleClosure` walks (the parents of the held role first, and in the order it
|
|
100
|
+
* lists them), whatever the order of `required`. `unknown` lists the required
|
|
101
|
+
* keys that are no role — they were skipped, not failed.
|
|
102
|
+
*
|
|
103
|
+
* A held role that is unknown or `null`, and an empty requirement, never
|
|
104
|
+
* satisfy: nobody holds what nobody was given.
|
|
105
|
+
*/
|
|
106
|
+
export declare function roleSatisfies(graph: RoleGraph, held: string | null, required: readonly string[]): {
|
|
107
|
+
satisfied: boolean;
|
|
108
|
+
via: string | null;
|
|
109
|
+
unknown: string[];
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* The cycle that giving `key` these parents would create, as `[key, …, key]`,
|
|
113
|
+
* or `null`. The graph is taken as it is with that one edit applied, so it
|
|
114
|
+
* answers for a role that does not exist yet as well. Cycles that do not pass
|
|
115
|
+
* through `key` are not its doing and are ignored.
|
|
116
|
+
*/
|
|
117
|
+
export declare function findCycle(graph: RoleGraph, key: string, inherits: readonly string[]): string[] | null;
|
|
118
|
+
/**
|
|
119
|
+
* Whether an absolute match pattern fits an absolute ROS name. A segment of
|
|
120
|
+
* `*` is any one segment; a segment of `**` is any number of segments, none
|
|
121
|
+
* included, so `/arm/**` fits `/arm` as well as `/arm/home`; `*` inside a
|
|
122
|
+
* segment (`/joint_*`) stands for any characters of that segment. Anything
|
|
123
|
+
* relative, with an empty segment or with a trailing slash fits nothing.
|
|
124
|
+
*/
|
|
125
|
+
export declare function matchRosGlob(pattern: string, rosName: string): boolean;
|
|
126
|
+
/** One exposed entry of a document, as the rights resolver sees it. The built-in datapoint, `bridge_state`, is not listed. */
|
|
127
|
+
export interface ExposureRef {
|
|
128
|
+
slug: string;
|
|
129
|
+
section: ExposureSection;
|
|
130
|
+
kind: EntryKind;
|
|
131
|
+
rosName: string | null;
|
|
132
|
+
}
|
|
133
|
+
/** Every exposed entry of the document, section by section in the order of `EXPOSURE_SECTIONS`. `[]` for no document. */
|
|
134
|
+
export declare function listExposures(doc: RobotConfigDoc | null): ExposureRef[];
|
|
135
|
+
/** Where a requirement came from. `index` is the rule's position in `access.rules`, counted from zero. */
|
|
136
|
+
export type RequirementSource = {
|
|
137
|
+
kind: 'entry';
|
|
138
|
+
} | {
|
|
139
|
+
kind: 'rule';
|
|
140
|
+
index: number;
|
|
141
|
+
match: string;
|
|
142
|
+
} | {
|
|
143
|
+
kind: 'robot';
|
|
144
|
+
} | {
|
|
145
|
+
kind: 'org_default';
|
|
146
|
+
};
|
|
147
|
+
/** Who may use something: any role that holds, or inherits, one of `roles`. */
|
|
148
|
+
export interface Requirement {
|
|
149
|
+
roles: string[];
|
|
150
|
+
source: RequirementSource;
|
|
151
|
+
}
|
|
152
|
+
/** What a requirement is asked about: an exposed entry by its slug, or a capability of the robot as a whole. */
|
|
153
|
+
export type RightsTarget = {
|
|
154
|
+
slug: string;
|
|
155
|
+
} | {
|
|
156
|
+
capability: 'assets' | 'job_history';
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* What a robot's published document, with the organization's defaults, asks of
|
|
160
|
+
* a caller for one target.
|
|
161
|
+
*
|
|
162
|
+
* For an entry: its own `role`, else the first `access.rules` rule that fits
|
|
163
|
+
* (by ROS name, and by kind when the rule names kinds), else the default of its
|
|
164
|
+
* kind. For `assets` and `job_history`: `access.<capability>` of the document,
|
|
165
|
+
* else the default. A kind with no default asks for nobody (`roles: []`).
|
|
166
|
+
*
|
|
167
|
+
* `null` when the document has no entry of that slug — including no document
|
|
168
|
+
* at all, which has no entries. A capability always has a requirement.
|
|
169
|
+
*/
|
|
170
|
+
export declare function requirementOf(doc: RobotConfigDoc | null, defaults: RoleDefaults, target: RightsTarget): Requirement | null;
|
|
171
|
+
/**
|
|
172
|
+
* One role key a document names, and where. `path` is the field in the form
|
|
173
|
+
* `formatPath` writes: `services.arm_home.role`, `access.rules[1].role`,
|
|
174
|
+
* `access.assets`. A list gives one reference per key, each at its own index —
|
|
175
|
+
* `services.arm_home.role[1]` — so a reader can point at the key itself.
|
|
176
|
+
* `slug` is the entry for a reference on an entry, `null` otherwise.
|
|
177
|
+
*/
|
|
178
|
+
export interface RoleRefUse {
|
|
179
|
+
key: string;
|
|
180
|
+
path: string;
|
|
181
|
+
slug: string | null;
|
|
182
|
+
}
|
|
183
|
+
/** Every role key the document names: on entries, in rules, and on `access.assets` and `access.job_history`. */
|
|
184
|
+
export declare function collectRoleRefs(doc: RobotConfigDoc | null): RoleRefUse[];
|
|
185
|
+
/**
|
|
186
|
+
* The warnings a document earns against the organization's roles. Never an
|
|
187
|
+
* error: both are published as they are, and the sentences are the ones the
|
|
188
|
+
* cloud answers and the editor shows.
|
|
189
|
+
*
|
|
190
|
+
* - `unknown_role`: a key that is no role of the organization. It grants
|
|
191
|
+
* nothing, and neither does inheritance through it.
|
|
192
|
+
* - `rule_matches_nothing`: an `access.rules` rule that fits no exposed entry
|
|
193
|
+
* of this document, so it changes nothing. A rule's `kinds` are honoured,
|
|
194
|
+
* and an entry without a ROS name — a camera that is not a ROS topic — is
|
|
195
|
+
* never matched. The built-in datapoint, `bridge_state`, is not an entry.
|
|
196
|
+
*/
|
|
197
|
+
export declare function roleIssues(doc: RobotConfigDoc | null, graph: RoleGraph): ValidationIssue[];
|