@fleetless/contracts 6.5.0 → 7.0.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/artifacts/openapi.json +5805 -1805
  3. package/artifacts/routes.json +75 -13
  4. package/artifacts/schema/addon-catalogue-entry.schema.json +1 -15
  5. package/artifacts/schema/billing-address.schema.json +7 -1
  6. package/artifacts/schema/billing-change-request.schema.json +9 -0
  7. package/artifacts/schema/billing-change-response.schema.json +2219 -625
  8. package/artifacts/schema/billing-details-update.schema.json +70 -0
  9. package/artifacts/schema/billing-details.schema.json +27 -3
  10. package/artifacts/schema/billing-view.schema.json +56 -24
  11. package/artifacts/schema/checkout-request.schema.json +90 -154
  12. package/artifacts/schema/checkout-response.schema.json +531 -17
  13. package/artifacts/schema/invoice-pay-request.schema.json +16 -0
  14. package/artifacts/schema/payment-method-change-request.schema.json +7 -0
  15. package/artifacts/schema/plan-catalogue-entry.schema.json +1 -15
  16. package/artifacts/schema/plan-prices.schema.json +1 -15
  17. package/artifacts/schema/purchase-billing-details.schema.json +111 -0
  18. package/artifacts/schema/purchase-conflict-details.schema.json +582 -0
  19. package/artifacts/schema/purchase-hold-reason.schema.json +9 -0
  20. package/artifacts/schema/purchase-intent-confirm-request.schema.json +40 -0
  21. package/artifacts/schema/purchase-intent-lookup-query.schema.json +56 -0
  22. package/artifacts/schema/purchase-intent-response.schema.json +1554 -0
  23. package/artifacts/schema/purchase-operation-key.schema.json +7 -0
  24. package/artifacts/schema/purchase-operation.schema.json +11 -0
  25. package/artifacts/schema/purchase-quote.schema.json +43 -0
  26. package/artifacts/schema/purchase-refusal-rule.schema.json +13 -0
  27. package/artifacts/schema/vat-decision.schema.json +77 -0
  28. package/artifacts/schema/vat-id-check-response.schema.json +111 -25
  29. package/artifacts/schema/vies-pending-reason.schema.json +9 -0
  30. package/dist/billing.d.ts +1128 -75
  31. package/dist/billing.js +174 -66
  32. package/dist/index.d.ts +2 -0
  33. package/dist/index.js +1 -0
  34. package/dist/plans.d.ts +4 -9
  35. package/dist/plans.js +4 -7
  36. package/dist/routes.js +33 -60
  37. package/package.json +1 -1
package/dist/routes.js CHANGED
@@ -12,7 +12,7 @@ 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';
15
+ import { purchaseIntentLookupQuery, purchaseIntentConfirmRequest, purchaseIntentResponse, invoicePayRequest, billingCancelRequest, billingChangeRequest, billingChangeResponse, billingDetailsUpdate, billingView, checkoutRequest, checkoutResponse, checkoutStatus, paymentMethodChangeRequest, vatIdCheckRequest, vatIdCheckResponse, } from './billing.js';
16
16
  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
17
  export const ROUTE_SECTIONS = [
18
18
  { id: 'health', title: 'Health' },
@@ -2914,22 +2914,29 @@ export const ROUTES = [
2914
2914
  },
2915
2915
  {
2916
2916
  method: 'POST', path: '/api/billing/checkout', section: 'billing',
2917
- summary: 'Starts a Mollie checkout for a plan, or an upgrade paid at once.',
2917
+ summary: "Records a company purchase intent for the first paid plan.",
2918
2918
  audience: 'developer', auth: 'developer', rateLimited: true, ownerTier: true, status: 201,
2919
2919
  params: [], query: null, request: checkoutRequest, response: checkoutResponse,
2920
2920
  errors: [...DEVELOPER_GUARD, 'tier_required', 'validation_error', 'plan_limit', 'target_state_conflict', 'rate_limited', ...BILLING_OFF, ...MOLLIE],
2921
2921
  transport: 'http',
2922
- notes: 'Rate limited on the `billing.checkout` bucket, same as `POST /api/billing/payment-method` and `POST /api/billing/invoices/:id/pay` ' +
2923
- '— the three routes that mint a Mollie checkout. `400 validation_error` names who may not pay with these rules: ' +
2924
- '`{ field: \'billing.address.country\', rule: \'eu_person\' }` for a person in another EU country, ' +
2925
- '`{ field: \'billing.vat_id\', rule: \'vat_id_required\' }` for a company there with no VAT ID, ' +
2926
- '`{ field: \'billing.vat_id\', rule: \'vat_id_invalid\' }` once VIES has said so, and ' +
2927
- '`{ field: \'accept_withdrawal\', rule: \'required\' }` for a person who did not confirm it. `409 target_state_conflict` names ' +
2928
- '`plan` with rule `already_billed` when the org already has an `active` or `past_due` billing account — checkout is for the first ' +
2929
- 'payment only, every later change is `POST /api/billing/change`. `checkout_url` is Mollie\'s hosted page, where the payer ' +
2930
- 'chooses card, PayPal or Apple Pay; the return lands on ' +
2931
- '`<console>/settings/billing?checkout=<checkout_id>`, which polls `GET /api/billing/checkout/:id` until the webhook — or the poll ' +
2932
- 'itself — has reconciled the payment. `409 plan_limit` is the org\'s own usage against the plan being bought.',
2922
+ 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.",
2923
+ },
2924
+ {
2925
+ method: 'GET', path: '/api/billing/intents', section: 'billing',
2926
+ summary: 'Recovers a purchase intent by operation key or intent ID.',
2927
+ audience: 'developer', auth: 'developer', rateLimited: false, ownerTier: true, status: 200,
2928
+ params: [], query: purchaseIntentLookupQuery, request: null, response: purchaseIntentResponse,
2929
+ errors: [...DEVELOPER_GUARD, 'tier_required', 'validation_error', 'not_found'], transport: 'http',
2930
+ 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.',
2931
+ },
2932
+ {
2933
+ method: 'POST', path: '/api/billing/intents/:id/confirm', section: 'billing',
2934
+ summary: 'Confirms the current purchase quote exactly once.',
2935
+ audience: 'developer', auth: 'developer', rateLimited: true, ownerTier: true, status: 200,
2936
+ params: [{ name: 'id', description: 'The intent ID returned by the start or lookup response.' }],
2937
+ query: null, request: purchaseIntentConfirmRequest, response: purchaseIntentResponse,
2938
+ errors: [...DEVELOPER_GUARD, 'tier_required', 'validation_error', 'not_found', 'target_state_conflict', 'plan_limit', 'rate_limited', ...BILLING_OFF, ...MOLLIE], transport: 'http',
2939
+ 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.',
2933
2940
  },
2934
2941
  {
2935
2942
  method: 'GET', path: '/api/billing/checkout/:id', section: 'billing',
@@ -2945,64 +2952,37 @@ export const ROUTES = [
2945
2952
  },
2946
2953
  {
2947
2954
  method: 'POST', path: '/api/billing/vat-id/check', section: 'billing',
2948
- summary: 'Checks a VAT ID against VIES, for the checkout form and the details page.',
2955
+ summary: "Checks a VAT ID using requester-aware direct VIES.",
2949
2956
  audience: 'developer', auth: 'developer', rateLimited: true, ownerTier: true, status: 200,
2950
2957
  params: [], query: null, request: vatIdCheckRequest, response: vatIdCheckResponse,
2951
2958
  errors: [...DEVELOPER_GUARD, 'tier_required', 'validation_error', 'rate_limited'], transport: 'http',
2952
- 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 ' +
2953
- 'an `unverified` VIES answer — the checkout itself accepts `unverified` and the hourly sweep re-checks it — this route ' +
2954
- 'only reports what VIES currently says, in a different place for the same ID, entered either at checkout or on `PATCH ' +
2955
- '/api/billing/details`.',
2959
+ notes: "Reports status and optional display name only; full evidence stays in protected Finance storage. valid with a missing identifier remains pending/vies_identifier_missing. unverified or unavailable remains pending without zero rating or payment. A form check never authorizes a later charge; Cloud binds current evidence to the buyer and quote at confirmation. Rate limited on billing.vat_check.",
2956
2960
  },
2957
2961
  {
2958
2962
  method: 'PATCH', path: '/api/billing/details', section: 'billing',
2959
- summary: "Edits the billing account's invoice email or VAT ID.",
2963
+ summary: "Edits company billing details for revalidation before the next charge.",
2960
2964
  audience: 'developer', auth: 'developer', rateLimited: false, ownerTier: true, status: 200,
2961
2965
  params: [], query: null, request: billingDetailsUpdate, response: billingView,
2962
2966
  errors: [...DEVELOPER_GUARD, 'tier_required', 'validation_error', 'not_found'], transport: 'http',
2963
- 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` ' +
2964
- '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 ' +
2965
- '`invalid` answer placed on the next renewal.',
2967
+ notes: "404 not_found when no billing account exists. Edits may change company name, full address/state, Tax ID, VAT ID and invoice email. Validate the merged buyer before a later charge; edits invalidate old evidence and quote revisions. Revalidate the email policy and country requirements. An edit does not create a payment, activate a plan, pay an invoice, clear dunning or lift a lock.",
2966
2968
  },
2967
2969
  {
2968
2970
  method: 'POST', path: '/api/billing/change', section: 'billing',
2969
- summary: "Moves the org's plan, cycle or add-ons, charging increases at once.",
2971
+ summary: "Records a paid-change intent or schedules a decrease.",
2970
2972
  audience: 'developer', auth: 'developer', rateLimited: false, ownerTier: true, status: 200,
2971
2973
  params: [], query: null, request: billingChangeRequest, response: billingChangeResponse,
2972
2974
  errors: [...DEVELOPER_GUARD, 'tier_required', 'validation_error', 'plan_limit', 'target_state_conflict', ...BILLING_OFF, ...MOLLIE],
2973
2975
  transport: 'http',
2974
- notes: 'The body names the **absolute** target — plan, cycle and add-ons — never a delta: the route compares it with the ' +
2975
- 'org\'s current state and splits the difference. The increasing part is charged now, through the same proration `changeNetCents` ' +
2976
- 'computes, and takes effect the moment Mollie accepts the `recurring` payment with anything but `failed`, `canceled` or `expired` ' +
2977
- '— card mandates, Apple Pay\'s included, usually answer `paid` within seconds, a PayPal one may stay `pending` for a while; if it ' +
2978
- 'fails later, its open invoice enters dunning like a failed renewal. If Mollie refuses or does not answer, nothing is applied ' +
2979
- 'and this answers `502 payment_provider_unavailable` instead. The decreasing part — a lower plan, yearly → monthly, fewer add-ons — ' +
2980
- '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 ' +
2981
- 'limits answers `409 plan_limit` and the console opens its choose-what-stays page. Any increase first withdraws a pending ' +
2982
- 'downgrade or cancel, exactly as the admin route does. `409 target_state_conflict` names `billing` with rule `no_account` (no ' +
2983
- 'checkout yet — use `POST /api/billing/checkout`), `past_due` (an open invoice has to be paid first) or `no_valid_mandate` (the ' +
2984
- 'payment method needs renewing first, `POST /api/billing/payment-method`). `charged` in the response is the invoice from the part ' +
2985
- 'charged now, or `null` when the whole request was a decrease.',
2976
+ 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.",
2986
2977
  },
2987
2978
  {
2988
2979
  method: 'POST', path: '/api/billing/payment-method', section: 'billing',
2989
- summary: 'Starts a Mollie checkout for a new payment method.',
2980
+ summary: "Records an invoice-paying method intent or a held mandate setup.",
2990
2981
  audience: 'developer', auth: 'developer', rateLimited: true, ownerTier: true, status: 201,
2991
2982
  params: [], query: null, request: paymentMethodChangeRequest, response: checkoutResponse,
2992
- errors: [...DEVELOPER_GUARD, 'tier_required', 'validation_error', 'not_found', 'rate_limited', ...BILLING_OFF, ...MOLLIE],
2983
+ errors: ['target_state_conflict', ...DEVELOPER_GUARD, 'tier_required', 'validation_error', 'not_found', 'rate_limited', ...BILLING_OFF, ...MOLLIE],
2993
2984
  transport: 'http',
2994
- notes: 'Rate limited on the `billing.checkout` bucket, same as `POST /api/billing/checkout`. Creates a hosted `first` payment on the ' +
2995
- 'existing Mollie customer, restricted to the chosen method (`card` → Mollie\'s `creditcard`, `paypal`, `applepay`). For `card` ' +
2996
- '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 ' +
2997
- 'dunning retry charges the new mandate — except for an invoice that was charged back, which is never charged again ' +
2998
- 'automatically; pay it with `POST /api/billing/invoices/:id/pay` — and that route still pays any open invoice at once. ' +
2999
- '`applepay` behaves the ' +
3000
- 'same where Mollie accepts a zero-amount Apple Pay payment; where it does not, a change to Apple Pay is only offered together ' +
3001
- 'with paying an open invoice — the payment is then that invoice\'s amount and pays it — and without one this answers ' +
3002
- '`400 validation_error` with `{ field: \'method\', rule: \'applepay_needs_open_invoice\' }`. A client offers what ' +
3003
- '`payment_method_options` in `GET /api/billing` lists. `404 not_found` when the org has no billing account yet. When the new ' +
3004
- 'mandate turns `valid` it becomes the account\'s — an Apple Pay one is a card mandate, shown as `applepay` — and every other ' +
3005
- 'mandate of the customer is revoked.',
2985
+ notes: "Use a stable operation_key and owner intent lookup after reload/timeout. Offer payment_method_options. Apple Pay with zero-amount changes disabled pays an open invoice through operation payment_method_invoice; without one, 400 validation_error has field method and rule applepay_needs_open_invoice. Apply the same buyer/VIES gate, current-amount reconfirmation and USD legacy hold as invoices/:id/pay. Pending, eligible and held contain no checkout URL; redirect only on payment_started.payment.kind hosted. A 0.00 mandate-only setup uses operation mandate_setup and held/mandate_policy_unresolved until the integration decision settles eligibility and currency. It pays no invoice and clears no dunning or lock. An invoice charged back is never retried automatically. 404 not_found when no account exists. Same key with changed input is a typed operation_key_reused conflict.",
3006
2986
  },
3007
2987
  {
3008
2988
  method: 'POST', path: '/api/billing/cancel', section: 'billing',
@@ -3035,20 +3015,13 @@ export const ROUTES = [
3035
3015
  },
3036
3016
  {
3037
3017
  method: 'POST', path: '/api/billing/invoices/:id/pay', section: 'billing',
3038
- summary: 'Pays one open invoice, through a new Mollie payment.',
3018
+ summary: "Records an owner-confirmed payment intent for an open invoice or due charge.",
3039
3019
  audience: 'developer', auth: 'developer', rateLimited: true, ownerTier: true, status: 201,
3040
3020
  params: [{ name: 'id', description: 'The invoice id, from `billingInvoice.id`, of the open invoice to pay — or a due charge\'s id, from `dunning.invoice_id`.' }],
3041
- query: null, request: null, response: checkoutResponse,
3042
- errors: [...DEVELOPER_GUARD, 'tier_required', 'not_found', 'target_state_conflict', 'rate_limited', ...BILLING_OFF, ...MOLLIE],
3021
+ query: null, request: invoicePayRequest, response: checkoutResponse,
3022
+ errors: ['validation_error', ...DEVELOPER_GUARD, 'tier_required', 'not_found', 'target_state_conflict', 'rate_limited', ...BILLING_OFF, ...MOLLIE],
3043
3023
  transport: 'http',
3044
- notes: 'Rate limited on the `billing.checkout` bucket, same as `POST /api/billing/checkout`. `409 target_state_conflict` names `invoice` ' +
3045
- 'with rule `not_open` when the invoice is already `paid` or `uncollectible` — there is nothing left to pay. Paying the open ' +
3046
- 'invoice of a locked org unlocks it and keeps the plan running to the period\'s end, the same as a renewal that ' +
3047
- 'succeeds on a retry. `:id` may also be a due charge\'s id from `dunning.invoice_id` in `GET /api/billing`: while the payer\'s ' +
3048
- 'VAT ID is unsettled a held renewal is a due charge that has no number yet, and it is numbered and issued as an invoice ' +
3049
- 'once this payment is paid. The payment charges the amount owed (`dunning.gross_cents`). While that due charge is held by ' +
3050
- 'the VAT ID this answers `409 target_state_conflict` with `{ field: \'billing\', rule: \'vat_id_invalid\' }`. ' +
3051
- '`404 not_found` for an unknown id or one from another org.',
3024
+ notes: "The required operation_key binds the org, invoice and request; reuse with changed input is 409 target_state_conflict (purchaseConflictDetails). :id may be an issued invoice or a due charge with no number. Recheck current buyer eligibility, VIES, invoice status, owed amount and original currency before every new provider call. Invalid VAT is state invalid_vat_id with rule vat_id_invalid, without a payment. Pending/eligible/held has no redirect; after VIES recovers, the owner must confirm the current quote. An issued USD invoice remains held/legacy_usd_invoice: never convert it or call the provider anew until the integration decision resolves the conflict. Already-created payments retain recorded currency/amount and are looked up/reconciled, never replaced. Under the org lock, confirmation checks the current owed amount and returns the same payment identity on retries. invoice_not_open is a typed conflict; 404 not_found for unknown/foreign invoice. Pending itself never pays an invoice, lifts a lock or resets dunning.",
3052
3025
  },
3053
3026
  {
3054
3027
  method: 'POST', path: '/api/billing/mollie/webhook', section: 'billing',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fleetless/contracts",
3
- "version": "6.5.0",
3
+ "version": "7.0.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",