@saasicat/core 1.0.0-rc.22 → 1.0.0-rc.24

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/index.js CHANGED
@@ -11,7 +11,8 @@ function buildActivePlanVersionWhere(asOf, options = {}) {
11
11
  const asOfDayStart = startOfUtcDay(asOf);
12
12
  const validityWindow = [
13
13
  { OR: [{ validFrom: null }, { validFrom: { lte: asOf } }] },
14
- { OR: [{ validUntil: null }, { validUntil: { gte: asOfDayStart } }] }
14
+ { OR: [{ validUntil: null }, { validUntil: { gte: asOfDayStart } }] },
15
+ { OR: [{ supersededAt: null }, { validUntil: { not: null } }] }
15
16
  ];
16
17
  if (!options.withEndsAt) {
17
18
  return { publishedAt: { not: null }, AND: validityWindow };
@@ -21,6 +22,16 @@ function buildActivePlanVersionWhere(asOf, options = {}) {
21
22
  AND: [...validityWindow, { OR: [{ endsAt: null }, { endsAt: { gt: asOf } }] }]
22
23
  };
23
24
  }
25
+ function isVersionActiveAt(version, asOf) {
26
+ const at = (value) => value === null || value === void 0 ? null : new Date(value);
27
+ const validFrom = at(version.validFrom);
28
+ const validUntil = at(version.validUntil);
29
+ const endsAt = at(version.endsAt);
30
+ if (validFrom && validFrom > asOf) return false;
31
+ if (validUntil && validUntil < startOfUtcDay(asOf)) return false;
32
+ if (version.supersededAt && !validUntil) return false;
33
+ return !(endsAt && endsAt <= asOf);
34
+ }
24
35
  var buildActiveVersionWhere = buildActivePlanVersionWhere;
25
36
 
26
37
  // src/bundle-draft-defaults.ts
@@ -74,6 +85,79 @@ function definedFields(data, keys) {
74
85
  var MARKETING_PRIORITY_MIN = 0;
75
86
  var MARKETING_PRIORITY_MAX = 1e4;
76
87
 
88
+ // src/money.ts
89
+ var HUNDRED = { units: 100n, scale: 0 };
90
+ function exactDecimal(value) {
91
+ if (!Number.isFinite(value)) {
92
+ throw new RangeError(`${String(value)} is not an amount money can be computed from.`);
93
+ }
94
+ const text = String(value);
95
+ const exponentAt = text.indexOf("e");
96
+ const mantissa = exponentAt === -1 ? text : text.slice(0, exponentAt);
97
+ const exponent = exponentAt === -1 ? 0 : Number(text.slice(exponentAt + 1));
98
+ const pointAt = mantissa.indexOf(".");
99
+ const whole = pointAt === -1 ? mantissa : mantissa.slice(0, pointAt);
100
+ const fraction = pointAt === -1 ? "" : mantissa.slice(pointAt + 1);
101
+ let units = BigInt(whole + fraction);
102
+ let scale = fraction.length - exponent;
103
+ if (scale < 0) {
104
+ units *= 10n ** BigInt(-scale);
105
+ scale = 0;
106
+ }
107
+ return { units, scale };
108
+ }
109
+ function sum(a, b) {
110
+ const scale = Math.max(a.scale, b.scale);
111
+ return {
112
+ units: a.units * 10n ** BigInt(scale - a.scale) + b.units * 10n ** BigInt(scale - b.scale),
113
+ scale
114
+ };
115
+ }
116
+ function roundHalfAwayFromZero(numerator, denominator) {
117
+ if (denominator === 0n) throw new RangeError("An amount cannot be divided by zero.");
118
+ const negative = numerator < 0n !== denominator < 0n;
119
+ const n = numerator < 0n ? -numerator : numerator;
120
+ const d = denominator < 0n ? -denominator : denominator;
121
+ const quotient = n / d;
122
+ const rounded = n % d * 2n >= d ? quotient + 1n : quotient;
123
+ return negative ? -rounded : rounded;
124
+ }
125
+ function cents(amount, factor, divisor) {
126
+ const numerator = amount.units * factor.units * 10n ** BigInt(divisor.scale) * 100n;
127
+ const denominator = divisor.units * 10n ** BigInt(amount.scale + factor.scale);
128
+ return roundHalfAwayFromZero(numerator, denominator);
129
+ }
130
+ function amountOf(inCents) {
131
+ return Number(inCents) / 100;
132
+ }
133
+ var ONE = { units: 1n, scale: 0 };
134
+ function roundToCents(amount) {
135
+ return amountOf(cents(exactDecimal(amount), ONE, ONE));
136
+ }
137
+ function sumToCents(...terms) {
138
+ const total = terms.map(exactDecimal).reduce(sum, { units: 0n, scale: 0 });
139
+ return amountOf(cents(total, ONE, ONE));
140
+ }
141
+ function toCents(amount) {
142
+ return Number(cents(exactDecimal(amount), ONE, ONE));
143
+ }
144
+ function percentOf(amount, percent) {
145
+ return amountOf(cents(exactDecimal(amount), exactDecimal(percent), HUNDRED));
146
+ }
147
+ function prorate(amount, part, whole) {
148
+ return amountOf(cents(exactDecimal(amount), exactDecimal(part), exactDecimal(whole)));
149
+ }
150
+ function grossFromNet(net, vatRate) {
151
+ return amountOf(cents(exactDecimal(net), sum(HUNDRED, exactDecimal(vatRate)), HUNDRED));
152
+ }
153
+ function netFromGross(gross, vatRate) {
154
+ return amountOf(cents(exactDecimal(gross), HUNDRED, sum(HUNDRED, exactDecimal(vatRate))));
155
+ }
156
+ function computeIncludedVat(gross, vatRate) {
157
+ const rate = exactDecimal(vatRate);
158
+ return amountOf(cents(exactDecimal(gross), rate, sum(HUNDRED, rate)));
159
+ }
160
+
77
161
  // src/promotion.types.ts
78
162
  function promoStatus(promo, today = /* @__PURE__ */ new Date()) {
79
163
  const from = new Date(promo.validFrom);
@@ -96,7 +180,9 @@ function boundedPromo(promo, basePrice) {
96
180
  const pct = withinBounds(promo.value, 100);
97
181
  return {
98
182
  kind: "percent",
99
- discounted: Math.round(basePrice * (100 - pct)) / 100,
183
+ // The discount is rounded and taken off, as a promo code's is: two
184
+ // rules for one percentage would state two prices for it.
185
+ discounted: sumToCents(basePrice, -percentOf(basePrice, pct)),
100
186
  original: basePrice,
101
187
  pct
102
188
  };
@@ -105,7 +191,7 @@ function boundedPromo(promo, basePrice) {
105
191
  const saved = withinBounds(promo.value, basePrice);
106
192
  return {
107
193
  kind: "amount",
108
- discounted: Math.round((basePrice - saved) * 100) / 100,
194
+ discounted: sumToCents(basePrice, -saved),
109
195
  original: basePrice,
110
196
  saved
111
197
  };
@@ -283,6 +369,286 @@ function appendNullableDecimalChange(out, field, oldValue, newValue, polarity) {
283
369
  appendDecimalChange(out, field, oldValue, newValue, polarity);
284
370
  }
285
371
 
372
+ // src/version-offer.ts
373
+ function takesSomethingAway(change) {
374
+ if (change.direction !== "REGRESSION") return false;
375
+ return change.field === "features.removed" || change.field.startsWith("quotas.");
376
+ }
377
+ function classifyVersionOffer(bound, candidate) {
378
+ const { changes } = classifyBundleVersionDiff(bound, candidate);
379
+ if (changes.some(takesSomethingAway)) return { class: "takes-something-away", changes };
380
+ if (changes.some((change) => change.direction === "REGRESSION")) {
381
+ return { class: "more-for-more", changes };
382
+ }
383
+ return { class: changes.length > 0 ? "improvement" : "same", changes };
384
+ }
385
+
386
+ // src/maintenance-window.types.ts
387
+ var MAINTENANCE_MESSAGE_MAX_LENGTH = 500;
388
+ var MAINTENANCE_STATE_MAX_AGE_SECONDS = 5;
389
+ var MAINTENANCE_CAPABILITY = "maintenance.manage";
390
+
391
+ // src/closed-value.ts
392
+ function oneOf(allowed, value, source) {
393
+ const match = allowed.find((entry) => entry === value);
394
+ if (match === void 0) {
395
+ throw new Error(
396
+ `${source.table} row '${source.id}' holds ${source.column} '${value}', which is none of ${allowed.join(", ")}.`
397
+ );
398
+ }
399
+ return match;
400
+ }
401
+
402
+ // src/subscription-notice-mapping.ts
403
+ var TABLE = "subscription_notices";
404
+ var KINDS = {
405
+ "version-offered": true,
406
+ "version-retired": true,
407
+ "version-retirement-reminder": true
408
+ };
409
+ function toSubscriptionNoticeRecord(row) {
410
+ return {
411
+ id: row.id,
412
+ tenantId: row.tenantId,
413
+ subscriptionId: row.subscriptionId,
414
+ kind: oneOf(Object.keys(KINDS), row.kind, {
415
+ table: TABLE,
416
+ column: "kind",
417
+ id: row.id
418
+ }),
419
+ subject: row.subject,
420
+ content: row.content,
421
+ createdAt: row.createdAt,
422
+ claimedAt: row.claimedAt,
423
+ deliveredAt: row.deliveredAt,
424
+ delivery: row.deliveredAt === null ? null : deliveryOf(row)
425
+ };
426
+ }
427
+ function deliveryOf(row) {
428
+ const { recipients, channel } = row;
429
+ if (!Array.isArray(recipients) || !recipients.every((recipient) => typeof recipient === "string") || channel === null) {
430
+ throw new Error(
431
+ `${TABLE} row '${row.id}' is delivered, but its recipients are not a list of strings or its channel is missing.`
432
+ );
433
+ }
434
+ return { recipients: [...recipients], channel };
435
+ }
436
+
437
+ // src/version-sale.ts
438
+ var DAY_MS = 24 * 60 * 60 * 1e3;
439
+ function versionSale(version, now) {
440
+ if (!version.publishedAt) return { kind: "draft" };
441
+ if (isVersionActiveAt(version, now)) {
442
+ return { kind: "on-sale", until: lastDayOnSale(version) };
443
+ }
444
+ const start = dateOf(version.validFrom);
445
+ if (start && start > now && isVersionActiveAt(version, start)) {
446
+ return { kind: "scheduled", from: dayOf(start) };
447
+ }
448
+ return { kind: "off-sale", since: firstDayOffSale(version, now) };
449
+ }
450
+ function versionOnSale(versions, now) {
451
+ const onSale = versions.filter((v) => versionSale(v, now).kind === "on-sale");
452
+ const startOf = (v) => dateOf(v.validFrom)?.getTime() ?? -Infinity;
453
+ onSale.sort((a, b) => startOf(b) - startOf(a) || (b.version ?? 0) - (a.version ?? 0));
454
+ return onSale[0] ?? null;
455
+ }
456
+ function versionOnSaleOrNext(versions, now) {
457
+ const onSale = versionOnSale(versions, now);
458
+ if (onSale) return onSale;
459
+ const scheduled = versions.filter((v) => versionSale(v, now).kind === "scheduled");
460
+ const startOf = (v) => dateOf(v.validFrom)?.getTime() ?? Infinity;
461
+ scheduled.sort((a, b) => startOf(a) - startOf(b));
462
+ return scheduled[0] ?? null;
463
+ }
464
+ function lastDayOnSale(version) {
465
+ const days = [];
466
+ const validUntil = dateOf(version.validUntil);
467
+ if (validUntil) days.push(dayOf(validUntil));
468
+ const endsAt = dateOf(version.endsAt);
469
+ if (endsAt) days.push(dayOf(new Date(endsAt.getTime() - 1)));
470
+ return earliest(days);
471
+ }
472
+ function firstDayOffSale(version, now) {
473
+ const days = [];
474
+ const validUntil = dateOf(version.validUntil);
475
+ if (validUntil && dayOf(validUntil) < dayOf(now)) {
476
+ days.push(dayOf(new Date(validUntil.getTime() + DAY_MS)));
477
+ }
478
+ const endsAt = dateOf(version.endsAt);
479
+ if (endsAt && endsAt <= now) days.push(dayOf(new Date(endsAt.getTime() - 1 + DAY_MS)));
480
+ return earliest(days);
481
+ }
482
+ function earliest(days) {
483
+ return days.length === 0 ? null : days.reduce((a, b) => a < b ? a : b);
484
+ }
485
+ function dateOf(value) {
486
+ if (value === null || value === void 0) return null;
487
+ const date = new Date(value);
488
+ return Number.isNaN(date.getTime()) ? null : date;
489
+ }
490
+ function dayOf(date) {
491
+ return date.toISOString().slice(0, 10);
492
+ }
493
+
494
+ // src/version-retirement.types.ts
495
+ var VERSION_RETIREMENT_CAPABILITY = "planVersions.retire";
496
+
497
+ // src/version-retirement-mapping.ts
498
+ function toVersionRetirementRecord(row) {
499
+ return {
500
+ id: row.id,
501
+ retired: {
502
+ planVersionId: row.retiredPlanVersionId,
503
+ planKey: row.retiredPlanKey,
504
+ version: row.retiredVersion
505
+ },
506
+ replacement: {
507
+ planVersionId: row.replacementPlanVersionId,
508
+ planKey: row.replacementPlanKey,
509
+ version: row.replacementVersion
510
+ },
511
+ announcedAt: row.announcedAt,
512
+ announcedBy: row.announcedBy
513
+ };
514
+ }
515
+
516
+ // src/scheduled-change-after-write.ts
517
+ var NO_SCHEDULED_CHANGE = {
518
+ pendingPlan: null,
519
+ pendingBillingCycle: null,
520
+ pendingEffectiveAt: null,
521
+ pendingChangeVersionId: null
522
+ };
523
+ function scheduledChangeAfterWrite(current, input) {
524
+ if (!input.keepsPendingChange) return NO_SCHEDULED_CHANGE;
525
+ const movesOnlyTheRhythm = current.pendingPlan === current.plan && current.pendingChangeVersionId === null;
526
+ return movesOnlyTheRhythm && current.plan !== input.planId ? { pendingPlan: input.planId } : {};
527
+ }
528
+
529
+ // src/retirement-switch.ts
530
+ function retirementSwitchTerms(notice, billingCycle) {
531
+ const priceIn = (side) => billingCycle === "YEARLY" ? side.yearlyNet : side.monthlyNet;
532
+ const replacement = priceIn(notice.replacement);
533
+ if (replacement === null) return null;
534
+ const retired = priceIn(notice.retired);
535
+ if (retired === null || replacement <= retired) return { priceNet: replacement, held: null };
536
+ return {
537
+ priceNet: replacement,
538
+ held: {
539
+ priceNet: retired,
540
+ amountNet: sumToCents(replacement, -retired),
541
+ // The last day to cancel without notice is the same day: the last
542
+ // whole one before the date the replacement takes over.
543
+ lastDay: notice.lastDayToCancel
544
+ }
545
+ };
546
+ }
547
+
548
+ // src/retirement-reminder.ts
549
+ var RETIREMENT_REMINDER_LEAD_DAYS = 14;
550
+ var DAY_MS2 = 24 * 60 * 60 * 1e3;
551
+ function retirementReminderDueAt(notice) {
552
+ return new Date(Date.parse(notice.effectiveAt) - RETIREMENT_REMINDER_LEAD_DAYS * DAY_MS2);
553
+ }
554
+ function retirementReminderIsDue(notice, now) {
555
+ return retirementReminderDueAt(notice) <= now && now.getTime() < Date.parse(notice.effectiveAt);
556
+ }
557
+ function retirementCostsTheSubscription(notice, billingCycle) {
558
+ if (notice.changes.some(takesSomethingAway)) return true;
559
+ const terms = retirementSwitchTerms(notice, billingCycle);
560
+ return terms === null || terms.held !== null;
561
+ }
562
+
563
+ // src/maintenance-window-mapping.ts
564
+ function toMaintenanceWindowRecord(row) {
565
+ return {
566
+ id: row.id,
567
+ startsAt: row.startsAt,
568
+ endsAt: row.endsAt,
569
+ message: row.message,
570
+ createdAt: row.createdAt,
571
+ createdBy: row.createdBy,
572
+ lockedAt: row.lockedAt,
573
+ lockedBy: row.lockedBy,
574
+ endedAt: row.endedAt,
575
+ endedBy: row.endedBy
576
+ };
577
+ }
578
+
579
+ // src/maintenance-window-views.ts
580
+ var RETRY_AFTER_WITHOUT_END_SECONDS = 60;
581
+ var iso = (date) => date ? date.toISOString() : null;
582
+ function maintenanceWindowStatusOf(window) {
583
+ if (window.endedAt) return window.lockedAt ? "ended" : "cancelled";
584
+ return window.lockedAt ? "locked" : "announced";
585
+ }
586
+ function isMaintenanceOverrun(window, now) {
587
+ return maintenanceWindowStatusOf(window) === "locked" && window.endsAt !== null && window.endsAt.getTime() <= now.getTime();
588
+ }
589
+ function isMaintenanceAnnouncementLapsed(window, now) {
590
+ return maintenanceWindowStatusOf(window) === "announced" && window.endsAt !== null && window.endsAt.getTime() <= now.getTime();
591
+ }
592
+ function maintenanceStatusOf(open, now) {
593
+ if (!open) return { state: "none" };
594
+ const status = maintenanceWindowStatusOf(open);
595
+ if (status === "locked" && open.lockedAt) {
596
+ return {
597
+ state: "locked",
598
+ lockedAt: open.lockedAt.toISOString(),
599
+ endsAt: iso(open.endsAt),
600
+ message: open.message,
601
+ overrun: isMaintenanceOverrun(open, now)
602
+ };
603
+ }
604
+ if (status === "announced" && open.startsAt && open.endsAt && !isMaintenanceAnnouncementLapsed(open, now)) {
605
+ return {
606
+ state: "announced",
607
+ startsAt: open.startsAt.toISOString(),
608
+ endsAt: open.endsAt.toISOString(),
609
+ message: open.message
610
+ };
611
+ }
612
+ return { state: "none" };
613
+ }
614
+ function maintenanceWindowViewOf(window, now) {
615
+ return {
616
+ id: window.id,
617
+ status: maintenanceWindowStatusOf(window),
618
+ startsAt: iso(window.startsAt),
619
+ endsAt: iso(window.endsAt),
620
+ message: window.message,
621
+ createdAt: window.createdAt.toISOString(),
622
+ createdBy: window.createdBy,
623
+ lockedAt: iso(window.lockedAt),
624
+ lockedBy: window.lockedBy,
625
+ endedAt: iso(window.endedAt),
626
+ endedBy: window.endedBy,
627
+ overrun: isMaintenanceOverrun(window, now),
628
+ lapsed: isMaintenanceAnnouncementLapsed(window, now)
629
+ };
630
+ }
631
+ function maintenanceRetryAfterSeconds(window, now) {
632
+ if (!window.endsAt || window.endsAt.getTime() <= now.getTime()) {
633
+ return RETRY_AFTER_WITHOUT_END_SECONDS;
634
+ }
635
+ return Math.max(1, Math.ceil((window.endsAt.getTime() - now.getTime()) / 1e3));
636
+ }
637
+
638
+ // src/zoned-instant.ts
639
+ function endsInOffset(text) {
640
+ const sign = text.charAt(text.length - 6);
641
+ return (sign === "+" || sign === "-") && text.charAt(text.length - 3) === ":";
642
+ }
643
+ function parseZonedInstant(text) {
644
+ const value = text.trim();
645
+ if (!value.includes("T")) return null;
646
+ const zoned = value.endsWith("Z") || value.endsWith("z") || endsInOffset(value);
647
+ if (!zoned) return null;
648
+ const moment = new Date(value);
649
+ return Number.isNaN(moment.getTime()) ? null : moment;
650
+ }
651
+
286
652
  // src/settings-subtree.ts
287
653
  var CATALOGUE_KEYS = /* @__PURE__ */ new Set([
288
654
  "schemaVersion",
@@ -400,11 +766,42 @@ var CATALOG_ERROR_CODES = {
400
766
  PLAN_TERMINATE_INVALID_DATE: "PLAN_TERMINATE_INVALID_DATE",
401
767
  PLAN_TERMINATE_DATE_NOT_FUTURE: "PLAN_TERMINATE_DATE_NOT_FUTURE",
402
768
  PLAN_TERMINATE_NOT_IMPLEMENTED: "PLAN_TERMINATE_NOT_IMPLEMENTED",
769
+ /**
770
+ * Subscriptions told of a retirement still move onto this version, and
771
+ * nothing moves onto a version that has ended. Carries the version, its
772
+ * plan key and the first day it may end: the day after the last move.
773
+ */
774
+ PLAN_TERMINATE_BEFORE_RETIREMENT_MOVES: "PLAN_TERMINATE_BEFORE_RETIREMENT_MOVES",
775
+ /**
776
+ * Subscriptions told of a retirement are past their date and still to be
777
+ * moved onto this version — a move the platform could not make yet — so it
778
+ * cannot end until they have moved. Carries how many, the version and its
779
+ * plan key.
780
+ */
781
+ PLAN_TERMINATE_WHILE_MOVES_OVERDUE: "PLAN_TERMINATE_WHILE_MOVES_OVERDUE",
782
+ /**
783
+ * Subscriptions on a retired version have not yet been told of their move
784
+ * onto this version — their notice has reached nobody, so their date is not
785
+ * set — and it cannot end until they have been. Carries how many, the
786
+ * version and its plan key.
787
+ */
788
+ PLAN_TERMINATE_WHILE_NOTICES_UNDELIVERED: "PLAN_TERMINATE_WHILE_NOTICES_UNDELIVERED",
403
789
  // ── bundle versions ──
404
790
  BUNDLE_VERSION_ALREADY_PUBLISHED: "BUNDLE_VERSION_ALREADY_PUBLISHED",
405
791
  BUNDLE_VERSION_NOT_EDITABLE: "BUNDLE_VERSION_NOT_EDITABLE",
406
792
  BUNDLE_VERSION_NOT_PUBLISHED: "BUNDLE_VERSION_NOT_PUBLISHED",
407
793
  BUNDLE_VERSION_SUPERSEDED: "BUNDLE_VERSION_SUPERSEDED",
794
+ /**
795
+ * The bundle version is published, and its window has not opened: it goes
796
+ * on sale on `validFrom`, and until then its predecessor is the one sold.
797
+ */
798
+ BUNDLE_VERSION_NOT_YET_ON_SALE: "BUNDLE_VERSION_NOT_YET_ON_SALE",
799
+ /**
800
+ * The add-on itself has been deleted from the catalogue. Deleting it leaves
801
+ * its versions' dates as they were, so the version asked for can still be
802
+ * inside its window; it is not on offer all the same.
803
+ */
804
+ BUNDLE_DELETED: "BUNDLE_DELETED",
408
805
  BUNDLE_VERSION_REGRESSION: "BUNDLE_VERSION_REGRESSION",
409
806
  BUNDLE_VERSION_ZERO_PRICE: "BUNDLE_VERSION_ZERO_PRICE",
410
807
  BUNDLE_VERSION_NO_PRICE: "BUNDLE_VERSION_NO_PRICE",
@@ -463,6 +860,22 @@ var BILLING_ERROR_CODES = {
463
860
  BUNDLE_NOT_SELF_SERVICE: "BUNDLE_NOT_SELF_SERVICE",
464
861
  BUNDLE_CYCLE_EXCEEDS_PLAN: "BUNDLE_CYCLE_EXCEEDS_PLAN",
465
862
  BUNDLE_NOT_PRICED_FOR_THIS_PLAN: "BUNDLE_NOT_PRICED_FOR_THIS_PLAN",
863
+ /**
864
+ * The bundle cannot run on a plan the subscription is already set to move
865
+ * to — by a scheduled change, or by a retirement it has been told of — and
866
+ * the booking would still be running then: that plan does not book it, or
867
+ * has no price for it. Carries that plan's key, the rhythm it is billed in
868
+ * there, and the day the move takes effect from, which can lie in the past
869
+ * while the move has not run yet.
870
+ */
871
+ BUNDLE_CANNOT_RUN_ON_UPCOMING_PLAN: "BUNDLE_CANNOT_RUN_ON_UPCOMING_PLAN",
872
+ /**
873
+ * As `BUNDLE_CANNOT_RUN_ON_UPCOMING_PLAN`, where only the rhythm stands in
874
+ * the way: a yearly bundle, and the subscription billed monthly from the
875
+ * day of the move — a switch of rhythm on the plan it keeps, for one, where
876
+ * naming the plan would point at the one it is already on. Same values.
877
+ */
878
+ BUNDLE_CANNOT_RUN_ON_UPCOMING_CYCLE: "BUNDLE_CANNOT_RUN_ON_UPCOMING_CYCLE",
466
879
  SUBSCRIPTION_BUNDLE_ALREADY_CANCELLED: "SUBSCRIPTION_BUNDLE_ALREADY_CANCELLED",
467
880
  SUBSCRIPTION_BUNDLE_NOT_CANCELLED: "SUBSCRIPTION_BUNDLE_NOT_CANCELLED",
468
881
  SUBSCRIPTION_BUNDLE_CANCELLATION_EFFECTIVE: "SUBSCRIPTION_BUNDLE_CANCELLATION_EFFECTIVE",
@@ -482,6 +895,12 @@ var BILLING_ERROR_CODES = {
482
895
  * in it: a plan without a yearly price is a monthly plan.
483
896
  */
484
897
  PLAN_NOT_SOLD_IN_CYCLE: "PLAN_NOT_SOLD_IN_CYCLE",
898
+ /**
899
+ * The subscription is bound to a plan version the plan repository does not
900
+ * find, or finds as a version of another plan. What the subscription pays
901
+ * cannot be read, so no change is quoted until the binding is repaired.
902
+ */
903
+ BOUND_PLAN_VERSION_UNREADABLE: "BOUND_PLAN_VERSION_UNREADABLE",
485
904
  /** Plan change refused. Carries `blockers[]` with their own codes. */
486
905
  PLAN_CHANGE_BLOCKED: "PLAN_CHANGE_BLOCKED",
487
906
  /**
@@ -504,6 +923,103 @@ var BILLING_ERROR_CODES = {
504
923
  * Carries the recomputed dates, so the page can re-ask instead of guessing.
505
924
  */
506
925
  CANCELLATION_TERMS_CHANGED: "CANCELLATION_TERMS_CHANGED",
926
+ /**
927
+ * The version the caller asked to switch to is no longer the one offered —
928
+ * another is on sale, the subscription moved, or there is no offer. Nothing
929
+ * was switched. Carries the current `offer`, or `null`, so the page can show
930
+ * it instead of guessing.
931
+ */
932
+ VERSION_OFFER_CHANGED: "VERSION_OFFER_CHANGED",
933
+ /**
934
+ * The version a change to another plan named is not the one on sale when
935
+ * the change was submitted: its preview was shown at another moment.
936
+ * Nothing was changed. Carries the current `preview`, so the page shows
937
+ * what the change binds now instead of what it would have.
938
+ */
939
+ PLAN_CHANGE_QUOTE_CHANGED: "PLAN_CHANGE_QUOTE_CHANGED",
940
+ /**
941
+ * A change to another plan named no version, where its preview names one:
942
+ * nothing says which price and terms the customer was shown, so nothing
943
+ * is changed.
944
+ */
945
+ PLAN_CHANGE_VERSION_NOT_NAMED: "PLAN_CHANGE_VERSION_NOT_NAMED",
946
+ /**
947
+ * A version that takes something away takes effect when the term ends, and
948
+ * the subscription's cancellation lands no later: the switch would never
949
+ * happen, so it is refused rather than recorded. Carries both dates.
950
+ */
951
+ VERSION_SWITCH_AFTER_CANCELLATION: "VERSION_SWITCH_AFTER_CANCELLATION",
952
+ /**
953
+ * A version that takes something away takes effect when the term ends, and
954
+ * it stops being sold before then — by its window or because an operator
955
+ * ended it — so it could not be bound when the change comes due. Refused
956
+ * rather than recorded; carries the dates.
957
+ */
958
+ VERSION_ENDS_BEFORE_SWITCH: "VERSION_ENDS_BEFORE_SWITCH",
959
+ // ── retiring a version for running subscriptions ──
960
+ /**
961
+ * The operator's terms are not confirmed to carry the clause a retirement
962
+ * rests on (`tenantBilling.orderlyRetirement.termsConfirmed` in
963
+ * `config/saas.yaml`), so none is accepted.
964
+ */
965
+ RETIREMENT_TERMS_NOT_CONFIRMED: "RETIREMENT_TERMS_NOT_CONFIRMED",
966
+ /**
967
+ * The version is still on sale: a subscription booked after the
968
+ * announcement would be on it without having been told. Carries the plan
969
+ * key and the version.
970
+ */
971
+ RETIREMENT_VERSION_ON_SALE: "RETIREMENT_VERSION_ON_SALE",
972
+ /** The replacement is not on sale, so nobody can continue on it. Carries plan key and version. */
973
+ RETIREMENT_REPLACEMENT_NOT_ON_SALE: "RETIREMENT_REPLACEMENT_NOT_ON_SALE",
974
+ /**
975
+ * The replacement has no price in the rhythm some of the subscriptions it
976
+ * reaches are billed in, so they cannot continue on it. Carries how many,
977
+ * and the replacement's plan key and version.
978
+ */
979
+ RETIREMENT_REPLACEMENT_NOT_SOLD_IN_RHYTHM: "RETIREMENT_REPLACEMENT_NOT_SOLD_IN_RHYTHM",
980
+ /**
981
+ * Some of the subscriptions the retirement reaches hold an add-on that
982
+ * cannot run on the replacement's plan, so they cannot continue on it.
983
+ * Carries how many, and the replacement's plan key and version.
984
+ */
985
+ RETIREMENT_REPLACEMENT_CANNOT_CARRY_BUNDLES: "RETIREMENT_REPLACEMENT_CANNOT_CARRY_BUNDLES",
986
+ /** The replacement named is the version being retired. */
987
+ RETIREMENT_REPLACEMENT_IS_RETIRED: "RETIREMENT_REPLACEMENT_IS_RETIRED",
988
+ /** No running subscription is on the version: there is nobody to tell. Carries plan key and version. */
989
+ RETIREMENT_NOTHING_AFFECTED: "RETIREMENT_NOTHING_AFFECTED",
990
+ /**
991
+ * Some of the subscriptions it reaches were reached by a retirement within
992
+ * the last twelve months, and a subscription is reached at most once in that
993
+ * time. Carries how many and which.
994
+ */
995
+ RETIREMENT_WITHIN_TWELVE_MONTHS: "RETIREMENT_WITHIN_TWELVE_MONTHS",
996
+ /**
997
+ * The subscriptions the retirement reaches, or their dates, changed since
998
+ * the preview the operator confirmed. Carries the preview as it stands.
999
+ */
1000
+ RETIREMENT_PREVIEW_CHANGED: "RETIREMENT_PREVIEW_CHANGED",
1001
+ /** No retirement of the subscription's version waits for its date: there is nothing to switch to. */
1002
+ RETIREMENT_SWITCH_NOT_PENDING: "RETIREMENT_SWITCH_NOT_PENDING",
1003
+ /** The switch opens once the trial has converted: a trial has no contract to hold the price on. */
1004
+ RETIREMENT_SWITCH_IN_TRIAL: "RETIREMENT_SWITCH_IN_TRIAL",
1005
+ /**
1006
+ * An add-on running today cannot run beside the replacement's plan, which
1007
+ * the switch would move the subscription onto today. Carries the add-on,
1008
+ * the plan and the earliest day the booking can end. Its own code rather
1009
+ * than a plan change's: the switch has no other plan to choose and no day
1010
+ * to pick, so the way past it is the add-on ending.
1011
+ */
1012
+ RETIREMENT_SWITCH_BUNDLE_CANNOT_FOLLOW: "RETIREMENT_SWITCH_BUNDLE_CANNOT_FOLLOW",
1013
+ /**
1014
+ * The subscription takes no switch now: a change is scheduled, it has
1015
+ * ended, or its plan is held for a special contract.
1016
+ */
1017
+ RETIREMENT_SWITCH_NOT_OPEN: "RETIREMENT_SWITCH_NOT_OPEN",
1018
+ /**
1019
+ * The version named is not the replacement the retirement names. Carries
1020
+ * the retirement as it now stands.
1021
+ */
1022
+ RETIREMENT_SWITCH_CHANGED: "RETIREMENT_SWITCH_CHANGED",
507
1023
  // ── the preview routes' own blockers and warnings ──
508
1024
  //
509
1025
  // These travel inside a 200 response, in `blockers[]` and `warnings[]`, not
@@ -533,14 +1049,23 @@ var BILLING_ERROR_CODES = {
533
1049
  CANCELLATION_LOCKS_THE_CYCLE: "CANCELLATION_LOCKS_THE_CYCLE",
534
1050
  /**
535
1051
  * A bundle the tenant already holds runs past the cycle they are moving to.
1052
+ * Carries the bundle, the earliest day the booking can end, and the two
1053
+ * rhythms.
536
1054
  *
537
1055
  * Its own code rather than `BUNDLE_CYCLE_EXCEEDS_PLAN`, which states the
538
1056
  * same rule about a booking that has not been made yet. The two need
539
1057
  * different sentences: this one can name the day the obstacle lifts and
540
- * tell the reader to cancel the booking, and that advice is wrong for
541
- * someone who is only about to book. One template cannot serve both.
1058
+ * tell the reader how to get past it, and that advice is wrong for someone
1059
+ * who is only about to book. One template cannot serve both.
542
1060
  */
543
1061
  BUNDLE_BOOKING_OUTLASTS_TARGET_CYCLE: "BUNDLE_BOOKING_OUTLASTS_TARGET_CYCLE",
1062
+ /**
1063
+ * A bundle the tenant already holds cannot run on the plan they are moving
1064
+ * to: that plan may not book it, or it has no price there in the rhythm
1065
+ * the booking is billed in. Carries the bundle, the plan and the earliest
1066
+ * day the booking can end.
1067
+ */
1068
+ BUNDLE_BOOKING_DOES_NOT_FIT_TARGET_PLAN: "BUNDLE_BOOKING_DOES_NOT_FIT_TARGET_PLAN",
544
1069
  /**
545
1070
  * Features of the previewed bundle are already covered by the plan or by
546
1071
  * another booked bundle. A warning rather than a blocker: paying twice is
@@ -562,7 +1087,6 @@ var BILLING_ERROR_CODES = {
562
1087
  * tenant reads and therefore needs a shipped text for.
563
1088
  */
564
1089
  BUNDLE_FEATURE_DEPENDENCY_UNSATISFIED: "BUNDLE_FEATURE_DEPENDENCY_UNSATISFIED",
565
- NO_PENDING_PLAN_VERSION: "NO_PENDING_PLAN_VERSION",
566
1090
  ONBOARDING_CREATE_FAILED: "ONBOARDING_CREATE_FAILED",
567
1091
  BUNDLE_PREVIEW_ARGUMENT_AMBIGUOUS: "BUNDLE_PREVIEW_ARGUMENT_AMBIGUOUS",
568
1092
  /**
@@ -613,7 +1137,15 @@ var CONTRACT_ERROR_CODES = {
613
1137
  CHECKOUT_OFFER_CHANGED: "CHECKOUT_OFFER_CHANGED",
614
1138
  SUBSCRIPTION_CONTRACT_NOT_FOUND: "SUBSCRIPTION_CONTRACT_NOT_FOUND",
615
1139
  NO_ACTIVE_SUBSCRIPTION_CONTRACT: "NO_ACTIVE_SUBSCRIPTION_CONTRACT",
616
- SUBSCRIPTION_CONTRACT_ALREADY_CLOSED: "SUBSCRIPTION_CONTRACT_ALREADY_CLOSED"
1140
+ SUBSCRIPTION_CONTRACT_ALREADY_CLOSED: "SUBSCRIPTION_CONTRACT_ALREADY_CLOSED",
1141
+ /**
1142
+ * A successor would run beside another contract of the tenant: the
1143
+ * contract in force moved while it was being written — another successor
1144
+ * took its place, or a cancellation capped it — and kept moving on a
1145
+ * second attempt, or a contract begins after the moment the successor
1146
+ * would take effect. Nothing was written.
1147
+ */
1148
+ SUBSCRIPTION_CONTRACT_CHANGED: "SUBSCRIPTION_CONTRACT_CHANGED"
617
1149
  };
618
1150
  var SUBSCRIBER_ERROR_CODES = {
619
1151
  /**
@@ -724,6 +1256,24 @@ var SETTINGS_ERROR_CODES = {
724
1256
  /** No recorded change has this id, or the installation keeps no record at all. */
725
1257
  SETTINGS_CHANGE_NOT_FOUND: "SETTINGS_CHANGE_NOT_FOUND"
726
1258
  };
1259
+ var MAINTENANCE_ERROR_CODES = {
1260
+ /** The application is locked for maintenance; the body carries the window. */
1261
+ MAINTENANCE: "MAINTENANCE",
1262
+ /** A window is already open: move or cancel it before announcing another. */
1263
+ MAINTENANCE_WINDOW_ALREADY_OPEN: "MAINTENANCE_WINDOW_ALREADY_OPEN",
1264
+ /** No open window has this id — it ended, or it never existed. */
1265
+ MAINTENANCE_WINDOW_NOT_OPEN: "MAINTENANCE_WINDOW_NOT_OPEN",
1266
+ /** The window is locked: its start is history, and unlocking is what ends it. */
1267
+ MAINTENANCE_WINDOW_LOCKED: "MAINTENANCE_WINDOW_LOCKED",
1268
+ /** The announced end is not after the announced start. */
1269
+ MAINTENANCE_WINDOW_END_NOT_AFTER_START: "MAINTENANCE_WINDOW_END_NOT_AFTER_START",
1270
+ /** The announced end has already passed. */
1271
+ MAINTENANCE_WINDOW_END_IN_PAST: "MAINTENANCE_WINDOW_END_IN_PAST",
1272
+ /** A time without its zone, or not a date and time at all; `field` names which. */
1273
+ MAINTENANCE_TIME_INVALID: "MAINTENANCE_TIME_INVALID",
1274
+ /** The message is longer than `MAINTENANCE_MESSAGE_MAX_LENGTH`. */
1275
+ MAINTENANCE_MESSAGE_TOO_LONG: "MAINTENANCE_MESSAGE_TOO_LONG"
1276
+ };
727
1277
  var PLATFORM_ERROR_CODES = {
728
1278
  ...SETUP_ERROR_CODES,
729
1279
  ...AUTH_ERROR_CODES,
@@ -734,7 +1284,8 @@ var PLATFORM_ERROR_CODES = {
734
1284
  ...SUBSCRIBER_ERROR_CODES,
735
1285
  ...REGISTRATION_ERROR_CODES,
736
1286
  ...PAYMENT_ERROR_CODES,
737
- ...SETTINGS_ERROR_CODES
1287
+ ...SETTINGS_ERROR_CODES,
1288
+ ...MAINTENANCE_ERROR_CODES
738
1289
  };
739
1290
 
740
1291
  // src/errors.ts
@@ -753,121 +1304,555 @@ var PlatformUserExistsError = class extends Error {
753
1304
  function isPlatformUserExistsError(err) {
754
1305
  return err instanceof Error && err.code === USER_ALREADY_EXISTS;
755
1306
  }
756
-
757
- // src/feature-requires.ts
758
- function buildFeatureRequiresIndex(features) {
759
- const index = /* @__PURE__ */ new Map();
760
- for (const feature of features) {
761
- const requires = (feature.requires ?? []).filter((key) => key !== feature.featureKey);
762
- if (requires.length > 0) index.set(feature.featureKey, requires);
763
- }
764
- return index;
765
- }
766
- function collectUnsatisfiedRequires(selected, index) {
767
- const own = new Set(selected);
768
- const unsatisfied = /* @__PURE__ */ new Set();
769
- for (const featureKey of selected) {
770
- for (const required of index.get(featureKey) ?? []) {
771
- if (!own.has(required)) unsatisfied.add(required);
772
- }
773
- }
774
- return [...unsatisfied].sort((a, b) => a.localeCompare(b));
775
- }
776
- function missingRequiresFor(bundle, coveredFeatures) {
777
- const missing = (bundle.requiresFeatures ?? []).filter((key) => !coveredFeatures.has(key));
778
- return [...new Set(missing)].sort((a, b) => a.localeCompare(b));
779
- }
780
- function resolveBundleAvailability(bundle, coveredFeatures) {
781
- if (bundle.features.length > 0 && bundle.features.every((f) => coveredFeatures.has(f))) {
782
- return "covered";
783
- }
784
- if (missingRequiresFor(bundle, coveredFeatures).length > 0) return "missing-requires";
785
- return "bookable";
786
- }
787
- function coverageExcludingSelf(selfVersionId, planFeatures, selectedBundles) {
788
- const covered = new Set(planFeatures);
789
- for (const bundle of selectedBundles) {
790
- if (bundle.bundleVersionId === selfVersionId) continue;
791
- for (const feature of bundle.features) covered.add(feature);
1307
+ var PERSISTENCE_REFUSAL = "PersistenceRefusal";
1308
+ var PersistenceRefusal = class extends Error {
1309
+ constructor(code, reason, message, params = {}) {
1310
+ super(message);
1311
+ this.code = code;
1312
+ this.reason = reason;
1313
+ this.params = params;
1314
+ this.name = PERSISTENCE_REFUSAL;
792
1315
  }
793
- return covered;
794
- }
795
- function isBundleRedundant(bundle, planFeatures, selectedBundles) {
796
- const covered = coverageExcludingSelf(bundle.bundleVersionId, planFeatures, selectedBundles);
797
- return resolveBundleAvailability(bundle, covered) === "covered";
798
- }
799
- function compareSelectable(a, b) {
800
- const orderA = a.sortOrder ?? Number.MAX_SAFE_INTEGER;
801
- const orderB = b.sortOrder ?? Number.MAX_SAFE_INTEGER;
802
- if (orderA !== orderB) return orderA - orderB;
803
- return a.bundleVersionId.localeCompare(b.bundleVersionId);
1316
+ code;
1317
+ reason;
1318
+ params;
1319
+ };
1320
+ function isPersistenceRefusal(err) {
1321
+ if (!(err instanceof Error) || err.name !== PERSISTENCE_REFUSAL) return false;
1322
+ const { code, reason } = err;
1323
+ return typeof code === "string" && (reason === "gone" || reason === "moved");
804
1324
  }
805
- function selectChargeableBundles(planFeatures, selectedBundles) {
806
- const kept = [...selectedBundles].sort(compareSelectable);
807
- for (; ; ) {
808
- const redundantIndex = kept.findIndex(
809
- (bundle) => isBundleRedundant(bundle, planFeatures, kept)
1325
+
1326
+ // src/optional-canonical-models.ts
1327
+ var OPTIONAL_CANONICAL_MODELS = {
1328
+ SuperAdminUser: ["core.superAdminProvisioning"],
1329
+ SuperAdminMfa: ["core.mfa"],
1330
+ AppliedSettings: ["core.appliedSettings"],
1331
+ SettingsChange: ["core.appliedSettings"],
1332
+ MaintenanceWindow: ["core.maintenanceWindows"],
1333
+ SubscriptionNotice: ["tenantBilling.subscriptionNotices"],
1334
+ VersionRetirement: ["tenantBilling.versionRetirements"],
1335
+ SubscriberLedgerEntry: ["entitlement.subscriberLedgerRepository"],
1336
+ PromoCodeHold: ["promo.holdRepository"]
1337
+ };
1338
+ function membersLeftOut(notAdopted = []) {
1339
+ const unknown = notAdopted.filter((model) => !Object.hasOwn(OPTIONAL_CANONICAL_MODELS, model));
1340
+ if (unknown.length > 0) {
1341
+ throw new Error(
1342
+ `notAdopted names ${unknown.join(", ")}, which the persistence bundle cannot leave out. It can leave out ${Object.keys(OPTIONAL_CANONICAL_MODELS).join(", ")}; for any other model it needs, pass your own adapter for the port that model serves.`
810
1343
  );
811
- if (redundantIndex === -1) return kept;
812
- kept.splice(redundantIndex, 1);
813
1344
  }
1345
+ return new Set(
1346
+ notAdopted.flatMap((model) => OPTIONAL_CANONICAL_MODELS[model])
1347
+ );
814
1348
  }
815
1349
 
816
- // src/payment-gateway.types.ts
817
- var PAYMENT_CALLBACK_REJECTED = "PAYMENT_CALLBACK_REJECTED";
818
- var PaymentCallbackRejectedError = class extends Error {
819
- code = PAYMENT_CALLBACK_REJECTED;
820
- constructor(reason) {
821
- super(`Payment callback rejected: ${reason}`);
822
- this.name = "PaymentCallbackRejectedError";
1350
+ // src/concurrency-gate.ts
1351
+ function concurrencyGate(limit) {
1352
+ if (!Number.isInteger(limit) || limit < 1) {
1353
+ throw new RangeError(`A concurrency limit is a whole number of at least 1, not ${limit}.`);
823
1354
  }
824
- };
825
- function isPaymentCallbackRejectedError(err) {
826
- return err instanceof Error && err.code === PAYMENT_CALLBACK_REJECTED;
827
- }
828
-
829
- // src/registration.types.ts
830
- var PENDING_EMAIL_TTL_HOURS = 72;
831
- var PENDING_ONBOARDING_TTL_DAYS = 14;
832
- var PENDING_CHECKOUT_TTL_DAYS = 30;
833
- var OTP_TTL_MINUTES = 10;
834
- var PASSWORD_RESET_TTL_MINUTES = 30;
835
- var OTP_RATE_LIMIT_MAX_SENDS = 3;
836
- var OTP_RATE_LIMIT_WINDOW_MINUTES = 15;
837
- var OTP_VERIFY_MAX_ATTEMPTS = 5;
838
- var REGISTRATION_STEP_BY_STATUS = {
839
- PENDING_EMAIL_VERIFICATION: 2,
840
- EMAIL_VERIFIED: 3,
841
- PLAN_SELECTED: 4,
842
- CHECKOUT_STARTED: 4,
843
- EXPIRED: 1,
844
- DELETED: 1
845
- };
846
- var REGISTRATION_RESUME_TTL_MINUTES = 60;
847
-
848
- // src/plan-mapping.ts
849
- function toPlanRow(row) {
850
- return {
851
- id: row.id,
852
- planKey: row.planKey,
853
- label: row.label,
854
- description: row.description,
855
- icon: row.icon,
856
- sortOrder: row.sortOrder,
857
- createdAt: row.createdAt.toISOString(),
858
- updatedAt: row.updatedAt.toISOString(),
859
- deletedAt: toIsoOrNull(row.deletedAt)
1355
+ let active = 0;
1356
+ const waiting = [];
1357
+ const release = () => {
1358
+ const next = waiting.shift();
1359
+ if (next) next();
1360
+ else active -= 1;
1361
+ };
1362
+ return async (work) => {
1363
+ if (active < limit) active += 1;
1364
+ else await new Promise((admit) => waiting.push(admit));
1365
+ try {
1366
+ return await work();
1367
+ } finally {
1368
+ release();
1369
+ }
860
1370
  };
861
1371
  }
862
- function toPlanVersionRow(row, planKey, fields) {
863
- const mapped = {
864
- id: row.id,
865
- version: row.version,
866
- baseVersionId: row.baseVersionId,
867
- planId: planKey,
868
- features: toFeatureKeys(row.features),
869
- quotas: toQuotaEffects(row.quotas),
870
- monthlyNet: String(row.monthlyNet),
1372
+ var GATES = /* @__PURE__ */ new WeakMap();
1373
+ function concurrencyGateOf(pool, limit) {
1374
+ const known = GATES.get(pool);
1375
+ if (known) {
1376
+ if (known.limit !== limit) {
1377
+ throw new RangeError(
1378
+ `This pool is bounded at ${known.limit} transactions already; a second bound of ${limit} would split it.`
1379
+ );
1380
+ }
1381
+ return known.gate;
1382
+ }
1383
+ const gate = concurrencyGate(limit);
1384
+ GATES.set(pool, { limit, gate });
1385
+ return gate;
1386
+ }
1387
+
1388
+ // src/error-messages.ts
1389
+ var ERROR_MESSAGES_EN = {
1390
+ // ── setup ──
1391
+ SETUP_DISABLED: "{envVar} is not set \u2014 setup is disabled.",
1392
+ INVALID_SETUP_TOKEN: "The setup token is not valid.",
1393
+ SETUP_ALREADY_DONE: "Setup has already been completed.",
1394
+ INVALID_EMAIL: "That is not a valid email address.",
1395
+ EMAIL_EXISTS: "An account with this email address already exists.",
1396
+ // ── auth ──
1397
+ NOT_AUTHENTICATED: "Not authenticated",
1398
+ NO_TENANT_ASSIGNED: "No tenant assigned",
1399
+ TENANT_CONTEXT_MISSING: "No tenant ID found on the request",
1400
+ TENANT_ADMIN_REQUIRED: "This action requires the TENANT_ADMIN role.",
1401
+ BILLING_PERMISSION_REQUIRED: "This part of the billing area requires the billing permission.",
1402
+ SUPER_ADMIN_REQUIRED: "Only the SUPER_ADMIN role is allowed",
1403
+ MFA_NOT_SET_UP: "Run the MFA setup via the CLI first.",
1404
+ MFA_REQUIRED: "TOTP code required in the X-Mfa-Code header.",
1405
+ MFA_FAILED: "Invalid TOTP code.",
1406
+ AUTH_GUARDS_NOT_CONFIGURED: "TenantBillingModule.forRoot.authGuards is not configured.",
1407
+ // ── catalog ──
1408
+ PLAN_HAS_DRAFTS: "Plan '{planKey}' still has {draftCount} open draft version(s). Discard them first (DELETE /admin/catalog/plan-versions/:id) or publish them.",
1409
+ PLAN_HAS_PUBLISHED_VERSIONS: "Plan '{planKey}' cannot be {operation} \u2014 it has {publishedCount} published version(s) ({liveCount} live, {supersededCount} superseded). Existing subscriptions reference those versions (contract protection P1), so the plan record must be preserved.",
1410
+ PLAN_HARD_DELETE_NOT_IMPLEMENTED: "Hard delete is not implemented in the current repository. Implement PlanRepository.hardDelete.",
1411
+ PLAN_VERSION_ALREADY_PUBLISHED: "PlanVersion '{versionId}' is already published; it is not published again or discarded.",
1412
+ PLAN_VERSION_NOT_EDITABLE: "PlanVersion '{versionId}' is not editable. Only drafts and published versions are editable that are latest-in-chain, bind no subscription yet, and whose validFrom lies in the future.",
1413
+ PLAN_VERSION_REGRESSION: "This plan version is regressive (feature removed / quota lowered / price raised). Publishing requires an explicit `forceRegressive: true` (UI confirmation dialog with MFA).",
1414
+ PLAN_VERSION_ZERO_PRICE: "A plan version cannot be published with a price of 0.00 (guard against seed placeholder). For deliberately free special contracts, set allowZeroPrice.",
1415
+ PLAN_VERSION_DISCARD_NOT_IMPLEMENTED: "Discard is not implemented in the current repository. Implement PlanRepository.deletePlanVersionDraft.",
1416
+ PLAN_VERSION_NOT_PUBLISHED: "PlanVersion '{versionId}' is not published and cannot be terminated.",
1417
+ PLAN_VERSION_SUPERSEDED: "PlanVersion '{versionId}' has already been superseded by a newer version and cannot be terminated.",
1418
+ PLAN_VERSION_VALID_FROM_REQUIRED: "validFrom must be set when publishing (on the draft or the publish call)..",
1419
+ PLAN_VERSION_VALID_FROM_INVALID: "validFrom '{validFrom}' is not a day (YYYY-MM-DD)",
1420
+ PLAN_VERSION_VALID_FROM_NOT_AFTER_PREVIOUS: "validFrom ({validFrom}) must be strictly after the validFrom of the previous version ({previousValidFrom}).",
1421
+ PLAN_VERSION_VALID_FROM_NOT_GAPLESS: "The predecessor has validUntil={previousValidUntil} \u2014 the successor must start seamlessly on the next day ({requiredValidFrom}). Received: {received}.",
1422
+ PLAN_VERSION_VALID_UNTIL_INVALID: "validUntil '{validUntil}' is not a day (YYYY-MM-DD)",
1423
+ PLAN_VERSION_VALID_UNTIL_BEFORE_FROM: "validUntil ({validUntil}) must be strictly after validFrom ({validFrom}).",
1424
+ PLAN_TERMINATE_INVALID_DATE: "endsAt is not a valid date.",
1425
+ PLAN_TERMINATE_DATE_NOT_FUTURE: "endsAt ({endsAt}) must lie strictly in the future.",
1426
+ PLAN_TERMINATE_NOT_IMPLEMENTED: "Terminate is not implemented in the current repository. Implement PlanRepository.terminate.",
1427
+ PLAN_TERMINATE_BEFORE_RETIREMENT_MOVES: "Subscriptions still move to version {version} of {planKey}, so it can end on {date} at the earliest.",
1428
+ PLAN_TERMINATE_WHILE_MOVES_OVERDUE: "{count} subscriptions are past their date and still to be moved to version {version} of {planKey}, so it cannot end until they have moved.",
1429
+ PLAN_TERMINATE_WHILE_NOTICES_UNDELIVERED: "{count} subscriptions have not yet been told that they move to version {version} of {planKey}, so it cannot end until they have been.",
1430
+ BUNDLE_VERSION_ALREADY_PUBLISHED: "BundleVersion '{versionId}' is already published; it is not published again or discarded.",
1431
+ BUNDLE_VERSION_NOT_EDITABLE: "BundleVersion '{versionId}' is not editable. Only drafts and published versions are editable that are latest-in-chain, bind no subscription yet, and whose validFrom lies in the future.",
1432
+ BUNDLE_VERSION_NOT_PUBLISHED: "BundleVersion '{bundleVersionId}' is not published and cannot be booked.",
1433
+ BUNDLE_VERSION_SUPERSEDED: "BundleVersion '{bundleVersionId}' has been superseded by a newer version.",
1434
+ BUNDLE_VERSION_NOT_YET_ON_SALE: "BundleVersion '{bundleVersionId}' goes on sale on {validFrom} and cannot be booked before.",
1435
+ BUNDLE_DELETED: "Bundle '{bundleKey}' has been deleted from the catalogue and cannot be booked.",
1436
+ BUNDLE_VERSION_REGRESSION: "This bundle version is regressive (feature removed / quota lowered / price raised). Publishing requires an explicit `forceRegressive: true` (UI confirmation dialog with MFA).",
1437
+ BUNDLE_VERSION_ZERO_PRICE: "A bundle version cannot be published with an explicit price of 0.00 (guard against seed placeholders). For free bundles leave it null, or set allowZeroPrice.",
1438
+ BUNDLE_VERSION_NO_PRICE: "This bundle version cannot be published without a price: neither a base price nor any plan override resolves one.",
1439
+ BUNDLE_VERSION_NOT_PRICED_FOR_PLAN: "This bundle is offered to plan '{planKey}', which is sold {billingCycle}, and no {billingCycle} price resolves for it \u2014 neither a base price nor a plan override.",
1440
+ BUNDLE_VERSION_DISCARD_NOT_IMPLEMENTED: "Discard is not implemented in the current repository. Implement BundleRepository.deleteDraft.",
1441
+ BUNDLE_VERSION_VALID_FROM_REQUIRED: "Published bundle versions must keep a validFrom. Set a new future date, or edit the draft before publishing.",
1442
+ BUNDLE_VERSION_VALID_FROM_INVALID: "validFrom '{validFrom}' is not a day (YYYY-MM-DD)",
1443
+ BUNDLE_VERSION_VALID_FROM_NOT_AFTER_PREVIOUS: "validFrom ({validFrom}) must be strictly after the validFrom of the previous version ({previousValidFrom}).",
1444
+ BUNDLE_VERSION_VALID_FROM_NOT_GAPLESS: "The predecessor has validUntil={previousValidUntil} \u2014 the successor must start seamlessly on the next day ({requiredValidFrom}). Received: {received}.",
1445
+ BUNDLE_VERSION_VALID_FROM_NOT_FUTURE: "validFrom ({validFrom}) must, for a published-but-future bundle version, still lie in the future.",
1446
+ BUNDLE_VERSION_VALID_UNTIL_INVALID: "validUntil '{validUntil}' is not a day (YYYY-MM-DD)",
1447
+ BUNDLE_VERSION_VALID_UNTIL_BEFORE_FROM: "validUntil ({validUntil}) must be strictly after validFrom ({validFrom}).",
1448
+ STRICT_MODE_VIOLATIONS: "The strict-mode check found drift against the discovery snapshot.",
1449
+ PLAN_NOT_FOUND: "Plan '{planId}' not found",
1450
+ PLAN_VERSION_NOT_FOUND: "PlanVersion '{versionId}' not found",
1451
+ BUNDLE_NOT_FOUND: "Bundle '{bundleId}' not found",
1452
+ BUNDLE_VERSION_NOT_FOUND: "BundleVersion '{bundleVersionId}' not found",
1453
+ FEATURE_NOT_FOUND: "Feature '{featureKey}' not found",
1454
+ QUOTA_NOT_FOUND: "Quota '{quotaKey}' not found",
1455
+ PROMOTION_NOT_FOUND: "Promotion '{promotionId}' not found",
1456
+ PROMOTION_VALUE_INVALID: "The value of a '{type}' promotion is not one its type takes: a percentage above 0 and at most 100, an amount above 0, an intro price of at least 0 for a whole number of months, or a whole number of free months.",
1457
+ MARKETING_PROJECTION_NOT_FOUND: "MarketingProjection '{projectionId}' not found",
1458
+ PLAN_ALREADY_EXISTS: "Plan '{planKey}' already exists",
1459
+ BUNDLE_ALREADY_EXISTS: "Bundle '{bundleKey}' already exists",
1460
+ MARKETING_PROJECTION_ALREADY_EXISTS: "Marketing projection for {targetType}/{targetVersionId}/{locale} already exists \u2014 use PATCH to edit it",
1461
+ PLAN_DRAFT_ALREADY_EXISTS: "Plan '{planKey}' already has a draft version v{draftVersion}; publish or discard it first",
1462
+ BUNDLE_DRAFT_ALREADY_EXISTS: "Bundle '{bundleKey}' already has a draft version v{draftVersion}; publish or discard it first",
1463
+ QUOTA_NOT_IN_DISCOVERY_SNAPSHOT: "Quota '{quotaKey}' is not in the discovery snapshot \u2014 a quota that is not declared in code cannot be approved",
1464
+ DISCOVERY_STATUS_TRANSITION_INVALID: "Transition '{from}' \u2192 '{to}' is not allowed",
1465
+ DISCOVERY_NOT_INITIALIZED: "Approval requires a discovery snapshot \u2014 discovery is not initialised (#25)",
1466
+ // ── catalogue import ──
1467
+ PLAN_CATALOG_UNREADABLE: "That file is not a plan catalog \u2014 it could not be read as one. Check that it is the YAML your app declares its plans in.",
1468
+ PLAN_CATALOG_INVALID: "The plan catalog was read, and then rejected: {message}",
1469
+ // ── billing ──
1470
+ BUNDLE_ALREADY_SUBSCRIBED: "Subscription '{subscriptionId}' has already actively booked this bundle.",
1471
+ BUNDLE_INCOMPATIBLE_WITH_PLAN: "This bundle cannot be booked on the {planKey} plan. The plans that can book it: {allowedPlanKeys}.",
1472
+ BUNDLE_NOT_SELF_SERVICE: "Bundle '{bundleKey}' is only activated via a special contract. Please contact the contract manager.",
1473
+ BUNDLE_CYCLE_EXCEEDS_PLAN: "A yearly bundle cannot run beside a monthly plan: it would still be committed on every day the plan could end.",
1474
+ BUNDLE_NOT_PRICED_FOR_THIS_PLAN: "This bundle has no price for the {planKey} plan in this billing cycle, so it cannot be booked from here.",
1475
+ BUNDLE_CANNOT_RUN_ON_UPCOMING_PLAN: "This bundle cannot run on the {planKey} plan, which the subscription moves to with effect from {from}.",
1476
+ BUNDLE_CANNOT_RUN_ON_UPCOMING_CYCLE: "A yearly bundle cannot run beside the monthly billing the subscription moves to with effect from {from}.",
1477
+ SUBSCRIPTION_BUNDLE_ALREADY_CANCELLED: "SubscriptionBundle '{subscriptionBundleId}' is already cancelled.",
1478
+ SUBSCRIPTION_BUNDLE_NOT_CANCELLED: "SubscriptionBundle '{subscriptionBundleId}' is not cancelled.",
1479
+ SUBSCRIPTION_BUNDLE_CANCELLATION_EFFECTIVE: "Cancellation already in effect \u2014 book the bundle again.",
1480
+ SUBSCRIPTION_NOT_FOUND: "No subscription for tenant {tenantId}",
1481
+ SUBSCRIPTION_TENANT_MISMATCH: "Subscription does not belong to the tenant",
1482
+ SUBSCRIPTION_BUNDLE_NOT_FOUND: "SubscriptionBundle '{subscriptionBundleId}' not found",
1483
+ TENANT_NOT_FOUND: "Tenant {slug} not found",
1484
+ NO_ACTIVE_PLAN_VERSION: "No version of plan {planId} is on sale as of {asOf}.",
1485
+ BOUND_PLAN_VERSION_UNREADABLE: 'The plan version this subscription is bound to ({planVersionId}) cannot be read for plan "{planKey}", so no change can be quoted.',
1486
+ PLAN_NOT_IN_CATALOG: 'Plan "{planKey}" is not in the catalog',
1487
+ PLAN_NOT_SELF_SERVICE: "{planName} is only activated via a special contract. Please contact the contract manager.",
1488
+ PLAN_NOT_SOLD_IN_CYCLE: "{planName} has no price for this billing rhythm and cannot be booked in it.",
1489
+ PLAN_CHANGE_BLOCKED: "Plan change during onboarding is blocked.",
1490
+ SUBSCRIPTION_CHANGED: "This subscription changed while the request was being decided. Reload it.",
1491
+ NO_SUBSCRIPTION: "This tenant has no subscription to cancel.",
1492
+ CANCELLATION_TERMS_CHANGED: "The effective date changed since it was shown. Confirm the new one.",
1493
+ VERSION_OFFER_CHANGED: "The offer changed since it was shown. Look at the current one before switching.",
1494
+ PLAN_CHANGE_QUOTE_CHANGED: "This plan changed since it was shown. Look at it again before changing to it.",
1495
+ PLAN_CHANGE_VERSION_NOT_NAMED: "A plan change has to name the version its preview showed.",
1496
+ VERSION_SWITCH_AFTER_CANCELLATION: "This subscription ends before this version would take effect, so it cannot be switched to.",
1497
+ VERSION_ENDS_BEFORE_SWITCH: "This version stops being sold before it would take effect, so it cannot be switched to.",
1498
+ RETIREMENT_TERMS_NOT_CONFIRMED: "Retiring a version for running subscriptions needs a clause in your terms. Set tenantBilling.orderlyRetirement.termsConfirmed in config/saas.yaml once they carry it.",
1499
+ RETIREMENT_VERSION_ON_SALE: "Version {version} of {planKey} is still on sale. End its sale first, so nobody books it after the announcement.",
1500
+ RETIREMENT_REPLACEMENT_NOT_ON_SALE: "Version {version} of {planKey} is not on sale, so subscriptions cannot continue on it.",
1501
+ RETIREMENT_REPLACEMENT_NOT_SOLD_IN_RHYTHM: "{count} of these subscriptions are billed in a rhythm version {version} of {planKey} has no price for, so they cannot continue on it.",
1502
+ RETIREMENT_REPLACEMENT_CANNOT_CARRY_BUNDLES: "{count} of these subscriptions hold a bundle that cannot run on version {version} of {planKey}, so they cannot continue on it.",
1503
+ RETIREMENT_REPLACEMENT_IS_RETIRED: "A version cannot be its own replacement.",
1504
+ RETIREMENT_NOTHING_AFFECTED: "No running subscription is on version {version} of {planKey}, so there is nobody to tell.",
1505
+ RETIREMENT_WITHIN_TWELVE_MONTHS: "{count} of these subscriptions were reached by a retirement within the last twelve months. A subscription is reached at most once a year.",
1506
+ RETIREMENT_PREVIEW_CHANGED: "The subscriptions this retirement reaches changed since they were shown. Look at them again before announcing it.",
1507
+ RETIREMENT_SWITCH_NOT_PENDING: "No retirement of your version is waiting for its date, so there is nothing to switch to.",
1508
+ RETIREMENT_SWITCH_IN_TRIAL: "The switch opens when your trial ends.",
1509
+ RETIREMENT_SWITCH_BUNDLE_CANNOT_FOLLOW: "{bundleName} cannot run on {planName} and runs until {until} at the earliest. Once it is cancelled, the switch can be made from that day.",
1510
+ RETIREMENT_SWITCH_NOT_OPEN: "This subscription cannot switch now: a change is scheduled, it has ended, or its plan is held for a special contract.",
1511
+ RETIREMENT_SWITCH_CHANGED: "The retirement changed since it was shown. Look at it again before switching.",
1512
+ SUBSCRIPTION_ENDED: "This subscription has ended. Its plan can no longer be changed.",
1513
+ PLAN_LOCKED: "Active {planName} special contract \u2014 please contact the contract manager to change plans.",
1514
+ QUOTA_OVER_TARGET: "Current usage {used} exceeds the target limit {targetMax} ({quotaKey}) in the {planName} plan. Please reduce usage first.",
1515
+ FEATURE_LOST: "Switching means losing access to one feature. Existing data is retained and never deleted \u2014 upgrading again unlocks it.",
1516
+ FEATURES_LOST: "Switching means losing access to {count} features. Existing data is retained and never deleted \u2014 upgrading again unlocks it.",
1517
+ NO_CHANGE: "Target plan and billing cycle already match the current state.",
1518
+ CANCELLATION_LOCKS_THE_CYCLE: "This subscription is cancelled, so its billing cycle cannot change. The plan can \u2014 keep the current cycle to change it today.",
1519
+ CYCLE_SHORTENS_AT_TERM_END: "A monthly {planName} cannot start inside the yearly term you are in. The upgrade takes effect when that term ends; to have it today, keep the yearly cycle.",
1520
+ BUNDLE_BOOKING_OUTLASTS_TARGET_CYCLE: "{bundleName} is billed yearly and runs until {until} at the earliest, which a monthly plan cannot carry. Once it is cancelled, a change that takes effect on or after that day goes through \u2014 or keep the yearly cycle.",
1521
+ BUNDLE_BOOKING_DOES_NOT_FIT_TARGET_PLAN: "{bundleName} cannot run on {planName} and runs until {until} at the earliest. Once it is cancelled, a change that takes effect on or after that day goes through \u2014 or choose another plan.",
1522
+ REDUNDANT_FEATURES: "The plan or another booked bundle already includes {count} of the features in this bundle \u2014 booking it pays for them twice.",
1523
+ MINIMUM_TERM_BINDS: "The minimum term extends beyond the end of the period \u2014 the cancellation only takes effect when the minimum term ends.",
1524
+ BUNDLE_FEATURE_DEPENDENCY_UNSATISFIED: "The bundle requires [{features}] \u2014 present neither in the plan nor in the active bundles.",
1525
+ ONBOARDING_CREATE_FAILED: "The account could not be created. Please try again.",
1526
+ BUNDLE_PREVIEW_ARGUMENT_AMBIGUOUS: "Exactly one of bundleVersionId (add preview) or subscriptionBundleId (cancel preview) must be given.",
1527
+ SUBSCRIPTION_PK_MISSING: "The adapter returned a subscription usage record without an id. Pass the subscription primary key through (see SubscriptionUsageRecord.id).",
1528
+ LIMIT_EXCEEDED: "The limit for {dimension} has been reached: {used} of {max}.",
1529
+ QUOTA_DIMENSION_UNKNOWN: 'Unknown quota dimension "{dimension}".',
1530
+ // ── promo ──
1531
+ PROMO_CODE_NOT_FOUND: "Code not found",
1532
+ PROMO_CODE_ALREADY_EXISTS: "The code exists, or a deleted code carries it; a deleted code keeps its name.",
1533
+ PROMO_CODE_HAS_REDEMPTIONS: "The code already has redemptions, or checkouts holding one \u2014 it cannot be soft-deleted. Pause it instead.",
1534
+ PROMO_CODE_NOT_REDEEMABLE: "Code cannot be redeemed: {reason}",
1535
+ PROMO_CODE_FORMAT_INVALID: 'The code may only contain upper-case letters, digits, "-" and "_" (4\u201332 characters).',
1536
+ PROMO_PERCENT_OUT_OF_RANGE: "The percentage must be between 0 and 100.",
1537
+ PROMO_AMOUNT_NOT_POSITIVE: "The amount must be positive.",
1538
+ PROMO_ONE_OFF_WITH_DURATION: "A one-off discount must not set a duration.",
1539
+ PROMO_DURATION_INVALID: "Invalid duration (at most 24 months or billing periods).",
1540
+ PROMO_VALIDITY_WINDOW_INVALID: "Invalid validity window.",
1541
+ PROMO_PLAN_NOT_DISCOUNTABLE: "{plan}-Plan cannot be discounted.",
1542
+ PROMO_MIN_AMOUNT_NOT_POSITIVE: "The minimum plan gross amount must be positive.",
1543
+ PROMO_WOULD_PRODUCE_ZERO_INVOICE: "For absolute amounts the discount must stay below the lowest applicable plan price, or allowZeroInvoice must be enabled.",
1544
+ PROMO_MAX_REDEMPTIONS_LOWERED: "maxRedemptions cannot be lowered.",
1545
+ // ── contract ──
1546
+ CHECKOUT_OFFER_LINE_ITEMS_REQUIRED: "A checkout offer can yield only one contract, and only once its line items are frozen.",
1547
+ CHECKOUT_OFFER_PLAN_LINE_ITEM_REQUIRED: "A checkout offer requires a frozen plan line item.",
1548
+ CHECKOUT_OFFER_BUNDLE_LINE_ITEMS_REQUIRED: "Every selected bundle version requires a frozen bundle line item.",
1549
+ CHECKOUT_OFFER_BUNDLE_VERSION_NOT_BOOKABLE: "At least one bundle version from the checkout offer is no longer bookable.",
1550
+ CHECKOUT_OFFER_FEATURE_DEPENDENCY_UNSATISFIED: "The selected plan does not cover all feature dependencies: [{missingRequires}] are missing from the plan + selected bundles.",
1551
+ CHECKOUT_OFFER_PLAN_NOT_OFFERED: "Plan '{planKey}' is not offered with a {billingCycle} price at the moment.",
1552
+ CHECKOUT_OFFER_BUNDLE_NOT_OFFERED: "Bundle version '{bundleVersionId}' cannot be added to this offer ({reason}).",
1553
+ CHECKOUT_OFFER_PROMO_CODE_NOT_ACCEPTED: "The promo code cannot be applied to this offer ({reason}).",
1554
+ CHECKOUT_OFFER_PRICE_NOT_CURRENT: "The prices of checkout offer '{offerId}' no longer match the catalogue; create a new offer.",
1555
+ SUBSCRIPTION_CONTRACT_LINE_ITEMS_REQUIRED: "A subscription contract requires at least one line item.",
1556
+ SUBSCRIPTION_CONTRACT_PLAN_LINE_ITEM_REQUIRED: "A subscription contract requires exactly one plan base item.",
1557
+ SUBSCRIPTION_CONTRACT_INVALID_DATE: "{field} must be a valid date.",
1558
+ SUBSCRIPTION_CONTRACT_INVALID_WINDOW: "effectiveUntil must be after effectiveFrom.",
1559
+ SUBSCRIPTION_CONTRACT_LINE_ITEM_TAX_MISMATCH: "A line item's taxAmount must be exactly priceGross minus priceNet.",
1560
+ SUBSCRIPTION_CONTRACT_TAX_RATE_NOT_PERCENT: "A subscription contract states a tax rate of {taxRate} at {field}, which is not a percentage: a rate lies from 0 to 100, and a value between 0 and 1 is refused as a fraction.",
1561
+ SUBSCRIPTION_CONTRACT_TERMINATION_BEFORE_START: "effectiveUntil must be after the effectiveFrom of the contract.",
1562
+ SUBSCRIPTION_CONTRACT_LINE_ITEM_CURRENCY_MISMATCH: "A line item must be booked in the currency its contract was priced in.",
1563
+ SUBSCRIPTION_CONTRACT_LINES_DO_NOT_ADD_UP: "The line items of a subscription contract add up to {lines} for {field}, but the contract states {stated}.",
1564
+ SUBSCRIPTION_CONTRACT_DISCOUNT_NEGATIVE: "A subscription contract states a discount of {amount} at {field}; a discount takes money off and is never negative.",
1565
+ CHECKOUT_OFFER_NOT_FOUND: "CheckoutOffer '{offerId}' not found",
1566
+ CHECKOUT_OFFER_EXPIRED: "Checkout offer '{offerId}' has expired and cannot be {action}",
1567
+ CHECKOUT_OFFER_ALREADY_CONSUMED: "Checkout offer '{offerId}' has already been consumed and cannot be {action}",
1568
+ CHECKOUT_OFFER_NOT_CONSUMED: "CheckoutOffer '{offerId}' must be consumed before the contract is created",
1569
+ CHECKOUT_OFFER_CHANGED: "Checkout offer '{offerId}' changed while it was being concluded. Load it again.",
1570
+ SUBSCRIPTION_CONTRACT_NOT_FOUND: "SubscriptionContract '{contractId}' not found",
1571
+ NO_ACTIVE_SUBSCRIPTION_CONTRACT: "No active subscription contract for tenant {tenantId}",
1572
+ SUBSCRIPTION_CONTRACT_ALREADY_CLOSED: "SubscriptionContract '{contractId}' is already closed",
1573
+ SUBSCRIPTION_CONTRACT_CHANGED: "The contracts of tenant '{tenantId}' changed while a successor was being written, or one begins after the moment it would take effect, so it would run beside another. Nothing was written.",
1574
+ // ── subscriber ──
1575
+ SUBSCRIBER_REQUIRED: "Tenant '{tenantId}' has no subscriber. Nothing is agreed or charged without the party to it: create the tenant's subscriber first.",
1576
+ SUBSCRIBER_ALREADY_EXISTS: "Tenant '{tenantId}' already has a subscriber.",
1577
+ SUBSCRIBER_NOT_FOUND: "Subscriber '{subscriberId}' not found",
1578
+ SUBSCRIBER_LEGAL_NAME_REQUIRED: "A subscriber needs its legal name.",
1579
+ SUBSCRIBER_DETAIL_INVALID: "The subscriber's {field} is not valid.",
1580
+ SUBSCRIBER_IDENTITY_NOT_A_CONTACT: "{field} is part of the subscriber's legal identity and changes only as a correction, with a reason.",
1581
+ SUBSCRIBER_CORRECTION_REASON_REQUIRED: "A correction of the legal identity needs a reason.",
1582
+ SUBSCRIBER_CORRECTION_ACTOR_REQUIRED: "A correction of the legal identity has to say who makes it.",
1583
+ SUBSCRIBER_CORRECTION_CHANGES_NOTHING: "The correction changes nothing: every value it names is already recorded.",
1584
+ SUBSCRIBER_TAKEOVER_IS_A_TRANSFER: "Another legal entity taking over a subscriber is a transfer, not a correction, and cannot be recorded as an edit.",
1585
+ // ── registration ──
1586
+ PENDING_REGISTRATION_NOT_FOUND: "This registration could not be found. It may have already been completed or discarded.",
1587
+ PENDING_REGISTRATION_EXPIRED: "This registration has expired. Please start again.",
1588
+ INVALID_REGISTRATION_STATE: "This step is not available at the current stage of the registration.",
1589
+ OTP_INVALID: "That code is not correct. Please check it and try again.",
1590
+ OTP_EXPIRED: "That code has expired. Please request a new one.",
1591
+ OTP_LOCKED: "Too many incorrect attempts. Please request a new code.",
1592
+ RATE_LIMITED: "Too many attempts. Please try again in {retryAfterSeconds} seconds.",
1593
+ RESUME_TOKEN_INVALID: "This resume link is no longer valid. Please request a new one.",
1594
+ RESUME_NOT_CONFIGURED: "Resuming a registration is not available.",
1595
+ CONFIGURATOR_NOT_CONFIGURED: "The configurator is not available.",
1596
+ CONFIG_NOT_SAVED: "The configuration could not be saved.",
1597
+ PLAN_NOT_AVAILABLE: "This plan is not available.",
1598
+ PLAN_NOT_SELECTED: "Please select a plan first.",
1599
+ MODEL_NOT_AVAILABLE: "This option is not available.",
1600
+ // ── payments ──
1601
+ PAYMENTS_NOT_CONFIGURED: "Payment methods cannot be set up here yet.",
1602
+ PAYMENT_GATEWAY_ACCOUNT_UNKNOWN: "No payment gateway account is configured under '{account}'.",
1603
+ PAYMENT_CALLBACK_REJECTED: "The payment callback could not be verified.",
1604
+ PAYMENT_RETURN_URL_NOT_ALLOWED: "The {field} leads to a site this installation does not return to.",
1605
+ PAYMENT_GATEWAY_FAILED: "The payment provider did not answer as expected. Please try again in a few minutes.",
1606
+ // ── entitlement (code lives in upsell.types.ts) ──
1607
+ [FEATURE_NOT_LICENSED]: "Feature {featureKeys} is not included in the current plan.",
1608
+ // ── settings ──
1609
+ SETTINGS_CHANGE_NOT_FOUND: "No recorded settings change has this id.",
1610
+ // ── maintenance ──
1611
+ MAINTENANCE: "The application is under maintenance.",
1612
+ MAINTENANCE_WINDOW_ALREADY_OPEN: "A maintenance window is already open. Move or cancel it before announcing another.",
1613
+ MAINTENANCE_WINDOW_NOT_OPEN: "No open maintenance window has this id.",
1614
+ MAINTENANCE_WINDOW_LOCKED: "This maintenance window is locked. Its start cannot move, and unlocking is what ends it.",
1615
+ MAINTENANCE_WINDOW_END_NOT_AFTER_START: "The end of a maintenance window has to be after its start.",
1616
+ MAINTENANCE_WINDOW_END_IN_PAST: "The end of a maintenance window cannot be in the past.",
1617
+ MAINTENANCE_TIME_INVALID: "The {field} has to be a date and time with its zone, such as 2026-10-02T22:00+02:00.",
1618
+ MAINTENANCE_MESSAGE_TOO_LONG: "The message may be at most {max} characters long."
1619
+ };
1620
+ function formatErrorMessage(template, params = {}) {
1621
+ return template.replace(/\{(\w+)\}/g, (match, name) => {
1622
+ const value = params[name];
1623
+ return value === void 0 || value === null ? match : String(value);
1624
+ });
1625
+ }
1626
+ function resolveErrorMessage(body, overrides = {}, defaults = ERROR_MESSAGES_EN) {
1627
+ const code = typeof body.code === "string" ? body.code : void 0;
1628
+ const template = (code && (overrides[code] ?? defaults[code])) ?? void 0;
1629
+ if (!template) {
1630
+ return typeof body.message === "string" ? body.message : code ?? "";
1631
+ }
1632
+ const { params, ...rest } = body;
1633
+ return formatErrorMessage(template, { ...rest, ...params });
1634
+ }
1635
+
1636
+ // src/refusal.ts
1637
+ function refusal(code, reason, params) {
1638
+ return new PersistenceRefusal(
1639
+ code,
1640
+ reason,
1641
+ formatErrorMessage(ERROR_MESSAGES_EN[code], params),
1642
+ params
1643
+ );
1644
+ }
1645
+
1646
+ // src/catalog-version-refusals.ts
1647
+ var CASES = {
1648
+ PlanVersion: {
1649
+ gone: { code: CATALOG_ERROR_CODES.PLAN_VERSION_NOT_FOUND, param: "versionId" },
1650
+ published: { code: CATALOG_ERROR_CODES.PLAN_VERSION_ALREADY_PUBLISHED, param: "versionId" },
1651
+ draft: { code: CATALOG_ERROR_CODES.PLAN_DRAFT_ALREADY_EXISTS, param: "planKey" }
1652
+ },
1653
+ BundleVersion: {
1654
+ gone: { code: CATALOG_ERROR_CODES.BUNDLE_VERSION_NOT_FOUND, param: "bundleVersionId" },
1655
+ published: {
1656
+ code: CATALOG_ERROR_CODES.BUNDLE_VERSION_ALREADY_PUBLISHED,
1657
+ param: "versionId"
1658
+ },
1659
+ draft: { code: CATALOG_ERROR_CODES.BUNDLE_DRAFT_ALREADY_EXISTS, param: "bundleKey" }
1660
+ }
1661
+ };
1662
+ function catalogVersionGone(kind, versionId) {
1663
+ const { code, param } = CASES[kind].gone;
1664
+ return new PersistenceRefusal(code, "gone", `${kind} '${versionId}' not found.`, {
1665
+ [param]: versionId
1666
+ });
1667
+ }
1668
+ function catalogVersionAlreadyPublished(kind, versionId) {
1669
+ const { code, param } = CASES[kind].published;
1670
+ return new PersistenceRefusal(
1671
+ code,
1672
+ "moved",
1673
+ `${kind} '${versionId}' is already published; it is not published again or discarded.`,
1674
+ { [param]: versionId }
1675
+ );
1676
+ }
1677
+ function catalogDraftExists(kind, key, draftVersion) {
1678
+ const { code, param } = CASES[kind].draft;
1679
+ return refusal(code, "moved", { [param]: key, draftVersion });
1680
+ }
1681
+
1682
+ // src/catalog-key-refusals.ts
1683
+ function planKeyTaken(planKey) {
1684
+ return refusal(CATALOG_ERROR_CODES.PLAN_ALREADY_EXISTS, "moved", { planKey });
1685
+ }
1686
+ function bundleKeyTaken(bundleKey) {
1687
+ return refusal(CATALOG_ERROR_CODES.BUNDLE_ALREADY_EXISTS, "moved", { bundleKey });
1688
+ }
1689
+ function marketingProjectionTaken(target) {
1690
+ return refusal(CATALOG_ERROR_CODES.MARKETING_PROJECTION_ALREADY_EXISTS, "moved", {
1691
+ targetType: target.targetType,
1692
+ targetVersionId: target.targetVersionId,
1693
+ locale: target.locale
1694
+ });
1695
+ }
1696
+
1697
+ // src/decimal-string.ts
1698
+ function toDecimalString(value) {
1699
+ if (!Number.isFinite(value)) {
1700
+ throw new RangeError(`${String(value)} is not an amount a numeric column can hold.`);
1701
+ }
1702
+ return String(value);
1703
+ }
1704
+
1705
+ // src/promo-code-refusals.ts
1706
+ function promoCodeTaken(code) {
1707
+ return new PersistenceRefusal(
1708
+ PROMO_ERROR_CODES.PROMO_CODE_ALREADY_EXISTS,
1709
+ "moved",
1710
+ `Promo code '${code}' is taken.`,
1711
+ { promoCode: code }
1712
+ );
1713
+ }
1714
+
1715
+ // src/subscription-refusals.ts
1716
+ function subscriptionGone(tenantId) {
1717
+ return refusal(BILLING_ERROR_CODES.SUBSCRIPTION_NOT_FOUND, "gone", { tenantId });
1718
+ }
1719
+ function noActivePlanVersion(planId, asOf) {
1720
+ return refusal(BILLING_ERROR_CODES.NO_ACTIVE_PLAN_VERSION, "gone", {
1721
+ planId,
1722
+ asOf: asOf.toISOString().slice(0, 10)
1723
+ });
1724
+ }
1725
+ function planNotInCatalog(planKey) {
1726
+ return refusal(BILLING_ERROR_CODES.PLAN_NOT_IN_CATALOG, "gone", { planKey });
1727
+ }
1728
+ function subscriptionBundleGone(subscriptionBundleId) {
1729
+ return refusal(BILLING_ERROR_CODES.SUBSCRIPTION_BUNDLE_NOT_FOUND, "gone", {
1730
+ subscriptionBundleId
1731
+ });
1732
+ }
1733
+ function subscriptionBundleAlreadyCancelled(subscriptionBundleId) {
1734
+ return refusal(BILLING_ERROR_CODES.SUBSCRIPTION_BUNDLE_ALREADY_CANCELLED, "moved", {
1735
+ subscriptionBundleId
1736
+ });
1737
+ }
1738
+ function subscriptionContractGone(contractId) {
1739
+ return refusal(CONTRACT_ERROR_CODES.SUBSCRIPTION_CONTRACT_NOT_FOUND, "gone", { contractId });
1740
+ }
1741
+
1742
+ // src/feature-requires.ts
1743
+ function buildFeatureRequiresIndex(features) {
1744
+ const index = /* @__PURE__ */ new Map();
1745
+ for (const feature of features) {
1746
+ const requires = (feature.requires ?? []).filter((key) => key !== feature.featureKey);
1747
+ if (requires.length > 0) index.set(feature.featureKey, requires);
1748
+ }
1749
+ return index;
1750
+ }
1751
+ function collectUnsatisfiedRequires(selected, index) {
1752
+ const own = new Set(selected);
1753
+ const unsatisfied = /* @__PURE__ */ new Set();
1754
+ for (const featureKey of selected) {
1755
+ for (const required of index.get(featureKey) ?? []) {
1756
+ if (!own.has(required)) unsatisfied.add(required);
1757
+ }
1758
+ }
1759
+ return [...unsatisfied].sort((a, b) => a.localeCompare(b));
1760
+ }
1761
+ function missingRequiresFor(bundle, coveredFeatures) {
1762
+ const missing = (bundle.requiresFeatures ?? []).filter((key) => !coveredFeatures.has(key));
1763
+ return [...new Set(missing)].sort((a, b) => a.localeCompare(b));
1764
+ }
1765
+ function resolveBundleAvailability(bundle, coveredFeatures) {
1766
+ if (bundle.features.length > 0 && bundle.features.every((f) => coveredFeatures.has(f))) {
1767
+ return "covered";
1768
+ }
1769
+ if (missingRequiresFor(bundle, coveredFeatures).length > 0) return "missing-requires";
1770
+ return "bookable";
1771
+ }
1772
+ function coverageExcludingSelf(selfVersionId, planFeatures, selectedBundles) {
1773
+ const covered = new Set(planFeatures);
1774
+ for (const bundle of selectedBundles) {
1775
+ if (bundle.bundleVersionId === selfVersionId) continue;
1776
+ for (const feature of bundle.features) covered.add(feature);
1777
+ }
1778
+ return covered;
1779
+ }
1780
+ function isBundleRedundant(bundle, planFeatures, selectedBundles) {
1781
+ const covered = coverageExcludingSelf(bundle.bundleVersionId, planFeatures, selectedBundles);
1782
+ return resolveBundleAvailability(bundle, covered) === "covered";
1783
+ }
1784
+ function compareSelectable(a, b) {
1785
+ const orderA = a.sortOrder ?? Number.MAX_SAFE_INTEGER;
1786
+ const orderB = b.sortOrder ?? Number.MAX_SAFE_INTEGER;
1787
+ if (orderA !== orderB) return orderA - orderB;
1788
+ return a.bundleVersionId.localeCompare(b.bundleVersionId);
1789
+ }
1790
+ function selectChargeableBundles(planFeatures, selectedBundles) {
1791
+ const kept = [...selectedBundles].sort(compareSelectable);
1792
+ for (; ; ) {
1793
+ const redundantIndex = kept.findIndex(
1794
+ (bundle) => isBundleRedundant(bundle, planFeatures, kept)
1795
+ );
1796
+ if (redundantIndex === -1) return kept;
1797
+ kept.splice(redundantIndex, 1);
1798
+ }
1799
+ }
1800
+
1801
+ // src/payment-gateway.types.ts
1802
+ var PAYMENT_CALLBACK_REJECTED = "PAYMENT_CALLBACK_REJECTED";
1803
+ var PaymentCallbackRejectedError = class extends Error {
1804
+ code = PAYMENT_CALLBACK_REJECTED;
1805
+ constructor(reason) {
1806
+ super(`Payment callback rejected: ${reason}`);
1807
+ this.name = "PaymentCallbackRejectedError";
1808
+ }
1809
+ };
1810
+ function isPaymentCallbackRejectedError(err) {
1811
+ return err instanceof Error && err.code === PAYMENT_CALLBACK_REJECTED;
1812
+ }
1813
+
1814
+ // src/registration.types.ts
1815
+ var PENDING_EMAIL_TTL_HOURS = 72;
1816
+ var PENDING_ONBOARDING_TTL_DAYS = 14;
1817
+ var PENDING_CHECKOUT_TTL_DAYS = 30;
1818
+ var OTP_TTL_MINUTES = 10;
1819
+ var PASSWORD_RESET_TTL_MINUTES = 30;
1820
+ var OTP_RATE_LIMIT_MAX_SENDS = 3;
1821
+ var OTP_RATE_LIMIT_WINDOW_MINUTES = 15;
1822
+ var OTP_VERIFY_MAX_ATTEMPTS = 5;
1823
+ var REGISTRATION_STEP_BY_STATUS = {
1824
+ PENDING_EMAIL_VERIFICATION: 2,
1825
+ EMAIL_VERIFIED: 3,
1826
+ PLAN_SELECTED: 4,
1827
+ CHECKOUT_STARTED: 4,
1828
+ EXPIRED: 1,
1829
+ DELETED: 1
1830
+ };
1831
+ var REGISTRATION_RESUME_TTL_MINUTES = 60;
1832
+
1833
+ // src/plan-mapping.ts
1834
+ function toPlanRow(row) {
1835
+ return {
1836
+ id: row.id,
1837
+ planKey: row.planKey,
1838
+ label: row.label,
1839
+ description: row.description,
1840
+ icon: row.icon,
1841
+ sortOrder: row.sortOrder,
1842
+ createdAt: row.createdAt.toISOString(),
1843
+ updatedAt: row.updatedAt.toISOString(),
1844
+ deletedAt: toIsoOrNull(row.deletedAt)
1845
+ };
1846
+ }
1847
+ function toPlanVersionRow(row, planKey) {
1848
+ return {
1849
+ id: row.id,
1850
+ version: row.version,
1851
+ baseVersionId: row.baseVersionId,
1852
+ planId: planKey,
1853
+ features: toFeatureKeys(row.features),
1854
+ quotas: toQuotaEffects(row.quotas),
1855
+ monthlyNet: String(row.monthlyNet),
871
1856
  yearlyNet: String(row.yearlyNet),
872
1857
  marketed: row.marketed,
873
1858
  publishedAt: toIsoOrNull(row.publishedAt),
@@ -875,17 +1860,14 @@ function toPlanVersionRow(row, planKey, fields) {
875
1860
  publishedChanges: Array.isArray(row.publishedChanges) ? row.publishedChanges : null,
876
1861
  changeNote: row.changeNote,
877
1862
  nonRegressive: row.nonRegressive,
878
- validFrom: fields.validityWindows ? toIsoOrNull(row.validFrom) : null,
879
- validUntil: fields.validityWindows ? toIsoOrNull(row.validUntil) : null,
1863
+ validFrom: toIsoOrNull(row.validFrom),
1864
+ validUntil: toIsoOrNull(row.validUntil),
1865
+ endsAt: toIsoOrNull(row.endsAt),
880
1866
  createdByUserId: row.createdByUserId,
881
1867
  publishedByUserId: row.publishedByUserId,
882
1868
  createdAt: row.createdAt.toISOString(),
883
1869
  updatedAt: row.updatedAt.toISOString()
884
1870
  };
885
- if (fields.endsAt) {
886
- mapped.endsAt = toIsoOrNull(row.endsAt);
887
- }
888
- return mapped;
889
1871
  }
890
1872
  function toIsoOrNull(value) {
891
1873
  return value ? value.toISOString() : null;
@@ -984,17 +1966,6 @@ function textOrNull(value) {
984
1966
  return trimmed === "" ? null : trimmed;
985
1967
  }
986
1968
 
987
- // src/closed-value.ts
988
- function oneOf(allowed, value, source) {
989
- const match = allowed.find((entry) => entry === value);
990
- if (match === void 0) {
991
- throw new Error(
992
- `${source.table} row '${source.id}' holds ${source.column} '${value}', which is none of ${allowed.join(", ")}.`
993
- );
994
- }
995
- return match;
996
- }
997
-
998
1969
  // src/subscriber-ledger-mapping.ts
999
1970
  var ORIGINS = {
1000
1971
  activation: true,
@@ -1009,10 +1980,10 @@ var SOURCES = {
1009
1980
  bundle: true,
1010
1981
  discount: true
1011
1982
  };
1012
- var TABLE = "subscriber_ledger_entries";
1983
+ var TABLE2 = "subscriber_ledger_entries";
1013
1984
  var CENT_TOLERANCE = 1e-6;
1014
1985
  function toSubscriberChargeRecord(row) {
1015
- const where = (column) => ({ table: TABLE, column, id: row.id });
1986
+ const where = (column) => ({ table: TABLE2, column, id: row.id });
1016
1987
  return {
1017
1988
  id: row.id,
1018
1989
  subscriberId: row.subscriberId,
@@ -1032,8 +2003,8 @@ function toSubscriberChargeRecord(row) {
1032
2003
  };
1033
2004
  }
1034
2005
  function subscriberChargeColumns(charge) {
1035
- const cents = charge.amountNet * 100;
1036
- if (!Number.isFinite(cents) || Math.abs(cents - Math.round(cents)) > CENT_TOLERANCE) {
2006
+ const cents2 = charge.amountNet * 100;
2007
+ if (!Number.isFinite(cents2) || Math.abs(cents2 - Math.round(cents2)) > CENT_TOLERANCE) {
1037
2008
  throw new Error(
1038
2009
  `A charge of ${charge.amountNet} is not a whole number of cents; round it once where it is derived, before it is written.`
1039
2010
  );
@@ -1176,7 +2147,7 @@ function toIdentityValues(value) {
1176
2147
  // src/subscriber-payment-method-mapping.ts
1177
2148
  var PAYMENT_METHOD_TYPES = ["card", "sepa_debit"];
1178
2149
  var STATUSES = ["ACTIVE", "REPLACED"];
1179
- var TABLE2 = "subscriber_payment_methods";
2150
+ var TABLE3 = "subscriber_payment_methods";
1180
2151
  function toSubscriberPaymentMethodRecord(row) {
1181
2152
  return {
1182
2153
  id: row.id,
@@ -1185,7 +2156,7 @@ function toSubscriberPaymentMethodRecord(row) {
1185
2156
  provider: row.provider,
1186
2157
  customerRef: row.customerRef,
1187
2158
  paymentMethodRef: row.paymentMethodRef,
1188
- type: oneOf(PAYMENT_METHOD_TYPES, row.type, { table: TABLE2, column: "type", id: row.id }),
2159
+ type: oneOf(PAYMENT_METHOD_TYPES, row.type, { table: TABLE3, column: "type", id: row.id }),
1189
2160
  brand: row.brand,
1190
2161
  last4: row.last4,
1191
2162
  expiryMonth: row.expiryMonth,
@@ -1193,7 +2164,7 @@ function toSubscriberPaymentMethodRecord(row) {
1193
2164
  country: row.country,
1194
2165
  bankCode: row.bankCode,
1195
2166
  mandateReference: row.mandateReference,
1196
- status: oneOf(STATUSES, row.status, { table: TABLE2, column: "status", id: row.id }),
2167
+ status: oneOf(STATUSES, row.status, { table: TABLE3, column: "status", id: row.id }),
1197
2168
  confirmedAt: row.confirmedAt,
1198
2169
  replacedAt: row.replacedAt,
1199
2170
  createdAt: row.createdAt
@@ -1374,6 +2345,52 @@ var ACTIVE_SUBSCRIPTION_CONTRACT_STATUSES = [
1374
2345
  "scheduled"
1375
2346
  ];
1376
2347
 
2348
+ // src/custom-limits.ts
2349
+ var CUSTOM_LIMITS_KEYS = ["quotas", "features"];
2350
+ var NOT_AN_OBJECT = "(the value is not an object)";
2351
+ function readCustomLimits(value) {
2352
+ if (value === null || value === void 0) return { limits: null, unread: [] };
2353
+ if (typeof value !== "object" || Array.isArray(value)) {
2354
+ return { limits: null, unread: [NOT_AN_OBJECT] };
2355
+ }
2356
+ const limits = {};
2357
+ const unread = [];
2358
+ for (const [key, entry] of Object.entries(value)) {
2359
+ if (key === "quotas" && isRecord(entry)) {
2360
+ limits.quotas = {};
2361
+ for (const [quota, amount] of Object.entries(entry)) {
2362
+ const value2 = readQuotaValue(amount);
2363
+ if (value2 === null) unread.push(`quotas.${quota}`);
2364
+ else limits.quotas[quota] = value2;
2365
+ }
2366
+ } else if (key === "features" && isFeatureList(entry)) {
2367
+ limits.features = [...entry];
2368
+ } else {
2369
+ unread.push(key);
2370
+ }
2371
+ }
2372
+ return { limits, unread };
2373
+ }
2374
+ function isRecord(value) {
2375
+ return value !== null && typeof value === "object" && !Array.isArray(value);
2376
+ }
2377
+ function isFeatureList(value) {
2378
+ return Array.isArray(value) && value.every((entry) => typeof entry === "string");
2379
+ }
2380
+ function customLimitsReader(report) {
2381
+ const reported = /* @__PURE__ */ new Set();
2382
+ return (subscriptionId, stored) => {
2383
+ const { limits, unread } = readCustomLimits(stored);
2384
+ if (unread.length > 0 && !reported.has(subscriptionId)) {
2385
+ reported.add(subscriptionId);
2386
+ report(
2387
+ `Subscription ${subscriptionId}: customLimits carries ${unread.join(", ")}, which the platform does not read, so these limits are not applied. It reads { quotas: { <quotaKey>: number }, features: string[] } (CustomLimits in @saasicat/core).`
2388
+ );
2389
+ }
2390
+ return limits;
2391
+ };
2392
+ }
2393
+
1377
2394
  // src/version-editability.ts
1378
2395
  function isVersionEditable(v, now = /* @__PURE__ */ new Date()) {
1379
2396
  if (v.publishedAt === null) {
@@ -1412,217 +2429,6 @@ function keepOneRecommended(plans, inRequestedLocale) {
1412
2429
  return winner;
1413
2430
  }
1414
2431
 
1415
- // src/error-messages.ts
1416
- var ERROR_MESSAGES_EN = {
1417
- // ── setup ──
1418
- SETUP_DISABLED: "{envVar} is not set \u2014 setup is disabled.",
1419
- INVALID_SETUP_TOKEN: "The setup token is not valid.",
1420
- SETUP_ALREADY_DONE: "Setup has already been completed.",
1421
- INVALID_EMAIL: "That is not a valid email address.",
1422
- EMAIL_EXISTS: "An account with this email address already exists.",
1423
- // ── auth ──
1424
- NOT_AUTHENTICATED: "Not authenticated",
1425
- NO_TENANT_ASSIGNED: "No tenant assigned",
1426
- TENANT_CONTEXT_MISSING: "No tenant ID found on the request",
1427
- TENANT_ADMIN_REQUIRED: "This action requires the TENANT_ADMIN role.",
1428
- BILLING_PERMISSION_REQUIRED: "This part of the billing area requires the billing permission.",
1429
- SUPER_ADMIN_REQUIRED: "Only the SUPER_ADMIN role is allowed",
1430
- MFA_NOT_SET_UP: "Run the MFA setup via the CLI first.",
1431
- MFA_REQUIRED: "TOTP code required in the X-Mfa-Code header.",
1432
- MFA_FAILED: "Invalid TOTP code.",
1433
- AUTH_GUARDS_NOT_CONFIGURED: "TenantBillingModule.forRoot.authGuards is not configured.",
1434
- // ── catalog ──
1435
- PLAN_HAS_DRAFTS: "Plan '{planKey}' still has {draftCount} open draft version(s). Discard them first (DELETE /admin/catalog/plan-versions/:id) or publish them.",
1436
- PLAN_HAS_PUBLISHED_VERSIONS: "Plan '{planKey}' cannot be {operation} \u2014 it has {publishedCount} published version(s) ({liveCount} live, {supersededCount} superseded). Existing subscriptions reference those versions (contract protection P1), so the plan record must be preserved.",
1437
- PLAN_HARD_DELETE_NOT_IMPLEMENTED: "Hard delete is not implemented in the current repository. Implement PlanRepository.hardDelete.",
1438
- PLAN_VERSION_ALREADY_PUBLISHED: "PlanVersion '{versionId}' is already published and cannot be discarded.",
1439
- PLAN_VERSION_NOT_EDITABLE: "PlanVersion '{versionId}' is not editable. Only drafts and published versions are editable that are latest-in-chain, bind no subscription yet, and whose validFrom lies in the future.",
1440
- PLAN_VERSION_REGRESSION: "This plan version is regressive (feature removed / quota lowered / price raised). Publishing requires an explicit `forceRegressive: true` (UI confirmation dialog with MFA).",
1441
- PLAN_VERSION_ZERO_PRICE: "A plan version cannot be published with a price of 0.00 (guard against seed placeholder). For deliberately free special contracts, set allowZeroPrice.",
1442
- PLAN_VERSION_DISCARD_NOT_IMPLEMENTED: "Discard is not implemented in the current repository. Implement PlanRepository.deletePlanVersionDraft.",
1443
- PLAN_VERSION_NOT_PUBLISHED: "PlanVersion '{versionId}' is not published and cannot be terminated.",
1444
- PLAN_VERSION_SUPERSEDED: "PlanVersion '{versionId}' has already been superseded by a newer version and cannot be terminated.",
1445
- PLAN_VERSION_VALID_FROM_REQUIRED: "validFrom must be set when publishing (on the draft or the publish call)..",
1446
- PLAN_VERSION_VALID_FROM_INVALID: "validFrom '{validFrom}' is not a valid date",
1447
- PLAN_VERSION_VALID_FROM_NOT_AFTER_PREVIOUS: "validFrom ({validFrom}) must be strictly after the validFrom of the previous version ({previousValidFrom}).",
1448
- PLAN_VERSION_VALID_FROM_NOT_GAPLESS: "The predecessor has validUntil={previousValidUntil} \u2014 the successor must start seamlessly on the next day ({requiredValidFrom}). Received: {received}.",
1449
- PLAN_VERSION_VALID_UNTIL_INVALID: "validUntil '{validUntil}' is not a valid date",
1450
- PLAN_VERSION_VALID_UNTIL_BEFORE_FROM: "validUntil ({validUntil}) must be strictly after validFrom ({validFrom}).",
1451
- PLAN_TERMINATE_INVALID_DATE: "endsAt is not a valid date.",
1452
- PLAN_TERMINATE_DATE_NOT_FUTURE: "endsAt ({endsAt}) must lie strictly in the future.",
1453
- PLAN_TERMINATE_NOT_IMPLEMENTED: "Terminate is not implemented in the current repository. Implement PlanRepository.terminate.",
1454
- BUNDLE_VERSION_ALREADY_PUBLISHED: "BundleVersion '{versionId}' is already published and cannot be discarded.",
1455
- BUNDLE_VERSION_NOT_EDITABLE: "BundleVersion '{versionId}' is not editable. Only drafts and published versions are editable that are latest-in-chain, bind no subscription yet, and whose validFrom lies in the future.",
1456
- BUNDLE_VERSION_NOT_PUBLISHED: "BundleVersion '{bundleVersionId}' is not published and cannot be booked.",
1457
- BUNDLE_VERSION_SUPERSEDED: "BundleVersion '{bundleVersionId}' has been superseded by a newer version.",
1458
- BUNDLE_VERSION_REGRESSION: "This bundle version is regressive (feature removed / quota lowered / price raised). Publishing requires an explicit `forceRegressive: true` (UI confirmation dialog with MFA).",
1459
- BUNDLE_VERSION_ZERO_PRICE: "A bundle version cannot be published with an explicit price of 0.00 (guard against seed placeholders). For free bundles leave it null, or set allowZeroPrice.",
1460
- BUNDLE_VERSION_NO_PRICE: "This bundle version cannot be published without a price: neither a base price nor any plan override resolves one.",
1461
- BUNDLE_VERSION_NOT_PRICED_FOR_PLAN: "This bundle is offered to plan '{planKey}', which is sold {billingCycle}, and no {billingCycle} price resolves for it \u2014 neither a base price nor a plan override.",
1462
- BUNDLE_VERSION_DISCARD_NOT_IMPLEMENTED: "Discard is not implemented in the current repository. Implement BundleRepository.deleteDraft.",
1463
- BUNDLE_VERSION_VALID_FROM_REQUIRED: "Published bundle versions must keep a validFrom. Set a new future date, or edit the draft before publishing.",
1464
- BUNDLE_VERSION_VALID_FROM_INVALID: "validFrom '{validFrom}' is not a valid date",
1465
- BUNDLE_VERSION_VALID_FROM_NOT_AFTER_PREVIOUS: "validFrom ({validFrom}) must be strictly after the validFrom of the previous version ({previousValidFrom}).",
1466
- BUNDLE_VERSION_VALID_FROM_NOT_GAPLESS: "The predecessor has validUntil={previousValidUntil} \u2014 the successor must start seamlessly on the next day ({requiredValidFrom}). Received: {received}.",
1467
- BUNDLE_VERSION_VALID_FROM_NOT_FUTURE: "validFrom ({validFrom}) must, for a published-but-future bundle version, still lie in the future.",
1468
- BUNDLE_VERSION_VALID_UNTIL_INVALID: "validUntil '{validUntil}' is not a valid date",
1469
- BUNDLE_VERSION_VALID_UNTIL_BEFORE_FROM: "validUntil ({validUntil}) must be strictly after validFrom ({validFrom}).",
1470
- STRICT_MODE_VIOLATIONS: "The strict-mode check found drift against the discovery snapshot.",
1471
- PLAN_NOT_FOUND: "Plan '{planId}' not found",
1472
- PLAN_VERSION_NOT_FOUND: "PlanVersion '{versionId}' not found",
1473
- BUNDLE_NOT_FOUND: "Bundle '{bundleId}' not found",
1474
- BUNDLE_VERSION_NOT_FOUND: "BundleVersion '{bundleVersionId}' not found",
1475
- FEATURE_NOT_FOUND: "Feature '{featureKey}' not found",
1476
- QUOTA_NOT_FOUND: "Quota '{quotaKey}' not found",
1477
- PROMOTION_NOT_FOUND: "Promotion '{promotionId}' not found",
1478
- PROMOTION_VALUE_INVALID: "The value of a '{type}' promotion is not one its type takes: a percentage above 0 and at most 100, an amount above 0, an intro price of at least 0 for a whole number of months, or a whole number of free months.",
1479
- MARKETING_PROJECTION_NOT_FOUND: "MarketingProjection '{projectionId}' not found",
1480
- PLAN_ALREADY_EXISTS: "Plan '{planKey}' already exists",
1481
- BUNDLE_ALREADY_EXISTS: "Bundle '{bundleKey}' already exists",
1482
- MARKETING_PROJECTION_ALREADY_EXISTS: "Marketing projection for {targetType}/{targetVersionId}/{locale} already exists \u2014 use PATCH to edit it",
1483
- PLAN_DRAFT_ALREADY_EXISTS: "Plan '{planKey}' already has a draft version v{draftVersion}; publish or discard it first",
1484
- BUNDLE_DRAFT_ALREADY_EXISTS: "Bundle '{bundleKey}' already has a draft version v{draftVersion}; publish or discard it first",
1485
- QUOTA_NOT_IN_DISCOVERY_SNAPSHOT: "Quota '{quotaKey}' is not in the discovery snapshot \u2014 a quota that is not declared in code cannot be approved",
1486
- DISCOVERY_STATUS_TRANSITION_INVALID: "Transition '{from}' \u2192 '{to}' is not allowed",
1487
- DISCOVERY_NOT_INITIALIZED: "Approval requires a discovery snapshot \u2014 discovery is not initialised (#25)",
1488
- // ── catalogue import ──
1489
- PLAN_CATALOG_UNREADABLE: "That file is not a plan catalog \u2014 it could not be read as one. Check that it is the YAML your app declares its plans in.",
1490
- PLAN_CATALOG_INVALID: "The plan catalog was read, and then rejected: {message}",
1491
- // ── billing ──
1492
- BUNDLE_ALREADY_SUBSCRIBED: "Subscription '{subscriptionId}' has already actively booked this bundle.",
1493
- BUNDLE_INCOMPATIBLE_WITH_PLAN: "BundleVersion '{bundleVersionId}' is not compatible with plan '{planKey}'. Allowed: [{allowedPlanKeys}].",
1494
- BUNDLE_NOT_SELF_SERVICE: "Bundle '{bundleKey}' is only activated via a special contract. Please contact the contract manager.",
1495
- BUNDLE_CYCLE_EXCEEDS_PLAN: "A yearly bundle cannot run beside a monthly plan: it would still be committed on every day the plan could end.",
1496
- BUNDLE_NOT_PRICED_FOR_THIS_PLAN: "This bundle has no {billingCycle} price for the {planKey} plan, so it cannot be booked from here.",
1497
- SUBSCRIPTION_BUNDLE_ALREADY_CANCELLED: "SubscriptionBundle '{subscriptionBundleId}' is already cancelled.",
1498
- SUBSCRIPTION_BUNDLE_NOT_CANCELLED: "SubscriptionBundle '{subscriptionBundleId}' is not cancelled.",
1499
- SUBSCRIPTION_BUNDLE_CANCELLATION_EFFECTIVE: "Cancellation already in effect \u2014 book the bundle again.",
1500
- SUBSCRIPTION_NOT_FOUND: "No subscription for tenant {tenantId}",
1501
- SUBSCRIPTION_TENANT_MISMATCH: "Subscription does not belong to the tenant",
1502
- SUBSCRIPTION_BUNDLE_NOT_FOUND: "SubscriptionBundle '{subscriptionBundleId}' not found",
1503
- TENANT_NOT_FOUND: "Tenant {slug} not found",
1504
- NO_ACTIVE_PLAN_VERSION: "No plan version for {planId} active as of {asOf} \u2014 neither the validFrom window is satisfied nor is a latest-live version available.",
1505
- PLAN_NOT_IN_CATALOG: 'Plan "{planKey}" is not in the catalog',
1506
- PLAN_NOT_SELF_SERVICE: "{planName} is only activated via a special contract. Please contact the contract manager.",
1507
- PLAN_NOT_SOLD_IN_CYCLE: "{planName} has no price for this billing rhythm and cannot be booked in it.",
1508
- PLAN_CHANGE_BLOCKED: "Plan change during onboarding is blocked.",
1509
- SUBSCRIPTION_CHANGED: "This subscription changed while the request was being decided. Reload it.",
1510
- NO_SUBSCRIPTION: "This tenant has no subscription to cancel.",
1511
- CANCELLATION_TERMS_CHANGED: "The effective date changed since it was shown. Confirm the new one.",
1512
- SUBSCRIPTION_ENDED: "This subscription has ended. Its plan can no longer be changed.",
1513
- PLAN_LOCKED: "Active {planName} special contract \u2014 please contact the contract manager to change plans.",
1514
- QUOTA_OVER_TARGET: "Current usage {used} exceeds the target limit {targetMax} ({quotaKey}) in the {planName} plan. Please reduce usage first.",
1515
- FEATURE_LOST: "Switching means losing access to one feature. Existing data is retained and never deleted \u2014 upgrading again unlocks it.",
1516
- FEATURES_LOST: "Switching means losing access to {count} features. Existing data is retained and never deleted \u2014 upgrading again unlocks it.",
1517
- NO_CHANGE: "Target plan and billing cycle already match the current state.",
1518
- CANCELLATION_LOCKS_THE_CYCLE: "This subscription is cancelled, so its billing cycle cannot change. The plan can \u2014 keep the current cycle to change it today.",
1519
- CYCLE_SHORTENS_AT_TERM_END: "A monthly {planName} cannot start inside the yearly term you are in. The upgrade takes effect when that term ends; to have it today, keep the yearly cycle.",
1520
- BUNDLE_BOOKING_OUTLASTS_TARGET_CYCLE: "A yearly bundle is booked until {until}. A monthly plan cannot carry it \u2014 cancel the bundle first, or keep the yearly cycle.",
1521
- REDUNDANT_FEATURES: "The plan or another booked bundle already includes {count} of the features in this bundle \u2014 booking it pays for them twice.",
1522
- MINIMUM_TERM_BINDS: "The minimum term extends beyond the end of the period \u2014 the cancellation only takes effect when the minimum term ends.",
1523
- BUNDLE_FEATURE_DEPENDENCY_UNSATISFIED: "The bundle requires [{features}] \u2014 present neither in the plan nor in the active bundles.",
1524
- NO_PENDING_PLAN_VERSION: "There is no pending plan version awaiting confirmation.",
1525
- ONBOARDING_CREATE_FAILED: "The account could not be created. Please try again.",
1526
- BUNDLE_PREVIEW_ARGUMENT_AMBIGUOUS: "Exactly one of bundleVersionId (add preview) or subscriptionBundleId (cancel preview) must be given.",
1527
- SUBSCRIPTION_PK_MISSING: "The adapter returned a subscription usage record without an id. Pass the subscription primary key through (see SubscriptionUsageRecord.id).",
1528
- LIMIT_EXCEEDED: "The limit for {dimension} has been reached: {used} of {max}.",
1529
- QUOTA_DIMENSION_UNKNOWN: 'Unknown quota dimension "{dimension}".',
1530
- // ── promo ──
1531
- PROMO_CODE_NOT_FOUND: "Code not found",
1532
- PROMO_CODE_ALREADY_EXISTS: "The code already exists.",
1533
- PROMO_CODE_HAS_REDEMPTIONS: "The code already has redemptions, or checkouts holding one \u2014 it cannot be soft-deleted. Pause it instead.",
1534
- PROMO_CODE_NOT_REDEEMABLE: "Code cannot be redeemed: {reason}",
1535
- PROMO_CODE_FORMAT_INVALID: 'The code may only contain upper-case letters, digits, "-" and "_" (4\u201332 characters).',
1536
- PROMO_PERCENT_OUT_OF_RANGE: "The percentage must be between 0 and 100.",
1537
- PROMO_AMOUNT_NOT_POSITIVE: "The amount must be positive.",
1538
- PROMO_ONE_OFF_WITH_DURATION: "A one-off discount must not set a duration.",
1539
- PROMO_DURATION_INVALID: "Invalid duration (at most 24 months or billing periods).",
1540
- PROMO_VALIDITY_WINDOW_INVALID: "Invalid validity window.",
1541
- PROMO_PLAN_NOT_DISCOUNTABLE: "{plan}-Plan cannot be discounted.",
1542
- PROMO_MIN_AMOUNT_NOT_POSITIVE: "The minimum plan gross amount must be positive.",
1543
- PROMO_WOULD_PRODUCE_ZERO_INVOICE: "For absolute amounts the discount must stay below the lowest applicable plan price, or allowZeroInvoice must be enabled.",
1544
- PROMO_MAX_REDEMPTIONS_LOWERED: "maxRedemptions cannot be lowered.",
1545
- // ── contract ──
1546
- CHECKOUT_OFFER_LINE_ITEMS_REQUIRED: "A checkout offer can yield only one contract, and only once its line items are frozen.",
1547
- CHECKOUT_OFFER_PLAN_LINE_ITEM_REQUIRED: "A checkout offer requires a frozen plan line item.",
1548
- CHECKOUT_OFFER_BUNDLE_LINE_ITEMS_REQUIRED: "Every selected bundle version requires a frozen bundle line item.",
1549
- CHECKOUT_OFFER_BUNDLE_VERSION_NOT_BOOKABLE: "At least one bundle version from the checkout offer is no longer bookable.",
1550
- CHECKOUT_OFFER_FEATURE_DEPENDENCY_UNSATISFIED: "The selected plan does not cover all feature dependencies: [{missingRequires}] are missing from the plan + selected bundles.",
1551
- CHECKOUT_OFFER_PLAN_NOT_OFFERED: "Plan '{planKey}' is not offered with a {billingCycle} price at the moment.",
1552
- CHECKOUT_OFFER_BUNDLE_NOT_OFFERED: "Bundle version '{bundleVersionId}' cannot be added to this offer ({reason}).",
1553
- CHECKOUT_OFFER_PROMO_CODE_NOT_ACCEPTED: "The promo code cannot be applied to this offer ({reason}).",
1554
- CHECKOUT_OFFER_PRICE_NOT_CURRENT: "The prices of checkout offer '{offerId}' no longer match the catalogue; create a new offer.",
1555
- SUBSCRIPTION_CONTRACT_LINE_ITEMS_REQUIRED: "A subscription contract requires at least one line item.",
1556
- SUBSCRIPTION_CONTRACT_PLAN_LINE_ITEM_REQUIRED: "A subscription contract requires exactly one plan base item.",
1557
- SUBSCRIPTION_CONTRACT_INVALID_DATE: "{field} must be a valid date.",
1558
- SUBSCRIPTION_CONTRACT_INVALID_WINDOW: "effectiveUntil must be after effectiveFrom.",
1559
- SUBSCRIPTION_CONTRACT_LINE_ITEM_TAX_MISMATCH: "A line item's taxAmount must be exactly priceGross minus priceNet.",
1560
- SUBSCRIPTION_CONTRACT_TAX_RATE_NOT_PERCENT: "A subscription contract states a tax rate of {taxRate} at {field}, which is not a percentage: a rate lies from 0 to 100, and a value between 0 and 1 is refused as a fraction.",
1561
- SUBSCRIPTION_CONTRACT_TERMINATION_BEFORE_START: "effectiveUntil must be after the effectiveFrom of the contract.",
1562
- SUBSCRIPTION_CONTRACT_LINE_ITEM_CURRENCY_MISMATCH: "A line item must be booked in the currency its contract was priced in.",
1563
- SUBSCRIPTION_CONTRACT_LINES_DO_NOT_ADD_UP: "The line items of a subscription contract add up to {lines} for {field}, but the contract states {stated}.",
1564
- SUBSCRIPTION_CONTRACT_DISCOUNT_NEGATIVE: "A subscription contract states a discount of {amount} at {field}; a discount takes money off and is never negative.",
1565
- CHECKOUT_OFFER_NOT_FOUND: "CheckoutOffer '{offerId}' not found",
1566
- CHECKOUT_OFFER_EXPIRED: "Checkout offer '{offerId}' has expired and cannot be {action}",
1567
- CHECKOUT_OFFER_ALREADY_CONSUMED: "Checkout offer '{offerId}' has already been consumed and cannot be {action}",
1568
- CHECKOUT_OFFER_NOT_CONSUMED: "CheckoutOffer '{offerId}' must be consumed before the contract is created",
1569
- CHECKOUT_OFFER_CHANGED: "Checkout offer '{offerId}' changed while it was being concluded. Load it again.",
1570
- SUBSCRIPTION_CONTRACT_NOT_FOUND: "SubscriptionContract '{contractId}' not found",
1571
- NO_ACTIVE_SUBSCRIPTION_CONTRACT: "No active subscription contract for tenant {tenantId}",
1572
- SUBSCRIPTION_CONTRACT_ALREADY_CLOSED: "SubscriptionContract '{contractId}' is already closed",
1573
- // ── subscriber ──
1574
- SUBSCRIBER_REQUIRED: "Tenant '{tenantId}' has no subscriber. Nothing is agreed or charged without the party to it: create the tenant's subscriber first.",
1575
- SUBSCRIBER_ALREADY_EXISTS: "Tenant '{tenantId}' already has a subscriber.",
1576
- SUBSCRIBER_NOT_FOUND: "Subscriber '{subscriberId}' not found",
1577
- SUBSCRIBER_LEGAL_NAME_REQUIRED: "A subscriber needs its legal name.",
1578
- SUBSCRIBER_DETAIL_INVALID: "The subscriber's {field} is not valid.",
1579
- SUBSCRIBER_IDENTITY_NOT_A_CONTACT: "{field} is part of the subscriber's legal identity and changes only as a correction, with a reason.",
1580
- SUBSCRIBER_CORRECTION_REASON_REQUIRED: "A correction of the legal identity needs a reason.",
1581
- SUBSCRIBER_CORRECTION_ACTOR_REQUIRED: "A correction of the legal identity has to say who makes it.",
1582
- SUBSCRIBER_CORRECTION_CHANGES_NOTHING: "The correction changes nothing: every value it names is already recorded.",
1583
- SUBSCRIBER_TAKEOVER_IS_A_TRANSFER: "Another legal entity taking over a subscriber is a transfer, not a correction, and cannot be recorded as an edit.",
1584
- // ── registration ──
1585
- PENDING_REGISTRATION_NOT_FOUND: "This registration could not be found. It may have already been completed or discarded.",
1586
- PENDING_REGISTRATION_EXPIRED: "This registration has expired. Please start again.",
1587
- INVALID_REGISTRATION_STATE: "This step is not available at the current stage of the registration.",
1588
- OTP_INVALID: "That code is not correct. Please check it and try again.",
1589
- OTP_EXPIRED: "That code has expired. Please request a new one.",
1590
- OTP_LOCKED: "Too many incorrect attempts. Please request a new code.",
1591
- RATE_LIMITED: "Too many attempts. Please try again in {retryAfterSeconds} seconds.",
1592
- RESUME_TOKEN_INVALID: "This resume link is no longer valid. Please request a new one.",
1593
- RESUME_NOT_CONFIGURED: "Resuming a registration is not available.",
1594
- CONFIGURATOR_NOT_CONFIGURED: "The configurator is not available.",
1595
- CONFIG_NOT_SAVED: "The configuration could not be saved.",
1596
- PLAN_NOT_AVAILABLE: "This plan is not available.",
1597
- PLAN_NOT_SELECTED: "Please select a plan first.",
1598
- MODEL_NOT_AVAILABLE: "This option is not available.",
1599
- // ── payments ──
1600
- PAYMENTS_NOT_CONFIGURED: "Payment methods cannot be set up here yet.",
1601
- PAYMENT_GATEWAY_ACCOUNT_UNKNOWN: "No payment gateway account is configured under '{account}'.",
1602
- PAYMENT_CALLBACK_REJECTED: "The payment callback could not be verified.",
1603
- PAYMENT_RETURN_URL_NOT_ALLOWED: "The {field} leads to a site this installation does not return to.",
1604
- PAYMENT_GATEWAY_FAILED: "The payment provider did not answer as expected. Please try again in a few minutes.",
1605
- // ── entitlement (code lives in upsell.types.ts) ──
1606
- [FEATURE_NOT_LICENSED]: "Feature {featureKeys} is not included in the current plan.",
1607
- // ── settings ──
1608
- SETTINGS_CHANGE_NOT_FOUND: "No recorded settings change has this id."
1609
- };
1610
- function formatErrorMessage(template, params = {}) {
1611
- return template.replace(/\{(\w+)\}/g, (match, name) => {
1612
- const value = params[name];
1613
- return value === void 0 || value === null ? match : String(value);
1614
- });
1615
- }
1616
- function resolveErrorMessage(body, overrides = {}, defaults = ERROR_MESSAGES_EN) {
1617
- const code = typeof body.code === "string" ? body.code : void 0;
1618
- const template = (code && (overrides[code] ?? defaults[code])) ?? void 0;
1619
- if (!template) {
1620
- return typeof body.message === "string" ? body.message : code ?? "";
1621
- }
1622
- const { params, ...rest } = body;
1623
- return formatErrorMessage(template, { ...rest, ...params });
1624
- }
1625
-
1626
2432
  // src/error-messages-de.ts
1627
2433
  var ERROR_MESSAGES_DE = {
1628
2434
  // ── setup ──
@@ -1646,7 +2452,7 @@ var ERROR_MESSAGES_DE = {
1646
2452
  PLAN_HAS_DRAFTS: "Plan '{planKey}' hat noch {draftCount} offene Entwurfsversion(en). Verwirf sie zuerst (DELETE /admin/catalog/plan-versions/:id) oder ver\xF6ffentliche sie.",
1647
2453
  PLAN_HAS_PUBLISHED_VERSIONS: "Plan '{planKey}' kann nicht {operation} werden \u2014 er hat {publishedCount} ver\xF6ffentlichte Version(en) ({liveCount} live, {supersededCount} abgel\xF6st). Bestehende Abonnements verweisen auf diese Versionen (Vertragsschutz P1), deshalb muss der Plan-Datensatz erhalten bleiben.",
1648
2454
  PLAN_HARD_DELETE_NOT_IMPLEMENTED: "Hard Delete ist im aktuellen Repository nicht implementiert. Implementiere PlanRepository.hardDelete.",
1649
- PLAN_VERSION_ALREADY_PUBLISHED: "PlanVersion '{versionId}' ist bereits ver\xF6ffentlicht und kann nicht verworfen werden.",
2455
+ PLAN_VERSION_ALREADY_PUBLISHED: "PlanVersion '{versionId}' ist bereits ver\xF6ffentlicht und wird weder erneut ver\xF6ffentlicht noch verworfen.",
1650
2456
  PLAN_VERSION_NOT_EDITABLE: "PlanVersion '{versionId}' ist nicht bearbeitbar. Bearbeitbar sind nur Entw\xFCrfe sowie ver\xF6ffentlichte Versionen, die letzte in der Kette sind, noch kein Abonnement binden und deren validFrom in der Zukunft liegt.",
1651
2457
  PLAN_VERSION_REGRESSION: "Diese Planversion ist regressiv (Feature entfernt / Quota gesenkt / Preis erh\xF6ht). Das Ver\xF6ffentlichen erfordert ein ausdr\xFCckliches `forceRegressive: true` (Best\xE4tigungsdialog in der UI mit MFA).",
1652
2458
  PLAN_VERSION_ZERO_PRICE: "Eine Planversion l\xE4sst sich nicht mit einem Preis von 0,00 ver\xF6ffentlichen (Schutz vor Seed-Platzhaltern). F\xFCr bewusst kostenlose Sondervertr\xE4ge setze allowZeroPrice.",
@@ -1654,29 +2460,34 @@ var ERROR_MESSAGES_DE = {
1654
2460
  PLAN_VERSION_NOT_PUBLISHED: "Die PlanVersion '{versionId}' ist nicht ver\xF6ffentlicht und kann nicht beendet werden.",
1655
2461
  PLAN_VERSION_SUPERSEDED: "Die PlanVersion '{versionId}' wurde bereits von einer Nachfolgeversion abgel\xF6st und kann nicht beendet werden.",
1656
2462
  PLAN_VERSION_VALID_FROM_REQUIRED: "validFrom muss beim Ver\xF6ffentlichen gesetzt sein (am Entwurf oder im Publish-Aufruf)..",
1657
- PLAN_VERSION_VALID_FROM_INVALID: "validFrom '{validFrom}' ist kein g\xFCltiges Datum",
2463
+ PLAN_VERSION_VALID_FROM_INVALID: "validFrom '{validFrom}' ist kein Tag (JJJJ-MM-TT)",
1658
2464
  PLAN_VERSION_VALID_FROM_NOT_AFTER_PREVIOUS: "validFrom ({validFrom}) muss strikt nach dem validFrom der Vorg\xE4ngerversion ({previousValidFrom}) liegen.",
1659
2465
  PLAN_VERSION_VALID_FROM_NOT_GAPLESS: "Der Vorg\xE4nger hat validUntil={previousValidUntil} \u2014 der Nachfolger muss l\xFCckenlos am Folgetag ({requiredValidFrom}) beginnen. Erhalten: {received}.",
1660
- PLAN_VERSION_VALID_UNTIL_INVALID: "validUntil '{validUntil}' ist kein g\xFCltiges Datum",
2466
+ PLAN_VERSION_VALID_UNTIL_INVALID: "validUntil '{validUntil}' ist kein Tag (JJJJ-MM-TT)",
1661
2467
  PLAN_VERSION_VALID_UNTIL_BEFORE_FROM: "validUntil ({validUntil}) muss strikt nach validFrom ({validFrom}) liegen.",
1662
2468
  PLAN_TERMINATE_INVALID_DATE: "endsAt ist kein g\xFCltiges Datum.",
1663
2469
  PLAN_TERMINATE_DATE_NOT_FUTURE: "endsAt ({endsAt}) muss strikt in der Zukunft liegen.",
1664
2470
  PLAN_TERMINATE_NOT_IMPLEMENTED: "Das Beenden ist im aktuellen Repository nicht implementiert. Implementiere PlanRepository.terminate.",
1665
- BUNDLE_VERSION_ALREADY_PUBLISHED: "BundleVersion '{versionId}' ist bereits ver\xF6ffentlicht und kann nicht verworfen werden.",
2471
+ PLAN_TERMINATE_BEFORE_RETIREMENT_MOVES: "Abonnements ziehen noch auf Version {version} von {planKey} um. Sie kann fr\xFChestens am {date} enden.",
2472
+ PLAN_TERMINATE_WHILE_MOVES_OVERDUE: "{count} Abonnements sind \xFCber ihr Datum und ziehen noch auf Version {version} von {planKey} um. Sie kann erst enden, wenn sie umgezogen sind.",
2473
+ PLAN_TERMINATE_WHILE_NOTICES_UNDELIVERED: "{count} Abonnements wissen noch nicht, dass sie auf Version {version} von {planKey} umziehen. Sie kann erst enden, wenn sie es erfahren haben.",
2474
+ BUNDLE_VERSION_ALREADY_PUBLISHED: "BundleVersion '{versionId}' ist bereits ver\xF6ffentlicht und wird weder erneut ver\xF6ffentlicht noch verworfen.",
1666
2475
  BUNDLE_VERSION_NOT_EDITABLE: "BundleVersion '{versionId}' ist nicht bearbeitbar. Bearbeitbar sind nur Entw\xFCrfe sowie ver\xF6ffentlichte Versionen, die letzte in der Kette sind, noch kein Abonnement binden und deren validFrom in der Zukunft liegt.",
1667
2476
  BUNDLE_VERSION_NOT_PUBLISHED: "BundleVersion '{bundleVersionId}' ist nicht ver\xF6ffentlicht und l\xE4sst sich nicht buchen.",
1668
2477
  BUNDLE_VERSION_SUPERSEDED: "BundleVersion '{bundleVersionId}' wurde durch eine neuere Version abgel\xF6st.",
2478
+ BUNDLE_VERSION_NOT_YET_ON_SALE: "BundleVersion '{bundleVersionId}' ist ab {validFrom} im Verkauf und kann vorher nicht gebucht werden.",
2479
+ BUNDLE_DELETED: "Bundle '{bundleKey}' wurde aus dem Katalog gel\xF6scht und l\xE4sst sich nicht buchen.",
1669
2480
  BUNDLE_VERSION_REGRESSION: "Diese Bundle-Version ist regressiv (Feature entfernt / Quota gesenkt / Preis erh\xF6ht). Das Ver\xF6ffentlichen erfordert ein ausdr\xFCckliches `forceRegressive: true` (Best\xE4tigungsdialog in der UI mit MFA).",
1670
2481
  BUNDLE_VERSION_ZERO_PRICE: "Eine Bundle-Version l\xE4sst sich nicht mit einem ausdr\xFCcklichen Preis von 0,00 ver\xF6ffentlichen (Schutz vor Seed-Platzhaltern). Kostenlose Bundles l\xE4sst du auf null, oder du setzt allowZeroPrice.",
1671
2482
  BUNDLE_VERSION_NO_PRICE: "Diese Bundle-Version kann ohne Preis nicht ver\xF6ffentlicht werden: weder ein Grundpreis noch eine Plan-\xDCberschreibung ergibt einen.",
1672
2483
  BUNDLE_VERSION_NOT_PRICED_FOR_PLAN: "Dieses Bundle wird dem Plan '{planKey}' angeboten, der {billingCycle} verkauft wird, und daf\xFCr ergibt sich kein {billingCycle} Preis \u2014 weder als Grundpreis noch als Plan-\xDCberschreibung.",
1673
2484
  BUNDLE_VERSION_DISCARD_NOT_IMPLEMENTED: "Das Verwerfen ist im aktuellen Repository nicht implementiert. Implementiere BundleRepository.deleteDraft.",
1674
2485
  BUNDLE_VERSION_VALID_FROM_REQUIRED: "Ver\xF6ffentlichte Bundle-Versionen m\xFCssen ein validFrom behalten. Setze ein neues Datum in der Zukunft, oder bearbeite den Entwurf vor dem Ver\xF6ffentlichen.",
1675
- BUNDLE_VERSION_VALID_FROM_INVALID: "validFrom '{validFrom}' ist kein g\xFCltiges Datum",
2486
+ BUNDLE_VERSION_VALID_FROM_INVALID: "validFrom '{validFrom}' ist kein Tag (JJJJ-MM-TT)",
1676
2487
  BUNDLE_VERSION_VALID_FROM_NOT_AFTER_PREVIOUS: "validFrom ({validFrom}) muss strikt nach dem validFrom der Vorg\xE4ngerversion ({previousValidFrom}) liegen.",
1677
2488
  BUNDLE_VERSION_VALID_FROM_NOT_GAPLESS: "Der Vorg\xE4nger hat validUntil={previousValidUntil} \u2014 der Nachfolger muss l\xFCckenlos am Folgetag ({requiredValidFrom}) beginnen. Erhalten: {received}.",
1678
2489
  BUNDLE_VERSION_VALID_FROM_NOT_FUTURE: "validFrom ({validFrom}) muss bei einer ver\xF6ffentlichten, aber zuk\xFCnftigen Bundle-Version weiterhin in der Zukunft liegen.",
1679
- BUNDLE_VERSION_VALID_UNTIL_INVALID: "validUntil '{validUntil}' ist kein g\xFCltiges Datum",
2490
+ BUNDLE_VERSION_VALID_UNTIL_INVALID: "validUntil '{validUntil}' ist kein Tag (JJJJ-MM-TT)",
1680
2491
  BUNDLE_VERSION_VALID_UNTIL_BEFORE_FROM: "validUntil ({validUntil}) muss strikt nach validFrom ({validFrom}) liegen.",
1681
2492
  STRICT_MODE_VIOLATIONS: "Die Strict-Mode-Pr\xFCfung hat eine Abweichung gegen\xFCber dem Discovery-Snapshot gefunden.",
1682
2493
  PLAN_NOT_FOUND: "Plan '{planId}' nicht gefunden",
@@ -1701,10 +2512,12 @@ var ERROR_MESSAGES_DE = {
1701
2512
  PLAN_CATALOG_INVALID: "Der Plankatalog wurde gelesen und dann abgelehnt: {message}",
1702
2513
  // ── billing ──
1703
2514
  BUNDLE_ALREADY_SUBSCRIBED: "Abonnement '{subscriptionId}' hat dieses Bundle bereits aktiv gebucht.",
1704
- BUNDLE_INCOMPATIBLE_WITH_PLAN: "BundleVersion '{bundleVersionId}' passt nicht zum Plan '{planKey}'. Erlaubt: [{allowedPlanKeys}].",
2515
+ BUNDLE_INCOMPATIBLE_WITH_PLAN: "Dieses Bundle kann im Plan {planKey} nicht gebucht werden. Buchbar ist es in: {allowedPlanKeys}.",
1705
2516
  BUNDLE_NOT_SELF_SERVICE: "Bundle '{bundleKey}' wird nur \xFCber einen Sondervertrag freigeschaltet. Bitte wende dich an die Vertragsverwaltung.",
1706
2517
  BUNDLE_CYCLE_EXCEEDS_PLAN: "Ein j\xE4hrlich abgerechnetes Bundle passt nicht zu einem monatlich abgerechneten Plan: es w\xE4re an jedem Tag gebunden, an dem der Plan enden kann.",
1707
- BUNDLE_NOT_PRICED_FOR_THIS_PLAN: "F\xFCr dieses Bundle ist im Plan {planKey} kein {billingCycle} Preis hinterlegt, es kann hier deshalb nicht gebucht werden.",
2518
+ BUNDLE_NOT_PRICED_FOR_THIS_PLAN: "F\xFCr dieses Bundle ist im Plan {planKey} in diesem Abrechnungsrhythmus kein Preis hinterlegt, es kann hier deshalb nicht gebucht werden.",
2519
+ BUNDLE_CANNOT_RUN_ON_UPCOMING_PLAN: "Dieses Bundle kann nicht im Plan {planKey} laufen, in den das Abonnement mit Wirkung ab {from} wechselt.",
2520
+ BUNDLE_CANNOT_RUN_ON_UPCOMING_CYCLE: "Ein j\xE4hrlich abgerechnetes Bundle kann nicht neben der monatlichen Abrechnung laufen, auf die das Abonnement mit Wirkung ab {from} wechselt.",
1708
2521
  SUBSCRIPTION_BUNDLE_ALREADY_CANCELLED: "SubscriptionBundle '{subscriptionBundleId}' ist bereits gek\xFCndigt.",
1709
2522
  SUBSCRIPTION_BUNDLE_NOT_CANCELLED: "SubscriptionBundle '{subscriptionBundleId}' ist nicht gek\xFCndigt.",
1710
2523
  SUBSCRIPTION_BUNDLE_CANCELLATION_EFFECTIVE: "Die K\xFCndigung ist bereits wirksam \u2014 buche das Bundle einfach neu.",
@@ -1712,7 +2525,8 @@ var ERROR_MESSAGES_DE = {
1712
2525
  SUBSCRIPTION_TENANT_MISMATCH: "Das Abonnement geh\xF6rt nicht zu diesem Mandanten",
1713
2526
  SUBSCRIPTION_BUNDLE_NOT_FOUND: "SubscriptionBundle '{subscriptionBundleId}' nicht gefunden",
1714
2527
  TENANT_NOT_FOUND: "Mandant {slug} nicht gefunden",
1715
- NO_ACTIVE_PLAN_VERSION: "Zum {asOf} ist keine Planversion f\xFCr {planId} aktiv \u2014 weder ist das validFrom-Fenster erf\xFCllt, noch steht eine j\xFCngste Live-Version bereit.",
2528
+ NO_ACTIVE_PLAN_VERSION: "Zum {asOf} ist keine Version des Plans {planId} im Verkauf.",
2529
+ BOUND_PLAN_VERSION_UNREADABLE: 'Die Planversion, an die dieses Abonnement gebunden ist ({planVersionId}), ist f\xFCr den Plan "{planKey}" nicht lesbar; deshalb kann kein Wechsel berechnet werden.',
1716
2530
  PLAN_NOT_IN_CATALOG: 'Plan "{planKey}" steht nicht im Katalog',
1717
2531
  PLAN_NOT_SELF_SERVICE: "{planName} wird nur \xFCber einen Sondervertrag freigeschaltet. Bitte wenden Sie sich an die Vertragsverwaltung.",
1718
2532
  PLAN_NOT_SOLD_IN_CYCLE: "{planName} hat f\xFCr diesen Abrechnungsrhythmus keinen Preis und kann darin nicht gebucht werden.",
@@ -1720,6 +2534,25 @@ var ERROR_MESSAGES_DE = {
1720
2534
  SUBSCRIPTION_CHANGED: "Dieses Abonnement hat sich ge\xE4ndert, w\xE4hrend die Anfrage entschieden wurde. Bitte lade es neu.",
1721
2535
  NO_SUBSCRIPTION: "Dieser Mandant hat kein Abonnement, das gek\xFCndigt werden kann.",
1722
2536
  CANCELLATION_TERMS_CHANGED: "Das Wirksamkeitsdatum hat sich seit der Anzeige ge\xE4ndert. Bitte best\xE4tige das neue Datum.",
2537
+ VERSION_OFFER_CHANGED: "Das Angebot hat sich seit der Anzeige ge\xE4ndert. Bitte sieh dir das aktuelle an, bevor du wechselst.",
2538
+ PLAN_CHANGE_QUOTE_CHANGED: "Dieser Plan hat sich seit der Anzeige ge\xE4ndert. Bitte sieh ihn dir noch einmal an, bevor du wechselst.",
2539
+ PLAN_CHANGE_VERSION_NOT_NAMED: "Ein Planwechsel muss die Version nennen, die seine Vorschau gezeigt hat.",
2540
+ VERSION_SWITCH_AFTER_CANCELLATION: "Dieses Abonnement endet, bevor diese Version wirksam w\xFCrde. Ein Wechsel dorthin ist nicht m\xF6glich.",
2541
+ VERSION_ENDS_BEFORE_SWITCH: "Diese Version wird nicht mehr verkauft, bevor sie wirksam w\xFCrde. Ein Wechsel dorthin ist nicht m\xF6glich.",
2542
+ RETIREMENT_TERMS_NOT_CONFIRMED: "Eine Version f\xFCr laufende Abonnements stillzulegen, braucht eine Klausel in deinen AGB. Setze tenantBilling.orderlyRetirement.termsConfirmed in config/saas.yaml, sobald sie sie enthalten.",
2543
+ RETIREMENT_VERSION_ON_SALE: "Version {version} von {planKey} wird noch verkauft. Beende zuerst ihren Verkauf, damit sie nach der Ank\xFCndigung niemand mehr bucht.",
2544
+ RETIREMENT_REPLACEMENT_NOT_ON_SALE: "Version {version} von {planKey} wird nicht verkauft. Abonnements k\xF6nnen nicht auf ihr weiterlaufen.",
2545
+ RETIREMENT_REPLACEMENT_NOT_SOLD_IN_RHYTHM: "{count} dieser Abonnements werden in einem Rhythmus abgerechnet, f\xFCr den Version {version} von {planKey} keinen Preis hat. Sie k\xF6nnen nicht auf ihr weiterlaufen.",
2546
+ RETIREMENT_REPLACEMENT_CANNOT_CARRY_BUNDLES: "{count} dieser Abonnements halten ein Bundle, das in Version {version} von {planKey} nicht laufen kann. Sie k\xF6nnen nicht auf ihr weiterlaufen.",
2547
+ RETIREMENT_REPLACEMENT_IS_RETIRED: "Eine Version kann nicht ihr eigener Ersatz sein.",
2548
+ RETIREMENT_NOTHING_AFFECTED: "Kein laufendes Abonnement nutzt Version {version} von {planKey}. Es gibt niemanden zu benachrichtigen.",
2549
+ RETIREMENT_WITHIN_TWELVE_MONTHS: "{count} dieser Abonnements waren in den letzten zw\xF6lf Monaten schon von einer Stilllegung betroffen. Ein Abonnement ist h\xF6chstens einmal im Jahr betroffen.",
2550
+ RETIREMENT_PREVIEW_CHANGED: "Die Abonnements, die diese Stilllegung betrifft, haben sich seit der Anzeige ge\xE4ndert. Sieh sie dir noch einmal an, bevor du sie ank\xFCndigst.",
2551
+ RETIREMENT_SWITCH_NOT_PENDING: "F\xFCr Ihre Version steht keine Einstellung mehr bevor. Es gibt nichts, wohin Sie wechseln k\xF6nnten.",
2552
+ RETIREMENT_SWITCH_IN_TRIAL: "Der Wechsel ist m\xF6glich, sobald Ihre Testphase endet.",
2553
+ RETIREMENT_SWITCH_BUNDLE_CANNOT_FOLLOW: "{bundleName} kann im Paket {planName} nicht laufen und l\xE4uft fr\xFChestens bis {until}. Ist es gek\xFCndigt, ist der Wechsel ab diesem Tag m\xF6glich.",
2554
+ RETIREMENT_SWITCH_NOT_OPEN: "Dieses Abonnement kann gerade nicht wechseln: Eine \xC4nderung ist geplant, es ist beendet, oder sein Paket gilt f\xFCr einen Sondervertrag.",
2555
+ RETIREMENT_SWITCH_CHANGED: "Die Einstellung hat sich seit der Anzeige ge\xE4ndert. Sehen Sie sie sich noch einmal an, bevor Sie wechseln.",
1723
2556
  SUBSCRIPTION_ENDED: "Dieses Abonnement ist beendet. Sein Paket kann nicht mehr gewechselt werden.",
1724
2557
  PLAN_LOCKED: "Aktiver Sondervertrag {planName} \u2014 f\xFCr einen Paketwechsel wenden Sie sich bitte an die Vertragsverwaltung.",
1725
2558
  QUOTA_OVER_TARGET: "Aktuelle Nutzung {used} \xFCberschreitet das Ziel-Limit {targetMax} ({quotaKey}) im Paket {planName}. Bitte zuerst die Nutzung reduzieren.",
@@ -1728,11 +2561,11 @@ var ERROR_MESSAGES_DE = {
1728
2561
  NO_CHANGE: "Zielpaket und Abrechnungsrhythmus entsprechen bereits dem aktuellen Stand.",
1729
2562
  CANCELLATION_LOCKS_THE_CYCLE: "Dieses Abonnement ist gek\xFCndigt, sein Abrechnungsrhythmus kann daher nicht wechseln. Das Paket schon \u2014 behalten Sie den aktuellen Rhythmus, um es heute zu wechseln.",
1730
2563
  CYCLE_SHORTENS_AT_TERM_END: "Ein monatlich abgerechnetes {planName} kann nicht innerhalb der laufenden Jahreslaufzeit beginnen. Das Upgrade greift zum Ende dieser Laufzeit; wer es sofort m\xF6chte, beh\xE4lt den j\xE4hrlichen Rhythmus.",
1731
- BUNDLE_BOOKING_OUTLASTS_TARGET_CYCLE: "Ein j\xE4hrlich abgerechnetes Bundle ist bis {until} gebucht. Ein monatlich abgerechnetes Paket kann es nicht tragen \u2014 k\xFCndigen Sie das Bundle zuerst, oder behalten Sie den j\xE4hrlichen Rhythmus.",
2564
+ BUNDLE_BOOKING_OUTLASTS_TARGET_CYCLE: "{bundleName} wird j\xE4hrlich abgerechnet und l\xE4uft fr\xFChestens bis {until}; ein monatlich abgerechnetes Paket kann es nicht tragen. Ist es gek\xFCndigt, geht ein Wechsel durch, der an diesem Tag oder sp\xE4ter wirksam wird \u2014 oder behalten Sie den j\xE4hrlichen Rhythmus.",
2565
+ BUNDLE_BOOKING_DOES_NOT_FIT_TARGET_PLAN: "{bundleName} kann im Paket {planName} nicht laufen und l\xE4uft fr\xFChestens bis {until}. Ist es gek\xFCndigt, geht ein Wechsel durch, der an diesem Tag oder sp\xE4ter wirksam wird \u2014 oder w\xE4hlen Sie ein anderes Paket.",
1732
2566
  REDUNDANT_FEATURES: "Der Plan oder ein anderes gebuchtes Bundle enth\xE4lt bereits {count} der Funktionen aus diesem Bundle \u2014 mit der Buchung werden sie doppelt bezahlt.",
1733
2567
  MINIMUM_TERM_BINDS: "Die Mindestlaufzeit reicht \xFCber das Ende der Periode hinaus \u2014 die K\xFCndigung wird erst zum Ende der Mindestlaufzeit wirksam.",
1734
2568
  BUNDLE_FEATURE_DEPENDENCY_UNSATISFIED: "Das Bundle setzt [{features}] voraus \u2014 weder im Plan noch in den aktiven Bundles vorhanden.",
1735
- NO_PENDING_PLAN_VERSION: "Es wartet keine Planversion auf eine Best\xE4tigung.",
1736
2569
  ONBOARDING_CREATE_FAILED: "Das Konto konnte nicht angelegt werden. Bitte versuche es noch einmal.",
1737
2570
  BUNDLE_PREVIEW_ARGUMENT_AMBIGUOUS: "Genau eines von bundleVersionId (Vorschau f\xFCrs Buchen) oder subscriptionBundleId (Vorschau f\xFCrs K\xFCndigen) muss angegeben sein.",
1738
2571
  SUBSCRIPTION_PK_MISSING: "Der Adapter hat einen SubscriptionUsageRecord ohne id geliefert. Bitte den Prim\xE4rschl\xFCssel der Subscription durchreichen (siehe SubscriptionUsageRecord.id).",
@@ -1740,7 +2573,7 @@ var ERROR_MESSAGES_DE = {
1740
2573
  QUOTA_DIMENSION_UNKNOWN: 'Unbekannte Quota-Dimension "{dimension}".',
1741
2574
  // ── promo ──
1742
2575
  PROMO_CODE_NOT_FOUND: "Code nicht gefunden",
1743
- PROMO_CODE_ALREADY_EXISTS: "Diesen Code gibt es bereits.",
2576
+ PROMO_CODE_ALREADY_EXISTS: "Diesen Code gibt es bereits, oder ein gel\xF6schter Code tr\xE4gt ihn; ein gel\xF6schter Code beh\xE4lt seinen Namen.",
1744
2577
  PROMO_CODE_HAS_REDEMPTIONS: "Der Code wurde bereits eingel\xF6st oder ist f\xFCr einen laufenden Checkout reserviert \u2014 er l\xE4sst sich nicht per Soft-Delete entfernen. Pausiere ihn stattdessen.",
1745
2578
  PROMO_CODE_NOT_REDEEMABLE: "Der Code l\xE4sst sich nicht einl\xF6sen: {reason}",
1746
2579
  PROMO_CODE_FORMAT_INVALID: 'Der Code darf nur Gro\xDFbuchstaben, Ziffern, "-" und "_" enthalten (4\u201332 Zeichen).',
@@ -1781,6 +2614,7 @@ var ERROR_MESSAGES_DE = {
1781
2614
  SUBSCRIPTION_CONTRACT_NOT_FOUND: "SubscriptionContract '{contractId}' nicht gefunden",
1782
2615
  NO_ACTIVE_SUBSCRIPTION_CONTRACT: "Kein aktiver Abo-Vertrag f\xFCr Mandant {tenantId}",
1783
2616
  SUBSCRIPTION_CONTRACT_ALREADY_CLOSED: "SubscriptionContract '{contractId}' ist bereits geschlossen",
2617
+ SUBSCRIPTION_CONTRACT_CHANGED: "Die Vertr\xE4ge von Mandant '{tenantId}' haben sich ge\xE4ndert, w\xE4hrend ein Nachfolger geschrieben wurde, oder einer beginnt nach dem Zeitpunkt, ab dem er g\xE4lte, sodass er neben einem anderen liefe. Es wurde nichts geschrieben.",
1784
2618
  // ── subscriber ──
1785
2619
  SUBSCRIBER_REQUIRED: "Mandant '{tenantId}' hat keinen Vertragspartner. Ohne ihn wird nichts vereinbart oder berechnet: Zuerst muss der Vertragspartner des Mandanten angelegt werden.",
1786
2620
  SUBSCRIBER_ALREADY_EXISTS: "Mandant '{tenantId}' hat bereits einen Vertragspartner.",
@@ -1816,7 +2650,16 @@ var ERROR_MESSAGES_DE = {
1816
2650
  // ── entitlement (code lives in upsell.types.ts) ──
1817
2651
  [FEATURE_NOT_LICENSED]: "Das Feature {featureKeys} ist im aktuellen Plan nicht enthalten.",
1818
2652
  // ── settings ──
1819
- SETTINGS_CHANGE_NOT_FOUND: "Keine aufgezeichnete Einstellungs\xE4nderung hat diese ID."
2653
+ SETTINGS_CHANGE_NOT_FOUND: "Keine aufgezeichnete Einstellungs\xE4nderung hat diese ID.",
2654
+ // ── maintenance ──
2655
+ MAINTENANCE: "Die Anwendung wird gerade gewartet.",
2656
+ MAINTENANCE_WINDOW_ALREADY_OPEN: "Es ist bereits ein Wartungsfenster offen. Verschiebe oder streiche es, bevor du ein weiteres ank\xFCndigst.",
2657
+ MAINTENANCE_WINDOW_NOT_OPEN: "Kein offenes Wartungsfenster hat diese ID.",
2658
+ MAINTENANCE_WINDOW_LOCKED: "Dieses Wartungsfenster ist gesperrt. Sein Beginn l\xE4sst sich nicht mehr verschieben, und beendet wird es durch Entsperren.",
2659
+ MAINTENANCE_WINDOW_END_NOT_AFTER_START: "Das Ende eines Wartungsfensters muss nach seinem Beginn liegen.",
2660
+ MAINTENANCE_WINDOW_END_IN_PAST: "Das Ende eines Wartungsfensters darf nicht in der Vergangenheit liegen.",
2661
+ MAINTENANCE_TIME_INVALID: "{field} muss Datum und Uhrzeit mit Zeitzone sein, etwa 2026-10-02T22:00+02:00.",
2662
+ MAINTENANCE_MESSAGE_TOO_LONG: "Die Nachricht darf h\xF6chstens {max} Zeichen lang sein."
1820
2663
  };
1821
2664
  export {
1822
2665
  ACTIVE_SUBSCRIPTION_CONTRACT_STATUSES,
@@ -1826,13 +2669,20 @@ export {
1826
2669
  CATALOGUE_KEYS,
1827
2670
  CATALOG_ERROR_CODES,
1828
2671
  CONTRACT_ERROR_CODES,
2672
+ CUSTOM_LIMITS_KEYS,
1829
2673
  ERROR_MESSAGES_DE,
1830
2674
  ERROR_MESSAGES_EN,
1831
2675
  FEATURE_NOT_LICENSED,
1832
2676
  ForeignPaymentMethodReferenceError,
1833
2677
  LEGAL_IDENTITY_FIELDS,
2678
+ MAINTENANCE_CAPABILITY,
2679
+ MAINTENANCE_ERROR_CODES,
2680
+ MAINTENANCE_MESSAGE_MAX_LENGTH,
2681
+ MAINTENANCE_STATE_MAX_AGE_SECONDS,
1834
2682
  MARKETING_PRIORITY_MAX,
1835
2683
  MARKETING_PRIORITY_MIN,
2684
+ NO_SCHEDULED_CHANGE,
2685
+ OPTIONAL_CANONICAL_MODELS,
1836
2686
  OTP_RATE_LIMIT_MAX_SENDS,
1837
2687
  OTP_RATE_LIMIT_WINDOW_MINUTES,
1838
2688
  OTP_TTL_MINUTES,
@@ -1847,62 +2697,108 @@ export {
1847
2697
  PROMO_ERROR_CODES,
1848
2698
  PaymentCallbackRejectedError,
1849
2699
  PersistenceCapabilityError,
2700
+ PersistenceRefusal,
1850
2701
  PlatformUserExistsError,
1851
2702
  REGISTRATION_ERROR_CODES,
1852
2703
  REGISTRATION_RESUME_TTL_MINUTES,
1853
2704
  REGISTRATION_STEP_BY_STATUS,
2705
+ RETIREMENT_REMINDER_LEAD_DAYS,
1854
2706
  SETTINGS_ERROR_CODES,
1855
2707
  SETUP_ERROR_CODES,
1856
2708
  SUBSCRIBER_ACCOUNT_CAPABILITY,
1857
2709
  SUBSCRIBER_ERROR_CODES,
2710
+ VERSION_RETIREMENT_CAPABILITY,
1858
2711
  applyPromo,
1859
2712
  assertPersistenceCapabilities,
1860
2713
  buildActivePlanVersionWhere,
1861
2714
  buildActiveVersionWhere,
1862
2715
  buildFeatureRequiresIndex,
1863
2716
  bundleDraftDefaults,
2717
+ bundleKeyTaken,
1864
2718
  bundleStemDefaults,
1865
2719
  canonicalJson,
2720
+ catalogDraftExists,
2721
+ catalogVersionAlreadyPublished,
2722
+ catalogVersionGone,
1866
2723
  classifyBundleVersionDiff,
1867
2724
  classifyIssuerChange,
1868
2725
  classifyPlanDiff,
2726
+ classifyVersionOffer,
1869
2727
  collectUnsatisfiedRequires,
2728
+ computeIncludedVat,
2729
+ concurrencyGate,
2730
+ concurrencyGateOf,
1870
2731
  contractPartiesOf,
1871
2732
  coverageExcludingSelf,
2733
+ customLimitsReader,
1872
2734
  definedFields,
1873
2735
  diffSettings,
1874
2736
  formatCustomerNumber,
1875
2737
  formatErrorMessage,
2738
+ grossFromNet,
1876
2739
  identityCorrectionDelta,
1877
2740
  isBundleRedundant,
1878
2741
  isForeignPaymentMethodReferenceError,
2742
+ isMaintenanceAnnouncementLapsed,
2743
+ isMaintenanceOverrun,
1879
2744
  isPaymentCallbackRejectedError,
2745
+ isPersistenceRefusal,
1880
2746
  isPlatformUserExistsError,
2747
+ isVersionActiveAt,
1881
2748
  isVersionEditable,
1882
2749
  issuerIdentityOf,
1883
2750
  keepOneRecommended,
2751
+ maintenanceRetryAfterSeconds,
2752
+ maintenanceStatusOf,
2753
+ maintenanceWindowStatusOf,
2754
+ maintenanceWindowViewOf,
2755
+ marketingProjectionTaken,
2756
+ membersLeftOut,
1884
2757
  missingRequiresFor,
1885
2758
  movedIdentityFields,
2759
+ netFromGross,
2760
+ noActivePlanVersion,
2761
+ parseZonedInstant,
2762
+ percentOf,
1886
2763
  pickActivePromo,
1887
2764
  planCatalogSettingsOf,
2765
+ planKeyTaken,
2766
+ planNotInCatalog,
1888
2767
  previousUtcDay,
2768
+ promoCodeTaken,
1889
2769
  promoStatus,
1890
2770
  promotionOnPrice,
2771
+ prorate,
2772
+ readCustomLimits,
1891
2773
  readQuotaRecord,
1892
2774
  readQuotaValue,
1893
2775
  recordedIssuerIdentity,
1894
2776
  refuseForeignPaymentMethodReference,
1895
2777
  resolveBundleAvailability,
1896
2778
  resolveErrorMessage,
2779
+ retirementCostsTheSubscription,
2780
+ retirementReminderDueAt,
2781
+ retirementReminderIsDue,
2782
+ retirementSwitchTerms,
2783
+ roundToCents,
1897
2784
  sameLegalIdentity,
2785
+ scheduledChangeAfterWrite,
1898
2786
  selectChargeableBundles,
1899
2787
  settingsSubtreeOf,
1900
2788
  startOfUtcDay,
1901
2789
  subscriberChargeColumns,
1902
2790
  subscriberFromRegistration,
1903
2791
  subscriberPaymentMethodColumns,
2792
+ subscriptionBundleAlreadyCancelled,
2793
+ subscriptionBundleGone,
2794
+ subscriptionContractGone,
2795
+ subscriptionGone,
2796
+ sumToCents,
1904
2797
  toBundleStemRow,
2798
+ toCents,
1905
2799
  toContractLineItemRecord,
2800
+ toDecimalString,
2801
+ toMaintenanceWindowRecord,
1906
2802
  toPlanRow,
1907
2803
  toPlanVersionRow,
1908
2804
  toRunningContractIssuer,
@@ -1911,5 +2807,10 @@ export {
1911
2807
  toSubscriberPaymentMethodRecord,
1912
2808
  toSubscriberRecord,
1913
2809
  toSubscriptionBundleRecord,
1914
- toSubscriptionContractRecord
2810
+ toSubscriptionContractRecord,
2811
+ toSubscriptionNoticeRecord,
2812
+ toVersionRetirementRecord,
2813
+ versionOnSale,
2814
+ versionOnSaleOrNext,
2815
+ versionSale
1915
2816
  };