@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.js CHANGED
@@ -1981,8 +1981,10 @@ function toRow(row) {
1981
1981
  }
1982
1982
  __name(toRow, "toRow");
1983
1983
 
1984
- // src/prisma-marketing-settings.repository.ts
1984
+ // src/prisma-maintenance-window.repository.ts
1985
+ import { randomUUID } from "crypto";
1985
1986
  import { Inject as Inject8, Injectable as Injectable9 } from "@nestjs/common";
1987
+ import { toMaintenanceWindowRecord } from "@saasicat/core";
1986
1988
  function _ts_decorate9(decorators, target, key, desc) {
1987
1989
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1988
1990
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -2000,6 +2002,128 @@ function _ts_param8(paramIndex, decorator) {
2000
2002
  };
2001
2003
  }
2002
2004
  __name(_ts_param8, "_ts_param");
2005
+ var COLUMNS = {
2006
+ id: true,
2007
+ startsAt: true,
2008
+ endsAt: true,
2009
+ message: true,
2010
+ createdAt: true,
2011
+ createdBy: true,
2012
+ lockedAt: true,
2013
+ lockedBy: true,
2014
+ endedAt: true,
2015
+ endedBy: true
2016
+ };
2017
+ var PrismaMaintenanceWindowRepository = class {
2018
+ static {
2019
+ __name(this, "PrismaMaintenanceWindowRepository");
2020
+ }
2021
+ prisma;
2022
+ constructor(prisma) {
2023
+ this.prisma = prisma;
2024
+ }
2025
+ get db() {
2026
+ return this.prisma;
2027
+ }
2028
+ async findOpen() {
2029
+ const row = await this.db.maintenanceWindow.findFirst({
2030
+ where: {
2031
+ endedAt: null
2032
+ },
2033
+ select: COLUMNS
2034
+ });
2035
+ return row ? toMaintenanceWindowRecord(row) : null;
2036
+ }
2037
+ async listRecent(limit) {
2038
+ const rows = await this.db.maintenanceWindow.findMany({
2039
+ select: COLUMNS,
2040
+ orderBy: [
2041
+ {
2042
+ createdAt: "desc"
2043
+ },
2044
+ {
2045
+ id: "desc"
2046
+ }
2047
+ ],
2048
+ take: limit
2049
+ });
2050
+ return rows.map(toMaintenanceWindowRecord);
2051
+ }
2052
+ /**
2053
+ * One statement, `skipDuplicates` being `ON CONFLICT DO NOTHING`: the
2054
+ * partial unique index that holds an installation to one open window is
2055
+ * what refuses the second, and it refuses by returning no row rather than
2056
+ * by raising. The id is a uuid made here, so the primary key cannot be the
2057
+ * key it met.
2058
+ */
2059
+ async open(window) {
2060
+ const [row] = await this.db.maintenanceWindow.createManyAndReturn({
2061
+ data: [
2062
+ {
2063
+ id: randomUUID(),
2064
+ ...window,
2065
+ endedAt: null,
2066
+ endedBy: null
2067
+ }
2068
+ ],
2069
+ skipDuplicates: true
2070
+ });
2071
+ return row ? toMaintenanceWindowRecord(row) : null;
2072
+ }
2073
+ /**
2074
+ * One guarded `UPDATE`: the stage the caller read is in the `WHERE`, so a
2075
+ * window another operator moved on a moment earlier leaves the count at
2076
+ * zero instead of being moved twice.
2077
+ */
2078
+ async update(id, stage, changes) {
2079
+ const { count } = await this.db.maintenanceWindow.updateMany({
2080
+ where: {
2081
+ id,
2082
+ endedAt: null,
2083
+ lockedAt: stage === "locked" ? {
2084
+ not: null
2085
+ } : null
2086
+ },
2087
+ data: changes
2088
+ });
2089
+ if (count !== 1) return null;
2090
+ const row = await this.db.maintenanceWindow.findUnique({
2091
+ where: {
2092
+ id
2093
+ },
2094
+ select: COLUMNS
2095
+ });
2096
+ return row ? toMaintenanceWindowRecord(row) : null;
2097
+ }
2098
+ };
2099
+ PrismaMaintenanceWindowRepository = _ts_decorate9([
2100
+ Injectable9(),
2101
+ _ts_param8(0, Inject8(PRISMA_CLIENT_TOKEN)),
2102
+ _ts_metadata8("design:type", Function),
2103
+ _ts_metadata8("design:paramtypes", [
2104
+ Object
2105
+ ])
2106
+ ], PrismaMaintenanceWindowRepository);
2107
+
2108
+ // src/prisma-marketing-settings.repository.ts
2109
+ import { Inject as Inject9, Injectable as Injectable10 } from "@nestjs/common";
2110
+ function _ts_decorate10(decorators, target, key, desc) {
2111
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2112
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2113
+ 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;
2114
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2115
+ }
2116
+ __name(_ts_decorate10, "_ts_decorate");
2117
+ function _ts_metadata9(k, v) {
2118
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2119
+ }
2120
+ __name(_ts_metadata9, "_ts_metadata");
2121
+ function _ts_param9(paramIndex, decorator) {
2122
+ return function(target, key) {
2123
+ decorator(target, key, paramIndex);
2124
+ };
2125
+ }
2126
+ __name(_ts_param9, "_ts_param");
2003
2127
  var SETTINGS_ROW_ID = "marketing-settings";
2004
2128
  var PrismaMarketingSettingsRepository = class {
2005
2129
  static {
@@ -2036,11 +2160,11 @@ var PrismaMarketingSettingsRepository = class {
2036
2160
  return toRow2(row);
2037
2161
  }
2038
2162
  };
2039
- PrismaMarketingSettingsRepository = _ts_decorate9([
2040
- Injectable9(),
2041
- _ts_param8(0, Inject8(PRISMA_CLIENT_TOKEN)),
2042
- _ts_metadata8("design:type", Function),
2043
- _ts_metadata8("design:paramtypes", [
2163
+ PrismaMarketingSettingsRepository = _ts_decorate10([
2164
+ Injectable10(),
2165
+ _ts_param9(0, Inject9(PRISMA_CLIENT_TOKEN)),
2166
+ _ts_metadata9("design:type", Function),
2167
+ _ts_metadata9("design:paramtypes", [
2044
2168
  typeof MarketingSettingsRepositoryClient === "undefined" ? Object : MarketingSettingsRepositoryClient
2045
2169
  ])
2046
2170
  ], PrismaMarketingSettingsRepository);
@@ -2053,24 +2177,24 @@ function toRow2(row) {
2053
2177
  __name(toRow2, "toRow");
2054
2178
 
2055
2179
  // src/prisma-mfa.adapter.ts
2056
- import { Inject as Inject9, Injectable as Injectable10 } from "@nestjs/common";
2057
- function _ts_decorate10(decorators, target, key, desc) {
2180
+ import { Inject as Inject10, Injectable as Injectable11 } from "@nestjs/common";
2181
+ function _ts_decorate11(decorators, target, key, desc) {
2058
2182
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2059
2183
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2060
2184
  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;
2061
2185
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2062
2186
  }
2063
- __name(_ts_decorate10, "_ts_decorate");
2064
- function _ts_metadata9(k, v) {
2187
+ __name(_ts_decorate11, "_ts_decorate");
2188
+ function _ts_metadata10(k, v) {
2065
2189
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2066
2190
  }
2067
- __name(_ts_metadata9, "_ts_metadata");
2068
- function _ts_param9(paramIndex, decorator) {
2191
+ __name(_ts_metadata10, "_ts_metadata");
2192
+ function _ts_param10(paramIndex, decorator) {
2069
2193
  return function(target, key) {
2070
2194
  decorator(target, key, paramIndex);
2071
2195
  };
2072
2196
  }
2073
- __name(_ts_param9, "_ts_param");
2197
+ __name(_ts_param10, "_ts_param");
2074
2198
  var PrismaMfaAdapter = class {
2075
2199
  static {
2076
2200
  __name(this, "PrismaMfaAdapter");
@@ -2113,34 +2237,34 @@ var PrismaMfaAdapter = class {
2113
2237
  return !!row?.secret && !!row?.enabledAt;
2114
2238
  }
2115
2239
  };
2116
- PrismaMfaAdapter = _ts_decorate10([
2117
- Injectable10(),
2118
- _ts_param9(0, Inject9(PRISMA_CLIENT_TOKEN)),
2119
- _ts_metadata9("design:type", Function),
2120
- _ts_metadata9("design:paramtypes", [
2240
+ PrismaMfaAdapter = _ts_decorate11([
2241
+ Injectable11(),
2242
+ _ts_param10(0, Inject10(PRISMA_CLIENT_TOKEN)),
2243
+ _ts_metadata10("design:type", Function),
2244
+ _ts_metadata10("design:paramtypes", [
2121
2245
  typeof Pick === "undefined" ? Object : Pick
2122
2246
  ])
2123
2247
  ], PrismaMfaAdapter);
2124
2248
 
2125
2249
  // src/prisma-plan-catalog-import-sink.adapter.ts
2126
- import { Inject as Inject10, Injectable as Injectable11, Optional as Optional2 } from "@nestjs/common";
2127
- function _ts_decorate11(decorators, target, key, desc) {
2250
+ import { Inject as Inject11, Injectable as Injectable12, Optional as Optional2 } from "@nestjs/common";
2251
+ function _ts_decorate12(decorators, target, key, desc) {
2128
2252
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2129
2253
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2130
2254
  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;
2131
2255
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2132
2256
  }
2133
- __name(_ts_decorate11, "_ts_decorate");
2134
- function _ts_metadata10(k, v) {
2257
+ __name(_ts_decorate12, "_ts_decorate");
2258
+ function _ts_metadata11(k, v) {
2135
2259
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2136
2260
  }
2137
- __name(_ts_metadata10, "_ts_metadata");
2138
- function _ts_param10(paramIndex, decorator) {
2261
+ __name(_ts_metadata11, "_ts_metadata");
2262
+ function _ts_param11(paramIndex, decorator) {
2139
2263
  return function(target, key) {
2140
2264
  decorator(target, key, paramIndex);
2141
2265
  };
2142
2266
  }
2143
- __name(_ts_param10, "_ts_param");
2267
+ __name(_ts_param11, "_ts_param");
2144
2268
  var PrismaPlanCatalogImportSink = class {
2145
2269
  static {
2146
2270
  __name(this, "PrismaPlanCatalogImportSink");
@@ -2257,38 +2381,38 @@ var PrismaPlanCatalogImportSink = class {
2257
2381
  };
2258
2382
  }
2259
2383
  };
2260
- PrismaPlanCatalogImportSink = _ts_decorate11([
2261
- Injectable11(),
2262
- _ts_param10(0, Inject10(PRISMA_CLIENT_TOKEN)),
2263
- _ts_param10(1, Optional2()),
2264
- _ts_param10(1, Inject10(PRISMA_SCHEMA_OPTIONS_TOKEN)),
2265
- _ts_metadata10("design:type", Function),
2266
- _ts_metadata10("design:paramtypes", [
2384
+ PrismaPlanCatalogImportSink = _ts_decorate12([
2385
+ Injectable12(),
2386
+ _ts_param11(0, Inject11(PRISMA_CLIENT_TOKEN)),
2387
+ _ts_param11(1, Optional2()),
2388
+ _ts_param11(1, Inject11(PRISMA_SCHEMA_OPTIONS_TOKEN)),
2389
+ _ts_metadata11("design:type", Function),
2390
+ _ts_metadata11("design:paramtypes", [
2267
2391
  typeof PlanCatalogImportClient === "undefined" ? Object : PlanCatalogImportClient,
2268
2392
  typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
2269
2393
  ])
2270
2394
  ], PrismaPlanCatalogImportSink);
2271
2395
 
2272
2396
  // src/prisma-plan-catalog-read-sink.adapter.ts
2273
- import { Inject as Inject11, Injectable as Injectable12, Optional as Optional3 } from "@nestjs/common";
2397
+ import { Inject as Inject12, Injectable as Injectable13, Optional as Optional3 } from "@nestjs/common";
2274
2398
  import { toPlanRow, toPlanVersionRow } from "@saasicat/core";
2275
- function _ts_decorate12(decorators, target, key, desc) {
2399
+ function _ts_decorate13(decorators, target, key, desc) {
2276
2400
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2277
2401
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2278
2402
  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;
2279
2403
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2280
2404
  }
2281
- __name(_ts_decorate12, "_ts_decorate");
2282
- function _ts_metadata11(k, v) {
2405
+ __name(_ts_decorate13, "_ts_decorate");
2406
+ function _ts_metadata12(k, v) {
2283
2407
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2284
2408
  }
2285
- __name(_ts_metadata11, "_ts_metadata");
2286
- function _ts_param11(paramIndex, decorator) {
2409
+ __name(_ts_metadata12, "_ts_metadata");
2410
+ function _ts_param12(paramIndex, decorator) {
2287
2411
  return function(target, key) {
2288
2412
  decorator(target, key, paramIndex);
2289
2413
  };
2290
2414
  }
2291
- __name(_ts_param11, "_ts_param");
2415
+ __name(_ts_param12, "_ts_param");
2292
2416
  var PrismaPlanCatalogReadSink = class {
2293
2417
  static {
2294
2418
  __name(this, "PrismaPlanCatalogReadSink");
@@ -2377,13 +2501,13 @@ var PrismaPlanCatalogReadSink = class {
2377
2501
  return getPrismaDelegate(this.prisma, this.delegateName);
2378
2502
  }
2379
2503
  };
2380
- PrismaPlanCatalogReadSink = _ts_decorate12([
2381
- Injectable12(),
2382
- _ts_param11(0, Inject11(PRISMA_CLIENT_TOKEN)),
2383
- _ts_param11(1, Optional3()),
2384
- _ts_param11(1, Inject11(PRISMA_SCHEMA_OPTIONS_TOKEN)),
2385
- _ts_metadata11("design:type", Function),
2386
- _ts_metadata11("design:paramtypes", [
2504
+ PrismaPlanCatalogReadSink = _ts_decorate13([
2505
+ Injectable13(),
2506
+ _ts_param12(0, Inject12(PRISMA_CLIENT_TOKEN)),
2507
+ _ts_param12(1, Optional3()),
2508
+ _ts_param12(1, Inject12(PRISMA_SCHEMA_OPTIONS_TOKEN)),
2509
+ _ts_metadata12("design:type", Function),
2510
+ _ts_metadata12("design:paramtypes", [
2387
2511
  typeof PlanCatalogReadClient === "undefined" ? Object : PlanCatalogReadClient,
2388
2512
  typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
2389
2513
  ])
@@ -2417,26 +2541,26 @@ function toFeatureCatalogEntryRow(row) {
2417
2541
  __name(toFeatureCatalogEntryRow, "toFeatureCatalogEntryRow");
2418
2542
 
2419
2543
  // src/prisma-plan.repository.ts
2420
- import { Inject as Inject12, Injectable as Injectable13, Optional as Optional4 } from "@nestjs/common";
2544
+ import { Inject as Inject13, Injectable as Injectable14, Optional as Optional4 } from "@nestjs/common";
2421
2545
  import { buildActivePlanVersionWhere, definedFields as definedFields2 } from "@saasicat/core";
2422
2546
  import { previousUtcDay as previousUtcDay2, toPlanRow as toPlanRow2, toPlanVersionRow as toPlanVersionRow2 } from "@saasicat/core";
2423
- function _ts_decorate13(decorators, target, key, desc) {
2547
+ function _ts_decorate14(decorators, target, key, desc) {
2424
2548
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2425
2549
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2426
2550
  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;
2427
2551
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2428
2552
  }
2429
- __name(_ts_decorate13, "_ts_decorate");
2430
- function _ts_metadata12(k, v) {
2553
+ __name(_ts_decorate14, "_ts_decorate");
2554
+ function _ts_metadata13(k, v) {
2431
2555
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2432
2556
  }
2433
- __name(_ts_metadata12, "_ts_metadata");
2434
- function _ts_param12(paramIndex, decorator) {
2557
+ __name(_ts_metadata13, "_ts_metadata");
2558
+ function _ts_param13(paramIndex, decorator) {
2435
2559
  return function(target, key) {
2436
2560
  decorator(target, key, paramIndex);
2437
2561
  };
2438
2562
  }
2439
- __name(_ts_param12, "_ts_param");
2563
+ __name(_ts_param13, "_ts_param");
2440
2564
  var PrismaPlanRepository = class {
2441
2565
  static {
2442
2566
  __name(this, "PrismaPlanRepository");
@@ -2890,37 +3014,37 @@ var PrismaPlanRepository = class {
2890
3014
  return toPlanVersionRow2(row, planKey, this.fields);
2891
3015
  }
2892
3016
  };
2893
- PrismaPlanRepository = _ts_decorate13([
2894
- Injectable13(),
2895
- _ts_param12(0, Inject12(PRISMA_CLIENT_TOKEN)),
2896
- _ts_param12(1, Optional4()),
2897
- _ts_param12(1, Inject12(PRISMA_SCHEMA_OPTIONS_TOKEN)),
2898
- _ts_metadata12("design:type", Function),
2899
- _ts_metadata12("design:paramtypes", [
3017
+ PrismaPlanRepository = _ts_decorate14([
3018
+ Injectable14(),
3019
+ _ts_param13(0, Inject13(PRISMA_CLIENT_TOKEN)),
3020
+ _ts_param13(1, Optional4()),
3021
+ _ts_param13(1, Inject13(PRISMA_SCHEMA_OPTIONS_TOKEN)),
3022
+ _ts_metadata13("design:type", Function),
3023
+ _ts_metadata13("design:paramtypes", [
2900
3024
  typeof PlanRepositoryClient === "undefined" ? Object : PlanRepositoryClient,
2901
3025
  typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
2902
3026
  ])
2903
3027
  ], PrismaPlanRepository);
2904
3028
 
2905
3029
  // src/prisma-payment-event-log.adapter.ts
2906
- import { Inject as Inject13, Injectable as Injectable14 } from "@nestjs/common";
2907
- function _ts_decorate14(decorators, target, key, desc) {
3030
+ import { Inject as Inject14, Injectable as Injectable15 } from "@nestjs/common";
3031
+ function _ts_decorate15(decorators, target, key, desc) {
2908
3032
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2909
3033
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2910
3034
  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;
2911
3035
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2912
3036
  }
2913
- __name(_ts_decorate14, "_ts_decorate");
2914
- function _ts_metadata13(k, v) {
3037
+ __name(_ts_decorate15, "_ts_decorate");
3038
+ function _ts_metadata14(k, v) {
2915
3039
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2916
3040
  }
2917
- __name(_ts_metadata13, "_ts_metadata");
2918
- function _ts_param13(paramIndex, decorator) {
3041
+ __name(_ts_metadata14, "_ts_metadata");
3042
+ function _ts_param14(paramIndex, decorator) {
2919
3043
  return function(target, key) {
2920
3044
  decorator(target, key, paramIndex);
2921
3045
  };
2922
3046
  }
2923
- __name(_ts_param13, "_ts_param");
3047
+ __name(_ts_param14, "_ts_param");
2924
3048
  var PrismaPaymentEventLog = class {
2925
3049
  static {
2926
3050
  __name(this, "PrismaPaymentEventLog");
@@ -2959,35 +3083,35 @@ var PrismaPaymentEventLog = class {
2959
3083
  });
2960
3084
  }
2961
3085
  };
2962
- PrismaPaymentEventLog = _ts_decorate14([
2963
- Injectable14(),
2964
- _ts_param13(0, Inject13(PRISMA_CLIENT_TOKEN)),
2965
- _ts_metadata13("design:type", Function),
2966
- _ts_metadata13("design:paramtypes", [
3086
+ PrismaPaymentEventLog = _ts_decorate15([
3087
+ Injectable15(),
3088
+ _ts_param14(0, Inject14(PRISMA_CLIENT_TOKEN)),
3089
+ _ts_metadata14("design:type", Function),
3090
+ _ts_metadata14("design:paramtypes", [
2967
3091
  Object
2968
3092
  ])
2969
3093
  ], PrismaPaymentEventLog);
2970
3094
 
2971
3095
  // src/prisma-plan-version.repository.ts
2972
- import { Inject as Inject14, Injectable as Injectable15, Optional as Optional5 } from "@nestjs/common";
3096
+ import { Inject as Inject15, Injectable as Injectable16, Optional as Optional5 } from "@nestjs/common";
2973
3097
  import { buildActivePlanVersionWhere as buildActivePlanVersionWhere2 } from "@saasicat/core";
2974
- function _ts_decorate15(decorators, target, key, desc) {
3098
+ function _ts_decorate16(decorators, target, key, desc) {
2975
3099
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2976
3100
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2977
3101
  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;
2978
3102
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2979
3103
  }
2980
- __name(_ts_decorate15, "_ts_decorate");
2981
- function _ts_metadata14(k, v) {
3104
+ __name(_ts_decorate16, "_ts_decorate");
3105
+ function _ts_metadata15(k, v) {
2982
3106
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
2983
3107
  }
2984
- __name(_ts_metadata14, "_ts_metadata");
2985
- function _ts_param14(paramIndex, decorator) {
3108
+ __name(_ts_metadata15, "_ts_metadata");
3109
+ function _ts_param15(paramIndex, decorator) {
2986
3110
  return function(target, key) {
2987
3111
  decorator(target, key, paramIndex);
2988
3112
  };
2989
3113
  }
2990
- __name(_ts_param14, "_ts_param");
3114
+ __name(_ts_param15, "_ts_param");
2991
3115
  var PrismaPlanVersionRepository = class {
2992
3116
  static {
2993
3117
  __name(this, "PrismaPlanVersionRepository");
@@ -3067,37 +3191,37 @@ var PrismaPlanVersionRepository = class {
3067
3191
  };
3068
3192
  }
3069
3193
  };
3070
- PrismaPlanVersionRepository = _ts_decorate15([
3071
- Injectable15(),
3072
- _ts_param14(0, Inject14(PRISMA_CLIENT_TOKEN)),
3073
- _ts_param14(1, Optional5()),
3074
- _ts_param14(1, Inject14(PRISMA_SCHEMA_OPTIONS_TOKEN)),
3075
- _ts_metadata14("design:type", Function),
3076
- _ts_metadata14("design:paramtypes", [
3194
+ PrismaPlanVersionRepository = _ts_decorate16([
3195
+ Injectable16(),
3196
+ _ts_param15(0, Inject15(PRISMA_CLIENT_TOKEN)),
3197
+ _ts_param15(1, Optional5()),
3198
+ _ts_param15(1, Inject15(PRISMA_SCHEMA_OPTIONS_TOKEN)),
3199
+ _ts_metadata15("design:type", Function),
3200
+ _ts_metadata15("design:paramtypes", [
3077
3201
  typeof PlanVersionRepositoryClient === "undefined" ? Object : PlanVersionRepositoryClient,
3078
3202
  typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
3079
3203
  ])
3080
3204
  ], PrismaPlanVersionRepository);
3081
3205
 
3082
3206
  // src/prisma-promotion.repository.ts
3083
- import { Inject as Inject15, Injectable as Injectable16 } from "@nestjs/common";
3084
- function _ts_decorate16(decorators, target, key, desc) {
3207
+ import { Inject as Inject16, Injectable as Injectable17 } from "@nestjs/common";
3208
+ function _ts_decorate17(decorators, target, key, desc) {
3085
3209
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3086
3210
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3087
3211
  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;
3088
3212
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3089
3213
  }
3090
- __name(_ts_decorate16, "_ts_decorate");
3091
- function _ts_metadata15(k, v) {
3214
+ __name(_ts_decorate17, "_ts_decorate");
3215
+ function _ts_metadata16(k, v) {
3092
3216
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3093
3217
  }
3094
- __name(_ts_metadata15, "_ts_metadata");
3095
- function _ts_param15(paramIndex, decorator) {
3218
+ __name(_ts_metadata16, "_ts_metadata");
3219
+ function _ts_param16(paramIndex, decorator) {
3096
3220
  return function(target, key) {
3097
3221
  decorator(target, key, paramIndex);
3098
3222
  };
3099
3223
  }
3100
- __name(_ts_param15, "_ts_param");
3224
+ __name(_ts_param16, "_ts_param");
3101
3225
  var PrismaPromotionRepository = class {
3102
3226
  static {
3103
3227
  __name(this, "PrismaPromotionRepository");
@@ -3217,11 +3341,11 @@ var PrismaPromotionRepository = class {
3217
3341
  });
3218
3342
  }
3219
3343
  };
3220
- PrismaPromotionRepository = _ts_decorate16([
3221
- Injectable16(),
3222
- _ts_param15(0, Inject15(PRISMA_CLIENT_TOKEN)),
3223
- _ts_metadata15("design:type", Function),
3224
- _ts_metadata15("design:paramtypes", [
3344
+ PrismaPromotionRepository = _ts_decorate17([
3345
+ Injectable17(),
3346
+ _ts_param16(0, Inject16(PRISMA_CLIENT_TOKEN)),
3347
+ _ts_metadata16("design:type", Function),
3348
+ _ts_metadata16("design:paramtypes", [
3225
3349
  typeof PromotionRepositoryClient === "undefined" ? Object : PromotionRepositoryClient
3226
3350
  ])
3227
3351
  ], PrismaPromotionRepository);
@@ -3272,25 +3396,25 @@ function toRow3(row) {
3272
3396
  __name(toRow3, "toRow");
3273
3397
 
3274
3398
  // src/prisma-promo-code-hold.repository.ts
3275
- import { randomUUID } from "crypto";
3276
- import { Inject as Inject16, Injectable as Injectable17 } from "@nestjs/common";
3277
- function _ts_decorate17(decorators, target, key, desc) {
3399
+ import { randomUUID as randomUUID2 } from "crypto";
3400
+ import { Inject as Inject17, Injectable as Injectable18 } from "@nestjs/common";
3401
+ function _ts_decorate18(decorators, target, key, desc) {
3278
3402
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3279
3403
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3280
3404
  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;
3281
3405
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3282
3406
  }
3283
- __name(_ts_decorate17, "_ts_decorate");
3284
- function _ts_metadata16(k, v) {
3407
+ __name(_ts_decorate18, "_ts_decorate");
3408
+ function _ts_metadata17(k, v) {
3285
3409
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3286
3410
  }
3287
- __name(_ts_metadata16, "_ts_metadata");
3288
- function _ts_param16(paramIndex, decorator) {
3411
+ __name(_ts_metadata17, "_ts_metadata");
3412
+ function _ts_param17(paramIndex, decorator) {
3289
3413
  return function(target, key) {
3290
3414
  decorator(target, key, paramIndex);
3291
3415
  };
3292
3416
  }
3293
- __name(_ts_param16, "_ts_param");
3417
+ __name(_ts_param17, "_ts_param");
3294
3418
  var HOLD_COLUMNS = {
3295
3419
  id: true,
3296
3420
  promoCodeId: true,
@@ -3345,7 +3469,7 @@ var PrismaPromoCodeHoldRepository = class {
3345
3469
  };
3346
3470
  const created = await holdsOf(tx).create({
3347
3471
  data: {
3348
- id: randomUUID(),
3472
+ id: randomUUID2(),
3349
3473
  ...hold
3350
3474
  },
3351
3475
  select: HOLD_COLUMNS
@@ -3442,11 +3566,11 @@ var PrismaPromoCodeHoldRepository = class {
3442
3566
  return released === 1;
3443
3567
  }
3444
3568
  };
3445
- PrismaPromoCodeHoldRepository = _ts_decorate17([
3446
- Injectable17(),
3447
- _ts_param16(0, Inject16(PRISMA_CLIENT_TOKEN)),
3448
- _ts_metadata16("design:type", Function),
3449
- _ts_metadata16("design:paramtypes", [
3569
+ PrismaPromoCodeHoldRepository = _ts_decorate18([
3570
+ Injectable18(),
3571
+ _ts_param17(0, Inject17(PRISMA_CLIENT_TOKEN)),
3572
+ _ts_metadata17("design:type", Function),
3573
+ _ts_metadata17("design:paramtypes", [
3450
3574
  typeof PrismaLike === "undefined" ? Object : PrismaLike
3451
3575
  ])
3452
3576
  ], PrismaPromoCodeHoldRepository);
@@ -3456,24 +3580,24 @@ function holdsOf(client) {
3456
3580
  __name(holdsOf, "holdsOf");
3457
3581
 
3458
3582
  // src/prisma-promo-code-redemption.repository.ts
3459
- import { Inject as Inject17, Injectable as Injectable18 } from "@nestjs/common";
3460
- function _ts_decorate18(decorators, target, key, desc) {
3583
+ import { Inject as Inject18, Injectable as Injectable19 } from "@nestjs/common";
3584
+ function _ts_decorate19(decorators, target, key, desc) {
3461
3585
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3462
3586
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3463
3587
  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;
3464
3588
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3465
3589
  }
3466
- __name(_ts_decorate18, "_ts_decorate");
3467
- function _ts_metadata17(k, v) {
3590
+ __name(_ts_decorate19, "_ts_decorate");
3591
+ function _ts_metadata18(k, v) {
3468
3592
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3469
3593
  }
3470
- __name(_ts_metadata17, "_ts_metadata");
3471
- function _ts_param17(paramIndex, decorator) {
3594
+ __name(_ts_metadata18, "_ts_metadata");
3595
+ function _ts_param18(paramIndex, decorator) {
3472
3596
  return function(target, key) {
3473
3597
  decorator(target, key, paramIndex);
3474
3598
  };
3475
3599
  }
3476
- __name(_ts_param17, "_ts_param");
3600
+ __name(_ts_param18, "_ts_param");
3477
3601
  var PrismaPromoCodeRedemptionRepository = class {
3478
3602
  static {
3479
3603
  __name(this, "PrismaPromoCodeRedemptionRepository");
@@ -3555,11 +3679,11 @@ var PrismaPromoCodeRedemptionRepository = class {
3555
3679
  return result.count;
3556
3680
  }
3557
3681
  };
3558
- PrismaPromoCodeRedemptionRepository = _ts_decorate18([
3559
- Injectable18(),
3560
- _ts_param17(0, Inject17(PRISMA_CLIENT_TOKEN)),
3561
- _ts_metadata17("design:type", Function),
3562
- _ts_metadata17("design:paramtypes", [
3682
+ PrismaPromoCodeRedemptionRepository = _ts_decorate19([
3683
+ Injectable19(),
3684
+ _ts_param18(0, Inject18(PRISMA_CLIENT_TOKEN)),
3685
+ _ts_metadata18("design:type", Function),
3686
+ _ts_metadata18("design:paramtypes", [
3563
3687
  typeof PrismaLike === "undefined" ? Object : PrismaLike
3564
3688
  ])
3565
3689
  ], PrismaPromoCodeRedemptionRepository);
@@ -3583,24 +3707,24 @@ function toRecord(row) {
3583
3707
  __name(toRecord, "toRecord");
3584
3708
 
3585
3709
  // src/prisma-promo-code.repository.ts
3586
- import { Inject as Inject18, Injectable as Injectable19 } from "@nestjs/common";
3587
- function _ts_decorate19(decorators, target, key, desc) {
3710
+ import { Inject as Inject19, Injectable as Injectable20 } from "@nestjs/common";
3711
+ function _ts_decorate20(decorators, target, key, desc) {
3588
3712
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3589
3713
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3590
3714
  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;
3591
3715
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3592
3716
  }
3593
- __name(_ts_decorate19, "_ts_decorate");
3594
- function _ts_metadata18(k, v) {
3717
+ __name(_ts_decorate20, "_ts_decorate");
3718
+ function _ts_metadata19(k, v) {
3595
3719
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3596
3720
  }
3597
- __name(_ts_metadata18, "_ts_metadata");
3598
- function _ts_param18(paramIndex, decorator) {
3721
+ __name(_ts_metadata19, "_ts_metadata");
3722
+ function _ts_param19(paramIndex, decorator) {
3599
3723
  return function(target, key) {
3600
3724
  decorator(target, key, paramIndex);
3601
3725
  };
3602
3726
  }
3603
- __name(_ts_param18, "_ts_param");
3727
+ __name(_ts_param19, "_ts_param");
3604
3728
  var PrismaPromoCodeRepository = class {
3605
3729
  static {
3606
3730
  __name(this, "PrismaPromoCodeRepository");
@@ -3754,11 +3878,11 @@ var PrismaPromoCodeRepository = class {
3754
3878
  return result.count;
3755
3879
  }
3756
3880
  };
3757
- PrismaPromoCodeRepository = _ts_decorate19([
3758
- Injectable19(),
3759
- _ts_param18(0, Inject18(PRISMA_CLIENT_TOKEN)),
3760
- _ts_metadata18("design:type", Function),
3761
- _ts_metadata18("design:paramtypes", [
3881
+ PrismaPromoCodeRepository = _ts_decorate20([
3882
+ Injectable20(),
3883
+ _ts_param19(0, Inject19(PRISMA_CLIENT_TOKEN)),
3884
+ _ts_metadata19("design:type", Function),
3885
+ _ts_metadata19("design:paramtypes", [
3762
3886
  typeof PrismaLike === "undefined" ? Object : PrismaLike
3763
3887
  ])
3764
3888
  ], PrismaPromoCodeRepository);
@@ -3797,24 +3921,24 @@ function toRecord2(row) {
3797
3921
  __name(toRecord2, "toRecord");
3798
3922
 
3799
3923
  // src/prisma-promo-code-validation-log.repository.ts
3800
- import { Inject as Inject19, Injectable as Injectable20 } from "@nestjs/common";
3801
- function _ts_decorate20(decorators, target, key, desc) {
3924
+ import { Inject as Inject20, Injectable as Injectable21 } from "@nestjs/common";
3925
+ function _ts_decorate21(decorators, target, key, desc) {
3802
3926
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3803
3927
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3804
3928
  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;
3805
3929
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3806
3930
  }
3807
- __name(_ts_decorate20, "_ts_decorate");
3808
- function _ts_metadata19(k, v) {
3931
+ __name(_ts_decorate21, "_ts_decorate");
3932
+ function _ts_metadata20(k, v) {
3809
3933
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3810
3934
  }
3811
- __name(_ts_metadata19, "_ts_metadata");
3812
- function _ts_param19(paramIndex, decorator) {
3935
+ __name(_ts_metadata20, "_ts_metadata");
3936
+ function _ts_param20(paramIndex, decorator) {
3813
3937
  return function(target, key) {
3814
3938
  decorator(target, key, paramIndex);
3815
3939
  };
3816
3940
  }
3817
- __name(_ts_param19, "_ts_param");
3941
+ __name(_ts_param20, "_ts_param");
3818
3942
  var PrismaPromoCodeValidationLogRepository = class {
3819
3943
  static {
3820
3944
  __name(this, "PrismaPromoCodeValidationLogRepository");
@@ -3843,34 +3967,34 @@ var PrismaPromoCodeValidationLogRepository = class {
3843
3967
  });
3844
3968
  }
3845
3969
  };
3846
- PrismaPromoCodeValidationLogRepository = _ts_decorate20([
3847
- Injectable20(),
3848
- _ts_param19(0, Inject19(PRISMA_CLIENT_TOKEN)),
3849
- _ts_metadata19("design:type", Function),
3850
- _ts_metadata19("design:paramtypes", [
3970
+ PrismaPromoCodeValidationLogRepository = _ts_decorate21([
3971
+ Injectable21(),
3972
+ _ts_param20(0, Inject20(PRISMA_CLIENT_TOKEN)),
3973
+ _ts_metadata20("design:type", Function),
3974
+ _ts_metadata20("design:paramtypes", [
3851
3975
  typeof PrismaLike === "undefined" ? Object : PrismaLike
3852
3976
  ])
3853
3977
  ], PrismaPromoCodeValidationLogRepository);
3854
3978
 
3855
3979
  // src/prisma-promo-subscription-lookup.adapter.ts
3856
- import { Inject as Inject20, Injectable as Injectable21 } from "@nestjs/common";
3857
- function _ts_decorate21(decorators, target, key, desc) {
3980
+ import { Inject as Inject21, Injectable as Injectable22 } from "@nestjs/common";
3981
+ function _ts_decorate22(decorators, target, key, desc) {
3858
3982
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3859
3983
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3860
3984
  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;
3861
3985
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3862
3986
  }
3863
- __name(_ts_decorate21, "_ts_decorate");
3864
- function _ts_metadata20(k, v) {
3987
+ __name(_ts_decorate22, "_ts_decorate");
3988
+ function _ts_metadata21(k, v) {
3865
3989
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3866
3990
  }
3867
- __name(_ts_metadata20, "_ts_metadata");
3868
- function _ts_param20(paramIndex, decorator) {
3991
+ __name(_ts_metadata21, "_ts_metadata");
3992
+ function _ts_param21(paramIndex, decorator) {
3869
3993
  return function(target, key) {
3870
3994
  decorator(target, key, paramIndex);
3871
3995
  };
3872
3996
  }
3873
- __name(_ts_param20, "_ts_param");
3997
+ __name(_ts_param21, "_ts_param");
3874
3998
  var PrismaPromoSubscriptionLookup = class {
3875
3999
  static {
3876
4000
  __name(this, "PrismaPromoSubscriptionLookup");
@@ -3896,34 +4020,35 @@ var PrismaPromoSubscriptionLookup = class {
3896
4020
  };
3897
4021
  }
3898
4022
  };
3899
- PrismaPromoSubscriptionLookup = _ts_decorate21([
3900
- Injectable21(),
3901
- _ts_param20(0, Inject20(PRISMA_CLIENT_TOKEN)),
3902
- _ts_metadata20("design:type", Function),
3903
- _ts_metadata20("design:paramtypes", [
4023
+ PrismaPromoSubscriptionLookup = _ts_decorate22([
4024
+ Injectable22(),
4025
+ _ts_param21(0, Inject21(PRISMA_CLIENT_TOKEN)),
4026
+ _ts_metadata21("design:type", Function),
4027
+ _ts_metadata21("design:paramtypes", [
3904
4028
  typeof PrismaLike === "undefined" ? Object : PrismaLike
3905
4029
  ])
3906
4030
  ], PrismaPromoSubscriptionLookup);
3907
4031
 
3908
4032
  // src/prisma-subscription-bundle.repository.ts
3909
- import { Inject as Inject21, Injectable as Injectable22 } from "@nestjs/common";
3910
- function _ts_decorate22(decorators, target, key, desc) {
4033
+ import { Inject as Inject22, Injectable as Injectable23 } from "@nestjs/common";
4034
+ import { toSubscriptionBundleRecord } from "@saasicat/core";
4035
+ function _ts_decorate23(decorators, target, key, desc) {
3911
4036
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3912
4037
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
3913
4038
  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;
3914
4039
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3915
- }
3916
- __name(_ts_decorate22, "_ts_decorate");
3917
- function _ts_metadata21(k, v) {
4040
+ }
4041
+ __name(_ts_decorate23, "_ts_decorate");
4042
+ function _ts_metadata22(k, v) {
3918
4043
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
3919
4044
  }
3920
- __name(_ts_metadata21, "_ts_metadata");
3921
- function _ts_param21(paramIndex, decorator) {
4045
+ __name(_ts_metadata22, "_ts_metadata");
4046
+ function _ts_param22(paramIndex, decorator) {
3922
4047
  return function(target, key) {
3923
4048
  decorator(target, key, paramIndex);
3924
4049
  };
3925
4050
  }
3926
- __name(_ts_param21, "_ts_param");
4051
+ __name(_ts_param22, "_ts_param");
3927
4052
  var PrismaSubscriptionBundleRepository = class {
3928
4053
  static {
3929
4054
  __name(this, "PrismaSubscriptionBundleRepository");
@@ -3944,7 +4069,7 @@ var PrismaSubscriptionBundleRepository = class {
3944
4069
  startedAt: "desc"
3945
4070
  }
3946
4071
  });
3947
- return rows.map(toRecord3);
4072
+ return rows.map(toSubscriptionBundleRecord);
3948
4073
  }
3949
4074
  async findById(subscriptionBundleId) {
3950
4075
  const row = await this.db().subscriptionBundle.findUnique({
@@ -3952,7 +4077,7 @@ var PrismaSubscriptionBundleRepository = class {
3952
4077
  id: subscriptionBundleId
3953
4078
  }
3954
4079
  });
3955
- return row ? toRecord3(row) : null;
4080
+ return row ? toSubscriptionBundleRecord(row) : null;
3956
4081
  }
3957
4082
  async listActiveBySubscription(subscriptionId, asOf = /* @__PURE__ */ new Date(), tx) {
3958
4083
  const rows = await this.db(tx).subscriptionBundle.findMany({
@@ -3973,7 +4098,7 @@ var PrismaSubscriptionBundleRepository = class {
3973
4098
  startedAt: "desc"
3974
4099
  }
3975
4100
  });
3976
- return rows.map(toRecord3);
4101
+ return rows.map(toSubscriptionBundleRecord);
3977
4102
  }
3978
4103
  async add(data) {
3979
4104
  const row = await this.db().subscriptionBundle.create({
@@ -3987,7 +4112,7 @@ var PrismaSubscriptionBundleRepository = class {
3987
4112
  currentPeriodEnd: data.currentPeriodEnd ?? null
3988
4113
  }
3989
4114
  });
3990
- return toRecord3(row);
4115
+ return toSubscriptionBundleRecord(row);
3991
4116
  }
3992
4117
  async cancel(subscriptionBundleId, data) {
3993
4118
  const { count } = await this.db().subscriptionBundle.updateMany({
@@ -4009,7 +4134,7 @@ var PrismaSubscriptionBundleRepository = class {
4009
4134
  }
4010
4135
  });
4011
4136
  if (!row) throw new Error(`SubscriptionBundle '${subscriptionBundleId}' disappeared`);
4012
- return toRecord3(row);
4137
+ return toSubscriptionBundleRecord(row);
4013
4138
  }
4014
4139
  async reactivate(subscriptionBundleId) {
4015
4140
  const row = await this.db().subscriptionBundle.update({
@@ -4021,7 +4146,7 @@ var PrismaSubscriptionBundleRepository = class {
4021
4146
  canceledEffectiveAt: null
4022
4147
  }
4023
4148
  });
4024
- return toRecord3(row);
4149
+ return toSubscriptionBundleRecord(row);
4025
4150
  }
4026
4151
  async countActiveByBundleVersionId(bundleVersionId, asOf = /* @__PURE__ */ new Date()) {
4027
4152
  return this.db().subscriptionBundle.count({
@@ -4041,52 +4166,35 @@ var PrismaSubscriptionBundleRepository = class {
4041
4166
  });
4042
4167
  }
4043
4168
  };
4044
- PrismaSubscriptionBundleRepository = _ts_decorate22([
4045
- Injectable22(),
4046
- _ts_param21(0, Inject21(PRISMA_CLIENT_TOKEN)),
4047
- _ts_metadata21("design:type", Function),
4048
- _ts_metadata21("design:paramtypes", [
4169
+ PrismaSubscriptionBundleRepository = _ts_decorate23([
4170
+ Injectable23(),
4171
+ _ts_param22(0, Inject22(PRISMA_CLIENT_TOKEN)),
4172
+ _ts_metadata22("design:type", Function),
4173
+ _ts_metadata22("design:paramtypes", [
4049
4174
  typeof SubscriptionBundleClient === "undefined" ? Object : SubscriptionBundleClient
4050
4175
  ])
4051
4176
  ], PrismaSubscriptionBundleRepository);
4052
- function toRecord3(row) {
4053
- return {
4054
- id: row.id,
4055
- subscriptionId: row.subscriptionId,
4056
- bundleVersionId: row.bundleVersionId,
4057
- startedAt: row.startedAt,
4058
- minimumTermEndsAt: row.minimumTermEndsAt,
4059
- billingCycle: row.billingCycle ?? null,
4060
- currentPeriodStart: row.currentPeriodStart ?? null,
4061
- currentPeriodEnd: row.currentPeriodEnd ?? null,
4062
- canceledAt: row.canceledAt,
4063
- canceledEffectiveAt: row.canceledEffectiveAt,
4064
- createdAt: row.createdAt,
4065
- updatedAt: row.updatedAt
4066
- };
4067
- }
4068
- __name(toRecord3, "toRecord");
4069
4177
 
4070
4178
  // src/prisma-subscription-contract.repository.ts
4071
- import { Inject as Inject22, Injectable as Injectable23 } from "@nestjs/common";
4179
+ import { Inject as Inject23, Injectable as Injectable24 } from "@nestjs/common";
4072
4180
  import { ACTIVE_SUBSCRIPTION_CONTRACT_STATUSES, toRunningContractIssuer, toSubscriptionContractRecord } from "@saasicat/core";
4073
- function _ts_decorate23(decorators, target, key, desc) {
4181
+ function _ts_decorate24(decorators, target, key, desc) {
4074
4182
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4075
4183
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4076
4184
  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;
4077
4185
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4078
4186
  }
4079
- __name(_ts_decorate23, "_ts_decorate");
4080
- function _ts_metadata22(k, v) {
4187
+ __name(_ts_decorate24, "_ts_decorate");
4188
+ function _ts_metadata23(k, v) {
4081
4189
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4082
4190
  }
4083
- __name(_ts_metadata22, "_ts_metadata");
4084
- function _ts_param22(paramIndex, decorator) {
4191
+ __name(_ts_metadata23, "_ts_metadata");
4192
+ function _ts_param23(paramIndex, decorator) {
4085
4193
  return function(target, key) {
4086
4194
  decorator(target, key, paramIndex);
4087
4195
  };
4088
4196
  }
4089
- __name(_ts_param22, "_ts_param");
4197
+ __name(_ts_param23, "_ts_param");
4090
4198
  var PrismaSubscriptionContractRepository = class {
4091
4199
  static {
4092
4200
  __name(this, "PrismaSubscriptionContractRepository");
@@ -4210,6 +4318,7 @@ var PrismaSubscriptionContractRepository = class {
4210
4318
  tenantId: data.tenantId,
4211
4319
  subscriberId: data.parties.subscriberId,
4212
4320
  subscriberSnapshot: data.parties.subscriber,
4321
+ partiesMigrated: data.partiesMigrated ?? false,
4213
4322
  status: data.status ?? "active",
4214
4323
  effectiveFrom: data.effectiveFrom,
4215
4324
  effectiveUntil: data.effectiveUntil ?? null,
@@ -4314,12 +4423,40 @@ var PrismaSubscriptionContractRepository = class {
4314
4423
  });
4315
4424
  return toSubscriptionContractRecord(row, row.lineItems);
4316
4425
  }
4426
+ async supersede(contractId, data, tx) {
4427
+ const db = this.db(tx);
4428
+ const { count } = await db.subscriptionContract.updateMany({
4429
+ where: {
4430
+ id: contractId,
4431
+ status: {
4432
+ in: [
4433
+ ...ACTIVE_SUBSCRIPTION_CONTRACT_STATUSES
4434
+ ]
4435
+ },
4436
+ effectiveUntil: data.readEffectiveUntil
4437
+ },
4438
+ data: {
4439
+ effectiveUntil: data.at,
4440
+ status: "superseded"
4441
+ }
4442
+ });
4443
+ if (count === 0) return null;
4444
+ const row = await db.subscriptionContract.findUnique({
4445
+ where: {
4446
+ id: contractId
4447
+ },
4448
+ include: {
4449
+ lineItems: true
4450
+ }
4451
+ });
4452
+ return row ? toSubscriptionContractRecord(row, row.lineItems) : null;
4453
+ }
4317
4454
  };
4318
- PrismaSubscriptionContractRepository = _ts_decorate23([
4319
- Injectable23(),
4320
- _ts_param22(0, Inject22(PRISMA_CLIENT_TOKEN)),
4321
- _ts_metadata22("design:type", Function),
4322
- _ts_metadata22("design:paramtypes", [
4455
+ PrismaSubscriptionContractRepository = _ts_decorate24([
4456
+ Injectable24(),
4457
+ _ts_param23(0, Inject23(PRISMA_CLIENT_TOKEN)),
4458
+ _ts_metadata23("design:type", Function),
4459
+ _ts_metadata23("design:paramtypes", [
4323
4460
  typeof PrismaLike === "undefined" ? Object : PrismaLike
4324
4461
  ])
4325
4462
  ], PrismaSubscriptionContractRepository);
@@ -4348,26 +4485,104 @@ function toLineItemCreate(item) {
4348
4485
  }
4349
4486
  __name(toLineItemCreate, "toLineItemCreate");
4350
4487
 
4488
+ // src/prisma-subscriber-ledger.repository.ts
4489
+ import { Inject as Inject24, Injectable as Injectable25 } from "@nestjs/common";
4490
+ import { subscriberChargeColumns, toSubscriberChargeRecord } from "@saasicat/core";
4491
+ function _ts_decorate25(decorators, target, key, desc) {
4492
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4493
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4494
+ 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;
4495
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
4496
+ }
4497
+ __name(_ts_decorate25, "_ts_decorate");
4498
+ function _ts_metadata24(k, v) {
4499
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4500
+ }
4501
+ __name(_ts_metadata24, "_ts_metadata");
4502
+ function _ts_param24(paramIndex, decorator) {
4503
+ return function(target, key) {
4504
+ decorator(target, key, paramIndex);
4505
+ };
4506
+ }
4507
+ __name(_ts_param24, "_ts_param");
4508
+ var PrismaSubscriberLedgerRepository = class {
4509
+ static {
4510
+ __name(this, "PrismaSubscriberLedgerRepository");
4511
+ }
4512
+ prisma;
4513
+ constructor(prisma) {
4514
+ this.prisma = prisma;
4515
+ }
4516
+ db(tx) {
4517
+ return tx ?? this.prisma;
4518
+ }
4519
+ /**
4520
+ * One statement, `skipDuplicates` being `ON CONFLICT DO NOTHING`: a charge
4521
+ * another caller wrote first — committed or still in flight — is waited for
4522
+ * and skipped rather than raised, and only what this call wrote comes back.
4523
+ * It names no conflict target, so it suppresses every unique key; the only
4524
+ * one besides the natural key is the primary key, a uuid made per row here.
4525
+ */
4526
+ async recordCharges(charges, tx) {
4527
+ if (charges.length === 0) return [];
4528
+ const rows = await this.db(tx).subscriberLedgerEntry.createManyAndReturn({
4529
+ data: charges.map(subscriberChargeColumns),
4530
+ skipDuplicates: true
4531
+ });
4532
+ return rows.map(toSubscriberChargeRecord);
4533
+ }
4534
+ async listBySubscription(subscriptionId, tx) {
4535
+ const rows = await this.db(tx).subscriberLedgerEntry.findMany({
4536
+ where: {
4537
+ subscriptionId
4538
+ },
4539
+ orderBy: [
4540
+ {
4541
+ periodStart: "asc"
4542
+ },
4543
+ {
4544
+ source: "asc"
4545
+ },
4546
+ {
4547
+ sourceRef: "asc"
4548
+ },
4549
+ {
4550
+ origin: "asc"
4551
+ }
4552
+ ]
4553
+ });
4554
+ return rows.map(toSubscriberChargeRecord);
4555
+ }
4556
+ };
4557
+ PrismaSubscriberLedgerRepository = _ts_decorate25([
4558
+ Injectable25(),
4559
+ _ts_param24(0, Inject24(PRISMA_CLIENT_TOKEN)),
4560
+ _ts_metadata24("design:type", Function),
4561
+ _ts_metadata24("design:paramtypes", [
4562
+ typeof LedgerClient === "undefined" ? Object : LedgerClient
4563
+ ])
4564
+ ], PrismaSubscriberLedgerRepository);
4565
+
4351
4566
  // src/prisma-subscriber-payment-method.repository.ts
4352
- import { Inject as Inject23, Injectable as Injectable24 } from "@nestjs/common";
4567
+ import { Inject as Inject25, Injectable as Injectable26 } from "@nestjs/common";
4353
4568
  import { ForeignPaymentMethodReferenceError, refuseForeignPaymentMethodReference, subscriberPaymentMethodColumns, toSubscriberPaymentMethodRecord } from "@saasicat/core";
4354
- function _ts_decorate24(decorators, target, key, desc) {
4569
+ function _ts_decorate26(decorators, target, key, desc) {
4355
4570
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4356
4571
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4357
4572
  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;
4358
4573
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4359
4574
  }
4360
- __name(_ts_decorate24, "_ts_decorate");
4361
- function _ts_metadata23(k, v) {
4575
+ __name(_ts_decorate26, "_ts_decorate");
4576
+ function _ts_metadata25(k, v) {
4362
4577
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4363
4578
  }
4364
- __name(_ts_metadata23, "_ts_metadata");
4365
- function _ts_param23(paramIndex, decorator) {
4579
+ __name(_ts_metadata25, "_ts_metadata");
4580
+ function _ts_param25(paramIndex, decorator) {
4366
4581
  return function(target, key) {
4367
4582
  decorator(target, key, paramIndex);
4368
4583
  };
4369
4584
  }
4370
- __name(_ts_param23, "_ts_param");
4585
+ __name(_ts_param25, "_ts_param");
4371
4586
  var PrismaSubscriberPaymentMethodRepository = class {
4372
4587
  static {
4373
4588
  __name(this, "PrismaSubscriberPaymentMethodRepository");
@@ -4570,35 +4785,35 @@ var PrismaSubscriberPaymentMethodRepository = class {
4570
4785
  return count === 1;
4571
4786
  }
4572
4787
  };
4573
- PrismaSubscriberPaymentMethodRepository = _ts_decorate24([
4574
- Injectable24(),
4575
- _ts_param23(0, Inject23(PRISMA_CLIENT_TOKEN)),
4576
- _ts_metadata23("design:type", Function),
4577
- _ts_metadata23("design:paramtypes", [
4788
+ PrismaSubscriberPaymentMethodRepository = _ts_decorate26([
4789
+ Injectable26(),
4790
+ _ts_param25(0, Inject25(PRISMA_CLIENT_TOKEN)),
4791
+ _ts_metadata25("design:type", Function),
4792
+ _ts_metadata25("design:paramtypes", [
4578
4793
  typeof PaymentMethodRepositoryClient === "undefined" ? Object : PaymentMethodRepositoryClient
4579
4794
  ])
4580
4795
  ], PrismaSubscriberPaymentMethodRepository);
4581
4796
 
4582
4797
  // src/prisma-subscriber.repository.ts
4583
- import { Inject as Inject24, Injectable as Injectable25 } from "@nestjs/common";
4798
+ import { Inject as Inject26, Injectable as Injectable27 } from "@nestjs/common";
4584
4799
  import { identityCorrectionDelta, toSubscriberCorrectionRecord, toSubscriberRecord } from "@saasicat/core";
4585
- function _ts_decorate25(decorators, target, key, desc) {
4800
+ function _ts_decorate27(decorators, target, key, desc) {
4586
4801
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4587
4802
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4588
4803
  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;
4589
4804
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4590
4805
  }
4591
- __name(_ts_decorate25, "_ts_decorate");
4592
- function _ts_metadata24(k, v) {
4806
+ __name(_ts_decorate27, "_ts_decorate");
4807
+ function _ts_metadata26(k, v) {
4593
4808
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4594
4809
  }
4595
- __name(_ts_metadata24, "_ts_metadata");
4596
- function _ts_param24(paramIndex, decorator) {
4810
+ __name(_ts_metadata26, "_ts_metadata");
4811
+ function _ts_param26(paramIndex, decorator) {
4597
4812
  return function(target, key) {
4598
4813
  decorator(target, key, paramIndex);
4599
4814
  };
4600
4815
  }
4601
- __name(_ts_param24, "_ts_param");
4816
+ __name(_ts_param26, "_ts_param");
4602
4817
  var WITH_LIVE_TENANT = {
4603
4818
  tenants: {
4604
4819
  where: {
@@ -4659,7 +4874,7 @@ var PrismaSubscriberRepository = class {
4659
4874
  },
4660
4875
  include: WITH_LIVE_TENANT
4661
4876
  });
4662
- return row ? toRecord4(row) : null;
4877
+ return row ? toRecord3(row) : null;
4663
4878
  }
4664
4879
  async findByTenantId(tenantId, tx) {
4665
4880
  const row = await this.db(tx).subscriber.findFirst({
@@ -4698,7 +4913,7 @@ var PrismaSubscriberRepository = class {
4698
4913
  const delta = identityCorrectionDelta(current, data.corrected);
4699
4914
  if (Object.keys(delta.corrected).length === 0) {
4700
4915
  return {
4701
- subscriber: toRecord4(current),
4916
+ subscriber: toRecord3(current),
4702
4917
  correction: null
4703
4918
  };
4704
4919
  }
@@ -4720,7 +4935,7 @@ var PrismaSubscriberRepository = class {
4720
4935
  }
4721
4936
  });
4722
4937
  return {
4723
- subscriber: toRecord4(updated),
4938
+ subscriber: toRecord3(updated),
4724
4939
  correction: toSubscriberCorrectionRecord(correction)
4725
4940
  };
4726
4941
  });
@@ -4742,38 +4957,38 @@ var PrismaSubscriberRepository = class {
4742
4957
  return rows.map(toSubscriberCorrectionRecord);
4743
4958
  }
4744
4959
  };
4745
- PrismaSubscriberRepository = _ts_decorate25([
4746
- Injectable25(),
4747
- _ts_param24(0, Inject24(PRISMA_CLIENT_TOKEN)),
4748
- _ts_metadata24("design:type", Function),
4749
- _ts_metadata24("design:paramtypes", [
4960
+ PrismaSubscriberRepository = _ts_decorate27([
4961
+ Injectable27(),
4962
+ _ts_param26(0, Inject26(PRISMA_CLIENT_TOKEN)),
4963
+ _ts_metadata26("design:type", Function),
4964
+ _ts_metadata26("design:paramtypes", [
4750
4965
  typeof SubscriberRepositoryClient === "undefined" ? Object : SubscriberRepositoryClient
4751
4966
  ])
4752
4967
  ], PrismaSubscriberRepository);
4753
- function toRecord4(row) {
4968
+ function toRecord3(row) {
4754
4969
  return toSubscriberRecord(row, row.tenants?.[0]?.tenantId ?? null);
4755
4970
  }
4756
- __name(toRecord4, "toRecord");
4971
+ __name(toRecord3, "toRecord");
4757
4972
 
4758
4973
  // src/prisma-subscription.repository.ts
4759
- import { Inject as Inject25, Injectable as Injectable26, Optional as Optional6 } from "@nestjs/common";
4760
- function _ts_decorate26(decorators, target, key, desc) {
4974
+ import { Inject as Inject27, Injectable as Injectable28, Optional as Optional6 } from "@nestjs/common";
4975
+ function _ts_decorate28(decorators, target, key, desc) {
4761
4976
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4762
4977
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4763
4978
  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;
4764
4979
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4765
4980
  }
4766
- __name(_ts_decorate26, "_ts_decorate");
4767
- function _ts_metadata25(k, v) {
4981
+ __name(_ts_decorate28, "_ts_decorate");
4982
+ function _ts_metadata27(k, v) {
4768
4983
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4769
4984
  }
4770
- __name(_ts_metadata25, "_ts_metadata");
4771
- function _ts_param25(paramIndex, decorator) {
4985
+ __name(_ts_metadata27, "_ts_metadata");
4986
+ function _ts_param27(paramIndex, decorator) {
4772
4987
  return function(target, key) {
4773
4988
  decorator(target, key, paramIndex);
4774
4989
  };
4775
4990
  }
4776
- __name(_ts_param25, "_ts_param");
4991
+ __name(_ts_param27, "_ts_param");
4777
4992
  var ACTIVE_STATUSES = [
4778
4993
  "ACTIVE",
4779
4994
  "TRIAL"
@@ -5008,37 +5223,37 @@ var PrismaSubscriptionRepository = class {
5008
5223
  ]));
5009
5224
  }
5010
5225
  };
5011
- PrismaSubscriptionRepository = _ts_decorate26([
5012
- Injectable26(),
5013
- _ts_param25(0, Inject25(PRISMA_CLIENT_TOKEN)),
5014
- _ts_param25(1, Optional6()),
5015
- _ts_param25(1, Inject25(PRISMA_SCHEMA_OPTIONS_TOKEN)),
5016
- _ts_metadata25("design:type", Function),
5017
- _ts_metadata25("design:paramtypes", [
5226
+ PrismaSubscriptionRepository = _ts_decorate28([
5227
+ Injectable28(),
5228
+ _ts_param27(0, Inject27(PRISMA_CLIENT_TOKEN)),
5229
+ _ts_param27(1, Optional6()),
5230
+ _ts_param27(1, Inject27(PRISMA_SCHEMA_OPTIONS_TOKEN)),
5231
+ _ts_metadata27("design:type", Function),
5232
+ _ts_metadata27("design:paramtypes", [
5018
5233
  typeof SubscriptionRepositoryClient === "undefined" ? Object : SubscriptionRepositoryClient,
5019
5234
  typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
5020
5235
  ])
5021
5236
  ], PrismaSubscriptionRepository);
5022
5237
 
5023
5238
  // src/prisma-subscription-usage.adapter.ts
5024
- import { Inject as Inject26, Injectable as Injectable27, Optional as Optional7 } from "@nestjs/common";
5025
- function _ts_decorate27(decorators, target, key, desc) {
5239
+ import { Inject as Inject28, Injectable as Injectable29, Optional as Optional7 } from "@nestjs/common";
5240
+ function _ts_decorate29(decorators, target, key, desc) {
5026
5241
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5027
5242
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5028
5243
  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;
5029
5244
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5030
5245
  }
5031
- __name(_ts_decorate27, "_ts_decorate");
5032
- function _ts_metadata26(k, v) {
5246
+ __name(_ts_decorate29, "_ts_decorate");
5247
+ function _ts_metadata28(k, v) {
5033
5248
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
5034
5249
  }
5035
- __name(_ts_metadata26, "_ts_metadata");
5036
- function _ts_param26(paramIndex, decorator) {
5250
+ __name(_ts_metadata28, "_ts_metadata");
5251
+ function _ts_param28(paramIndex, decorator) {
5037
5252
  return function(target, key) {
5038
5253
  decorator(target, key, paramIndex);
5039
5254
  };
5040
5255
  }
5041
- __name(_ts_param26, "_ts_param");
5256
+ __name(_ts_param28, "_ts_param");
5042
5257
  var PrismaSubscriptionUsageAdapter = class {
5043
5258
  static {
5044
5259
  __name(this, "PrismaSubscriptionUsageAdapter");
@@ -5129,38 +5344,38 @@ var PrismaSubscriptionUsageAdapter = class {
5129
5344
  return getPrismaDelegate(this.prisma, this.planVersionDelegateName);
5130
5345
  }
5131
5346
  };
5132
- PrismaSubscriptionUsageAdapter = _ts_decorate27([
5133
- Injectable27(),
5134
- _ts_param26(0, Inject26(PRISMA_CLIENT_TOKEN)),
5135
- _ts_param26(1, Optional7()),
5136
- _ts_param26(1, Inject26(PRISMA_SCHEMA_OPTIONS_TOKEN)),
5137
- _ts_metadata26("design:type", Function),
5138
- _ts_metadata26("design:paramtypes", [
5347
+ PrismaSubscriptionUsageAdapter = _ts_decorate29([
5348
+ Injectable29(),
5349
+ _ts_param28(0, Inject28(PRISMA_CLIENT_TOKEN)),
5350
+ _ts_param28(1, Optional7()),
5351
+ _ts_param28(1, Inject28(PRISMA_SCHEMA_OPTIONS_TOKEN)),
5352
+ _ts_metadata28("design:type", Function),
5353
+ _ts_metadata28("design:paramtypes", [
5139
5354
  typeof SubscriptionUsageClient === "undefined" ? Object : SubscriptionUsageClient,
5140
5355
  typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
5141
5356
  ])
5142
5357
  ], PrismaSubscriptionUsageAdapter);
5143
5358
 
5144
5359
  // src/prisma-super-admin-bootstrap.adapter.ts
5145
- import { Inject as Inject27, Injectable as Injectable28 } from "@nestjs/common";
5360
+ import { Inject as Inject29, Injectable as Injectable30 } from "@nestjs/common";
5146
5361
  import { PlatformUserExistsError } from "@saasicat/core";
5147
- function _ts_decorate28(decorators, target, key, desc) {
5362
+ function _ts_decorate30(decorators, target, key, desc) {
5148
5363
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5149
5364
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5150
5365
  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;
5151
5366
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5152
5367
  }
5153
- __name(_ts_decorate28, "_ts_decorate");
5154
- function _ts_metadata27(k, v) {
5368
+ __name(_ts_decorate30, "_ts_decorate");
5369
+ function _ts_metadata29(k, v) {
5155
5370
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
5156
5371
  }
5157
- __name(_ts_metadata27, "_ts_metadata");
5158
- function _ts_param27(paramIndex, decorator) {
5372
+ __name(_ts_metadata29, "_ts_metadata");
5373
+ function _ts_param29(paramIndex, decorator) {
5159
5374
  return function(target, key) {
5160
5375
  decorator(target, key, paramIndex);
5161
5376
  };
5162
5377
  }
5163
- __name(_ts_param27, "_ts_param");
5378
+ __name(_ts_param29, "_ts_param");
5164
5379
  var PASSWORD_HASHER_TOKEN = /* @__PURE__ */ Symbol.for("saasicat/adapter-prisma/PasswordHasher");
5165
5380
  var PrismaSuperAdminBootstrapAdapter = class {
5166
5381
  static {
@@ -5210,37 +5425,37 @@ var PrismaSuperAdminBootstrapAdapter = class {
5210
5425
  };
5211
5426
  }
5212
5427
  };
5213
- PrismaSuperAdminBootstrapAdapter = _ts_decorate28([
5214
- Injectable28(),
5215
- _ts_param27(0, Inject27(PRISMA_CLIENT_TOKEN)),
5216
- _ts_param27(1, Inject27(PASSWORD_HASHER_TOKEN)),
5217
- _ts_metadata27("design:type", Function),
5218
- _ts_metadata27("design:paramtypes", [
5428
+ PrismaSuperAdminBootstrapAdapter = _ts_decorate30([
5429
+ Injectable30(),
5430
+ _ts_param29(0, Inject29(PRISMA_CLIENT_TOKEN)),
5431
+ _ts_param29(1, Inject29(PASSWORD_HASHER_TOKEN)),
5432
+ _ts_metadata29("design:type", Function),
5433
+ _ts_metadata29("design:paramtypes", [
5219
5434
  typeof PrismaLike === "undefined" ? Object : PrismaLike,
5220
5435
  typeof PasswordHasher === "undefined" ? Object : PasswordHasher
5221
5436
  ])
5222
5437
  ], PrismaSuperAdminBootstrapAdapter);
5223
5438
 
5224
5439
  // src/prisma-tenant-subscription-write.adapter.ts
5225
- import { Inject as Inject28, Injectable as Injectable29, Optional as Optional8 } from "@nestjs/common";
5440
+ import { Inject as Inject30, Injectable as Injectable31, Optional as Optional8 } from "@nestjs/common";
5226
5441
  import { buildActivePlanVersionWhere as buildActivePlanVersionWhere3 } from "@saasicat/core";
5227
- function _ts_decorate29(decorators, target, key, desc) {
5442
+ function _ts_decorate31(decorators, target, key, desc) {
5228
5443
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5229
5444
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5230
5445
  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;
5231
5446
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5232
5447
  }
5233
- __name(_ts_decorate29, "_ts_decorate");
5234
- function _ts_metadata28(k, v) {
5448
+ __name(_ts_decorate31, "_ts_decorate");
5449
+ function _ts_metadata30(k, v) {
5235
5450
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
5236
5451
  }
5237
- __name(_ts_metadata28, "_ts_metadata");
5238
- function _ts_param28(paramIndex, decorator) {
5452
+ __name(_ts_metadata30, "_ts_metadata");
5453
+ function _ts_param30(paramIndex, decorator) {
5239
5454
  return function(target, key) {
5240
5455
  decorator(target, key, paramIndex);
5241
5456
  };
5242
5457
  }
5243
- __name(_ts_param28, "_ts_param");
5458
+ __name(_ts_param30, "_ts_param");
5244
5459
  var PrismaTenantSubscriptionWriteAdapter = class {
5245
5460
  static {
5246
5461
  __name(this, "PrismaTenantSubscriptionWriteAdapter");
@@ -5597,13 +5812,13 @@ var PrismaTenantSubscriptionWriteAdapter = class {
5597
5812
  }
5598
5813
  }
5599
5814
  };
5600
- PrismaTenantSubscriptionWriteAdapter = _ts_decorate29([
5601
- Injectable29(),
5602
- _ts_param28(0, Inject28(PRISMA_CLIENT_TOKEN)),
5603
- _ts_param28(1, Optional8()),
5604
- _ts_param28(1, Inject28(PRISMA_SCHEMA_OPTIONS_TOKEN)),
5605
- _ts_metadata28("design:type", Function),
5606
- _ts_metadata28("design:paramtypes", [
5815
+ PrismaTenantSubscriptionWriteAdapter = _ts_decorate31([
5816
+ Injectable31(),
5817
+ _ts_param30(0, Inject30(PRISMA_CLIENT_TOKEN)),
5818
+ _ts_param30(1, Optional8()),
5819
+ _ts_param30(1, Inject30(PRISMA_SCHEMA_OPTIONS_TOKEN)),
5820
+ _ts_metadata30("design:type", Function),
5821
+ _ts_metadata30("design:paramtypes", [
5607
5822
  typeof TransactionalPrismaClient === "undefined" ? Object : TransactionalPrismaClient,
5608
5823
  typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
5609
5824
  ])
@@ -5622,24 +5837,24 @@ function clearedPendingVersionData() {
5622
5837
  __name(clearedPendingVersionData, "clearedPendingVersionData");
5623
5838
 
5624
5839
  // src/prisma-transaction-runner.adapter.ts
5625
- import { Inject as Inject29, Injectable as Injectable30 } from "@nestjs/common";
5626
- function _ts_decorate30(decorators, target, key, desc) {
5840
+ import { Inject as Inject31, Injectable as Injectable32 } from "@nestjs/common";
5841
+ function _ts_decorate32(decorators, target, key, desc) {
5627
5842
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5628
5843
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5629
5844
  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;
5630
5845
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5631
5846
  }
5632
- __name(_ts_decorate30, "_ts_decorate");
5633
- function _ts_metadata29(k, v) {
5847
+ __name(_ts_decorate32, "_ts_decorate");
5848
+ function _ts_metadata31(k, v) {
5634
5849
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
5635
5850
  }
5636
- __name(_ts_metadata29, "_ts_metadata");
5637
- function _ts_param29(paramIndex, decorator) {
5851
+ __name(_ts_metadata31, "_ts_metadata");
5852
+ function _ts_param31(paramIndex, decorator) {
5638
5853
  return function(target, key) {
5639
5854
  decorator(target, key, paramIndex);
5640
5855
  };
5641
5856
  }
5642
- __name(_ts_param29, "_ts_param");
5857
+ __name(_ts_param31, "_ts_param");
5643
5858
  var PrismaTransactionRunner = class {
5644
5859
  static {
5645
5860
  __name(this, "PrismaTransactionRunner");
@@ -5653,24 +5868,24 @@ var PrismaTransactionRunner = class {
5653
5868
  return transaction((tx) => fn(tx));
5654
5869
  }
5655
5870
  };
5656
- PrismaTransactionRunner = _ts_decorate30([
5657
- Injectable30(),
5658
- _ts_param29(0, Inject29(PRISMA_CLIENT_TOKEN)),
5659
- _ts_metadata29("design:type", Function),
5660
- _ts_metadata29("design:paramtypes", [
5871
+ PrismaTransactionRunner = _ts_decorate32([
5872
+ Injectable32(),
5873
+ _ts_param31(0, Inject31(PRISMA_CLIENT_TOKEN)),
5874
+ _ts_metadata31("design:type", Function),
5875
+ _ts_metadata31("design:paramtypes", [
5661
5876
  typeof Record === "undefined" ? Object : Record
5662
5877
  ])
5663
5878
  ], PrismaTransactionRunner);
5664
5879
 
5665
5880
  // src/zero-promo-revenue-aggregator.adapter.ts
5666
- import { Injectable as Injectable31 } from "@nestjs/common";
5667
- function _ts_decorate31(decorators, target, key, desc) {
5881
+ import { Injectable as Injectable33 } from "@nestjs/common";
5882
+ function _ts_decorate33(decorators, target, key, desc) {
5668
5883
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5669
5884
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5670
5885
  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;
5671
5886
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5672
5887
  }
5673
- __name(_ts_decorate31, "_ts_decorate");
5888
+ __name(_ts_decorate33, "_ts_decorate");
5674
5889
  var ZeroPromoRevenueDeductionAggregator = class {
5675
5890
  static {
5676
5891
  __name(this, "ZeroPromoRevenueDeductionAggregator");
@@ -5679,8 +5894,8 @@ var ZeroPromoRevenueDeductionAggregator = class {
5679
5894
  return "0.00";
5680
5895
  }
5681
5896
  };
5682
- ZeroPromoRevenueDeductionAggregator = _ts_decorate31([
5683
- Injectable31()
5897
+ ZeroPromoRevenueDeductionAggregator = _ts_decorate33([
5898
+ Injectable33()
5684
5899
  ], ZeroPromoRevenueDeductionAggregator);
5685
5900
 
5686
5901
  // src/prisma-persistence.ts
@@ -5707,13 +5922,16 @@ function prismaPersistence(options) {
5707
5922
  auditQuery: provide((prisma) => new PrismaAuditQueryAdapter(prisma)),
5708
5923
  auditStats: provide((prisma) => new PrismaAuditStatsAdapter(prisma)),
5709
5924
  superAdminProvisioning: buildProvisioning(client, options.passwordHasher),
5710
- appliedSettings: provide((prisma) => new PrismaAppliedSettingsRepository(canonical(prisma)))
5925
+ appliedSettings: provide((prisma) => new PrismaAppliedSettingsRepository(canonical(prisma))),
5926
+ maintenanceWindows: provide((prisma) => new PrismaMaintenanceWindowRepository(canonical(prisma)))
5711
5927
  },
5712
5928
  entitlement: {
5713
5929
  subscriptionRepository: provide((prisma) => new PrismaSubscriptionRepository(prisma, options.schema)),
5714
5930
  planVersionRepository: provide((prisma) => new PrismaPlanVersionRepository(prisma, options.schema)),
5715
5931
  subscriptionContractRepository: provide((prisma) => new PrismaSubscriptionContractRepository(prisma)),
5716
5932
  subscriberRepository: provide((prisma) => new PrismaSubscriberRepository(canonical(prisma))),
5933
+ // The charges those contracts give rise to, written once each.
5934
+ subscriberLedgerRepository: provide((prisma) => new PrismaSubscriberLedgerRepository(canonical(prisma))),
5717
5935
  subscriptionBundleRepository: provide((prisma) => new PrismaSubscriptionBundleRepository(canonical(prisma))),
5718
5936
  bundleRepository: provide((prisma) => new PrismaBundleRepository(canonical(prisma), options.bundle))
5719
5937
  },
@@ -5803,6 +6021,7 @@ export {
5803
6021
  PrismaAuditStatsAdapter,
5804
6022
  PrismaBundleRepository,
5805
6023
  PrismaCatalogEntryRepository,
6024
+ PrismaMaintenanceWindowRepository,
5806
6025
  PrismaMarketingProjectionRepository,
5807
6026
  PrismaMarketingSettingsRepository,
5808
6027
  PrismaMfaAdapter,
@@ -5817,6 +6036,7 @@ export {
5817
6036
  PrismaPromoCodeValidationLogRepository,
5818
6037
  PrismaPromoSubscriptionLookup,
5819
6038
  PrismaPromotionRepository,
6039
+ PrismaSubscriberLedgerRepository,
5820
6040
  PrismaSubscriberPaymentMethodRepository,
5821
6041
  PrismaSubscriberRepository,
5822
6042
  PrismaSubscriptionBundleRepository,