@fleetless/contracts 6.3.0-next.3 → 6.3.0-next.5

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 (32) hide show
  1. package/CHANGELOG.md +9 -42
  2. package/artifacts/openapi.json +1841 -4344
  3. package/artifacts/routes.json +5 -330
  4. package/dist/errors.d.ts +5 -17
  5. package/dist/errors.js +6 -31
  6. package/dist/index.d.ts +2 -4
  7. package/dist/index.js +1 -5
  8. package/dist/plans.d.ts +9 -9
  9. package/dist/realtime.d.ts +2 -2
  10. package/dist/rest.d.ts +11 -10
  11. package/dist/rest.js +8 -7
  12. package/dist/routes.d.ts +1 -1
  13. package/dist/routes.js +12 -194
  14. package/package.json +1 -1
  15. package/artifacts/schema/billing-address.schema.json +0 -49
  16. package/artifacts/schema/billing-cancel-request.schema.json +0 -12
  17. package/artifacts/schema/billing-change-request.schema.json +0 -60
  18. package/artifacts/schema/billing-change-response.schema.json +0 -799
  19. package/artifacts/schema/billing-details-update.schema.json +0 -25
  20. package/artifacts/schema/billing-details.schema.json +0 -176
  21. package/artifacts/schema/billing-invoice.schema.json +0 -76
  22. package/artifacts/schema/billing-view.schema.json +0 -705
  23. package/artifacts/schema/checkout-request.schema.json +0 -252
  24. package/artifacts/schema/checkout-response.schema.json +0 -22
  25. package/artifacts/schema/checkout-status.schema.json +0 -49
  26. package/artifacts/schema/payment-method-change-request.schema.json +0 -19
  27. package/artifacts/schema/payment-method.schema.json +0 -86
  28. package/artifacts/schema/payment-provider-unavailable-details.schema.json +0 -29
  29. package/artifacts/schema/vat-id-check-request.schema.json +0 -22
  30. package/artifacts/schema/vat-id-check-response.schema.json +0 -36
  31. package/dist/billing.d.ts +0 -812
  32. package/dist/billing.js +0 -462
@@ -260,13 +260,13 @@ export type DatapointEvent = z.infer<typeof datapointEvent>;
260
260
  */
261
261
  export declare const liveSessionEndReason: z.ZodEnum<{
262
262
  unknown: "unknown";
263
- expired: "expired";
264
263
  plan_limit: "plan_limit";
265
264
  publish_failed: "publish_failed";
266
265
  robot_offline: "robot_offline";
267
266
  config_changed: "config_changed";
268
267
  released_by_peer: "released_by_peer";
269
268
  revoked: "revoked";
269
+ expired: "expired";
270
270
  robot_deleted: "robot_deleted";
271
271
  }>;
272
272
  export type LiveSessionEndReason = z.infer<typeof liveSessionEndReason>;
@@ -292,13 +292,13 @@ export declare const liveSessionEvent: z.ZodObject<{
292
292
  state: z.ZodLiteral<"ended">;
293
293
  reason: z.ZodEnum<{
294
294
  unknown: "unknown";
295
- expired: "expired";
296
295
  plan_limit: "plan_limit";
297
296
  publish_failed: "publish_failed";
298
297
  robot_offline: "robot_offline";
299
298
  config_changed: "config_changed";
300
299
  released_by_peer: "released_by_peer";
301
300
  revoked: "revoked";
301
+ expired: "expired";
302
302
  robot_deleted: "robot_deleted";
303
303
  }>;
304
304
  detail: z.ZodNullable<z.ZodString>;
package/dist/rest.d.ts CHANGED
@@ -1847,10 +1847,10 @@ export declare const USAGE_WINDOW_MAX_DAYS = 366;
1847
1847
  * told to look at the wrong thing.
1848
1848
  */
1849
1849
  export declare const usageMetric: z.ZodEnum<{
1850
- asset_bytes: "asset_bytes";
1851
1850
  api_calls: "api_calls";
1852
1851
  live_session_ms: "live_session_ms";
1853
1852
  retention_bytes: "retention_bytes";
1853
+ asset_bytes: "asset_bytes";
1854
1854
  robot_online_ms: "robot_online_ms";
1855
1855
  }>;
1856
1856
  export type UsageMetric = z.infer<typeof usageMetric>;
@@ -1970,10 +1970,10 @@ export declare const usageRow: z.ZodObject<{
1970
1970
  app_id: z.ZodNullable<z.ZodUUID>;
1971
1971
  app_name: z.ZodNullable<z.ZodString>;
1972
1972
  metric: z.ZodEnum<{
1973
- asset_bytes: "asset_bytes";
1974
1973
  api_calls: "api_calls";
1975
1974
  live_session_ms: "live_session_ms";
1976
1975
  retention_bytes: "retention_bytes";
1976
+ asset_bytes: "asset_bytes";
1977
1977
  robot_online_ms: "robot_online_ms";
1978
1978
  }>;
1979
1979
  day: z.ZodString;
@@ -1986,10 +1986,10 @@ export declare const orgUsageResponse: z.ZodObject<{
1986
1986
  app_id: z.ZodNullable<z.ZodUUID>;
1987
1987
  app_name: z.ZodNullable<z.ZodString>;
1988
1988
  metric: z.ZodEnum<{
1989
- asset_bytes: "asset_bytes";
1990
1989
  api_calls: "api_calls";
1991
1990
  live_session_ms: "live_session_ms";
1992
1991
  retention_bytes: "retention_bytes";
1992
+ asset_bytes: "asset_bytes";
1993
1993
  robot_online_ms: "robot_online_ms";
1994
1994
  }>;
1995
1995
  day: z.ZodString;
@@ -2006,13 +2006,14 @@ export declare const patchRobotRequest: z.ZodObject<{
2006
2006
  export type PatchRobotRequest = z.infer<typeof patchRobotRequest>;
2007
2007
  /**
2008
2008
  * `POST /api/robots/:id/config/rename-slug` — atomic server-side rename:
2009
- * rewrites the **draft** config, every app-role grant carrying
2010
- * `{robot_id, from}`, and the recorded history rows, in one transaction.
2011
- * Job runs and audit events keep the old slug as historical fact. The
2012
- * published config is immutable, so the caller must publish afterwards
2013
- * (`requires_publish`); samples arriving between rename and the applied
2014
- * publish still land under the old slug — named residual, not migrated.
2015
- * Second residual in that same window: grants and the draft already name
2009
+ * rewrites the **draft** config and every app-role grant carrying
2010
+ * `{robot_id, from}`, and moves the recorded history with the name, in one
2011
+ * transaction, without rewriting stored samples. Job runs and audit events
2012
+ * keep the old slug as historical fact. The published config is immutable,
2013
+ * so the caller must publish afterwards (`requires_publish`); samples the
2014
+ * robot sends under the old slug between the rename and the publish join the
2015
+ * renamed history.
2016
+ * One residual remains in that same window: grants and the draft already name
2016
2017
  * `to`, but the still-published config exposes only `from` until the
2017
2018
  * publish lands — an end user's app has no working name for the datapoint
2018
2019
  * at all for however long that gap lasts, since `to` isn't published yet
package/dist/rest.js CHANGED
@@ -1852,13 +1852,14 @@ export const orgUsageResponse = z.object({
1852
1852
  export const patchRobotRequest = z.object({ name: z.string().min(1).max(63) }).strict();
1853
1853
  /**
1854
1854
  * `POST /api/robots/:id/config/rename-slug` — atomic server-side rename:
1855
- * rewrites the **draft** config, every app-role grant carrying
1856
- * `{robot_id, from}`, and the recorded history rows, in one transaction.
1857
- * Job runs and audit events keep the old slug as historical fact. The
1858
- * published config is immutable, so the caller must publish afterwards
1859
- * (`requires_publish`); samples arriving between rename and the applied
1860
- * publish still land under the old slug — named residual, not migrated.
1861
- * Second residual in that same window: grants and the draft already name
1855
+ * rewrites the **draft** config and every app-role grant carrying
1856
+ * `{robot_id, from}`, and moves the recorded history with the name, in one
1857
+ * transaction, without rewriting stored samples. Job runs and audit events
1858
+ * keep the old slug as historical fact. The published config is immutable,
1859
+ * so the caller must publish afterwards (`requires_publish`); samples the
1860
+ * robot sends under the old slug between the rename and the publish join the
1861
+ * renamed history.
1862
+ * One residual remains in that same window: grants and the draft already name
1862
1863
  * `to`, but the still-published config exposes only `from` until the
1863
1864
  * publish lands — an end user's app has no working name for the datapoint
1864
1865
  * at all for however long that gap lasts, since `to` isn't published yet
package/dist/routes.d.ts CHANGED
@@ -36,7 +36,7 @@ export type RouteAudience = 'developer' | 'client' | 'internal';
36
36
  */
37
37
  export type RouteAuth = 'developer' | 'developer_or_client' | 'none' | 'robot_upload' | 'in_handler' | 'ops';
38
38
  export type RouteTransport = 'http' | 'websocket';
39
- export type RouteSection = 'health' | 'developer-auth' | 'client-auth' | 'org' | 'billing' | 'users' | 'apps' | 'robots' | 'config' | 'alerts' | 'commands' | 'cameras' | 'assets' | 'mcp' | 'transports';
39
+ export type RouteSection = 'health' | 'developer-auth' | 'client-auth' | 'org' | 'users' | 'apps' | 'robots' | 'config' | 'alerts' | 'commands' | 'cameras' | 'assets' | 'mcp' | 'transports';
40
40
  export interface RouteParam {
41
41
  readonly name: string;
42
42
  /** One sentence: what the segment identifies and where a caller gets it. */
package/dist/routes.js CHANGED
@@ -12,14 +12,12 @@ 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 { billingCancelRequest, billingChangeRequest, billingChangeResponse, billingDetailsUpdate, billingView, checkoutRequest, checkoutResponse, checkoutStatus, paymentMethodChangeRequest, vatIdCheckRequest, vatIdCheckResponse, } from './billing.js';
16
15
  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
16
  export const ROUTE_SECTIONS = [
18
17
  { id: 'health', title: 'Health' },
19
18
  { id: 'developer-auth', title: 'Developer auth' },
20
19
  { id: 'client-auth', title: 'App-user (client) auth' },
21
20
  { id: 'org', title: 'Org' },
22
- { id: 'billing', title: 'Billing' },
23
21
  { id: 'users', title: 'Team' },
24
22
  { id: 'apps', title: 'Apps' },
25
23
  { id: 'robots', title: 'Robots' },
@@ -94,17 +92,6 @@ export const IN_HANDLER_ROUTES = [
94
92
  * than an undocumented one: a consumer branches on it and the branch is dead.
95
93
  */
96
94
  const DEVELOPER_GUARD = ['unauthorized', 'token_expired', 'token_revoked'];
97
- /**
98
- * The billing section's shorthand for the two refusals that come from
99
- * billing's own infrastructure rather than from what the caller sent
100
- * (2026-10-04, fleetless/fleetless#104): `BILLING_OFF` is no payment
101
- * provider configured at all, `MOLLIE` is Mollie itself not
102
- * answering. Every billing route that charges or opens a Mollie checkout
103
- * lists both; a route that only reads or edits local state lists neither,
104
- * and answers normally without a key.
105
- */
106
- const BILLING_OFF = ['billing_unavailable'];
107
- const MOLLIE = ['payment_provider_unavailable'];
108
95
  /**
109
96
  * The same, for `auth: 'developer_or_client'` — one guard resolving a developer
110
97
  * bearer, an end-user bearer **or** a server key through a single token lookup.
@@ -2324,17 +2311,20 @@ export const ROUTES = [
2324
2311
  },
2325
2312
  {
2326
2313
  method: 'POST', path: '/api/robots/:id/config/rename-slug', section: 'config',
2327
- summary: 'Renames a slug in the draft and rewrites every role grant and history row that named it.',
2314
+ summary: 'Renames a slug in the draft and moves every role grant and the recorded history with the name.',
2328
2315
  audience: 'developer', auth: 'developer', rateLimited: false, ownerTier: false, status: 200,
2329
2316
  params: [{ name: 'id', description: 'The robot\'s uuid, as returned by `POST /api/robots` or listed by `GET /api/robots`.' }],
2330
2317
  query: null, request: renameSlugRequest, response: renameSlugResponse,
2331
2318
  errors: [
2332
2319
  ...DEVELOPER_GUARD, 'invalid_uuid', 'not_found', 'validation_error', 'draft_not_a_document',
2333
- 'unknown_slug', 'reserved_slug', 'duplicate_slug', 'internal_error',
2320
+ 'unknown_slug', 'reserved_slug', 'duplicate_slug', 'history_migrating', 'internal_error',
2334
2321
  ], transport: 'http',
2335
- notes: 'One transaction over three places a slug is written down: the draft document, every app-role grant carrying it, and the recorded ' +
2336
- 'history rows. The published configuration is immutable, so `requires_publish` says the rename is not live on the robot yet. A draft ' +
2337
- 'that is not a document is `409 draft_not_a_document` — the same word the usage preview uses for the same state.',
2322
+ notes: 'One transaction: the draft document and every app-role grant carrying the slug are rewritten, and the recorded history moves with ' +
2323
+ 'the name without rewriting any stored sample, so a rename takes the same time however much history there is. Samples the robot ' +
2324
+ 'still sends under the old slug until the next publish join the renamed history. The published configuration is immutable, so ' +
2325
+ '`requires_publish` says the rename is not live on the robot yet. A draft that is not a document is `409 draft_not_a_document` — the ' +
2326
+ 'same word the usage preview uses for the same state. While the recorded history is being migrated the rename is refused with ' +
2327
+ '`409 history_migrating`; nothing is written, and the same request succeeds once the migration has finished.',
2338
2328
  },
2339
2329
  {
2340
2330
  method: 'GET', path: '/api/robots/:id/config/slug-usage/:slug', section: 'config',
@@ -2820,8 +2810,8 @@ export const ROUTES = [
2820
2810
  params: [], query: null, request: planChangeRequest, response: orgPlan,
2821
2811
  errors: [...DEVELOPER_GUARD, 'tier_required', 'validation_error', 'plan_limit', 'target_state_conflict'], transport: 'http',
2822
2812
  notes: 'Owner tier, and **downward only**: this route moves the org to a lower plan or cancels it outright to Basic. It never moves the org ' +
2823
- 'up — an upgrade or an add-on goes through the billing routes instead (`POST /api/billing/checkout`, `POST /api/billing/change`). ' +
2824
- '`409 target_state_conflict` names `target_plan` with rule `not_lower` when the ' +
2813
+ 'up — until payment exists, an upgrade or an add-on is not this route\'s job at all, and is handled today as a Feedback request that ' +
2814
+ 'Fleetless then applies through the admin route. `409 target_state_conflict` names `target_plan` with rule `not_lower` when the ' +
2825
2815
  'chosen plan is not below the org\'s current one; with rule `locked_basic_only` when the org is locked (`orgLock`) and the chosen ' +
2826
2816
  'plan is anything but Basic; and with rule `migration_basic_only` when the org is still on the beta, awaiting the switch to priced ' +
2827
2817
  'plans, and the chosen plan is anything but Basic — that choice is exactly what the org lands on at the switch. An owner is never ' +
@@ -2850,186 +2840,14 @@ export const ROUTES = [
2850
2840
  audience: 'internal', auth: 'ops', rateLimited: true, ownerTier: false, status: 200,
2851
2841
  params: [{ name: 'id', description: 'The org\'s uuid, whose plan, add-ons or overrides the operator is changing.' }],
2852
2842
  query: null, request: adminPlanChangeRequest, response: orgPlan,
2853
- errors: ['unauthorized', 'not_found', 'validation_error', 'plan_limit', 'rate_limited', 'target_state_conflict'], transport: 'http',
2843
+ errors: ['unauthorized', 'not_found', 'validation_error', 'plan_limit', 'rate_limited'], transport: 'http',
2854
2844
  notes: 'Every public host answers `404 not_found` for every `/api/admin/*` path — this route is reachable only on the cloud\'s private ' +
2855
2845
  'address — and that same address answers `404` here too while `OPS_API_TOKEN` is not configured, so a door with no key behind it ' +
2856
2846
  'reads exactly like one nobody opened. An unknown `:id` is the same `404`. Applies at once, never queued as a `pending_change`, ' +
2857
2847
  '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 ' +
2858
2848
  '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 ' +
2859
2849
  'also withdraws any `pending_change`, ends a beta org\'s wait for the switch and lifts a lock. Audited as `org.plan_changed` with ' +
2860
- 'the `fleetless` actor, never a developer\'s — the row names what an operator did, not who in the org asked for it. ' +
2861
- '`409 target_state_conflict` names `currency` or `period_ends_at` with rule `billed` when the org has a billing account ' +
2862
- 'in `active` or `past_due` and the request names either field: both are fixed at the first payment and billing, not the operator, ' +
2863
- '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 ' +
2864
- 'charged from the next renewal, except `enterprise` and `basic`, which the sweep cancels the billing account for instead.',
2865
- },
2866
- /* --- billing (2026-10-04, fleetless/fleetless#104) ----------------------
2867
- *
2868
- * Every route here but the webhook is owner-only (`ownerTier: true`), a
2869
- * developer answers `403 tier_required` and `GET /api/billing`
2870
- * is no exception — a developer reads #103's plan cards from
2871
- * `GET /api/org/plan` instead, without the payer, payment method or
2872
- * invoices. The routes that list `billing_unavailable` and
2873
- * `payment_provider_unavailable` spread them from the `BILLING_OFF` and
2874
- * `MOLLIE` constants near the top of this file.
2875
- */
2876
- {
2877
- method: 'GET', path: '/api/billing', section: 'billing',
2878
- summary: "Reads the org's billing account, payment method and invoices.",
2879
- audience: 'developer', auth: 'developer', rateLimited: false, ownerTier: true, status: 200,
2880
- params: [], query: null, request: null, response: billingView,
2881
- errors: [...DEVELOPER_GUARD, 'tier_required'], transport: 'http',
2882
- notes: '`available: false` when `MOLLIE_API_KEY` is not configured — this cloud takes no payments, and every billing route that ' +
2883
- 'charges or opens a Mollie checkout answers `503 billing_unavailable` instead of acting; cancel, resume, the details and the ' +
2884
- 'VAT-ID check need no Mollie and answer normally. `account` is `null` before the org has ever checked out; the plan ' +
2885
- 'and its limits still come from `GET /api/org/plan` (#103) and are not repeated here.',
2886
- },
2887
- {
2888
- method: 'POST', path: '/api/billing/checkout', section: 'billing',
2889
- summary: 'Starts a Mollie checkout for a plan, or an upgrade paid at once.',
2890
- audience: 'developer', auth: 'developer', rateLimited: true, ownerTier: true, status: 201,
2891
- params: [], query: null, request: checkoutRequest, response: checkoutResponse,
2892
- errors: [...DEVELOPER_GUARD, 'tier_required', 'validation_error', 'plan_limit', 'target_state_conflict', 'rate_limited', ...BILLING_OFF, ...MOLLIE],
2893
- transport: 'http',
2894
- notes: 'Rate limited on the `billing.checkout` bucket, same as `POST /api/billing/payment-method` and `POST /api/billing/invoices/:id/pay` ' +
2895
- '— the three routes that mint a Mollie checkout. `400 validation_error` names who may not pay with these rules: ' +
2896
- '`{ field: \'billing.address.country\', rule: \'eu_person\' }` for a person in another EU country, ' +
2897
- '`{ field: \'billing.vat_id\', rule: \'vat_id_required\' }` for a company there with no VAT ID, ' +
2898
- '`{ field: \'billing.vat_id\', rule: \'vat_id_invalid\' }` once VIES has said so, and ' +
2899
- '`{ field: \'accept_withdrawal\', rule: \'required\' }` for a person who did not confirm it. `409 target_state_conflict` names ' +
2900
- '`plan` with rule `already_billed` when the org already has an `active` or `past_due` billing account — checkout is for the first ' +
2901
- 'payment only, every later change is `POST /api/billing/change`. `checkout_url` is Mollie\'s hosted page, where the payer ' +
2902
- 'chooses card, PayPal or Apple Pay; the return lands on ' +
2903
- '`<console>/settings/billing?checkout=<checkout_id>`, which polls `GET /api/billing/checkout/:id` until the webhook — or the poll ' +
2904
- 'itself — has reconciled the payment. `409 plan_limit` is the org\'s own usage against the plan being bought.',
2905
- },
2906
- {
2907
- method: 'GET', path: '/api/billing/checkout/:id', section: 'billing',
2908
- summary: "Reads a checkout's status, for the return page's poll.",
2909
- audience: 'developer', auth: 'developer', rateLimited: false, ownerTier: true, status: 200,
2910
- params: [{ name: 'id', description: 'The checkout id from `checkoutResponse.checkout_id`, carried on the return URL.' }],
2911
- query: null, request: null, response: checkoutStatus,
2912
- errors: [...DEVELOPER_GUARD, 'tier_required', 'not_found'], transport: 'http',
2913
- notes: 'Calls the same `reconcilePayment(deps, molliePaymentId)` the webhook calls, so a return page that lands before the ' +
2914
- 'webhook does still sees the payment applied — this route, not the webhook, is what the dev stack and the test-mode suite rely on, ' +
2915
- 'since Mollie refuses an unreachable webhook URL. `plan` is the org\'s plan after applying, unchanged unless `purpose` ' +
2916
- 'is `upgrade` and `status` is `paid`.',
2917
- },
2918
- {
2919
- method: 'POST', path: '/api/billing/vat-id/check', section: 'billing',
2920
- summary: 'Checks a VAT ID against VIES, for the checkout form and the details page.',
2921
- audience: 'developer', auth: 'developer', rateLimited: true, ownerTier: true, status: 200,
2922
- params: [], query: null, request: vatIdCheckRequest, response: vatIdCheckResponse,
2923
- errors: [...DEVELOPER_GUARD, 'tier_required', 'validation_error', 'rate_limited'], transport: 'http',
2924
- notes: 'Rate limited on its own `billing.vat_check` bucket, sized for a form checked on blur rather than for a checkout. Never refuses for ' +
2925
- 'an `unverified` VIES answer — the checkout itself accepts `unverified` and the hourly sweep re-checks it — this route ' +
2926
- 'only reports what VIES currently says, in a different place for the same ID, entered either at checkout or on `PATCH ' +
2927
- '/api/billing/details`.',
2928
- },
2929
- {
2930
- method: 'PATCH', path: '/api/billing/details', section: 'billing',
2931
- summary: "Edits the billing account's invoice email or VAT ID.",
2932
- audience: 'developer', auth: 'developer', rateLimited: false, ownerTier: true, status: 200,
2933
- params: [], query: null, request: billingDetailsUpdate, response: billingView,
2934
- errors: [...DEVELOPER_GUARD, 'tier_required', 'validation_error', 'not_found'], transport: 'http',
2935
- notes: '`404 not_found` when the org has no billing account yet — there is nothing here to edit before the first checkout. A new `vat_id` ' +
2936
- 'is re-checked through VIES the same way `POST /api/billing/vat-id/check` does; a valid ID entered here lifts the block a definitive ' +
2937
- '`invalid` answer placed on the next renewal.',
2938
- },
2939
- {
2940
- method: 'POST', path: '/api/billing/change', section: 'billing',
2941
- summary: "Moves the org's plan, cycle or add-ons, charging increases at once.",
2942
- audience: 'developer', auth: 'developer', rateLimited: false, ownerTier: true, status: 200,
2943
- params: [], query: null, request: billingChangeRequest, response: billingChangeResponse,
2944
- errors: [...DEVELOPER_GUARD, 'tier_required', 'validation_error', 'plan_limit', 'target_state_conflict', ...BILLING_OFF, ...MOLLIE],
2945
- transport: 'http',
2946
- notes: 'The body names the **absolute** target — plan, cycle and add-ons — never a delta: the route compares it with the ' +
2947
- 'org\'s current state and splits the difference. The increasing part is charged now, through the same proration `changeNetCents` ' +
2948
- 'computes, and takes effect the moment Mollie accepts the `recurring` payment with anything but `failed`, `canceled` or `expired` ' +
2949
- '— card mandates, Apple Pay\'s included, usually answer `paid` within seconds, a PayPal one may stay `pending` for a while; if it ' +
2950
- 'fails later, its open invoice enters dunning like a failed renewal. If Mollie refuses or does not answer, nothing is applied ' +
2951
- 'and this answers `502 payment_provider_unavailable` instead. The decreasing part — a lower plan, yearly → monthly, fewer add-ons — ' +
2952
- 'is stored as a pending change and applied at the period\'s end, same as `PUT /api/org/plan/change`; a lower plan over the target\'s ' +
2953
- 'limits answers `409 plan_limit` and the console opens #103\'s choose-what-stays page. Any increase first withdraws a pending ' +
2954
- 'downgrade or cancel, exactly as the admin route does. `409 target_state_conflict` names `billing` with rule `no_account` (no ' +
2955
- 'checkout yet — use `POST /api/billing/checkout`), `past_due` (an open invoice has to be paid first) or `no_valid_mandate` (the ' +
2956
- 'payment method needs renewing first, `POST /api/billing/payment-method`). `charged` in the response is the invoice from the part ' +
2957
- 'charged now, or `null` when the whole request was a decrease.',
2958
- },
2959
- {
2960
- method: 'POST', path: '/api/billing/payment-method', section: 'billing',
2961
- summary: 'Starts a Mollie checkout for a new payment method.',
2962
- audience: 'developer', auth: 'developer', rateLimited: true, ownerTier: true, status: 201,
2963
- params: [], query: null, request: paymentMethodChangeRequest, response: checkoutResponse,
2964
- errors: [...DEVELOPER_GUARD, 'tier_required', 'validation_error', 'not_found', 'rate_limited', ...BILLING_OFF, ...MOLLIE],
2965
- transport: 'http',
2966
- notes: 'Rate limited on the `billing.checkout` bucket, same as `POST /api/billing/checkout`. Creates a hosted `first` payment on the ' +
2967
- 'existing Mollie customer, restricted to the chosen method (`card` → Mollie\'s `creditcard`, `paypal`, `applepay`). For `card` ' +
2968
- 'and `paypal` it is a payment of **0.00** in the org\'s currency that pays no open invoice: the invoice stays open, the next ' +
2969
- 'dunning retry charges the new mandate, and `POST /api/billing/invoices/:id/pay` still pays it at once. `applepay` behaves the ' +
2970
- 'same where Mollie accepts a zero-amount Apple Pay payment; where it does not, a change to Apple Pay is only offered together ' +
2971
- 'with paying an open invoice — the payment is then that invoice\'s amount and pays it — and without one this answers ' +
2972
- '`400 validation_error` with `{ field: \'method\', rule: \'applepay_needs_open_invoice\' }`. A client offers what ' +
2973
- '`payment_method_options` in `GET /api/billing` lists. `404 not_found` when the org has no billing account yet. When the new ' +
2974
- 'mandate turns `valid` it becomes the account\'s — an Apple Pay one is a card mandate, shown as `applepay` — and every other ' +
2975
- 'mandate of the customer is revoked.',
2976
- },
2977
- {
2978
- method: 'POST', path: '/api/billing/cancel', section: 'billing',
2979
- summary: "Schedules the org's plan to cancel to Basic at the period's end.",
2980
- audience: 'developer', auth: 'developer', rateLimited: false, ownerTier: true, status: 200,
2981
- params: [], query: null, request: billingCancelRequest, requestOptional: true, response: billingView,
2982
- errors: [...DEVELOPER_GUARD, 'tier_required', 'validation_error', 'not_found', 'plan_limit'], transport: 'http',
2983
- notes: 'A body is optional — `reason` alone, and nobody but Fleetless reads it. `404 not_found` when the org has no billing account to ' +
2984
- 'cancel. Takes effect at the period\'s end, nothing credited or refunded; over Basic\'s limits this is refused `409 ' +
2985
- 'plan_limit` and the console sends the owner to #103\'s choose-what-stays page instead, the same as a plan downgrade. "Cancel at ' +
2986
- 'period end" is not a flag here — it reads as `pending_change.target_plan === \'basic\'` on `GET /api/org/plan`.',
2987
- },
2988
- {
2989
- method: 'POST', path: '/api/billing/resume', section: 'billing',
2990
- summary: 'Withdraws a scheduled cancel, keeping the current plan.',
2991
- audience: 'developer', auth: 'developer', rateLimited: false, ownerTier: true, status: 200,
2992
- params: [], query: null, request: null, response: billingView,
2993
- errors: [...DEVELOPER_GUARD, 'tier_required', 'not_found'], transport: 'http',
2994
- notes: '`404 not_found` when nothing is pending — there is no scheduled cancel to withdraw. The org stays on its current plan, unchanged.',
2995
- },
2996
- {
2997
- method: 'GET', path: '/api/billing/invoices/:id/pdf', section: 'billing',
2998
- summary: "Downloads one invoice's rendered PDF.",
2999
- audience: 'developer', auth: 'developer', rateLimited: false, ownerTier: true, status: 200,
3000
- params: [{ name: 'id', description: 'The invoice id, from `billingInvoice.id` in `GET /api/billing`\'s `invoices`.' }],
3001
- query: null, request: null, response: null, contentType: 'application/pdf',
3002
- errors: [...DEVELOPER_GUARD, 'tier_required', 'not_found'], transport: 'http',
3003
- notes: 'Rendered once, with `pdfkit`, when the invoice is issued, and stored as bytes — an issued invoice never changes, so this always ' +
3004
- 'answers the same PDF for the same id. `404 not_found` for an unknown id or one from another org.',
3005
- },
3006
- {
3007
- method: 'POST', path: '/api/billing/invoices/:id/pay', section: 'billing',
3008
- summary: 'Pays one open invoice, through a new Mollie payment.',
3009
- audience: 'developer', auth: 'developer', rateLimited: true, ownerTier: true, status: 201,
3010
- params: [{ name: 'id', description: 'The invoice id, from `billingInvoice.id`, of the open invoice to pay.' }],
3011
- query: null, request: null, response: checkoutResponse,
3012
- errors: [...DEVELOPER_GUARD, 'tier_required', 'not_found', 'target_state_conflict', 'rate_limited', ...BILLING_OFF, ...MOLLIE],
3013
- transport: 'http',
3014
- notes: 'Rate limited on the `billing.checkout` bucket, same as `POST /api/billing/checkout`. `409 target_state_conflict` names `invoice` ' +
3015
- 'with rule `not_open` when the invoice is already `paid` or `uncollectible` — there is nothing left to pay. Paying the open ' +
3016
- 'invoice of a locked org unlocks it and keeps the plan running to the period\'s end, the same as a renewal that ' +
3017
- 'succeeds on a retry. `404 not_found` for an unknown id or one from another org.',
3018
- },
3019
- {
3020
- method: 'POST', path: '/api/billing/mollie/webhook', section: 'billing',
3021
- summary: "Takes Mollie's payment-changed notification and reconciles the payment.",
3022
- audience: 'internal', auth: 'none', rateLimited: true, ownerTier: false, status: 200,
3023
- params: [], query: null, request: null, response: null,
3024
- errors: ['rate_limited'], transport: 'http',
3025
- notes: '**The body is never trusted**: it names only a payment id (`id=tr_…`, form-encoded, Mollie\'s own shape), and this route ' +
3026
- 'does nothing with it but call `reconcilePayment(deps, molliePaymentId)` — the same function `GET /api/billing/checkout/:id` and ' +
3027
- 'the hourly sweep call — which fetches the payment from Mollie itself and applies what Mollie says, idempotently. Rate limited on ' +
3028
- 'the `billing.webhook` bucket, per ip, 600/min — generous, because this is Mollie\'s own infrastructure calling, not a browser; ' +
3029
- 'over it the answer is `429 rate_limited`, and Mollie retries the notification later. **Every other answer is `200`**, including an id this cloud does not recognise, which is logged and otherwise ignored, **except a ' +
3030
- 'processing fault, which is `500`** so Mollie retries the notification rather than this cloud losing it. `auth: \'none\'` because ' +
3031
- 'Mollie signs nothing Fleetless checks here — the payment is only ever trusted once fetched back from Mollie\'s own API with the ' +
3032
- 'configured key.',
2850
+ 'the `fleetless` actor, never a developer\'s — the row names what an operator did, not who in the org asked for it.',
3033
2851
  },
3034
2852
  /* ------------------------------------------------- assets (robot upload) */
3035
2853
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fleetless/contracts",
3
- "version": "6.3.0-next.3",
3
+ "version": "6.3.0-next.5",
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",
@@ -1,49 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "type": "object",
4
- "properties": {
5
- "line1": {
6
- "type": "string",
7
- "minLength": 1,
8
- "maxLength": 200,
9
- "description": "Street and number, or the first address line."
10
- },
11
- "line2": {
12
- "anyOf": [
13
- {
14
- "type": "string",
15
- "maxLength": 200
16
- },
17
- {
18
- "type": "null"
19
- }
20
- ],
21
- "description": "A second address line, or `null` when there is none."
22
- },
23
- "postal_code": {
24
- "type": "string",
25
- "minLength": 1,
26
- "maxLength": 20,
27
- "description": "Postal or ZIP code."
28
- },
29
- "city": {
30
- "type": "string",
31
- "minLength": 1,
32
- "maxLength": 100,
33
- "description": "City or town."
34
- },
35
- "country": {
36
- "type": "string",
37
- "pattern": "^[A-Z]{2}$",
38
- "description": "The billing country. Decides VAT (`vatFor`) and currency (`currencyForCountry`)."
39
- }
40
- },
41
- "required": [
42
- "line1",
43
- "line2",
44
- "postal_code",
45
- "city",
46
- "country"
47
- ],
48
- "additionalProperties": false
49
- }
@@ -1,12 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "type": "object",
4
- "properties": {
5
- "reason": {
6
- "description": "An optional free-text reason. Shown to nobody but Fleetless.",
7
- "type": "string",
8
- "maxLength": 500
9
- }
10
- },
11
- "additionalProperties": false
12
- }
@@ -1,60 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "type": "object",
4
- "properties": {
5
- "plan": {
6
- "description": "The target plan. Omitted leaves the plan as it is.",
7
- "type": "string",
8
- "enum": [
9
- "plus",
10
- "pro"
11
- ]
12
- },
13
- "cycle": {
14
- "description": "The target cycle. Omitted leaves the cycle as it is.",
15
- "type": "string",
16
- "enum": [
17
- "monthly",
18
- "yearly"
19
- ]
20
- },
21
- "addons": {
22
- "description": "Absolute add-on counts to end up with, not a delta. Omitted leaves add-ons as they are.",
23
- "type": "object",
24
- "properties": {
25
- "seats": {
26
- "type": "integer",
27
- "minimum": 0,
28
- "maximum": 9007199254740991,
29
- "description": "Extra developer seats, one each."
30
- },
31
- "robots": {
32
- "type": "integer",
33
- "minimum": 0,
34
- "maximum": 9007199254740991,
35
- "description": "Extra robots, one each."
36
- },
37
- "apps": {
38
- "type": "integer",
39
- "minimum": 0,
40
- "maximum": 9007199254740991,
41
- "description": "Extra apps, one each."
42
- },
43
- "app_user_packs": {
44
- "type": "integer",
45
- "minimum": 0,
46
- "maximum": 9007199254740991,
47
- "description": "Packs of five extra app users."
48
- },
49
- "live_video_packs": {
50
- "type": "integer",
51
- "minimum": 0,
52
- "maximum": 9007199254740991,
53
- "description": "Packs of 250 extra hours of app-user live video per month."
54
- }
55
- },
56
- "additionalProperties": false
57
- }
58
- },
59
- "additionalProperties": false
60
- }