@fleetless/contracts 9.2.0-next.1 → 10.1.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 (37) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/artifacts/openapi.json +18609 -10341
  3. package/artifacts/routes.json +96 -16
  4. package/artifacts/schema/billing-change-response.schema.json +1527 -1727
  5. package/artifacts/schema/billing-decision-amounts.schema.json +244 -0
  6. package/artifacts/schema/billing-decision-display-request.schema.json +24 -0
  7. package/artifacts/schema/billing-decision-display-response.schema.json +3130 -0
  8. package/artifacts/schema/billing-decision-period.schema.json +550 -0
  9. package/artifacts/schema/billing-decision-snapshot.schema.json +3103 -0
  10. package/artifacts/schema/checkout-request.schema.json +3 -4
  11. package/artifacts/schema/checkout-response.schema.json +492 -402
  12. package/artifacts/schema/confirmation-proof.schema.json +6 -0
  13. package/artifacts/schema/plan-change-decision-lookup-query.schema.json +16 -0
  14. package/artifacts/schema/plan-change-decision-status-response.schema.json +543 -0
  15. package/artifacts/schema/plan-change-prepare-request.schema.json +84 -0
  16. package/artifacts/schema/plan-change-prepare-response.schema.json +3162 -0
  17. package/artifacts/schema/plan-change-request.schema.json +177 -65
  18. package/artifacts/schema/purchase-conflict-details.schema.json +94 -0
  19. package/artifacts/schema/purchase-intent-accepted-without-payment.schema.json +95 -0
  20. package/artifacts/schema/purchase-intent-confirm-request.schema.json +146 -33
  21. package/artifacts/schema/purchase-intent-draft.schema.json +449 -0
  22. package/artifacts/schema/purchase-intent-payment-started.schema.json +184 -0
  23. package/artifacts/schema/purchase-intent-response.schema.json +1235 -168
  24. package/dist/billing.d.ts +5665 -210
  25. package/dist/billing.js +224 -29
  26. package/dist/confirmation-proof.d.ts +5 -0
  27. package/dist/confirmation-proof.js +6 -0
  28. package/dist/iana-time-zones.d.ts +2 -0
  29. package/dist/iana-time-zones.js +426 -0
  30. package/dist/index.d.ts +5 -4
  31. package/dist/index.js +3 -2
  32. package/dist/plans.d.ts +125 -1
  33. package/dist/plans.js +19 -1
  34. package/dist/purchase-operation-key.d.ts +4 -0
  35. package/dist/purchase-operation-key.js +4 -0
  36. package/dist/routes.js +42 -21
  37. package/package.json +3 -1
@@ -6596,11 +6596,37 @@
6596
6596
  "transport": "http",
6597
6597
  "notes": "The one read the console's Plan & billing page, its usage and limit gauges, and every upgrade prompt and feature gate draw from — nothing else computes `limits` or `usage` on its own. `limits` is already the effective ceiling, the catalogue row raised by `addons` or replaced by an operator's override, so a consumer never recomputes it from the catalogue. `usage` is counted fresh on every call, never cached. `switch` is present only for an organization still on the beta that has not yet landed on a priced plan."
6598
6598
  },
6599
+ {
6600
+ "method": "POST",
6601
+ "path": "/api/org/plan/change/prepare",
6602
+ "section": "org",
6603
+ "summary": "Prepares a nonbinding downward-plan decision and its C.4 display.",
6604
+ "audience": "developer",
6605
+ "auth": "developer",
6606
+ "rateLimited": false,
6607
+ "ownerTier": true,
6608
+ "status": 200,
6609
+ "params": [],
6610
+ "query": null,
6611
+ "request": "plan-change-prepare-request",
6612
+ "response": "plan-change-prepare-response",
6613
+ "errors": [
6614
+ "unauthorized",
6615
+ "token_expired",
6616
+ "token_revoked",
6617
+ "tier_required",
6618
+ "validation_error",
6619
+ "plan_limit",
6620
+ "target_state_conflict"
6621
+ ],
6622
+ "transport": "http",
6623
+ "notes": "Owner only. Persists a prepared change reference and a short-lived display, without mutating the plan, pending_change, or legal acceptance. A same-key, same-input retry while undecided returns the same change_id with a fresh display. A Basic cancellation reason belongs only in the final PUT."
6624
+ },
6599
6625
  {
6600
6626
  "method": "PUT",
6601
6627
  "path": "/api/org/plan/change",
6602
6628
  "section": "org",
6603
- "summary": "Moves the org's plan down — a lower plan or a cancellation to Basic — queuing the change rather than applying it at once.",
6629
+ "summary": "Confirms a prepared downward-plan decision with its C.4 proof.",
6604
6630
  "audience": "developer",
6605
6631
  "auth": "developer",
6606
6632
  "rateLimited": false,
@@ -6620,7 +6646,32 @@
6620
6646
  "target_state_conflict"
6621
6647
  ],
6622
6648
  "transport": "http",
6623
- "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 up — an upgrade or an add-on goes through the billing routes instead (`POST /api/billing/checkout`, `POST /api/billing/change`). `409 target_state_conflict` names `target_plan` with rule `not_lower` when the chosen plan is not below the org's current one; with rule `locked_basic_only` when the org is locked (`orgLock`) and the chosen plan is anything but Basic; and with rule `migration_basic_only` when the org is still on the beta, awaiting the switch to priced 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 named in `keep` and always stays, but still counts against the target plan's `seats`; `409 plan_limit` names `seats` when the owners alone already exceed it, and names whichever other limit `keep` still exceeds otherwise. `keep` is `null` when the org's current usage already fits the target plan outright and nothing is deleted; named, it lists exactly the robots, apps, app users and developers that stay. The choice is stored as `pending_change` and takes effect at `period_ends_at` — **everything of the chosen kind not named in `keep` is deleted at that instant, never before** — except a choice made while the org is locked, which takes effect at once, and a beta org's choice, which takes effect at the switch date instead. Anything created while the choice is pending is checked against the target plan too and, when it passes, is folded into `keep`, so exactly what the confirmation counted is what is actually deleted. A later `PUT` replaces a still-pending choice outright."
6649
+ "notes": "Owner tier, and **downward only**: a prior prepare returns change_id and a displayed snapshot; this final PUT requires its confirmation_proof and the same operation_key, target_plan and keep. Only Basic permits cancellation_reason (at most 500 input characters). The reason is final idempotency metadata, not price or legal evidence. An exact replay returns the original result; a changed reason with the same key conflicts before effect. The decision and legal acceptance commit together. This route moves the org to a lower plan or cancels it outright to Basic. It never moves the org up — an upgrade or an add-on goes through the billing routes instead (`POST /api/billing/checkout`, `POST /api/billing/change`). `409 target_state_conflict` names `target_plan` with rule `not_lower` when the chosen plan is not below the org's current one; with rule `locked_basic_only` when the org is locked (`orgLock`) and the chosen plan is anything but Basic; and with rule `migration_basic_only` when the org is still on the beta, awaiting the switch to priced 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 named in `keep` and always stays, but still counts against the target plan's `seats`; `409 plan_limit` names `seats` when the owners alone already exceed it, and names whichever other limit `keep` still exceeds otherwise. `keep` is `null` when the org's current usage already fits the target plan outright and nothing is deleted; named, it lists exactly the robots, apps, app users and developers that stay. The choice is stored as `pending_change` and takes effect at `period_ends_at` — **everything of the chosen kind not named in `keep` is deleted at that instant, never before** — except a choice made while the org is locked, which takes effect at once, and a beta org's choice, which takes effect at the switch date instead. Anything created while the choice is pending is checked against the target plan too and, when it passes, is folded into `keep`, so exactly what the confirmation counted is what is actually deleted. Replacing a still-pending choice requires a new prepare and proof-bound final PUT."
6650
+ },
6651
+ {
6652
+ "method": "GET",
6653
+ "path": "/api/org/plan/change/decisions",
6654
+ "section": "org",
6655
+ "summary": "Looks up the prepared or accepted owner plan decision by operation key.",
6656
+ "audience": "developer",
6657
+ "auth": "developer",
6658
+ "rateLimited": false,
6659
+ "ownerTier": true,
6660
+ "status": 200,
6661
+ "params": [],
6662
+ "query": "plan-change-decision-lookup-query",
6663
+ "request": null,
6664
+ "response": "plan-change-decision-status-response",
6665
+ "errors": [
6666
+ "unauthorized",
6667
+ "token_expired",
6668
+ "token_revoked",
6669
+ "tier_required",
6670
+ "validation_error",
6671
+ "not_found"
6672
+ ],
6673
+ "transport": "http",
6674
+ "notes": "Scope the operation key to the authenticated real Owner and organization. An unknown or foreign key returns 404 without disclosure. Prepared returns only change_id; accepted returns the stored original orgPlan result. No proof is returned. Console checks this before asking for a fresh display after a lost final response."
6624
6675
  },
6625
6676
  {
6626
6677
  "method": "DELETE",
@@ -6644,7 +6695,7 @@
6644
6695
  "not_found"
6645
6696
  ],
6646
6697
  "transport": "http",
6647
- "notes": "Owner tier. `404 not_found` when the org has no `pending_change` to withdraw. The org stays on its current plan, unchanged, as if the choice had never been made; a developer who wants a different one sends a new `PUT`, which would have replaced this one outright anyway."
6698
+ "notes": "Owner tier. `404 not_found` when the org has no `pending_change` to withdraw. The org stays on its current plan, unchanged, as if the choice had never been made; an Owner who wants a different one prepares a new display and confirms it with a final PUT."
6648
6699
  },
6649
6700
  {
6650
6701
  "method": "PATCH",
@@ -6697,7 +6748,7 @@
6697
6748
  "tier_required"
6698
6749
  ],
6699
6750
  "transport": "http",
6700
- "notes": "`available: false` when `MOLLIE_API_KEY` is not configured — this cloud takes no payments, and every billing route that charges or opens a Mollie checkout answers `503 billing_unavailable` instead of acting; cancel, resume, the details and the VAT-ID check need no Mollie and answer normally. `account` is `null` before the org has ever checked out; the plan and its limits still come from `GET /api/org/plan` (fleetless/fleetless issue 103) and are not repeated here."
6751
+ "notes": "`available: false` when `MOLLIE_API_KEY` is not configured — this cloud takes no payments, and every billing route that charges or opens a Mollie checkout answers `503 billing_unavailable` instead of acting; plan-change prepare, resume, the details and the VAT-ID check need no Mollie and answer normally. `account` is `null` before the org has ever checked out; the plan and its limits still come from `GET /api/org/plan` (fleetless/fleetless issue 103) and are not repeated here."
6701
6752
  },
6702
6753
  {
6703
6754
  "method": "POST",
@@ -6726,7 +6777,7 @@
6726
6777
  "payment_provider_unavailable"
6727
6778
  ],
6728
6779
  "transport": "http",
6729
- "notes": "Basic stays free for every payer. New paid checkout requires a company, terms, current buyer eligibility and an EUR quote. Other EU countries require direct VIES valid with an identifier; unavailable/unverified or missing identifier returns awaiting_vies without payment or redirect. Cloud checks the non-EU Tax ID and versioned public-email policy, and US state. Persist operation_key before POST; the same org/key/input returns the same intent, different input is 409 target_state_conflict with purchaseConflictDetails rule operation_key_reused. Owner lookup recovers a lost response. Only explicit confirmation of the current quote may create a payment; a worker cannot start it. payment_started.payment.checkout_url exists only for a hosted payment, where the buyer chooses card, PayPal or Apple Pay. Its return is <console>/settings/billing?checkout=<checkout_id>; GET /api/billing/checkout/:id reconciles the recorded payment. An active/past_due account uses billing/change; already_billed and plan_limit retain their existing meanings."
6780
+ "notes": "Basic stays free for every payer. This start creates only a nonbinding draft; accept_terms is deprecated and cannot confirm an order. Current company, buyer, VIES and EUR quote checks still apply. Persist operation_key before POST; same key/input recovers the intent, changed input conflicts. An eligible Owner obtains a no-store C.4 display, then explicitly confirms with its proof. No payment or acceptance occurs at start. Hosted payment later offers card, PayPal or Apple Pay; its return is <console>/settings/billing?checkout=<checkout_id>. An active/past_due account uses billing/change."
6730
6781
  },
6731
6782
  {
6732
6783
  "method": "GET",
@@ -6751,7 +6802,38 @@
6751
6802
  "not_found"
6752
6803
  ],
6753
6804
  "transport": "http",
6754
- "notes": "Supply exactly one of operation_key or intent_id and the expected operation. Scope lookup to the authenticated owner and org; unknown, foreign-org or mismatched-operation intents return 404 without disclosure. Repeating a lookup after restart or lost response returns the same intent/payment identity and, for a paid change, its billing result. Awaiting VIES and eligible states never start payment; Console polls at a bounded interval and asks for fresh confirmation of the displayed quote."
6805
+ "notes": "Supply exactly one of operation_key or intent_id and the expected operation. Scope lookup to the authenticated owner and org; unknown, foreign-org or mismatched-operation intents return 404 without disclosure. Repeating a lookup after restart or lost response returns the same intent/payment identity and, for a paid change, its billing result. A proof is never returned here; a still-eligible decision needs a fresh C.4 display and explicit Owner click."
6806
+ },
6807
+ {
6808
+ "method": "POST",
6809
+ "path": "/api/billing/intents/:id/display",
6810
+ "section": "billing",
6811
+ "summary": "Issues a short-lived C.4 decision display and opaque confirmation proof.",
6812
+ "audience": "developer",
6813
+ "auth": "developer",
6814
+ "rateLimited": false,
6815
+ "ownerTier": true,
6816
+ "status": 200,
6817
+ "params": [
6818
+ {
6819
+ "name": "id",
6820
+ "description": "The eligible intent ID returned by checkout or billing change."
6821
+ }
6822
+ ],
6823
+ "query": null,
6824
+ "request": "billing-decision-display-request",
6825
+ "response": "billing-decision-display-response",
6826
+ "errors": [
6827
+ "unauthorized",
6828
+ "token_expired",
6829
+ "token_revoked",
6830
+ "tier_required",
6831
+ "validation_error",
6832
+ "not_found",
6833
+ "target_state_conflict"
6834
+ ],
6835
+ "transport": "http",
6836
+ "notes": "Owner only, Cache-Control: no-store. Cloud persists the snapshot and proof hash for an eligible current checkout or paid-change intent of this Owner and org. Pending, held, refused or accepted intents cannot mint a new proof. The proof never appears in lookup, billing views or logs."
6755
6837
  },
6756
6838
  {
6757
6839
  "method": "POST",
@@ -6786,7 +6868,7 @@
6786
6868
  "payment_provider_unavailable"
6787
6869
  ],
6788
6870
  "transport": "http",
6789
- "notes": "Require the same operation_key and operation plus the displayed quote_revision and buyer_fingerprint. Under the org lock compare current buyer, country, VAT ID, Tax ID, invoice email/policy version, US state, EUR quote, invoice status/amount/currency and integration holds. A stale revision is 409 target_state_conflict with purchaseConflictDetails/current_intent; the owner must confirm again. Foreign or mismatched operation is 404 without disclosure. Pending or held cannot charge. Persist one payment row before the provider call and use its ID as the provider idempotency key. Repeated confirmations and lost responses recover that payment/result; never create another. Look up/adopt a possibly-created payment before resending after a timeout; ambiguity is not permission to charge again."
6871
+ "notes": "Checkout and paid-change decisions require confirmation_proof along with the operation key, quote revision and buyer fingerprint shown in the persisted C.4 display. Cloud rechecks buyer, quote, selection, legal references, period and current state under the org lock; stale or spent proof conflicts without effect. One decision and one legal acceptance commit together. An exact same-key replay returns the original result without another payment or acceptance. Foreign ownership answers 404 without disclosure; pending or held cannot charge."
6790
6872
  },
6791
6873
  {
6792
6874
  "method": "GET",
@@ -6871,7 +6953,7 @@
6871
6953
  "method": "POST",
6872
6954
  "path": "/api/billing/change",
6873
6955
  "section": "billing",
6874
- "summary": "Records a paid-change intent or schedules a decrease.",
6956
+ "summary": "Records a nonbinding paid-change intent for a plan, cycle or add-on target.",
6875
6957
  "audience": "developer",
6876
6958
  "auth": "developer",
6877
6959
  "rateLimited": false,
@@ -6893,7 +6975,7 @@
6893
6975
  "payment_provider_unavailable"
6894
6976
  ],
6895
6977
  "transport": "http",
6896
- "notes": "The request names an absolute plan/cycle/add-on target and a stable operation_key. Increases need a current company/EUR decision and explicit owner confirmation even after a worker resolves VIES. billingChangeResponse carries intent while awaiting_vies, eligible, refused or held; the old plan stays in effect. Confirm under the org lock, comparing buyer/policy fingerprint and quote revision; use one persisted payment row for provider idempotency. A started paid change returns billing, charged and intent with payment_started. An immediate accepted decrease retains the billing/charged branch (charged null); decreases are scheduled for period end. Existing no_account, past_due, no_valid_mandate and plan_limit conflicts remain. Do not advance periods, cancel existing choices or begin dunning merely because an intent is pending."
6978
+ "notes": "The request names an absolute plan/cycle/add-on target and a stable operation_key. Start is nonbinding for every change, including zero-charge, scheduled and formerly immediate decreases: it neither changes the plan nor writes legal acceptance. An eligible Owner obtains a C.4 display and explicitly confirms with its proof. Confirmation may return accepted_no_payment with charged: null and no provider payment or redirect, or payment_started for a charged change. Exact-key lookup recovers the accepted result. Existing no_account, past_due, no_valid_mandate and plan_limit conflicts remain."
6897
6979
  },
6898
6980
  {
6899
6981
  "method": "POST",
@@ -6928,28 +7010,26 @@
6928
7010
  "method": "POST",
6929
7011
  "path": "/api/billing/cancel",
6930
7012
  "section": "billing",
6931
- "summary": "Schedules the org's plan to cancel to Basic at the period's end.",
7013
+ "summary": "Rejects legacy direct cancellation after the C.4 gate is active.",
6932
7014
  "audience": "developer",
6933
7015
  "auth": "developer",
6934
7016
  "rateLimited": false,
6935
7017
  "ownerTier": true,
6936
- "status": 200,
7018
+ "status": 409,
6937
7019
  "params": [],
6938
7020
  "query": null,
6939
7021
  "request": "billing-cancel-request",
6940
7022
  "requestOptional": true,
6941
- "response": "billing-view",
7023
+ "response": null,
6942
7024
  "errors": [
6943
7025
  "unauthorized",
6944
7026
  "token_expired",
6945
7027
  "token_revoked",
6946
7028
  "tier_required",
6947
- "validation_error",
6948
- "not_found",
6949
- "plan_limit"
7029
+ "target_state_conflict"
6950
7030
  ],
6951
7031
  "transport": "http",
6952
- "notes": "A body is optional — `reason` alone, and nobody but Fleetless reads it. `404 not_found` when the org has no billing account to cancel. Takes effect at the period's end, nothing credited or refunded; over Basic's limits this is refused `409 plan_limit` and the console sends the owner to its choose-what-stays page instead, the same as a plan downgrade. \"Cancel at period end\" is not a flag here — it reads as `pending_change.target_plan === 'basic'` on `GET /api/org/plan`."
7032
+ "notes": "The C.4 gate rejects this legacy POST with 409 target_state_conflict before mutation, audit or mail. Console uses POST /api/org/plan/change/prepare and the proof-bound final PUT for Basic, including an optional reason there. This route cannot confirm a customer decision."
6953
7033
  },
6954
7034
  {
6955
7035
  "method": "POST",