@fleetless/contracts 13.3.0 → 14.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.
Files changed (98) hide show
  1. package/CHANGELOG.md +141 -0
  2. package/artifacts/openapi.json +1983 -784
  3. package/artifacts/routes.json +224 -208
  4. package/artifacts/schema/access-warning.schema.json +51 -0
  5. package/artifacts/schema/action-config.schema.json +35 -0
  6. package/artifacts/schema/app-access-response.schema.json +136 -0
  7. package/artifacts/schema/app-access.schema.json +80 -0
  8. package/artifacts/schema/app-deletion-summary.schema.json +0 -7
  9. package/artifacts/schema/app-invitation-list-response.schema.json +13 -6
  10. package/artifacts/schema/app-invitation.schema.json +5 -5
  11. package/artifacts/schema/app-list-response.schema.json +6 -6
  12. package/artifacts/schema/app-lock.schema.json +30 -0
  13. package/artifacts/schema/app-user-list-response.schema.json +13 -6
  14. package/artifacts/schema/app-user.schema.json +13 -6
  15. package/artifacts/schema/app.schema.json +6 -6
  16. package/artifacts/schema/auth-ok.schema.json +20 -6
  17. package/artifacts/schema/camera-list-response.schema.json +1 -1
  18. package/artifacts/schema/client-identity.schema.json +21 -6
  19. package/artifacts/schema/cloud-config.schema.json +359 -5
  20. package/artifacts/schema/config-draft-response.schema.json +359 -5
  21. package/artifacts/schema/config-version-response.schema.json +359 -5
  22. package/artifacts/schema/create-app-invitation-request.schema.json +4 -4
  23. package/artifacts/schema/create-app-user-request.schema.json +4 -4
  24. package/artifacts/schema/create-org-role-request.schema.json +33 -0
  25. package/artifacts/schema/dangling-reference.schema.json +129 -0
  26. package/artifacts/schema/datapoint-config.schema.json +35 -0
  27. package/artifacts/schema/datapoint-list-response.schema.json +1 -1
  28. package/artifacts/schema/effective-capability.schema.json +104 -0
  29. package/artifacts/schema/effective-rights-query.schema.json +19 -0
  30. package/artifacts/schema/effective-rights-response.schema.json +310 -0
  31. package/artifacts/schema/effective-robot-rights.schema.json +266 -0
  32. package/artifacts/schema/invoke-or-service-response.schema.json +1 -1
  33. package/artifacts/schema/invoke-response.schema.json +1 -1
  34. package/artifacts/schema/journal-intent-v2-body.schema.json +74 -0
  35. package/artifacts/schema/journal-intent-v2.schema.json +84 -0
  36. package/artifacts/schema/journal-replay-receipt-body.schema.json +1 -0
  37. package/artifacts/schema/journal-replay-receipt.schema.json +1 -0
  38. package/artifacts/schema/mcp-robot-datasheet.schema.json +2 -2
  39. package/artifacts/schema/org-role-list-response.schema.json +205 -0
  40. package/artifacts/schema/org-role.schema.json +59 -0
  41. package/artifacts/schema/patch-app-user-request.schema.json +4 -4
  42. package/artifacts/schema/patch-org-role-request.schema.json +38 -0
  43. package/artifacts/schema/publish-config-response.schema.json +48 -1
  44. package/artifacts/schema/publisher-config.schema.json +35 -0
  45. package/artifacts/schema/put-role-defaults-request.schema.json +127 -0
  46. package/artifacts/schema/reference-place.schema.json +111 -0
  47. package/artifacts/schema/rename-slug-response.schema.json +4 -3
  48. package/artifacts/schema/robot-config-doc.schema.json +359 -5
  49. package/artifacts/schema/role-cycle-details.schema.json +18 -0
  50. package/artifacts/schema/role-defaults-response.schema.json +59 -0
  51. package/artifacts/schema/role-rename-preview.schema.json +146 -0
  52. package/artifacts/schema/service-config.schema.json +35 -0
  53. package/artifacts/schema/slug-usage-response.schema.json +4 -3
  54. package/artifacts/schema/update-app-request.schema.json +0 -12
  55. package/dist/app-users.d.ts +11 -8
  56. package/dist/app-users.js +18 -10
  57. package/dist/apps.d.ts +242 -71
  58. package/dist/apps.js +205 -151
  59. package/dist/audit.d.ts +3 -3
  60. package/dist/billing.d.ts +10 -10
  61. package/dist/client-auth.d.ts +5 -2
  62. package/dist/client-auth.js +11 -3
  63. package/dist/client-robots.d.ts +1 -1
  64. package/dist/client-robots.js +1 -1
  65. package/dist/common.d.ts +1 -1
  66. package/dist/common.js +1 -1
  67. package/dist/config-issues.d.ts +1 -1
  68. package/dist/config-issues.js +1 -1
  69. package/dist/config.d.ts +77 -11
  70. package/dist/config.js +108 -14
  71. package/dist/errors.d.ts +14 -5
  72. package/dist/errors.js +37 -24
  73. package/dist/index.d.ts +18 -8
  74. package/dist/index.js +14 -4
  75. package/dist/journal-intents.d.ts +30 -0
  76. package/dist/journal-intents.js +3 -0
  77. package/dist/legal-acceptances.d.ts +2 -2
  78. package/dist/mcp.d.ts +5 -37
  79. package/dist/mcp.js +4 -14
  80. package/dist/org-roles.d.ts +182 -0
  81. package/dist/org-roles.js +198 -0
  82. package/dist/plans.d.ts +6 -6
  83. package/dist/protocol.d.ts +19 -1
  84. package/dist/realtime.d.ts +6 -3
  85. package/dist/realtime.js +1 -1
  86. package/dist/rest.d.ts +76 -25
  87. package/dist/rest.js +41 -29
  88. package/dist/rights.d.ts +197 -0
  89. package/dist/rights.js +396 -0
  90. package/dist/routes.js +185 -134
  91. package/package.json +1 -1
  92. package/artifacts/schema/mcp-role-preview-response.schema.json +0 -134
  93. package/artifacts/schema/role-delete-query.schema.json +0 -13
  94. package/artifacts/schema/role-in-use-details.schema.json +0 -28
  95. package/artifacts/schema/role-list-response.schema.json +0 -48
  96. package/artifacts/schema/role-permissions.schema.json +0 -61
  97. package/artifacts/schema/role-rename-request.schema.json +0 -16
  98. package/artifacts/schema/role.schema.json +0 -35
package/dist/rest.js CHANGED
@@ -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({
@@ -333,7 +336,7 @@ 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 two built-ins, plus every datapoint the published configuration exposes and the caller\'s role grants.',
339
+ description: 'Everything a client may read on this robot: the two built-ins, plus every datapoint the published configuration exposes and the caller\'s role may read.',
337
340
  }),
338
341
  });
339
342
  /**
@@ -349,7 +352,7 @@ export const putRobotDetailsResponse = z.object({
349
352
  });
350
353
  export const putRobotDetailsRequest = z.object({ details: robotDetailsDoc });
351
354
  /* ------------------------------------------------------------------------
352
- * The command surface, and what a role may be granted.
355
+ * The command surface, and what a role may be required to use.
353
356
  *
354
357
  * The routes, written down because cloud, console and SDK each need them and
355
358
  * a body schema does not imply a path:
@@ -364,9 +367,9 @@ export const putRobotDetailsRequest = z.object({ details: robotDetailsDoc });
364
367
  * | `GET /api/robots/:id/exposures` | — | `exposureListResponse` |
365
368
  *
366
369
  * **Commands are addressed by slug, never by kind.** Slugs are one namespace
367
- * across all kinds and a role grant is `{robot, slug}` with no kind in
368
- * it — so a path segment naming the kind would demand a fact the permission
369
- * model deliberately does not carry. The cloud already knows from the
370
+ * across all kinds, and a requirement, a rule and a lock all name a slug
371
+ * with no kind in it — so a path segment naming the kind would demand a fact
372
+ * the rights model deliberately does not carry. The cloud already knows from the
370
373
  * published configuration whether a slug is an action or a service; a caller
371
374
  * who wants to know asks `/exposures`.
372
375
  *
@@ -488,7 +491,7 @@ export const invokeResponse = z.object({
488
491
  }),
489
492
  /** The slug's kind — see `commandResult.kind` for why the caller needs it. */
490
493
  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 a role grant which it invoked, so the answer says which it was rather than leaving it to be inferred from the shape.',
494
+ 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
495
  }),
493
496
  });
494
497
  /** A service call answers with its result directly — no job to observe. */
@@ -502,7 +505,7 @@ export const serviceCallResponse = z.object({
502
505
  * shapes.**
503
506
  *
504
507
  * One route serves both kinds, because a path segment naming the kind would
505
- * demand a fact a role grant does not carry. **The slug's kind decides, and
508
+ * demand a fact the rights model does not carry. **The slug's kind decides, and
506
509
  * nothing in the request does**: an *action* answers `202` with an
507
510
  * `invokeResponse` the moment the job exists, a *service* answers `200` with
508
511
  * a `serviceCallResponse` once the result is in. They differ only in what the
@@ -681,7 +684,7 @@ export const jobResponse = z.object({
681
684
  * audience the asset store exists for.
682
685
  *
683
686
  * So: a developer reaches the robot because it belongs to their org; an end
684
- * user reaches it when their role grants `assets`.
687
+ * user reaches it when their role satisfies the robot's `assets` requirement.
685
688
  *
686
689
  * **The rewritten mesh URIs in a served URDF are absolute, not
687
690
  * root-relative.** A relative URL resolves against *the consumer's* origin,
@@ -789,11 +792,12 @@ export const robotJobsResponse = z.object({
789
792
  }),
790
793
  });
791
794
  /**
792
- * Every slug of a robot that a role can be granted, **with its kind**.
795
+ * Every slug of a robot that a role can be required to use or an app can lock,
796
+ * **with its kind**.
793
797
  *
794
- * A roles matrix built against the datapoint list alone cannot grant an
795
- * action, a service or a publisher. One list that names every kind, with its
796
- * kind, is what a matrix needs.
798
+ * A rights view built against the datapoint list alone cannot show an action,
799
+ * a service or a publisher. One list that names every kind, with its kind, is
800
+ * what such a view needs.
797
801
  */
798
802
  export const exposure = z.object({
799
803
  slug,
@@ -930,7 +934,7 @@ export const cameraDescriptor = z.object({
930
934
  });
931
935
  export const cameraListResponse = z.object({
932
936
  cameras: z.array(cameraDescriptor).meta({
933
- description: 'Every camera the published configuration exposes on this robot **and** the caller\'s role grants. A developer sees all of them; an end user sees what their role allows.',
937
+ 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
938
  }),
935
939
  });
936
940
  /**
@@ -1619,11 +1623,12 @@ export const BRIDGE_LATENCY_RETENTION_DAYS = 7;
1619
1623
  * `GET /api/robots/:id/jobs/history`** — robot-scoped, one route for
1620
1624
  * developers and clients like every other robot-scoped read (`.../jobs`,
1621
1625
  * `.../assets`, `.../datapoints`), never a parallel `/api/client/…` twin. An
1622
- * end user reaches it only when their role's `capabilities.action_history`
1623
- * says so — otherwise `403 capability_required`, naming the capability — and
1624
- * sees only runs on slugs their role grants. On this route `?robot_id=` is
1625
- * not a filter: the path already names the robot, and a query naming a
1626
- * different one is refused rather than quietly answered about the path's.
1626
+ * end user reaches it only when their role satisfies the robot's
1627
+ * `job_history` requirement — otherwise `403 capability_required`, naming the
1628
+ * capability — and sees only runs on slugs their role may use. On this route
1629
+ * `?robot_id=` is not a filter: the path already names the robot, and a query
1630
+ * naming a different one is refused rather than quietly answered about the
1631
+ * path's.
1627
1632
  *
1628
1633
  * **It discloses the actor, and that is what a developer weighs before
1629
1634
  * granting the capability.** A `jobRun` names who invoked it — `jobActor`
@@ -1893,27 +1898,30 @@ export const orgUsageResponse = z.object({
1893
1898
  export const patchRobotRequest = z.object({ name: z.string().min(1).max(63) }).strict();
1894
1899
  /**
1895
1900
  * `POST /api/robots/:id/config/rename-slug` — atomic server-side rename:
1896
- * rewrites the **draft** config and every app-role grant carrying
1901
+ * rewrites the **draft** config and every app lock naming
1897
1902
  * `{robot_id, from}`, and moves the recorded history with the name, in one
1898
1903
  * transaction, without rewriting stored samples. Job runs and audit events
1899
1904
  * keep the old slug as historical fact. The published config is immutable,
1900
1905
  * so the caller must publish afterwards (`requires_publish`); samples the
1901
1906
  * robot sends under the old slug between the rename and the publish join the
1902
1907
  * renamed history.
1903
- * One residual remains in that same window: grants and the draft already name
1904
- * `to`, but the still-published config exposes only `from` until the
1905
- * publish lands — an end user's app has no working name for the datapoint
1906
- * at all for however long that gap lasts, since `to` isn't published yet
1907
- * and `from` no longer has a grant behind it. The console must publish
1908
- * immediately after a rename to keep this window short; nothing server-side
1909
- * closes it.
1908
+ *
1909
+ * **Locks follow the rename, and keep the old name.** A lock that lists
1910
+ * `from` lists `to` as well afterwards: until the publish lands, the
1911
+ * published config still exposes only `from`, and dropping it from the lock
1912
+ * would open the capability in that gap. Once the publish has landed, the old
1913
+ * name is an `unknown_lock_slug` warning in the app's access and is removed
1914
+ * with its next `PUT`. A rename that would push a lock past the most slugs
1915
+ * one lock can hold is refused and writes nothing.
1910
1916
  * This schema only enforces slug *shape*; whether `to` is reserved or
1911
1917
  * already in use on this robot is checked once, behind the cloud's
1912
1918
  * `validation.ts` door — one door, not a second copy of that rule here.
1913
1919
  */
1914
1920
  export const renameSlugRequest = z.object({ from: slug, to: slug }).strict();
1915
1921
  export const renameSlugResponse = z.object({
1916
- rewritten_grants: z.number().int().nonnegative(),
1922
+ rewritten_locks: z.number().int().nonnegative().meta({
1923
+ 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.',
1924
+ }),
1917
1925
  history_moved: z.boolean(),
1918
1926
  requires_publish: z.literal(true)
1919
1927
  });
@@ -1921,13 +1929,17 @@ export const renameSlugResponse = z.object({
1921
1929
  * `GET /api/robots/:id/config/slug-usage/:slug` — what a rename would touch;
1922
1930
  * feeds the console's confirm dialog.
1923
1931
  *
1924
- * `alert_count` is part of the atomic rename transaction alongside grants and
1932
+ * `alert_count` is part of the atomic rename transaction alongside locks and
1925
1933
  * history: alerts are keyed by `(robot_id, slug)` too, and a rename that
1926
1934
  * silently moved the alert row while the usage preview stayed silent about it
1927
1935
  * would show a developer a smaller blast radius than the rename actually has.
1936
+ * `lock_count` is the same promise for the locks: it counts every lock the
1937
+ * rename would rewrite.
1928
1938
  */
1929
1939
  export const slugUsageResponse = z.object({
1930
- grant_count: z.number().int().nonnegative(),
1940
+ lock_count: z.number().int().nonnegative().meta({
1941
+ 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.',
1942
+ }),
1931
1943
  app_identifiers: z.array(z.string()),
1932
1944
  has_recorded_history: z.boolean(),
1933
1945
  alert_count: z.number().int().nonnegative(),
@@ -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. Built-in datapoints are 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 datapoints are not entries.
196
+ */
197
+ export declare function roleIssues(doc: RobotConfigDoc | null, graph: RoleGraph): ValidationIssue[];