@saasicat/adapter-prisma 1.0.0-rc.15 → 1.0.0-rc.16
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/.build-stamp +1 -1
- package/dist/index.cjs +255 -71
- package/dist/index.d.cts +30 -3
- package/dist/index.d.ts +30 -3
- package/dist/index.js +250 -67
- package/package.json +4 -4
package/dist/.build-stamp
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
94dd4fee4df67ac6e3036db7c9d37a9f867897873518b43e928e05ebd381a8f4
|
package/dist/index.cjs
CHANGED
|
@@ -45,6 +45,7 @@ __export(index_exports, {
|
|
|
45
45
|
PrismaPromoCodeValidationLogRepository: () => PrismaPromoCodeValidationLogRepository,
|
|
46
46
|
PrismaPromoSubscriptionLookup: () => PrismaPromoSubscriptionLookup,
|
|
47
47
|
PrismaPromotionRepository: () => PrismaPromotionRepository,
|
|
48
|
+
PrismaSubscriberRepository: () => PrismaSubscriberRepository,
|
|
48
49
|
PrismaSubscriptionBundleRepository: () => PrismaSubscriptionBundleRepository,
|
|
49
50
|
PrismaSubscriptionContractRepository: () => PrismaSubscriptionContractRepository,
|
|
50
51
|
PrismaSubscriptionRepository: () => PrismaSubscriptionRepository,
|
|
@@ -4018,6 +4019,8 @@ var PrismaSubscriptionContractRepository = class {
|
|
|
4018
4019
|
const row = await this.db(tx).subscriptionContract.create({
|
|
4019
4020
|
data: {
|
|
4020
4021
|
tenantId: data.tenantId,
|
|
4022
|
+
subscriberId: data.parties.subscriberId,
|
|
4023
|
+
subscriberSnapshot: data.parties.subscriber,
|
|
4021
4024
|
status: data.status ?? "active",
|
|
4022
4025
|
effectiveFrom: data.effectiveFrom,
|
|
4023
4026
|
effectiveUntil: data.effectiveUntil ?? null,
|
|
@@ -4035,6 +4038,9 @@ var PrismaSubscriptionContractRepository = class {
|
|
|
4035
4038
|
...data.termsSnapshot != null ? {
|
|
4036
4039
|
termsSnapshot: data.termsSnapshot
|
|
4037
4040
|
} : {},
|
|
4041
|
+
...data.parties.issuer != null ? {
|
|
4042
|
+
issuerSnapshot: data.parties.issuer
|
|
4043
|
+
} : {},
|
|
4038
4044
|
lineItems: {
|
|
4039
4045
|
create: data.lineItems.map(toLineItemCreate)
|
|
4040
4046
|
}
|
|
@@ -4099,8 +4105,9 @@ function toLineItemCreate(item) {
|
|
|
4099
4105
|
}
|
|
4100
4106
|
__name(toLineItemCreate, "toLineItemCreate");
|
|
4101
4107
|
|
|
4102
|
-
// src/prisma-
|
|
4108
|
+
// src/prisma-subscriber.repository.ts
|
|
4103
4109
|
var import_common22 = require("@nestjs/common");
|
|
4110
|
+
var import_core8 = require("@saasicat/core");
|
|
4104
4111
|
function _ts_decorate22(decorators, target, key, desc) {
|
|
4105
4112
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4106
4113
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4118,6 +4125,181 @@ function _ts_param21(paramIndex, decorator) {
|
|
|
4118
4125
|
};
|
|
4119
4126
|
}
|
|
4120
4127
|
__name(_ts_param21, "_ts_param");
|
|
4128
|
+
var WITH_LIVE_TENANT = {
|
|
4129
|
+
tenants: {
|
|
4130
|
+
where: {
|
|
4131
|
+
unlinkedAt: null
|
|
4132
|
+
},
|
|
4133
|
+
select: {
|
|
4134
|
+
tenantId: true
|
|
4135
|
+
},
|
|
4136
|
+
take: 1
|
|
4137
|
+
}
|
|
4138
|
+
};
|
|
4139
|
+
var PrismaSubscriberRepository = class {
|
|
4140
|
+
static {
|
|
4141
|
+
__name(this, "PrismaSubscriberRepository");
|
|
4142
|
+
}
|
|
4143
|
+
prisma;
|
|
4144
|
+
constructor(prisma) {
|
|
4145
|
+
this.prisma = prisma;
|
|
4146
|
+
}
|
|
4147
|
+
db(tx) {
|
|
4148
|
+
return tx ?? this.prisma;
|
|
4149
|
+
}
|
|
4150
|
+
/** On the caller's transaction when there is one, otherwise in one of its own. */
|
|
4151
|
+
inTransaction(tx, fn) {
|
|
4152
|
+
if (tx) return fn(this.db(tx));
|
|
4153
|
+
return this.prisma.$transaction((own) => fn(own));
|
|
4154
|
+
}
|
|
4155
|
+
async createForTenant(data, tx) {
|
|
4156
|
+
const { tenantId, ...details } = data;
|
|
4157
|
+
return this.inTransaction(tx, async (db) => {
|
|
4158
|
+
const created = await db.subscriber.create({
|
|
4159
|
+
data: details
|
|
4160
|
+
});
|
|
4161
|
+
const linked = await db.subscriberTenant.createMany({
|
|
4162
|
+
data: [
|
|
4163
|
+
{
|
|
4164
|
+
subscriberId: created.id,
|
|
4165
|
+
tenantId
|
|
4166
|
+
}
|
|
4167
|
+
],
|
|
4168
|
+
skipDuplicates: true
|
|
4169
|
+
});
|
|
4170
|
+
if (linked.count === 0) {
|
|
4171
|
+
await db.subscriber.delete({
|
|
4172
|
+
where: {
|
|
4173
|
+
id: created.id
|
|
4174
|
+
}
|
|
4175
|
+
});
|
|
4176
|
+
return null;
|
|
4177
|
+
}
|
|
4178
|
+
return (0, import_core8.toSubscriberRecord)(created, tenantId);
|
|
4179
|
+
});
|
|
4180
|
+
}
|
|
4181
|
+
async findById(subscriberId, tx) {
|
|
4182
|
+
const row = await this.db(tx).subscriber.findUnique({
|
|
4183
|
+
where: {
|
|
4184
|
+
id: subscriberId
|
|
4185
|
+
},
|
|
4186
|
+
include: WITH_LIVE_TENANT
|
|
4187
|
+
});
|
|
4188
|
+
return row ? toRecord4(row) : null;
|
|
4189
|
+
}
|
|
4190
|
+
async findByTenantId(tenantId, tx) {
|
|
4191
|
+
const row = await this.db(tx).subscriber.findFirst({
|
|
4192
|
+
where: {
|
|
4193
|
+
tenants: {
|
|
4194
|
+
some: {
|
|
4195
|
+
tenantId,
|
|
4196
|
+
unlinkedAt: null
|
|
4197
|
+
}
|
|
4198
|
+
}
|
|
4199
|
+
}
|
|
4200
|
+
});
|
|
4201
|
+
return row ? (0, import_core8.toSubscriberRecord)(row, tenantId) : null;
|
|
4202
|
+
}
|
|
4203
|
+
async updateContact(subscriberId, change, tx) {
|
|
4204
|
+
const db = this.db(tx);
|
|
4205
|
+
const { count } = await db.subscriber.updateMany({
|
|
4206
|
+
where: {
|
|
4207
|
+
id: subscriberId
|
|
4208
|
+
},
|
|
4209
|
+
data: change
|
|
4210
|
+
});
|
|
4211
|
+
if (count === 0) return null;
|
|
4212
|
+
return this.findById(subscriberId, tx);
|
|
4213
|
+
}
|
|
4214
|
+
async correctIdentity(subscriberId, data, tx) {
|
|
4215
|
+
return this.inTransaction(tx, async (db) => {
|
|
4216
|
+
await db.$queryRaw`SELECT "id" FROM "subscribers" WHERE "id" = ${subscriberId} FOR UPDATE`;
|
|
4217
|
+
const current = await db.subscriber.findUnique({
|
|
4218
|
+
where: {
|
|
4219
|
+
id: subscriberId
|
|
4220
|
+
},
|
|
4221
|
+
include: WITH_LIVE_TENANT
|
|
4222
|
+
});
|
|
4223
|
+
if (!current) return null;
|
|
4224
|
+
const delta = (0, import_core8.identityCorrectionDelta)(current, data.corrected);
|
|
4225
|
+
if (Object.keys(delta.corrected).length === 0) {
|
|
4226
|
+
return {
|
|
4227
|
+
subscriber: toRecord4(current),
|
|
4228
|
+
correction: null
|
|
4229
|
+
};
|
|
4230
|
+
}
|
|
4231
|
+
const updated = await db.subscriber.update({
|
|
4232
|
+
where: {
|
|
4233
|
+
id: subscriberId
|
|
4234
|
+
},
|
|
4235
|
+
data: delta.corrected,
|
|
4236
|
+
include: WITH_LIVE_TENANT
|
|
4237
|
+
});
|
|
4238
|
+
const correction = await db.subscriberCorrection.create({
|
|
4239
|
+
data: {
|
|
4240
|
+
subscriberId,
|
|
4241
|
+
previous: delta.previous,
|
|
4242
|
+
corrected: delta.corrected,
|
|
4243
|
+
reason: data.reason,
|
|
4244
|
+
correctedBy: data.correctedBy,
|
|
4245
|
+
correctedAt: data.correctedAt
|
|
4246
|
+
}
|
|
4247
|
+
});
|
|
4248
|
+
return {
|
|
4249
|
+
subscriber: toRecord4(updated),
|
|
4250
|
+
correction: (0, import_core8.toSubscriberCorrectionRecord)(correction)
|
|
4251
|
+
};
|
|
4252
|
+
});
|
|
4253
|
+
}
|
|
4254
|
+
async listCorrections(subscriberId) {
|
|
4255
|
+
const rows = await this.db().subscriberCorrection.findMany({
|
|
4256
|
+
where: {
|
|
4257
|
+
subscriberId
|
|
4258
|
+
},
|
|
4259
|
+
orderBy: [
|
|
4260
|
+
{
|
|
4261
|
+
correctedAt: "desc"
|
|
4262
|
+
},
|
|
4263
|
+
{
|
|
4264
|
+
id: "desc"
|
|
4265
|
+
}
|
|
4266
|
+
]
|
|
4267
|
+
});
|
|
4268
|
+
return rows.map(import_core8.toSubscriberCorrectionRecord);
|
|
4269
|
+
}
|
|
4270
|
+
};
|
|
4271
|
+
PrismaSubscriberRepository = _ts_decorate22([
|
|
4272
|
+
(0, import_common22.Injectable)(),
|
|
4273
|
+
_ts_param21(0, (0, import_common22.Inject)(PRISMA_CLIENT_TOKEN)),
|
|
4274
|
+
_ts_metadata21("design:type", Function),
|
|
4275
|
+
_ts_metadata21("design:paramtypes", [
|
|
4276
|
+
typeof SubscriberRepositoryClient === "undefined" ? Object : SubscriberRepositoryClient
|
|
4277
|
+
])
|
|
4278
|
+
], PrismaSubscriberRepository);
|
|
4279
|
+
function toRecord4(row) {
|
|
4280
|
+
return (0, import_core8.toSubscriberRecord)(row, row.tenants?.[0]?.tenantId ?? null);
|
|
4281
|
+
}
|
|
4282
|
+
__name(toRecord4, "toRecord");
|
|
4283
|
+
|
|
4284
|
+
// src/prisma-subscription.repository.ts
|
|
4285
|
+
var import_common23 = require("@nestjs/common");
|
|
4286
|
+
function _ts_decorate23(decorators, target, key, desc) {
|
|
4287
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4288
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4289
|
+
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;
|
|
4290
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4291
|
+
}
|
|
4292
|
+
__name(_ts_decorate23, "_ts_decorate");
|
|
4293
|
+
function _ts_metadata22(k, v) {
|
|
4294
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4295
|
+
}
|
|
4296
|
+
__name(_ts_metadata22, "_ts_metadata");
|
|
4297
|
+
function _ts_param22(paramIndex, decorator) {
|
|
4298
|
+
return function(target, key) {
|
|
4299
|
+
decorator(target, key, paramIndex);
|
|
4300
|
+
};
|
|
4301
|
+
}
|
|
4302
|
+
__name(_ts_param22, "_ts_param");
|
|
4121
4303
|
var ACTIVE_STATUSES = [
|
|
4122
4304
|
"ACTIVE",
|
|
4123
4305
|
"TRIAL"
|
|
@@ -4352,37 +4534,37 @@ var PrismaSubscriptionRepository = class {
|
|
|
4352
4534
|
]));
|
|
4353
4535
|
}
|
|
4354
4536
|
};
|
|
4355
|
-
PrismaSubscriptionRepository =
|
|
4356
|
-
(0,
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4537
|
+
PrismaSubscriptionRepository = _ts_decorate23([
|
|
4538
|
+
(0, import_common23.Injectable)(),
|
|
4539
|
+
_ts_param22(0, (0, import_common23.Inject)(PRISMA_CLIENT_TOKEN)),
|
|
4540
|
+
_ts_param22(1, (0, import_common23.Optional)()),
|
|
4541
|
+
_ts_param22(1, (0, import_common23.Inject)(PRISMA_SCHEMA_OPTIONS_TOKEN)),
|
|
4542
|
+
_ts_metadata22("design:type", Function),
|
|
4543
|
+
_ts_metadata22("design:paramtypes", [
|
|
4362
4544
|
typeof SubscriptionRepositoryClient === "undefined" ? Object : SubscriptionRepositoryClient,
|
|
4363
4545
|
typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
|
|
4364
4546
|
])
|
|
4365
4547
|
], PrismaSubscriptionRepository);
|
|
4366
4548
|
|
|
4367
4549
|
// src/prisma-subscription-usage.adapter.ts
|
|
4368
|
-
var
|
|
4369
|
-
function
|
|
4550
|
+
var import_common24 = require("@nestjs/common");
|
|
4551
|
+
function _ts_decorate24(decorators, target, key, desc) {
|
|
4370
4552
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4371
4553
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4372
4554
|
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;
|
|
4373
4555
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4374
4556
|
}
|
|
4375
|
-
__name(
|
|
4376
|
-
function
|
|
4557
|
+
__name(_ts_decorate24, "_ts_decorate");
|
|
4558
|
+
function _ts_metadata23(k, v) {
|
|
4377
4559
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4378
4560
|
}
|
|
4379
|
-
__name(
|
|
4380
|
-
function
|
|
4561
|
+
__name(_ts_metadata23, "_ts_metadata");
|
|
4562
|
+
function _ts_param23(paramIndex, decorator) {
|
|
4381
4563
|
return function(target, key) {
|
|
4382
4564
|
decorator(target, key, paramIndex);
|
|
4383
4565
|
};
|
|
4384
4566
|
}
|
|
4385
|
-
__name(
|
|
4567
|
+
__name(_ts_param23, "_ts_param");
|
|
4386
4568
|
var PrismaSubscriptionUsageAdapter = class {
|
|
4387
4569
|
static {
|
|
4388
4570
|
__name(this, "PrismaSubscriptionUsageAdapter");
|
|
@@ -4473,38 +4655,38 @@ var PrismaSubscriptionUsageAdapter = class {
|
|
|
4473
4655
|
return getPrismaDelegate(this.prisma, this.planVersionDelegateName);
|
|
4474
4656
|
}
|
|
4475
4657
|
};
|
|
4476
|
-
PrismaSubscriptionUsageAdapter =
|
|
4477
|
-
(0,
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4658
|
+
PrismaSubscriptionUsageAdapter = _ts_decorate24([
|
|
4659
|
+
(0, import_common24.Injectable)(),
|
|
4660
|
+
_ts_param23(0, (0, import_common24.Inject)(PRISMA_CLIENT_TOKEN)),
|
|
4661
|
+
_ts_param23(1, (0, import_common24.Optional)()),
|
|
4662
|
+
_ts_param23(1, (0, import_common24.Inject)(PRISMA_SCHEMA_OPTIONS_TOKEN)),
|
|
4663
|
+
_ts_metadata23("design:type", Function),
|
|
4664
|
+
_ts_metadata23("design:paramtypes", [
|
|
4483
4665
|
typeof SubscriptionUsageClient === "undefined" ? Object : SubscriptionUsageClient,
|
|
4484
4666
|
typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
|
|
4485
4667
|
])
|
|
4486
4668
|
], PrismaSubscriptionUsageAdapter);
|
|
4487
4669
|
|
|
4488
4670
|
// src/prisma-super-admin-bootstrap.adapter.ts
|
|
4489
|
-
var
|
|
4490
|
-
var
|
|
4491
|
-
function
|
|
4671
|
+
var import_common25 = require("@nestjs/common");
|
|
4672
|
+
var import_core9 = require("@saasicat/core");
|
|
4673
|
+
function _ts_decorate25(decorators, target, key, desc) {
|
|
4492
4674
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4493
4675
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4494
4676
|
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
4677
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4496
4678
|
}
|
|
4497
|
-
__name(
|
|
4498
|
-
function
|
|
4679
|
+
__name(_ts_decorate25, "_ts_decorate");
|
|
4680
|
+
function _ts_metadata24(k, v) {
|
|
4499
4681
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4500
4682
|
}
|
|
4501
|
-
__name(
|
|
4502
|
-
function
|
|
4683
|
+
__name(_ts_metadata24, "_ts_metadata");
|
|
4684
|
+
function _ts_param24(paramIndex, decorator) {
|
|
4503
4685
|
return function(target, key) {
|
|
4504
4686
|
decorator(target, key, paramIndex);
|
|
4505
4687
|
};
|
|
4506
4688
|
}
|
|
4507
|
-
__name(
|
|
4689
|
+
__name(_ts_param24, "_ts_param");
|
|
4508
4690
|
var PASSWORD_HASHER_TOKEN = /* @__PURE__ */ Symbol.for("saasicat/adapter-prisma/PasswordHasher");
|
|
4509
4691
|
var PrismaSuperAdminBootstrapAdapter = class {
|
|
4510
4692
|
static {
|
|
@@ -4532,7 +4714,7 @@ var PrismaSuperAdminBootstrapAdapter = class {
|
|
|
4532
4714
|
}
|
|
4533
4715
|
});
|
|
4534
4716
|
if (existing) {
|
|
4535
|
-
throw new
|
|
4717
|
+
throw new import_core9.PlatformUserExistsError(email, existing.platformRole);
|
|
4536
4718
|
}
|
|
4537
4719
|
const row = await this.prisma.superAdminUser.create({
|
|
4538
4720
|
data: {
|
|
@@ -4554,37 +4736,37 @@ var PrismaSuperAdminBootstrapAdapter = class {
|
|
|
4554
4736
|
};
|
|
4555
4737
|
}
|
|
4556
4738
|
};
|
|
4557
|
-
PrismaSuperAdminBootstrapAdapter =
|
|
4558
|
-
(0,
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4739
|
+
PrismaSuperAdminBootstrapAdapter = _ts_decorate25([
|
|
4740
|
+
(0, import_common25.Injectable)(),
|
|
4741
|
+
_ts_param24(0, (0, import_common25.Inject)(PRISMA_CLIENT_TOKEN)),
|
|
4742
|
+
_ts_param24(1, (0, import_common25.Inject)(PASSWORD_HASHER_TOKEN)),
|
|
4743
|
+
_ts_metadata24("design:type", Function),
|
|
4744
|
+
_ts_metadata24("design:paramtypes", [
|
|
4563
4745
|
typeof PrismaLike === "undefined" ? Object : PrismaLike,
|
|
4564
4746
|
typeof PasswordHasher === "undefined" ? Object : PasswordHasher
|
|
4565
4747
|
])
|
|
4566
4748
|
], PrismaSuperAdminBootstrapAdapter);
|
|
4567
4749
|
|
|
4568
4750
|
// src/prisma-tenant-subscription-write.adapter.ts
|
|
4569
|
-
var
|
|
4570
|
-
var
|
|
4571
|
-
function
|
|
4751
|
+
var import_common26 = require("@nestjs/common");
|
|
4752
|
+
var import_core10 = require("@saasicat/core");
|
|
4753
|
+
function _ts_decorate26(decorators, target, key, desc) {
|
|
4572
4754
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4573
4755
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4574
4756
|
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;
|
|
4575
4757
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4576
4758
|
}
|
|
4577
|
-
__name(
|
|
4578
|
-
function
|
|
4759
|
+
__name(_ts_decorate26, "_ts_decorate");
|
|
4760
|
+
function _ts_metadata25(k, v) {
|
|
4579
4761
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4580
4762
|
}
|
|
4581
|
-
__name(
|
|
4582
|
-
function
|
|
4763
|
+
__name(_ts_metadata25, "_ts_metadata");
|
|
4764
|
+
function _ts_param25(paramIndex, decorator) {
|
|
4583
4765
|
return function(target, key) {
|
|
4584
4766
|
decorator(target, key, paramIndex);
|
|
4585
4767
|
};
|
|
4586
4768
|
}
|
|
4587
|
-
__name(
|
|
4769
|
+
__name(_ts_param25, "_ts_param");
|
|
4588
4770
|
var PrismaTenantSubscriptionWriteAdapter = class {
|
|
4589
4771
|
static {
|
|
4590
4772
|
__name(this, "PrismaTenantSubscriptionWriteAdapter");
|
|
@@ -4854,9 +5036,9 @@ var PrismaTenantSubscriptionWriteAdapter = class {
|
|
|
4854
5036
|
}
|
|
4855
5037
|
async findTargetPlanVersionId(client, storagePlanId, asOf) {
|
|
4856
5038
|
const activeWindow = this.schema.tenantSubscription.activeVersionSelection === "validity-window";
|
|
4857
|
-
const activeVersionWhere = this.schema.tenantSubscription.withEndsAt ? (0,
|
|
5039
|
+
const activeVersionWhere = this.schema.tenantSubscription.withEndsAt ? (0, import_core10.buildActivePlanVersionWhere)(asOf, {
|
|
4858
5040
|
withEndsAt: true
|
|
4859
|
-
}) : (0,
|
|
5041
|
+
}) : (0, import_core10.buildActivePlanVersionWhere)(asOf);
|
|
4860
5042
|
const where = activeWindow ? {
|
|
4861
5043
|
planId: storagePlanId,
|
|
4862
5044
|
...activeVersionWhere
|
|
@@ -4920,13 +5102,13 @@ var PrismaTenantSubscriptionWriteAdapter = class {
|
|
|
4920
5102
|
}
|
|
4921
5103
|
}
|
|
4922
5104
|
};
|
|
4923
|
-
PrismaTenantSubscriptionWriteAdapter =
|
|
4924
|
-
(0,
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
5105
|
+
PrismaTenantSubscriptionWriteAdapter = _ts_decorate26([
|
|
5106
|
+
(0, import_common26.Injectable)(),
|
|
5107
|
+
_ts_param25(0, (0, import_common26.Inject)(PRISMA_CLIENT_TOKEN)),
|
|
5108
|
+
_ts_param25(1, (0, import_common26.Optional)()),
|
|
5109
|
+
_ts_param25(1, (0, import_common26.Inject)(PRISMA_SCHEMA_OPTIONS_TOKEN)),
|
|
5110
|
+
_ts_metadata25("design:type", Function),
|
|
5111
|
+
_ts_metadata25("design:paramtypes", [
|
|
4930
5112
|
typeof TransactionalPrismaClient === "undefined" ? Object : TransactionalPrismaClient,
|
|
4931
5113
|
typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
|
|
4932
5114
|
])
|
|
@@ -4945,24 +5127,24 @@ function clearedPendingVersionData() {
|
|
|
4945
5127
|
__name(clearedPendingVersionData, "clearedPendingVersionData");
|
|
4946
5128
|
|
|
4947
5129
|
// src/prisma-transaction-runner.adapter.ts
|
|
4948
|
-
var
|
|
4949
|
-
function
|
|
5130
|
+
var import_common27 = require("@nestjs/common");
|
|
5131
|
+
function _ts_decorate27(decorators, target, key, desc) {
|
|
4950
5132
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4951
5133
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4952
5134
|
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;
|
|
4953
5135
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4954
5136
|
}
|
|
4955
|
-
__name(
|
|
4956
|
-
function
|
|
5137
|
+
__name(_ts_decorate27, "_ts_decorate");
|
|
5138
|
+
function _ts_metadata26(k, v) {
|
|
4957
5139
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4958
5140
|
}
|
|
4959
|
-
__name(
|
|
4960
|
-
function
|
|
5141
|
+
__name(_ts_metadata26, "_ts_metadata");
|
|
5142
|
+
function _ts_param26(paramIndex, decorator) {
|
|
4961
5143
|
return function(target, key) {
|
|
4962
5144
|
decorator(target, key, paramIndex);
|
|
4963
5145
|
};
|
|
4964
5146
|
}
|
|
4965
|
-
__name(
|
|
5147
|
+
__name(_ts_param26, "_ts_param");
|
|
4966
5148
|
var PrismaTransactionRunner = class {
|
|
4967
5149
|
static {
|
|
4968
5150
|
__name(this, "PrismaTransactionRunner");
|
|
@@ -4976,24 +5158,24 @@ var PrismaTransactionRunner = class {
|
|
|
4976
5158
|
return transaction((tx) => fn(tx));
|
|
4977
5159
|
}
|
|
4978
5160
|
};
|
|
4979
|
-
PrismaTransactionRunner =
|
|
4980
|
-
(0,
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
5161
|
+
PrismaTransactionRunner = _ts_decorate27([
|
|
5162
|
+
(0, import_common27.Injectable)(),
|
|
5163
|
+
_ts_param26(0, (0, import_common27.Inject)(PRISMA_CLIENT_TOKEN)),
|
|
5164
|
+
_ts_metadata26("design:type", Function),
|
|
5165
|
+
_ts_metadata26("design:paramtypes", [
|
|
4984
5166
|
typeof Record === "undefined" ? Object : Record
|
|
4985
5167
|
])
|
|
4986
5168
|
], PrismaTransactionRunner);
|
|
4987
5169
|
|
|
4988
5170
|
// src/zero-promo-revenue-aggregator.adapter.ts
|
|
4989
|
-
var
|
|
4990
|
-
function
|
|
5171
|
+
var import_common28 = require("@nestjs/common");
|
|
5172
|
+
function _ts_decorate28(decorators, target, key, desc) {
|
|
4991
5173
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4992
5174
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4993
5175
|
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;
|
|
4994
5176
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4995
5177
|
}
|
|
4996
|
-
__name(
|
|
5178
|
+
__name(_ts_decorate28, "_ts_decorate");
|
|
4997
5179
|
var ZeroPromoRevenueDeductionAggregator = class {
|
|
4998
5180
|
static {
|
|
4999
5181
|
__name(this, "ZeroPromoRevenueDeductionAggregator");
|
|
@@ -5002,8 +5184,8 @@ var ZeroPromoRevenueDeductionAggregator = class {
|
|
|
5002
5184
|
return "0.00";
|
|
5003
5185
|
}
|
|
5004
5186
|
};
|
|
5005
|
-
ZeroPromoRevenueDeductionAggregator =
|
|
5006
|
-
(0,
|
|
5187
|
+
ZeroPromoRevenueDeductionAggregator = _ts_decorate28([
|
|
5188
|
+
(0, import_common28.Injectable)()
|
|
5007
5189
|
], ZeroPromoRevenueDeductionAggregator);
|
|
5008
5190
|
|
|
5009
5191
|
// src/prisma-persistence.ts
|
|
@@ -5036,6 +5218,7 @@ function prismaPersistence(options) {
|
|
|
5036
5218
|
subscriptionRepository: provide((prisma) => new PrismaSubscriptionRepository(prisma, options.schema)),
|
|
5037
5219
|
planVersionRepository: provide((prisma) => new PrismaPlanVersionRepository(prisma, options.schema)),
|
|
5038
5220
|
subscriptionContractRepository: provide((prisma) => new PrismaSubscriptionContractRepository(prisma)),
|
|
5221
|
+
subscriberRepository: provide((prisma) => new PrismaSubscriberRepository(canonical(prisma))),
|
|
5039
5222
|
subscriptionBundleRepository: provide((prisma) => new PrismaSubscriptionBundleRepository(canonical(prisma))),
|
|
5040
5223
|
bundleRepository: provide((prisma) => new PrismaBundleRepository(canonical(prisma), options.bundle))
|
|
5041
5224
|
},
|
|
@@ -5133,6 +5316,7 @@ __name(buildProvisioning, "buildProvisioning");
|
|
|
5133
5316
|
PrismaPromoCodeValidationLogRepository,
|
|
5134
5317
|
PrismaPromoSubscriptionLookup,
|
|
5135
5318
|
PrismaPromotionRepository,
|
|
5319
|
+
PrismaSubscriberRepository,
|
|
5136
5320
|
PrismaSubscriptionBundleRepository,
|
|
5137
5321
|
PrismaSubscriptionContractRepository,
|
|
5138
5322
|
PrismaSubscriptionRepository,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AdminResourcesPort, AdminTenantListFilter, AdminTenantListRow, AdminTenantDetail, AdminTenantStateResult, AdminUserListFilter, AdminUserListRow, AdminAuditListFilter, AuditEntry, AdminSubscriptionListRow, BundleRepository, TransactionContext, BundleVersionRow, BundleListFilter, BundleRow, CreateBundleData, UpdateBundleData, CreateBundleVersionDraftData, UpdateBundleVersionDraftData, PublishBundleVersionMeta, PersistenceInjectionToken, PasswordHasher, SaaSiCatPersistenceAdapter, TransactionRunner, MfaPort, AuditPort, AdminActor, AuditQueryPort, AuditQuery, AuditStatsPort, RlsBypassPort, SubscriptionRepository, SubscriptionRecord, SubscriptionUsagePort, SubscriptionUsageRecord, SubscriptionBundleRepository, SubscriptionBundleRecord, CreateSubscriptionBundleData, CancelSubscriptionBundleData, TenantSubscriptionWritePort, ApplyOnboardingSelectionInput, RedeemPromoInTransactionCallback, ApplyOnboardingSelectionResult, ImmediatePlanChangeInput, ScheduledPlanChangeInput, CancelSubscriptionInput, CancelSubscriptionResult, PlanVersionRepository, PlanVersionRecord, PromoCodeRepository, PromoCodeRecord, PromoCodeFilter, CreatePromoCodeData, UpdatePromoCodeData, PromoCodeRedemptionRepository, PromoCodeRedemptionRecord, PromoCodeRedemptionStatus, PromoCodeRedemptionListItem, PromoCodeValidationLogRepository, PromoSubscriptionLookup, BillingCycle, PromoRevenueDeductionAggregator, SuperAdminProvisioningPort, CreateSuperAdminCliInput, PlatformUserDto, PlanCatalogReadSink, PlanCatalogReadSnapshot, PlanCatalogImportSink, UpsertPlanInput, UpsertResult, UpsertPlanVersionInput, UpsertFeatureCatalogEntryInput, PlanRepository, PlanVersionRow, PlanListFilter, PlanRow, CreatePlanData, UpdatePlanData, CreatePlanVersionDraftData, UpdatePlanVersionDraftData, VersionChange, CatalogEntryRepository, CatalogEntryFilter, CapabilityCatalogEntryRow, FeatureCatalogEntryRow, QuotaCatalogEntryRow, UpsertCapabilityEntryData, UpsertFeatureEntryData, UpsertQuotaEntryData, SetCatalogEntryReviewData, CatalogEntryI18n, UpdateCatalogEntryBaseData, MarketingProjectionRepository, MarketingProjectionFilter, MarketingProjectionRow, CreateMarketingProjectionData, UpdateMarketingProjectionData, MarketingSettingsRepository, MarketingSettingsRow, UpdateMarketingSettingsData, PromotionRepository, PromotionRow, CreatePromotionData, UpdatePromotionData, SubscriptionContractRepository, SubscriptionContractFilter, SubscriptionContractRecord,
|
|
1
|
+
import { AdminResourcesPort, AdminTenantListFilter, AdminTenantListRow, AdminTenantDetail, AdminTenantStateResult, AdminUserListFilter, AdminUserListRow, AdminAuditListFilter, AuditEntry, AdminSubscriptionListRow, BundleRepository, TransactionContext, BundleVersionRow, BundleListFilter, BundleRow, CreateBundleData, UpdateBundleData, CreateBundleVersionDraftData, UpdateBundleVersionDraftData, PublishBundleVersionMeta, PersistenceInjectionToken, PasswordHasher, SaaSiCatPersistenceAdapter, TransactionRunner, MfaPort, AuditPort, AdminActor, AuditQueryPort, AuditQuery, AuditStatsPort, RlsBypassPort, SubscriptionRepository, SubscriptionRecord, SubscriptionUsagePort, SubscriptionUsageRecord, SubscriptionBundleRepository, SubscriptionBundleRecord, CreateSubscriptionBundleData, CancelSubscriptionBundleData, TenantSubscriptionWritePort, ApplyOnboardingSelectionInput, RedeemPromoInTransactionCallback, ApplyOnboardingSelectionResult, ImmediatePlanChangeInput, ScheduledPlanChangeInput, CancelSubscriptionInput, CancelSubscriptionResult, PlanVersionRepository, PlanVersionRecord, PromoCodeRepository, PromoCodeRecord, PromoCodeFilter, CreatePromoCodeData, UpdatePromoCodeData, PromoCodeRedemptionRepository, PromoCodeRedemptionRecord, PromoCodeRedemptionStatus, PromoCodeRedemptionListItem, PromoCodeValidationLogRepository, PromoSubscriptionLookup, BillingCycle, PromoRevenueDeductionAggregator, SuperAdminProvisioningPort, CreateSuperAdminCliInput, PlatformUserDto, PlanCatalogReadSink, PlanCatalogReadSnapshot, PlanCatalogImportSink, UpsertPlanInput, UpsertResult, UpsertPlanVersionInput, UpsertFeatureCatalogEntryInput, PlanRepository, PlanVersionRow, PlanListFilter, PlanRow, CreatePlanData, UpdatePlanData, CreatePlanVersionDraftData, UpdatePlanVersionDraftData, VersionChange, CatalogEntryRepository, CatalogEntryFilter, CapabilityCatalogEntryRow, FeatureCatalogEntryRow, QuotaCatalogEntryRow, UpsertCapabilityEntryData, UpsertFeatureEntryData, UpsertQuotaEntryData, SetCatalogEntryReviewData, CatalogEntryI18n, UpdateCatalogEntryBaseData, MarketingProjectionRepository, MarketingProjectionFilter, MarketingProjectionRow, CreateMarketingProjectionData, UpdateMarketingProjectionData, MarketingSettingsRepository, MarketingSettingsRow, UpdateMarketingSettingsData, PromotionRepository, PromotionRow, CreatePromotionData, UpdatePromotionData, SubscriptionContractRepository, SubscriptionContractFilter, SubscriptionContractRecord, NewSubscriptionContractData, TerminateSubscriptionContractData, SubscriberRepository, CreateSubscriberData, SubscriberRecord, SubscriberContactChange, SubscriberCorrectionData, SubscriberCorrectionResult, SubscriberCorrectionRecord, AppliedSettingsPort, AppliedSettingsRecord, NewSettingsChange, SettingsChangeRecord, SettingsChangeFilter } from '@saasicat/core';
|
|
2
2
|
|
|
3
3
|
declare const PRISMA_CLIENT_TOKEN: unique symbol;
|
|
4
4
|
/** Prisma `Decimal` values arrive as objects with `toString()`; tests may use plain values. */
|
|
@@ -1603,10 +1603,37 @@ declare class PrismaSubscriptionContractRepository implements SubscriptionContra
|
|
|
1603
1603
|
findById(contractId: string): Promise<SubscriptionContractRecord | null>;
|
|
1604
1604
|
findActiveByTenantId(tenantId: string, asOf?: Date, tx?: TransactionContext): Promise<SubscriptionContractRecord | null>;
|
|
1605
1605
|
findByOriginalOfferId(offerId: string, tx?: TransactionContext): Promise<SubscriptionContractRecord | null>;
|
|
1606
|
-
create(data:
|
|
1606
|
+
create(data: NewSubscriptionContractData, tx?: TransactionContext): Promise<SubscriptionContractRecord>;
|
|
1607
1607
|
terminate(contractId: string, data: TerminateSubscriptionContractData): Promise<SubscriptionContractRecord>;
|
|
1608
1608
|
}
|
|
1609
1609
|
|
|
1610
|
+
/** Root-client fields used directly: the delegates and the interactive transaction. */
|
|
1611
|
+
interface SubscriberRepositoryClient {
|
|
1612
|
+
subscriber: unknown;
|
|
1613
|
+
$transaction<T>(fn: (tx: unknown) => Promise<T>): Promise<T>;
|
|
1614
|
+
}
|
|
1615
|
+
/**
|
|
1616
|
+
* `SubscriberRepository` against the canonical `subscribers`,
|
|
1617
|
+
* `subscriber_tenants` and `subscriber_corrections` tables.
|
|
1618
|
+
*
|
|
1619
|
+
* The customer number is the column default: the database counts, from where
|
|
1620
|
+
* `constraints.postgres.sql` starts it, so two subscribers created at once
|
|
1621
|
+
* never share a number.
|
|
1622
|
+
*/
|
|
1623
|
+
declare class PrismaSubscriberRepository implements SubscriberRepository {
|
|
1624
|
+
private readonly prisma;
|
|
1625
|
+
constructor(prisma: SubscriberRepositoryClient);
|
|
1626
|
+
private db;
|
|
1627
|
+
/** On the caller's transaction when there is one, otherwise in one of its own. */
|
|
1628
|
+
private inTransaction;
|
|
1629
|
+
createForTenant(data: CreateSubscriberData, tx?: TransactionContext): Promise<SubscriberRecord | null>;
|
|
1630
|
+
findById(subscriberId: string, tx?: TransactionContext): Promise<SubscriberRecord | null>;
|
|
1631
|
+
findByTenantId(tenantId: string, tx?: TransactionContext): Promise<SubscriberRecord | null>;
|
|
1632
|
+
updateContact(subscriberId: string, change: SubscriberContactChange, tx?: TransactionContext): Promise<SubscriberRecord | null>;
|
|
1633
|
+
correctIdentity(subscriberId: string, data: SubscriberCorrectionData, tx?: TransactionContext): Promise<SubscriberCorrectionResult | null>;
|
|
1634
|
+
listCorrections(subscriberId: string): Promise<SubscriberCorrectionRecord[]>;
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1610
1637
|
/** Root-client fields used directly: the two delegates and the interactive transaction. */
|
|
1611
1638
|
interface AppliedSettingsRepositoryClient {
|
|
1612
1639
|
appliedSettings: unknown;
|
|
@@ -1628,4 +1655,4 @@ declare class PrismaAppliedSettingsRepository implements AppliedSettingsPort {
|
|
|
1628
1655
|
acknowledgeChange(id: string, acknowledgedBy: string, acknowledgedAt: Date): Promise<SettingsChangeRecord | null>;
|
|
1629
1656
|
}
|
|
1630
1657
|
|
|
1631
|
-
export { type AdminResourcesDelegates, type AdminResourcesFields, AsyncLocalRlsBypassAdapter, type DecimalLike, PASSWORD_HASHER_TOKEN, PRISMA_BUNDLE_REPOSITORY_OPTIONS, PRISMA_CLIENT_TOKEN, PRISMA_SCHEMA_OPTIONS_TOKEN, PrismaAdminResourcesAdapter, type PrismaAdminResourcesOptions, PrismaAppliedSettingsRepository, PrismaAuditAdapter, PrismaAuditQueryAdapter, PrismaAuditStatsAdapter, PrismaBundleRepository, type PrismaBundleRepositoryOptions, PrismaCatalogEntryRepository, type PrismaLike, PrismaMarketingProjectionRepository, PrismaMarketingSettingsRepository, PrismaMfaAdapter, type PrismaModelDelegateLike, type PrismaPersistenceOptions, type PrismaPlanBindingMode, type PrismaPlanBindingOptions, type PrismaPlanBindingResolver, PrismaPlanCatalogImportSink, PrismaPlanCatalogReadSink, type PrismaPlanDelegateOptions, PrismaPlanRepository, type PrismaPlanVersionFieldCapabilities, type PrismaPlanVersionFieldOptions, PrismaPlanVersionRepository, PrismaPromoCodeRedemptionRepository, PrismaPromoCodeRepository, PrismaPromoCodeValidationLogRepository, PrismaPromoSubscriptionLookup, PrismaPromotionRepository, type PrismaSchemaOptions, PrismaSubscriptionBundleRepository, PrismaSubscriptionContractRepository, PrismaSubscriptionRepository, PrismaSubscriptionUsageAdapter, PrismaSuperAdminBootstrapAdapter, type PrismaTenantSubscriptionOptions, PrismaTenantSubscriptionWriteAdapter, PrismaTransactionRunner, type PrismaTxLike, type ResolvedAdminResourcesSchema, type ResolvedPrismaSchemaOptions, ZeroPromoRevenueDeductionAggregator, assertDelegatesExist, buildActorTag, createPrismaPlanBindingResolver, getPrismaDelegate, prismaPersistence, resolveAdminResourcesSchema, resolvePrismaSchemaOptions };
|
|
1658
|
+
export { type AdminResourcesDelegates, type AdminResourcesFields, AsyncLocalRlsBypassAdapter, type DecimalLike, PASSWORD_HASHER_TOKEN, PRISMA_BUNDLE_REPOSITORY_OPTIONS, PRISMA_CLIENT_TOKEN, PRISMA_SCHEMA_OPTIONS_TOKEN, PrismaAdminResourcesAdapter, type PrismaAdminResourcesOptions, PrismaAppliedSettingsRepository, PrismaAuditAdapter, PrismaAuditQueryAdapter, PrismaAuditStatsAdapter, PrismaBundleRepository, type PrismaBundleRepositoryOptions, PrismaCatalogEntryRepository, type PrismaLike, PrismaMarketingProjectionRepository, PrismaMarketingSettingsRepository, PrismaMfaAdapter, type PrismaModelDelegateLike, type PrismaPersistenceOptions, type PrismaPlanBindingMode, type PrismaPlanBindingOptions, type PrismaPlanBindingResolver, PrismaPlanCatalogImportSink, PrismaPlanCatalogReadSink, type PrismaPlanDelegateOptions, PrismaPlanRepository, type PrismaPlanVersionFieldCapabilities, type PrismaPlanVersionFieldOptions, PrismaPlanVersionRepository, PrismaPromoCodeRedemptionRepository, PrismaPromoCodeRepository, PrismaPromoCodeValidationLogRepository, PrismaPromoSubscriptionLookup, PrismaPromotionRepository, type PrismaSchemaOptions, PrismaSubscriberRepository, PrismaSubscriptionBundleRepository, PrismaSubscriptionContractRepository, PrismaSubscriptionRepository, PrismaSubscriptionUsageAdapter, PrismaSuperAdminBootstrapAdapter, type PrismaTenantSubscriptionOptions, PrismaTenantSubscriptionWriteAdapter, PrismaTransactionRunner, type PrismaTxLike, type ResolvedAdminResourcesSchema, type ResolvedPrismaSchemaOptions, ZeroPromoRevenueDeductionAggregator, assertDelegatesExist, buildActorTag, createPrismaPlanBindingResolver, getPrismaDelegate, prismaPersistence, resolveAdminResourcesSchema, resolvePrismaSchemaOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AdminResourcesPort, AdminTenantListFilter, AdminTenantListRow, AdminTenantDetail, AdminTenantStateResult, AdminUserListFilter, AdminUserListRow, AdminAuditListFilter, AuditEntry, AdminSubscriptionListRow, BundleRepository, TransactionContext, BundleVersionRow, BundleListFilter, BundleRow, CreateBundleData, UpdateBundleData, CreateBundleVersionDraftData, UpdateBundleVersionDraftData, PublishBundleVersionMeta, PersistenceInjectionToken, PasswordHasher, SaaSiCatPersistenceAdapter, TransactionRunner, MfaPort, AuditPort, AdminActor, AuditQueryPort, AuditQuery, AuditStatsPort, RlsBypassPort, SubscriptionRepository, SubscriptionRecord, SubscriptionUsagePort, SubscriptionUsageRecord, SubscriptionBundleRepository, SubscriptionBundleRecord, CreateSubscriptionBundleData, CancelSubscriptionBundleData, TenantSubscriptionWritePort, ApplyOnboardingSelectionInput, RedeemPromoInTransactionCallback, ApplyOnboardingSelectionResult, ImmediatePlanChangeInput, ScheduledPlanChangeInput, CancelSubscriptionInput, CancelSubscriptionResult, PlanVersionRepository, PlanVersionRecord, PromoCodeRepository, PromoCodeRecord, PromoCodeFilter, CreatePromoCodeData, UpdatePromoCodeData, PromoCodeRedemptionRepository, PromoCodeRedemptionRecord, PromoCodeRedemptionStatus, PromoCodeRedemptionListItem, PromoCodeValidationLogRepository, PromoSubscriptionLookup, BillingCycle, PromoRevenueDeductionAggregator, SuperAdminProvisioningPort, CreateSuperAdminCliInput, PlatformUserDto, PlanCatalogReadSink, PlanCatalogReadSnapshot, PlanCatalogImportSink, UpsertPlanInput, UpsertResult, UpsertPlanVersionInput, UpsertFeatureCatalogEntryInput, PlanRepository, PlanVersionRow, PlanListFilter, PlanRow, CreatePlanData, UpdatePlanData, CreatePlanVersionDraftData, UpdatePlanVersionDraftData, VersionChange, CatalogEntryRepository, CatalogEntryFilter, CapabilityCatalogEntryRow, FeatureCatalogEntryRow, QuotaCatalogEntryRow, UpsertCapabilityEntryData, UpsertFeatureEntryData, UpsertQuotaEntryData, SetCatalogEntryReviewData, CatalogEntryI18n, UpdateCatalogEntryBaseData, MarketingProjectionRepository, MarketingProjectionFilter, MarketingProjectionRow, CreateMarketingProjectionData, UpdateMarketingProjectionData, MarketingSettingsRepository, MarketingSettingsRow, UpdateMarketingSettingsData, PromotionRepository, PromotionRow, CreatePromotionData, UpdatePromotionData, SubscriptionContractRepository, SubscriptionContractFilter, SubscriptionContractRecord,
|
|
1
|
+
import { AdminResourcesPort, AdminTenantListFilter, AdminTenantListRow, AdminTenantDetail, AdminTenantStateResult, AdminUserListFilter, AdminUserListRow, AdminAuditListFilter, AuditEntry, AdminSubscriptionListRow, BundleRepository, TransactionContext, BundleVersionRow, BundleListFilter, BundleRow, CreateBundleData, UpdateBundleData, CreateBundleVersionDraftData, UpdateBundleVersionDraftData, PublishBundleVersionMeta, PersistenceInjectionToken, PasswordHasher, SaaSiCatPersistenceAdapter, TransactionRunner, MfaPort, AuditPort, AdminActor, AuditQueryPort, AuditQuery, AuditStatsPort, RlsBypassPort, SubscriptionRepository, SubscriptionRecord, SubscriptionUsagePort, SubscriptionUsageRecord, SubscriptionBundleRepository, SubscriptionBundleRecord, CreateSubscriptionBundleData, CancelSubscriptionBundleData, TenantSubscriptionWritePort, ApplyOnboardingSelectionInput, RedeemPromoInTransactionCallback, ApplyOnboardingSelectionResult, ImmediatePlanChangeInput, ScheduledPlanChangeInput, CancelSubscriptionInput, CancelSubscriptionResult, PlanVersionRepository, PlanVersionRecord, PromoCodeRepository, PromoCodeRecord, PromoCodeFilter, CreatePromoCodeData, UpdatePromoCodeData, PromoCodeRedemptionRepository, PromoCodeRedemptionRecord, PromoCodeRedemptionStatus, PromoCodeRedemptionListItem, PromoCodeValidationLogRepository, PromoSubscriptionLookup, BillingCycle, PromoRevenueDeductionAggregator, SuperAdminProvisioningPort, CreateSuperAdminCliInput, PlatformUserDto, PlanCatalogReadSink, PlanCatalogReadSnapshot, PlanCatalogImportSink, UpsertPlanInput, UpsertResult, UpsertPlanVersionInput, UpsertFeatureCatalogEntryInput, PlanRepository, PlanVersionRow, PlanListFilter, PlanRow, CreatePlanData, UpdatePlanData, CreatePlanVersionDraftData, UpdatePlanVersionDraftData, VersionChange, CatalogEntryRepository, CatalogEntryFilter, CapabilityCatalogEntryRow, FeatureCatalogEntryRow, QuotaCatalogEntryRow, UpsertCapabilityEntryData, UpsertFeatureEntryData, UpsertQuotaEntryData, SetCatalogEntryReviewData, CatalogEntryI18n, UpdateCatalogEntryBaseData, MarketingProjectionRepository, MarketingProjectionFilter, MarketingProjectionRow, CreateMarketingProjectionData, UpdateMarketingProjectionData, MarketingSettingsRepository, MarketingSettingsRow, UpdateMarketingSettingsData, PromotionRepository, PromotionRow, CreatePromotionData, UpdatePromotionData, SubscriptionContractRepository, SubscriptionContractFilter, SubscriptionContractRecord, NewSubscriptionContractData, TerminateSubscriptionContractData, SubscriberRepository, CreateSubscriberData, SubscriberRecord, SubscriberContactChange, SubscriberCorrectionData, SubscriberCorrectionResult, SubscriberCorrectionRecord, AppliedSettingsPort, AppliedSettingsRecord, NewSettingsChange, SettingsChangeRecord, SettingsChangeFilter } from '@saasicat/core';
|
|
2
2
|
|
|
3
3
|
declare const PRISMA_CLIENT_TOKEN: unique symbol;
|
|
4
4
|
/** Prisma `Decimal` values arrive as objects with `toString()`; tests may use plain values. */
|
|
@@ -1603,10 +1603,37 @@ declare class PrismaSubscriptionContractRepository implements SubscriptionContra
|
|
|
1603
1603
|
findById(contractId: string): Promise<SubscriptionContractRecord | null>;
|
|
1604
1604
|
findActiveByTenantId(tenantId: string, asOf?: Date, tx?: TransactionContext): Promise<SubscriptionContractRecord | null>;
|
|
1605
1605
|
findByOriginalOfferId(offerId: string, tx?: TransactionContext): Promise<SubscriptionContractRecord | null>;
|
|
1606
|
-
create(data:
|
|
1606
|
+
create(data: NewSubscriptionContractData, tx?: TransactionContext): Promise<SubscriptionContractRecord>;
|
|
1607
1607
|
terminate(contractId: string, data: TerminateSubscriptionContractData): Promise<SubscriptionContractRecord>;
|
|
1608
1608
|
}
|
|
1609
1609
|
|
|
1610
|
+
/** Root-client fields used directly: the delegates and the interactive transaction. */
|
|
1611
|
+
interface SubscriberRepositoryClient {
|
|
1612
|
+
subscriber: unknown;
|
|
1613
|
+
$transaction<T>(fn: (tx: unknown) => Promise<T>): Promise<T>;
|
|
1614
|
+
}
|
|
1615
|
+
/**
|
|
1616
|
+
* `SubscriberRepository` against the canonical `subscribers`,
|
|
1617
|
+
* `subscriber_tenants` and `subscriber_corrections` tables.
|
|
1618
|
+
*
|
|
1619
|
+
* The customer number is the column default: the database counts, from where
|
|
1620
|
+
* `constraints.postgres.sql` starts it, so two subscribers created at once
|
|
1621
|
+
* never share a number.
|
|
1622
|
+
*/
|
|
1623
|
+
declare class PrismaSubscriberRepository implements SubscriberRepository {
|
|
1624
|
+
private readonly prisma;
|
|
1625
|
+
constructor(prisma: SubscriberRepositoryClient);
|
|
1626
|
+
private db;
|
|
1627
|
+
/** On the caller's transaction when there is one, otherwise in one of its own. */
|
|
1628
|
+
private inTransaction;
|
|
1629
|
+
createForTenant(data: CreateSubscriberData, tx?: TransactionContext): Promise<SubscriberRecord | null>;
|
|
1630
|
+
findById(subscriberId: string, tx?: TransactionContext): Promise<SubscriberRecord | null>;
|
|
1631
|
+
findByTenantId(tenantId: string, tx?: TransactionContext): Promise<SubscriberRecord | null>;
|
|
1632
|
+
updateContact(subscriberId: string, change: SubscriberContactChange, tx?: TransactionContext): Promise<SubscriberRecord | null>;
|
|
1633
|
+
correctIdentity(subscriberId: string, data: SubscriberCorrectionData, tx?: TransactionContext): Promise<SubscriberCorrectionResult | null>;
|
|
1634
|
+
listCorrections(subscriberId: string): Promise<SubscriberCorrectionRecord[]>;
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1610
1637
|
/** Root-client fields used directly: the two delegates and the interactive transaction. */
|
|
1611
1638
|
interface AppliedSettingsRepositoryClient {
|
|
1612
1639
|
appliedSettings: unknown;
|
|
@@ -1628,4 +1655,4 @@ declare class PrismaAppliedSettingsRepository implements AppliedSettingsPort {
|
|
|
1628
1655
|
acknowledgeChange(id: string, acknowledgedBy: string, acknowledgedAt: Date): Promise<SettingsChangeRecord | null>;
|
|
1629
1656
|
}
|
|
1630
1657
|
|
|
1631
|
-
export { type AdminResourcesDelegates, type AdminResourcesFields, AsyncLocalRlsBypassAdapter, type DecimalLike, PASSWORD_HASHER_TOKEN, PRISMA_BUNDLE_REPOSITORY_OPTIONS, PRISMA_CLIENT_TOKEN, PRISMA_SCHEMA_OPTIONS_TOKEN, PrismaAdminResourcesAdapter, type PrismaAdminResourcesOptions, PrismaAppliedSettingsRepository, PrismaAuditAdapter, PrismaAuditQueryAdapter, PrismaAuditStatsAdapter, PrismaBundleRepository, type PrismaBundleRepositoryOptions, PrismaCatalogEntryRepository, type PrismaLike, PrismaMarketingProjectionRepository, PrismaMarketingSettingsRepository, PrismaMfaAdapter, type PrismaModelDelegateLike, type PrismaPersistenceOptions, type PrismaPlanBindingMode, type PrismaPlanBindingOptions, type PrismaPlanBindingResolver, PrismaPlanCatalogImportSink, PrismaPlanCatalogReadSink, type PrismaPlanDelegateOptions, PrismaPlanRepository, type PrismaPlanVersionFieldCapabilities, type PrismaPlanVersionFieldOptions, PrismaPlanVersionRepository, PrismaPromoCodeRedemptionRepository, PrismaPromoCodeRepository, PrismaPromoCodeValidationLogRepository, PrismaPromoSubscriptionLookup, PrismaPromotionRepository, type PrismaSchemaOptions, PrismaSubscriptionBundleRepository, PrismaSubscriptionContractRepository, PrismaSubscriptionRepository, PrismaSubscriptionUsageAdapter, PrismaSuperAdminBootstrapAdapter, type PrismaTenantSubscriptionOptions, PrismaTenantSubscriptionWriteAdapter, PrismaTransactionRunner, type PrismaTxLike, type ResolvedAdminResourcesSchema, type ResolvedPrismaSchemaOptions, ZeroPromoRevenueDeductionAggregator, assertDelegatesExist, buildActorTag, createPrismaPlanBindingResolver, getPrismaDelegate, prismaPersistence, resolveAdminResourcesSchema, resolvePrismaSchemaOptions };
|
|
1658
|
+
export { type AdminResourcesDelegates, type AdminResourcesFields, AsyncLocalRlsBypassAdapter, type DecimalLike, PASSWORD_HASHER_TOKEN, PRISMA_BUNDLE_REPOSITORY_OPTIONS, PRISMA_CLIENT_TOKEN, PRISMA_SCHEMA_OPTIONS_TOKEN, PrismaAdminResourcesAdapter, type PrismaAdminResourcesOptions, PrismaAppliedSettingsRepository, PrismaAuditAdapter, PrismaAuditQueryAdapter, PrismaAuditStatsAdapter, PrismaBundleRepository, type PrismaBundleRepositoryOptions, PrismaCatalogEntryRepository, type PrismaLike, PrismaMarketingProjectionRepository, PrismaMarketingSettingsRepository, PrismaMfaAdapter, type PrismaModelDelegateLike, type PrismaPersistenceOptions, type PrismaPlanBindingMode, type PrismaPlanBindingOptions, type PrismaPlanBindingResolver, PrismaPlanCatalogImportSink, PrismaPlanCatalogReadSink, type PrismaPlanDelegateOptions, PrismaPlanRepository, type PrismaPlanVersionFieldCapabilities, type PrismaPlanVersionFieldOptions, PrismaPlanVersionRepository, PrismaPromoCodeRedemptionRepository, PrismaPromoCodeRepository, PrismaPromoCodeValidationLogRepository, PrismaPromoSubscriptionLookup, PrismaPromotionRepository, type PrismaSchemaOptions, PrismaSubscriberRepository, PrismaSubscriptionBundleRepository, PrismaSubscriptionContractRepository, PrismaSubscriptionRepository, PrismaSubscriptionUsageAdapter, PrismaSuperAdminBootstrapAdapter, type PrismaTenantSubscriptionOptions, PrismaTenantSubscriptionWriteAdapter, PrismaTransactionRunner, type PrismaTxLike, type ResolvedAdminResourcesSchema, type ResolvedPrismaSchemaOptions, ZeroPromoRevenueDeductionAggregator, assertDelegatesExist, buildActorTag, createPrismaPlanBindingResolver, getPrismaDelegate, prismaPersistence, resolveAdminResourcesSchema, resolvePrismaSchemaOptions };
|
package/dist/index.js
CHANGED
|
@@ -3956,6 +3956,8 @@ var PrismaSubscriptionContractRepository = class {
|
|
|
3956
3956
|
const row = await this.db(tx).subscriptionContract.create({
|
|
3957
3957
|
data: {
|
|
3958
3958
|
tenantId: data.tenantId,
|
|
3959
|
+
subscriberId: data.parties.subscriberId,
|
|
3960
|
+
subscriberSnapshot: data.parties.subscriber,
|
|
3959
3961
|
status: data.status ?? "active",
|
|
3960
3962
|
effectiveFrom: data.effectiveFrom,
|
|
3961
3963
|
effectiveUntil: data.effectiveUntil ?? null,
|
|
@@ -3973,6 +3975,9 @@ var PrismaSubscriptionContractRepository = class {
|
|
|
3973
3975
|
...data.termsSnapshot != null ? {
|
|
3974
3976
|
termsSnapshot: data.termsSnapshot
|
|
3975
3977
|
} : {},
|
|
3978
|
+
...data.parties.issuer != null ? {
|
|
3979
|
+
issuerSnapshot: data.parties.issuer
|
|
3980
|
+
} : {},
|
|
3976
3981
|
lineItems: {
|
|
3977
3982
|
create: data.lineItems.map(toLineItemCreate)
|
|
3978
3983
|
}
|
|
@@ -4037,8 +4042,9 @@ function toLineItemCreate(item) {
|
|
|
4037
4042
|
}
|
|
4038
4043
|
__name(toLineItemCreate, "toLineItemCreate");
|
|
4039
4044
|
|
|
4040
|
-
// src/prisma-
|
|
4041
|
-
import { Inject as Inject21, Injectable as Injectable22
|
|
4045
|
+
// src/prisma-subscriber.repository.ts
|
|
4046
|
+
import { Inject as Inject21, Injectable as Injectable22 } from "@nestjs/common";
|
|
4047
|
+
import { identityCorrectionDelta, toSubscriberCorrectionRecord, toSubscriberRecord } from "@saasicat/core";
|
|
4042
4048
|
function _ts_decorate22(decorators, target, key, desc) {
|
|
4043
4049
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4044
4050
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4056,6 +4062,181 @@ function _ts_param21(paramIndex, decorator) {
|
|
|
4056
4062
|
};
|
|
4057
4063
|
}
|
|
4058
4064
|
__name(_ts_param21, "_ts_param");
|
|
4065
|
+
var WITH_LIVE_TENANT = {
|
|
4066
|
+
tenants: {
|
|
4067
|
+
where: {
|
|
4068
|
+
unlinkedAt: null
|
|
4069
|
+
},
|
|
4070
|
+
select: {
|
|
4071
|
+
tenantId: true
|
|
4072
|
+
},
|
|
4073
|
+
take: 1
|
|
4074
|
+
}
|
|
4075
|
+
};
|
|
4076
|
+
var PrismaSubscriberRepository = class {
|
|
4077
|
+
static {
|
|
4078
|
+
__name(this, "PrismaSubscriberRepository");
|
|
4079
|
+
}
|
|
4080
|
+
prisma;
|
|
4081
|
+
constructor(prisma) {
|
|
4082
|
+
this.prisma = prisma;
|
|
4083
|
+
}
|
|
4084
|
+
db(tx) {
|
|
4085
|
+
return tx ?? this.prisma;
|
|
4086
|
+
}
|
|
4087
|
+
/** On the caller's transaction when there is one, otherwise in one of its own. */
|
|
4088
|
+
inTransaction(tx, fn) {
|
|
4089
|
+
if (tx) return fn(this.db(tx));
|
|
4090
|
+
return this.prisma.$transaction((own) => fn(own));
|
|
4091
|
+
}
|
|
4092
|
+
async createForTenant(data, tx) {
|
|
4093
|
+
const { tenantId, ...details } = data;
|
|
4094
|
+
return this.inTransaction(tx, async (db) => {
|
|
4095
|
+
const created = await db.subscriber.create({
|
|
4096
|
+
data: details
|
|
4097
|
+
});
|
|
4098
|
+
const linked = await db.subscriberTenant.createMany({
|
|
4099
|
+
data: [
|
|
4100
|
+
{
|
|
4101
|
+
subscriberId: created.id,
|
|
4102
|
+
tenantId
|
|
4103
|
+
}
|
|
4104
|
+
],
|
|
4105
|
+
skipDuplicates: true
|
|
4106
|
+
});
|
|
4107
|
+
if (linked.count === 0) {
|
|
4108
|
+
await db.subscriber.delete({
|
|
4109
|
+
where: {
|
|
4110
|
+
id: created.id
|
|
4111
|
+
}
|
|
4112
|
+
});
|
|
4113
|
+
return null;
|
|
4114
|
+
}
|
|
4115
|
+
return toSubscriberRecord(created, tenantId);
|
|
4116
|
+
});
|
|
4117
|
+
}
|
|
4118
|
+
async findById(subscriberId, tx) {
|
|
4119
|
+
const row = await this.db(tx).subscriber.findUnique({
|
|
4120
|
+
where: {
|
|
4121
|
+
id: subscriberId
|
|
4122
|
+
},
|
|
4123
|
+
include: WITH_LIVE_TENANT
|
|
4124
|
+
});
|
|
4125
|
+
return row ? toRecord4(row) : null;
|
|
4126
|
+
}
|
|
4127
|
+
async findByTenantId(tenantId, tx) {
|
|
4128
|
+
const row = await this.db(tx).subscriber.findFirst({
|
|
4129
|
+
where: {
|
|
4130
|
+
tenants: {
|
|
4131
|
+
some: {
|
|
4132
|
+
tenantId,
|
|
4133
|
+
unlinkedAt: null
|
|
4134
|
+
}
|
|
4135
|
+
}
|
|
4136
|
+
}
|
|
4137
|
+
});
|
|
4138
|
+
return row ? toSubscriberRecord(row, tenantId) : null;
|
|
4139
|
+
}
|
|
4140
|
+
async updateContact(subscriberId, change, tx) {
|
|
4141
|
+
const db = this.db(tx);
|
|
4142
|
+
const { count } = await db.subscriber.updateMany({
|
|
4143
|
+
where: {
|
|
4144
|
+
id: subscriberId
|
|
4145
|
+
},
|
|
4146
|
+
data: change
|
|
4147
|
+
});
|
|
4148
|
+
if (count === 0) return null;
|
|
4149
|
+
return this.findById(subscriberId, tx);
|
|
4150
|
+
}
|
|
4151
|
+
async correctIdentity(subscriberId, data, tx) {
|
|
4152
|
+
return this.inTransaction(tx, async (db) => {
|
|
4153
|
+
await db.$queryRaw`SELECT "id" FROM "subscribers" WHERE "id" = ${subscriberId} FOR UPDATE`;
|
|
4154
|
+
const current = await db.subscriber.findUnique({
|
|
4155
|
+
where: {
|
|
4156
|
+
id: subscriberId
|
|
4157
|
+
},
|
|
4158
|
+
include: WITH_LIVE_TENANT
|
|
4159
|
+
});
|
|
4160
|
+
if (!current) return null;
|
|
4161
|
+
const delta = identityCorrectionDelta(current, data.corrected);
|
|
4162
|
+
if (Object.keys(delta.corrected).length === 0) {
|
|
4163
|
+
return {
|
|
4164
|
+
subscriber: toRecord4(current),
|
|
4165
|
+
correction: null
|
|
4166
|
+
};
|
|
4167
|
+
}
|
|
4168
|
+
const updated = await db.subscriber.update({
|
|
4169
|
+
where: {
|
|
4170
|
+
id: subscriberId
|
|
4171
|
+
},
|
|
4172
|
+
data: delta.corrected,
|
|
4173
|
+
include: WITH_LIVE_TENANT
|
|
4174
|
+
});
|
|
4175
|
+
const correction = await db.subscriberCorrection.create({
|
|
4176
|
+
data: {
|
|
4177
|
+
subscriberId,
|
|
4178
|
+
previous: delta.previous,
|
|
4179
|
+
corrected: delta.corrected,
|
|
4180
|
+
reason: data.reason,
|
|
4181
|
+
correctedBy: data.correctedBy,
|
|
4182
|
+
correctedAt: data.correctedAt
|
|
4183
|
+
}
|
|
4184
|
+
});
|
|
4185
|
+
return {
|
|
4186
|
+
subscriber: toRecord4(updated),
|
|
4187
|
+
correction: toSubscriberCorrectionRecord(correction)
|
|
4188
|
+
};
|
|
4189
|
+
});
|
|
4190
|
+
}
|
|
4191
|
+
async listCorrections(subscriberId) {
|
|
4192
|
+
const rows = await this.db().subscriberCorrection.findMany({
|
|
4193
|
+
where: {
|
|
4194
|
+
subscriberId
|
|
4195
|
+
},
|
|
4196
|
+
orderBy: [
|
|
4197
|
+
{
|
|
4198
|
+
correctedAt: "desc"
|
|
4199
|
+
},
|
|
4200
|
+
{
|
|
4201
|
+
id: "desc"
|
|
4202
|
+
}
|
|
4203
|
+
]
|
|
4204
|
+
});
|
|
4205
|
+
return rows.map(toSubscriberCorrectionRecord);
|
|
4206
|
+
}
|
|
4207
|
+
};
|
|
4208
|
+
PrismaSubscriberRepository = _ts_decorate22([
|
|
4209
|
+
Injectable22(),
|
|
4210
|
+
_ts_param21(0, Inject21(PRISMA_CLIENT_TOKEN)),
|
|
4211
|
+
_ts_metadata21("design:type", Function),
|
|
4212
|
+
_ts_metadata21("design:paramtypes", [
|
|
4213
|
+
typeof SubscriberRepositoryClient === "undefined" ? Object : SubscriberRepositoryClient
|
|
4214
|
+
])
|
|
4215
|
+
], PrismaSubscriberRepository);
|
|
4216
|
+
function toRecord4(row) {
|
|
4217
|
+
return toSubscriberRecord(row, row.tenants?.[0]?.tenantId ?? null);
|
|
4218
|
+
}
|
|
4219
|
+
__name(toRecord4, "toRecord");
|
|
4220
|
+
|
|
4221
|
+
// src/prisma-subscription.repository.ts
|
|
4222
|
+
import { Inject as Inject22, Injectable as Injectable23, Optional as Optional6 } from "@nestjs/common";
|
|
4223
|
+
function _ts_decorate23(decorators, target, key, desc) {
|
|
4224
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4225
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4226
|
+
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;
|
|
4227
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4228
|
+
}
|
|
4229
|
+
__name(_ts_decorate23, "_ts_decorate");
|
|
4230
|
+
function _ts_metadata22(k, v) {
|
|
4231
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4232
|
+
}
|
|
4233
|
+
__name(_ts_metadata22, "_ts_metadata");
|
|
4234
|
+
function _ts_param22(paramIndex, decorator) {
|
|
4235
|
+
return function(target, key) {
|
|
4236
|
+
decorator(target, key, paramIndex);
|
|
4237
|
+
};
|
|
4238
|
+
}
|
|
4239
|
+
__name(_ts_param22, "_ts_param");
|
|
4059
4240
|
var ACTIVE_STATUSES = [
|
|
4060
4241
|
"ACTIVE",
|
|
4061
4242
|
"TRIAL"
|
|
@@ -4290,37 +4471,37 @@ var PrismaSubscriptionRepository = class {
|
|
|
4290
4471
|
]));
|
|
4291
4472
|
}
|
|
4292
4473
|
};
|
|
4293
|
-
PrismaSubscriptionRepository =
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4474
|
+
PrismaSubscriptionRepository = _ts_decorate23([
|
|
4475
|
+
Injectable23(),
|
|
4476
|
+
_ts_param22(0, Inject22(PRISMA_CLIENT_TOKEN)),
|
|
4477
|
+
_ts_param22(1, Optional6()),
|
|
4478
|
+
_ts_param22(1, Inject22(PRISMA_SCHEMA_OPTIONS_TOKEN)),
|
|
4479
|
+
_ts_metadata22("design:type", Function),
|
|
4480
|
+
_ts_metadata22("design:paramtypes", [
|
|
4300
4481
|
typeof SubscriptionRepositoryClient === "undefined" ? Object : SubscriptionRepositoryClient,
|
|
4301
4482
|
typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
|
|
4302
4483
|
])
|
|
4303
4484
|
], PrismaSubscriptionRepository);
|
|
4304
4485
|
|
|
4305
4486
|
// src/prisma-subscription-usage.adapter.ts
|
|
4306
|
-
import { Inject as
|
|
4307
|
-
function
|
|
4487
|
+
import { Inject as Inject23, Injectable as Injectable24, Optional as Optional7 } from "@nestjs/common";
|
|
4488
|
+
function _ts_decorate24(decorators, target, key, desc) {
|
|
4308
4489
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4309
4490
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4310
4491
|
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;
|
|
4311
4492
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4312
4493
|
}
|
|
4313
|
-
__name(
|
|
4314
|
-
function
|
|
4494
|
+
__name(_ts_decorate24, "_ts_decorate");
|
|
4495
|
+
function _ts_metadata23(k, v) {
|
|
4315
4496
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4316
4497
|
}
|
|
4317
|
-
__name(
|
|
4318
|
-
function
|
|
4498
|
+
__name(_ts_metadata23, "_ts_metadata");
|
|
4499
|
+
function _ts_param23(paramIndex, decorator) {
|
|
4319
4500
|
return function(target, key) {
|
|
4320
4501
|
decorator(target, key, paramIndex);
|
|
4321
4502
|
};
|
|
4322
4503
|
}
|
|
4323
|
-
__name(
|
|
4504
|
+
__name(_ts_param23, "_ts_param");
|
|
4324
4505
|
var PrismaSubscriptionUsageAdapter = class {
|
|
4325
4506
|
static {
|
|
4326
4507
|
__name(this, "PrismaSubscriptionUsageAdapter");
|
|
@@ -4411,38 +4592,38 @@ var PrismaSubscriptionUsageAdapter = class {
|
|
|
4411
4592
|
return getPrismaDelegate(this.prisma, this.planVersionDelegateName);
|
|
4412
4593
|
}
|
|
4413
4594
|
};
|
|
4414
|
-
PrismaSubscriptionUsageAdapter =
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4595
|
+
PrismaSubscriptionUsageAdapter = _ts_decorate24([
|
|
4596
|
+
Injectable24(),
|
|
4597
|
+
_ts_param23(0, Inject23(PRISMA_CLIENT_TOKEN)),
|
|
4598
|
+
_ts_param23(1, Optional7()),
|
|
4599
|
+
_ts_param23(1, Inject23(PRISMA_SCHEMA_OPTIONS_TOKEN)),
|
|
4600
|
+
_ts_metadata23("design:type", Function),
|
|
4601
|
+
_ts_metadata23("design:paramtypes", [
|
|
4421
4602
|
typeof SubscriptionUsageClient === "undefined" ? Object : SubscriptionUsageClient,
|
|
4422
4603
|
typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
|
|
4423
4604
|
])
|
|
4424
4605
|
], PrismaSubscriptionUsageAdapter);
|
|
4425
4606
|
|
|
4426
4607
|
// src/prisma-super-admin-bootstrap.adapter.ts
|
|
4427
|
-
import { Inject as
|
|
4608
|
+
import { Inject as Inject24, Injectable as Injectable25 } from "@nestjs/common";
|
|
4428
4609
|
import { PlatformUserExistsError } from "@saasicat/core";
|
|
4429
|
-
function
|
|
4610
|
+
function _ts_decorate25(decorators, target, key, desc) {
|
|
4430
4611
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4431
4612
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4432
4613
|
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;
|
|
4433
4614
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4434
4615
|
}
|
|
4435
|
-
__name(
|
|
4436
|
-
function
|
|
4616
|
+
__name(_ts_decorate25, "_ts_decorate");
|
|
4617
|
+
function _ts_metadata24(k, v) {
|
|
4437
4618
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4438
4619
|
}
|
|
4439
|
-
__name(
|
|
4440
|
-
function
|
|
4620
|
+
__name(_ts_metadata24, "_ts_metadata");
|
|
4621
|
+
function _ts_param24(paramIndex, decorator) {
|
|
4441
4622
|
return function(target, key) {
|
|
4442
4623
|
decorator(target, key, paramIndex);
|
|
4443
4624
|
};
|
|
4444
4625
|
}
|
|
4445
|
-
__name(
|
|
4626
|
+
__name(_ts_param24, "_ts_param");
|
|
4446
4627
|
var PASSWORD_HASHER_TOKEN = /* @__PURE__ */ Symbol.for("saasicat/adapter-prisma/PasswordHasher");
|
|
4447
4628
|
var PrismaSuperAdminBootstrapAdapter = class {
|
|
4448
4629
|
static {
|
|
@@ -4492,37 +4673,37 @@ var PrismaSuperAdminBootstrapAdapter = class {
|
|
|
4492
4673
|
};
|
|
4493
4674
|
}
|
|
4494
4675
|
};
|
|
4495
|
-
PrismaSuperAdminBootstrapAdapter =
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4676
|
+
PrismaSuperAdminBootstrapAdapter = _ts_decorate25([
|
|
4677
|
+
Injectable25(),
|
|
4678
|
+
_ts_param24(0, Inject24(PRISMA_CLIENT_TOKEN)),
|
|
4679
|
+
_ts_param24(1, Inject24(PASSWORD_HASHER_TOKEN)),
|
|
4680
|
+
_ts_metadata24("design:type", Function),
|
|
4681
|
+
_ts_metadata24("design:paramtypes", [
|
|
4501
4682
|
typeof PrismaLike === "undefined" ? Object : PrismaLike,
|
|
4502
4683
|
typeof PasswordHasher === "undefined" ? Object : PasswordHasher
|
|
4503
4684
|
])
|
|
4504
4685
|
], PrismaSuperAdminBootstrapAdapter);
|
|
4505
4686
|
|
|
4506
4687
|
// src/prisma-tenant-subscription-write.adapter.ts
|
|
4507
|
-
import { Inject as
|
|
4688
|
+
import { Inject as Inject25, Injectable as Injectable26, Optional as Optional8 } from "@nestjs/common";
|
|
4508
4689
|
import { buildActivePlanVersionWhere as buildActivePlanVersionWhere3 } from "@saasicat/core";
|
|
4509
|
-
function
|
|
4690
|
+
function _ts_decorate26(decorators, target, key, desc) {
|
|
4510
4691
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4511
4692
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4512
4693
|
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;
|
|
4513
4694
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4514
4695
|
}
|
|
4515
|
-
__name(
|
|
4516
|
-
function
|
|
4696
|
+
__name(_ts_decorate26, "_ts_decorate");
|
|
4697
|
+
function _ts_metadata25(k, v) {
|
|
4517
4698
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4518
4699
|
}
|
|
4519
|
-
__name(
|
|
4520
|
-
function
|
|
4700
|
+
__name(_ts_metadata25, "_ts_metadata");
|
|
4701
|
+
function _ts_param25(paramIndex, decorator) {
|
|
4521
4702
|
return function(target, key) {
|
|
4522
4703
|
decorator(target, key, paramIndex);
|
|
4523
4704
|
};
|
|
4524
4705
|
}
|
|
4525
|
-
__name(
|
|
4706
|
+
__name(_ts_param25, "_ts_param");
|
|
4526
4707
|
var PrismaTenantSubscriptionWriteAdapter = class {
|
|
4527
4708
|
static {
|
|
4528
4709
|
__name(this, "PrismaTenantSubscriptionWriteAdapter");
|
|
@@ -4858,13 +5039,13 @@ var PrismaTenantSubscriptionWriteAdapter = class {
|
|
|
4858
5039
|
}
|
|
4859
5040
|
}
|
|
4860
5041
|
};
|
|
4861
|
-
PrismaTenantSubscriptionWriteAdapter =
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
5042
|
+
PrismaTenantSubscriptionWriteAdapter = _ts_decorate26([
|
|
5043
|
+
Injectable26(),
|
|
5044
|
+
_ts_param25(0, Inject25(PRISMA_CLIENT_TOKEN)),
|
|
5045
|
+
_ts_param25(1, Optional8()),
|
|
5046
|
+
_ts_param25(1, Inject25(PRISMA_SCHEMA_OPTIONS_TOKEN)),
|
|
5047
|
+
_ts_metadata25("design:type", Function),
|
|
5048
|
+
_ts_metadata25("design:paramtypes", [
|
|
4868
5049
|
typeof TransactionalPrismaClient === "undefined" ? Object : TransactionalPrismaClient,
|
|
4869
5050
|
typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
|
|
4870
5051
|
])
|
|
@@ -4883,24 +5064,24 @@ function clearedPendingVersionData() {
|
|
|
4883
5064
|
__name(clearedPendingVersionData, "clearedPendingVersionData");
|
|
4884
5065
|
|
|
4885
5066
|
// src/prisma-transaction-runner.adapter.ts
|
|
4886
|
-
import { Inject as
|
|
4887
|
-
function
|
|
5067
|
+
import { Inject as Inject26, Injectable as Injectable27 } from "@nestjs/common";
|
|
5068
|
+
function _ts_decorate27(decorators, target, key, desc) {
|
|
4888
5069
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4889
5070
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4890
5071
|
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;
|
|
4891
5072
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4892
5073
|
}
|
|
4893
|
-
__name(
|
|
4894
|
-
function
|
|
5074
|
+
__name(_ts_decorate27, "_ts_decorate");
|
|
5075
|
+
function _ts_metadata26(k, v) {
|
|
4895
5076
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4896
5077
|
}
|
|
4897
|
-
__name(
|
|
4898
|
-
function
|
|
5078
|
+
__name(_ts_metadata26, "_ts_metadata");
|
|
5079
|
+
function _ts_param26(paramIndex, decorator) {
|
|
4899
5080
|
return function(target, key) {
|
|
4900
5081
|
decorator(target, key, paramIndex);
|
|
4901
5082
|
};
|
|
4902
5083
|
}
|
|
4903
|
-
__name(
|
|
5084
|
+
__name(_ts_param26, "_ts_param");
|
|
4904
5085
|
var PrismaTransactionRunner = class {
|
|
4905
5086
|
static {
|
|
4906
5087
|
__name(this, "PrismaTransactionRunner");
|
|
@@ -4914,24 +5095,24 @@ var PrismaTransactionRunner = class {
|
|
|
4914
5095
|
return transaction((tx) => fn(tx));
|
|
4915
5096
|
}
|
|
4916
5097
|
};
|
|
4917
|
-
PrismaTransactionRunner =
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
5098
|
+
PrismaTransactionRunner = _ts_decorate27([
|
|
5099
|
+
Injectable27(),
|
|
5100
|
+
_ts_param26(0, Inject26(PRISMA_CLIENT_TOKEN)),
|
|
5101
|
+
_ts_metadata26("design:type", Function),
|
|
5102
|
+
_ts_metadata26("design:paramtypes", [
|
|
4922
5103
|
typeof Record === "undefined" ? Object : Record
|
|
4923
5104
|
])
|
|
4924
5105
|
], PrismaTransactionRunner);
|
|
4925
5106
|
|
|
4926
5107
|
// src/zero-promo-revenue-aggregator.adapter.ts
|
|
4927
|
-
import { Injectable as
|
|
4928
|
-
function
|
|
5108
|
+
import { Injectable as Injectable28 } from "@nestjs/common";
|
|
5109
|
+
function _ts_decorate28(decorators, target, key, desc) {
|
|
4929
5110
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4930
5111
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4931
5112
|
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;
|
|
4932
5113
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4933
5114
|
}
|
|
4934
|
-
__name(
|
|
5115
|
+
__name(_ts_decorate28, "_ts_decorate");
|
|
4935
5116
|
var ZeroPromoRevenueDeductionAggregator = class {
|
|
4936
5117
|
static {
|
|
4937
5118
|
__name(this, "ZeroPromoRevenueDeductionAggregator");
|
|
@@ -4940,8 +5121,8 @@ var ZeroPromoRevenueDeductionAggregator = class {
|
|
|
4940
5121
|
return "0.00";
|
|
4941
5122
|
}
|
|
4942
5123
|
};
|
|
4943
|
-
ZeroPromoRevenueDeductionAggregator =
|
|
4944
|
-
|
|
5124
|
+
ZeroPromoRevenueDeductionAggregator = _ts_decorate28([
|
|
5125
|
+
Injectable28()
|
|
4945
5126
|
], ZeroPromoRevenueDeductionAggregator);
|
|
4946
5127
|
|
|
4947
5128
|
// src/prisma-persistence.ts
|
|
@@ -4974,6 +5155,7 @@ function prismaPersistence(options) {
|
|
|
4974
5155
|
subscriptionRepository: provide((prisma) => new PrismaSubscriptionRepository(prisma, options.schema)),
|
|
4975
5156
|
planVersionRepository: provide((prisma) => new PrismaPlanVersionRepository(prisma, options.schema)),
|
|
4976
5157
|
subscriptionContractRepository: provide((prisma) => new PrismaSubscriptionContractRepository(prisma)),
|
|
5158
|
+
subscriberRepository: provide((prisma) => new PrismaSubscriberRepository(canonical(prisma))),
|
|
4977
5159
|
subscriptionBundleRepository: provide((prisma) => new PrismaSubscriptionBundleRepository(canonical(prisma))),
|
|
4978
5160
|
bundleRepository: provide((prisma) => new PrismaBundleRepository(canonical(prisma), options.bundle))
|
|
4979
5161
|
},
|
|
@@ -5070,6 +5252,7 @@ export {
|
|
|
5070
5252
|
PrismaPromoCodeValidationLogRepository,
|
|
5071
5253
|
PrismaPromoSubscriptionLookup,
|
|
5072
5254
|
PrismaPromotionRepository,
|
|
5255
|
+
PrismaSubscriberRepository,
|
|
5073
5256
|
PrismaSubscriptionBundleRepository,
|
|
5074
5257
|
PrismaSubscriptionContractRepository,
|
|
5075
5258
|
PrismaSubscriptionRepository,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saasicat/adapter-prisma",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.16",
|
|
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.
|
|
26
|
+
"@saasicat/core": "^1.0.0-rc.16"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@nestjs/common": "^11.0.0"
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"@prisma/client": "^6.19.0",
|
|
36
36
|
"tsup": "^8.0.0",
|
|
37
37
|
"typescript": "^6.0.0",
|
|
38
|
-
"@saasicat/persistence-testing": "^1.0.0-rc.
|
|
39
|
-
"@saasicat/spec": "^1.0.0-rc.
|
|
38
|
+
"@saasicat/persistence-testing": "^1.0.0-rc.16",
|
|
39
|
+
"@saasicat/spec": "^1.0.0-rc.16"
|
|
40
40
|
},
|
|
41
41
|
"license": "PolyForm-Shield-1.0.0",
|
|
42
42
|
"author": "Taci Uelker",
|