@saasicat/adapter-prisma 1.0.0-rc.21 → 1.0.0-rc.23

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.cjs CHANGED
@@ -33,6 +33,7 @@ __export(index_exports, {
33
33
  PrismaAuditStatsAdapter: () => PrismaAuditStatsAdapter,
34
34
  PrismaBundleRepository: () => PrismaBundleRepository,
35
35
  PrismaCatalogEntryRepository: () => PrismaCatalogEntryRepository,
36
+ PrismaMaintenanceWindowRepository: () => PrismaMaintenanceWindowRepository,
36
37
  PrismaMarketingProjectionRepository: () => PrismaMarketingProjectionRepository,
37
38
  PrismaMarketingSettingsRepository: () => PrismaMarketingSettingsRepository,
38
39
  PrismaMfaAdapter: () => PrismaMfaAdapter,
@@ -47,6 +48,7 @@ __export(index_exports, {
47
48
  PrismaPromoCodeValidationLogRepository: () => PrismaPromoCodeValidationLogRepository,
48
49
  PrismaPromoSubscriptionLookup: () => PrismaPromoSubscriptionLookup,
49
50
  PrismaPromotionRepository: () => PrismaPromotionRepository,
51
+ PrismaSubscriberLedgerRepository: () => PrismaSubscriberLedgerRepository,
50
52
  PrismaSubscriberPaymentMethodRepository: () => PrismaSubscriberPaymentMethodRepository,
51
53
  PrismaSubscriberRepository: () => PrismaSubscriberRepository,
52
54
  PrismaSubscriptionBundleRepository: () => PrismaSubscriptionBundleRepository,
@@ -2047,8 +2049,10 @@ function toRow(row) {
2047
2049
  }
2048
2050
  __name(toRow, "toRow");
2049
2051
 
2050
- // src/prisma-marketing-settings.repository.ts
2052
+ // src/prisma-maintenance-window.repository.ts
2053
+ var import_node_crypto = require("crypto");
2051
2054
  var import_common9 = require("@nestjs/common");
2055
+ var import_core3 = require("@saasicat/core");
2052
2056
  function _ts_decorate9(decorators, target, key, desc) {
2053
2057
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2054
2058
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -2066,6 +2070,128 @@ function _ts_param8(paramIndex, decorator) {
2066
2070
  };
2067
2071
  }
2068
2072
  __name(_ts_param8, "_ts_param");
2073
+ var COLUMNS = {
2074
+ id: true,
2075
+ startsAt: true,
2076
+ endsAt: true,
2077
+ message: true,
2078
+ createdAt: true,
2079
+ createdBy: true,
2080
+ lockedAt: true,
2081
+ lockedBy: true,
2082
+ endedAt: true,
2083
+ endedBy: true
2084
+ };
2085
+ var PrismaMaintenanceWindowRepository = class {
2086
+ static {
2087
+ __name(this, "PrismaMaintenanceWindowRepository");
2088
+ }
2089
+ prisma;
2090
+ constructor(prisma) {
2091
+ this.prisma = prisma;
2092
+ }
2093
+ get db() {
2094
+ return this.prisma;
2095
+ }
2096
+ async findOpen() {
2097
+ const row = await this.db.maintenanceWindow.findFirst({
2098
+ where: {
2099
+ endedAt: null
2100
+ },
2101
+ select: COLUMNS
2102
+ });
2103
+ return row ? (0, import_core3.toMaintenanceWindowRecord)(row) : null;
2104
+ }
2105
+ async listRecent(limit) {
2106
+ const rows = await this.db.maintenanceWindow.findMany({
2107
+ select: COLUMNS,
2108
+ orderBy: [
2109
+ {
2110
+ createdAt: "desc"
2111
+ },
2112
+ {
2113
+ id: "desc"
2114
+ }
2115
+ ],
2116
+ take: limit
2117
+ });
2118
+ return rows.map(import_core3.toMaintenanceWindowRecord);
2119
+ }
2120
+ /**
2121
+ * One statement, `skipDuplicates` being `ON CONFLICT DO NOTHING`: the
2122
+ * partial unique index that holds an installation to one open window is
2123
+ * what refuses the second, and it refuses by returning no row rather than
2124
+ * by raising. The id is a uuid made here, so the primary key cannot be the
2125
+ * key it met.
2126
+ */
2127
+ async open(window) {
2128
+ const [row] = await this.db.maintenanceWindow.createManyAndReturn({
2129
+ data: [
2130
+ {
2131
+ id: (0, import_node_crypto.randomUUID)(),
2132
+ ...window,
2133
+ endedAt: null,
2134
+ endedBy: null
2135
+ }
2136
+ ],
2137
+ skipDuplicates: true
2138
+ });
2139
+ return row ? (0, import_core3.toMaintenanceWindowRecord)(row) : null;
2140
+ }
2141
+ /**
2142
+ * One guarded `UPDATE`: the stage the caller read is in the `WHERE`, so a
2143
+ * window another operator moved on a moment earlier leaves the count at
2144
+ * zero instead of being moved twice.
2145
+ */
2146
+ async update(id, stage, changes) {
2147
+ const { count } = await this.db.maintenanceWindow.updateMany({
2148
+ where: {
2149
+ id,
2150
+ endedAt: null,
2151
+ lockedAt: stage === "locked" ? {
2152
+ not: null
2153
+ } : null
2154
+ },
2155
+ data: changes
2156
+ });
2157
+ if (count !== 1) return null;
2158
+ const row = await this.db.maintenanceWindow.findUnique({
2159
+ where: {
2160
+ id
2161
+ },
2162
+ select: COLUMNS
2163
+ });
2164
+ return row ? (0, import_core3.toMaintenanceWindowRecord)(row) : null;
2165
+ }
2166
+ };
2167
+ PrismaMaintenanceWindowRepository = _ts_decorate9([
2168
+ (0, import_common9.Injectable)(),
2169
+ _ts_param8(0, (0, import_common9.Inject)(PRISMA_CLIENT_TOKEN)),
2170
+ _ts_metadata8("design:type", Function),
2171
+ _ts_metadata8("design:paramtypes", [
2172
+ Object
2173
+ ])
2174
+ ], PrismaMaintenanceWindowRepository);
2175
+
2176
+ // src/prisma-marketing-settings.repository.ts
2177
+ var import_common10 = require("@nestjs/common");
2178
+ function _ts_decorate10(decorators, target, key, desc) {
2179
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2180
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2181
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2182
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2183
+ }
2184
+ __name(_ts_decorate10, "_ts_decorate");
2185
+ function _ts_metadata9(k, v) {
2186
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2187
+ }
2188
+ __name(_ts_metadata9, "_ts_metadata");
2189
+ function _ts_param9(paramIndex, decorator) {
2190
+ return function(target, key) {
2191
+ decorator(target, key, paramIndex);
2192
+ };
2193
+ }
2194
+ __name(_ts_param9, "_ts_param");
2069
2195
  var SETTINGS_ROW_ID = "marketing-settings";
2070
2196
  var PrismaMarketingSettingsRepository = class {
2071
2197
  static {
@@ -2102,11 +2228,11 @@ var PrismaMarketingSettingsRepository = class {
2102
2228
  return toRow2(row);
2103
2229
  }
2104
2230
  };
2105
- PrismaMarketingSettingsRepository = _ts_decorate9([
2106
- (0, import_common9.Injectable)(),
2107
- _ts_param8(0, (0, import_common9.Inject)(PRISMA_CLIENT_TOKEN)),
2108
- _ts_metadata8("design:type", Function),
2109
- _ts_metadata8("design:paramtypes", [
2231
+ PrismaMarketingSettingsRepository = _ts_decorate10([
2232
+ (0, import_common10.Injectable)(),
2233
+ _ts_param9(0, (0, import_common10.Inject)(PRISMA_CLIENT_TOKEN)),
2234
+ _ts_metadata9("design:type", Function),
2235
+ _ts_metadata9("design:paramtypes", [
2110
2236
  typeof MarketingSettingsRepositoryClient === "undefined" ? Object : MarketingSettingsRepositoryClient
2111
2237
  ])
2112
2238
  ], PrismaMarketingSettingsRepository);
@@ -2119,24 +2245,24 @@ function toRow2(row) {
2119
2245
  __name(toRow2, "toRow");
2120
2246
 
2121
2247
  // src/prisma-mfa.adapter.ts
2122
- var import_common10 = require("@nestjs/common");
2123
- function _ts_decorate10(decorators, target, key, desc) {
2248
+ var import_common11 = require("@nestjs/common");
2249
+ function _ts_decorate11(decorators, target, key, desc) {
2124
2250
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2125
2251
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2126
2252
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2127
2253
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2128
2254
  }
2129
- __name(_ts_decorate10, "_ts_decorate");
2130
- function _ts_metadata9(k, v) {
2255
+ __name(_ts_decorate11, "_ts_decorate");
2256
+ function _ts_metadata10(k, v) {
2131
2257
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2132
2258
  }
2133
- __name(_ts_metadata9, "_ts_metadata");
2134
- function _ts_param9(paramIndex, decorator) {
2259
+ __name(_ts_metadata10, "_ts_metadata");
2260
+ function _ts_param10(paramIndex, decorator) {
2135
2261
  return function(target, key) {
2136
2262
  decorator(target, key, paramIndex);
2137
2263
  };
2138
2264
  }
2139
- __name(_ts_param9, "_ts_param");
2265
+ __name(_ts_param10, "_ts_param");
2140
2266
  var PrismaMfaAdapter = class {
2141
2267
  static {
2142
2268
  __name(this, "PrismaMfaAdapter");
@@ -2179,34 +2305,34 @@ var PrismaMfaAdapter = class {
2179
2305
  return !!row?.secret && !!row?.enabledAt;
2180
2306
  }
2181
2307
  };
2182
- PrismaMfaAdapter = _ts_decorate10([
2183
- (0, import_common10.Injectable)(),
2184
- _ts_param9(0, (0, import_common10.Inject)(PRISMA_CLIENT_TOKEN)),
2185
- _ts_metadata9("design:type", Function),
2186
- _ts_metadata9("design:paramtypes", [
2308
+ PrismaMfaAdapter = _ts_decorate11([
2309
+ (0, import_common11.Injectable)(),
2310
+ _ts_param10(0, (0, import_common11.Inject)(PRISMA_CLIENT_TOKEN)),
2311
+ _ts_metadata10("design:type", Function),
2312
+ _ts_metadata10("design:paramtypes", [
2187
2313
  typeof Pick === "undefined" ? Object : Pick
2188
2314
  ])
2189
2315
  ], PrismaMfaAdapter);
2190
2316
 
2191
2317
  // src/prisma-plan-catalog-import-sink.adapter.ts
2192
- var import_common11 = require("@nestjs/common");
2193
- function _ts_decorate11(decorators, target, key, desc) {
2318
+ var import_common12 = require("@nestjs/common");
2319
+ function _ts_decorate12(decorators, target, key, desc) {
2194
2320
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2195
2321
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2196
2322
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2197
2323
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2198
2324
  }
2199
- __name(_ts_decorate11, "_ts_decorate");
2200
- function _ts_metadata10(k, v) {
2325
+ __name(_ts_decorate12, "_ts_decorate");
2326
+ function _ts_metadata11(k, v) {
2201
2327
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2202
2328
  }
2203
- __name(_ts_metadata10, "_ts_metadata");
2204
- function _ts_param10(paramIndex, decorator) {
2329
+ __name(_ts_metadata11, "_ts_metadata");
2330
+ function _ts_param11(paramIndex, decorator) {
2205
2331
  return function(target, key) {
2206
2332
  decorator(target, key, paramIndex);
2207
2333
  };
2208
2334
  }
2209
- __name(_ts_param10, "_ts_param");
2335
+ __name(_ts_param11, "_ts_param");
2210
2336
  var PrismaPlanCatalogImportSink = class {
2211
2337
  static {
2212
2338
  __name(this, "PrismaPlanCatalogImportSink");
@@ -2323,38 +2449,38 @@ var PrismaPlanCatalogImportSink = class {
2323
2449
  };
2324
2450
  }
2325
2451
  };
2326
- PrismaPlanCatalogImportSink = _ts_decorate11([
2327
- (0, import_common11.Injectable)(),
2328
- _ts_param10(0, (0, import_common11.Inject)(PRISMA_CLIENT_TOKEN)),
2329
- _ts_param10(1, (0, import_common11.Optional)()),
2330
- _ts_param10(1, (0, import_common11.Inject)(PRISMA_SCHEMA_OPTIONS_TOKEN)),
2331
- _ts_metadata10("design:type", Function),
2332
- _ts_metadata10("design:paramtypes", [
2452
+ PrismaPlanCatalogImportSink = _ts_decorate12([
2453
+ (0, import_common12.Injectable)(),
2454
+ _ts_param11(0, (0, import_common12.Inject)(PRISMA_CLIENT_TOKEN)),
2455
+ _ts_param11(1, (0, import_common12.Optional)()),
2456
+ _ts_param11(1, (0, import_common12.Inject)(PRISMA_SCHEMA_OPTIONS_TOKEN)),
2457
+ _ts_metadata11("design:type", Function),
2458
+ _ts_metadata11("design:paramtypes", [
2333
2459
  typeof PlanCatalogImportClient === "undefined" ? Object : PlanCatalogImportClient,
2334
2460
  typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
2335
2461
  ])
2336
2462
  ], PrismaPlanCatalogImportSink);
2337
2463
 
2338
2464
  // src/prisma-plan-catalog-read-sink.adapter.ts
2339
- var import_common12 = require("@nestjs/common");
2340
- var import_core3 = require("@saasicat/core");
2341
- function _ts_decorate12(decorators, target, key, desc) {
2465
+ var import_common13 = require("@nestjs/common");
2466
+ var import_core4 = require("@saasicat/core");
2467
+ function _ts_decorate13(decorators, target, key, desc) {
2342
2468
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2343
2469
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2344
2470
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2345
2471
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2346
2472
  }
2347
- __name(_ts_decorate12, "_ts_decorate");
2348
- function _ts_metadata11(k, v) {
2473
+ __name(_ts_decorate13, "_ts_decorate");
2474
+ function _ts_metadata12(k, v) {
2349
2475
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2350
2476
  }
2351
- __name(_ts_metadata11, "_ts_metadata");
2352
- function _ts_param11(paramIndex, decorator) {
2477
+ __name(_ts_metadata12, "_ts_metadata");
2478
+ function _ts_param12(paramIndex, decorator) {
2353
2479
  return function(target, key) {
2354
2480
  decorator(target, key, paramIndex);
2355
2481
  };
2356
2482
  }
2357
- __name(_ts_param11, "_ts_param");
2483
+ __name(_ts_param12, "_ts_param");
2358
2484
  var PrismaPlanCatalogReadSink = class {
2359
2485
  static {
2360
2486
  __name(this, "PrismaPlanCatalogReadSink");
@@ -2428,13 +2554,13 @@ var PrismaPlanCatalogReadSink = class {
2428
2554
  ]
2429
2555
  });
2430
2556
  return {
2431
- plans: plans.map(import_core3.toPlanRow),
2557
+ plans: plans.map(import_core4.toPlanRow),
2432
2558
  livePlanVersions: livePlanVersions.map((row) => {
2433
2559
  const planKey = planKeysByStoredId.get(row.planId);
2434
2560
  if (!planKey) {
2435
2561
  throw new Error(`PlanVersion ${row.id} references a plan that does not exist: '${row.planId}'.`);
2436
2562
  }
2437
- return (0, import_core3.toPlanVersionRow)(row, planKey, this.fields);
2563
+ return (0, import_core4.toPlanVersionRow)(row, planKey, this.fields);
2438
2564
  }),
2439
2565
  featureEntries: featureEntries.map(toFeatureCatalogEntryRow)
2440
2566
  };
@@ -2443,13 +2569,13 @@ var PrismaPlanCatalogReadSink = class {
2443
2569
  return getPrismaDelegate(this.prisma, this.delegateName);
2444
2570
  }
2445
2571
  };
2446
- PrismaPlanCatalogReadSink = _ts_decorate12([
2447
- (0, import_common12.Injectable)(),
2448
- _ts_param11(0, (0, import_common12.Inject)(PRISMA_CLIENT_TOKEN)),
2449
- _ts_param11(1, (0, import_common12.Optional)()),
2450
- _ts_param11(1, (0, import_common12.Inject)(PRISMA_SCHEMA_OPTIONS_TOKEN)),
2451
- _ts_metadata11("design:type", Function),
2452
- _ts_metadata11("design:paramtypes", [
2572
+ PrismaPlanCatalogReadSink = _ts_decorate13([
2573
+ (0, import_common13.Injectable)(),
2574
+ _ts_param12(0, (0, import_common13.Inject)(PRISMA_CLIENT_TOKEN)),
2575
+ _ts_param12(1, (0, import_common13.Optional)()),
2576
+ _ts_param12(1, (0, import_common13.Inject)(PRISMA_SCHEMA_OPTIONS_TOKEN)),
2577
+ _ts_metadata12("design:type", Function),
2578
+ _ts_metadata12("design:paramtypes", [
2453
2579
  typeof PlanCatalogReadClient === "undefined" ? Object : PlanCatalogReadClient,
2454
2580
  typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
2455
2581
  ])
@@ -2483,26 +2609,26 @@ function toFeatureCatalogEntryRow(row) {
2483
2609
  __name(toFeatureCatalogEntryRow, "toFeatureCatalogEntryRow");
2484
2610
 
2485
2611
  // src/prisma-plan.repository.ts
2486
- var import_common13 = require("@nestjs/common");
2487
- var import_core4 = require("@saasicat/core");
2612
+ var import_common14 = require("@nestjs/common");
2488
2613
  var import_core5 = require("@saasicat/core");
2489
- function _ts_decorate13(decorators, target, key, desc) {
2614
+ var import_core6 = require("@saasicat/core");
2615
+ function _ts_decorate14(decorators, target, key, desc) {
2490
2616
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2491
2617
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2492
2618
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2493
2619
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2494
2620
  }
2495
- __name(_ts_decorate13, "_ts_decorate");
2496
- function _ts_metadata12(k, v) {
2621
+ __name(_ts_decorate14, "_ts_decorate");
2622
+ function _ts_metadata13(k, v) {
2497
2623
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2498
2624
  }
2499
- __name(_ts_metadata12, "_ts_metadata");
2500
- function _ts_param12(paramIndex, decorator) {
2625
+ __name(_ts_metadata13, "_ts_metadata");
2626
+ function _ts_param13(paramIndex, decorator) {
2501
2627
  return function(target, key) {
2502
2628
  decorator(target, key, paramIndex);
2503
2629
  };
2504
2630
  }
2505
- __name(_ts_param12, "_ts_param");
2631
+ __name(_ts_param13, "_ts_param");
2506
2632
  var PrismaPlanRepository = class {
2507
2633
  static {
2508
2634
  __name(this, "PrismaPlanRepository");
@@ -2627,7 +2753,7 @@ var PrismaPlanRepository = class {
2627
2753
  }
2628
2754
  ]
2629
2755
  });
2630
- return rows.map(import_core5.toPlanRow);
2756
+ return rows.map(import_core6.toPlanRow);
2631
2757
  }
2632
2758
  async findById(planId) {
2633
2759
  const row = await this.db().plan.findUnique({
@@ -2635,7 +2761,7 @@ var PrismaPlanRepository = class {
2635
2761
  id: planId
2636
2762
  }
2637
2763
  });
2638
- return row ? (0, import_core5.toPlanRow)(row) : null;
2764
+ return row ? (0, import_core6.toPlanRow)(row) : null;
2639
2765
  }
2640
2766
  /**
2641
2767
  * Whether this installation already uses this plan key — **including
@@ -2652,7 +2778,7 @@ var PrismaPlanRepository = class {
2652
2778
  planKey
2653
2779
  }
2654
2780
  });
2655
- return row ? (0, import_core5.toPlanRow)(row) : null;
2781
+ return row ? (0, import_core6.toPlanRow)(row) : null;
2656
2782
  }
2657
2783
  async create(data) {
2658
2784
  const created = await this.db().plan.create({
@@ -2664,21 +2790,21 @@ var PrismaPlanRepository = class {
2664
2790
  sortOrder: data.sortOrder ?? 0
2665
2791
  }
2666
2792
  });
2667
- return (0, import_core5.toPlanRow)(created);
2793
+ return (0, import_core6.toPlanRow)(created);
2668
2794
  }
2669
2795
  async update(planId, data) {
2670
2796
  const updated = await this.db().plan.update({
2671
2797
  where: {
2672
2798
  id: planId
2673
2799
  },
2674
- data: (0, import_core4.definedFields)(data, [
2800
+ data: (0, import_core5.definedFields)(data, [
2675
2801
  "label",
2676
2802
  "description",
2677
2803
  "icon",
2678
2804
  "sortOrder"
2679
2805
  ])
2680
2806
  });
2681
- return (0, import_core5.toPlanRow)(updated);
2807
+ return (0, import_core6.toPlanRow)(updated);
2682
2808
  }
2683
2809
  async softDelete(planId) {
2684
2810
  await this.db().plan.update({
@@ -2767,9 +2893,9 @@ var PrismaPlanRepository = class {
2767
2893
  const db = this.db(tx);
2768
2894
  const storedPlanId = await this.binding.findStoragePlanId(db, planKey);
2769
2895
  if (storedPlanId === null) return null;
2770
- const activeWhere = this.fields.endsAt ? (0, import_core4.buildActivePlanVersionWhere)(asOf, {
2896
+ const activeWhere = this.fields.endsAt ? (0, import_core5.buildActivePlanVersionWhere)(asOf, {
2771
2897
  withEndsAt: true
2772
- }) : (0, import_core4.buildActivePlanVersionWhere)(asOf);
2898
+ }) : (0, import_core5.buildActivePlanVersionWhere)(asOf);
2773
2899
  const row = await this.versions(db).findFirst({
2774
2900
  where: {
2775
2901
  planId: storedPlanId,
@@ -2888,7 +3014,7 @@ var PrismaPlanRepository = class {
2888
3014
  });
2889
3015
  const now = /* @__PURE__ */ new Date();
2890
3016
  if (previous) {
2891
- const predecessorValidUntil = (0, import_core5.previousUtcDay)(publishMeta.validFrom);
3017
+ const predecessorValidUntil = (0, import_core6.previousUtcDay)(publishMeta.validFrom);
2892
3018
  await planVersion.update({
2893
3019
  where: {
2894
3020
  id: previous.id
@@ -2953,40 +3079,40 @@ var PrismaPlanRepository = class {
2953
3079
  return this.toPlanVersionRow(updated, planKey);
2954
3080
  }
2955
3081
  toPlanVersionRow(row, planKey) {
2956
- return (0, import_core5.toPlanVersionRow)(row, planKey, this.fields);
3082
+ return (0, import_core6.toPlanVersionRow)(row, planKey, this.fields);
2957
3083
  }
2958
3084
  };
2959
- PrismaPlanRepository = _ts_decorate13([
2960
- (0, import_common13.Injectable)(),
2961
- _ts_param12(0, (0, import_common13.Inject)(PRISMA_CLIENT_TOKEN)),
2962
- _ts_param12(1, (0, import_common13.Optional)()),
2963
- _ts_param12(1, (0, import_common13.Inject)(PRISMA_SCHEMA_OPTIONS_TOKEN)),
2964
- _ts_metadata12("design:type", Function),
2965
- _ts_metadata12("design:paramtypes", [
3085
+ PrismaPlanRepository = _ts_decorate14([
3086
+ (0, import_common14.Injectable)(),
3087
+ _ts_param13(0, (0, import_common14.Inject)(PRISMA_CLIENT_TOKEN)),
3088
+ _ts_param13(1, (0, import_common14.Optional)()),
3089
+ _ts_param13(1, (0, import_common14.Inject)(PRISMA_SCHEMA_OPTIONS_TOKEN)),
3090
+ _ts_metadata13("design:type", Function),
3091
+ _ts_metadata13("design:paramtypes", [
2966
3092
  typeof PlanRepositoryClient === "undefined" ? Object : PlanRepositoryClient,
2967
3093
  typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
2968
3094
  ])
2969
3095
  ], PrismaPlanRepository);
2970
3096
 
2971
3097
  // src/prisma-payment-event-log.adapter.ts
2972
- var import_common14 = require("@nestjs/common");
2973
- function _ts_decorate14(decorators, target, key, desc) {
3098
+ var import_common15 = require("@nestjs/common");
3099
+ function _ts_decorate15(decorators, target, key, desc) {
2974
3100
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2975
3101
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2976
3102
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2977
3103
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2978
3104
  }
2979
- __name(_ts_decorate14, "_ts_decorate");
2980
- function _ts_metadata13(k, v) {
3105
+ __name(_ts_decorate15, "_ts_decorate");
3106
+ function _ts_metadata14(k, v) {
2981
3107
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2982
3108
  }
2983
- __name(_ts_metadata13, "_ts_metadata");
2984
- function _ts_param13(paramIndex, decorator) {
3109
+ __name(_ts_metadata14, "_ts_metadata");
3110
+ function _ts_param14(paramIndex, decorator) {
2985
3111
  return function(target, key) {
2986
3112
  decorator(target, key, paramIndex);
2987
3113
  };
2988
3114
  }
2989
- __name(_ts_param13, "_ts_param");
3115
+ __name(_ts_param14, "_ts_param");
2990
3116
  var PrismaPaymentEventLog = class {
2991
3117
  static {
2992
3118
  __name(this, "PrismaPaymentEventLog");
@@ -3025,35 +3151,35 @@ var PrismaPaymentEventLog = class {
3025
3151
  });
3026
3152
  }
3027
3153
  };
3028
- PrismaPaymentEventLog = _ts_decorate14([
3029
- (0, import_common14.Injectable)(),
3030
- _ts_param13(0, (0, import_common14.Inject)(PRISMA_CLIENT_TOKEN)),
3031
- _ts_metadata13("design:type", Function),
3032
- _ts_metadata13("design:paramtypes", [
3154
+ PrismaPaymentEventLog = _ts_decorate15([
3155
+ (0, import_common15.Injectable)(),
3156
+ _ts_param14(0, (0, import_common15.Inject)(PRISMA_CLIENT_TOKEN)),
3157
+ _ts_metadata14("design:type", Function),
3158
+ _ts_metadata14("design:paramtypes", [
3033
3159
  Object
3034
3160
  ])
3035
3161
  ], PrismaPaymentEventLog);
3036
3162
 
3037
3163
  // src/prisma-plan-version.repository.ts
3038
- var import_common15 = require("@nestjs/common");
3039
- var import_core6 = require("@saasicat/core");
3040
- function _ts_decorate15(decorators, target, key, desc) {
3164
+ var import_common16 = require("@nestjs/common");
3165
+ var import_core7 = require("@saasicat/core");
3166
+ function _ts_decorate16(decorators, target, key, desc) {
3041
3167
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3042
3168
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3043
3169
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3044
3170
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3045
3171
  }
3046
- __name(_ts_decorate15, "_ts_decorate");
3047
- function _ts_metadata14(k, v) {
3172
+ __name(_ts_decorate16, "_ts_decorate");
3173
+ function _ts_metadata15(k, v) {
3048
3174
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3049
3175
  }
3050
- __name(_ts_metadata14, "_ts_metadata");
3051
- function _ts_param14(paramIndex, decorator) {
3176
+ __name(_ts_metadata15, "_ts_metadata");
3177
+ function _ts_param15(paramIndex, decorator) {
3052
3178
  return function(target, key) {
3053
3179
  decorator(target, key, paramIndex);
3054
3180
  };
3055
3181
  }
3056
- __name(_ts_param14, "_ts_param");
3182
+ __name(_ts_param15, "_ts_param");
3057
3183
  var PrismaPlanVersionRepository = class {
3058
3184
  static {
3059
3185
  __name(this, "PrismaPlanVersionRepository");
@@ -3099,9 +3225,9 @@ var PrismaPlanVersionRepository = class {
3099
3225
  const db = this.db(tx);
3100
3226
  const storedPlanId = await this.binding.findStoragePlanId(db, planId);
3101
3227
  if (storedPlanId === null) return null;
3102
- const activeWhere = this.fields.endsAt ? (0, import_core6.buildActivePlanVersionWhere)(asOf, {
3228
+ const activeWhere = this.fields.endsAt ? (0, import_core7.buildActivePlanVersionWhere)(asOf, {
3103
3229
  withEndsAt: true
3104
- }) : (0, import_core6.buildActivePlanVersionWhere)(asOf);
3230
+ }) : (0, import_core7.buildActivePlanVersionWhere)(asOf);
3105
3231
  const row = await this.versions(db).findFirst({
3106
3232
  where: {
3107
3233
  planId: storedPlanId,
@@ -3133,37 +3259,37 @@ var PrismaPlanVersionRepository = class {
3133
3259
  };
3134
3260
  }
3135
3261
  };
3136
- PrismaPlanVersionRepository = _ts_decorate15([
3137
- (0, import_common15.Injectable)(),
3138
- _ts_param14(0, (0, import_common15.Inject)(PRISMA_CLIENT_TOKEN)),
3139
- _ts_param14(1, (0, import_common15.Optional)()),
3140
- _ts_param14(1, (0, import_common15.Inject)(PRISMA_SCHEMA_OPTIONS_TOKEN)),
3141
- _ts_metadata14("design:type", Function),
3142
- _ts_metadata14("design:paramtypes", [
3262
+ PrismaPlanVersionRepository = _ts_decorate16([
3263
+ (0, import_common16.Injectable)(),
3264
+ _ts_param15(0, (0, import_common16.Inject)(PRISMA_CLIENT_TOKEN)),
3265
+ _ts_param15(1, (0, import_common16.Optional)()),
3266
+ _ts_param15(1, (0, import_common16.Inject)(PRISMA_SCHEMA_OPTIONS_TOKEN)),
3267
+ _ts_metadata15("design:type", Function),
3268
+ _ts_metadata15("design:paramtypes", [
3143
3269
  typeof PlanVersionRepositoryClient === "undefined" ? Object : PlanVersionRepositoryClient,
3144
3270
  typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
3145
3271
  ])
3146
3272
  ], PrismaPlanVersionRepository);
3147
3273
 
3148
3274
  // src/prisma-promotion.repository.ts
3149
- var import_common16 = require("@nestjs/common");
3150
- function _ts_decorate16(decorators, target, key, desc) {
3275
+ var import_common17 = require("@nestjs/common");
3276
+ function _ts_decorate17(decorators, target, key, desc) {
3151
3277
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3152
3278
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3153
3279
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3154
3280
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3155
3281
  }
3156
- __name(_ts_decorate16, "_ts_decorate");
3157
- function _ts_metadata15(k, v) {
3282
+ __name(_ts_decorate17, "_ts_decorate");
3283
+ function _ts_metadata16(k, v) {
3158
3284
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3159
3285
  }
3160
- __name(_ts_metadata15, "_ts_metadata");
3161
- function _ts_param15(paramIndex, decorator) {
3286
+ __name(_ts_metadata16, "_ts_metadata");
3287
+ function _ts_param16(paramIndex, decorator) {
3162
3288
  return function(target, key) {
3163
3289
  decorator(target, key, paramIndex);
3164
3290
  };
3165
3291
  }
3166
- __name(_ts_param15, "_ts_param");
3292
+ __name(_ts_param16, "_ts_param");
3167
3293
  var PrismaPromotionRepository = class {
3168
3294
  static {
3169
3295
  __name(this, "PrismaPromotionRepository");
@@ -3283,11 +3409,11 @@ var PrismaPromotionRepository = class {
3283
3409
  });
3284
3410
  }
3285
3411
  };
3286
- PrismaPromotionRepository = _ts_decorate16([
3287
- (0, import_common16.Injectable)(),
3288
- _ts_param15(0, (0, import_common16.Inject)(PRISMA_CLIENT_TOKEN)),
3289
- _ts_metadata15("design:type", Function),
3290
- _ts_metadata15("design:paramtypes", [
3412
+ PrismaPromotionRepository = _ts_decorate17([
3413
+ (0, import_common17.Injectable)(),
3414
+ _ts_param16(0, (0, import_common17.Inject)(PRISMA_CLIENT_TOKEN)),
3415
+ _ts_metadata16("design:type", Function),
3416
+ _ts_metadata16("design:paramtypes", [
3291
3417
  typeof PromotionRepositoryClient === "undefined" ? Object : PromotionRepositoryClient
3292
3418
  ])
3293
3419
  ], PrismaPromotionRepository);
@@ -3338,25 +3464,25 @@ function toRow3(row) {
3338
3464
  __name(toRow3, "toRow");
3339
3465
 
3340
3466
  // src/prisma-promo-code-hold.repository.ts
3341
- var import_node_crypto = require("crypto");
3342
- var import_common17 = require("@nestjs/common");
3343
- function _ts_decorate17(decorators, target, key, desc) {
3467
+ var import_node_crypto2 = require("crypto");
3468
+ var import_common18 = require("@nestjs/common");
3469
+ function _ts_decorate18(decorators, target, key, desc) {
3344
3470
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3345
3471
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3346
3472
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3347
3473
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3348
3474
  }
3349
- __name(_ts_decorate17, "_ts_decorate");
3350
- function _ts_metadata16(k, v) {
3475
+ __name(_ts_decorate18, "_ts_decorate");
3476
+ function _ts_metadata17(k, v) {
3351
3477
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3352
3478
  }
3353
- __name(_ts_metadata16, "_ts_metadata");
3354
- function _ts_param16(paramIndex, decorator) {
3479
+ __name(_ts_metadata17, "_ts_metadata");
3480
+ function _ts_param17(paramIndex, decorator) {
3355
3481
  return function(target, key) {
3356
3482
  decorator(target, key, paramIndex);
3357
3483
  };
3358
3484
  }
3359
- __name(_ts_param16, "_ts_param");
3485
+ __name(_ts_param17, "_ts_param");
3360
3486
  var HOLD_COLUMNS = {
3361
3487
  id: true,
3362
3488
  promoCodeId: true,
@@ -3411,7 +3537,7 @@ var PrismaPromoCodeHoldRepository = class {
3411
3537
  };
3412
3538
  const created = await holdsOf(tx).create({
3413
3539
  data: {
3414
- id: (0, import_node_crypto.randomUUID)(),
3540
+ id: (0, import_node_crypto2.randomUUID)(),
3415
3541
  ...hold
3416
3542
  },
3417
3543
  select: HOLD_COLUMNS
@@ -3508,11 +3634,11 @@ var PrismaPromoCodeHoldRepository = class {
3508
3634
  return released === 1;
3509
3635
  }
3510
3636
  };
3511
- PrismaPromoCodeHoldRepository = _ts_decorate17([
3512
- (0, import_common17.Injectable)(),
3513
- _ts_param16(0, (0, import_common17.Inject)(PRISMA_CLIENT_TOKEN)),
3514
- _ts_metadata16("design:type", Function),
3515
- _ts_metadata16("design:paramtypes", [
3637
+ PrismaPromoCodeHoldRepository = _ts_decorate18([
3638
+ (0, import_common18.Injectable)(),
3639
+ _ts_param17(0, (0, import_common18.Inject)(PRISMA_CLIENT_TOKEN)),
3640
+ _ts_metadata17("design:type", Function),
3641
+ _ts_metadata17("design:paramtypes", [
3516
3642
  typeof PrismaLike === "undefined" ? Object : PrismaLike
3517
3643
  ])
3518
3644
  ], PrismaPromoCodeHoldRepository);
@@ -3522,24 +3648,24 @@ function holdsOf(client) {
3522
3648
  __name(holdsOf, "holdsOf");
3523
3649
 
3524
3650
  // src/prisma-promo-code-redemption.repository.ts
3525
- var import_common18 = require("@nestjs/common");
3526
- function _ts_decorate18(decorators, target, key, desc) {
3651
+ var import_common19 = require("@nestjs/common");
3652
+ function _ts_decorate19(decorators, target, key, desc) {
3527
3653
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3528
3654
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3529
3655
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3530
3656
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3531
3657
  }
3532
- __name(_ts_decorate18, "_ts_decorate");
3533
- function _ts_metadata17(k, v) {
3658
+ __name(_ts_decorate19, "_ts_decorate");
3659
+ function _ts_metadata18(k, v) {
3534
3660
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3535
3661
  }
3536
- __name(_ts_metadata17, "_ts_metadata");
3537
- function _ts_param17(paramIndex, decorator) {
3662
+ __name(_ts_metadata18, "_ts_metadata");
3663
+ function _ts_param18(paramIndex, decorator) {
3538
3664
  return function(target, key) {
3539
3665
  decorator(target, key, paramIndex);
3540
3666
  };
3541
3667
  }
3542
- __name(_ts_param17, "_ts_param");
3668
+ __name(_ts_param18, "_ts_param");
3543
3669
  var PrismaPromoCodeRedemptionRepository = class {
3544
3670
  static {
3545
3671
  __name(this, "PrismaPromoCodeRedemptionRepository");
@@ -3621,11 +3747,11 @@ var PrismaPromoCodeRedemptionRepository = class {
3621
3747
  return result.count;
3622
3748
  }
3623
3749
  };
3624
- PrismaPromoCodeRedemptionRepository = _ts_decorate18([
3625
- (0, import_common18.Injectable)(),
3626
- _ts_param17(0, (0, import_common18.Inject)(PRISMA_CLIENT_TOKEN)),
3627
- _ts_metadata17("design:type", Function),
3628
- _ts_metadata17("design:paramtypes", [
3750
+ PrismaPromoCodeRedemptionRepository = _ts_decorate19([
3751
+ (0, import_common19.Injectable)(),
3752
+ _ts_param18(0, (0, import_common19.Inject)(PRISMA_CLIENT_TOKEN)),
3753
+ _ts_metadata18("design:type", Function),
3754
+ _ts_metadata18("design:paramtypes", [
3629
3755
  typeof PrismaLike === "undefined" ? Object : PrismaLike
3630
3756
  ])
3631
3757
  ], PrismaPromoCodeRedemptionRepository);
@@ -3649,24 +3775,24 @@ function toRecord(row) {
3649
3775
  __name(toRecord, "toRecord");
3650
3776
 
3651
3777
  // src/prisma-promo-code.repository.ts
3652
- var import_common19 = require("@nestjs/common");
3653
- function _ts_decorate19(decorators, target, key, desc) {
3778
+ var import_common20 = require("@nestjs/common");
3779
+ function _ts_decorate20(decorators, target, key, desc) {
3654
3780
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3655
3781
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3656
3782
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3657
3783
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3658
3784
  }
3659
- __name(_ts_decorate19, "_ts_decorate");
3660
- function _ts_metadata18(k, v) {
3785
+ __name(_ts_decorate20, "_ts_decorate");
3786
+ function _ts_metadata19(k, v) {
3661
3787
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3662
3788
  }
3663
- __name(_ts_metadata18, "_ts_metadata");
3664
- function _ts_param18(paramIndex, decorator) {
3789
+ __name(_ts_metadata19, "_ts_metadata");
3790
+ function _ts_param19(paramIndex, decorator) {
3665
3791
  return function(target, key) {
3666
3792
  decorator(target, key, paramIndex);
3667
3793
  };
3668
3794
  }
3669
- __name(_ts_param18, "_ts_param");
3795
+ __name(_ts_param19, "_ts_param");
3670
3796
  var PrismaPromoCodeRepository = class {
3671
3797
  static {
3672
3798
  __name(this, "PrismaPromoCodeRepository");
@@ -3820,11 +3946,11 @@ var PrismaPromoCodeRepository = class {
3820
3946
  return result.count;
3821
3947
  }
3822
3948
  };
3823
- PrismaPromoCodeRepository = _ts_decorate19([
3824
- (0, import_common19.Injectable)(),
3825
- _ts_param18(0, (0, import_common19.Inject)(PRISMA_CLIENT_TOKEN)),
3826
- _ts_metadata18("design:type", Function),
3827
- _ts_metadata18("design:paramtypes", [
3949
+ PrismaPromoCodeRepository = _ts_decorate20([
3950
+ (0, import_common20.Injectable)(),
3951
+ _ts_param19(0, (0, import_common20.Inject)(PRISMA_CLIENT_TOKEN)),
3952
+ _ts_metadata19("design:type", Function),
3953
+ _ts_metadata19("design:paramtypes", [
3828
3954
  typeof PrismaLike === "undefined" ? Object : PrismaLike
3829
3955
  ])
3830
3956
  ], PrismaPromoCodeRepository);
@@ -3863,24 +3989,24 @@ function toRecord2(row) {
3863
3989
  __name(toRecord2, "toRecord");
3864
3990
 
3865
3991
  // src/prisma-promo-code-validation-log.repository.ts
3866
- var import_common20 = require("@nestjs/common");
3867
- function _ts_decorate20(decorators, target, key, desc) {
3992
+ var import_common21 = require("@nestjs/common");
3993
+ function _ts_decorate21(decorators, target, key, desc) {
3868
3994
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3869
3995
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3870
3996
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3871
3997
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3872
3998
  }
3873
- __name(_ts_decorate20, "_ts_decorate");
3874
- function _ts_metadata19(k, v) {
3999
+ __name(_ts_decorate21, "_ts_decorate");
4000
+ function _ts_metadata20(k, v) {
3875
4001
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3876
4002
  }
3877
- __name(_ts_metadata19, "_ts_metadata");
3878
- function _ts_param19(paramIndex, decorator) {
4003
+ __name(_ts_metadata20, "_ts_metadata");
4004
+ function _ts_param20(paramIndex, decorator) {
3879
4005
  return function(target, key) {
3880
4006
  decorator(target, key, paramIndex);
3881
4007
  };
3882
4008
  }
3883
- __name(_ts_param19, "_ts_param");
4009
+ __name(_ts_param20, "_ts_param");
3884
4010
  var PrismaPromoCodeValidationLogRepository = class {
3885
4011
  static {
3886
4012
  __name(this, "PrismaPromoCodeValidationLogRepository");
@@ -3909,34 +4035,34 @@ var PrismaPromoCodeValidationLogRepository = class {
3909
4035
  });
3910
4036
  }
3911
4037
  };
3912
- PrismaPromoCodeValidationLogRepository = _ts_decorate20([
3913
- (0, import_common20.Injectable)(),
3914
- _ts_param19(0, (0, import_common20.Inject)(PRISMA_CLIENT_TOKEN)),
3915
- _ts_metadata19("design:type", Function),
3916
- _ts_metadata19("design:paramtypes", [
4038
+ PrismaPromoCodeValidationLogRepository = _ts_decorate21([
4039
+ (0, import_common21.Injectable)(),
4040
+ _ts_param20(0, (0, import_common21.Inject)(PRISMA_CLIENT_TOKEN)),
4041
+ _ts_metadata20("design:type", Function),
4042
+ _ts_metadata20("design:paramtypes", [
3917
4043
  typeof PrismaLike === "undefined" ? Object : PrismaLike
3918
4044
  ])
3919
4045
  ], PrismaPromoCodeValidationLogRepository);
3920
4046
 
3921
4047
  // src/prisma-promo-subscription-lookup.adapter.ts
3922
- var import_common21 = require("@nestjs/common");
3923
- function _ts_decorate21(decorators, target, key, desc) {
4048
+ var import_common22 = require("@nestjs/common");
4049
+ function _ts_decorate22(decorators, target, key, desc) {
3924
4050
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3925
4051
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3926
4052
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3927
4053
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3928
4054
  }
3929
- __name(_ts_decorate21, "_ts_decorate");
3930
- function _ts_metadata20(k, v) {
4055
+ __name(_ts_decorate22, "_ts_decorate");
4056
+ function _ts_metadata21(k, v) {
3931
4057
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3932
4058
  }
3933
- __name(_ts_metadata20, "_ts_metadata");
3934
- function _ts_param20(paramIndex, decorator) {
4059
+ __name(_ts_metadata21, "_ts_metadata");
4060
+ function _ts_param21(paramIndex, decorator) {
3935
4061
  return function(target, key) {
3936
4062
  decorator(target, key, paramIndex);
3937
4063
  };
3938
4064
  }
3939
- __name(_ts_param20, "_ts_param");
4065
+ __name(_ts_param21, "_ts_param");
3940
4066
  var PrismaPromoSubscriptionLookup = class {
3941
4067
  static {
3942
4068
  __name(this, "PrismaPromoSubscriptionLookup");
@@ -3962,34 +4088,35 @@ var PrismaPromoSubscriptionLookup = class {
3962
4088
  };
3963
4089
  }
3964
4090
  };
3965
- PrismaPromoSubscriptionLookup = _ts_decorate21([
3966
- (0, import_common21.Injectable)(),
3967
- _ts_param20(0, (0, import_common21.Inject)(PRISMA_CLIENT_TOKEN)),
3968
- _ts_metadata20("design:type", Function),
3969
- _ts_metadata20("design:paramtypes", [
4091
+ PrismaPromoSubscriptionLookup = _ts_decorate22([
4092
+ (0, import_common22.Injectable)(),
4093
+ _ts_param21(0, (0, import_common22.Inject)(PRISMA_CLIENT_TOKEN)),
4094
+ _ts_metadata21("design:type", Function),
4095
+ _ts_metadata21("design:paramtypes", [
3970
4096
  typeof PrismaLike === "undefined" ? Object : PrismaLike
3971
4097
  ])
3972
4098
  ], PrismaPromoSubscriptionLookup);
3973
4099
 
3974
4100
  // src/prisma-subscription-bundle.repository.ts
3975
- var import_common22 = require("@nestjs/common");
3976
- function _ts_decorate22(decorators, target, key, desc) {
4101
+ var import_common23 = require("@nestjs/common");
4102
+ var import_core8 = require("@saasicat/core");
4103
+ function _ts_decorate23(decorators, target, key, desc) {
3977
4104
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3978
4105
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3979
4106
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3980
4107
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3981
4108
  }
3982
- __name(_ts_decorate22, "_ts_decorate");
3983
- function _ts_metadata21(k, v) {
4109
+ __name(_ts_decorate23, "_ts_decorate");
4110
+ function _ts_metadata22(k, v) {
3984
4111
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3985
4112
  }
3986
- __name(_ts_metadata21, "_ts_metadata");
3987
- function _ts_param21(paramIndex, decorator) {
4113
+ __name(_ts_metadata22, "_ts_metadata");
4114
+ function _ts_param22(paramIndex, decorator) {
3988
4115
  return function(target, key) {
3989
4116
  decorator(target, key, paramIndex);
3990
4117
  };
3991
4118
  }
3992
- __name(_ts_param21, "_ts_param");
4119
+ __name(_ts_param22, "_ts_param");
3993
4120
  var PrismaSubscriptionBundleRepository = class {
3994
4121
  static {
3995
4122
  __name(this, "PrismaSubscriptionBundleRepository");
@@ -4010,7 +4137,7 @@ var PrismaSubscriptionBundleRepository = class {
4010
4137
  startedAt: "desc"
4011
4138
  }
4012
4139
  });
4013
- return rows.map(toRecord3);
4140
+ return rows.map(import_core8.toSubscriptionBundleRecord);
4014
4141
  }
4015
4142
  async findById(subscriptionBundleId) {
4016
4143
  const row = await this.db().subscriptionBundle.findUnique({
@@ -4018,7 +4145,7 @@ var PrismaSubscriptionBundleRepository = class {
4018
4145
  id: subscriptionBundleId
4019
4146
  }
4020
4147
  });
4021
- return row ? toRecord3(row) : null;
4148
+ return row ? (0, import_core8.toSubscriptionBundleRecord)(row) : null;
4022
4149
  }
4023
4150
  async listActiveBySubscription(subscriptionId, asOf = /* @__PURE__ */ new Date(), tx) {
4024
4151
  const rows = await this.db(tx).subscriptionBundle.findMany({
@@ -4039,7 +4166,7 @@ var PrismaSubscriptionBundleRepository = class {
4039
4166
  startedAt: "desc"
4040
4167
  }
4041
4168
  });
4042
- return rows.map(toRecord3);
4169
+ return rows.map(import_core8.toSubscriptionBundleRecord);
4043
4170
  }
4044
4171
  async add(data) {
4045
4172
  const row = await this.db().subscriptionBundle.create({
@@ -4053,7 +4180,7 @@ var PrismaSubscriptionBundleRepository = class {
4053
4180
  currentPeriodEnd: data.currentPeriodEnd ?? null
4054
4181
  }
4055
4182
  });
4056
- return toRecord3(row);
4183
+ return (0, import_core8.toSubscriptionBundleRecord)(row);
4057
4184
  }
4058
4185
  async cancel(subscriptionBundleId, data) {
4059
4186
  const { count } = await this.db().subscriptionBundle.updateMany({
@@ -4075,7 +4202,7 @@ var PrismaSubscriptionBundleRepository = class {
4075
4202
  }
4076
4203
  });
4077
4204
  if (!row) throw new Error(`SubscriptionBundle '${subscriptionBundleId}' disappeared`);
4078
- return toRecord3(row);
4205
+ return (0, import_core8.toSubscriptionBundleRecord)(row);
4079
4206
  }
4080
4207
  async reactivate(subscriptionBundleId) {
4081
4208
  const row = await this.db().subscriptionBundle.update({
@@ -4087,7 +4214,7 @@ var PrismaSubscriptionBundleRepository = class {
4087
4214
  canceledEffectiveAt: null
4088
4215
  }
4089
4216
  });
4090
- return toRecord3(row);
4217
+ return (0, import_core8.toSubscriptionBundleRecord)(row);
4091
4218
  }
4092
4219
  async countActiveByBundleVersionId(bundleVersionId, asOf = /* @__PURE__ */ new Date()) {
4093
4220
  return this.db().subscriptionBundle.count({
@@ -4107,52 +4234,35 @@ var PrismaSubscriptionBundleRepository = class {
4107
4234
  });
4108
4235
  }
4109
4236
  };
4110
- PrismaSubscriptionBundleRepository = _ts_decorate22([
4111
- (0, import_common22.Injectable)(),
4112
- _ts_param21(0, (0, import_common22.Inject)(PRISMA_CLIENT_TOKEN)),
4113
- _ts_metadata21("design:type", Function),
4114
- _ts_metadata21("design:paramtypes", [
4237
+ PrismaSubscriptionBundleRepository = _ts_decorate23([
4238
+ (0, import_common23.Injectable)(),
4239
+ _ts_param22(0, (0, import_common23.Inject)(PRISMA_CLIENT_TOKEN)),
4240
+ _ts_metadata22("design:type", Function),
4241
+ _ts_metadata22("design:paramtypes", [
4115
4242
  typeof SubscriptionBundleClient === "undefined" ? Object : SubscriptionBundleClient
4116
4243
  ])
4117
4244
  ], PrismaSubscriptionBundleRepository);
4118
- function toRecord3(row) {
4119
- return {
4120
- id: row.id,
4121
- subscriptionId: row.subscriptionId,
4122
- bundleVersionId: row.bundleVersionId,
4123
- startedAt: row.startedAt,
4124
- minimumTermEndsAt: row.minimumTermEndsAt,
4125
- billingCycle: row.billingCycle ?? null,
4126
- currentPeriodStart: row.currentPeriodStart ?? null,
4127
- currentPeriodEnd: row.currentPeriodEnd ?? null,
4128
- canceledAt: row.canceledAt,
4129
- canceledEffectiveAt: row.canceledEffectiveAt,
4130
- createdAt: row.createdAt,
4131
- updatedAt: row.updatedAt
4132
- };
4133
- }
4134
- __name(toRecord3, "toRecord");
4135
4245
 
4136
4246
  // src/prisma-subscription-contract.repository.ts
4137
- var import_common23 = require("@nestjs/common");
4138
- var import_core7 = require("@saasicat/core");
4139
- function _ts_decorate23(decorators, target, key, desc) {
4247
+ var import_common24 = require("@nestjs/common");
4248
+ var import_core9 = require("@saasicat/core");
4249
+ function _ts_decorate24(decorators, target, key, desc) {
4140
4250
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4141
4251
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4142
4252
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4143
4253
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4144
4254
  }
4145
- __name(_ts_decorate23, "_ts_decorate");
4146
- function _ts_metadata22(k, v) {
4255
+ __name(_ts_decorate24, "_ts_decorate");
4256
+ function _ts_metadata23(k, v) {
4147
4257
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4148
4258
  }
4149
- __name(_ts_metadata22, "_ts_metadata");
4150
- function _ts_param22(paramIndex, decorator) {
4259
+ __name(_ts_metadata23, "_ts_metadata");
4260
+ function _ts_param23(paramIndex, decorator) {
4151
4261
  return function(target, key) {
4152
4262
  decorator(target, key, paramIndex);
4153
4263
  };
4154
4264
  }
4155
- __name(_ts_param22, "_ts_param");
4265
+ __name(_ts_param23, "_ts_param");
4156
4266
  var PrismaSubscriptionContractRepository = class {
4157
4267
  static {
4158
4268
  __name(this, "PrismaSubscriptionContractRepository");
@@ -4201,7 +4311,7 @@ var PrismaSubscriptionContractRepository = class {
4201
4311
  }
4202
4312
  ]
4203
4313
  });
4204
- return rows.map((row) => (0, import_core7.toSubscriptionContractRecord)(row, row.lineItems));
4314
+ return rows.map((row) => (0, import_core9.toSubscriptionContractRecord)(row, row.lineItems));
4205
4315
  }
4206
4316
  async findById(contractId) {
4207
4317
  const row = await this.db().subscriptionContract.findUnique({
@@ -4212,7 +4322,7 @@ var PrismaSubscriptionContractRepository = class {
4212
4322
  lineItems: true
4213
4323
  }
4214
4324
  });
4215
- return row ? (0, import_core7.toSubscriptionContractRecord)(row, row.lineItems) : null;
4325
+ return row ? (0, import_core9.toSubscriptionContractRecord)(row, row.lineItems) : null;
4216
4326
  }
4217
4327
  async findActiveByTenantId(tenantId, asOf = /* @__PURE__ */ new Date(), tx) {
4218
4328
  const row = await this.db(tx).subscriptionContract.findFirst({
@@ -4220,7 +4330,7 @@ var PrismaSubscriptionContractRepository = class {
4220
4330
  tenantId,
4221
4331
  status: {
4222
4332
  in: [
4223
- ...import_core7.ACTIVE_SUBSCRIPTION_CONTRACT_STATUSES
4333
+ ...import_core9.ACTIVE_SUBSCRIPTION_CONTRACT_STATUSES
4224
4334
  ]
4225
4335
  },
4226
4336
  effectiveFrom: {
@@ -4249,7 +4359,7 @@ var PrismaSubscriptionContractRepository = class {
4249
4359
  }
4250
4360
  ]
4251
4361
  });
4252
- return row ? (0, import_core7.toSubscriptionContractRecord)(row, row.lineItems) : null;
4362
+ return row ? (0, import_core9.toSubscriptionContractRecord)(row, row.lineItems) : null;
4253
4363
  }
4254
4364
  async findByOriginalOfferId(offerId, tx) {
4255
4365
  const row = await this.db(tx).subscriptionContract.findFirst({
@@ -4268,7 +4378,7 @@ var PrismaSubscriptionContractRepository = class {
4268
4378
  }
4269
4379
  ]
4270
4380
  });
4271
- return row ? (0, import_core7.toSubscriptionContractRecord)(row, row.lineItems) : null;
4381
+ return row ? (0, import_core9.toSubscriptionContractRecord)(row, row.lineItems) : null;
4272
4382
  }
4273
4383
  async create(data, tx) {
4274
4384
  const row = await this.db(tx).subscriptionContract.create({
@@ -4276,6 +4386,7 @@ var PrismaSubscriptionContractRepository = class {
4276
4386
  tenantId: data.tenantId,
4277
4387
  subscriberId: data.parties.subscriberId,
4278
4388
  subscriberSnapshot: data.parties.subscriber,
4389
+ partiesMigrated: data.partiesMigrated ?? false,
4279
4390
  status: data.status ?? "active",
4280
4391
  effectiveFrom: data.effectiveFrom,
4281
4392
  effectiveUntil: data.effectiveUntil ?? null,
@@ -4304,13 +4415,13 @@ var PrismaSubscriptionContractRepository = class {
4304
4415
  lineItems: true
4305
4416
  }
4306
4417
  });
4307
- return (0, import_core7.toSubscriptionContractRecord)(row, row.lineItems);
4418
+ return (0, import_core9.toSubscriptionContractRecord)(row, row.lineItems);
4308
4419
  }
4309
4420
  async listRunningIssuers(limit, asOf = /* @__PURE__ */ new Date()) {
4310
4421
  const where = {
4311
4422
  status: {
4312
4423
  in: [
4313
- ...import_core7.ACTIVE_SUBSCRIPTION_CONTRACT_STATUSES
4424
+ ...import_core9.ACTIVE_SUBSCRIPTION_CONTRACT_STATUSES
4314
4425
  ]
4315
4426
  },
4316
4427
  OR: [
@@ -4357,7 +4468,7 @@ var PrismaSubscriptionContractRepository = class {
4357
4468
  ]);
4358
4469
  return {
4359
4470
  total,
4360
- contracts: rows.map(import_core7.toRunningContractIssuer)
4471
+ contracts: rows.map(import_core9.toRunningContractIssuer)
4361
4472
  };
4362
4473
  }
4363
4474
  async terminate(contractId, data) {
@@ -4378,14 +4489,42 @@ var PrismaSubscriptionContractRepository = class {
4378
4489
  lineItems: true
4379
4490
  }
4380
4491
  });
4381
- return (0, import_core7.toSubscriptionContractRecord)(row, row.lineItems);
4492
+ return (0, import_core9.toSubscriptionContractRecord)(row, row.lineItems);
4493
+ }
4494
+ async supersede(contractId, data, tx) {
4495
+ const db = this.db(tx);
4496
+ const { count } = await db.subscriptionContract.updateMany({
4497
+ where: {
4498
+ id: contractId,
4499
+ status: {
4500
+ in: [
4501
+ ...import_core9.ACTIVE_SUBSCRIPTION_CONTRACT_STATUSES
4502
+ ]
4503
+ },
4504
+ effectiveUntil: data.readEffectiveUntil
4505
+ },
4506
+ data: {
4507
+ effectiveUntil: data.at,
4508
+ status: "superseded"
4509
+ }
4510
+ });
4511
+ if (count === 0) return null;
4512
+ const row = await db.subscriptionContract.findUnique({
4513
+ where: {
4514
+ id: contractId
4515
+ },
4516
+ include: {
4517
+ lineItems: true
4518
+ }
4519
+ });
4520
+ return row ? (0, import_core9.toSubscriptionContractRecord)(row, row.lineItems) : null;
4382
4521
  }
4383
4522
  };
4384
- PrismaSubscriptionContractRepository = _ts_decorate23([
4385
- (0, import_common23.Injectable)(),
4386
- _ts_param22(0, (0, import_common23.Inject)(PRISMA_CLIENT_TOKEN)),
4387
- _ts_metadata22("design:type", Function),
4388
- _ts_metadata22("design:paramtypes", [
4523
+ PrismaSubscriptionContractRepository = _ts_decorate24([
4524
+ (0, import_common24.Injectable)(),
4525
+ _ts_param23(0, (0, import_common24.Inject)(PRISMA_CLIENT_TOKEN)),
4526
+ _ts_metadata23("design:type", Function),
4527
+ _ts_metadata23("design:paramtypes", [
4389
4528
  typeof PrismaLike === "undefined" ? Object : PrismaLike
4390
4529
  ])
4391
4530
  ], PrismaSubscriptionContractRepository);
@@ -4414,26 +4553,104 @@ function toLineItemCreate(item) {
4414
4553
  }
4415
4554
  __name(toLineItemCreate, "toLineItemCreate");
4416
4555
 
4556
+ // src/prisma-subscriber-ledger.repository.ts
4557
+ var import_common25 = require("@nestjs/common");
4558
+ var import_core10 = require("@saasicat/core");
4559
+ function _ts_decorate25(decorators, target, key, desc) {
4560
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4561
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4562
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4563
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
4564
+ }
4565
+ __name(_ts_decorate25, "_ts_decorate");
4566
+ function _ts_metadata24(k, v) {
4567
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4568
+ }
4569
+ __name(_ts_metadata24, "_ts_metadata");
4570
+ function _ts_param24(paramIndex, decorator) {
4571
+ return function(target, key) {
4572
+ decorator(target, key, paramIndex);
4573
+ };
4574
+ }
4575
+ __name(_ts_param24, "_ts_param");
4576
+ var PrismaSubscriberLedgerRepository = class {
4577
+ static {
4578
+ __name(this, "PrismaSubscriberLedgerRepository");
4579
+ }
4580
+ prisma;
4581
+ constructor(prisma) {
4582
+ this.prisma = prisma;
4583
+ }
4584
+ db(tx) {
4585
+ return tx ?? this.prisma;
4586
+ }
4587
+ /**
4588
+ * One statement, `skipDuplicates` being `ON CONFLICT DO NOTHING`: a charge
4589
+ * another caller wrote first — committed or still in flight — is waited for
4590
+ * and skipped rather than raised, and only what this call wrote comes back.
4591
+ * It names no conflict target, so it suppresses every unique key; the only
4592
+ * one besides the natural key is the primary key, a uuid made per row here.
4593
+ */
4594
+ async recordCharges(charges, tx) {
4595
+ if (charges.length === 0) return [];
4596
+ const rows = await this.db(tx).subscriberLedgerEntry.createManyAndReturn({
4597
+ data: charges.map(import_core10.subscriberChargeColumns),
4598
+ skipDuplicates: true
4599
+ });
4600
+ return rows.map(import_core10.toSubscriberChargeRecord);
4601
+ }
4602
+ async listBySubscription(subscriptionId, tx) {
4603
+ const rows = await this.db(tx).subscriberLedgerEntry.findMany({
4604
+ where: {
4605
+ subscriptionId
4606
+ },
4607
+ orderBy: [
4608
+ {
4609
+ periodStart: "asc"
4610
+ },
4611
+ {
4612
+ source: "asc"
4613
+ },
4614
+ {
4615
+ sourceRef: "asc"
4616
+ },
4617
+ {
4618
+ origin: "asc"
4619
+ }
4620
+ ]
4621
+ });
4622
+ return rows.map(import_core10.toSubscriberChargeRecord);
4623
+ }
4624
+ };
4625
+ PrismaSubscriberLedgerRepository = _ts_decorate25([
4626
+ (0, import_common25.Injectable)(),
4627
+ _ts_param24(0, (0, import_common25.Inject)(PRISMA_CLIENT_TOKEN)),
4628
+ _ts_metadata24("design:type", Function),
4629
+ _ts_metadata24("design:paramtypes", [
4630
+ typeof LedgerClient === "undefined" ? Object : LedgerClient
4631
+ ])
4632
+ ], PrismaSubscriberLedgerRepository);
4633
+
4417
4634
  // src/prisma-subscriber-payment-method.repository.ts
4418
- var import_common24 = require("@nestjs/common");
4419
- var import_core8 = require("@saasicat/core");
4420
- function _ts_decorate24(decorators, target, key, desc) {
4635
+ var import_common26 = require("@nestjs/common");
4636
+ var import_core11 = require("@saasicat/core");
4637
+ function _ts_decorate26(decorators, target, key, desc) {
4421
4638
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4422
4639
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4423
4640
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4424
4641
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4425
4642
  }
4426
- __name(_ts_decorate24, "_ts_decorate");
4427
- function _ts_metadata23(k, v) {
4643
+ __name(_ts_decorate26, "_ts_decorate");
4644
+ function _ts_metadata25(k, v) {
4428
4645
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4429
4646
  }
4430
- __name(_ts_metadata23, "_ts_metadata");
4431
- function _ts_param23(paramIndex, decorator) {
4647
+ __name(_ts_metadata25, "_ts_metadata");
4648
+ function _ts_param25(paramIndex, decorator) {
4432
4649
  return function(target, key) {
4433
4650
  decorator(target, key, paramIndex);
4434
4651
  };
4435
4652
  }
4436
- __name(_ts_param23, "_ts_param");
4653
+ __name(_ts_param25, "_ts_param");
4437
4654
  var PrismaSubscriberPaymentMethodRepository = class {
4438
4655
  static {
4439
4656
  __name(this, "PrismaSubscriberPaymentMethodRepository");
@@ -4465,9 +4682,9 @@ var PrismaSubscriberPaymentMethodRepository = class {
4465
4682
  }
4466
4683
  });
4467
4684
  if (recorded) {
4468
- (0, import_core8.refuseForeignPaymentMethodReference)(recorded, data.subscriberId);
4685
+ (0, import_core11.refuseForeignPaymentMethodReference)(recorded, data.subscriberId);
4469
4686
  return {
4470
- method: (0, import_core8.toSubscriberPaymentMethodRecord)(recorded),
4687
+ method: (0, import_core11.toSubscriberPaymentMethodRecord)(recorded),
4471
4688
  outcome: "already-recorded"
4472
4689
  };
4473
4690
  }
@@ -4479,13 +4696,13 @@ var PrismaSubscriberPaymentMethodRepository = class {
4479
4696
  });
4480
4697
  const replacedOnArrival = active && active.confirmedAt.getTime() > data.confirmedAt.getTime() ? active.confirmedAt : null;
4481
4698
  const claimed = await this.claimReference(db, {
4482
- ...(0, import_core8.subscriberPaymentMethodColumns)(data),
4699
+ ...(0, import_core11.subscriberPaymentMethodColumns)(data),
4483
4700
  status: "REPLACED",
4484
4701
  replacedAt: replacedOnArrival ?? data.confirmedAt
4485
4702
  });
4486
4703
  if (replacedOnArrival) {
4487
4704
  return {
4488
- method: (0, import_core8.toSubscriberPaymentMethodRecord)(claimed),
4705
+ method: (0, import_core11.toSubscriberPaymentMethodRecord)(claimed),
4489
4706
  outcome: "superseded"
4490
4707
  };
4491
4708
  }
@@ -4510,7 +4727,7 @@ var PrismaSubscriberPaymentMethodRepository = class {
4510
4727
  }
4511
4728
  });
4512
4729
  return {
4513
- method: (0, import_core8.toSubscriberPaymentMethodRecord)(inUse),
4730
+ method: (0, import_core11.toSubscriberPaymentMethodRecord)(inUse),
4514
4731
  outcome: "activated"
4515
4732
  };
4516
4733
  });
@@ -4570,7 +4787,7 @@ var PrismaSubscriberPaymentMethodRepository = class {
4570
4787
  skipDuplicates: true
4571
4788
  });
4572
4789
  if (!claimed) {
4573
- throw new import_core8.ForeignPaymentMethodReferenceError(row.gatewayAccount, row.paymentMethodRef);
4790
+ throw new import_core11.ForeignPaymentMethodReferenceError(row.gatewayAccount, row.paymentMethodRef);
4574
4791
  }
4575
4792
  return claimed;
4576
4793
  }
@@ -4581,7 +4798,7 @@ var PrismaSubscriberPaymentMethodRepository = class {
4581
4798
  status: "ACTIVE"
4582
4799
  }
4583
4800
  });
4584
- return row ? (0, import_core8.toSubscriberPaymentMethodRecord)(row) : null;
4801
+ return row ? (0, import_core11.toSubscriberPaymentMethodRecord)(row) : null;
4585
4802
  }
4586
4803
  async findByReference(reference, tx) {
4587
4804
  const row = await this.db(tx).subscriberPaymentMethod.findFirst({
@@ -4591,7 +4808,7 @@ var PrismaSubscriberPaymentMethodRepository = class {
4591
4808
  paymentMethodRef: reference.paymentMethodRef
4592
4809
  }
4593
4810
  });
4594
- return row ? (0, import_core8.toSubscriberPaymentMethodRecord)(row) : null;
4811
+ return row ? (0, import_core11.toSubscriberPaymentMethodRecord)(row) : null;
4595
4812
  }
4596
4813
  async accountsInUse() {
4597
4814
  const rows = await this.db().subscriberPaymentMethod.findMany({
@@ -4636,35 +4853,35 @@ var PrismaSubscriberPaymentMethodRepository = class {
4636
4853
  return count === 1;
4637
4854
  }
4638
4855
  };
4639
- PrismaSubscriberPaymentMethodRepository = _ts_decorate24([
4640
- (0, import_common24.Injectable)(),
4641
- _ts_param23(0, (0, import_common24.Inject)(PRISMA_CLIENT_TOKEN)),
4642
- _ts_metadata23("design:type", Function),
4643
- _ts_metadata23("design:paramtypes", [
4856
+ PrismaSubscriberPaymentMethodRepository = _ts_decorate26([
4857
+ (0, import_common26.Injectable)(),
4858
+ _ts_param25(0, (0, import_common26.Inject)(PRISMA_CLIENT_TOKEN)),
4859
+ _ts_metadata25("design:type", Function),
4860
+ _ts_metadata25("design:paramtypes", [
4644
4861
  typeof PaymentMethodRepositoryClient === "undefined" ? Object : PaymentMethodRepositoryClient
4645
4862
  ])
4646
4863
  ], PrismaSubscriberPaymentMethodRepository);
4647
4864
 
4648
4865
  // src/prisma-subscriber.repository.ts
4649
- var import_common25 = require("@nestjs/common");
4650
- var import_core9 = require("@saasicat/core");
4651
- function _ts_decorate25(decorators, target, key, desc) {
4866
+ var import_common27 = require("@nestjs/common");
4867
+ var import_core12 = require("@saasicat/core");
4868
+ function _ts_decorate27(decorators, target, key, desc) {
4652
4869
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4653
4870
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4654
4871
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4655
4872
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4656
4873
  }
4657
- __name(_ts_decorate25, "_ts_decorate");
4658
- function _ts_metadata24(k, v) {
4874
+ __name(_ts_decorate27, "_ts_decorate");
4875
+ function _ts_metadata26(k, v) {
4659
4876
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4660
4877
  }
4661
- __name(_ts_metadata24, "_ts_metadata");
4662
- function _ts_param24(paramIndex, decorator) {
4878
+ __name(_ts_metadata26, "_ts_metadata");
4879
+ function _ts_param26(paramIndex, decorator) {
4663
4880
  return function(target, key) {
4664
4881
  decorator(target, key, paramIndex);
4665
4882
  };
4666
4883
  }
4667
- __name(_ts_param24, "_ts_param");
4884
+ __name(_ts_param26, "_ts_param");
4668
4885
  var WITH_LIVE_TENANT = {
4669
4886
  tenants: {
4670
4887
  where: {
@@ -4715,7 +4932,7 @@ var PrismaSubscriberRepository = class {
4715
4932
  });
4716
4933
  return null;
4717
4934
  }
4718
- return (0, import_core9.toSubscriberRecord)(created, tenantId);
4935
+ return (0, import_core12.toSubscriberRecord)(created, tenantId);
4719
4936
  });
4720
4937
  }
4721
4938
  async findById(subscriberId, tx) {
@@ -4725,7 +4942,7 @@ var PrismaSubscriberRepository = class {
4725
4942
  },
4726
4943
  include: WITH_LIVE_TENANT
4727
4944
  });
4728
- return row ? toRecord4(row) : null;
4945
+ return row ? toRecord3(row) : null;
4729
4946
  }
4730
4947
  async findByTenantId(tenantId, tx) {
4731
4948
  const row = await this.db(tx).subscriber.findFirst({
@@ -4738,7 +4955,7 @@ var PrismaSubscriberRepository = class {
4738
4955
  }
4739
4956
  }
4740
4957
  });
4741
- return row ? (0, import_core9.toSubscriberRecord)(row, tenantId) : null;
4958
+ return row ? (0, import_core12.toSubscriberRecord)(row, tenantId) : null;
4742
4959
  }
4743
4960
  async updateContact(subscriberId, change, tx) {
4744
4961
  const db = this.db(tx);
@@ -4761,10 +4978,10 @@ var PrismaSubscriberRepository = class {
4761
4978
  include: WITH_LIVE_TENANT
4762
4979
  });
4763
4980
  if (!current) return null;
4764
- const delta = (0, import_core9.identityCorrectionDelta)(current, data.corrected);
4981
+ const delta = (0, import_core12.identityCorrectionDelta)(current, data.corrected);
4765
4982
  if (Object.keys(delta.corrected).length === 0) {
4766
4983
  return {
4767
- subscriber: toRecord4(current),
4984
+ subscriber: toRecord3(current),
4768
4985
  correction: null
4769
4986
  };
4770
4987
  }
@@ -4786,8 +5003,8 @@ var PrismaSubscriberRepository = class {
4786
5003
  }
4787
5004
  });
4788
5005
  return {
4789
- subscriber: toRecord4(updated),
4790
- correction: (0, import_core9.toSubscriberCorrectionRecord)(correction)
5006
+ subscriber: toRecord3(updated),
5007
+ correction: (0, import_core12.toSubscriberCorrectionRecord)(correction)
4791
5008
  };
4792
5009
  });
4793
5010
  }
@@ -4805,41 +5022,41 @@ var PrismaSubscriberRepository = class {
4805
5022
  }
4806
5023
  ]
4807
5024
  });
4808
- return rows.map(import_core9.toSubscriberCorrectionRecord);
5025
+ return rows.map(import_core12.toSubscriberCorrectionRecord);
4809
5026
  }
4810
5027
  };
4811
- PrismaSubscriberRepository = _ts_decorate25([
4812
- (0, import_common25.Injectable)(),
4813
- _ts_param24(0, (0, import_common25.Inject)(PRISMA_CLIENT_TOKEN)),
4814
- _ts_metadata24("design:type", Function),
4815
- _ts_metadata24("design:paramtypes", [
5028
+ PrismaSubscriberRepository = _ts_decorate27([
5029
+ (0, import_common27.Injectable)(),
5030
+ _ts_param26(0, (0, import_common27.Inject)(PRISMA_CLIENT_TOKEN)),
5031
+ _ts_metadata26("design:type", Function),
5032
+ _ts_metadata26("design:paramtypes", [
4816
5033
  typeof SubscriberRepositoryClient === "undefined" ? Object : SubscriberRepositoryClient
4817
5034
  ])
4818
5035
  ], PrismaSubscriberRepository);
4819
- function toRecord4(row) {
4820
- return (0, import_core9.toSubscriberRecord)(row, row.tenants?.[0]?.tenantId ?? null);
5036
+ function toRecord3(row) {
5037
+ return (0, import_core12.toSubscriberRecord)(row, row.tenants?.[0]?.tenantId ?? null);
4821
5038
  }
4822
- __name(toRecord4, "toRecord");
5039
+ __name(toRecord3, "toRecord");
4823
5040
 
4824
5041
  // src/prisma-subscription.repository.ts
4825
- var import_common26 = require("@nestjs/common");
4826
- function _ts_decorate26(decorators, target, key, desc) {
5042
+ var import_common28 = require("@nestjs/common");
5043
+ function _ts_decorate28(decorators, target, key, desc) {
4827
5044
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4828
5045
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4829
5046
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4830
5047
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4831
5048
  }
4832
- __name(_ts_decorate26, "_ts_decorate");
4833
- function _ts_metadata25(k, v) {
5049
+ __name(_ts_decorate28, "_ts_decorate");
5050
+ function _ts_metadata27(k, v) {
4834
5051
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4835
5052
  }
4836
- __name(_ts_metadata25, "_ts_metadata");
4837
- function _ts_param25(paramIndex, decorator) {
5053
+ __name(_ts_metadata27, "_ts_metadata");
5054
+ function _ts_param27(paramIndex, decorator) {
4838
5055
  return function(target, key) {
4839
5056
  decorator(target, key, paramIndex);
4840
5057
  };
4841
5058
  }
4842
- __name(_ts_param25, "_ts_param");
5059
+ __name(_ts_param27, "_ts_param");
4843
5060
  var ACTIVE_STATUSES = [
4844
5061
  "ACTIVE",
4845
5062
  "TRIAL"
@@ -5074,37 +5291,37 @@ var PrismaSubscriptionRepository = class {
5074
5291
  ]));
5075
5292
  }
5076
5293
  };
5077
- PrismaSubscriptionRepository = _ts_decorate26([
5078
- (0, import_common26.Injectable)(),
5079
- _ts_param25(0, (0, import_common26.Inject)(PRISMA_CLIENT_TOKEN)),
5080
- _ts_param25(1, (0, import_common26.Optional)()),
5081
- _ts_param25(1, (0, import_common26.Inject)(PRISMA_SCHEMA_OPTIONS_TOKEN)),
5082
- _ts_metadata25("design:type", Function),
5083
- _ts_metadata25("design:paramtypes", [
5294
+ PrismaSubscriptionRepository = _ts_decorate28([
5295
+ (0, import_common28.Injectable)(),
5296
+ _ts_param27(0, (0, import_common28.Inject)(PRISMA_CLIENT_TOKEN)),
5297
+ _ts_param27(1, (0, import_common28.Optional)()),
5298
+ _ts_param27(1, (0, import_common28.Inject)(PRISMA_SCHEMA_OPTIONS_TOKEN)),
5299
+ _ts_metadata27("design:type", Function),
5300
+ _ts_metadata27("design:paramtypes", [
5084
5301
  typeof SubscriptionRepositoryClient === "undefined" ? Object : SubscriptionRepositoryClient,
5085
5302
  typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
5086
5303
  ])
5087
5304
  ], PrismaSubscriptionRepository);
5088
5305
 
5089
5306
  // src/prisma-subscription-usage.adapter.ts
5090
- var import_common27 = require("@nestjs/common");
5091
- function _ts_decorate27(decorators, target, key, desc) {
5307
+ var import_common29 = require("@nestjs/common");
5308
+ function _ts_decorate29(decorators, target, key, desc) {
5092
5309
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5093
5310
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5094
5311
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5095
5312
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5096
5313
  }
5097
- __name(_ts_decorate27, "_ts_decorate");
5098
- function _ts_metadata26(k, v) {
5314
+ __name(_ts_decorate29, "_ts_decorate");
5315
+ function _ts_metadata28(k, v) {
5099
5316
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
5100
5317
  }
5101
- __name(_ts_metadata26, "_ts_metadata");
5102
- function _ts_param26(paramIndex, decorator) {
5318
+ __name(_ts_metadata28, "_ts_metadata");
5319
+ function _ts_param28(paramIndex, decorator) {
5103
5320
  return function(target, key) {
5104
5321
  decorator(target, key, paramIndex);
5105
5322
  };
5106
5323
  }
5107
- __name(_ts_param26, "_ts_param");
5324
+ __name(_ts_param28, "_ts_param");
5108
5325
  var PrismaSubscriptionUsageAdapter = class {
5109
5326
  static {
5110
5327
  __name(this, "PrismaSubscriptionUsageAdapter");
@@ -5195,38 +5412,38 @@ var PrismaSubscriptionUsageAdapter = class {
5195
5412
  return getPrismaDelegate(this.prisma, this.planVersionDelegateName);
5196
5413
  }
5197
5414
  };
5198
- PrismaSubscriptionUsageAdapter = _ts_decorate27([
5199
- (0, import_common27.Injectable)(),
5200
- _ts_param26(0, (0, import_common27.Inject)(PRISMA_CLIENT_TOKEN)),
5201
- _ts_param26(1, (0, import_common27.Optional)()),
5202
- _ts_param26(1, (0, import_common27.Inject)(PRISMA_SCHEMA_OPTIONS_TOKEN)),
5203
- _ts_metadata26("design:type", Function),
5204
- _ts_metadata26("design:paramtypes", [
5415
+ PrismaSubscriptionUsageAdapter = _ts_decorate29([
5416
+ (0, import_common29.Injectable)(),
5417
+ _ts_param28(0, (0, import_common29.Inject)(PRISMA_CLIENT_TOKEN)),
5418
+ _ts_param28(1, (0, import_common29.Optional)()),
5419
+ _ts_param28(1, (0, import_common29.Inject)(PRISMA_SCHEMA_OPTIONS_TOKEN)),
5420
+ _ts_metadata28("design:type", Function),
5421
+ _ts_metadata28("design:paramtypes", [
5205
5422
  typeof SubscriptionUsageClient === "undefined" ? Object : SubscriptionUsageClient,
5206
5423
  typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
5207
5424
  ])
5208
5425
  ], PrismaSubscriptionUsageAdapter);
5209
5426
 
5210
5427
  // src/prisma-super-admin-bootstrap.adapter.ts
5211
- var import_common28 = require("@nestjs/common");
5212
- var import_core10 = require("@saasicat/core");
5213
- function _ts_decorate28(decorators, target, key, desc) {
5428
+ var import_common30 = require("@nestjs/common");
5429
+ var import_core13 = require("@saasicat/core");
5430
+ function _ts_decorate30(decorators, target, key, desc) {
5214
5431
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5215
5432
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5216
5433
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5217
5434
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5218
5435
  }
5219
- __name(_ts_decorate28, "_ts_decorate");
5220
- function _ts_metadata27(k, v) {
5436
+ __name(_ts_decorate30, "_ts_decorate");
5437
+ function _ts_metadata29(k, v) {
5221
5438
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
5222
5439
  }
5223
- __name(_ts_metadata27, "_ts_metadata");
5224
- function _ts_param27(paramIndex, decorator) {
5440
+ __name(_ts_metadata29, "_ts_metadata");
5441
+ function _ts_param29(paramIndex, decorator) {
5225
5442
  return function(target, key) {
5226
5443
  decorator(target, key, paramIndex);
5227
5444
  };
5228
5445
  }
5229
- __name(_ts_param27, "_ts_param");
5446
+ __name(_ts_param29, "_ts_param");
5230
5447
  var PASSWORD_HASHER_TOKEN = /* @__PURE__ */ Symbol.for("saasicat/adapter-prisma/PasswordHasher");
5231
5448
  var PrismaSuperAdminBootstrapAdapter = class {
5232
5449
  static {
@@ -5254,7 +5471,7 @@ var PrismaSuperAdminBootstrapAdapter = class {
5254
5471
  }
5255
5472
  });
5256
5473
  if (existing) {
5257
- throw new import_core10.PlatformUserExistsError(email, existing.platformRole);
5474
+ throw new import_core13.PlatformUserExistsError(email, existing.platformRole);
5258
5475
  }
5259
5476
  const row = await this.prisma.superAdminUser.create({
5260
5477
  data: {
@@ -5276,37 +5493,37 @@ var PrismaSuperAdminBootstrapAdapter = class {
5276
5493
  };
5277
5494
  }
5278
5495
  };
5279
- PrismaSuperAdminBootstrapAdapter = _ts_decorate28([
5280
- (0, import_common28.Injectable)(),
5281
- _ts_param27(0, (0, import_common28.Inject)(PRISMA_CLIENT_TOKEN)),
5282
- _ts_param27(1, (0, import_common28.Inject)(PASSWORD_HASHER_TOKEN)),
5283
- _ts_metadata27("design:type", Function),
5284
- _ts_metadata27("design:paramtypes", [
5496
+ PrismaSuperAdminBootstrapAdapter = _ts_decorate30([
5497
+ (0, import_common30.Injectable)(),
5498
+ _ts_param29(0, (0, import_common30.Inject)(PRISMA_CLIENT_TOKEN)),
5499
+ _ts_param29(1, (0, import_common30.Inject)(PASSWORD_HASHER_TOKEN)),
5500
+ _ts_metadata29("design:type", Function),
5501
+ _ts_metadata29("design:paramtypes", [
5285
5502
  typeof PrismaLike === "undefined" ? Object : PrismaLike,
5286
5503
  typeof PasswordHasher === "undefined" ? Object : PasswordHasher
5287
5504
  ])
5288
5505
  ], PrismaSuperAdminBootstrapAdapter);
5289
5506
 
5290
5507
  // src/prisma-tenant-subscription-write.adapter.ts
5291
- var import_common29 = require("@nestjs/common");
5292
- var import_core11 = require("@saasicat/core");
5293
- function _ts_decorate29(decorators, target, key, desc) {
5508
+ var import_common31 = require("@nestjs/common");
5509
+ var import_core14 = require("@saasicat/core");
5510
+ function _ts_decorate31(decorators, target, key, desc) {
5294
5511
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5295
5512
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5296
5513
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5297
5514
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5298
5515
  }
5299
- __name(_ts_decorate29, "_ts_decorate");
5300
- function _ts_metadata28(k, v) {
5516
+ __name(_ts_decorate31, "_ts_decorate");
5517
+ function _ts_metadata30(k, v) {
5301
5518
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
5302
5519
  }
5303
- __name(_ts_metadata28, "_ts_metadata");
5304
- function _ts_param28(paramIndex, decorator) {
5520
+ __name(_ts_metadata30, "_ts_metadata");
5521
+ function _ts_param30(paramIndex, decorator) {
5305
5522
  return function(target, key) {
5306
5523
  decorator(target, key, paramIndex);
5307
5524
  };
5308
5525
  }
5309
- __name(_ts_param28, "_ts_param");
5526
+ __name(_ts_param30, "_ts_param");
5310
5527
  var PrismaTenantSubscriptionWriteAdapter = class {
5311
5528
  static {
5312
5529
  __name(this, "PrismaTenantSubscriptionWriteAdapter");
@@ -5590,9 +5807,9 @@ var PrismaTenantSubscriptionWriteAdapter = class {
5590
5807
  }
5591
5808
  async findTargetPlanVersionId(client, storagePlanId, asOf) {
5592
5809
  const activeWindow = this.schema.tenantSubscription.activeVersionSelection === "validity-window";
5593
- const activeVersionWhere = this.schema.tenantSubscription.withEndsAt ? (0, import_core11.buildActivePlanVersionWhere)(asOf, {
5810
+ const activeVersionWhere = this.schema.tenantSubscription.withEndsAt ? (0, import_core14.buildActivePlanVersionWhere)(asOf, {
5594
5811
  withEndsAt: true
5595
- }) : (0, import_core11.buildActivePlanVersionWhere)(asOf);
5812
+ }) : (0, import_core14.buildActivePlanVersionWhere)(asOf);
5596
5813
  const where = activeWindow ? {
5597
5814
  planId: storagePlanId,
5598
5815
  ...activeVersionWhere
@@ -5663,13 +5880,13 @@ var PrismaTenantSubscriptionWriteAdapter = class {
5663
5880
  }
5664
5881
  }
5665
5882
  };
5666
- PrismaTenantSubscriptionWriteAdapter = _ts_decorate29([
5667
- (0, import_common29.Injectable)(),
5668
- _ts_param28(0, (0, import_common29.Inject)(PRISMA_CLIENT_TOKEN)),
5669
- _ts_param28(1, (0, import_common29.Optional)()),
5670
- _ts_param28(1, (0, import_common29.Inject)(PRISMA_SCHEMA_OPTIONS_TOKEN)),
5671
- _ts_metadata28("design:type", Function),
5672
- _ts_metadata28("design:paramtypes", [
5883
+ PrismaTenantSubscriptionWriteAdapter = _ts_decorate31([
5884
+ (0, import_common31.Injectable)(),
5885
+ _ts_param30(0, (0, import_common31.Inject)(PRISMA_CLIENT_TOKEN)),
5886
+ _ts_param30(1, (0, import_common31.Optional)()),
5887
+ _ts_param30(1, (0, import_common31.Inject)(PRISMA_SCHEMA_OPTIONS_TOKEN)),
5888
+ _ts_metadata30("design:type", Function),
5889
+ _ts_metadata30("design:paramtypes", [
5673
5890
  typeof TransactionalPrismaClient === "undefined" ? Object : TransactionalPrismaClient,
5674
5891
  typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
5675
5892
  ])
@@ -5688,24 +5905,24 @@ function clearedPendingVersionData() {
5688
5905
  __name(clearedPendingVersionData, "clearedPendingVersionData");
5689
5906
 
5690
5907
  // src/prisma-transaction-runner.adapter.ts
5691
- var import_common30 = require("@nestjs/common");
5692
- function _ts_decorate30(decorators, target, key, desc) {
5908
+ var import_common32 = require("@nestjs/common");
5909
+ function _ts_decorate32(decorators, target, key, desc) {
5693
5910
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5694
5911
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5695
5912
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5696
5913
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5697
5914
  }
5698
- __name(_ts_decorate30, "_ts_decorate");
5699
- function _ts_metadata29(k, v) {
5915
+ __name(_ts_decorate32, "_ts_decorate");
5916
+ function _ts_metadata31(k, v) {
5700
5917
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
5701
5918
  }
5702
- __name(_ts_metadata29, "_ts_metadata");
5703
- function _ts_param29(paramIndex, decorator) {
5919
+ __name(_ts_metadata31, "_ts_metadata");
5920
+ function _ts_param31(paramIndex, decorator) {
5704
5921
  return function(target, key) {
5705
5922
  decorator(target, key, paramIndex);
5706
5923
  };
5707
5924
  }
5708
- __name(_ts_param29, "_ts_param");
5925
+ __name(_ts_param31, "_ts_param");
5709
5926
  var PrismaTransactionRunner = class {
5710
5927
  static {
5711
5928
  __name(this, "PrismaTransactionRunner");
@@ -5719,24 +5936,24 @@ var PrismaTransactionRunner = class {
5719
5936
  return transaction((tx) => fn(tx));
5720
5937
  }
5721
5938
  };
5722
- PrismaTransactionRunner = _ts_decorate30([
5723
- (0, import_common30.Injectable)(),
5724
- _ts_param29(0, (0, import_common30.Inject)(PRISMA_CLIENT_TOKEN)),
5725
- _ts_metadata29("design:type", Function),
5726
- _ts_metadata29("design:paramtypes", [
5939
+ PrismaTransactionRunner = _ts_decorate32([
5940
+ (0, import_common32.Injectable)(),
5941
+ _ts_param31(0, (0, import_common32.Inject)(PRISMA_CLIENT_TOKEN)),
5942
+ _ts_metadata31("design:type", Function),
5943
+ _ts_metadata31("design:paramtypes", [
5727
5944
  typeof Record === "undefined" ? Object : Record
5728
5945
  ])
5729
5946
  ], PrismaTransactionRunner);
5730
5947
 
5731
5948
  // src/zero-promo-revenue-aggregator.adapter.ts
5732
- var import_common31 = require("@nestjs/common");
5733
- function _ts_decorate31(decorators, target, key, desc) {
5949
+ var import_common33 = require("@nestjs/common");
5950
+ function _ts_decorate33(decorators, target, key, desc) {
5734
5951
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5735
5952
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5736
5953
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5737
5954
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5738
5955
  }
5739
- __name(_ts_decorate31, "_ts_decorate");
5956
+ __name(_ts_decorate33, "_ts_decorate");
5740
5957
  var ZeroPromoRevenueDeductionAggregator = class {
5741
5958
  static {
5742
5959
  __name(this, "ZeroPromoRevenueDeductionAggregator");
@@ -5745,8 +5962,8 @@ var ZeroPromoRevenueDeductionAggregator = class {
5745
5962
  return "0.00";
5746
5963
  }
5747
5964
  };
5748
- ZeroPromoRevenueDeductionAggregator = _ts_decorate31([
5749
- (0, import_common31.Injectable)()
5965
+ ZeroPromoRevenueDeductionAggregator = _ts_decorate33([
5966
+ (0, import_common33.Injectable)()
5750
5967
  ], ZeroPromoRevenueDeductionAggregator);
5751
5968
 
5752
5969
  // src/prisma-persistence.ts
@@ -5773,13 +5990,16 @@ function prismaPersistence(options) {
5773
5990
  auditQuery: provide((prisma) => new PrismaAuditQueryAdapter(prisma)),
5774
5991
  auditStats: provide((prisma) => new PrismaAuditStatsAdapter(prisma)),
5775
5992
  superAdminProvisioning: buildProvisioning(client, options.passwordHasher),
5776
- appliedSettings: provide((prisma) => new PrismaAppliedSettingsRepository(canonical(prisma)))
5993
+ appliedSettings: provide((prisma) => new PrismaAppliedSettingsRepository(canonical(prisma))),
5994
+ maintenanceWindows: provide((prisma) => new PrismaMaintenanceWindowRepository(canonical(prisma)))
5777
5995
  },
5778
5996
  entitlement: {
5779
5997
  subscriptionRepository: provide((prisma) => new PrismaSubscriptionRepository(prisma, options.schema)),
5780
5998
  planVersionRepository: provide((prisma) => new PrismaPlanVersionRepository(prisma, options.schema)),
5781
5999
  subscriptionContractRepository: provide((prisma) => new PrismaSubscriptionContractRepository(prisma)),
5782
6000
  subscriberRepository: provide((prisma) => new PrismaSubscriberRepository(canonical(prisma))),
6001
+ // The charges those contracts give rise to, written once each.
6002
+ subscriberLedgerRepository: provide((prisma) => new PrismaSubscriberLedgerRepository(canonical(prisma))),
5783
6003
  subscriptionBundleRepository: provide((prisma) => new PrismaSubscriptionBundleRepository(canonical(prisma))),
5784
6004
  bundleRepository: provide((prisma) => new PrismaBundleRepository(canonical(prisma), options.bundle))
5785
6005
  },
@@ -5870,6 +6090,7 @@ __name(buildProvisioning, "buildProvisioning");
5870
6090
  PrismaAuditStatsAdapter,
5871
6091
  PrismaBundleRepository,
5872
6092
  PrismaCatalogEntryRepository,
6093
+ PrismaMaintenanceWindowRepository,
5873
6094
  PrismaMarketingProjectionRepository,
5874
6095
  PrismaMarketingSettingsRepository,
5875
6096
  PrismaMfaAdapter,
@@ -5884,6 +6105,7 @@ __name(buildProvisioning, "buildProvisioning");
5884
6105
  PrismaPromoCodeValidationLogRepository,
5885
6106
  PrismaPromoSubscriptionLookup,
5886
6107
  PrismaPromotionRepository,
6108
+ PrismaSubscriberLedgerRepository,
5887
6109
  PrismaSubscriberPaymentMethodRepository,
5888
6110
  PrismaSubscriberRepository,
5889
6111
  PrismaSubscriptionBundleRepository,