@fleetless/contracts 7.1.0 → 8.1.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/billing.d.ts CHANGED
@@ -333,6 +333,10 @@ export declare const purchaseHoldReason: z.ZodEnum<{
333
333
  legacy_usd_invoice: "legacy_usd_invoice";
334
334
  legacy_payer_unresolved: "legacy_payer_unresolved";
335
335
  mandate_policy_unresolved: "mandate_policy_unresolved";
336
+ lexware_contact_pending: "lexware_contact_pending";
337
+ lexware_contact_changed: "lexware_contact_changed";
338
+ issuer_cutover_in_progress: "issuer_cutover_in_progress";
339
+ lexware_issuance_paused: "lexware_issuance_paused";
336
340
  }>;
337
341
  export declare const purchaseRefusalRule: z.ZodEnum<{
338
342
  company_required: "company_required";
@@ -394,6 +398,10 @@ export declare const purchaseIntent: z.ZodDiscriminatedUnion<[z.ZodObject<{
394
398
  legacy_usd_invoice: "legacy_usd_invoice";
395
399
  legacy_payer_unresolved: "legacy_payer_unresolved";
396
400
  mandate_policy_unresolved: "mandate_policy_unresolved";
401
+ lexware_contact_pending: "lexware_contact_pending";
402
+ lexware_contact_changed: "lexware_contact_changed";
403
+ issuer_cutover_in_progress: "issuer_cutover_in_progress";
404
+ lexware_issuance_paused: "lexware_issuance_paused";
397
405
  }>;
398
406
  original_amount: z.ZodOptional<z.ZodObject<{
399
407
  currency: z.ZodEnum<{
@@ -511,6 +519,10 @@ export declare const checkoutResponse: z.ZodDiscriminatedUnion<[z.ZodObject<{
511
519
  legacy_usd_invoice: "legacy_usd_invoice";
512
520
  legacy_payer_unresolved: "legacy_payer_unresolved";
513
521
  mandate_policy_unresolved: "mandate_policy_unresolved";
522
+ lexware_contact_pending: "lexware_contact_pending";
523
+ lexware_contact_changed: "lexware_contact_changed";
524
+ issuer_cutover_in_progress: "issuer_cutover_in_progress";
525
+ lexware_issuance_paused: "lexware_issuance_paused";
514
526
  }>;
515
527
  original_amount: z.ZodOptional<z.ZodObject<{
516
528
  currency: z.ZodEnum<{
@@ -664,6 +676,10 @@ export declare const purchaseConflictDetails: z.ZodDiscriminatedUnion<[z.ZodObje
664
676
  legacy_usd_invoice: "legacy_usd_invoice";
665
677
  legacy_payer_unresolved: "legacy_payer_unresolved";
666
678
  mandate_policy_unresolved: "mandate_policy_unresolved";
679
+ lexware_contact_pending: "lexware_contact_pending";
680
+ lexware_contact_changed: "lexware_contact_changed";
681
+ issuer_cutover_in_progress: "issuer_cutover_in_progress";
682
+ lexware_issuance_paused: "lexware_issuance_paused";
667
683
  }>;
668
684
  original_amount: z.ZodOptional<z.ZodObject<{
669
685
  currency: z.ZodEnum<{
@@ -1013,6 +1029,71 @@ export declare const billingAccount: z.ZodObject<{
1013
1029
  }, z.core.$strip>>;
1014
1030
  }, z.core.$strip>;
1015
1031
  export type BillingAccount = z.infer<typeof billingAccount>;
1032
+ /** Which system issues an org's charges: `cloud` before the issuer cutover (invoices only, in `invoices`) or `lexware` after it (due charges, in `charges`). */
1033
+ export declare const billingIssuer: z.ZodEnum<{
1034
+ cloud: "cloud";
1035
+ lexware: "lexware";
1036
+ }>;
1037
+ export type BillingIssuer = z.infer<typeof billingIssuer>;
1038
+ /**
1039
+ * Whether a due charge already has a confirmed Lexware invoice: `not_issued`
1040
+ * while the charge is not collected (`due`, a failed retry, or
1041
+ * `uncollectible` — there is nothing to invoice yet); `pending` once
1042
+ * collected but before Lexware confirms the invoice, in any intent state
1043
+ * short of a linked document; `issued` once Lexware's invoice is linked,
1044
+ * naming the document `GET /api/billing/documents/:id` reads.
1045
+ */
1046
+ export declare const billingChargeInvoice: z.ZodDiscriminatedUnion<[z.ZodObject<{
1047
+ state: z.ZodLiteral<"not_issued">;
1048
+ }, z.core.$strict>, z.ZodObject<{
1049
+ state: z.ZodLiteral<"pending">;
1050
+ }, z.core.$strict>, z.ZodObject<{
1051
+ state: z.ZodLiteral<"issued">;
1052
+ document_id: z.ZodUUID;
1053
+ }, z.core.$strict>], "state">;
1054
+ export type BillingChargeInvoice = z.infer<typeof billingChargeInvoice>;
1055
+ /**
1056
+ * One due charge billed through Lexware after the issuer cutover, read in
1057
+ * `billingView.charges`. `id` is the charge's own id — never a Cloud
1058
+ * invoice number — and the one `POST /api/billing/charges/:id/pay` takes.
1059
+ */
1060
+ export declare const billingCharge: z.ZodObject<{
1061
+ id: z.ZodUUID;
1062
+ kind: z.ZodEnum<{
1063
+ first: "first";
1064
+ renewal: "renewal";
1065
+ change: "change";
1066
+ }>;
1067
+ status: z.ZodEnum<{
1068
+ paid: "paid";
1069
+ uncollectible: "uncollectible";
1070
+ due: "due";
1071
+ cancelled: "cancelled";
1072
+ }>;
1073
+ currency: z.ZodLiteral<"eur">;
1074
+ net_cents: z.ZodNumber;
1075
+ vat_rate_percent: z.ZodNumber;
1076
+ vat_cents: z.ZodNumber;
1077
+ gross_cents: z.ZodNumber;
1078
+ period_start: z.ZodISODateTime;
1079
+ period_end: z.ZodISODateTime;
1080
+ due_at: z.ZodISODateTime;
1081
+ paid_at: z.ZodNullable<z.ZodISODateTime>;
1082
+ invoice: z.ZodDiscriminatedUnion<[z.ZodObject<{
1083
+ state: z.ZodLiteral<"not_issued">;
1084
+ }, z.core.$strict>, z.ZodObject<{
1085
+ state: z.ZodLiteral<"pending">;
1086
+ }, z.core.$strict>, z.ZodObject<{
1087
+ state: z.ZodLiteral<"issued">;
1088
+ document_id: z.ZodUUID;
1089
+ }, z.core.$strict>], "state">;
1090
+ }, z.core.$strict>;
1091
+ export type BillingCharge = z.infer<typeof billingCharge>;
1092
+ /** `POST /api/billing/charges/:id/pay`'s body — the same shape as `invoicePayRequest`: a stable `operation_key`. */
1093
+ export declare const chargePayRequest: z.ZodObject<{
1094
+ operation_key: z.ZodUUID;
1095
+ }, z.core.$strict>;
1096
+ export type ChargePayRequest = z.infer<typeof chargePayRequest>;
1016
1097
  /** `GET /api/billing`'s answer, and what every other billing route hands back after a change. */
1017
1098
  export declare const billingView: z.ZodObject<{
1018
1099
  available: z.ZodBoolean;
@@ -1124,6 +1205,10 @@ export declare const billingView: z.ZodObject<{
1124
1205
  }>;
1125
1206
  pays_invoice: z.ZodBoolean;
1126
1207
  }, z.core.$strip>>;
1208
+ issuer: z.ZodEnum<{
1209
+ cloud: "cloud";
1210
+ lexware: "lexware";
1211
+ }>;
1127
1212
  invoices: z.ZodArray<z.ZodObject<{
1128
1213
  id: z.ZodUUID;
1129
1214
  number: z.ZodString;
@@ -1142,6 +1227,37 @@ export declare const billingView: z.ZodObject<{
1142
1227
  vat_cents: z.ZodNumber;
1143
1228
  gross_cents: z.ZodNumber;
1144
1229
  }, z.core.$strip>>;
1230
+ charges: z.ZodArray<z.ZodObject<{
1231
+ id: z.ZodUUID;
1232
+ kind: z.ZodEnum<{
1233
+ first: "first";
1234
+ renewal: "renewal";
1235
+ change: "change";
1236
+ }>;
1237
+ status: z.ZodEnum<{
1238
+ paid: "paid";
1239
+ uncollectible: "uncollectible";
1240
+ due: "due";
1241
+ cancelled: "cancelled";
1242
+ }>;
1243
+ currency: z.ZodLiteral<"eur">;
1244
+ net_cents: z.ZodNumber;
1245
+ vat_rate_percent: z.ZodNumber;
1246
+ vat_cents: z.ZodNumber;
1247
+ gross_cents: z.ZodNumber;
1248
+ period_start: z.ZodISODateTime;
1249
+ period_end: z.ZodISODateTime;
1250
+ due_at: z.ZodISODateTime;
1251
+ paid_at: z.ZodNullable<z.ZodISODateTime>;
1252
+ invoice: z.ZodDiscriminatedUnion<[z.ZodObject<{
1253
+ state: z.ZodLiteral<"not_issued">;
1254
+ }, z.core.$strict>, z.ZodObject<{
1255
+ state: z.ZodLiteral<"pending">;
1256
+ }, z.core.$strict>, z.ZodObject<{
1257
+ state: z.ZodLiteral<"issued">;
1258
+ document_id: z.ZodUUID;
1259
+ }, z.core.$strict>], "state">;
1260
+ }, z.core.$strict>>;
1145
1261
  }, z.core.$strip>;
1146
1262
  export type BillingView = z.infer<typeof billingView>;
1147
1263
  /**
@@ -1422,6 +1538,10 @@ export declare const billingChangeResponse: z.ZodUnion<readonly [z.ZodObject<{
1422
1538
  }>;
1423
1539
  pays_invoice: z.ZodBoolean;
1424
1540
  }, z.core.$strip>>;
1541
+ issuer: z.ZodEnum<{
1542
+ cloud: "cloud";
1543
+ lexware: "lexware";
1544
+ }>;
1425
1545
  invoices: z.ZodArray<z.ZodObject<{
1426
1546
  id: z.ZodUUID;
1427
1547
  number: z.ZodString;
@@ -1440,6 +1560,37 @@ export declare const billingChangeResponse: z.ZodUnion<readonly [z.ZodObject<{
1440
1560
  vat_cents: z.ZodNumber;
1441
1561
  gross_cents: z.ZodNumber;
1442
1562
  }, z.core.$strip>>;
1563
+ charges: z.ZodArray<z.ZodObject<{
1564
+ id: z.ZodUUID;
1565
+ kind: z.ZodEnum<{
1566
+ first: "first";
1567
+ renewal: "renewal";
1568
+ change: "change";
1569
+ }>;
1570
+ status: z.ZodEnum<{
1571
+ paid: "paid";
1572
+ uncollectible: "uncollectible";
1573
+ due: "due";
1574
+ cancelled: "cancelled";
1575
+ }>;
1576
+ currency: z.ZodLiteral<"eur">;
1577
+ net_cents: z.ZodNumber;
1578
+ vat_rate_percent: z.ZodNumber;
1579
+ vat_cents: z.ZodNumber;
1580
+ gross_cents: z.ZodNumber;
1581
+ period_start: z.ZodISODateTime;
1582
+ period_end: z.ZodISODateTime;
1583
+ due_at: z.ZodISODateTime;
1584
+ paid_at: z.ZodNullable<z.ZodISODateTime>;
1585
+ invoice: z.ZodDiscriminatedUnion<[z.ZodObject<{
1586
+ state: z.ZodLiteral<"not_issued">;
1587
+ }, z.core.$strict>, z.ZodObject<{
1588
+ state: z.ZodLiteral<"pending">;
1589
+ }, z.core.$strict>, z.ZodObject<{
1590
+ state: z.ZodLiteral<"issued">;
1591
+ document_id: z.ZodUUID;
1592
+ }, z.core.$strict>], "state">;
1593
+ }, z.core.$strict>>;
1443
1594
  }, z.core.$strip>;
1444
1595
  charged: z.ZodNullable<z.ZodObject<{
1445
1596
  id: z.ZodUUID;
@@ -1510,6 +1661,10 @@ export declare const billingChangeResponse: z.ZodUnion<readonly [z.ZodObject<{
1510
1661
  legacy_usd_invoice: "legacy_usd_invoice";
1511
1662
  legacy_payer_unresolved: "legacy_payer_unresolved";
1512
1663
  mandate_policy_unresolved: "mandate_policy_unresolved";
1664
+ lexware_contact_pending: "lexware_contact_pending";
1665
+ lexware_contact_changed: "lexware_contact_changed";
1666
+ issuer_cutover_in_progress: "issuer_cutover_in_progress";
1667
+ lexware_issuance_paused: "lexware_issuance_paused";
1513
1668
  }>;
1514
1669
  original_amount: z.ZodOptional<z.ZodObject<{
1515
1670
  currency: z.ZodEnum<{
@@ -1706,6 +1861,10 @@ export declare const billingChangeResponse: z.ZodUnion<readonly [z.ZodObject<{
1706
1861
  }>;
1707
1862
  pays_invoice: z.ZodBoolean;
1708
1863
  }, z.core.$strip>>;
1864
+ issuer: z.ZodEnum<{
1865
+ cloud: "cloud";
1866
+ lexware: "lexware";
1867
+ }>;
1709
1868
  invoices: z.ZodArray<z.ZodObject<{
1710
1869
  id: z.ZodUUID;
1711
1870
  number: z.ZodString;
@@ -1724,6 +1883,37 @@ export declare const billingChangeResponse: z.ZodUnion<readonly [z.ZodObject<{
1724
1883
  vat_cents: z.ZodNumber;
1725
1884
  gross_cents: z.ZodNumber;
1726
1885
  }, z.core.$strip>>;
1886
+ charges: z.ZodArray<z.ZodObject<{
1887
+ id: z.ZodUUID;
1888
+ kind: z.ZodEnum<{
1889
+ first: "first";
1890
+ renewal: "renewal";
1891
+ change: "change";
1892
+ }>;
1893
+ status: z.ZodEnum<{
1894
+ paid: "paid";
1895
+ uncollectible: "uncollectible";
1896
+ due: "due";
1897
+ cancelled: "cancelled";
1898
+ }>;
1899
+ currency: z.ZodLiteral<"eur">;
1900
+ net_cents: z.ZodNumber;
1901
+ vat_rate_percent: z.ZodNumber;
1902
+ vat_cents: z.ZodNumber;
1903
+ gross_cents: z.ZodNumber;
1904
+ period_start: z.ZodISODateTime;
1905
+ period_end: z.ZodISODateTime;
1906
+ due_at: z.ZodISODateTime;
1907
+ paid_at: z.ZodNullable<z.ZodISODateTime>;
1908
+ invoice: z.ZodDiscriminatedUnion<[z.ZodObject<{
1909
+ state: z.ZodLiteral<"not_issued">;
1910
+ }, z.core.$strict>, z.ZodObject<{
1911
+ state: z.ZodLiteral<"pending">;
1912
+ }, z.core.$strict>, z.ZodObject<{
1913
+ state: z.ZodLiteral<"issued">;
1914
+ document_id: z.ZodUUID;
1915
+ }, z.core.$strict>], "state">;
1916
+ }, z.core.$strict>>;
1727
1917
  }, z.core.$strip>;
1728
1918
  charged: z.ZodNullable<z.ZodObject<{
1729
1919
  id: z.ZodUUID;
@@ -1796,6 +1986,10 @@ export declare const purchaseIntentResponse: z.ZodUnion<readonly [z.ZodDiscrimin
1796
1986
  legacy_usd_invoice: "legacy_usd_invoice";
1797
1987
  legacy_payer_unresolved: "legacy_payer_unresolved";
1798
1988
  mandate_policy_unresolved: "mandate_policy_unresolved";
1989
+ lexware_contact_pending: "lexware_contact_pending";
1990
+ lexware_contact_changed: "lexware_contact_changed";
1991
+ issuer_cutover_in_progress: "issuer_cutover_in_progress";
1992
+ lexware_issuance_paused: "lexware_issuance_paused";
1799
1993
  }>;
1800
1994
  original_amount: z.ZodOptional<z.ZodObject<{
1801
1995
  currency: z.ZodEnum<{
@@ -1991,6 +2185,10 @@ export declare const purchaseIntentResponse: z.ZodUnion<readonly [z.ZodDiscrimin
1991
2185
  }>;
1992
2186
  pays_invoice: z.ZodBoolean;
1993
2187
  }, z.core.$strip>>;
2188
+ issuer: z.ZodEnum<{
2189
+ cloud: "cloud";
2190
+ lexware: "lexware";
2191
+ }>;
1994
2192
  invoices: z.ZodArray<z.ZodObject<{
1995
2193
  id: z.ZodUUID;
1996
2194
  number: z.ZodString;
@@ -2009,6 +2207,37 @@ export declare const purchaseIntentResponse: z.ZodUnion<readonly [z.ZodDiscrimin
2009
2207
  vat_cents: z.ZodNumber;
2010
2208
  gross_cents: z.ZodNumber;
2011
2209
  }, z.core.$strip>>;
2210
+ charges: z.ZodArray<z.ZodObject<{
2211
+ id: z.ZodUUID;
2212
+ kind: z.ZodEnum<{
2213
+ first: "first";
2214
+ renewal: "renewal";
2215
+ change: "change";
2216
+ }>;
2217
+ status: z.ZodEnum<{
2218
+ paid: "paid";
2219
+ uncollectible: "uncollectible";
2220
+ due: "due";
2221
+ cancelled: "cancelled";
2222
+ }>;
2223
+ currency: z.ZodLiteral<"eur">;
2224
+ net_cents: z.ZodNumber;
2225
+ vat_rate_percent: z.ZodNumber;
2226
+ vat_cents: z.ZodNumber;
2227
+ gross_cents: z.ZodNumber;
2228
+ period_start: z.ZodISODateTime;
2229
+ period_end: z.ZodISODateTime;
2230
+ due_at: z.ZodISODateTime;
2231
+ paid_at: z.ZodNullable<z.ZodISODateTime>;
2232
+ invoice: z.ZodDiscriminatedUnion<[z.ZodObject<{
2233
+ state: z.ZodLiteral<"not_issued">;
2234
+ }, z.core.$strict>, z.ZodObject<{
2235
+ state: z.ZodLiteral<"pending">;
2236
+ }, z.core.$strict>, z.ZodObject<{
2237
+ state: z.ZodLiteral<"issued">;
2238
+ document_id: z.ZodUUID;
2239
+ }, z.core.$strict>], "state">;
2240
+ }, z.core.$strict>>;
2012
2241
  }, z.core.$strip>;
2013
2242
  charged: z.ZodNullable<z.ZodObject<{
2014
2243
  id: z.ZodUUID;
package/dist/billing.js CHANGED
@@ -328,7 +328,13 @@ const quoteIdentity = {
328
328
  quote_revision: z.string().trim().min(1).max(200).meta({ description: 'Opaque revision of the displayed quote; echo it when confirming.' }),
329
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
330
  };
331
- export const purchaseHoldReason = z.enum(['legacy_usd_invoice', 'legacy_payer_unresolved', 'mandate_policy_unresolved']);
331
+ export const purchaseHoldReason = z.enum([
332
+ 'legacy_usd_invoice', 'legacy_payer_unresolved', 'mandate_policy_unresolved',
333
+ // The Lexware issuer cutover (2026-10-19, fleetless/fleetless#327): holds
334
+ // during and after the move from Cloud-issued invoices to charges billed
335
+ // through Lexware.
336
+ 'lexware_contact_pending', 'lexware_contact_changed', 'issuer_cutover_in_progress', 'lexware_issuance_paused',
337
+ ]);
332
338
  export const purchaseRefusalRule = z.enum(['company_required', 'vat_id_required', 'vat_id_invalid', 'tax_id_required', 'us_state_required', 'public_email_domain', 'invoice_not_open']);
333
339
  // Cross-field invariants also travel in JSON Schema so non-TypeScript callers
334
340
  // cannot treat an invoice payment as an unbound checkout or a held setup as a charge.
@@ -530,8 +536,10 @@ export const billingAccount = z.object({
530
536
  }).meta({ description: "What takes effect at the period's end." }),
531
537
  dunning: z.object({
532
538
  invoice_id: z.uuid().meta({
533
- description: 'The open invoice dunning is chasing — or, while the payer\'s VAT ID is unsettled, the due charge that becomes one: it has ' +
534
- 'no number yet and is not in `invoices`. `POST /api/billing/invoices/:id/pay` takes either.',
539
+ description: 'What dunning is chasing: a historical open `FL-…` invoice, or a due charge. Before the issuer cutover a due charge appears ' +
540
+ 'here only while the payer\'s VAT ID is unsettled; it has no number yet, is not in `invoices`, and ' +
541
+ '`POST /api/billing/invoices/:id/pay` takes either. After the cutover this is always a due charge (in `charges`): pay it with ' +
542
+ '`POST /api/billing/charges/:id/pay`.',
535
543
  }),
536
544
  gross_cents: z.number().int().meta({
537
545
  description: 'The amount owed, in integer cents — after a partial chargeback only the charged-back part.',
@@ -548,6 +556,76 @@ export const billingAccount = z.object({
548
556
  }),
549
557
  }).nullable().meta({ description: '`null` while nothing is overdue. During a VAT-ID hold the charge is due but not yet invoiced.' }),
550
558
  });
559
+ /*
560
+ * ---------------------------------------------------------------------------
561
+ * The Lexware issuer cutover: due charges billed and paid individually
562
+ * through Lexware, taking over from the Cloud-issued invoice for every new
563
+ * charge (2026-10-19, fleetless/fleetless#327).
564
+ *
565
+ * `billingAccount.dunning.invoice_id` and `invoicePayRequest`/
566
+ * `checkoutResponse` already describe a due charge with no number of its
567
+ * own; `billingCharge` is the shape of that charge, read in
568
+ * `billingView.charges`, with its own Lexware invoice link
569
+ * (`billingChargeInvoice`) and its own pay route
570
+ * (`POST /api/billing/charges/:id/pay`, `chargePayRequest`).
571
+ * ---------------------------------------------------------------------------
572
+ */
573
+ /** Which system issues an org's charges: `cloud` before the issuer cutover (invoices only, in `invoices`) or `lexware` after it (due charges, in `charges`). */
574
+ export const billingIssuer = z.enum(['cloud', 'lexware']);
575
+ /**
576
+ * Whether a due charge already has a confirmed Lexware invoice: `not_issued`
577
+ * while the charge is not collected (`due`, a failed retry, or
578
+ * `uncollectible` — there is nothing to invoice yet); `pending` once
579
+ * collected but before Lexware confirms the invoice, in any intent state
580
+ * short of a linked document; `issued` once Lexware's invoice is linked,
581
+ * naming the document `GET /api/billing/documents/:id` reads.
582
+ */
583
+ export const billingChargeInvoice = z.discriminatedUnion('state', [
584
+ z.object({ state: z.literal('not_issued').meta({ description: 'Not collected (due, a failed retry, or uncollectible): no invoice exists.' }) }).strict(),
585
+ z.object({ state: z.literal('pending').meta({ description: 'Collected; the Lexware invoice is not yet confirmed.' }) }).strict(),
586
+ z.object({
587
+ state: z.literal('issued').meta({ description: 'Lexware has confirmed the invoice.' }),
588
+ document_id: z.uuid().meta({ description: "The Lexware document's id — read it with `GET /api/billing/documents/:id`." }),
589
+ }).strict(),
590
+ ]);
591
+ // The same invariant in JSON Schema, so non-TypeScript callers see it too.
592
+ const chargeInvoiceRules = [
593
+ { if: { properties: { status: { const: 'paid' } }, required: ['status'] }, then: { properties: { invoice: { properties: { state: { enum: ['pending', 'issued'] } } } } } },
594
+ { if: { properties: { status: { enum: ['due', 'uncollectible', 'cancelled'] } }, required: ['status'] }, then: { properties: { invoice: { properties: { state: { const: 'not_issued' } } } } } },
595
+ ];
596
+ /** Refused when `status` and `invoice.state` disagree: a paid charge has an invoice (pending or issued); every other status has none yet. */
597
+ function refuseChargeInvoiceMismatch(charge, ctx) {
598
+ const notIssued = charge.invoice.state === 'not_issued';
599
+ if ((charge.status === 'paid') === notIssued) {
600
+ ctx.addIssue({ code: 'custom', path: ['invoice'], message: 'A paid charge has an invoice (pending or issued); every other status has none yet.' });
601
+ }
602
+ }
603
+ /**
604
+ * One due charge billed through Lexware after the issuer cutover, read in
605
+ * `billingView.charges`. `id` is the charge's own id — never a Cloud
606
+ * invoice number — and the one `POST /api/billing/charges/:id/pay` takes.
607
+ */
608
+ export const billingCharge = z.object({
609
+ id: z.uuid().meta({ description: "The due charge's id — never a Cloud invoice number. Pay it with `POST /api/billing/charges/:id/pay`." }),
610
+ kind: z.enum(['first', 'renewal', 'change']).meta({ description: 'What caused the charge: the first charge after checkout, a scheduled renewal, or a mid-period plan change.' }),
611
+ status: z.enum(['due', 'paid', 'uncollectible', 'cancelled']).meta({
612
+ description: "The charge's own status. A charged back or manually refunded charge stays `paid` — refunds and chargebacks are handled in " +
613
+ "Mollie or Lexware by hand; this status and the invoice it names are unchanged, and the resulting Lexware credit note appears " +
614
+ 'under `GET /api/billing/documents` instead.',
615
+ }),
616
+ currency: z.literal('eur').meta({ description: 'Every charge billed through Lexware is EUR.' }),
617
+ net_cents: z.number().int().nonnegative().meta({ description: 'The charge, excluding VAT, in integer cents.' }),
618
+ vat_rate_percent: z.number().int().min(0).max(100).meta({ description: 'The VAT rate applied, in whole percent.' }),
619
+ vat_cents: z.number().int().nonnegative().meta({ description: 'VAT, in integer cents (`vatCents`).' }),
620
+ gross_cents: z.number().int().nonnegative().meta({ description: 'Net plus VAT, in integer cents.' }),
621
+ period_start: z.iso.datetime().meta({ description: "The covered period's start." }),
622
+ period_end: z.iso.datetime().meta({ description: "The covered period's end." }),
623
+ due_at: z.iso.datetime().meta({ description: 'When this charge is due.' }),
624
+ paid_at: z.iso.datetime().nullable().meta({ description: 'When this charge was paid, or `null` while unpaid.' }),
625
+ invoice: billingChargeInvoice.meta({ description: 'Whether a Lexware invoice exists for this charge yet, and which document it names once it does.' }),
626
+ }).strict().superRefine(refuseChargeInvoiceMismatch).meta({ allOf: chargeInvoiceRules });
627
+ /** `POST /api/billing/charges/:id/pay`'s body — the same shape as `invoicePayRequest`: a stable `operation_key`. */
628
+ export const chargePayRequest = invoicePayRequest;
551
629
  /** `GET /api/billing`'s answer, and what every other billing route hands back after a change. */
552
630
  export const billingView = z.object({
553
631
  available: z.boolean().meta({ description: 'Whether this cloud takes payments at all — `false` when no Mollie key is configured.' }),
@@ -560,7 +638,13 @@ export const billingView = z.object({
560
638
  description: 'What a payment-method change may offer right now, so a client offers exactly what the cloud accepts. `applepay` is absent when ' +
561
639
  'it needs an open invoice and none is open; `[]` when the org has no billing account.',
562
640
  }),
563
- invoices: z.array(billingInvoice).meta({ description: 'Newest first, at most 24.' }),
641
+ issuer: billingIssuer.meta({ description: "Which system issues this org's charges: `cloud` before the issuer cutover, or `lexware` after it." }),
642
+ invoices: z.array(billingInvoice).meta({ description: 'Cloud-issued invoices from before the issuer cutover; read-only, never grows after it. Newest first, at most 24.' }),
643
+ charges: z.array(billingCharge).meta({
644
+ description: 'Newest first, at most 24. Lists only due charges with issuer `lexware` — never a pre-cutover charge, a legacy payment ' +
645
+ '(legacy_issued/legacy_held/legacy_person/legacy_usd) or a late USD collection: none of those carry a Lexware intent, and they ' +
646
+ 'stay in `invoices` or nowhere. `[]` while `issuer` is `cloud`.',
647
+ }),
564
648
  });
565
649
  /*
566
650
  * ---------------------------------------------------------------------------
package/dist/errors.d.ts CHANGED
@@ -258,5 +258,5 @@ export type BillingDocumentsUnavailableDetails = z.infer<typeof billingDocuments
258
258
  * list is the shared vocabulary, not a closed set, so a new refusal never
259
259
  * needs a contracts release before it can be reported honestly.
260
260
  */
261
- export declare const ERROR_CODES: readonly ["not_found", "validation_error", "bad_request", "unknown_datapoint", "invalid_token", "protocol_mismatch", "bridge_too_old", "invalid_frame", "duplicate_slug", "reserved_slug", "unknown_slug", "unknown_field_path", "unknown_type", "unknown_topic", "invalid_rate", "invalid_range", "config_conflict", "no_data", "robot_offline", "bridge_timeout", "unauthorized", "forbidden", "invalid_credentials", "token_expired", "token_revoked", "email_taken", "identifier_taken", "weak_password", "account_blocked", "busy", "parameter_invalid", "cancel_rejected", "job_lost", "job_unknown_to_bridge", "action_server_lost", "action_failed", "goal_rejected", "goal_send_failed", "result_failed", "goal_uncontrollable", "bridge_disconnected", "config_changed", "publisher_busy", "unknown_command", "not_subscribable", "camera_offline", "no_snapshot_yet", "live_unavailable", "wrong_kind", "not_recorded", "not_aggregatable", "quota_exceeded", "credential_in_use", "goal_timeout", "robot_in_use", "robot_deletion_partial", "job_queue_full", "invalid_uuid", "rate_limited", "tier_required", "token_spent", "service_timeout", "asset_missing", "dynamic_registration_disabled", "client_limit_reached", "idp_unavailable", "mcp_disabled", "tool_not_available", "capability_required", "last_owner", "role_name_taken", "role_in_use", "last_role", "target_state_conflict", "signup_closed", "draft_not_a_document", "internal_error", "not_cancellable", "unsupported_media_type", "wrong_browser", "invalid_yaml", "unstorable_yaml", "registration_closed", "domain_not_allowed", "email_unverified", "origin_not_allowed", "template_invalid", "provider_disabled", "provider_misconfigured", "invalid_redirect_uri", "interaction_expired", "invalid_code", "method_not_allowed", "plan_limit", "plan_required", "org_locked", "file_too_large", "billing_unavailable", "payment_provider_unavailable", "history_migrating", "billing_documents_unavailable"];
261
+ export declare const ERROR_CODES: readonly ["not_found", "validation_error", "bad_request", "unknown_datapoint", "invalid_token", "protocol_mismatch", "bridge_too_old", "invalid_frame", "duplicate_slug", "reserved_slug", "unknown_slug", "unknown_field_path", "unknown_type", "unknown_topic", "invalid_rate", "invalid_range", "config_conflict", "no_data", "robot_offline", "bridge_timeout", "unauthorized", "forbidden", "invalid_credentials", "token_expired", "token_revoked", "email_taken", "identifier_taken", "weak_password", "account_blocked", "busy", "parameter_invalid", "cancel_rejected", "job_lost", "job_unknown_to_bridge", "action_server_lost", "action_failed", "goal_rejected", "goal_send_failed", "result_failed", "goal_uncontrollable", "bridge_disconnected", "config_changed", "publisher_busy", "unknown_command", "not_subscribable", "camera_offline", "no_snapshot_yet", "live_unavailable", "wrong_kind", "not_recorded", "not_aggregatable", "quota_exceeded", "credential_in_use", "goal_timeout", "robot_in_use", "robot_deletion_partial", "job_queue_full", "invalid_uuid", "rate_limited", "tier_required", "token_spent", "service_timeout", "asset_missing", "dynamic_registration_disabled", "client_limit_reached", "idp_unavailable", "mcp_disabled", "tool_not_available", "capability_required", "last_owner", "role_name_taken", "role_in_use", "last_role", "target_state_conflict", "signup_closed", "draft_not_a_document", "internal_error", "not_cancellable", "unsupported_media_type", "wrong_browser", "invalid_yaml", "unstorable_yaml", "registration_closed", "domain_not_allowed", "email_unverified", "origin_not_allowed", "template_invalid", "provider_disabled", "provider_misconfigured", "invalid_redirect_uri", "interaction_expired", "invalid_code", "method_not_allowed", "plan_limit", "plan_required", "org_locked", "file_too_large", "billing_unavailable", "payment_provider_unavailable", "history_migrating", "billing_documents_unavailable", "support_read_only", "support_forbidden"];
262
262
  export type ErrorCode = (typeof ERROR_CODES)[number];
package/dist/errors.js CHANGED
@@ -1101,4 +1101,36 @@ export const ERROR_CODES = [
1101
1101
  * page, bytes that are not a PDF or an XML). Nothing is streamed then.
1102
1102
  */
1103
1103
  'billing_documents_unavailable',
1104
+ // 2026-10-28 — support sessions (Block D, internal operator impersonation).
1105
+ /**
1106
+ * `403`: a support session in `read` mode reached a writing route — any
1107
+ * `POST`, `PUT`, `PATCH` or `DELETE` on the developer surface — or sent a
1108
+ * realtime control frame that would write. Reading stays open throughout:
1109
+ * only the write is refused, so a session an operator has not switched to
1110
+ * `edit` can diagnose without being able to change anything.
1111
+ *
1112
+ * Distinct from `forbidden`, which is silent about existence and about a
1113
+ * caller's role: this is about the **session's mode**, not about what the
1114
+ * underlying role would otherwise permit — the same support session would
1115
+ * answer normally to the identical request once switched to `edit`.
1116
+ * Produced by the cloud's support-session policy guard on the developer
1117
+ * HTTP surface and by the realtime socket, for the control frames it
1118
+ * refuses the same way.
1119
+ */
1120
+ 'support_read_only',
1121
+ /**
1122
+ * `403`: a route a support session never reaches, in either mode — signing
1123
+ * in again, account recovery, and system operations such as deleting the
1124
+ * org or rotating another developer's credentials. A support session is a
1125
+ * narrow, time-boxed stand-in for diagnosing and fixing one org's
1126
+ * configuration; it is never a path to the account layer underneath it,
1127
+ * `edit` mode included.
1128
+ *
1129
+ * Distinct from `support_read_only`, which is about a session's mode on a
1130
+ * route it could otherwise reach: this is a route no support session
1131
+ * reaches regardless of mode. Produced by the cloud's support-session
1132
+ * policy guard on the developer HTTP surface and by the realtime socket,
1133
+ * for the control frames it refuses the same way.
1134
+ */
1135
+ 'support_forbidden',
1104
1136
  ];
package/dist/index.d.ts CHANGED
@@ -33,6 +33,8 @@ export { password, org, patchOrgResponse, sessionTokens, refreshRequest, waitlis
33
33
  export type { Org, PatchOrgResponse, SessionTokens, RefreshRequest, WaitlistRequest, OrgAdminTier, FleetlessUser, FleetlessUserListResponse, CreateTeamInviteRequest, TeamInvite, PendingTeamInvite, PendingTeamInviteListResponse, AcceptTeamInviteRequest, PatchFleetlessUserRequest, TierChangeRequest, MailStatus, TierRequiredDetails, PasswordChangeRequest, IdpIssuer, TwoFactorSetupResponse, WebauthnOptionsResponse, DeveloperPasskey, DeveloperTwoFactor, CreatePasskeyRequest, CreatePasskeyResponse, RenamePasskeyRequest, TotpConfirmRequest, TotpConfirmResponse, RecoveryCodesResponse, AuthMeResponse, PatchOrgRequest, PatchAuthMeRequest, } from './identity.js';
34
34
  export { FEEDBACK_KINDS, FEEDBACK_MESSAGE_MAX, feedbackKind, feedbackRequest, feedbackResponse } from './feedback.js';
35
35
  export type { FeedbackKind, FeedbackRequest, FeedbackResponse } from './feedback.js';
36
+ export { supportSessionInfo, supportTokenRequest, supportTokenResponse, authMeSupportResponse } from './support.js';
37
+ export type { SupportSessionInfo, SupportTokenRequest, SupportTokenResponse, AuthMeSupportResponse } from './support.js';
36
38
  export { appIdentifier, app, appListResponse, appDeletionSummary, createAppRequest, updateAppRequest, serverKeyToken, serverKey, serverKeyListResponse, createServerKeyResponse, role, roleListResponse, rolePermissions, roleRenameRequest, roleDeleteQuery, roleInUseDetails, } from './apps.js';
37
39
  export type { App, AppListResponse, AppDeletionSummary, CreateAppRequest, UpdateAppRequest, ServerKey, ServerKeyListResponse, CreateServerKeyResponse, Role, RoleListResponse, RolePermissions, RoleRenameRequest, RoleDeleteQuery, RoleInUseDetails, } from './apps.js';
38
40
  export { clientLoginRequest, clientRefreshRequest, clientLogoutRequest, clientRegisterRequest, clientVerifyEmailRequest, clientResendVerificationRequest, clientPasswordResetRequest, clientPasswordResetConfirmRequest, clientAcceptInvitationRequest, CLIENT_OIDC_CALLBACK_PATH, clientProviderListQuery, clientProviderListResponse, clientOidcStartQuery, clientOidcCallbackQuery, clientOidcExchangeRequest, clientOidcErrorCode, clientMcpInteraction, clientMcpInteractionDecisionResponse, mcpConsentGrant, mcpConsentGrantListResponse, clientIdentity, clientLoginCodeRequest, clientLoginCodeVerifyRequest, twoFactorChallenge, clientSignInResult, clientTwoFactorVerifyRequest, clientTwoFactorSetupRequest, clientTwoFactorSetupConfirmRequest, clientTwoFactorSetupConfirmResponse, clientTwoFactorDisableRequest, } from './client-auth.js';
@@ -57,7 +59,7 @@ export { planId, PLAN_ORDER, planLimitKey, planLimits, planFeature, planFeatures
57
59
  export type { PlanId, PlanLimitKey, PlanLimits, PlanFeature, PlanFeatures, PlanPrices, PlanSupport, PlanCatalogueEntry, AddonKey, AddonCatalogueEntry, } from './plans.js';
58
60
  export { planCurrency, orgAddons, orgPlanUsage, planChangeKeep, planChangeReason, pendingPlanChange, orgLock, orgPlan, planChangeRequest, planOverrides, adminPlanChangeRequest, } from './plans.js';
59
61
  export type { PlanCurrency, OrgAddons, OrgPlanUsage, PlanChangeKeep, PlanChangeReason, PendingPlanChange, OrgLock, OrgPlan, PlanChangeRequest, PlanOverrides, AdminPlanChangeRequest, } from './plans.js';
60
- export { countryCode, EU_COUNTRIES, SELLER_COUNTRY, DE_VAT_RATE_PERCENT, isEuCountry, currencyForCountry, payerKind, billingCycle, vatTreatment, payerRefusalRule, vatFor, viesCountry, normalizeVatId, periodNetCents, prorateCents, vatCents, chargeAmounts, DAY_MS, periodDays, remainingDays, changeNetCents, checkoutQuote, BILLING_RETRY_DAYS, BILLING_LOCK_DAY, billingAddress, billingDetails, checkoutRequest, checkoutResponse, checkoutStatus, vatIdStatus, vatIdCheckRequest, vatIdCheckResponse, billingChangeRequest, billingCancelRequest, billingDetailsUpdate, paymentMethodKind, paymentMethodChangeRequest, billingAccountStatus, paymentMethod, invoiceStatus, billingInvoice, billingAccount, billingView, billingChangeResponse, billingDocumentKind, billingDocumentStatus, billingDocumentProfile, billingDocumentFormat, billingDocument, billingDocumentList, billingDocumentFileRole, billingDocumentDetail, billingDocumentFileQuery, } from './billing.js';
61
- export type { PayerKind, BillingCycle, VatTreatment, PayerRefusalRule, VatDecision, ChargeAmounts, BillingState, QuoteLine, CheckoutQuote, BillingAddress, BillingDetails, CheckoutRequest, CheckoutResponse, CheckoutStatus, VatIdStatus, VatIdCheckRequest, VatIdCheckResponse, BillingChangeRequest, BillingCancelRequest, BillingDetailsUpdate, PaymentMethodKind, PaymentMethodChangeRequest, BillingAccountStatus, PaymentMethod, InvoiceStatus, BillingInvoice, BillingAccount, BillingView, BillingChangeResponse, BillingDocumentKind, BillingDocumentStatus, BillingDocumentProfile, BillingDocumentFormat, BillingDocument, BillingDocumentList, BillingDocumentFileRole, BillingDocumentDetail, BillingDocumentFileQuery, } from './billing.js';
62
+ export { countryCode, EU_COUNTRIES, SELLER_COUNTRY, DE_VAT_RATE_PERCENT, isEuCountry, currencyForCountry, payerKind, billingCycle, vatTreatment, payerRefusalRule, vatFor, viesCountry, normalizeVatId, periodNetCents, prorateCents, vatCents, chargeAmounts, DAY_MS, periodDays, remainingDays, changeNetCents, checkoutQuote, BILLING_RETRY_DAYS, BILLING_LOCK_DAY, billingAddress, billingDetails, checkoutRequest, checkoutResponse, checkoutStatus, vatIdStatus, vatIdCheckRequest, vatIdCheckResponse, billingChangeRequest, billingCancelRequest, billingDetailsUpdate, paymentMethodKind, paymentMethodChangeRequest, billingAccountStatus, paymentMethod, invoiceStatus, billingInvoice, billingAccount, billingView, billingChangeResponse, billingDocumentKind, billingDocumentStatus, billingDocumentProfile, billingDocumentFormat, billingDocument, billingDocumentList, billingDocumentFileRole, billingDocumentDetail, billingDocumentFileQuery, billingIssuer, billingChargeInvoice, billingCharge, chargePayRequest, } from './billing.js';
63
+ export type { PayerKind, BillingCycle, VatTreatment, PayerRefusalRule, VatDecision, ChargeAmounts, BillingState, QuoteLine, CheckoutQuote, BillingAddress, BillingDetails, CheckoutRequest, CheckoutResponse, CheckoutStatus, VatIdStatus, VatIdCheckRequest, VatIdCheckResponse, BillingChangeRequest, BillingCancelRequest, BillingDetailsUpdate, PaymentMethodKind, PaymentMethodChangeRequest, BillingAccountStatus, PaymentMethod, InvoiceStatus, BillingInvoice, BillingAccount, BillingView, BillingChangeResponse, BillingDocumentKind, BillingDocumentStatus, BillingDocumentProfile, BillingDocumentFormat, BillingDocument, BillingDocumentList, BillingDocumentFileRole, BillingDocumentDetail, BillingDocumentFileQuery, BillingIssuer, BillingChargeInvoice, BillingCharge, ChargePayRequest, } from './billing.js';
62
64
  export { purchaseBillingDetails, purchaseOperationKey, purchaseOperation, purchaseQuote, purchaseHoldReason, purchaseRefusalRule, purchaseIntent, purchaseIntentLookupQuery, purchaseIntentConfirmRequest, purchaseConflictDetails, invoicePayRequest, purchaseIntentResponse, vatDecision, viesPendingReason, } from './billing.js';
63
65
  export type { PurchaseBillingDetails, PurchaseOperation, PurchaseQuote, PurchaseIntent, PurchaseIntentLookupQuery, PurchaseIntentConfirmRequest, PurchaseConflictDetails, InvoicePayRequest, PurchaseIntentResponse, ViesVerdict, ViesPendingReason, } from './billing.js';
package/dist/index.js CHANGED
@@ -44,6 +44,8 @@ webauthnJson, webauthnOptionsResponse, developerPasskey, developerTwoFactor, cre
44
44
  authMeResponse, patchOrgRequest, patchAuthMeRequest, } from './identity.js';
45
45
  // 2026-09-30 — the console's feedback modal.
46
46
  export { FEEDBACK_KINDS, FEEDBACK_MESSAGE_MAX, feedbackKind, feedbackRequest, feedbackResponse } from './feedback.js';
47
+ // Support sessions: an operator temporarily holding a console session for one org (internal, additive).
48
+ export { supportSessionInfo, supportTokenRequest, supportTokenResponse, authMeSupportResponse } from './support.js';
47
49
  export { appIdentifier, app, appListResponse, appDeletionSummary, createAppRequest, updateAppRequest, serverKeyToken, serverKey, serverKeyListResponse, createServerKeyResponse, role, roleListResponse, rolePermissions, roleRenameRequest, roleDeleteQuery, roleInUseDetails, } from './apps.js';
48
50
  export { clientLoginRequest, clientRefreshRequest, clientLogoutRequest, clientRegisterRequest, clientVerifyEmailRequest, clientResendVerificationRequest, clientPasswordResetRequest, clientPasswordResetConfirmRequest, clientAcceptInvitationRequest, CLIENT_OIDC_CALLBACK_PATH, clientProviderListQuery, clientProviderListResponse, clientOidcStartQuery, clientOidcCallbackQuery, clientOidcExchangeRequest, clientOidcErrorCode, clientMcpInteraction, clientMcpInteractionDecisionResponse, mcpConsentGrant, mcpConsentGrantListResponse, clientIdentity, clientLoginCodeRequest, clientLoginCodeVerifyRequest, twoFactorChallenge, clientSignInResult, clientTwoFactorVerifyRequest, clientTwoFactorSetupRequest, clientTwoFactorSetupConfirmRequest, clientTwoFactorSetupConfirmResponse, clientTwoFactorDisableRequest, } from './client-auth.js';
49
51
  export { clientRobotListItem, clientRobotListResponse } from './client-robots.js';
@@ -74,5 +76,7 @@ export { planCurrency, orgAddons, orgPlanUsage, planChangeKeep, planChangeReason
74
76
  // 2026-10-04 — billing through Mollie (#104).
75
77
  export { countryCode, EU_COUNTRIES, SELLER_COUNTRY, DE_VAT_RATE_PERCENT, isEuCountry, currencyForCountry, payerKind, billingCycle, vatTreatment, payerRefusalRule, vatFor, viesCountry, normalizeVatId, periodNetCents, prorateCents, vatCents, chargeAmounts, DAY_MS, periodDays, remainingDays, changeNetCents, checkoutQuote, BILLING_RETRY_DAYS, BILLING_LOCK_DAY, billingAddress, billingDetails, checkoutRequest, checkoutResponse, checkoutStatus, vatIdStatus, vatIdCheckRequest, vatIdCheckResponse, billingChangeRequest, billingCancelRequest, billingDetailsUpdate, paymentMethodKind, paymentMethodChangeRequest, billingAccountStatus, paymentMethod, invoiceStatus, billingInvoice, billingAccount, billingView, billingChangeResponse,
76
78
  // 2026-10-19 — Lexware billing documents (fleetless/fleetless#544).
77
- billingDocumentKind, billingDocumentStatus, billingDocumentProfile, billingDocumentFormat, billingDocument, billingDocumentList, billingDocumentFileRole, billingDocumentDetail, billingDocumentFileQuery, } from './billing.js';
79
+ billingDocumentKind, billingDocumentStatus, billingDocumentProfile, billingDocumentFormat, billingDocument, billingDocumentList, billingDocumentFileRole, billingDocumentDetail, billingDocumentFileQuery,
80
+ // 2026-10-19 — the Lexware issuer cutover (fleetless/fleetless#327).
81
+ billingIssuer, billingChargeInvoice, billingCharge, chargePayRequest, } from './billing.js';
78
82
  export { purchaseBillingDetails, purchaseOperationKey, purchaseOperation, purchaseQuote, purchaseHoldReason, purchaseRefusalRule, purchaseIntent, purchaseIntentLookupQuery, purchaseIntentConfirmRequest, purchaseConflictDetails, invoicePayRequest, purchaseIntentResponse, vatDecision, viesPendingReason, } from './billing.js';