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

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
@@ -3907,6 +3907,7 @@ PrismaPromoSubscriptionLookup = _ts_decorate21([
3907
3907
 
3908
3908
  // src/prisma-subscription-bundle.repository.ts
3909
3909
  import { Inject as Inject21, Injectable as Injectable22 } from "@nestjs/common";
3910
+ import { toSubscriptionBundleRecord } from "@saasicat/core";
3910
3911
  function _ts_decorate22(decorators, target, key, desc) {
3911
3912
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3912
3913
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -3944,7 +3945,7 @@ var PrismaSubscriptionBundleRepository = class {
3944
3945
  startedAt: "desc"
3945
3946
  }
3946
3947
  });
3947
- return rows.map(toRecord3);
3948
+ return rows.map(toSubscriptionBundleRecord);
3948
3949
  }
3949
3950
  async findById(subscriptionBundleId) {
3950
3951
  const row = await this.db().subscriptionBundle.findUnique({
@@ -3952,7 +3953,7 @@ var PrismaSubscriptionBundleRepository = class {
3952
3953
  id: subscriptionBundleId
3953
3954
  }
3954
3955
  });
3955
- return row ? toRecord3(row) : null;
3956
+ return row ? toSubscriptionBundleRecord(row) : null;
3956
3957
  }
3957
3958
  async listActiveBySubscription(subscriptionId, asOf = /* @__PURE__ */ new Date(), tx) {
3958
3959
  const rows = await this.db(tx).subscriptionBundle.findMany({
@@ -3973,7 +3974,7 @@ var PrismaSubscriptionBundleRepository = class {
3973
3974
  startedAt: "desc"
3974
3975
  }
3975
3976
  });
3976
- return rows.map(toRecord3);
3977
+ return rows.map(toSubscriptionBundleRecord);
3977
3978
  }
3978
3979
  async add(data) {
3979
3980
  const row = await this.db().subscriptionBundle.create({
@@ -3987,7 +3988,7 @@ var PrismaSubscriptionBundleRepository = class {
3987
3988
  currentPeriodEnd: data.currentPeriodEnd ?? null
3988
3989
  }
3989
3990
  });
3990
- return toRecord3(row);
3991
+ return toSubscriptionBundleRecord(row);
3991
3992
  }
3992
3993
  async cancel(subscriptionBundleId, data) {
3993
3994
  const { count } = await this.db().subscriptionBundle.updateMany({
@@ -4009,7 +4010,7 @@ var PrismaSubscriptionBundleRepository = class {
4009
4010
  }
4010
4011
  });
4011
4012
  if (!row) throw new Error(`SubscriptionBundle '${subscriptionBundleId}' disappeared`);
4012
- return toRecord3(row);
4013
+ return toSubscriptionBundleRecord(row);
4013
4014
  }
4014
4015
  async reactivate(subscriptionBundleId) {
4015
4016
  const row = await this.db().subscriptionBundle.update({
@@ -4021,7 +4022,7 @@ var PrismaSubscriptionBundleRepository = class {
4021
4022
  canceledEffectiveAt: null
4022
4023
  }
4023
4024
  });
4024
- return toRecord3(row);
4025
+ return toSubscriptionBundleRecord(row);
4025
4026
  }
4026
4027
  async countActiveByBundleVersionId(bundleVersionId, asOf = /* @__PURE__ */ new Date()) {
4027
4028
  return this.db().subscriptionBundle.count({
@@ -4049,23 +4050,6 @@ PrismaSubscriptionBundleRepository = _ts_decorate22([
4049
4050
  typeof SubscriptionBundleClient === "undefined" ? Object : SubscriptionBundleClient
4050
4051
  ])
4051
4052
  ], 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
4053
 
4070
4054
  // src/prisma-subscription-contract.repository.ts
4071
4055
  import { Inject as Inject22, Injectable as Injectable23 } from "@nestjs/common";
@@ -4348,9 +4332,9 @@ function toLineItemCreate(item) {
4348
4332
  }
4349
4333
  __name(toLineItemCreate, "toLineItemCreate");
4350
4334
 
4351
- // src/prisma-subscriber-payment-method.repository.ts
4335
+ // src/prisma-subscriber-ledger.repository.ts
4352
4336
  import { Inject as Inject23, Injectable as Injectable24 } from "@nestjs/common";
4353
- import { ForeignPaymentMethodReferenceError, refuseForeignPaymentMethodReference, subscriberPaymentMethodColumns, toSubscriberPaymentMethodRecord } from "@saasicat/core";
4337
+ import { subscriberChargeColumns, toSubscriberChargeRecord } from "@saasicat/core";
4354
4338
  function _ts_decorate24(decorators, target, key, desc) {
4355
4339
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4356
4340
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -4368,6 +4352,84 @@ function _ts_param23(paramIndex, decorator) {
4368
4352
  };
4369
4353
  }
4370
4354
  __name(_ts_param23, "_ts_param");
4355
+ var PrismaSubscriberLedgerRepository = class {
4356
+ static {
4357
+ __name(this, "PrismaSubscriberLedgerRepository");
4358
+ }
4359
+ prisma;
4360
+ constructor(prisma) {
4361
+ this.prisma = prisma;
4362
+ }
4363
+ db(tx) {
4364
+ return tx ?? this.prisma;
4365
+ }
4366
+ /**
4367
+ * One statement, `skipDuplicates` being `ON CONFLICT DO NOTHING`: a charge
4368
+ * another caller wrote first — committed or still in flight — is waited for
4369
+ * and skipped rather than raised, and only what this call wrote comes back.
4370
+ * It names no conflict target, so it suppresses every unique key; the only
4371
+ * one besides the natural key is the primary key, a uuid made per row here.
4372
+ */
4373
+ async recordCharges(charges, tx) {
4374
+ if (charges.length === 0) return [];
4375
+ const rows = await this.db(tx).subscriberLedgerEntry.createManyAndReturn({
4376
+ data: charges.map(subscriberChargeColumns),
4377
+ skipDuplicates: true
4378
+ });
4379
+ return rows.map(toSubscriberChargeRecord);
4380
+ }
4381
+ async listBySubscription(subscriptionId, tx) {
4382
+ const rows = await this.db(tx).subscriberLedgerEntry.findMany({
4383
+ where: {
4384
+ subscriptionId
4385
+ },
4386
+ orderBy: [
4387
+ {
4388
+ periodStart: "asc"
4389
+ },
4390
+ {
4391
+ source: "asc"
4392
+ },
4393
+ {
4394
+ sourceRef: "asc"
4395
+ },
4396
+ {
4397
+ origin: "asc"
4398
+ }
4399
+ ]
4400
+ });
4401
+ return rows.map(toSubscriberChargeRecord);
4402
+ }
4403
+ };
4404
+ PrismaSubscriberLedgerRepository = _ts_decorate24([
4405
+ Injectable24(),
4406
+ _ts_param23(0, Inject23(PRISMA_CLIENT_TOKEN)),
4407
+ _ts_metadata23("design:type", Function),
4408
+ _ts_metadata23("design:paramtypes", [
4409
+ typeof LedgerClient === "undefined" ? Object : LedgerClient
4410
+ ])
4411
+ ], PrismaSubscriberLedgerRepository);
4412
+
4413
+ // src/prisma-subscriber-payment-method.repository.ts
4414
+ import { Inject as Inject24, Injectable as Injectable25 } from "@nestjs/common";
4415
+ import { ForeignPaymentMethodReferenceError, refuseForeignPaymentMethodReference, subscriberPaymentMethodColumns, toSubscriberPaymentMethodRecord } from "@saasicat/core";
4416
+ function _ts_decorate25(decorators, target, key, desc) {
4417
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4418
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4419
+ 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;
4420
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
4421
+ }
4422
+ __name(_ts_decorate25, "_ts_decorate");
4423
+ function _ts_metadata24(k, v) {
4424
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4425
+ }
4426
+ __name(_ts_metadata24, "_ts_metadata");
4427
+ function _ts_param24(paramIndex, decorator) {
4428
+ return function(target, key) {
4429
+ decorator(target, key, paramIndex);
4430
+ };
4431
+ }
4432
+ __name(_ts_param24, "_ts_param");
4371
4433
  var PrismaSubscriberPaymentMethodRepository = class {
4372
4434
  static {
4373
4435
  __name(this, "PrismaSubscriberPaymentMethodRepository");
@@ -4570,35 +4632,35 @@ var PrismaSubscriberPaymentMethodRepository = class {
4570
4632
  return count === 1;
4571
4633
  }
4572
4634
  };
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", [
4635
+ PrismaSubscriberPaymentMethodRepository = _ts_decorate25([
4636
+ Injectable25(),
4637
+ _ts_param24(0, Inject24(PRISMA_CLIENT_TOKEN)),
4638
+ _ts_metadata24("design:type", Function),
4639
+ _ts_metadata24("design:paramtypes", [
4578
4640
  typeof PaymentMethodRepositoryClient === "undefined" ? Object : PaymentMethodRepositoryClient
4579
4641
  ])
4580
4642
  ], PrismaSubscriberPaymentMethodRepository);
4581
4643
 
4582
4644
  // src/prisma-subscriber.repository.ts
4583
- import { Inject as Inject24, Injectable as Injectable25 } from "@nestjs/common";
4645
+ import { Inject as Inject25, Injectable as Injectable26 } from "@nestjs/common";
4584
4646
  import { identityCorrectionDelta, toSubscriberCorrectionRecord, toSubscriberRecord } from "@saasicat/core";
4585
- function _ts_decorate25(decorators, target, key, desc) {
4647
+ function _ts_decorate26(decorators, target, key, desc) {
4586
4648
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4587
4649
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4588
4650
  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
4651
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4590
4652
  }
4591
- __name(_ts_decorate25, "_ts_decorate");
4592
- function _ts_metadata24(k, v) {
4653
+ __name(_ts_decorate26, "_ts_decorate");
4654
+ function _ts_metadata25(k, v) {
4593
4655
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4594
4656
  }
4595
- __name(_ts_metadata24, "_ts_metadata");
4596
- function _ts_param24(paramIndex, decorator) {
4657
+ __name(_ts_metadata25, "_ts_metadata");
4658
+ function _ts_param25(paramIndex, decorator) {
4597
4659
  return function(target, key) {
4598
4660
  decorator(target, key, paramIndex);
4599
4661
  };
4600
4662
  }
4601
- __name(_ts_param24, "_ts_param");
4663
+ __name(_ts_param25, "_ts_param");
4602
4664
  var WITH_LIVE_TENANT = {
4603
4665
  tenants: {
4604
4666
  where: {
@@ -4659,7 +4721,7 @@ var PrismaSubscriberRepository = class {
4659
4721
  },
4660
4722
  include: WITH_LIVE_TENANT
4661
4723
  });
4662
- return row ? toRecord4(row) : null;
4724
+ return row ? toRecord3(row) : null;
4663
4725
  }
4664
4726
  async findByTenantId(tenantId, tx) {
4665
4727
  const row = await this.db(tx).subscriber.findFirst({
@@ -4698,7 +4760,7 @@ var PrismaSubscriberRepository = class {
4698
4760
  const delta = identityCorrectionDelta(current, data.corrected);
4699
4761
  if (Object.keys(delta.corrected).length === 0) {
4700
4762
  return {
4701
- subscriber: toRecord4(current),
4763
+ subscriber: toRecord3(current),
4702
4764
  correction: null
4703
4765
  };
4704
4766
  }
@@ -4720,7 +4782,7 @@ var PrismaSubscriberRepository = class {
4720
4782
  }
4721
4783
  });
4722
4784
  return {
4723
- subscriber: toRecord4(updated),
4785
+ subscriber: toRecord3(updated),
4724
4786
  correction: toSubscriberCorrectionRecord(correction)
4725
4787
  };
4726
4788
  });
@@ -4742,38 +4804,38 @@ var PrismaSubscriberRepository = class {
4742
4804
  return rows.map(toSubscriberCorrectionRecord);
4743
4805
  }
4744
4806
  };
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", [
4807
+ PrismaSubscriberRepository = _ts_decorate26([
4808
+ Injectable26(),
4809
+ _ts_param25(0, Inject25(PRISMA_CLIENT_TOKEN)),
4810
+ _ts_metadata25("design:type", Function),
4811
+ _ts_metadata25("design:paramtypes", [
4750
4812
  typeof SubscriberRepositoryClient === "undefined" ? Object : SubscriberRepositoryClient
4751
4813
  ])
4752
4814
  ], PrismaSubscriberRepository);
4753
- function toRecord4(row) {
4815
+ function toRecord3(row) {
4754
4816
  return toSubscriberRecord(row, row.tenants?.[0]?.tenantId ?? null);
4755
4817
  }
4756
- __name(toRecord4, "toRecord");
4818
+ __name(toRecord3, "toRecord");
4757
4819
 
4758
4820
  // 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) {
4821
+ import { Inject as Inject26, Injectable as Injectable27, Optional as Optional6 } from "@nestjs/common";
4822
+ function _ts_decorate27(decorators, target, key, desc) {
4761
4823
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4762
4824
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4763
4825
  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
4826
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4765
4827
  }
4766
- __name(_ts_decorate26, "_ts_decorate");
4767
- function _ts_metadata25(k, v) {
4828
+ __name(_ts_decorate27, "_ts_decorate");
4829
+ function _ts_metadata26(k, v) {
4768
4830
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4769
4831
  }
4770
- __name(_ts_metadata25, "_ts_metadata");
4771
- function _ts_param25(paramIndex, decorator) {
4832
+ __name(_ts_metadata26, "_ts_metadata");
4833
+ function _ts_param26(paramIndex, decorator) {
4772
4834
  return function(target, key) {
4773
4835
  decorator(target, key, paramIndex);
4774
4836
  };
4775
4837
  }
4776
- __name(_ts_param25, "_ts_param");
4838
+ __name(_ts_param26, "_ts_param");
4777
4839
  var ACTIVE_STATUSES = [
4778
4840
  "ACTIVE",
4779
4841
  "TRIAL"
@@ -5008,37 +5070,37 @@ var PrismaSubscriptionRepository = class {
5008
5070
  ]));
5009
5071
  }
5010
5072
  };
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", [
5073
+ PrismaSubscriptionRepository = _ts_decorate27([
5074
+ Injectable27(),
5075
+ _ts_param26(0, Inject26(PRISMA_CLIENT_TOKEN)),
5076
+ _ts_param26(1, Optional6()),
5077
+ _ts_param26(1, Inject26(PRISMA_SCHEMA_OPTIONS_TOKEN)),
5078
+ _ts_metadata26("design:type", Function),
5079
+ _ts_metadata26("design:paramtypes", [
5018
5080
  typeof SubscriptionRepositoryClient === "undefined" ? Object : SubscriptionRepositoryClient,
5019
5081
  typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
5020
5082
  ])
5021
5083
  ], PrismaSubscriptionRepository);
5022
5084
 
5023
5085
  // 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) {
5086
+ import { Inject as Inject27, Injectable as Injectable28, Optional as Optional7 } from "@nestjs/common";
5087
+ function _ts_decorate28(decorators, target, key, desc) {
5026
5088
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5027
5089
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5028
5090
  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
5091
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5030
5092
  }
5031
- __name(_ts_decorate27, "_ts_decorate");
5032
- function _ts_metadata26(k, v) {
5093
+ __name(_ts_decorate28, "_ts_decorate");
5094
+ function _ts_metadata27(k, v) {
5033
5095
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
5034
5096
  }
5035
- __name(_ts_metadata26, "_ts_metadata");
5036
- function _ts_param26(paramIndex, decorator) {
5097
+ __name(_ts_metadata27, "_ts_metadata");
5098
+ function _ts_param27(paramIndex, decorator) {
5037
5099
  return function(target, key) {
5038
5100
  decorator(target, key, paramIndex);
5039
5101
  };
5040
5102
  }
5041
- __name(_ts_param26, "_ts_param");
5103
+ __name(_ts_param27, "_ts_param");
5042
5104
  var PrismaSubscriptionUsageAdapter = class {
5043
5105
  static {
5044
5106
  __name(this, "PrismaSubscriptionUsageAdapter");
@@ -5129,38 +5191,38 @@ var PrismaSubscriptionUsageAdapter = class {
5129
5191
  return getPrismaDelegate(this.prisma, this.planVersionDelegateName);
5130
5192
  }
5131
5193
  };
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", [
5194
+ PrismaSubscriptionUsageAdapter = _ts_decorate28([
5195
+ Injectable28(),
5196
+ _ts_param27(0, Inject27(PRISMA_CLIENT_TOKEN)),
5197
+ _ts_param27(1, Optional7()),
5198
+ _ts_param27(1, Inject27(PRISMA_SCHEMA_OPTIONS_TOKEN)),
5199
+ _ts_metadata27("design:type", Function),
5200
+ _ts_metadata27("design:paramtypes", [
5139
5201
  typeof SubscriptionUsageClient === "undefined" ? Object : SubscriptionUsageClient,
5140
5202
  typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
5141
5203
  ])
5142
5204
  ], PrismaSubscriptionUsageAdapter);
5143
5205
 
5144
5206
  // src/prisma-super-admin-bootstrap.adapter.ts
5145
- import { Inject as Inject27, Injectable as Injectable28 } from "@nestjs/common";
5207
+ import { Inject as Inject28, Injectable as Injectable29 } from "@nestjs/common";
5146
5208
  import { PlatformUserExistsError } from "@saasicat/core";
5147
- function _ts_decorate28(decorators, target, key, desc) {
5209
+ function _ts_decorate29(decorators, target, key, desc) {
5148
5210
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5149
5211
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5150
5212
  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
5213
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5152
5214
  }
5153
- __name(_ts_decorate28, "_ts_decorate");
5154
- function _ts_metadata27(k, v) {
5215
+ __name(_ts_decorate29, "_ts_decorate");
5216
+ function _ts_metadata28(k, v) {
5155
5217
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
5156
5218
  }
5157
- __name(_ts_metadata27, "_ts_metadata");
5158
- function _ts_param27(paramIndex, decorator) {
5219
+ __name(_ts_metadata28, "_ts_metadata");
5220
+ function _ts_param28(paramIndex, decorator) {
5159
5221
  return function(target, key) {
5160
5222
  decorator(target, key, paramIndex);
5161
5223
  };
5162
5224
  }
5163
- __name(_ts_param27, "_ts_param");
5225
+ __name(_ts_param28, "_ts_param");
5164
5226
  var PASSWORD_HASHER_TOKEN = /* @__PURE__ */ Symbol.for("saasicat/adapter-prisma/PasswordHasher");
5165
5227
  var PrismaSuperAdminBootstrapAdapter = class {
5166
5228
  static {
@@ -5210,37 +5272,37 @@ var PrismaSuperAdminBootstrapAdapter = class {
5210
5272
  };
5211
5273
  }
5212
5274
  };
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", [
5275
+ PrismaSuperAdminBootstrapAdapter = _ts_decorate29([
5276
+ Injectable29(),
5277
+ _ts_param28(0, Inject28(PRISMA_CLIENT_TOKEN)),
5278
+ _ts_param28(1, Inject28(PASSWORD_HASHER_TOKEN)),
5279
+ _ts_metadata28("design:type", Function),
5280
+ _ts_metadata28("design:paramtypes", [
5219
5281
  typeof PrismaLike === "undefined" ? Object : PrismaLike,
5220
5282
  typeof PasswordHasher === "undefined" ? Object : PasswordHasher
5221
5283
  ])
5222
5284
  ], PrismaSuperAdminBootstrapAdapter);
5223
5285
 
5224
5286
  // src/prisma-tenant-subscription-write.adapter.ts
5225
- import { Inject as Inject28, Injectable as Injectable29, Optional as Optional8 } from "@nestjs/common";
5287
+ import { Inject as Inject29, Injectable as Injectable30, Optional as Optional8 } from "@nestjs/common";
5226
5288
  import { buildActivePlanVersionWhere as buildActivePlanVersionWhere3 } from "@saasicat/core";
5227
- function _ts_decorate29(decorators, target, key, desc) {
5289
+ function _ts_decorate30(decorators, target, key, desc) {
5228
5290
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5229
5291
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5230
5292
  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
5293
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5232
5294
  }
5233
- __name(_ts_decorate29, "_ts_decorate");
5234
- function _ts_metadata28(k, v) {
5295
+ __name(_ts_decorate30, "_ts_decorate");
5296
+ function _ts_metadata29(k, v) {
5235
5297
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
5236
5298
  }
5237
- __name(_ts_metadata28, "_ts_metadata");
5238
- function _ts_param28(paramIndex, decorator) {
5299
+ __name(_ts_metadata29, "_ts_metadata");
5300
+ function _ts_param29(paramIndex, decorator) {
5239
5301
  return function(target, key) {
5240
5302
  decorator(target, key, paramIndex);
5241
5303
  };
5242
5304
  }
5243
- __name(_ts_param28, "_ts_param");
5305
+ __name(_ts_param29, "_ts_param");
5244
5306
  var PrismaTenantSubscriptionWriteAdapter = class {
5245
5307
  static {
5246
5308
  __name(this, "PrismaTenantSubscriptionWriteAdapter");
@@ -5597,13 +5659,13 @@ var PrismaTenantSubscriptionWriteAdapter = class {
5597
5659
  }
5598
5660
  }
5599
5661
  };
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", [
5662
+ PrismaTenantSubscriptionWriteAdapter = _ts_decorate30([
5663
+ Injectable30(),
5664
+ _ts_param29(0, Inject29(PRISMA_CLIENT_TOKEN)),
5665
+ _ts_param29(1, Optional8()),
5666
+ _ts_param29(1, Inject29(PRISMA_SCHEMA_OPTIONS_TOKEN)),
5667
+ _ts_metadata29("design:type", Function),
5668
+ _ts_metadata29("design:paramtypes", [
5607
5669
  typeof TransactionalPrismaClient === "undefined" ? Object : TransactionalPrismaClient,
5608
5670
  typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
5609
5671
  ])
@@ -5622,24 +5684,24 @@ function clearedPendingVersionData() {
5622
5684
  __name(clearedPendingVersionData, "clearedPendingVersionData");
5623
5685
 
5624
5686
  // 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) {
5687
+ import { Inject as Inject30, Injectable as Injectable31 } from "@nestjs/common";
5688
+ function _ts_decorate31(decorators, target, key, desc) {
5627
5689
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5628
5690
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5629
5691
  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
5692
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5631
5693
  }
5632
- __name(_ts_decorate30, "_ts_decorate");
5633
- function _ts_metadata29(k, v) {
5694
+ __name(_ts_decorate31, "_ts_decorate");
5695
+ function _ts_metadata30(k, v) {
5634
5696
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
5635
5697
  }
5636
- __name(_ts_metadata29, "_ts_metadata");
5637
- function _ts_param29(paramIndex, decorator) {
5698
+ __name(_ts_metadata30, "_ts_metadata");
5699
+ function _ts_param30(paramIndex, decorator) {
5638
5700
  return function(target, key) {
5639
5701
  decorator(target, key, paramIndex);
5640
5702
  };
5641
5703
  }
5642
- __name(_ts_param29, "_ts_param");
5704
+ __name(_ts_param30, "_ts_param");
5643
5705
  var PrismaTransactionRunner = class {
5644
5706
  static {
5645
5707
  __name(this, "PrismaTransactionRunner");
@@ -5653,24 +5715,24 @@ var PrismaTransactionRunner = class {
5653
5715
  return transaction((tx) => fn(tx));
5654
5716
  }
5655
5717
  };
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", [
5718
+ PrismaTransactionRunner = _ts_decorate31([
5719
+ Injectable31(),
5720
+ _ts_param30(0, Inject30(PRISMA_CLIENT_TOKEN)),
5721
+ _ts_metadata30("design:type", Function),
5722
+ _ts_metadata30("design:paramtypes", [
5661
5723
  typeof Record === "undefined" ? Object : Record
5662
5724
  ])
5663
5725
  ], PrismaTransactionRunner);
5664
5726
 
5665
5727
  // src/zero-promo-revenue-aggregator.adapter.ts
5666
- import { Injectable as Injectable31 } from "@nestjs/common";
5667
- function _ts_decorate31(decorators, target, key, desc) {
5728
+ import { Injectable as Injectable32 } from "@nestjs/common";
5729
+ function _ts_decorate32(decorators, target, key, desc) {
5668
5730
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
5669
5731
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5670
5732
  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
5733
  return c > 3 && r && Object.defineProperty(target, key, r), r;
5672
5734
  }
5673
- __name(_ts_decorate31, "_ts_decorate");
5735
+ __name(_ts_decorate32, "_ts_decorate");
5674
5736
  var ZeroPromoRevenueDeductionAggregator = class {
5675
5737
  static {
5676
5738
  __name(this, "ZeroPromoRevenueDeductionAggregator");
@@ -5679,8 +5741,8 @@ var ZeroPromoRevenueDeductionAggregator = class {
5679
5741
  return "0.00";
5680
5742
  }
5681
5743
  };
5682
- ZeroPromoRevenueDeductionAggregator = _ts_decorate31([
5683
- Injectable31()
5744
+ ZeroPromoRevenueDeductionAggregator = _ts_decorate32([
5745
+ Injectable32()
5684
5746
  ], ZeroPromoRevenueDeductionAggregator);
5685
5747
 
5686
5748
  // src/prisma-persistence.ts
@@ -5714,6 +5776,8 @@ function prismaPersistence(options) {
5714
5776
  planVersionRepository: provide((prisma) => new PrismaPlanVersionRepository(prisma, options.schema)),
5715
5777
  subscriptionContractRepository: provide((prisma) => new PrismaSubscriptionContractRepository(prisma)),
5716
5778
  subscriberRepository: provide((prisma) => new PrismaSubscriberRepository(canonical(prisma))),
5779
+ // The charges those contracts give rise to, written once each.
5780
+ subscriberLedgerRepository: provide((prisma) => new PrismaSubscriberLedgerRepository(canonical(prisma))),
5717
5781
  subscriptionBundleRepository: provide((prisma) => new PrismaSubscriptionBundleRepository(canonical(prisma))),
5718
5782
  bundleRepository: provide((prisma) => new PrismaBundleRepository(canonical(prisma), options.bundle))
5719
5783
  },
@@ -5817,6 +5881,7 @@ export {
5817
5881
  PrismaPromoCodeValidationLogRepository,
5818
5882
  PrismaPromoSubscriptionLookup,
5819
5883
  PrismaPromotionRepository,
5884
+ PrismaSubscriberLedgerRepository,
5820
5885
  PrismaSubscriberPaymentMethodRepository,
5821
5886
  PrismaSubscriberRepository,
5822
5887
  PrismaSubscriptionBundleRepository,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saasicat/adapter-prisma",
3
- "version": "1.0.0-rc.21",
3
+ "version": "1.0.0-rc.22",
4
4
  "description": "Prisma + PostgreSQL persistence for SaaSiCat: one standard bundle for core, catalog, entitlement, tenant billing, Admin resources and promo, plus individual adapters for custom compositions.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -23,7 +23,7 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "@saasicat/core": "^1.0.0-rc.21"
26
+ "@saasicat/core": "^1.0.0-rc.22"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "@nestjs/common": "^11.0.0",
@@ -41,8 +41,8 @@
41
41
  "@prisma/client": "^6.19.0",
42
42
  "tsup": "^8.0.0",
43
43
  "typescript": "^6.0.0",
44
- "@saasicat/persistence-testing": "^1.0.0-rc.21",
45
- "@saasicat/spec": "^1.0.0-rc.21"
44
+ "@saasicat/persistence-testing": "^1.0.0-rc.22",
45
+ "@saasicat/spec": "^1.0.0-rc.22"
46
46
  },
47
47
  "license": "PolyForm-Shield-1.0.0",
48
48
  "author": "Taci Uelker",