@saasicat/core 1.0.0-rc.2 → 1.0.0-rc.20

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
@@ -2,6 +2,11 @@
2
2
  function startOfUtcDay(date) {
3
3
  return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate()));
4
4
  }
5
+ function previousUtcDay(value) {
6
+ const result = new Date(value);
7
+ result.setUTCDate(result.getUTCDate() - 1);
8
+ return result;
9
+ }
5
10
  function buildActivePlanVersionWhere(asOf, options = {}) {
6
11
  const asOfDayStart = startOfUtcDay(asOf);
7
12
  const validityWindow = [
@@ -18,6 +23,57 @@ function buildActivePlanVersionWhere(asOf, options = {}) {
18
23
  }
19
24
  var buildActiveVersionWhere = buildActivePlanVersionWhere;
20
25
 
26
+ // src/bundle-draft-defaults.ts
27
+ function bundleDraftDefaults(data) {
28
+ return {
29
+ baseVersionId: data.baseVersionId ?? null,
30
+ features: data.features,
31
+ quotas: data.quotas ?? {},
32
+ compatibility: data.compatibility ?? {},
33
+ pricingOverrides: data.pricingOverrides ?? [],
34
+ monthlyNet: data.monthlyNet ?? null,
35
+ yearlyNet: data.yearlyNet ?? null,
36
+ marketed: data.marketed ?? true,
37
+ changeNote: data.changeNote ?? "",
38
+ createdByUserId: data.createdByUserId ?? null
39
+ };
40
+ }
41
+ function bundleStemDefaults(data) {
42
+ return {
43
+ bundleKey: data.bundleKey,
44
+ label: data.label,
45
+ description: data.description ?? null,
46
+ icon: data.icon ?? null,
47
+ sortOrder: data.sortOrder ?? 0,
48
+ i18n: data.i18n ?? {}
49
+ };
50
+ }
51
+ function toBundleStemRow(row) {
52
+ return {
53
+ id: row.id,
54
+ bundleKey: row.bundleKey,
55
+ label: row.label,
56
+ description: row.description,
57
+ icon: row.icon,
58
+ sortOrder: row.sortOrder,
59
+ i18n: row.i18n !== null && typeof row.i18n === "object" && !Array.isArray(row.i18n) ? row.i18n : {},
60
+ createdAt: row.createdAt.toISOString(),
61
+ updatedAt: row.updatedAt.toISOString(),
62
+ deletedAt: row.deletedAt?.toISOString() ?? null
63
+ };
64
+ }
65
+ function definedFields(data, keys) {
66
+ const patch = {};
67
+ for (const key of keys) {
68
+ if (data[key] !== void 0) patch[key] = data[key];
69
+ }
70
+ return patch;
71
+ }
72
+
73
+ // src/catalog-entry.types.ts
74
+ var MARKETING_PRIORITY_MIN = 0;
75
+ var MARKETING_PRIORITY_MAX = 1e4;
76
+
21
77
  // src/promotion.types.ts
22
78
  function promoStatus(promo, today = /* @__PURE__ */ new Date()) {
23
79
  const from = new Date(promo.validFrom);
@@ -62,25 +118,29 @@ function applyPromo(promo, basePrice) {
62
118
  return null;
63
119
  }
64
120
 
121
+ // src/quota-value.ts
122
+ function readQuotaValue(value) {
123
+ if (typeof value === "number") return Number.isFinite(value) ? value : null;
124
+ if (typeof value !== "string") return null;
125
+ if (value.trim() === "") return null;
126
+ const parsed = Number(value);
127
+ return Number.isFinite(parsed) ? parsed : null;
128
+ }
129
+ var UNCOUNTABLE = -1;
130
+ function readQuotaRecord(value) {
131
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return {};
132
+ const quotas = {};
133
+ for (const [key, entry] of Object.entries(value)) {
134
+ quotas[key] = readQuotaValue(entry) ?? UNCOUNTABLE;
135
+ }
136
+ return quotas;
137
+ }
138
+
65
139
  // src/version-diff.ts
66
140
  function classifyPlanDiff(oldV, newV) {
67
141
  const changes = [];
68
142
  appendFeatureChanges(changes, oldV.features, newV.features);
69
- appendNumberChange(changes, "maxUsers", oldV.maxUsers, newV.maxUsers, "higherIsBetter");
70
- appendNumberChange(
71
- changes,
72
- "maxVehicles",
73
- oldV.maxVehicles,
74
- newV.maxVehicles,
75
- "higherIsBetter"
76
- );
77
- appendNumberChange(
78
- changes,
79
- "maxStorageGb",
80
- oldV.maxStorageGb,
81
- newV.maxStorageGb,
82
- "higherIsBetter"
83
- );
143
+ appendQuotaChanges(changes, oldV.quotas, newV.quotas);
84
144
  appendDecimalChange(changes, "monthlyNet", oldV.monthlyNet, newV.monthlyNet, "lowerIsBetter");
85
145
  appendDecimalChange(changes, "yearlyNet", oldV.yearlyNet, newV.yearlyNet, "lowerIsBetter");
86
146
  return buildResult(changes);
@@ -127,11 +187,6 @@ function appendFeatureChanges(out, oldFeatures, newFeatures) {
127
187
  });
128
188
  }
129
189
  }
130
- function appendNumberChange(out, field, oldValue, newValue, polarity) {
131
- if (oldValue === newValue) return;
132
- const direction = directionFromCmp(newValue - oldValue, polarity);
133
- out.push({ field, oldValue, newValue, direction });
134
- }
135
190
  function appendDecimalChange(out, field, oldValue, newValue, polarity) {
136
191
  const oldNum = toNumber(oldValue);
137
192
  const newNum = toNumber(newValue);
@@ -162,16 +217,31 @@ function buildResult(changes) {
162
217
  return { nonRegressive, changes };
163
218
  }
164
219
  function appendQuotaChanges(out, oldQuotas, newQuotas) {
220
+ const at = (quotas, key) => Object.hasOwn(quotas, key) ? quotas[key] : 0;
165
221
  const allKeys = /* @__PURE__ */ new Set([...Object.keys(oldQuotas), ...Object.keys(newQuotas)]);
166
222
  for (const key of allKeys) {
167
- const oldValue = oldQuotas[key] ?? 0;
168
- const newValue = newQuotas[key] ?? 0;
223
+ const oldRaw = at(oldQuotas, key);
224
+ const newRaw = at(newQuotas, key);
225
+ if (oldRaw === newRaw) continue;
226
+ const oldValue = toQuotaNumber(oldRaw);
227
+ const newValue = toQuotaNumber(newRaw);
169
228
  if (oldValue === newValue) continue;
170
- const direction = directionFromQuotaCmp(oldValue, newValue);
171
- out.push({ field: `quotas.${key}`, oldValue, newValue, direction });
229
+ out.push({
230
+ field: `quotas.${key}`,
231
+ oldValue: reportableQuota(oldRaw, oldValue),
232
+ newValue: reportableQuota(newRaw, newValue),
233
+ direction: directionFromQuotaCmp(oldValue, newValue)
234
+ });
172
235
  }
173
236
  }
237
+ function toQuotaNumber(value) {
238
+ return readQuotaValue(value) ?? Number.NaN;
239
+ }
240
+ function reportableQuota(raw, asNumber) {
241
+ return Number.isFinite(asNumber) ? asNumber : String(raw);
242
+ }
174
243
  function directionFromQuotaCmp(oldValue, newValue) {
244
+ if (!Number.isFinite(oldValue) || !Number.isFinite(newValue)) return "REGRESSION";
175
245
  if (oldValue === -1 && newValue !== -1) return "REGRESSION";
176
246
  if (newValue === -1 && oldValue !== -1) return "IMPROVEMENT";
177
247
  return newValue > oldValue ? "IMPROVEMENT" : "REGRESSION";
@@ -199,6 +269,60 @@ function appendNullableDecimalChange(out, field, oldValue, newValue, polarity) {
199
269
  appendDecimalChange(out, field, oldValue, newValue, polarity);
200
270
  }
201
271
 
272
+ // src/settings-subtree.ts
273
+ var CATALOGUE_KEYS = /* @__PURE__ */ new Set([
274
+ "schemaVersion",
275
+ "features",
276
+ "plans"
277
+ ]);
278
+ function planCatalogSettingsOf(catalog) {
279
+ return settingsSubtreeOf(catalog);
280
+ }
281
+ function settingsSubtreeOf(catalog) {
282
+ const settings = {};
283
+ for (const [key, value] of Object.entries(catalog)) {
284
+ if (CATALOGUE_KEYS.has(key)) continue;
285
+ if (value === void 0) continue;
286
+ settings[key] = value;
287
+ }
288
+ return settings;
289
+ }
290
+ function canonicalJson(value) {
291
+ const json = JSON.stringify(value, (_key, member) => {
292
+ if (member && typeof member === "object" && !Array.isArray(member)) {
293
+ const sorted = {};
294
+ for (const name of Object.keys(member).sort()) {
295
+ sorted[name] = member[name];
296
+ }
297
+ return sorted;
298
+ }
299
+ return member;
300
+ });
301
+ return json ?? "undefined";
302
+ }
303
+ function isPlainObject(value) {
304
+ return value !== null && typeof value === "object" && !Array.isArray(value);
305
+ }
306
+ function diffSettings(before, after) {
307
+ const differences = [];
308
+ collectDifferences(before, after, [], differences);
309
+ return differences.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
310
+ }
311
+ function isObjectOrAbsent(value) {
312
+ return value === void 0 || isPlainObject(value);
313
+ }
314
+ function collectDifferences(before, after, path, out) {
315
+ if (isObjectOrAbsent(before) && isObjectOrAbsent(after) && (before || after)) {
316
+ const names = /* @__PURE__ */ new Set([...Object.keys(before ?? {}), ...Object.keys(after ?? {})]);
317
+ for (const name of names) {
318
+ collectDifferences(before?.[name], after?.[name], [...path, name], out);
319
+ }
320
+ return;
321
+ }
322
+ if (canonicalJson(before) === canonicalJson(after)) return;
323
+ out.push({ path: path.join("."), before, after });
324
+ }
325
+
202
326
  // src/ports/persistence-ports.types.ts
203
327
  var PersistenceCapabilityError = class extends Error {
204
328
  constructor(missing, requiredBy) {
@@ -269,6 +393,8 @@ var CATALOG_ERROR_CODES = {
269
393
  BUNDLE_VERSION_SUPERSEDED: "BUNDLE_VERSION_SUPERSEDED",
270
394
  BUNDLE_VERSION_REGRESSION: "BUNDLE_VERSION_REGRESSION",
271
395
  BUNDLE_VERSION_ZERO_PRICE: "BUNDLE_VERSION_ZERO_PRICE",
396
+ BUNDLE_VERSION_NO_PRICE: "BUNDLE_VERSION_NO_PRICE",
397
+ BUNDLE_VERSION_NOT_PRICED_FOR_PLAN: "BUNDLE_VERSION_NOT_PRICED_FOR_PLAN",
272
398
  BUNDLE_VERSION_DISCARD_NOT_IMPLEMENTED: "BUNDLE_VERSION_DISCARD_NOT_IMPLEMENTED",
273
399
  BUNDLE_VERSION_VALID_FROM_REQUIRED: "BUNDLE_VERSION_VALID_FROM_REQUIRED",
274
400
  BUNDLE_VERSION_VALID_FROM_INVALID: "BUNDLE_VERSION_VALID_FROM_INVALID",
@@ -298,7 +424,12 @@ var CATALOG_ERROR_CODES = {
298
424
  // ── discovery ──
299
425
  QUOTA_NOT_IN_DISCOVERY_SNAPSHOT: "QUOTA_NOT_IN_DISCOVERY_SNAPSHOT",
300
426
  DISCOVERY_STATUS_TRANSITION_INVALID: "DISCOVERY_STATUS_TRANSITION_INVALID",
301
- DISCOVERY_NOT_INITIALIZED: "DISCOVERY_NOT_INITIALIZED"
427
+ DISCOVERY_NOT_INITIALIZED: "DISCOVERY_NOT_INITIALIZED",
428
+ // ── catalogue import ──
429
+ /** The uploaded document is not a plan catalog — unparseable, or not an object. */
430
+ PLAN_CATALOG_UNREADABLE: "PLAN_CATALOG_UNREADABLE",
431
+ /** It parsed, and then failed the schema or a cross-field rule. */
432
+ PLAN_CATALOG_INVALID: "PLAN_CATALOG_INVALID"
302
433
  };
303
434
  var BILLING_ERROR_CODES = {
304
435
  /**
@@ -310,6 +441,8 @@ var BILLING_ERROR_CODES = {
310
441
  BUNDLE_ALREADY_SUBSCRIBED: "BUNDLE_ALREADY_SUBSCRIBED",
311
442
  BUNDLE_INCOMPATIBLE_WITH_PLAN: "BUNDLE_INCOMPATIBLE_WITH_PLAN",
312
443
  BUNDLE_NOT_SELF_SERVICE: "BUNDLE_NOT_SELF_SERVICE",
444
+ BUNDLE_CYCLE_EXCEEDS_PLAN: "BUNDLE_CYCLE_EXCEEDS_PLAN",
445
+ BUNDLE_NOT_PRICED_FOR_THIS_PLAN: "BUNDLE_NOT_PRICED_FOR_THIS_PLAN",
313
446
  SUBSCRIPTION_BUNDLE_ALREADY_CANCELLED: "SUBSCRIPTION_BUNDLE_ALREADY_CANCELLED",
314
447
  SUBSCRIPTION_BUNDLE_NOT_CANCELLED: "SUBSCRIPTION_BUNDLE_NOT_CANCELLED",
315
448
  SUBSCRIPTION_BUNDLE_CANCELLATION_EFFECTIVE: "SUBSCRIPTION_BUNDLE_CANCELLATION_EFFECTIVE",
@@ -324,8 +457,91 @@ var BILLING_ERROR_CODES = {
324
457
  PLAN_NOT_IN_CATALOG: "PLAN_NOT_IN_CATALOG",
325
458
  /** Plan exists but cannot be booked via self-service. */
326
459
  PLAN_NOT_SELF_SERVICE: "PLAN_NOT_SELF_SERVICE",
460
+ /**
461
+ * Plan carries no price for the requested billing cycle, so it is not sold
462
+ * in it: a plan without a yearly price is a monthly plan.
463
+ */
464
+ PLAN_NOT_SOLD_IN_CYCLE: "PLAN_NOT_SOLD_IN_CYCLE",
327
465
  /** Plan change refused. Carries `blockers[]` with their own codes. */
328
466
  PLAN_CHANGE_BLOCKED: "PLAN_CHANGE_BLOCKED",
467
+ /**
468
+ * The subscription moved between the read a request was decided on and the
469
+ * write it attempted, so nothing was written. The caller reloads and asks
470
+ * again.
471
+ */
472
+ SUBSCRIPTION_CHANGED: "SUBSCRIPTION_CHANGED",
473
+ /**
474
+ * The tenant has no subscription to act on.
475
+ *
476
+ * `SUBSCRIPTION_NOT_FOUND` states the same fact on the read routes. Both
477
+ * are already on the wire and a code is renamed only deliberately, so both
478
+ * are named here rather than one being dropped behind a consumer's back.
479
+ */
480
+ NO_SUBSCRIPTION: "NO_SUBSCRIPTION",
481
+ /**
482
+ * The cancellation date the reader was shown is no longer the one the rules
483
+ * return, so the confirmation is refused rather than silently applied.
484
+ * Carries the recomputed dates, so the page can re-ask instead of guessing.
485
+ */
486
+ CANCELLATION_TERMS_CHANGED: "CANCELLATION_TERMS_CHANGED",
487
+ // ── the preview routes' own blockers and warnings ──
488
+ //
489
+ // These travel inside a 200 response, in `blockers[]` and `warnings[]`, not
490
+ // as thrown errors — but they are read by a person and so belong in the same
491
+ // catalogue. Each carries `params` with the values its sentence names. Two
492
+ // routes emit them: the plan-change preview and the bundle preview.
493
+ //
494
+ // Three of them used to construct their code from the subject:
495
+ // `VEHICLES_OVER_TARGET`, `ENTERPRISE_LOCKED`, `PRO_NOT_SELF_SERVICE`. That
496
+ // made the set grow with every quota and plan an installation defines, so no
497
+ // catalogue could be complete against it and no guard could check one. The
498
+ // subject is a parameter now.
499
+ /** The subscription has ended; its plan can no longer be changed. */
500
+ SUBSCRIPTION_ENDED: "SUBSCRIPTION_ENDED",
501
+ /** An active special contract blocks self-service plan changes. */
502
+ PLAN_LOCKED: "PLAN_LOCKED",
503
+ /** Current usage of one quota exceeds what the target plan allows. */
504
+ QUOTA_OVER_TARGET: "QUOTA_OVER_TARGET",
505
+ /** The change drops features the tenant has today. */
506
+ FEATURE_LOST: "FEATURE_LOST",
507
+ FEATURES_LOST: "FEATURES_LOST",
508
+ /** Target plan and cycle already match what is in place. */
509
+ NO_CHANGE: "NO_CHANGE",
510
+ /** A shorter cycle cannot start inside the term already running. */
511
+ CYCLE_SHORTENS_AT_TERM_END: "CYCLE_SHORTENS_AT_TERM_END",
512
+ /** A cancelled subscription cannot change its billing cycle. */
513
+ CANCELLATION_LOCKS_THE_CYCLE: "CANCELLATION_LOCKS_THE_CYCLE",
514
+ /**
515
+ * A bundle the tenant already holds runs past the cycle they are moving to.
516
+ *
517
+ * Its own code rather than `BUNDLE_CYCLE_EXCEEDS_PLAN`, which states the
518
+ * same rule about a booking that has not been made yet. The two need
519
+ * different sentences: this one can name the day the obstacle lifts and
520
+ * tell the reader to cancel the booking, and that advice is wrong for
521
+ * someone who is only about to book. One template cannot serve both.
522
+ */
523
+ BUNDLE_BOOKING_OUTLASTS_TARGET_CYCLE: "BUNDLE_BOOKING_OUTLASTS_TARGET_CYCLE",
524
+ /**
525
+ * Features of the previewed bundle are already covered by the plan or by
526
+ * another booked bundle. A warning rather than a blocker: paying twice is
527
+ * the customer's decision, and the preview only has to say so first.
528
+ */
529
+ REDUNDANT_FEATURES: "REDUNDANT_FEATURES",
530
+ /**
531
+ * A booking's minimum term outlasts the period being cancelled, so the
532
+ * cancellation takes effect at the end of the term, not of the period.
533
+ */
534
+ MINIMUM_TERM_BINDS: "MINIMUM_TERM_BINDS",
535
+ /**
536
+ * The previewed bundle requires features that neither the plan nor an
537
+ * active booking provides.
538
+ *
539
+ * The same string is a `StrictModeWarningCode` in `bundle.types.ts`, where
540
+ * it names the catalogue-authoring reading of the rule and travels with its
541
+ * own message. This declaration is the booking preview's blocker, which a
542
+ * tenant reads and therefore needs a shipped text for.
543
+ */
544
+ BUNDLE_FEATURE_DEPENDENCY_UNSATISFIED: "BUNDLE_FEATURE_DEPENDENCY_UNSATISFIED",
329
545
  NO_PENDING_PLAN_VERSION: "NO_PENDING_PLAN_VERSION",
330
546
  ONBOARDING_CREATE_FAILED: "ONBOARDING_CREATE_FAILED",
331
547
  BUNDLE_PREVIEW_ARGUMENT_AMBIGUOUS: "BUNDLE_PREVIEW_ARGUMENT_AMBIGUOUS",
@@ -345,20 +561,57 @@ var CONTRACT_ERROR_CODES = {
345
561
  CHECKOUT_OFFER_BUNDLE_LINE_ITEMS_REQUIRED: "CHECKOUT_OFFER_BUNDLE_LINE_ITEMS_REQUIRED",
346
562
  CHECKOUT_OFFER_BUNDLE_VERSION_NOT_BOOKABLE: "CHECKOUT_OFFER_BUNDLE_VERSION_NOT_BOOKABLE",
347
563
  CHECKOUT_OFFER_FEATURE_DEPENDENCY_UNSATISFIED: "CHECKOUT_OFFER_FEATURE_DEPENDENCY_UNSATISFIED",
564
+ CHECKOUT_OFFER_PLAN_NOT_OFFERED: "CHECKOUT_OFFER_PLAN_NOT_OFFERED",
565
+ CHECKOUT_OFFER_BUNDLE_NOT_OFFERED: "CHECKOUT_OFFER_BUNDLE_NOT_OFFERED",
566
+ CHECKOUT_OFFER_PROMO_CODE_NOT_ACCEPTED: "CHECKOUT_OFFER_PROMO_CODE_NOT_ACCEPTED",
567
+ CHECKOUT_OFFER_PRICE_NOT_CURRENT: "CHECKOUT_OFFER_PRICE_NOT_CURRENT",
348
568
  SUBSCRIPTION_CONTRACT_LINE_ITEMS_REQUIRED: "SUBSCRIPTION_CONTRACT_LINE_ITEMS_REQUIRED",
349
569
  SUBSCRIPTION_CONTRACT_PLAN_LINE_ITEM_REQUIRED: "SUBSCRIPTION_CONTRACT_PLAN_LINE_ITEM_REQUIRED",
350
570
  SUBSCRIPTION_CONTRACT_INVALID_DATE: "SUBSCRIPTION_CONTRACT_INVALID_DATE",
351
571
  SUBSCRIPTION_CONTRACT_INVALID_WINDOW: "SUBSCRIPTION_CONTRACT_INVALID_WINDOW",
572
+ SUBSCRIPTION_CONTRACT_LINE_ITEM_TAX_MISMATCH: "SUBSCRIPTION_CONTRACT_LINE_ITEM_TAX_MISMATCH",
573
+ SUBSCRIPTION_CONTRACT_TAX_RATE_NOT_PERCENT: "SUBSCRIPTION_CONTRACT_TAX_RATE_NOT_PERCENT",
574
+ SUBSCRIPTION_CONTRACT_LINE_ITEM_CURRENCY_MISMATCH: "SUBSCRIPTION_CONTRACT_LINE_ITEM_CURRENCY_MISMATCH",
352
575
  SUBSCRIPTION_CONTRACT_TERMINATION_BEFORE_START: "SUBSCRIPTION_CONTRACT_TERMINATION_BEFORE_START",
353
576
  // ── stage 3 ──
354
577
  CHECKOUT_OFFER_NOT_FOUND: "CHECKOUT_OFFER_NOT_FOUND",
355
578
  CHECKOUT_OFFER_EXPIRED: "CHECKOUT_OFFER_EXPIRED",
356
579
  CHECKOUT_OFFER_ALREADY_CONSUMED: "CHECKOUT_OFFER_ALREADY_CONSUMED",
357
580
  CHECKOUT_OFFER_NOT_CONSUMED: "CHECKOUT_OFFER_NOT_CONSUMED",
581
+ /**
582
+ * The offer changed between the checks of `conclude` and the transaction
583
+ * that consumed it, so the contract checked is not the one the offer now
584
+ * describes. Nothing was written; load the offer and conclude it again.
585
+ */
586
+ CHECKOUT_OFFER_CHANGED: "CHECKOUT_OFFER_CHANGED",
358
587
  SUBSCRIPTION_CONTRACT_NOT_FOUND: "SUBSCRIPTION_CONTRACT_NOT_FOUND",
359
588
  NO_ACTIVE_SUBSCRIPTION_CONTRACT: "NO_ACTIVE_SUBSCRIPTION_CONTRACT",
360
589
  SUBSCRIPTION_CONTRACT_ALREADY_CLOSED: "SUBSCRIPTION_CONTRACT_ALREADY_CLOSED"
361
590
  };
591
+ var SUBSCRIBER_ERROR_CODES = {
592
+ /**
593
+ * A contract, a plan change or a booking for a tenant that has no
594
+ * subscriber. Nothing is agreed or charged without the party to it.
595
+ * Carries `tenantId`.
596
+ */
597
+ SUBSCRIBER_REQUIRED: "SUBSCRIBER_REQUIRED",
598
+ /** The tenant already has a live subscriber. Carries `tenantId`. */
599
+ SUBSCRIBER_ALREADY_EXISTS: "SUBSCRIBER_ALREADY_EXISTS",
600
+ SUBSCRIBER_NOT_FOUND: "SUBSCRIBER_NOT_FOUND",
601
+ SUBSCRIBER_LEGAL_NAME_REQUIRED: "SUBSCRIBER_LEGAL_NAME_REQUIRED",
602
+ /**
603
+ * A detail that has a form — the country, the invoice email — is not in it,
604
+ * or one sign-up requires — the billing address — is missing. Carries `field`.
605
+ */
606
+ SUBSCRIBER_DETAIL_INVALID: "SUBSCRIBER_DETAIL_INVALID",
607
+ /** A contact change named a field of the legal identity. Carries `field`. */
608
+ SUBSCRIBER_IDENTITY_NOT_A_CONTACT: "SUBSCRIBER_IDENTITY_NOT_A_CONTACT",
609
+ SUBSCRIBER_CORRECTION_REASON_REQUIRED: "SUBSCRIBER_CORRECTION_REASON_REQUIRED",
610
+ SUBSCRIBER_CORRECTION_ACTOR_REQUIRED: "SUBSCRIBER_CORRECTION_ACTOR_REQUIRED",
611
+ SUBSCRIBER_CORRECTION_CHANGES_NOTHING: "SUBSCRIBER_CORRECTION_CHANGES_NOTHING",
612
+ /** The operator declared another legal entity: that is a transfer, not an edit. */
613
+ SUBSCRIBER_TAKEOVER_IS_A_TRANSFER: "SUBSCRIBER_TAKEOVER_IS_A_TRANSFER"
614
+ };
362
615
  var REGISTRATION_ERROR_CODES = {
363
616
  PENDING_REGISTRATION_NOT_FOUND: "PENDING_REGISTRATION_NOT_FOUND",
364
617
  PENDING_REGISTRATION_EXPIRED: "PENDING_REGISTRATION_EXPIRED",
@@ -384,6 +637,12 @@ var AUTH_ERROR_CODES = {
384
637
  /** Neither `tenantId` nor `userId` could be resolved from the request. */
385
638
  TENANT_CONTEXT_MISSING: "TENANT_CONTEXT_MISSING",
386
639
  TENANT_ADMIN_REQUIRED: "TENANT_ADMIN_REQUIRED",
640
+ /**
641
+ * The tenant's billing area — its payment method, and later its invoices
642
+ * and account — needs the billing permission, which the application maps
643
+ * to its roles and the tenant's administrator holds by default.
644
+ */
645
+ BILLING_PERMISSION_REQUIRED: "BILLING_PERMISSION_REQUIRED",
387
646
  SUPER_ADMIN_REQUIRED: "SUPER_ADMIN_REQUIRED",
388
647
  /** TOTP MFA has never been set up for this user. */
389
648
  MFA_NOT_SET_UP: "MFA_NOT_SET_UP",
@@ -411,6 +670,26 @@ var PROMO_ERROR_CODES = {
411
670
  PROMO_WOULD_PRODUCE_ZERO_INVOICE: "PROMO_WOULD_PRODUCE_ZERO_INVOICE",
412
671
  PROMO_MAX_REDEMPTIONS_LOWERED: "PROMO_MAX_REDEMPTIONS_LOWERED"
413
672
  };
673
+ var PAYMENT_ERROR_CODES = {
674
+ /**
675
+ * No gateway account takes new payment methods:
676
+ * `config/saas.yaml#payments.newPaymentMethods` names none.
677
+ */
678
+ PAYMENTS_NOT_CONFIGURED: "PAYMENTS_NOT_CONFIGURED",
679
+ /** A callback arrived for an account `config/saas.yaml#payments.accounts` does not name. Carries `account`. */
680
+ PAYMENT_GATEWAY_ACCOUNT_UNKNOWN: "PAYMENT_GATEWAY_ACCOUNT_UNKNOWN",
681
+ /** A callback the gateway did not send: its signature does not verify. */
682
+ PAYMENT_CALLBACK_REJECTED: "PAYMENT_CALLBACK_REJECTED",
683
+ /**
684
+ * A success or cancel URL at an origin `config/saas.yaml#payments.returnUrlOrigins`
685
+ * does not name. Carries `field`.
686
+ */
687
+ PAYMENT_RETURN_URL_NOT_ALLOWED: "PAYMENT_RETURN_URL_NOT_ALLOWED"
688
+ };
689
+ var SETTINGS_ERROR_CODES = {
690
+ /** No recorded change has this id, or the installation keeps no record at all. */
691
+ SETTINGS_CHANGE_NOT_FOUND: "SETTINGS_CHANGE_NOT_FOUND"
692
+ };
414
693
  var PLATFORM_ERROR_CODES = {
415
694
  ...SETUP_ERROR_CODES,
416
695
  ...AUTH_ERROR_CODES,
@@ -418,7 +697,10 @@ var PLATFORM_ERROR_CODES = {
418
697
  ...CATALOG_ERROR_CODES,
419
698
  ...BILLING_ERROR_CODES,
420
699
  ...CONTRACT_ERROR_CODES,
421
- ...REGISTRATION_ERROR_CODES
700
+ ...SUBSCRIBER_ERROR_CODES,
701
+ ...REGISTRATION_ERROR_CODES,
702
+ ...PAYMENT_ERROR_CODES,
703
+ ...SETTINGS_ERROR_CODES
422
704
  };
423
705
 
424
706
  // src/errors.ts
@@ -497,6 +779,19 @@ function selectChargeableBundles(planFeatures, selectedBundles) {
497
779
  }
498
780
  }
499
781
 
782
+ // src/payment-gateway.types.ts
783
+ var PAYMENT_CALLBACK_REJECTED = "PAYMENT_CALLBACK_REJECTED";
784
+ var PaymentCallbackRejectedError = class extends Error {
785
+ code = PAYMENT_CALLBACK_REJECTED;
786
+ constructor(reason) {
787
+ super(`Payment callback rejected: ${reason}`);
788
+ this.name = "PaymentCallbackRejectedError";
789
+ }
790
+ };
791
+ function isPaymentCallbackRejectedError(err) {
792
+ return err instanceof Error && err.code === PAYMENT_CALLBACK_REJECTED;
793
+ }
794
+
500
795
  // src/registration.types.ts
501
796
  var PENDING_EMAIL_TTL_HOURS = 72;
502
797
  var PENDING_ONBOARDING_TTL_DAYS = 14;
@@ -516,6 +811,418 @@ var REGISTRATION_STEP_BY_STATUS = {
516
811
  };
517
812
  var REGISTRATION_RESUME_TTL_MINUTES = 60;
518
813
 
814
+ // src/plan-mapping.ts
815
+ function toPlanRow(row) {
816
+ return {
817
+ id: row.id,
818
+ planKey: row.planKey,
819
+ label: row.label,
820
+ description: row.description,
821
+ icon: row.icon,
822
+ sortOrder: row.sortOrder,
823
+ createdAt: row.createdAt.toISOString(),
824
+ updatedAt: row.updatedAt.toISOString(),
825
+ deletedAt: toIsoOrNull(row.deletedAt)
826
+ };
827
+ }
828
+ function toPlanVersionRow(row, planKey, fields) {
829
+ const mapped = {
830
+ id: row.id,
831
+ version: row.version,
832
+ baseVersionId: row.baseVersionId,
833
+ planId: planKey,
834
+ features: toFeatureKeys(row.features),
835
+ quotas: toQuotaEffects(row.quotas),
836
+ monthlyNet: String(row.monthlyNet),
837
+ yearlyNet: String(row.yearlyNet),
838
+ marketed: row.marketed,
839
+ publishedAt: toIsoOrNull(row.publishedAt),
840
+ supersededAt: toIsoOrNull(row.supersededAt),
841
+ publishedChanges: Array.isArray(row.publishedChanges) ? row.publishedChanges : null,
842
+ changeNote: row.changeNote,
843
+ nonRegressive: row.nonRegressive,
844
+ validFrom: fields.validityWindows ? toIsoOrNull(row.validFrom) : null,
845
+ validUntil: fields.validityWindows ? toIsoOrNull(row.validUntil) : null,
846
+ createdByUserId: row.createdByUserId,
847
+ publishedByUserId: row.publishedByUserId,
848
+ createdAt: row.createdAt.toISOString(),
849
+ updatedAt: row.updatedAt.toISOString()
850
+ };
851
+ if (fields.endsAt) {
852
+ mapped.endsAt = toIsoOrNull(row.endsAt);
853
+ }
854
+ return mapped;
855
+ }
856
+ function toIsoOrNull(value) {
857
+ return value ? value.toISOString() : null;
858
+ }
859
+ function toFeatureKeys(value) {
860
+ if (!Array.isArray(value)) return [];
861
+ return value.filter((entry) => typeof entry === "string");
862
+ }
863
+ function toQuotaEffects(value) {
864
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
865
+ return {};
866
+ }
867
+ const quotas = {};
868
+ for (const [key, entry] of Object.entries(value)) {
869
+ quotas[key] = readQuotaValue(entry) ?? Number.NaN;
870
+ }
871
+ return quotas;
872
+ }
873
+
874
+ // src/legal-identity.ts
875
+ var LEGAL_IDENTITY_FIELDS = [
876
+ "legalName",
877
+ "vatId",
878
+ "taxNumber"
879
+ ];
880
+ function sameLegalIdentity(before, after) {
881
+ return LEGAL_IDENTITY_FIELDS.every((field) => before[field] === after[field]);
882
+ }
883
+ function movedIdentityFields(before, after) {
884
+ return LEGAL_IDENTITY_FIELDS.filter((field) => before[field] !== after[field]);
885
+ }
886
+
887
+ // src/issuer-identity.ts
888
+ function issuerIdentityOf(issuer) {
889
+ if (!issuer) return null;
890
+ return identityOf({
891
+ legalName: issuer.legalName,
892
+ vatId: issuer.vatId,
893
+ taxNumber: issuer.taxNumber
894
+ });
895
+ }
896
+ function recordedIssuerIdentity(settings) {
897
+ const issuer = settings?.issuer;
898
+ if (issuer === null || typeof issuer !== "object" || Array.isArray(issuer)) return null;
899
+ return identityOf(issuer);
900
+ }
901
+ function identityOf(source) {
902
+ const legalName = textOrNull(source.legalName);
903
+ if (legalName === null) return null;
904
+ return {
905
+ legalName,
906
+ vatId: textOrNull(source.vatId),
907
+ taxNumber: textOrNull(source.taxNumber)
908
+ };
909
+ }
910
+ function classifyIssuerChange(recorded, issuer) {
911
+ const current = issuerIdentityOf(issuer);
912
+ if (!recorded)
913
+ return current ? { kind: "first-naming", identity: current } : { kind: "none-named" };
914
+ if (current && sameLegalIdentity(recorded, current))
915
+ return { kind: "unchanged", identity: current };
916
+ if (!current) {
917
+ const moved2 = LEGAL_IDENTITY_FIELDS.filter((field) => recorded[field] !== null);
918
+ return {
919
+ kind: "undeclared",
920
+ recorded,
921
+ current: null,
922
+ moved: moved2,
923
+ fault: { kind: "names-no-issuer" }
924
+ };
925
+ }
926
+ const moved = movedIdentityFields(recorded, current);
927
+ const fault = faultIn(issuer?.correctionOf, recorded, moved);
928
+ if (fault) return { kind: "undeclared", recorded, current, moved, fault };
929
+ const declaration = issuer?.correctionOf;
930
+ return { kind: "corrected", recorded, current, moved, reason: declaration.reason };
931
+ }
932
+ function faultIn(declaration, recorded, moved) {
933
+ if (!declaration) return { kind: "absent" };
934
+ for (const field of LEGAL_IDENTITY_FIELDS) {
935
+ if (!Object.prototype.hasOwnProperty.call(declaration, field)) continue;
936
+ const declared = textOrNull(declaration[field]);
937
+ if (declared !== recorded[field]) {
938
+ return { kind: "names-another-value", field, declared, recorded: recorded[field] };
939
+ }
940
+ }
941
+ for (const field of moved) {
942
+ if (Object.prototype.hasOwnProperty.call(declaration, field)) continue;
943
+ return { kind: "leaves-a-field-out", field, recorded: recorded[field] };
944
+ }
945
+ return null;
946
+ }
947
+ function textOrNull(value) {
948
+ if (typeof value !== "string") return null;
949
+ const trimmed = value.trim();
950
+ return trimmed === "" ? null : trimmed;
951
+ }
952
+
953
+ // src/subscriber-mapping.ts
954
+ function formatCustomerNumber(prefix, sequence) {
955
+ return `${prefix}${sequence}`;
956
+ }
957
+ function toSubscriberRecord(row, tenantId) {
958
+ return {
959
+ id: row.id,
960
+ customerNumber: formatCustomerNumber(row.customerNumberPrefix, row.customerSequence),
961
+ legalName: row.legalName,
962
+ addressLine1: row.addressLine1,
963
+ addressLine2: row.addressLine2,
964
+ postalCode: row.postalCode,
965
+ city: row.city,
966
+ country: row.country,
967
+ vatId: row.vatId,
968
+ taxNumber: row.taxNumber,
969
+ invoiceEmail: row.invoiceEmail,
970
+ tenantId,
971
+ migrated: row.migrated,
972
+ createdAt: row.createdAt,
973
+ updatedAt: row.updatedAt
974
+ };
975
+ }
976
+ function toSubscriberCorrectionRecord(row) {
977
+ return {
978
+ id: row.id,
979
+ subscriberId: row.subscriberId,
980
+ previous: toIdentityValues(row.previous),
981
+ corrected: toIdentityValues(row.corrected),
982
+ reason: row.reason,
983
+ correctedBy: row.correctedBy,
984
+ correctedAt: row.correctedAt
985
+ };
986
+ }
987
+ function identityCorrectionDelta(current, corrected) {
988
+ const previous = {};
989
+ const next = {};
990
+ for (const field of LEGAL_IDENTITY_FIELDS) {
991
+ const value = corrected[field];
992
+ if (value === void 0 || value === current[field]) continue;
993
+ previous[field] = current[field];
994
+ next[field] = value;
995
+ }
996
+ return {
997
+ previous,
998
+ corrected: next
999
+ };
1000
+ }
1001
+ function contractPartiesOf(subscriber, issuer) {
1002
+ const party = {
1003
+ customerNumber: subscriber.customerNumber,
1004
+ legalName: subscriber.legalName,
1005
+ vatId: subscriber.vatId,
1006
+ taxNumber: subscriber.taxNumber,
1007
+ addressLine1: subscriber.addressLine1,
1008
+ addressLine2: subscriber.addressLine2,
1009
+ postalCode: subscriber.postalCode,
1010
+ city: subscriber.city,
1011
+ country: subscriber.country
1012
+ };
1013
+ return {
1014
+ subscriberId: subscriber.id,
1015
+ subscriber: party,
1016
+ issuer: issuer ? issuerPartyOf(issuer) : null
1017
+ };
1018
+ }
1019
+ function issuerPartyOf(issuer) {
1020
+ const identity = issuerIdentityOf(issuer);
1021
+ return {
1022
+ legalName: identity?.legalName ?? "",
1023
+ vatId: identity?.vatId ?? null,
1024
+ taxNumber: identity?.taxNumber ?? null,
1025
+ // Settled like the three above rather than copied verbatim: one copy
1026
+ // whose halves were settled differently is a row that reads two ways,
1027
+ // and a city written with a trailing space is not another city.
1028
+ addressLine1: settledText(issuer.addressLine1),
1029
+ addressLine2: settledText(issuer.addressLine2),
1030
+ postalCode: settledText(issuer.postalCode),
1031
+ city: settledText(issuer.city),
1032
+ country: settledText(issuer.country)
1033
+ };
1034
+ }
1035
+ function settledText(value) {
1036
+ if (typeof value !== "string") return null;
1037
+ const trimmed = value.trim();
1038
+ return trimmed === "" ? null : trimmed;
1039
+ }
1040
+ function subscriberFromRegistration(pending) {
1041
+ return {
1042
+ legalName: pending.tenantName,
1043
+ invoiceEmail: pending.email,
1044
+ addressLine1: pending.addressLine1,
1045
+ addressLine2: pending.addressLine2,
1046
+ postalCode: pending.postalCode,
1047
+ city: pending.city,
1048
+ country: pending.country,
1049
+ vatId: pending.vatId,
1050
+ taxNumber: pending.taxNumber
1051
+ };
1052
+ }
1053
+ function toIdentityValues(value) {
1054
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return {};
1055
+ const source = value;
1056
+ const values = {};
1057
+ for (const field of LEGAL_IDENTITY_FIELDS) {
1058
+ if (!Object.prototype.hasOwnProperty.call(source, field)) continue;
1059
+ const entry = source[field];
1060
+ values[field] = typeof entry === "string" ? entry : null;
1061
+ }
1062
+ return values;
1063
+ }
1064
+
1065
+ // src/subscriber-payment-method-mapping.ts
1066
+ var PAYMENT_METHOD_TYPES = ["card", "sepa_debit"];
1067
+ var STATUSES = ["ACTIVE", "REPLACED"];
1068
+ function toSubscriberPaymentMethodRecord(row) {
1069
+ return {
1070
+ id: row.id,
1071
+ subscriberId: row.subscriberId,
1072
+ gatewayAccount: row.gatewayAccount,
1073
+ provider: row.provider,
1074
+ customerRef: row.customerRef,
1075
+ paymentMethodRef: row.paymentMethodRef,
1076
+ type: oneOf(PAYMENT_METHOD_TYPES, row.type, "type", row.id),
1077
+ brand: row.brand,
1078
+ last4: row.last4,
1079
+ expiryMonth: row.expiryMonth,
1080
+ expiryYear: row.expiryYear,
1081
+ country: row.country,
1082
+ bankCode: row.bankCode,
1083
+ mandateReference: row.mandateReference,
1084
+ status: oneOf(STATUSES, row.status, "status", row.id),
1085
+ confirmedAt: row.confirmedAt,
1086
+ replacedAt: row.replacedAt,
1087
+ createdAt: row.createdAt
1088
+ };
1089
+ }
1090
+ function subscriberPaymentMethodColumns(data) {
1091
+ return {
1092
+ subscriberId: data.subscriberId,
1093
+ gatewayAccount: data.gatewayAccount,
1094
+ provider: data.provider,
1095
+ customerRef: data.customerRef,
1096
+ paymentMethodRef: data.paymentMethodRef,
1097
+ type: data.type,
1098
+ brand: data.brand,
1099
+ last4: data.last4,
1100
+ expiryMonth: data.expiryMonth,
1101
+ expiryYear: data.expiryYear,
1102
+ country: data.country,
1103
+ bankCode: data.bankCode,
1104
+ mandateReference: data.mandateReference,
1105
+ confirmedAt: data.confirmedAt
1106
+ };
1107
+ }
1108
+ function oneOf(allowed, value, column, id) {
1109
+ const match = allowed.find((entry) => entry === value);
1110
+ if (match === void 0) {
1111
+ throw new Error(
1112
+ `subscriber_payment_methods row '${id}' holds ${column} '${value}', which is none of ${allowed.join(", ")}.`
1113
+ );
1114
+ }
1115
+ return match;
1116
+ }
1117
+
1118
+ // src/subscription-contract-mapping.ts
1119
+ function toSubscriptionContractRecord(row, lineItems) {
1120
+ return {
1121
+ id: row.id,
1122
+ tenantId: row.tenantId,
1123
+ subscriberId: row.subscriberId,
1124
+ subscriber: toSubscriberParty(row.subscriberSnapshot),
1125
+ issuer: isPlainObject2(row.issuerSnapshot) ? toIssuerParty(row.issuerSnapshot) : null,
1126
+ partiesMigrated: row.partiesMigrated,
1127
+ status: row.status,
1128
+ effectiveFrom: row.effectiveFrom,
1129
+ effectiveUntil: row.effectiveUntil,
1130
+ originalOfferId: row.originalOfferId,
1131
+ originalPlanVersionId: row.originalPlanVersionId,
1132
+ originalBundleVersionIds: toStringArray(row.originalBundleVersionIds),
1133
+ entitlementSnapshot: isPlainObject2(row.entitlementSnapshot) ? row.entitlementSnapshot : null,
1134
+ priceSnapshot: row.priceSnapshot,
1135
+ promotionSnapshots: toUnknownArray(row.promotionSnapshots),
1136
+ promoCodeSnapshots: toUnknownArray(row.promoCodeSnapshots),
1137
+ termsSnapshot: toRecordOrNull(row.termsSnapshot),
1138
+ lineItems: lineItems.map(toContractLineItemRecord),
1139
+ createdAt: row.createdAt,
1140
+ updatedAt: row.updatedAt
1141
+ };
1142
+ }
1143
+ function toContractLineItemRecord(row) {
1144
+ return {
1145
+ id: row.id,
1146
+ contractId: row.contractId,
1147
+ kind: row.kind,
1148
+ sourceKey: row.sourceKey,
1149
+ sourceVersionId: row.sourceVersionId,
1150
+ titleSnapshot: row.titleSnapshot,
1151
+ descriptionSnapshot: row.descriptionSnapshot,
1152
+ quantity: row.quantity,
1153
+ unit: row.unit,
1154
+ priceNet: Number(row.priceNet),
1155
+ priceGross: Number(row.priceGross),
1156
+ billingCycle: row.billingCycle,
1157
+ currency: row.currency,
1158
+ taxRate: Number(row.taxRate),
1159
+ taxAmount: Number(row.taxAmount),
1160
+ minimumTermUntil: row.minimumTermUntil,
1161
+ featuresSnapshot: toStringArray(row.featuresSnapshot),
1162
+ quotaEffectsSnapshot: toQuotaEffects2(row.quotaEffectsSnapshot),
1163
+ metadata: toRecordOrNull(row.metadata),
1164
+ createdAt: row.createdAt
1165
+ };
1166
+ }
1167
+ function toSubscriberParty(value) {
1168
+ const source = isPlainObject2(value) ? value : {};
1169
+ return {
1170
+ customerNumber: stringOr(source.customerNumber, ""),
1171
+ ...toIssuerParty(source)
1172
+ };
1173
+ }
1174
+ function toRunningContractIssuer(row) {
1175
+ const issuer = isPlainObject2(row.issuerSnapshot) ? row.issuerSnapshot : null;
1176
+ return {
1177
+ id: row.id,
1178
+ tenantId: row.tenantId,
1179
+ issuerLegalName: issuer ? stringOrNull(issuer.legalName) : null,
1180
+ effectiveFrom: row.effectiveFrom
1181
+ };
1182
+ }
1183
+ function toIssuerParty(value) {
1184
+ const source = value;
1185
+ return {
1186
+ legalName: stringOr(source.legalName, ""),
1187
+ vatId: stringOrNull(source.vatId),
1188
+ taxNumber: stringOrNull(source.taxNumber),
1189
+ addressLine1: stringOrNull(source.addressLine1),
1190
+ addressLine2: stringOrNull(source.addressLine2),
1191
+ postalCode: stringOrNull(source.postalCode),
1192
+ city: stringOrNull(source.city),
1193
+ country: stringOrNull(source.country)
1194
+ };
1195
+ }
1196
+ function stringOr(value, fallback) {
1197
+ return typeof value === "string" ? value : fallback;
1198
+ }
1199
+ function stringOrNull(value) {
1200
+ return typeof value === "string" ? value : null;
1201
+ }
1202
+ function isPlainObject2(value) {
1203
+ return value !== null && typeof value === "object" && !Array.isArray(value);
1204
+ }
1205
+ function toUnknownArray(value) {
1206
+ return Array.isArray(value) ? value : [];
1207
+ }
1208
+ function toRecordOrNull(value) {
1209
+ return isPlainObject2(value) ? value : null;
1210
+ }
1211
+ function toStringArray(value) {
1212
+ if (!Array.isArray(value)) return [];
1213
+ return value.filter((entry) => typeof entry === "string");
1214
+ }
1215
+ function toQuotaEffects2(value) {
1216
+ return isPlainObject2(value) ? readQuotaRecord(value) : {};
1217
+ }
1218
+
1219
+ // src/subscription-contract.types.ts
1220
+ var BUNDLE_PRICE_LOOKUP_LIMIT = 200;
1221
+ var ACTIVE_SUBSCRIPTION_CONTRACT_STATUSES = [
1222
+ "active",
1223
+ "scheduled"
1224
+ ];
1225
+
519
1226
  // src/version-editability.ts
520
1227
  function isVersionEditable(v, now = /* @__PURE__ */ new Date()) {
521
1228
  if (v.publishedAt === null) {
@@ -543,6 +1250,17 @@ function isVersionEditable(v, now = /* @__PURE__ */ new Date()) {
543
1250
  return { editable: true, reason: "pre-active" };
544
1251
  }
545
1252
 
1253
+ // src/recommended-plan.ts
1254
+ function keepOneRecommended(plans, inRequestedLocale) {
1255
+ const recommended = plans.filter((plan) => plan.highlight);
1256
+ if (recommended.length === 0) return null;
1257
+ const winner = recommended.find((plan) => inRequestedLocale.has(plan.planKey)) ?? recommended[0];
1258
+ for (const plan of recommended) {
1259
+ if (plan !== winner) plan.highlight = false;
1260
+ }
1261
+ return winner;
1262
+ }
1263
+
546
1264
  // src/error-messages.ts
547
1265
  var ERROR_MESSAGES_EN = {
548
1266
  // ── setup ──
@@ -556,6 +1274,7 @@ var ERROR_MESSAGES_EN = {
556
1274
  NO_TENANT_ASSIGNED: "No tenant assigned",
557
1275
  TENANT_CONTEXT_MISSING: "No tenant ID found on the request",
558
1276
  TENANT_ADMIN_REQUIRED: "This action requires the TENANT_ADMIN role.",
1277
+ BILLING_PERMISSION_REQUIRED: "This part of the billing area requires the billing permission.",
559
1278
  SUPER_ADMIN_REQUIRED: "Only the SUPER_ADMIN role is allowed",
560
1279
  MFA_NOT_SET_UP: "Run the MFA setup via the CLI first.",
561
1280
  MFA_REQUIRED: "TOTP code required in the X-Mfa-Code header.",
@@ -587,6 +1306,8 @@ var ERROR_MESSAGES_EN = {
587
1306
  BUNDLE_VERSION_SUPERSEDED: "BundleVersion '{bundleVersionId}' has been superseded by a newer version.",
588
1307
  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).",
589
1308
  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.",
1309
+ BUNDLE_VERSION_NO_PRICE: "This bundle version cannot be published without a price: neither a base price nor any plan override resolves one.",
1310
+ 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.",
590
1311
  BUNDLE_VERSION_DISCARD_NOT_IMPLEMENTED: "Discard is not implemented in the current repository. Implement BundleRepository.deleteDraft.",
591
1312
  BUNDLE_VERSION_VALID_FROM_REQUIRED: "Published bundle versions must keep a validFrom. Set a new future date, or edit the draft before publishing.",
592
1313
  BUNDLE_VERSION_VALID_FROM_INVALID: "validFrom '{validFrom}' is not a valid date",
@@ -600,22 +1321,27 @@ var ERROR_MESSAGES_EN = {
600
1321
  PLAN_VERSION_NOT_FOUND: "PlanVersion '{versionId}' not found",
601
1322
  BUNDLE_NOT_FOUND: "Bundle '{bundleId}' not found",
602
1323
  BUNDLE_VERSION_NOT_FOUND: "BundleVersion '{bundleVersionId}' not found",
603
- FEATURE_NOT_FOUND: "Feature '{featureKey}' not found in project '{projectKey}'",
604
- QUOTA_NOT_FOUND: "Quota '{quotaKey}' not found in project '{projectKey}'",
1324
+ FEATURE_NOT_FOUND: "Feature '{featureKey}' not found",
1325
+ QUOTA_NOT_FOUND: "Quota '{quotaKey}' not found",
605
1326
  PROMOTION_NOT_FOUND: "Promotion '{promotionId}' not found",
606
1327
  MARKETING_PROJECTION_NOT_FOUND: "MarketingProjection '{projectionId}' not found",
607
- PLAN_ALREADY_EXISTS: "Plan '{planKey}' already exists in project '{projectKey}'",
608
- BUNDLE_ALREADY_EXISTS: "Bundle '{bundleKey}' already exists in project '{projectKey}'",
1328
+ PLAN_ALREADY_EXISTS: "Plan '{planKey}' already exists",
1329
+ BUNDLE_ALREADY_EXISTS: "Bundle '{bundleKey}' already exists",
609
1330
  MARKETING_PROJECTION_ALREADY_EXISTS: "Marketing projection for {targetType}/{targetVersionId}/{locale} already exists \u2014 use PATCH to edit it",
610
1331
  PLAN_DRAFT_ALREADY_EXISTS: "Plan '{planKey}' already has a draft version v{draftVersion}; publish or discard it first",
611
1332
  BUNDLE_DRAFT_ALREADY_EXISTS: "Bundle '{bundleKey}' already has a draft version v{draftVersion}; publish or discard it first",
612
1333
  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",
613
1334
  DISCOVERY_STATUS_TRANSITION_INVALID: "Transition '{from}' \u2192 '{to}' is not allowed",
614
1335
  DISCOVERY_NOT_INITIALIZED: "Approval requires a discovery snapshot \u2014 discovery is not initialised (#25)",
1336
+ // ── catalogue import ──
1337
+ 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.",
1338
+ PLAN_CATALOG_INVALID: "The plan catalog was read, and then rejected: {message}",
615
1339
  // ── billing ──
616
1340
  BUNDLE_ALREADY_SUBSCRIBED: "Subscription '{subscriptionId}' has already actively booked this bundle.",
617
1341
  BUNDLE_INCOMPATIBLE_WITH_PLAN: "BundleVersion '{bundleVersionId}' is not compatible with plan '{planKey}'. Allowed: [{allowedPlanKeys}].",
618
1342
  BUNDLE_NOT_SELF_SERVICE: "Bundle '{bundleKey}' is only activated via a special contract. Please contact the contract manager.",
1343
+ 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.",
1344
+ BUNDLE_NOT_PRICED_FOR_THIS_PLAN: "This bundle has no {billingCycle} price for the {planKey} plan, so it cannot be booked from here.",
619
1345
  SUBSCRIPTION_BUNDLE_ALREADY_CANCELLED: "SubscriptionBundle '{subscriptionBundleId}' is already cancelled.",
620
1346
  SUBSCRIPTION_BUNDLE_NOT_CANCELLED: "SubscriptionBundle '{subscriptionBundleId}' is not cancelled.",
621
1347
  SUBSCRIPTION_BUNDLE_CANCELLATION_EFFECTIVE: "Cancellation already in effect \u2014 book the bundle again.",
@@ -624,9 +1350,25 @@ var ERROR_MESSAGES_EN = {
624
1350
  SUBSCRIPTION_BUNDLE_NOT_FOUND: "SubscriptionBundle '{subscriptionBundleId}' not found",
625
1351
  TENANT_NOT_FOUND: "Tenant {slug} not found",
626
1352
  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.",
627
- PLAN_NOT_IN_CATALOG: 'Plan "{planKey}" is not in the catalog ({projectKey})',
628
- PLAN_NOT_SELF_SERVICE: "{planKey} is not activated via self-service.",
1353
+ PLAN_NOT_IN_CATALOG: 'Plan "{planKey}" is not in the catalog',
1354
+ PLAN_NOT_SELF_SERVICE: "{planName} is only activated via a special contract. Please contact the contract manager.",
1355
+ PLAN_NOT_SOLD_IN_CYCLE: "{planName} has no price for this billing rhythm and cannot be booked in it.",
629
1356
  PLAN_CHANGE_BLOCKED: "Plan change during onboarding is blocked.",
1357
+ SUBSCRIPTION_CHANGED: "This subscription changed while the request was being decided. Reload it.",
1358
+ NO_SUBSCRIPTION: "This tenant has no subscription to cancel.",
1359
+ CANCELLATION_TERMS_CHANGED: "The effective date changed since it was shown. Confirm the new one.",
1360
+ SUBSCRIPTION_ENDED: "This subscription has ended. Its plan can no longer be changed.",
1361
+ PLAN_LOCKED: "Active {planName} special contract \u2014 please contact the contract manager to change plans.",
1362
+ QUOTA_OVER_TARGET: "Current usage {used} exceeds the target limit {targetMax} ({quotaKey}) in the {planName} plan. Please reduce usage first.",
1363
+ FEATURE_LOST: "Switching means losing access to one feature. Existing data is retained and never deleted \u2014 upgrading again unlocks it.",
1364
+ FEATURES_LOST: "Switching means losing access to {count} features. Existing data is retained and never deleted \u2014 upgrading again unlocks it.",
1365
+ NO_CHANGE: "Target plan and billing cycle already match the current state.",
1366
+ 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.",
1367
+ 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.",
1368
+ 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.",
1369
+ REDUNDANT_FEATURES: "The plan or another booked bundle already includes {count} of the features in this bundle \u2014 booking it pays for them twice.",
1370
+ MINIMUM_TERM_BINDS: "The minimum term extends beyond the end of the period \u2014 the cancellation only takes effect when the minimum term ends.",
1371
+ BUNDLE_FEATURE_DEPENDENCY_UNSATISFIED: "The bundle requires [{features}] \u2014 present neither in the plan nor in the active bundles.",
630
1372
  NO_PENDING_PLAN_VERSION: "There is no pending plan version awaiting confirmation.",
631
1373
  ONBOARDING_CREATE_FAILED: "The account could not be created. Please try again.",
632
1374
  BUNDLE_PREVIEW_ARGUMENT_AMBIGUOUS: "Exactly one of bundleVersionId (add preview) or subscriptionBundleId (cancel preview) must be given.",
@@ -654,18 +1396,37 @@ var ERROR_MESSAGES_EN = {
654
1396
  CHECKOUT_OFFER_BUNDLE_LINE_ITEMS_REQUIRED: "Every selected bundle version requires a frozen bundle line item.",
655
1397
  CHECKOUT_OFFER_BUNDLE_VERSION_NOT_BOOKABLE: "At least one bundle version from the checkout offer is no longer bookable.",
656
1398
  CHECKOUT_OFFER_FEATURE_DEPENDENCY_UNSATISFIED: "The selected plan does not cover all feature dependencies: [{missingRequires}] are missing from the plan + selected bundles.",
1399
+ CHECKOUT_OFFER_PLAN_NOT_OFFERED: "Plan '{planKey}' is not offered with a {billingCycle} price at the moment.",
1400
+ CHECKOUT_OFFER_BUNDLE_NOT_OFFERED: "Bundle version '{bundleVersionId}' cannot be added to this offer ({reason}).",
1401
+ CHECKOUT_OFFER_PROMO_CODE_NOT_ACCEPTED: "The promo code cannot be applied to this offer ({reason}).",
1402
+ CHECKOUT_OFFER_PRICE_NOT_CURRENT: "The prices of checkout offer '{offerId}' no longer match the catalogue; create a new offer.",
657
1403
  SUBSCRIPTION_CONTRACT_LINE_ITEMS_REQUIRED: "A subscription contract requires at least one line item.",
658
1404
  SUBSCRIPTION_CONTRACT_PLAN_LINE_ITEM_REQUIRED: "A subscription contract requires exactly one plan base item.",
659
1405
  SUBSCRIPTION_CONTRACT_INVALID_DATE: "{field} must be a valid date.",
660
1406
  SUBSCRIPTION_CONTRACT_INVALID_WINDOW: "effectiveUntil must be after effectiveFrom.",
1407
+ SUBSCRIPTION_CONTRACT_LINE_ITEM_TAX_MISMATCH: "A line item's taxAmount must be exactly priceGross minus priceNet.",
1408
+ 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.",
661
1409
  SUBSCRIPTION_CONTRACT_TERMINATION_BEFORE_START: "effectiveUntil must be after the effectiveFrom of the contract.",
1410
+ SUBSCRIPTION_CONTRACT_LINE_ITEM_CURRENCY_MISMATCH: "A line item must be booked in the currency its contract was priced in.",
662
1411
  CHECKOUT_OFFER_NOT_FOUND: "CheckoutOffer '{offerId}' not found",
663
1412
  CHECKOUT_OFFER_EXPIRED: "Checkout offer '{offerId}' has expired and cannot be {action}",
664
1413
  CHECKOUT_OFFER_ALREADY_CONSUMED: "Checkout offer '{offerId}' has already been consumed and cannot be {action}",
665
1414
  CHECKOUT_OFFER_NOT_CONSUMED: "CheckoutOffer '{offerId}' must be consumed before the contract is created",
1415
+ CHECKOUT_OFFER_CHANGED: "Checkout offer '{offerId}' changed while it was being concluded. Load it again.",
666
1416
  SUBSCRIPTION_CONTRACT_NOT_FOUND: "SubscriptionContract '{contractId}' not found",
667
1417
  NO_ACTIVE_SUBSCRIPTION_CONTRACT: "No active subscription contract for tenant {tenantId}",
668
1418
  SUBSCRIPTION_CONTRACT_ALREADY_CLOSED: "SubscriptionContract '{contractId}' is already closed",
1419
+ // ── subscriber ──
1420
+ SUBSCRIBER_REQUIRED: "Tenant '{tenantId}' has no subscriber. Nothing is agreed or charged without the party to it: create the tenant's subscriber first.",
1421
+ SUBSCRIBER_ALREADY_EXISTS: "Tenant '{tenantId}' already has a subscriber.",
1422
+ SUBSCRIBER_NOT_FOUND: "Subscriber '{subscriberId}' not found",
1423
+ SUBSCRIBER_LEGAL_NAME_REQUIRED: "A subscriber needs its legal name.",
1424
+ SUBSCRIBER_DETAIL_INVALID: "The subscriber's {field} is not valid.",
1425
+ SUBSCRIBER_IDENTITY_NOT_A_CONTACT: "{field} is part of the subscriber's legal identity and changes only as a correction, with a reason.",
1426
+ SUBSCRIBER_CORRECTION_REASON_REQUIRED: "A correction of the legal identity needs a reason.",
1427
+ SUBSCRIBER_CORRECTION_ACTOR_REQUIRED: "A correction of the legal identity has to say who makes it.",
1428
+ SUBSCRIBER_CORRECTION_CHANGES_NOTHING: "The correction changes nothing: every value it names is already recorded.",
1429
+ 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.",
669
1430
  // ── registration ──
670
1431
  PENDING_REGISTRATION_NOT_FOUND: "This registration could not be found. It may have already been completed or discarded.",
671
1432
  PENDING_REGISTRATION_EXPIRED: "This registration has expired. Please start again.",
@@ -681,8 +1442,15 @@ var ERROR_MESSAGES_EN = {
681
1442
  PLAN_NOT_AVAILABLE: "This plan is not available.",
682
1443
  PLAN_NOT_SELECTED: "Please select a plan first.",
683
1444
  MODEL_NOT_AVAILABLE: "This option is not available.",
1445
+ // ── payments ──
1446
+ PAYMENTS_NOT_CONFIGURED: "Payment methods cannot be set up here yet.",
1447
+ PAYMENT_GATEWAY_ACCOUNT_UNKNOWN: "No payment gateway account is configured under '{account}'.",
1448
+ PAYMENT_CALLBACK_REJECTED: "The payment callback could not be verified.",
1449
+ PAYMENT_RETURN_URL_NOT_ALLOWED: "The {field} leads to a site this installation does not return to.",
684
1450
  // ── entitlement (code lives in upsell.types.ts) ──
685
- [FEATURE_NOT_LICENSED]: "Feature {featureKeys} is not included in the current plan."
1451
+ [FEATURE_NOT_LICENSED]: "Feature {featureKeys} is not included in the current plan.",
1452
+ // ── settings ──
1453
+ SETTINGS_CHANGE_NOT_FOUND: "No recorded settings change has this id."
686
1454
  };
687
1455
  function formatErrorMessage(template, params = {}) {
688
1456
  return template.replace(/\{(\w+)\}/g, (match, name) => {
@@ -713,6 +1481,7 @@ var ERROR_MESSAGES_DE = {
713
1481
  NO_TENANT_ASSIGNED: "Kein Mandant zugeordnet",
714
1482
  TENANT_CONTEXT_MISSING: "Am Request wurde keine Mandanten-ID gefunden",
715
1483
  TENANT_ADMIN_REQUIRED: "Diese Aktion erfordert die Rolle TENANT_ADMIN.",
1484
+ BILLING_PERMISSION_REQUIRED: "Dieser Teil der Abrechnung erfordert die Abrechnungs-Berechtigung.",
716
1485
  SUPER_ADMIN_REQUIRED: "Nur die Rolle SUPER_ADMIN ist zugelassen",
717
1486
  MFA_NOT_SET_UP: "Richte MFA zuerst \xFCber die CLI ein.",
718
1487
  MFA_REQUIRED: "TOTP-Code im Header X-Mfa-Code erforderlich.",
@@ -744,6 +1513,8 @@ var ERROR_MESSAGES_DE = {
744
1513
  BUNDLE_VERSION_SUPERSEDED: "BundleVersion '{bundleVersionId}' wurde durch eine neuere Version abgel\xF6st.",
745
1514
  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).",
746
1515
  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.",
1516
+ BUNDLE_VERSION_NO_PRICE: "Diese Bundle-Version kann ohne Preis nicht ver\xF6ffentlicht werden: weder ein Grundpreis noch eine Plan-\xDCberschreibung ergibt einen.",
1517
+ 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.",
747
1518
  BUNDLE_VERSION_DISCARD_NOT_IMPLEMENTED: "Das Verwerfen ist im aktuellen Repository nicht implementiert. Implementiere BundleRepository.deleteDraft.",
748
1519
  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.",
749
1520
  BUNDLE_VERSION_VALID_FROM_INVALID: "validFrom '{validFrom}' ist kein g\xFCltiges Datum",
@@ -757,22 +1528,27 @@ var ERROR_MESSAGES_DE = {
757
1528
  PLAN_VERSION_NOT_FOUND: "PlanVersion '{versionId}' nicht gefunden",
758
1529
  BUNDLE_NOT_FOUND: "Bundle '{bundleId}' nicht gefunden",
759
1530
  BUNDLE_VERSION_NOT_FOUND: "BundleVersion '{bundleVersionId}' nicht gefunden",
760
- FEATURE_NOT_FOUND: "Feature '{featureKey}' im Projekt '{projectKey}' nicht gefunden",
761
- QUOTA_NOT_FOUND: "Quota '{quotaKey}' im Projekt '{projectKey}' nicht gefunden",
1531
+ FEATURE_NOT_FOUND: "Feature '{featureKey}' nicht gefunden",
1532
+ QUOTA_NOT_FOUND: "Quota '{quotaKey}' nicht gefunden",
762
1533
  PROMOTION_NOT_FOUND: "Promotion '{promotionId}' nicht gefunden",
763
1534
  MARKETING_PROJECTION_NOT_FOUND: "MarketingProjection '{projectionId}' nicht gefunden",
764
- PLAN_ALREADY_EXISTS: "Plan '{planKey}' gibt es im Projekt '{projectKey}' bereits",
765
- BUNDLE_ALREADY_EXISTS: "Bundle '{bundleKey}' gibt es im Projekt '{projectKey}' bereits",
1535
+ PLAN_ALREADY_EXISTS: "Plan '{planKey}' gibt es bereits",
1536
+ BUNDLE_ALREADY_EXISTS: "Bundle '{bundleKey}' gibt es bereits",
766
1537
  MARKETING_PROJECTION_ALREADY_EXISTS: "F\xFCr {targetType}/{targetVersionId}/{locale} gibt es bereits eine Marketing-Projektion \u2014 bearbeite sie per PATCH",
767
1538
  PLAN_DRAFT_ALREADY_EXISTS: "Plan '{planKey}' hat bereits die Entwurfsversion v{draftVersion}; ver\xF6ffentliche oder verwirf sie zuerst",
768
1539
  BUNDLE_DRAFT_ALREADY_EXISTS: "Bundle '{bundleKey}' hat bereits die Entwurfsversion v{draftVersion}; ver\xF6ffentliche oder verwirf sie zuerst",
769
1540
  QUOTA_NOT_IN_DISCOVERY_SNAPSHOT: "Quota '{quotaKey}' steht nicht im Discovery-Snapshot \u2014 eine Quota, die im Code nicht deklariert ist, l\xE4sst sich nicht freigeben",
770
1541
  DISCOVERY_STATUS_TRANSITION_INVALID: "Der \xDCbergang '{from}' \u2192 '{to}' ist nicht erlaubt",
771
1542
  DISCOVERY_NOT_INITIALIZED: "Die Freigabe braucht einen Discovery-Snapshot \u2014 Discovery ist nicht initialisiert (#25)",
1543
+ // ── catalogue import ──
1544
+ PLAN_CATALOG_UNREADABLE: "Diese Datei ist kein Plankatalog \u2014 sie lie\xDF sich nicht als einer lesen. Pr\xFCfe, ob es die YAML-Datei ist, in der deine App ihre Pl\xE4ne deklariert.",
1545
+ PLAN_CATALOG_INVALID: "Der Plankatalog wurde gelesen und dann abgelehnt: {message}",
772
1546
  // ── billing ──
773
1547
  BUNDLE_ALREADY_SUBSCRIBED: "Abonnement '{subscriptionId}' hat dieses Bundle bereits aktiv gebucht.",
774
1548
  BUNDLE_INCOMPATIBLE_WITH_PLAN: "BundleVersion '{bundleVersionId}' passt nicht zum Plan '{planKey}'. Erlaubt: [{allowedPlanKeys}].",
775
1549
  BUNDLE_NOT_SELF_SERVICE: "Bundle '{bundleKey}' wird nur \xFCber einen Sondervertrag freigeschaltet. Bitte wende dich an die Vertragsverwaltung.",
1550
+ 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.",
1551
+ 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.",
776
1552
  SUBSCRIPTION_BUNDLE_ALREADY_CANCELLED: "SubscriptionBundle '{subscriptionBundleId}' ist bereits gek\xFCndigt.",
777
1553
  SUBSCRIPTION_BUNDLE_NOT_CANCELLED: "SubscriptionBundle '{subscriptionBundleId}' ist nicht gek\xFCndigt.",
778
1554
  SUBSCRIPTION_BUNDLE_CANCELLATION_EFFECTIVE: "Die K\xFCndigung ist bereits wirksam \u2014 buche das Bundle einfach neu.",
@@ -781,9 +1557,25 @@ var ERROR_MESSAGES_DE = {
781
1557
  SUBSCRIPTION_BUNDLE_NOT_FOUND: "SubscriptionBundle '{subscriptionBundleId}' nicht gefunden",
782
1558
  TENANT_NOT_FOUND: "Mandant {slug} nicht gefunden",
783
1559
  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.",
784
- PLAN_NOT_IN_CATALOG: 'Plan "{planKey}" steht nicht im Katalog ({projectKey})',
785
- PLAN_NOT_SELF_SERVICE: "{planKey} wird nicht per Self-Service freigeschaltet.",
1560
+ PLAN_NOT_IN_CATALOG: 'Plan "{planKey}" steht nicht im Katalog',
1561
+ PLAN_NOT_SELF_SERVICE: "{planName} wird nur \xFCber einen Sondervertrag freigeschaltet. Bitte wenden Sie sich an die Vertragsverwaltung.",
1562
+ PLAN_NOT_SOLD_IN_CYCLE: "{planName} hat f\xFCr diesen Abrechnungsrhythmus keinen Preis und kann darin nicht gebucht werden.",
786
1563
  PLAN_CHANGE_BLOCKED: "W\xE4hrend des Onboardings ist ein Planwechsel gesperrt.",
1564
+ SUBSCRIPTION_CHANGED: "Dieses Abonnement hat sich ge\xE4ndert, w\xE4hrend die Anfrage entschieden wurde. Bitte lade es neu.",
1565
+ NO_SUBSCRIPTION: "Dieser Mandant hat kein Abonnement, das gek\xFCndigt werden kann.",
1566
+ CANCELLATION_TERMS_CHANGED: "Das Wirksamkeitsdatum hat sich seit der Anzeige ge\xE4ndert. Bitte best\xE4tige das neue Datum.",
1567
+ SUBSCRIPTION_ENDED: "Dieses Abonnement ist beendet. Sein Paket kann nicht mehr gewechselt werden.",
1568
+ PLAN_LOCKED: "Aktiver Sondervertrag {planName} \u2014 f\xFCr einen Paketwechsel wenden Sie sich bitte an die Vertragsverwaltung.",
1569
+ QUOTA_OVER_TARGET: "Aktuelle Nutzung {used} \xFCberschreitet das Ziel-Limit {targetMax} ({quotaKey}) im Paket {planName}. Bitte zuerst die Nutzung reduzieren.",
1570
+ FEATURE_LOST: "Beim Wechsel verlieren Sie den Zugriff auf eine Funktion. Vorhandene Daten bleiben erhalten und werden nie gel\xF6scht \u2014 ein sp\xE4teres Upgrade schaltet sie wieder frei.",
1571
+ FEATURES_LOST: "Beim Wechsel verlieren Sie den Zugriff auf {count} Funktionen. Vorhandene Daten bleiben erhalten und werden nie gel\xF6scht \u2014 ein sp\xE4teres Upgrade schaltet sie wieder frei.",
1572
+ NO_CHANGE: "Zielpaket und Abrechnungsrhythmus entsprechen bereits dem aktuellen Stand.",
1573
+ 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.",
1574
+ 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.",
1575
+ 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.",
1576
+ 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.",
1577
+ MINIMUM_TERM_BINDS: "Die Mindestlaufzeit reicht \xFCber das Ende der Periode hinaus \u2014 die K\xFCndigung wird erst zum Ende der Mindestlaufzeit wirksam.",
1578
+ BUNDLE_FEATURE_DEPENDENCY_UNSATISFIED: "Das Bundle setzt [{features}] voraus \u2014 weder im Plan noch in den aktiven Bundles vorhanden.",
787
1579
  NO_PENDING_PLAN_VERSION: "Es wartet keine Planversion auf eine Best\xE4tigung.",
788
1580
  ONBOARDING_CREATE_FAILED: "Das Konto konnte nicht angelegt werden. Bitte versuche es noch einmal.",
789
1581
  BUNDLE_PREVIEW_ARGUMENT_AMBIGUOUS: "Genau eines von bundleVersionId (Vorschau f\xFCrs Buchen) oder subscriptionBundleId (Vorschau f\xFCrs K\xFCndigen) muss angegeben sein.",
@@ -811,18 +1603,37 @@ var ERROR_MESSAGES_DE = {
811
1603
  CHECKOUT_OFFER_BUNDLE_LINE_ITEMS_REQUIRED: "Jede gew\xE4hlte Bundle-Version braucht eine eingefrorene Bundle-Position.",
812
1604
  CHECKOUT_OFFER_BUNDLE_VERSION_NOT_BOOKABLE: "Mindestens eine Bundle-Version aus dem Checkout-Angebot ist nicht mehr buchbar.",
813
1605
  CHECKOUT_OFFER_FEATURE_DEPENDENCY_UNSATISFIED: "Der gew\xE4hlte Plan deckt nicht alle Feature-Abh\xE4ngigkeiten ab: [{missingRequires}] fehlen in Plan und gew\xE4hlten Bundles.",
1606
+ CHECKOUT_OFFER_PLAN_NOT_OFFERED: "Plan '{planKey}' wird derzeit nicht mit einem Preis f\xFCr den Rhythmus {billingCycle} angeboten.",
1607
+ CHECKOUT_OFFER_BUNDLE_NOT_OFFERED: "Bundle-Version '{bundleVersionId}' kann diesem Angebot nicht hinzugef\xFCgt werden ({reason}).",
1608
+ CHECKOUT_OFFER_PROMO_CODE_NOT_ACCEPTED: "Der Rabattcode kann auf dieses Angebot nicht angewendet werden ({reason}).",
1609
+ CHECKOUT_OFFER_PRICE_NOT_CURRENT: "Die Preise des Angebots '{offerId}' stimmen nicht mehr mit dem Katalog \xFCberein; bitte ein neues Angebot erstellen.",
814
1610
  SUBSCRIPTION_CONTRACT_LINE_ITEMS_REQUIRED: "Ein Abo-Vertrag braucht mindestens eine Position.",
815
1611
  SUBSCRIPTION_CONTRACT_PLAN_LINE_ITEM_REQUIRED: "Ein Abo-Vertrag braucht genau eine Plan-Grundposition.",
816
1612
  SUBSCRIPTION_CONTRACT_INVALID_DATE: "{field} muss ein g\xFCltiges Datum sein.",
817
1613
  SUBSCRIPTION_CONTRACT_INVALID_WINDOW: "effectiveUntil muss nach effectiveFrom liegen.",
1614
+ SUBSCRIPTION_CONTRACT_LINE_ITEM_TAX_MISMATCH: "taxAmount einer Position muss exakt priceGross minus priceNet sein.",
1615
+ SUBSCRIPTION_CONTRACT_TAX_RATE_NOT_PERCENT: "Ein Abo-Vertrag nennt bei {field} einen Steuersatz von {taxRate}, der kein Prozentsatz ist: Ein Satz liegt zwischen 0 und 100, und ein Wert zwischen 0 und 1 wird als Bruch abgelehnt.",
1616
+ SUBSCRIPTION_CONTRACT_LINE_ITEM_CURRENCY_MISMATCH: "Eine Position muss in der W\xE4hrung gebucht sein, in der ihr Vertrag bepreist ist.",
818
1617
  SUBSCRIPTION_CONTRACT_TERMINATION_BEFORE_START: "effectiveUntil muss nach dem effectiveFrom des Vertrags liegen.",
819
1618
  CHECKOUT_OFFER_NOT_FOUND: "CheckoutOffer '{offerId}' nicht gefunden",
820
1619
  CHECKOUT_OFFER_EXPIRED: "Checkout-Angebot '{offerId}' ist abgelaufen \u2014 '{action}' ist nicht mehr m\xF6glich",
821
1620
  CHECKOUT_OFFER_ALREADY_CONSUMED: "Checkout-Angebot '{offerId}' wurde bereits eingel\xF6st \u2014 '{action}' ist nicht mehr m\xF6glich",
822
1621
  CHECKOUT_OFFER_NOT_CONSUMED: "CheckoutOffer '{offerId}' muss eingel\xF6st sein, bevor der Vertrag entsteht",
1622
+ CHECKOUT_OFFER_CHANGED: "Checkout-Angebot '{offerId}' hat sich w\xE4hrend des Abschlusses ge\xE4ndert. Bitte neu laden.",
823
1623
  SUBSCRIPTION_CONTRACT_NOT_FOUND: "SubscriptionContract '{contractId}' nicht gefunden",
824
1624
  NO_ACTIVE_SUBSCRIPTION_CONTRACT: "Kein aktiver Abo-Vertrag f\xFCr Mandant {tenantId}",
825
1625
  SUBSCRIPTION_CONTRACT_ALREADY_CLOSED: "SubscriptionContract '{contractId}' ist bereits geschlossen",
1626
+ // ── subscriber ──
1627
+ SUBSCRIBER_REQUIRED: "Mandant '{tenantId}' hat keinen Vertragspartner. Ohne ihn wird nichts vereinbart oder berechnet: Zuerst muss der Vertragspartner des Mandanten angelegt werden.",
1628
+ SUBSCRIBER_ALREADY_EXISTS: "Mandant '{tenantId}' hat bereits einen Vertragspartner.",
1629
+ SUBSCRIBER_NOT_FOUND: "Vertragspartner '{subscriberId}' nicht gefunden",
1630
+ SUBSCRIBER_LEGAL_NAME_REQUIRED: "Ein Vertragspartner braucht seinen rechtlichen Namen.",
1631
+ SUBSCRIBER_DETAIL_INVALID: "Das Feld {field} des Vertragspartners ist ung\xFCltig.",
1632
+ SUBSCRIBER_IDENTITY_NOT_A_CONTACT: "{field} geh\xF6rt zur rechtlichen Identit\xE4t des Vertragspartners und \xE4ndert sich nur als Korrektur mit Begr\xFCndung.",
1633
+ SUBSCRIBER_CORRECTION_REASON_REQUIRED: "Eine Korrektur der rechtlichen Identit\xE4t braucht eine Begr\xFCndung.",
1634
+ SUBSCRIBER_CORRECTION_ACTOR_REQUIRED: "Eine Korrektur der rechtlichen Identit\xE4t muss nennen, wer sie vornimmt.",
1635
+ SUBSCRIBER_CORRECTION_CHANGES_NOTHING: "Die Korrektur \xE4ndert nichts: Jeder genannte Wert ist bereits erfasst.",
1636
+ SUBSCRIBER_TAKEOVER_IS_A_TRANSFER: "\xDCbernimmt eine andere Rechtsperson, ist das eine \xDCbertragung und keine Korrektur; sie l\xE4sst sich nicht als \xC4nderung erfassen.",
826
1637
  // ── registration ──
827
1638
  PENDING_REGISTRATION_NOT_FOUND: "Diese Registrierung konnten wir nicht finden. Vielleicht ist sie bereits abgeschlossen oder verworfen.",
828
1639
  PENDING_REGISTRATION_EXPIRED: "Diese Registrierung ist abgelaufen. Bitte fange noch einmal von vorn an.",
@@ -838,51 +1649,100 @@ var ERROR_MESSAGES_DE = {
838
1649
  PLAN_NOT_AVAILABLE: "Dieser Plan steht nicht zur Verf\xFCgung.",
839
1650
  PLAN_NOT_SELECTED: "Bitte w\xE4hle zuerst einen Plan aus.",
840
1651
  MODEL_NOT_AVAILABLE: "Diese Option steht nicht zur Verf\xFCgung.",
1652
+ // ── payments ──
1653
+ PAYMENTS_NOT_CONFIGURED: "Zahlungsmethoden k\xF6nnen hier noch nicht hinterlegt werden.",
1654
+ PAYMENT_GATEWAY_ACCOUNT_UNKNOWN: "Unter '{account}' ist kein Konto eines Zahlungsanbieters eingerichtet.",
1655
+ PAYMENT_CALLBACK_REJECTED: "Die R\xFCckmeldung des Zahlungsanbieters lie\xDF sich nicht pr\xFCfen.",
1656
+ PAYMENT_RETURN_URL_NOT_ALLOWED: "Die {field} f\xFChrt auf eine Seite, zu der diese Installation nicht zur\xFCckleitet.",
841
1657
  // ── entitlement (code lives in upsell.types.ts) ──
842
- [FEATURE_NOT_LICENSED]: "Das Feature {featureKeys} ist im aktuellen Plan nicht enthalten."
1658
+ [FEATURE_NOT_LICENSED]: "Das Feature {featureKeys} ist im aktuellen Plan nicht enthalten.",
1659
+ // ── settings ──
1660
+ SETTINGS_CHANGE_NOT_FOUND: "Keine aufgezeichnete Einstellungs\xE4nderung hat diese ID."
843
1661
  };
844
1662
  export {
1663
+ ACTIVE_SUBSCRIPTION_CONTRACT_STATUSES,
845
1664
  AUTH_ERROR_CODES,
846
1665
  BILLING_ERROR_CODES,
1666
+ BUNDLE_PRICE_LOOKUP_LIMIT,
1667
+ CATALOGUE_KEYS,
847
1668
  CATALOG_ERROR_CODES,
848
1669
  CONTRACT_ERROR_CODES,
849
1670
  ERROR_MESSAGES_DE,
850
1671
  ERROR_MESSAGES_EN,
851
1672
  FEATURE_NOT_LICENSED,
1673
+ LEGAL_IDENTITY_FIELDS,
1674
+ MARKETING_PRIORITY_MAX,
1675
+ MARKETING_PRIORITY_MIN,
852
1676
  OTP_RATE_LIMIT_MAX_SENDS,
853
1677
  OTP_RATE_LIMIT_WINDOW_MINUTES,
854
1678
  OTP_TTL_MINUTES,
855
1679
  OTP_VERIFY_MAX_ATTEMPTS,
856
1680
  PASSWORD_RESET_TTL_MINUTES,
1681
+ PAYMENT_ERROR_CODES,
1682
+ PAYMENT_METHOD_TYPES,
857
1683
  PENDING_CHECKOUT_TTL_DAYS,
858
1684
  PENDING_EMAIL_TTL_HOURS,
859
1685
  PENDING_ONBOARDING_TTL_DAYS,
860
1686
  PLATFORM_ERROR_CODES,
861
1687
  PROMO_ERROR_CODES,
1688
+ PaymentCallbackRejectedError,
862
1689
  PersistenceCapabilityError,
863
1690
  PlatformUserExistsError,
864
1691
  REGISTRATION_ERROR_CODES,
865
1692
  REGISTRATION_RESUME_TTL_MINUTES,
866
1693
  REGISTRATION_STEP_BY_STATUS,
1694
+ SETTINGS_ERROR_CODES,
867
1695
  SETUP_ERROR_CODES,
1696
+ SUBSCRIBER_ERROR_CODES,
868
1697
  applyPromo,
869
1698
  assertPersistenceCapabilities,
870
1699
  buildActivePlanVersionWhere,
871
1700
  buildActiveVersionWhere,
872
1701
  buildFeatureRequiresIndex,
1702
+ bundleDraftDefaults,
1703
+ bundleStemDefaults,
1704
+ canonicalJson,
873
1705
  classifyBundleVersionDiff,
1706
+ classifyIssuerChange,
874
1707
  classifyPlanDiff,
875
1708
  collectUnsatisfiedRequires,
1709
+ contractPartiesOf,
876
1710
  coverageExcludingSelf,
1711
+ definedFields,
1712
+ diffSettings,
1713
+ formatCustomerNumber,
877
1714
  formatErrorMessage,
1715
+ identityCorrectionDelta,
878
1716
  isBundleRedundant,
1717
+ isPaymentCallbackRejectedError,
879
1718
  isPlatformUserExistsError,
880
1719
  isVersionEditable,
1720
+ issuerIdentityOf,
1721
+ keepOneRecommended,
881
1722
  missingRequiresFor,
1723
+ movedIdentityFields,
882
1724
  pickActivePromo,
1725
+ planCatalogSettingsOf,
1726
+ previousUtcDay,
883
1727
  promoStatus,
1728
+ readQuotaRecord,
1729
+ readQuotaValue,
1730
+ recordedIssuerIdentity,
884
1731
  resolveBundleAvailability,
885
1732
  resolveErrorMessage,
1733
+ sameLegalIdentity,
886
1734
  selectChargeableBundles,
887
- startOfUtcDay
1735
+ settingsSubtreeOf,
1736
+ startOfUtcDay,
1737
+ subscriberFromRegistration,
1738
+ subscriberPaymentMethodColumns,
1739
+ toBundleStemRow,
1740
+ toContractLineItemRecord,
1741
+ toPlanRow,
1742
+ toPlanVersionRow,
1743
+ toRunningContractIssuer,
1744
+ toSubscriberCorrectionRecord,
1745
+ toSubscriberPaymentMethodRecord,
1746
+ toSubscriberRecord,
1747
+ toSubscriptionContractRecord
888
1748
  };