@fleetless/contracts 6.3.0 → 6.4.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,51 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ import { z } from 'zod';
3
+ import { OPERATOR_REASON_MAX_LENGTH, OPERATOR_REASON_MIN_LENGTH } from './operator.js';
4
+ /**
5
+ * One line of a command's preview (fleetless/fleetless#268): `changes`
6
+ * moves a value from `from` to `to`, `triggers` sets something off (a mail,
7
+ * a refund, a document), `keeps` states that something explicitly stays as
8
+ * it is.
9
+ */
10
+ export const previewEffect = z.object({
11
+ kind: z.enum(['changes', 'triggers', 'keeps']).meta({ description: '`changes`: a value moves from `from` to `to`. `triggers`: something is set off (a mail, a refund, a document). `keeps`: something explicitly stays as it is.' }),
12
+ label: z.string().min(1).max(300),
13
+ from: z.string().max(300).nullable().optional(),
14
+ to: z.string().max(300).nullable().optional(),
15
+ amount_cents: z.number().int().optional(),
16
+ });
17
+ /** What a command's preview answers before an execute: at least one effect. */
18
+ export const operatorPreview = z.object({ effects: z.array(previewEffect).min(1).max(50) });
19
+ const reason = z.string().trim().min(OPERATOR_REASON_MIN_LENGTH).max(OPERATOR_REASON_MAX_LENGTH);
20
+ /**
21
+ * The request body of an operator command, parameterised over its own
22
+ * input shape: a `preview` that only reads, or an `execute` that carries the
23
+ * reason, the preview it confirms and a replay key (fleetless/fleetless#268).
24
+ */
25
+ export function operatorCommandRequest(input) {
26
+ return z.discriminatedUnion('mode', [
27
+ z.object({ mode: z.literal('preview'), input }),
28
+ z.object({ mode: z.literal('execute'), input, reason, preview_token: z.string().min(1).max(512), idempotency_key: z.uuid() }),
29
+ ]);
30
+ }
31
+ /** The audit rows a command's execute wrote: the operator audit always, the org's audit when the command named one. */
32
+ export const operatorAuditRef = z.object({ operator_audit: z.uuid(), org_audit: z.uuid().nullable() });
33
+ /**
34
+ * The response of an operator command, parameterised over its preview and
35
+ * result shapes: a preview mode answers `preview` and a token to confirm it
36
+ * with; an execute answers `result` and the audit rows it wrote.
37
+ */
38
+ export function operatorCommandResponse(preview, result) {
39
+ return z.union([
40
+ z.object({ preview, preview_token: z.string().min(1) }),
41
+ z.object({ result, audit_ref: operatorAuditRef }),
42
+ ]);
43
+ }
44
+ /** `409 preview_stale`'s `details`: a fresh preview and its token, to confirm instead. */
45
+ export const previewStaleDetails = z.object({ preview: operatorPreview, preview_token: z.string().min(1) });
46
+ /** The no-op command's input: the org whose audit the row proves the protocol against. */
47
+ export const noopCommandInput = z.object({ org_id: z.uuid() });
48
+ /** The no-op command's result: it changes nothing, always. */
49
+ export const noopCommandResult = z.object({ changed: z.literal(false) });
50
+ export const noopCommandRequest = operatorCommandRequest(noopCommandInput);
51
+ export const noopCommandResponse = operatorCommandResponse(operatorPreview, noopCommandResult);
@@ -0,0 +1,63 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ import { z } from 'zod';
3
+ /**
4
+ * The three roles an operator assertion may name (fleetless/fleetless#268). The
5
+ * cloud looks up which of them a route needs from `RouteEntry.operator`;
6
+ * a role not listed here makes an assertion malformed (`401`).
7
+ */
8
+ export declare const OPERATOR_ROLES: readonly ["operator-admin", "operator-finance", "operator-support"];
9
+ export declare const operatorRole: z.ZodEnum<{
10
+ "operator-admin": "operator-admin";
11
+ "operator-finance": "operator-finance";
12
+ "operator-support": "operator-support";
13
+ }>;
14
+ export type OperatorRole = z.infer<typeof operatorRole>;
15
+ /**
16
+ * How the operator app confirms a command's execute (fleetless/fleetless#268).
17
+ * Set only on command routes, never on a read.
18
+ */
19
+ export declare const CONFIRMATION_LEVELS: readonly ["click", "second_click", "type_to_confirm"];
20
+ export declare const confirmationLevel: z.ZodEnum<{
21
+ click: "click";
22
+ second_click: "second_click";
23
+ type_to_confirm: "type_to_confirm";
24
+ }>;
25
+ export type ConfirmationLevel = z.infer<typeof confirmationLevel>;
26
+ /** The operator assertion's `iss` claim; the cloud refuses any other issuer. */
27
+ export declare const OPERATOR_ASSERTION_ISSUER = "fleetless-operator";
28
+ /** The `Authorization` header scheme the assertion is sent with: `Authorization: Operator <jwt>`. */
29
+ export declare const OPERATOR_AUTH_SCHEME = "Operator";
30
+ /** The longest `exp - iat` the cloud accepts; a longer-lived assertion is malformed (`401`). */
31
+ export declare const OPERATOR_ASSERTION_MAX_LIFETIME_SECONDS = 60;
32
+ /** How far into the future `iat` may lie before the cloud refuses it as malformed (`401`). */
33
+ export declare const OPERATOR_ASSERTION_MAX_FUTURE_SKEW_SECONDS = 30;
34
+ /** How long a `jti` is remembered to refuse a replay, in the cloud process's memory. */
35
+ export declare const OPERATOR_ASSERTION_REPLAY_WINDOW_SECONDS = 120;
36
+ /** The shortest `reason` a command execute may send, after trimming. */
37
+ export declare const OPERATOR_REASON_MIN_LENGTH = 10;
38
+ /** The longest `reason` a command execute may send. */
39
+ export declare const OPERATOR_REASON_MAX_LENGTH = 2000;
40
+ /** How long a preview token stays valid before an execute against it answers `409 preview_stale`. */
41
+ export declare const OPERATOR_PREVIEW_MAX_AGE_MS: number;
42
+ /**
43
+ * The claims of an operator assertion (fleetless/fleetless#268): an EdDSA JWT
44
+ * naming the acting person and their roles. The cloud verifies the
45
+ * signature against `OPERATOR_ASSERTION_KEYS` and this shape against the
46
+ * claims before trusting any of it.
47
+ */
48
+ export declare const operatorAssertionClaims: z.ZodObject<{
49
+ iss: z.ZodLiteral<"fleetless-operator">;
50
+ aud: z.ZodString;
51
+ sub: z.ZodString;
52
+ name: z.ZodString;
53
+ email: z.ZodEmail;
54
+ roles: z.ZodArray<z.ZodEnum<{
55
+ "operator-admin": "operator-admin";
56
+ "operator-finance": "operator-finance";
57
+ "operator-support": "operator-support";
58
+ }>>;
59
+ iat: z.ZodNumber;
60
+ exp: z.ZodNumber;
61
+ jti: z.ZodString;
62
+ }, z.core.$strip>;
63
+ export type OperatorAssertionClaims = z.infer<typeof operatorAssertionClaims>;
@@ -0,0 +1,48 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ import { z } from 'zod';
3
+ /**
4
+ * The three roles an operator assertion may name (fleetless/fleetless#268). The
5
+ * cloud looks up which of them a route needs from `RouteEntry.operator`;
6
+ * a role not listed here makes an assertion malformed (`401`).
7
+ */
8
+ export const OPERATOR_ROLES = ['operator-admin', 'operator-finance', 'operator-support'];
9
+ export const operatorRole = z.enum(OPERATOR_ROLES);
10
+ /**
11
+ * How the operator app confirms a command's execute (fleetless/fleetless#268).
12
+ * Set only on command routes, never on a read.
13
+ */
14
+ export const CONFIRMATION_LEVELS = ['click', 'second_click', 'type_to_confirm'];
15
+ export const confirmationLevel = z.enum(CONFIRMATION_LEVELS);
16
+ /** The operator assertion's `iss` claim; the cloud refuses any other issuer. */
17
+ export const OPERATOR_ASSERTION_ISSUER = 'fleetless-operator';
18
+ /** The `Authorization` header scheme the assertion is sent with: `Authorization: Operator <jwt>`. */
19
+ export const OPERATOR_AUTH_SCHEME = 'Operator';
20
+ /** The longest `exp - iat` the cloud accepts; a longer-lived assertion is malformed (`401`). */
21
+ export const OPERATOR_ASSERTION_MAX_LIFETIME_SECONDS = 60;
22
+ /** How far into the future `iat` may lie before the cloud refuses it as malformed (`401`). */
23
+ export const OPERATOR_ASSERTION_MAX_FUTURE_SKEW_SECONDS = 30;
24
+ /** How long a `jti` is remembered to refuse a replay, in the cloud process's memory. */
25
+ export const OPERATOR_ASSERTION_REPLAY_WINDOW_SECONDS = 120;
26
+ /** The shortest `reason` a command execute may send, after trimming. */
27
+ export const OPERATOR_REASON_MIN_LENGTH = 10;
28
+ /** The longest `reason` a command execute may send. */
29
+ export const OPERATOR_REASON_MAX_LENGTH = 2000;
30
+ /** How long a preview token stays valid before an execute against it answers `409 preview_stale`. */
31
+ export const OPERATOR_PREVIEW_MAX_AGE_MS = 10 * 60 * 1000;
32
+ /**
33
+ * The claims of an operator assertion (fleetless/fleetless#268): an EdDSA JWT
34
+ * naming the acting person and their roles. The cloud verifies the
35
+ * signature against `OPERATOR_ASSERTION_KEYS` and this shape against the
36
+ * claims before trusting any of it.
37
+ */
38
+ export const operatorAssertionClaims = z.object({
39
+ iss: z.literal(OPERATOR_ASSERTION_ISSUER),
40
+ aud: z.string().min(1),
41
+ sub: z.string().min(1).max(200),
42
+ name: z.string().min(1).max(200),
43
+ email: z.email().max(320),
44
+ roles: z.array(operatorRole).max(OPERATOR_ROLES.length),
45
+ iat: z.number().int(),
46
+ exp: z.number().int(),
47
+ jti: z.string().min(16).max(128),
48
+ });
package/dist/plans.d.ts CHANGED
@@ -28,9 +28,9 @@ export declare const PLAN_ORDER: readonly PlanId[];
28
28
  * off the same catalogue row.
29
29
  */
30
30
  export declare const planLimitKey: z.ZodEnum<{
31
- apps: "apps";
32
31
  seats: "seats";
33
32
  robots: "robots";
33
+ apps: "apps";
34
34
  app_users: "app_users";
35
35
  live_video_ms_per_month: "live_video_ms_per_month";
36
36
  asset_bytes_per_robot: "asset_bytes_per_robot";
@@ -58,9 +58,9 @@ export type PlanLimits = z.infer<typeof planLimits>;
58
58
  * may be bought at all — `pro` and `enterprise`).
59
59
  */
60
60
  export declare const planFeature: z.ZodEnum<{
61
- require_two_factor: "require_two_factor";
62
- two_factor: "two_factor";
63
61
  app_mcp: "app_mcp";
62
+ two_factor: "two_factor";
63
+ require_two_factor: "require_two_factor";
64
64
  app_oidc: "app_oidc";
65
65
  hosted_logo: "hosted_logo";
66
66
  audit_export: "audit_export";
@@ -68,9 +68,9 @@ export declare const planFeature: z.ZodEnum<{
68
68
  }>;
69
69
  export type PlanFeature = z.infer<typeof planFeature>;
70
70
  export declare const planFeatures: z.ZodObject<{
71
- require_two_factor: z.ZodBoolean;
72
- two_factor: z.ZodBoolean;
73
71
  app_mcp: z.ZodBoolean;
72
+ two_factor: z.ZodBoolean;
73
+ require_two_factor: z.ZodBoolean;
74
74
  app_oidc: z.ZodBoolean;
75
75
  hosted_logo: z.ZodBoolean;
76
76
  audit_export: z.ZodBoolean;
@@ -85,8 +85,8 @@ export declare const planPrices: z.ZodObject<{
85
85
  }, z.core.$strip>;
86
86
  export type PlanPrices = z.infer<typeof planPrices>;
87
87
  export declare const planSupport: z.ZodEnum<{
88
- email: "email";
89
88
  community: "community";
89
+ email: "email";
90
90
  priority: "priority";
91
91
  named_contact: "named_contact";
92
92
  }>;
@@ -110,9 +110,9 @@ export declare const planCatalogueEntry: z.ZodObject<{
110
110
  audit_days: z.ZodNullable<z.ZodNumber>;
111
111
  }, z.core.$strip>;
112
112
  features: z.ZodObject<{
113
- require_two_factor: z.ZodBoolean;
114
- two_factor: z.ZodBoolean;
115
113
  app_mcp: z.ZodBoolean;
114
+ two_factor: z.ZodBoolean;
115
+ require_two_factor: z.ZodBoolean;
116
116
  app_oidc: z.ZodBoolean;
117
117
  hosted_logo: z.ZodBoolean;
118
118
  audit_export: z.ZodBoolean;
@@ -125,8 +125,8 @@ export declare const planCatalogueEntry: z.ZodObject<{
125
125
  usd_year: z.ZodNumber;
126
126
  }, z.core.$strip>>;
127
127
  support: z.ZodEnum<{
128
- email: "email";
129
128
  community: "community";
129
+ email: "email";
130
130
  priority: "priority";
131
131
  named_contact: "named_contact";
132
132
  }>;
@@ -138,25 +138,25 @@ export type PlanCatalogueEntry = z.infer<typeof planCatalogueEntry>;
138
138
  * buy them (`planFeature.addons`: `pro` and `enterprise`).
139
139
  */
140
140
  export declare const addonKey: z.ZodEnum<{
141
- apps: "apps";
142
141
  seats: "seats";
143
142
  robots: "robots";
143
+ apps: "apps";
144
144
  app_user_packs: "app_user_packs";
145
145
  live_video_packs: "live_video_packs";
146
146
  }>;
147
147
  export type AddonKey = z.infer<typeof addonKey>;
148
148
  export declare const addonCatalogueEntry: z.ZodObject<{
149
149
  key: z.ZodEnum<{
150
- apps: "apps";
151
150
  seats: "seats";
152
151
  robots: "robots";
152
+ apps: "apps";
153
153
  app_user_packs: "app_user_packs";
154
154
  live_video_packs: "live_video_packs";
155
155
  }>;
156
156
  raises: z.ZodEnum<{
157
- apps: "apps";
158
157
  seats: "seats";
159
158
  robots: "robots";
159
+ apps: "apps";
160
160
  app_users: "app_users";
161
161
  live_video_ms_per_month: "live_video_ms_per_month";
162
162
  asset_bytes_per_robot: "asset_bytes_per_robot";
@@ -367,9 +367,9 @@ export declare const orgPlan: z.ZodObject<{
367
367
  audit_days: z.ZodNullable<z.ZodNumber>;
368
368
  }, z.core.$strip>;
369
369
  features: z.ZodObject<{
370
- require_two_factor: z.ZodBoolean;
371
- two_factor: z.ZodBoolean;
372
370
  app_mcp: z.ZodBoolean;
371
+ two_factor: z.ZodBoolean;
372
+ require_two_factor: z.ZodBoolean;
373
373
  app_oidc: z.ZodBoolean;
374
374
  hosted_logo: z.ZodBoolean;
375
375
  audit_export: z.ZodBoolean;
@@ -454,9 +454,9 @@ export type PlanChangeRequest = z.infer<typeof planChangeRequest>;
454
454
  * optional — omitted and `null` are two different instructions.
455
455
  */
456
456
  export declare const planOverrides: z.ZodObject<{
457
- apps: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
458
457
  seats: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
459
458
  robots: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
459
+ apps: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
460
460
  app_users: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
461
461
  live_video_ms_per_month: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
462
462
  asset_bytes_per_robot: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
@@ -489,9 +489,9 @@ export declare const adminPlanChangeRequest: z.ZodObject<{
489
489
  live_video_packs: z.ZodOptional<z.ZodNumber>;
490
490
  }, z.core.$strict>>;
491
491
  overrides: z.ZodOptional<z.ZodObject<{
492
- apps: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
493
492
  seats: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
494
493
  robots: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
494
+ apps: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
495
495
  app_users: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
496
496
  live_video_ms_per_month: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
497
497
  asset_bytes_per_robot: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
package/dist/routes.d.ts CHANGED
@@ -28,13 +28,17 @@
28
28
  */
29
29
  import type { ZodType } from 'zod';
30
30
  import type { ErrorCode } from './errors.js';
31
+ import type { ConfirmationLevel, OperatorRole } from './operator.js';
31
32
  export type RouteMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
32
33
  export type RouteAudience = 'developer' | 'client' | 'internal';
33
34
  /**
34
35
  * `ops` (2026-10-02, fleetless/fleetless#103): a bearer token the operator
35
36
  * holds (`OPS_API_TOKEN`); never reachable through a public host.
37
+ *
38
+ * `operator` (fleetless/fleetless#268): a short-lived assertion naming the
39
+ * acting person and their roles; the roles a route needs are in `operator`.
36
40
  */
37
- export type RouteAuth = 'developer' | 'developer_or_client' | 'none' | 'robot_upload' | 'in_handler' | 'ops';
41
+ export type RouteAuth = 'developer' | 'developer_or_client' | 'none' | 'robot_upload' | 'in_handler' | 'ops' | 'operator';
38
42
  export type RouteTransport = 'http' | 'websocket';
39
43
  export type RouteSection = 'health' | 'developer-auth' | 'client-auth' | 'org' | 'billing' | 'users' | 'apps' | 'robots' | 'config' | 'alerts' | 'commands' | 'cameras' | 'assets' | 'mcp' | 'transports';
40
44
  export interface RouteParam {
@@ -42,6 +46,13 @@ export interface RouteParam {
42
46
  /** One sentence: what the segment identifies and where a caller gets it. */
43
47
  readonly description: string;
44
48
  }
49
+ /** Set exactly when `auth` is `operator` (fleetless/fleetless#268). */
50
+ export interface RouteOperatorAccess {
51
+ /** The roles that may call this route (fleetless/fleetless#268). Never empty. */
52
+ readonly roles: readonly OperatorRole[];
53
+ /** Set on command routes only: how the operator app confirms an execute. */
54
+ readonly confirmation?: ConfirmationLevel;
55
+ }
45
56
  export interface RouteEntry {
46
57
  readonly method: RouteMethod;
47
58
  /** The display path with `:name` params and no inline regex. */
@@ -89,6 +100,8 @@ export interface RouteEntry {
89
100
  readonly transport: RouteTransport;
90
101
  /** Markdown rendered under the route; the place for what the schema cannot say. */
91
102
  readonly notes?: string;
103
+ /** Set exactly when `auth` is `operator`. */
104
+ readonly operator?: RouteOperatorAccess;
92
105
  }
93
106
  export declare const ROUTE_SECTIONS: readonly {
94
107
  readonly id: RouteSection;
@@ -123,3 +136,9 @@ export declare const IN_HANDLER_ROUTES: readonly string[];
123
136
  */
124
137
  export declare function developerSignInRoutes(prefix: '/console/oauth' | '/mcp/oauth'): RouteEntry[];
125
138
  export declare const ROUTES: readonly RouteEntry[];
139
+ /**
140
+ * The roles (and, for a command, the confirmation level) a caller of this
141
+ * operator route needs, looked up by method and path (fleetless/fleetless#268).
142
+ * Throws for a route that is not `auth: 'operator'`.
143
+ */
144
+ export declare function operatorAccess(method: RouteMethod, path: string): RouteOperatorAccess;
package/dist/routes.js CHANGED
@@ -12,6 +12,9 @@ import { jobRunListResponse, jobRunQuery, jobRunSummary, jobRunSummaryQuery } fr
12
12
  import { MCP_APP_PATHS, mcpRobotDatasheet, mcpRolePreviewResponse } from './mcp.js';
13
13
  import { authorizationServerMetadata, dynamicClientRegistrationRequest, dynamicClientRegistrationResponse, oauthAuthorizeQuery, oauthRedirectResponse, oauthTokenRequest, oauthTokenResponse, protectedResourceMetadata, } from './oauth.js';
14
14
  import { adminPlanChangeRequest, orgPlan, planChangeRequest } from './plans.js';
15
+ import { OPERATOR_ROLES } from './operator.js';
16
+ import { noopCommandRequest, noopCommandResponse } from './operator-commands.js';
17
+ import { adminSearchQuery, adminSearchResponse, adminOrgDetail } from './admin.js';
15
18
  import { billingCancelRequest, billingChangeRequest, billingChangeResponse, billingDetailsUpdate, billingView, checkoutRequest, checkoutResponse, checkoutStatus, paymentMethodChangeRequest, vatIdCheckRequest, vatIdCheckResponse, } from './billing.js';
16
19
  import { cameraListResponse, cancelRequest, configDraftResponse, configVersionResponse, configVersionsResponse, createRobotRequest, createRobotResponse, datapointListResponse, datapointValue, exposureListResponse, fetchTypesRequest, fetchTypesResponse, historyQuery, historyResponse, introspectionResponse, invokeOrServiceResponse, invokeRequest, jobResponse, liveSessionResponse, orgHealthQuery, orgLatencyQuery, orgLatencyResponse, orgQuotaUsage, orgUsageQuery, orgUsageResponse, patchRobotRequest, patchRobotResponse, publishConfigResponse, publishRequest, putConfigDraftRequest, putRobotDetailsRequest, putRobotDetailsResponse, robotTokenRotateResponse, jointStatePutRequest, jointStatePutResponse, releaseLiveQuery, renameSlugRequest, renameSlugResponse, robotDeleteQuery, resourceHealthListResponse, robotDeletionSummary, robotDetailResponse, robotJobsResponse, robotListResponse, slugUsageResponse, snapshotMetaResponse, typesResponse, } from './rest.js';
17
20
  export const ROUTE_SECTIONS = [
@@ -2866,6 +2869,65 @@ export const ROUTES = [
2866
2869
  'owns them from then on. The plan itself keeps working on a billed org — a plan, an add-on or an override the operator sets here is ' +
2867
2870
  'charged from the next renewal, except `enterprise` and `basic`, which the sweep cancels the billing account for instead.',
2868
2871
  },
2872
+ /* --- operator admin API (fleetless/fleetless#268) -----------------------
2873
+ *
2874
+ * Every route below is `audience: 'internal'`, `section: 'org'` and
2875
+ * reachable only on the cloud's private admin listener, behind the
2876
+ * operator gate: with it off, each answers exactly what an unregistered
2877
+ * path answers, even for a perfectly valid assertion.
2878
+ */
2879
+ {
2880
+ method: 'POST', path: '/api/admin/commands/noop', section: 'org',
2881
+ summary: 'Runs the no-op command: proves the preview-reason-execute protocol without changing anything.',
2882
+ audience: 'internal', auth: 'operator', rateLimited: true, ownerTier: false, status: 200,
2883
+ operator: { roles: OPERATOR_ROLES, confirmation: 'click' },
2884
+ params: [], query: null, request: noopCommandRequest, response: noopCommandResponse,
2885
+ errors: ['unauthorized', 'forbidden', 'not_found', 'validation_error', 'preview_stale', 'idempotency_key_reused', 'rate_limited'],
2886
+ transport: 'http',
2887
+ notes: 'Reachable only where the cloud enables it (`OPERATOR_NOOP_COMMAND=true`; refused in production). Proves the command path end to ' +
2888
+ 'end without a real effect: a preview always answers one `keeps` effect, and an execute writes the operator audit plus an ' +
2889
+ '`operator.noop` row in the named org\'s audit, and nothing else. Every public host, and the private address while the operator ' +
2890
+ 'API is not enabled, answers `404 not_found` for this path like any other unregistered one. A role the route does not list is ' +
2891
+ 'refused with `403 forbidden`: a command says no where a read stays silent.',
2892
+ },
2893
+ {
2894
+ method: 'GET', path: '/api/admin/search', section: 'org',
2895
+ summary: 'Finds an org, person, invoice, payment or robot by a literal, case-insensitive match.',
2896
+ audience: 'internal', auth: 'operator', rateLimited: true, ownerTier: false, status: 200,
2897
+ operator: { roles: OPERATOR_ROLES },
2898
+ params: [], query: adminSearchQuery, request: null, response: adminSearchResponse,
2899
+ errors: ['unauthorized', 'not_found', 'validation_error', 'rate_limited'], transport: 'http',
2900
+ notes: '`q` is matched literally — `%`, `_` and `\\` carry no wildcard meaning — never as an `ILIKE` pattern, so a two-character query ' +
2901
+ 'never dumps a table. At most `ADMIN_SEARCH_LIMIT` hits come back; `truncated` says whether more exist. A hit kind the caller\'s ' +
2902
+ 'role may not see is left out rather than refused: `operator-support` gets no `invoice` or `payment` hits. Every public host, and ' +
2903
+ 'the private address while the operator API is not enabled, answers `404 not_found` for this path. A role the route does not ' +
2904
+ 'list gets that same `404 not_found`, so a read never reveals that it exists.',
2905
+ },
2906
+ {
2907
+ method: 'GET', path: '/api/admin/orgs/:id', section: 'org',
2908
+ summary: "Reads an org's detail as the operator: its owner, plan, billing state and counts.",
2909
+ audience: 'internal', auth: 'operator', rateLimited: true, ownerTier: false, status: 200,
2910
+ operator: { roles: OPERATOR_ROLES },
2911
+ params: [{ name: 'id', description: "The org's uuid, whose detail the operator is reading." }],
2912
+ query: null, request: null, response: adminOrgDetail,
2913
+ errors: ['unauthorized', 'not_found', 'rate_limited'], transport: 'http',
2914
+ notes: '`billing` carries the account\'s state and next charge only — never the payer, address or payment method. An unknown `:id` is ' +
2915
+ '`404 not_found`, the same every public host and the private address answer for this path while the operator API is not ' +
2916
+ 'enabled. A role the route does not list gets that same `404 not_found`, so a read never reveals that it exists.',
2917
+ },
2918
+ {
2919
+ method: 'GET', path: '/api/admin/orgs/:id/usage', section: 'org',
2920
+ summary: "Reads what an org consumed per day, per app and per metric, as the operator.",
2921
+ audience: 'internal', auth: 'operator', rateLimited: true, ownerTier: false, status: 200,
2922
+ operator: { roles: OPERATOR_ROLES },
2923
+ params: [{ name: 'id', description: "The org's uuid, whose usage the operator is reading." }],
2924
+ query: orgUsageQuery, request: null, response: orgUsageResponse,
2925
+ errors: ['unauthorized', 'not_found', 'validation_error', 'rate_limited'], transport: 'http',
2926
+ notes: "Identical to `GET /api/org/usage` for the named org: the same window rule, the same `from_day <= to_day` cross-field check, and " +
2927
+ 'the same echoed window. An unknown `:id` is `404 not_found`, the same every public host and the private address answer for ' +
2928
+ 'this path while the operator API is not enabled. A role the route does not list gets that same `404 not_found`, so a read ' +
2929
+ 'never reveals that it exists.',
2930
+ },
2869
2931
  /* --- billing (2026-10-04, fleetless/fleetless#104) ----------------------
2870
2932
  *
2871
2933
  * Every route here but the webhook is owner-only (`ownerTier: true`), a
@@ -3074,3 +3136,16 @@ export const ROUTES = [
3074
3136
  notes: 'Authentication happens in the first frame, not on the upgrade. The frame types are the `realtime` schemas.',
3075
3137
  },
3076
3138
  ];
3139
+ /** Every `auth: 'operator'` route, keyed `METHOD path`, for `operatorAccess`. */
3140
+ const OPERATOR_ACCESS = new Map(ROUTES.filter((r) => r.auth === 'operator').map((r) => [`${r.method} ${r.path}`, r.operator]));
3141
+ /**
3142
+ * The roles (and, for a command, the confirmation level) a caller of this
3143
+ * operator route needs, looked up by method and path (fleetless/fleetless#268).
3144
+ * Throws for a route that is not `auth: 'operator'`.
3145
+ */
3146
+ export function operatorAccess(method, path) {
3147
+ const access = OPERATOR_ACCESS.get(`${method} ${path}`);
3148
+ if (!access)
3149
+ throw new Error(`${method} ${path} is not an operator route`);
3150
+ return access;
3151
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fleetless/contracts",
3
- "version": "6.3.0",
3
+ "version": "6.4.0-next.1",
4
4
  "description": "Fleetless wire contracts: the bridge-cloud protocol, the REST API schemas and the error codes, as zod schemas with generated JSON Schema and OpenAPI artifacts.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Dehne Robotik GmbH",