@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
package/dist/billing.js CHANGED
@@ -1,6 +1,12 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  import { z } from 'zod';
3
- import { ADDONS, PLANS, PLAN_ORDER, addonKey, orgAddons, planCurrency, planId, } from './plans.js';
3
+ import { ADDONS, PLANS, PLAN_ORDER, addonKey, orgAddons, planCurrency, planId, planChangeKeep, } from './plans.js';
4
+ import { legalDocumentReference } from './legal.js';
5
+ import { purchaseOperationKey } from './purchase-operation-key.js';
6
+ import { confirmationProof } from './confirmation-proof.js';
7
+ import { ianaTimeZones } from './iana-time-zones.js';
8
+ export { purchaseOperationKey } from './purchase-operation-key.js';
9
+ export { confirmationProof } from './confirmation-proof.js';
4
10
  /**
5
11
  * Countries, VAT and the money math for billing through Mollie
6
12
  * (fleetless/fleetless#104).
@@ -297,7 +303,6 @@ export const purchaseBillingDetails = billingDetails.options[0].superRefine((pay
297
303
  }
298
304
  }).meta({ description: 'New company purchase. Other EU countries require VAT ID; non-EU requires Tax ID; US requires two-letter state. Cloud additionally checks the versioned public-email policy and current VIES evidence.' });
299
305
  /** Generate before POST, persist across reloads; unique within the authenticated org. */
300
- export const purchaseOperationKey = z.uuid().meta({ description: 'Client-generated UUID persisted before the start request. Unique per org and reused only for identical input.' });
301
306
  export const purchaseOperation = z.enum(['checkout', 'paid_change', 'invoice_payment', 'payment_method_invoice', 'mandate_setup']);
302
307
  const chargeOperation = purchaseOperation.exclude(['mandate_setup']);
303
308
  /** Starting a checkout records an intent; only confirming its current quote may create a payment. */
@@ -307,7 +312,7 @@ export const checkoutRequest = z.object({
307
312
  cycle: billingCycle.meta({ description: 'Monthly, or yearly at 15 percent off.' }),
308
313
  addons: orgAddons.partial().strict().optional().meta({ description: 'Add-on units to buy; Pro only. Cloud refuses add-ons on Plus.' }),
309
314
  billing: purchaseBillingDetails.meta({ description: 'The company buying the plan. Country requirements, current VIES and the email policy must pass before charging.' }),
310
- accept_terms: z.literal(true).meta({ description: 'Confirms the terms of service for this purchase.' }),
315
+ accept_terms: z.literal(true).optional().meta({ description: 'Deprecated draft input. It is not evidence of a displayed C.4 declaration and never confirms an order.' }),
311
316
  }).strict();
312
317
  const purchaseCents = z.number().int().nonnegative();
313
318
  /** Current amount to confirm. Issued USD invoices must be held, never relabelled EUR. */
@@ -318,16 +323,155 @@ export const purchaseQuote = z.object({
318
323
  gross_cents: purchaseCents.meta({ description: 'Total to confirm, including VAT, in cents.' }),
319
324
  rate_percent: z.number().int().min(0).max(100).meta({ description: 'VAT rate in whole percent.' }),
320
325
  }).strict();
326
+ const quoteIdentity = {
327
+ quote_revision: z.string().trim().min(1).max(200).meta({ description: 'Opaque revision of the displayed quote; echo it when confirming.' }),
328
+ buyer_fingerprint: z.string().trim().min(1).max(200).meta({ description: 'Opaque revision of buyer details and email policy; never full VIES evidence.' }),
329
+ };
330
+ /** Cloud issues a display only for an eligible, current customer decision. */
331
+ export const billingDecisionDisplayRequest = z.object({
332
+ operation_key: purchaseOperationKey,
333
+ operation: z.enum(['checkout', 'paid_change']),
334
+ }).strict();
335
+ const selectionBase = {
336
+ plan: z.enum(['basic', 'plus', 'pro']),
337
+ cycle: billingCycle,
338
+ addons: orgAddons,
339
+ };
340
+ const purchaseSelection = z.object(selectionBase).strict();
341
+ const planChangeSelection = z.object({ ...selectionBase, keep: planChangeKeep.nullable() }).strict();
342
+ const addonLine = z.object({ addon: addonKey, quantity: z.number().int().positive(), net_cents: purchaseCents }).strict();
343
+ const treatmentRules = [
344
+ { if: { properties: { vat_treatment: { const: 'de_standard' } }, required: ['vat_treatment'] }, then: { properties: { quote: { properties: { rate_percent: { const: 19 } } } } } },
345
+ { if: { properties: { vat_treatment: { const: 'reverse_charge' } }, required: ['vat_treatment'] }, then: { properties: { quote: { properties: { rate_percent: { const: 0 }, vat_cents: { const: 0 } } }, period_vat_cents: { const: 0 }, vat_treatment_line: { const: 'Reverse charge — VAT payable by the recipient' } } } },
346
+ { if: { properties: { vat_treatment: { const: 'outside_eu' } }, required: ['vat_treatment'] }, then: { properties: { quote: { properties: { rate_percent: { const: 0 }, vat_cents: { const: 0 } } }, period_vat_cents: { const: 0 }, vat_treatment_line: { const: 'Not taxable in Germany' } } } },
347
+ ];
348
+ export const billingDecisionAmounts = z.object({
349
+ currency: z.literal('eur'),
350
+ quote: purchaseQuote,
351
+ plan_net_cents: purchaseCents,
352
+ addon_lines: z.array(addonLine),
353
+ period_net_cents: purchaseCents,
354
+ period_vat_cents: purchaseCents,
355
+ period_gross_cents: purchaseCents,
356
+ vat_treatment: vatTreatment,
357
+ vat_treatment_line: z.string().min(1),
358
+ due_today_gross_cents: purchaseCents,
359
+ prorated_net_cents: purchaseCents.nullable(),
360
+ renewal_net_cents: purchaseCents,
361
+ }).strict().superRefine((value, ctx) => {
362
+ const invalid = (field, message) => ctx.addIssue({ code: 'custom', path: [field], message });
363
+ if (value.quote.gross_cents !== value.quote.net_cents + value.quote.vat_cents)
364
+ invalid('quote', 'Quote gross must equal net plus VAT.');
365
+ if (value.period_gross_cents !== value.period_net_cents + value.period_vat_cents)
366
+ invalid('period_gross_cents', 'Period gross must equal net plus VAT.');
367
+ if (value.period_net_cents !== value.plan_net_cents + value.addon_lines.reduce((sum, line) => sum + line.net_cents, 0))
368
+ invalid('period_net_cents', 'Plan and add-on lines must reconcile.');
369
+ if (value.due_today_gross_cents !== value.quote.gross_cents)
370
+ invalid('due_today_gross_cents', 'Due today must equal the quote gross.');
371
+ if (value.vat_treatment === 'de_standard') {
372
+ if (value.quote.rate_percent !== 19 || !value.vat_treatment_line.startsWith('19% German VAT: '))
373
+ invalid('vat_treatment', 'German VAT requires 19 percent and its display line.');
374
+ }
375
+ else if (value.quote.rate_percent !== 0 || value.quote.vat_cents !== 0 || value.period_vat_cents !== 0 || value.vat_treatment_line !== (value.vat_treatment === 'reverse_charge' ? 'Reverse charge — VAT payable by the recipient' : 'Not taxable in Germany')) {
376
+ invalid('vat_treatment', 'Zero-rated treatment, rate, VAT and line must agree.');
377
+ }
378
+ }).meta({ allOf: treatmentRules });
379
+ const utcInstant = z.iso.datetime().regex(/Z$/);
380
+ const ianaTimeZone = z.enum(ianaTimeZones);
381
+ function localDate(instant, timeZone) {
382
+ try {
383
+ const parts = new Intl.DateTimeFormat('en-US', { timeZone, year: 'numeric', month: '2-digit', day: '2-digit' }).formatToParts(new Date(instant));
384
+ const get = (type) => parts.find((part) => part.type === type)?.value ?? '';
385
+ return `${get('year')}-${get('month')}-${get('day')}`;
386
+ }
387
+ catch {
388
+ return null;
389
+ }
390
+ }
391
+ export const billingDecisionPeriod = z.object({
392
+ display_time_zone: ianaTimeZone,
393
+ starts_on: z.iso.date(),
394
+ starts_at: utcInstant.nullable(),
395
+ current_period_ends_at: utcInstant,
396
+ renews_at: utcInstant,
397
+ effective: z.discriminatedUnion('mode', [
398
+ z.object({ mode: z.literal('on_confirmation'), quoted_as_of_at: utcInstant, local_date: z.iso.date() }).strict(),
399
+ z.object({ mode: z.literal('scheduled'), at: utcInstant, at_period_end: z.boolean() }).strict(),
400
+ ]),
401
+ }).strict().superRefine((period, ctx) => {
402
+ if (period.starts_at && localDate(period.starts_at, period.display_time_zone) !== period.starts_on)
403
+ ctx.addIssue({ code: 'custom', path: ['starts_on'], message: 'Start date must match the instant in the display zone.' });
404
+ if (period.effective.mode === 'scheduled' && period.effective.at_period_end && period.effective.at !== period.current_period_ends_at)
405
+ ctx.addIssue({ code: 'custom', path: ['effective', 'at'], message: 'Period-end effect must equal the current period boundary.' });
406
+ if (period.effective.mode === 'on_confirmation' && localDate(period.effective.quoted_as_of_at, period.display_time_zone) !== period.effective.local_date)
407
+ ctx.addIssue({ code: 'custom', path: ['effective', 'local_date'], message: 'Quoted local date must match the display zone.' });
408
+ });
409
+ const declaration = z.object({
410
+ text_id: z.literal('DR-1374-draft-3-C.4'),
411
+ text: z.string().min(1),
412
+ terms: legalDocumentReference,
413
+ dpa: legalDocumentReference,
414
+ }).strict().superRefine((value, ctx) => {
415
+ if (value.terms.url === value.dpa.url)
416
+ ctx.addIssue({ code: 'custom', path: ['dpa'], message: 'Terms and DPA require separate version URLs.' });
417
+ });
418
+ const snapshotBase = z.object({
419
+ snapshot_id: z.uuid(),
420
+ decision_id: z.uuid(),
421
+ operation_key: purchaseOperationKey,
422
+ owner_id: z.uuid(),
423
+ organization_id: z.uuid(),
424
+ organization_name: z.string().min(1),
425
+ ...quoteIdentity,
426
+ amounts: billingDecisionAmounts,
427
+ period: billingDecisionPeriod,
428
+ declaration,
429
+ expires_at: utcInstant,
430
+ }).strict();
431
+ export const billingDecisionSnapshot = z.discriminatedUnion('decision_kind', [
432
+ snapshotBase.extend({ decision_kind: z.literal('checkout'), selection: purchaseSelection }).strict(),
433
+ snapshotBase.extend({ decision_kind: z.literal('paid_change'), selection: purchaseSelection }).strict(),
434
+ snapshotBase.extend({ decision_kind: z.literal('plan_change'), selection: planChangeSelection }).strict(),
435
+ ]).superRefine((value, ctx) => {
436
+ const expected = `By selecting “Order and pay”, you agree to the Terms of Service and the Data Processing Agreement for ${value.organization_name}.`;
437
+ if (value.declaration.text !== expected)
438
+ ctx.addIssue({ code: 'custom', path: ['declaration', 'text'], message: 'Declaration must match the approved C.4 sentence and organization.' });
439
+ if (value.amounts.vat_treatment === 'de_standard') {
440
+ const euro = (cents) => new Intl.NumberFormat('en-US', { style: 'currency', currency: 'EUR' }).format(cents / 100);
441
+ const period = value.selection.cycle === 'monthly' ? 'month' : 'year';
442
+ const line = `19% German VAT: ${euro(value.amounts.period_vat_cents)}; total ${euro(value.amounts.period_gross_cents)} per ${period}`;
443
+ if (value.amounts.vat_treatment_line !== line)
444
+ ctx.addIssue({ code: 'custom', path: ['amounts', 'vat_treatment_line'], message: 'German VAT line must match the displayed period amounts and cycle.' });
445
+ }
446
+ const lines = value.amounts.addon_lines;
447
+ const expectedAddons = addonKey.options.filter((key) => value.selection.addons[key] > 0);
448
+ if (lines.length !== expectedAddons.length || lines.some((line, i) => line.addon !== expectedAddons[i] || line.quantity !== value.selection.addons[line.addon]))
449
+ ctx.addIssue({ code: 'custom', path: ['amounts', 'addon_lines'], message: 'Add-on lines must match absolute selection in catalogue order.' });
450
+ });
451
+ export const billingDecisionDisplayResponse = z.object({
452
+ confirmation_proof: confirmationProof,
453
+ expires_at: utcInstant,
454
+ snapshot: billingDecisionSnapshot,
455
+ }).strict().superRefine((value, ctx) => {
456
+ if (value.expires_at !== value.snapshot.expires_at)
457
+ ctx.addIssue({ code: 'custom', path: ['expires_at'], message: 'Display and snapshot expiry must match.' });
458
+ });
459
+ /** A prepared downward plan change carries the same Cloud-issued display. */
460
+ export const planChangePrepareResponse = z.object({
461
+ change_id: z.uuid(),
462
+ display: billingDecisionDisplayResponse,
463
+ }).strict().superRefine((value, ctx) => {
464
+ if (value.display.snapshot.decision_kind !== 'plan_change')
465
+ ctx.addIssue({ code: 'custom', path: ['display', 'snapshot', 'decision_kind'], message: 'Prepared plan changes require a plan-change display.' });
466
+ if (value.display.snapshot.decision_id !== value.change_id)
467
+ ctx.addIssue({ code: 'custom', path: ['display', 'snapshot', 'decision_id'], message: 'Display must refer to the prepared change.' });
468
+ }).meta({ allOf: [{ properties: { display: { properties: { snapshot: { properties: { decision_kind: { const: 'plan_change' } } } } } } }] });
321
469
  const intentIdentity = {
322
470
  intent_id: z.uuid().meta({ description: 'Opaque persisted purchase intent identity.' }),
323
471
  operation_key: purchaseOperationKey,
324
472
  operation: chargeOperation,
325
473
  invoice_id: z.uuid().optional().meta({ description: 'The due charge or issued invoice, for invoice-paying operations.' }),
326
474
  };
327
- const quoteIdentity = {
328
- quote_revision: z.string().trim().min(1).max(200).meta({ description: 'Opaque revision of the displayed quote; echo it when confirming.' }),
329
- buyer_fingerprint: z.string().trim().min(1).max(200).meta({ description: 'Opaque revision of buyer details and email policy; never full VIES evidence.' }),
330
- };
331
475
  export const purchaseHoldReason = z.enum([
332
476
  'legacy_usd_invoice', 'legacy_payer_unresolved', 'mandate_policy_unresolved',
333
477
  // The Lexware issuer cutover (2026-10-19, fleetless/fleetless#327): holds
@@ -355,8 +499,8 @@ function validateIntent(intent, ctx) {
355
499
  ctx.addIssue({ code: 'custom', path: ['payment'], message: 'Owner checkout and invoice payment require a hosted payment.' });
356
500
  }
357
501
  }
358
- /** Public owner read. No unpaid state can contain a provider redirect. */
359
- export const purchaseIntent = z.discriminatedUnion('state', [
502
+ /** Unaccepted intents. No draft contains a provider redirect or billing decision. */
503
+ const draftVariants = [
360
504
  z.object({ ...intentIdentity, state: z.literal('awaiting_vies'), reason: viesPendingReason, next_attempt_at: z.iso.datetime() }).strict(),
361
505
  z.object({ ...intentIdentity, ...quoteIdentity, state: z.literal('eligible'), quote: purchaseQuote }).strict(),
362
506
  z.object({
@@ -366,16 +510,51 @@ export const purchaseIntent = z.discriminatedUnion('state', [
366
510
  }).strict(),
367
511
  z.object({ ...intentIdentity, state: z.literal('invalid_vat_id'), field: z.literal('billing.vat_id'), rule: z.literal('vat_id_invalid') }).strict(),
368
512
  z.object({ ...intentIdentity, state: z.literal('refused'), field: z.string().min(1), rule: purchaseRefusalRule }).strict(),
369
- z.object({
370
- ...intentIdentity, state: z.literal('payment_started'), payment_id: z.uuid(),
371
- payment: z.discriminatedUnion('kind', [
372
- z.object({ kind: z.literal('hosted'), checkout_id: z.uuid(), checkout_url: z.url() }).strict(),
373
- z.object({ kind: z.literal('mandate') }).strict(),
374
- ]),
375
- }).strict(),
513
+ ];
514
+ export const purchaseIntentDraft = z.discriminatedUnion('state', draftVariants).superRefine(validateIntent).meta({ allOf: intentRules });
515
+ const paymentStartedVariant = z.object({
516
+ ...intentIdentity, state: z.literal('payment_started'), payment_id: z.uuid(),
517
+ payment: z.discriminatedUnion('kind', [
518
+ z.object({ kind: z.literal('hosted'), checkout_id: z.uuid(), checkout_url: z.url() }).strict(),
519
+ z.object({ kind: z.literal('mandate') }).strict(),
520
+ ]),
521
+ }).strict();
522
+ export const purchaseIntentPaymentStarted = paymentStartedVariant.superRefine(validateIntent).meta({ allOf: intentRules });
523
+ export const purchaseIntentAcceptedWithoutPayment = z.object({
524
+ intent_id: z.uuid(),
525
+ operation_key: purchaseOperationKey,
526
+ operation: z.literal('paid_change'),
527
+ state: z.literal('accepted_no_payment'),
528
+ ...quoteIdentity,
529
+ quote: purchaseQuote.extend({ net_cents: z.literal(0), vat_cents: z.literal(0), gross_cents: z.literal(0) }).strict(),
530
+ accepted_at: utcInstant,
531
+ }).strict();
532
+ /** Public owner read. Accepted zero-charge changes have no provider payment. */
533
+ export const purchaseIntent = z.discriminatedUnion('state', [
534
+ ...draftVariants, paymentStartedVariant, purchaseIntentAcceptedWithoutPayment,
535
+ ]).superRefine(validateIntent).meta({ allOf: intentRules });
536
+ /** Shared by checkout, invoice payment and method change. Paid changes use their own response. */
537
+ const nonChangeOperation = purchaseOperation.exclude(['paid_change']);
538
+ const nonChangeChargeOperation = chargeOperation.exclude(['paid_change']);
539
+ const nonChangeDraft = z.discriminatedUnion('state', [
540
+ draftVariants[0].safeExtend({ operation: nonChangeChargeOperation }),
541
+ draftVariants[1].safeExtend({ operation: nonChangeChargeOperation }),
542
+ draftVariants[2].safeExtend({ operation: nonChangeOperation }),
543
+ draftVariants[3].safeExtend({ operation: nonChangeChargeOperation }),
544
+ draftVariants[4].safeExtend({ operation: nonChangeChargeOperation }),
545
+ ]).superRefine(validateIntent).meta({ allOf: intentRules });
546
+ const nonChangePaymentStarted = paymentStartedVariant
547
+ .safeExtend({ operation: nonChangeChargeOperation })
548
+ .superRefine(validateIntent).meta({ allOf: intentRules });
549
+ const paidChangeOperation = z.literal('paid_change');
550
+ const paidChangeDraft = z.discriminatedUnion('state', [
551
+ draftVariants[0].safeExtend({ operation: paidChangeOperation }),
552
+ draftVariants[1].safeExtend({ operation: paidChangeOperation }),
553
+ draftVariants[2].safeExtend({ operation: paidChangeOperation }),
554
+ draftVariants[3].safeExtend({ operation: paidChangeOperation }),
555
+ draftVariants[4].safeExtend({ operation: paidChangeOperation }),
376
556
  ]).superRefine(validateIntent).meta({ allOf: intentRules });
377
- /** Shared by checkout, invoice payment and method change. Mandate-only setup remains held. */
378
- export const checkoutResponse = purchaseIntent;
557
+ export const checkoutResponse = z.union([nonChangeDraft, nonChangePaymentStarted]);
379
558
  /** Lookup needs one identity, plus the expected operation; a mismatch discloses nothing. */
380
559
  export const purchaseIntentLookupQuery = z.object({
381
560
  operation_key: purchaseOperationKey.optional().meta({ description: 'The client operation key; supply this or intent_id, never both.' }),
@@ -390,9 +569,14 @@ export const purchaseIntentLookupQuery = z.object({
390
569
  { required: ['intent_id'], not: { required: ['operation_key'] } },
391
570
  ],
392
571
  });
393
- export const purchaseIntentConfirmRequest = z.object({
394
- operation_key: purchaseOperationKey, operation: chargeOperation, ...quoteIdentity,
395
- }).strict();
572
+ const provedConfirmation = { operation_key: purchaseOperationKey, ...quoteIdentity, confirmation_proof: confirmationProof };
573
+ const invoiceConfirmation = { operation_key: purchaseOperationKey, ...quoteIdentity };
574
+ export const purchaseIntentConfirmRequest = z.discriminatedUnion('operation', [
575
+ z.object({ ...provedConfirmation, operation: z.literal('checkout') }).strict(),
576
+ z.object({ ...provedConfirmation, operation: z.literal('paid_change') }).strict(),
577
+ z.object({ ...invoiceConfirmation, operation: z.literal('invoice_payment') }).strict(),
578
+ z.object({ ...invoiceConfirmation, operation: z.literal('payment_method_invoice') }).strict(),
579
+ ]);
396
580
  /** `409 target_state_conflict` details. Stale confirmation returns the new owner-visible intent. */
397
581
  export const purchaseConflictDetails = z.discriminatedUnion('rule', [
398
582
  z.object({ field: z.literal('operation_key'), rule: z.literal('operation_key_reused') }).strict(),
@@ -756,18 +940,29 @@ export const billingDocumentDetail = billingDocumentBase
756
940
  export const billingDocumentFileQuery = z.object({
757
941
  format: billingDocumentFormat.default('pdf').meta({ description: 'The file format to read. `xml` answers `404` unless the document is `XRechnung`.' }),
758
942
  }).strict();
759
- /** `POST /api/billing/change`'s answer: the billing view afterwards, and what was charged right now, if anything. */
760
- const acceptedBillingChange = z.object({
943
+ /** Accepted paid changes retain their provider identity; accepted no-payment changes have none. */
944
+ const acceptedBillingFields = {
761
945
  billing: billingView.meta({ description: 'The billing view after the change.' }),
762
946
  charged: billingInvoice.nullable().meta({ description: 'The invoice charged now, or `null` when the change was only scheduled for the period\'s end.' }),
947
+ };
948
+ const acceptedPaidChange = z.object({
949
+ ...acceptedBillingFields,
950
+ intent: paymentStartedVariant.safeExtend({ operation: z.literal('paid_change') }),
951
+ }).strict();
952
+ const acceptedNoPaymentChange = z.object({
953
+ billing: billingView,
954
+ charged: z.null(),
955
+ intent: purchaseIntentAcceptedWithoutPayment,
763
956
  }).strict();
764
957
  export const billingChangeResponse = z.union([
765
- acceptedBillingChange,
766
- z.object({ intent: purchaseIntent }).strict(),
767
- z.object({ ...acceptedBillingChange.shape, intent: purchaseIntent.options[5].superRefine(validateIntent).meta({ allOf: intentRules }) }).strict(),
958
+ z.object({ intent: paidChangeDraft }).strict(),
959
+ acceptedPaidChange,
960
+ acceptedNoPaymentChange,
768
961
  ]);
769
- /** Confirmation/lookup recovers the same payment, and the resulting view for a paid change. */
962
+ /** Confirmation/lookup recover the original decision, never a bare accepted change. */
770
963
  export const purchaseIntentResponse = z.union([
771
- purchaseIntent,
772
- z.object({ ...acceptedBillingChange.shape, intent: purchaseIntent.options[5].superRefine(validateIntent).meta({ allOf: intentRules }) }).strict(),
964
+ purchaseIntentDraft,
965
+ nonChangePaymentStarted,
966
+ acceptedPaidChange,
967
+ acceptedNoPaymentChange,
773
968
  ]);
@@ -0,0 +1,5 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ import { z } from 'zod';
3
+ /** Syntax only: Cloud verifies the stored proof binding and expiry. */
4
+ export declare const confirmationProof: z.ZodString;
5
+ export type ConfirmationProof = z.infer<typeof confirmationProof>;
@@ -0,0 +1,6 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ import { z } from 'zod';
3
+ /** Syntax only: Cloud verifies the stored proof binding and expiry. */
4
+ export const confirmationProof = z.string().regex(/^[A-Za-z0-9_-]{43}$/).meta({
5
+ description: 'Opaque 32-byte Cloud proof, unpadded base64url. Syntax alone is not evidence.',
6
+ });
@@ -0,0 +1,2 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ export declare const ianaTimeZones: readonly ["UTC", "Etc/UTC", "Etc/GMT", "Africa/Abidjan", "Africa/Accra", "Africa/Addis_Ababa", "Africa/Algiers", "Africa/Asmera", "Africa/Bamako", "Africa/Bangui", "Africa/Banjul", "Africa/Bissau", "Africa/Blantyre", "Africa/Brazzaville", "Africa/Bujumbura", "Africa/Cairo", "Africa/Casablanca", "Africa/Ceuta", "Africa/Conakry", "Africa/Dakar", "Africa/Dar_es_Salaam", "Africa/Djibouti", "Africa/Douala", "Africa/El_Aaiun", "Africa/Freetown", "Africa/Gaborone", "Africa/Harare", "Africa/Johannesburg", "Africa/Juba", "Africa/Kampala", "Africa/Khartoum", "Africa/Kigali", "Africa/Kinshasa", "Africa/Lagos", "Africa/Libreville", "Africa/Lome", "Africa/Luanda", "Africa/Lubumbashi", "Africa/Lusaka", "Africa/Malabo", "Africa/Maputo", "Africa/Maseru", "Africa/Mbabane", "Africa/Mogadishu", "Africa/Monrovia", "Africa/Nairobi", "Africa/Ndjamena", "Africa/Niamey", "Africa/Nouakchott", "Africa/Ouagadougou", "Africa/Porto-Novo", "Africa/Sao_Tome", "Africa/Tripoli", "Africa/Tunis", "Africa/Windhoek", "America/Adak", "America/Anchorage", "America/Anguilla", "America/Antigua", "America/Araguaina", "America/Argentina/La_Rioja", "America/Argentina/Rio_Gallegos", "America/Argentina/Salta", "America/Argentina/San_Juan", "America/Argentina/San_Luis", "America/Argentina/Tucuman", "America/Argentina/Ushuaia", "America/Aruba", "America/Asuncion", "America/Bahia", "America/Bahia_Banderas", "America/Barbados", "America/Belem", "America/Belize", "America/Blanc-Sablon", "America/Boa_Vista", "America/Bogota", "America/Boise", "America/Buenos_Aires", "America/Cambridge_Bay", "America/Campo_Grande", "America/Cancun", "America/Caracas", "America/Catamarca", "America/Cayenne", "America/Cayman", "America/Chicago", "America/Chihuahua", "America/Ciudad_Juarez", "America/Coral_Harbour", "America/Cordoba", "America/Costa_Rica", "America/Coyhaique", "America/Creston", "America/Cuiaba", "America/Curacao", "America/Danmarkshavn", "America/Dawson", "America/Dawson_Creek", "America/Denver", "America/Detroit", "America/Dominica", "America/Edmonton", "America/Eirunepe", "America/El_Salvador", "America/Fort_Nelson", "America/Fortaleza", "America/Glace_Bay", "America/Godthab", "America/Goose_Bay", "America/Grand_Turk", "America/Grenada", "America/Guadeloupe", "America/Guatemala", "America/Guayaquil", "America/Guyana", "America/Halifax", "America/Havana", "America/Hermosillo", "America/Indiana/Knox", "America/Indiana/Marengo", "America/Indiana/Petersburg", "America/Indiana/Tell_City", "America/Indiana/Vevay", "America/Indiana/Vincennes", "America/Indiana/Winamac", "America/Indianapolis", "America/Inuvik", "America/Iqaluit", "America/Jamaica", "America/Jujuy", "America/Juneau", "America/Kentucky/Monticello", "America/Kralendijk", "America/La_Paz", "America/Lima", "America/Los_Angeles", "America/Louisville", "America/Lower_Princes", "America/Maceio", "America/Managua", "America/Manaus", "America/Marigot", "America/Martinique", "America/Matamoros", "America/Mazatlan", "America/Mendoza", "America/Menominee", "America/Merida", "America/Metlakatla", "America/Mexico_City", "America/Miquelon", "America/Moncton", "America/Monterrey", "America/Montevideo", "America/Montserrat", "America/Nassau", "America/New_York", "America/Nome", "America/Noronha", "America/North_Dakota/Beulah", "America/North_Dakota/Center", "America/North_Dakota/New_Salem", "America/Ojinaga", "America/Panama", "America/Paramaribo", "America/Phoenix", "America/Port-au-Prince", "America/Port_of_Spain", "America/Porto_Velho", "America/Puerto_Rico", "America/Punta_Arenas", "America/Rankin_Inlet", "America/Recife", "America/Regina", "America/Resolute", "America/Rio_Branco", "America/Santarem", "America/Santiago", "America/Santo_Domingo", "America/Sao_Paulo", "America/Scoresbysund", "America/Sitka", "America/St_Barthelemy", "America/St_Johns", "America/St_Kitts", "America/St_Lucia", "America/St_Thomas", "America/St_Vincent", "America/Swift_Current", "America/Tegucigalpa", "America/Thule", "America/Tijuana", "America/Toronto", "America/Tortola", "America/Vancouver", "America/Whitehorse", "America/Winnipeg", "America/Yakutat", "Antarctica/Casey", "Antarctica/Davis", "Antarctica/DumontDUrville", "Antarctica/Macquarie", "Antarctica/Mawson", "Antarctica/McMurdo", "Antarctica/Palmer", "Antarctica/Rothera", "Antarctica/Syowa", "Antarctica/Troll", "Antarctica/Vostok", "Arctic/Longyearbyen", "Asia/Aden", "Asia/Almaty", "Asia/Amman", "Asia/Anadyr", "Asia/Aqtau", "Asia/Aqtobe", "Asia/Ashgabat", "Asia/Atyrau", "Asia/Baghdad", "Asia/Bahrain", "Asia/Baku", "Asia/Bangkok", "Asia/Barnaul", "Asia/Beirut", "Asia/Bishkek", "Asia/Brunei", "Asia/Calcutta", "Asia/Chita", "Asia/Colombo", "Asia/Damascus", "Asia/Dhaka", "Asia/Dili", "Asia/Dubai", "Asia/Dushanbe", "Asia/Famagusta", "Asia/Gaza", "Asia/Hebron", "Asia/Hong_Kong", "Asia/Hovd", "Asia/Irkutsk", "Asia/Jakarta", "Asia/Jayapura", "Asia/Jerusalem", "Asia/Kabul", "Asia/Kamchatka", "Asia/Karachi", "Asia/Katmandu", "Asia/Khandyga", "Asia/Krasnoyarsk", "Asia/Kuala_Lumpur", "Asia/Kuching", "Asia/Kuwait", "Asia/Macau", "Asia/Magadan", "Asia/Makassar", "Asia/Manila", "Asia/Muscat", "Asia/Nicosia", "Asia/Novokuznetsk", "Asia/Novosibirsk", "Asia/Omsk", "Asia/Oral", "Asia/Phnom_Penh", "Asia/Pontianak", "Asia/Pyongyang", "Asia/Qatar", "Asia/Qostanay", "Asia/Qyzylorda", "Asia/Rangoon", "Asia/Riyadh", "Asia/Saigon", "Asia/Sakhalin", "Asia/Samarkand", "Asia/Seoul", "Asia/Shanghai", "Asia/Singapore", "Asia/Srednekolymsk", "Asia/Taipei", "Asia/Tashkent", "Asia/Tbilisi", "Asia/Tehran", "Asia/Thimphu", "Asia/Tokyo", "Asia/Tomsk", "Asia/Ulaanbaatar", "Asia/Urumqi", "Asia/Ust-Nera", "Asia/Vientiane", "Asia/Vladivostok", "Asia/Yakutsk", "Asia/Yekaterinburg", "Asia/Yerevan", "Atlantic/Azores", "Atlantic/Bermuda", "Atlantic/Canary", "Atlantic/Cape_Verde", "Atlantic/Faeroe", "Atlantic/Madeira", "Atlantic/Reykjavik", "Atlantic/South_Georgia", "Atlantic/St_Helena", "Atlantic/Stanley", "Australia/Adelaide", "Australia/Brisbane", "Australia/Broken_Hill", "Australia/Darwin", "Australia/Eucla", "Australia/Hobart", "Australia/Lindeman", "Australia/Lord_Howe", "Australia/Melbourne", "Australia/Perth", "Australia/Sydney", "Europe/Amsterdam", "Europe/Andorra", "Europe/Astrakhan", "Europe/Athens", "Europe/Belgrade", "Europe/Berlin", "Europe/Bratislava", "Europe/Brussels", "Europe/Bucharest", "Europe/Budapest", "Europe/Busingen", "Europe/Chisinau", "Europe/Copenhagen", "Europe/Dublin", "Europe/Gibraltar", "Europe/Guernsey", "Europe/Helsinki", "Europe/Isle_of_Man", "Europe/Istanbul", "Europe/Jersey", "Europe/Kaliningrad", "Europe/Kiev", "Europe/Kirov", "Europe/Lisbon", "Europe/Ljubljana", "Europe/London", "Europe/Luxembourg", "Europe/Madrid", "Europe/Malta", "Europe/Mariehamn", "Europe/Minsk", "Europe/Monaco", "Europe/Moscow", "Europe/Oslo", "Europe/Paris", "Europe/Podgorica", "Europe/Prague", "Europe/Riga", "Europe/Rome", "Europe/Samara", "Europe/San_Marino", "Europe/Sarajevo", "Europe/Saratov", "Europe/Simferopol", "Europe/Skopje", "Europe/Sofia", "Europe/Stockholm", "Europe/Tallinn", "Europe/Tirane", "Europe/Ulyanovsk", "Europe/Vaduz", "Europe/Vatican", "Europe/Vienna", "Europe/Vilnius", "Europe/Volgograd", "Europe/Warsaw", "Europe/Zagreb", "Europe/Zurich", "Indian/Antananarivo", "Indian/Chagos", "Indian/Christmas", "Indian/Cocos", "Indian/Comoro", "Indian/Kerguelen", "Indian/Mahe", "Indian/Maldives", "Indian/Mauritius", "Indian/Mayotte", "Indian/Reunion", "Pacific/Apia", "Pacific/Auckland", "Pacific/Bougainville", "Pacific/Chatham", "Pacific/Easter", "Pacific/Efate", "Pacific/Enderbury", "Pacific/Fakaofo", "Pacific/Fiji", "Pacific/Funafuti", "Pacific/Galapagos", "Pacific/Gambier", "Pacific/Guadalcanal", "Pacific/Guam", "Pacific/Honolulu", "Pacific/Kiritimati", "Pacific/Kosrae", "Pacific/Kwajalein", "Pacific/Majuro", "Pacific/Marquesas", "Pacific/Midway", "Pacific/Nauru", "Pacific/Niue", "Pacific/Norfolk", "Pacific/Noumea", "Pacific/Pago_Pago", "Pacific/Palau", "Pacific/Pitcairn", "Pacific/Ponape", "Pacific/Port_Moresby", "Pacific/Rarotonga", "Pacific/Saipan", "Pacific/Tahiti", "Pacific/Tarawa", "Pacific/Tongatapu", "Pacific/Truk", "Pacific/Wake", "Pacific/Wallis"];