@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.
package/CHANGELOG.md CHANGED
@@ -9,6 +9,34 @@ version.
9
9
 
10
10
  ## [Unreleased]
11
11
 
12
+ ### Added
13
+
14
+ - **The operator's admin API (fleetless/fleetless#268).** `RouteAuth`
15
+ gains `operator`: a short-lived EdDSA-signed assertion naming the acting
16
+ person and their roles (`operatorRole`: `operator-admin`,
17
+ `operator-finance`, `operator-support`), carried as
18
+ `Authorization: Operator <jwt>` and verified against
19
+ `operatorAssertionClaims`. Every `auth: 'operator'` route is
20
+ `audience: 'internal'` and carries a `RouteEntry.operator` block (roles,
21
+ and a `confirmationLevel` on a command), looked up by `operatorAccess`
22
+ and written into `routes.json` as `operator`.
23
+ - **The command protocol.** `operatorCommandRequest`/`operatorCommandResponse`
24
+ describe a preview-reason-execute cycle: a `preview` mode answering
25
+ `operatorPreview` and a token, an `execute` mode taking a `reason`, that
26
+ token and an `idempotency_key`, and a result carrying `operatorAuditRef`.
27
+ `409 preview_stale` carries a fresh preview in `previewStaleDetails`.
28
+ The no-op command (`POST /api/admin/commands/noop`,
29
+ `noopCommandRequest`/`noopCommandResponse`) proves the protocol without
30
+ changing anything.
31
+ - **Search and org reads.** `GET /api/admin/search`
32
+ (`adminSearchQuery`/`adminSearchResponse`, hit kinds org, person, invoice,
33
+ payment, robot), `GET /api/admin/orgs/:id` (`adminOrgDetail`) and
34
+ `GET /api/admin/orgs/:id/usage`, identical to the developer's own usage
35
+ read for the named org.
36
+ - **Two error codes**: `preview_stale` (409, an execute's preview is no
37
+ longer current) and `idempotency_key_reused` (409, the key was already
38
+ used for a different command, input or operator).
39
+
12
40
  ## [6.3.0] — 2026-10-05
13
41
 
14
42
  ### Added
package/CONTRIBUTING.md CHANGED
@@ -72,10 +72,10 @@ developer machine path or a first-name attribution.
72
72
  an issue first — so we can say what else has to move with it.
73
73
 
74
74
  **CI runs on GitHub Actions**, in this repository
75
- (`.github/workflows/verify.yml`) — the suite, on every push and every pull
76
- request. `release.yml` (the **Release** button) calls that same file on the
77
- commit it publishes, so a release is never checked by a different pipeline
78
- than a push.
75
+ (`.github/workflows/verify.yml`) — the suite, on every pull request and
76
+ every push to `main`. `release.yml` (the **Release** button) calls that same
77
+ file on the commit it publishes, so a release is never checked by a different
78
+ pipeline than a push.
79
79
 
80
80
  **Your pull request is verified, a fork's included** — the same file, the
81
81
  same suite. The first run by a first-time contributor waits for a maintainer
@@ -6475,6 +6475,139 @@
6475
6475
  "transport": "http",
6476
6476
  "notes": "Every public host answers `404 not_found` for every `/api/admin/*` path — this route is reachable only on the cloud's private address — and that same address answers `404` here too while `OPS_API_TOKEN` is not configured, so a door with no key behind it reads exactly like one nobody opened. An unknown `:id` is the same `404`. Applies at once, never queued as a `pending_change`, and only when the org's current usage fits the result: `409 plan_limit` when a lower plan, a lowered override or a removed add-on would leave the org over a limit — the operator never deletes an org's things, only the owner's own choice does. On success it also withdraws any `pending_change`, ends a beta org's wait for the switch and lifts a lock. Audited as `org.plan_changed` with the `fleetless` actor, never a developer's — the row names what an operator did, not who in the org asked for it. `409 target_state_conflict` names `currency` or `period_ends_at` with rule `billed` when the org has a billing account in `active` or `past_due` and the request names either field: both are fixed at the first payment and billing, not the operator, 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 charged from the next renewal, except `enterprise` and `basic`, which the sweep cancels the billing account for instead."
6477
6477
  },
6478
+ {
6479
+ "method": "POST",
6480
+ "path": "/api/admin/commands/noop",
6481
+ "section": "org",
6482
+ "summary": "Runs the no-op command: proves the preview-reason-execute protocol without changing anything.",
6483
+ "audience": "internal",
6484
+ "auth": "operator",
6485
+ "rateLimited": true,
6486
+ "ownerTier": false,
6487
+ "status": 200,
6488
+ "params": [],
6489
+ "query": null,
6490
+ "request": "noop-command-request",
6491
+ "response": "noop-command-response",
6492
+ "errors": [
6493
+ "unauthorized",
6494
+ "forbidden",
6495
+ "not_found",
6496
+ "validation_error",
6497
+ "preview_stale",
6498
+ "idempotency_key_reused",
6499
+ "rate_limited"
6500
+ ],
6501
+ "transport": "http",
6502
+ "notes": "Reachable only where the cloud enables it (`OPERATOR_NOOP_COMMAND=true`; refused in production). Proves the command path end to end without a real effect: a preview always answers one `keeps` effect, and an execute writes the operator audit plus an `operator.noop` row in the named org's audit, and nothing else. Every public host, and the private address while the operator API is not enabled, answers `404 not_found` for this path like any other unregistered one. A role the route does not list is refused with `403 forbidden`: a command says no where a read stays silent.",
6503
+ "operator": {
6504
+ "roles": [
6505
+ "operator-admin",
6506
+ "operator-finance",
6507
+ "operator-support"
6508
+ ],
6509
+ "confirmation": "click"
6510
+ }
6511
+ },
6512
+ {
6513
+ "method": "GET",
6514
+ "path": "/api/admin/search",
6515
+ "section": "org",
6516
+ "summary": "Finds an org, person, invoice, payment or robot by a literal, case-insensitive match.",
6517
+ "audience": "internal",
6518
+ "auth": "operator",
6519
+ "rateLimited": true,
6520
+ "ownerTier": false,
6521
+ "status": 200,
6522
+ "params": [],
6523
+ "query": "admin-search-query",
6524
+ "request": null,
6525
+ "response": "admin-search-response",
6526
+ "errors": [
6527
+ "unauthorized",
6528
+ "not_found",
6529
+ "validation_error",
6530
+ "rate_limited"
6531
+ ],
6532
+ "transport": "http",
6533
+ "notes": "`q` is matched literally — `%`, `_` and `\\` carry no wildcard meaning — never as an `ILIKE` pattern, so a two-character query never dumps a table. At most `ADMIN_SEARCH_LIMIT` hits come back; `truncated` says whether more exist. A hit kind the caller's role may not see is left out rather than refused: `operator-support` gets no `invoice` or `payment` hits. Every public host, and the private address while the operator API is not enabled, answers `404 not_found` for this path. A role the route does not list gets that same `404 not_found`, so a read never reveals that it exists.",
6534
+ "operator": {
6535
+ "roles": [
6536
+ "operator-admin",
6537
+ "operator-finance",
6538
+ "operator-support"
6539
+ ]
6540
+ }
6541
+ },
6542
+ {
6543
+ "method": "GET",
6544
+ "path": "/api/admin/orgs/:id",
6545
+ "section": "org",
6546
+ "summary": "Reads an org's detail as the operator: its owner, plan, billing state and counts.",
6547
+ "audience": "internal",
6548
+ "auth": "operator",
6549
+ "rateLimited": true,
6550
+ "ownerTier": false,
6551
+ "status": 200,
6552
+ "params": [
6553
+ {
6554
+ "name": "id",
6555
+ "description": "The org's uuid, whose detail the operator is reading."
6556
+ }
6557
+ ],
6558
+ "query": null,
6559
+ "request": null,
6560
+ "response": "admin-org-detail",
6561
+ "errors": [
6562
+ "unauthorized",
6563
+ "not_found",
6564
+ "rate_limited"
6565
+ ],
6566
+ "transport": "http",
6567
+ "notes": "`billing` carries the account's state and next charge only — never the payer, address or payment method. An unknown `:id` is `404 not_found`, the same every public host and the private address answer for 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 never reveals that it exists.",
6568
+ "operator": {
6569
+ "roles": [
6570
+ "operator-admin",
6571
+ "operator-finance",
6572
+ "operator-support"
6573
+ ]
6574
+ }
6575
+ },
6576
+ {
6577
+ "method": "GET",
6578
+ "path": "/api/admin/orgs/:id/usage",
6579
+ "section": "org",
6580
+ "summary": "Reads what an org consumed per day, per app and per metric, as the operator.",
6581
+ "audience": "internal",
6582
+ "auth": "operator",
6583
+ "rateLimited": true,
6584
+ "ownerTier": false,
6585
+ "status": 200,
6586
+ "params": [
6587
+ {
6588
+ "name": "id",
6589
+ "description": "The org's uuid, whose usage the operator is reading."
6590
+ }
6591
+ ],
6592
+ "query": "org-usage-query",
6593
+ "request": null,
6594
+ "response": "org-usage-response",
6595
+ "errors": [
6596
+ "unauthorized",
6597
+ "not_found",
6598
+ "validation_error",
6599
+ "rate_limited"
6600
+ ],
6601
+ "transport": "http",
6602
+ "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 the same echoed window. An unknown `:id` is `404 not_found`, the same every public host and the private address answer for 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 never reveals that it exists.",
6603
+ "operator": {
6604
+ "roles": [
6605
+ "operator-admin",
6606
+ "operator-finance",
6607
+ "operator-support"
6608
+ ]
6609
+ }
6610
+ },
6478
6611
  {
6479
6612
  "method": "GET",
6480
6613
  "path": "/api/billing",