@saasicat/adapter-prisma 1.0.0-rc.14 → 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 +276 -73
- package/dist/index.d.cts +31 -3
- package/dist/index.d.ts +31 -3
- package/dist/index.js +271 -69
- 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,
|
|
@@ -3995,10 +3996,31 @@ var PrismaSubscriptionContractRepository = class {
|
|
|
3995
3996
|
});
|
|
3996
3997
|
return row ? (0, import_core7.toSubscriptionContractRecord)(row, row.lineItems) : null;
|
|
3997
3998
|
}
|
|
3998
|
-
async
|
|
3999
|
-
const row = await this.db().subscriptionContract.
|
|
3999
|
+
async findByOriginalOfferId(offerId, tx) {
|
|
4000
|
+
const row = await this.db(tx).subscriptionContract.findFirst({
|
|
4001
|
+
where: {
|
|
4002
|
+
originalOfferId: offerId
|
|
4003
|
+
},
|
|
4004
|
+
include: {
|
|
4005
|
+
lineItems: true
|
|
4006
|
+
},
|
|
4007
|
+
orderBy: [
|
|
4008
|
+
{
|
|
4009
|
+
createdAt: "asc"
|
|
4010
|
+
},
|
|
4011
|
+
{
|
|
4012
|
+
id: "asc"
|
|
4013
|
+
}
|
|
4014
|
+
]
|
|
4015
|
+
});
|
|
4016
|
+
return row ? (0, import_core7.toSubscriptionContractRecord)(row, row.lineItems) : null;
|
|
4017
|
+
}
|
|
4018
|
+
async create(data, tx) {
|
|
4019
|
+
const row = await this.db(tx).subscriptionContract.create({
|
|
4000
4020
|
data: {
|
|
4001
4021
|
tenantId: data.tenantId,
|
|
4022
|
+
subscriberId: data.parties.subscriberId,
|
|
4023
|
+
subscriberSnapshot: data.parties.subscriber,
|
|
4002
4024
|
status: data.status ?? "active",
|
|
4003
4025
|
effectiveFrom: data.effectiveFrom,
|
|
4004
4026
|
effectiveUntil: data.effectiveUntil ?? null,
|
|
@@ -4016,6 +4038,9 @@ var PrismaSubscriptionContractRepository = class {
|
|
|
4016
4038
|
...data.termsSnapshot != null ? {
|
|
4017
4039
|
termsSnapshot: data.termsSnapshot
|
|
4018
4040
|
} : {},
|
|
4041
|
+
...data.parties.issuer != null ? {
|
|
4042
|
+
issuerSnapshot: data.parties.issuer
|
|
4043
|
+
} : {},
|
|
4019
4044
|
lineItems: {
|
|
4020
4045
|
create: data.lineItems.map(toLineItemCreate)
|
|
4021
4046
|
}
|
|
@@ -4080,8 +4105,9 @@ function toLineItemCreate(item) {
|
|
|
4080
4105
|
}
|
|
4081
4106
|
__name(toLineItemCreate, "toLineItemCreate");
|
|
4082
4107
|
|
|
4083
|
-
// src/prisma-
|
|
4108
|
+
// src/prisma-subscriber.repository.ts
|
|
4084
4109
|
var import_common22 = require("@nestjs/common");
|
|
4110
|
+
var import_core8 = require("@saasicat/core");
|
|
4085
4111
|
function _ts_decorate22(decorators, target, key, desc) {
|
|
4086
4112
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4087
4113
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4099,6 +4125,181 @@ function _ts_param21(paramIndex, decorator) {
|
|
|
4099
4125
|
};
|
|
4100
4126
|
}
|
|
4101
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");
|
|
4102
4303
|
var ACTIVE_STATUSES = [
|
|
4103
4304
|
"ACTIVE",
|
|
4104
4305
|
"TRIAL"
|
|
@@ -4333,37 +4534,37 @@ var PrismaSubscriptionRepository = class {
|
|
|
4333
4534
|
]));
|
|
4334
4535
|
}
|
|
4335
4536
|
};
|
|
4336
|
-
PrismaSubscriptionRepository =
|
|
4337
|
-
(0,
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
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", [
|
|
4343
4544
|
typeof SubscriptionRepositoryClient === "undefined" ? Object : SubscriptionRepositoryClient,
|
|
4344
4545
|
typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
|
|
4345
4546
|
])
|
|
4346
4547
|
], PrismaSubscriptionRepository);
|
|
4347
4548
|
|
|
4348
4549
|
// src/prisma-subscription-usage.adapter.ts
|
|
4349
|
-
var
|
|
4350
|
-
function
|
|
4550
|
+
var import_common24 = require("@nestjs/common");
|
|
4551
|
+
function _ts_decorate24(decorators, target, key, desc) {
|
|
4351
4552
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4352
4553
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4353
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;
|
|
4354
4555
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4355
4556
|
}
|
|
4356
|
-
__name(
|
|
4357
|
-
function
|
|
4557
|
+
__name(_ts_decorate24, "_ts_decorate");
|
|
4558
|
+
function _ts_metadata23(k, v) {
|
|
4358
4559
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4359
4560
|
}
|
|
4360
|
-
__name(
|
|
4361
|
-
function
|
|
4561
|
+
__name(_ts_metadata23, "_ts_metadata");
|
|
4562
|
+
function _ts_param23(paramIndex, decorator) {
|
|
4362
4563
|
return function(target, key) {
|
|
4363
4564
|
decorator(target, key, paramIndex);
|
|
4364
4565
|
};
|
|
4365
4566
|
}
|
|
4366
|
-
__name(
|
|
4567
|
+
__name(_ts_param23, "_ts_param");
|
|
4367
4568
|
var PrismaSubscriptionUsageAdapter = class {
|
|
4368
4569
|
static {
|
|
4369
4570
|
__name(this, "PrismaSubscriptionUsageAdapter");
|
|
@@ -4454,38 +4655,38 @@ var PrismaSubscriptionUsageAdapter = class {
|
|
|
4454
4655
|
return getPrismaDelegate(this.prisma, this.planVersionDelegateName);
|
|
4455
4656
|
}
|
|
4456
4657
|
};
|
|
4457
|
-
PrismaSubscriptionUsageAdapter =
|
|
4458
|
-
(0,
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
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", [
|
|
4464
4665
|
typeof SubscriptionUsageClient === "undefined" ? Object : SubscriptionUsageClient,
|
|
4465
4666
|
typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
|
|
4466
4667
|
])
|
|
4467
4668
|
], PrismaSubscriptionUsageAdapter);
|
|
4468
4669
|
|
|
4469
4670
|
// src/prisma-super-admin-bootstrap.adapter.ts
|
|
4470
|
-
var
|
|
4471
|
-
var
|
|
4472
|
-
function
|
|
4671
|
+
var import_common25 = require("@nestjs/common");
|
|
4672
|
+
var import_core9 = require("@saasicat/core");
|
|
4673
|
+
function _ts_decorate25(decorators, target, key, desc) {
|
|
4473
4674
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4474
4675
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4475
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;
|
|
4476
4677
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4477
4678
|
}
|
|
4478
|
-
__name(
|
|
4479
|
-
function
|
|
4679
|
+
__name(_ts_decorate25, "_ts_decorate");
|
|
4680
|
+
function _ts_metadata24(k, v) {
|
|
4480
4681
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4481
4682
|
}
|
|
4482
|
-
__name(
|
|
4483
|
-
function
|
|
4683
|
+
__name(_ts_metadata24, "_ts_metadata");
|
|
4684
|
+
function _ts_param24(paramIndex, decorator) {
|
|
4484
4685
|
return function(target, key) {
|
|
4485
4686
|
decorator(target, key, paramIndex);
|
|
4486
4687
|
};
|
|
4487
4688
|
}
|
|
4488
|
-
__name(
|
|
4689
|
+
__name(_ts_param24, "_ts_param");
|
|
4489
4690
|
var PASSWORD_HASHER_TOKEN = /* @__PURE__ */ Symbol.for("saasicat/adapter-prisma/PasswordHasher");
|
|
4490
4691
|
var PrismaSuperAdminBootstrapAdapter = class {
|
|
4491
4692
|
static {
|
|
@@ -4513,7 +4714,7 @@ var PrismaSuperAdminBootstrapAdapter = class {
|
|
|
4513
4714
|
}
|
|
4514
4715
|
});
|
|
4515
4716
|
if (existing) {
|
|
4516
|
-
throw new
|
|
4717
|
+
throw new import_core9.PlatformUserExistsError(email, existing.platformRole);
|
|
4517
4718
|
}
|
|
4518
4719
|
const row = await this.prisma.superAdminUser.create({
|
|
4519
4720
|
data: {
|
|
@@ -4535,37 +4736,37 @@ var PrismaSuperAdminBootstrapAdapter = class {
|
|
|
4535
4736
|
};
|
|
4536
4737
|
}
|
|
4537
4738
|
};
|
|
4538
|
-
PrismaSuperAdminBootstrapAdapter =
|
|
4539
|
-
(0,
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
|
|
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", [
|
|
4544
4745
|
typeof PrismaLike === "undefined" ? Object : PrismaLike,
|
|
4545
4746
|
typeof PasswordHasher === "undefined" ? Object : PasswordHasher
|
|
4546
4747
|
])
|
|
4547
4748
|
], PrismaSuperAdminBootstrapAdapter);
|
|
4548
4749
|
|
|
4549
4750
|
// src/prisma-tenant-subscription-write.adapter.ts
|
|
4550
|
-
var
|
|
4551
|
-
var
|
|
4552
|
-
function
|
|
4751
|
+
var import_common26 = require("@nestjs/common");
|
|
4752
|
+
var import_core10 = require("@saasicat/core");
|
|
4753
|
+
function _ts_decorate26(decorators, target, key, desc) {
|
|
4553
4754
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4554
4755
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4555
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;
|
|
4556
4757
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4557
4758
|
}
|
|
4558
|
-
__name(
|
|
4559
|
-
function
|
|
4759
|
+
__name(_ts_decorate26, "_ts_decorate");
|
|
4760
|
+
function _ts_metadata25(k, v) {
|
|
4560
4761
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4561
4762
|
}
|
|
4562
|
-
__name(
|
|
4563
|
-
function
|
|
4763
|
+
__name(_ts_metadata25, "_ts_metadata");
|
|
4764
|
+
function _ts_param25(paramIndex, decorator) {
|
|
4564
4765
|
return function(target, key) {
|
|
4565
4766
|
decorator(target, key, paramIndex);
|
|
4566
4767
|
};
|
|
4567
4768
|
}
|
|
4568
|
-
__name(
|
|
4769
|
+
__name(_ts_param25, "_ts_param");
|
|
4569
4770
|
var PrismaTenantSubscriptionWriteAdapter = class {
|
|
4570
4771
|
static {
|
|
4571
4772
|
__name(this, "PrismaTenantSubscriptionWriteAdapter");
|
|
@@ -4835,9 +5036,9 @@ var PrismaTenantSubscriptionWriteAdapter = class {
|
|
|
4835
5036
|
}
|
|
4836
5037
|
async findTargetPlanVersionId(client, storagePlanId, asOf) {
|
|
4837
5038
|
const activeWindow = this.schema.tenantSubscription.activeVersionSelection === "validity-window";
|
|
4838
|
-
const activeVersionWhere = this.schema.tenantSubscription.withEndsAt ? (0,
|
|
5039
|
+
const activeVersionWhere = this.schema.tenantSubscription.withEndsAt ? (0, import_core10.buildActivePlanVersionWhere)(asOf, {
|
|
4839
5040
|
withEndsAt: true
|
|
4840
|
-
}) : (0,
|
|
5041
|
+
}) : (0, import_core10.buildActivePlanVersionWhere)(asOf);
|
|
4841
5042
|
const where = activeWindow ? {
|
|
4842
5043
|
planId: storagePlanId,
|
|
4843
5044
|
...activeVersionWhere
|
|
@@ -4901,13 +5102,13 @@ var PrismaTenantSubscriptionWriteAdapter = class {
|
|
|
4901
5102
|
}
|
|
4902
5103
|
}
|
|
4903
5104
|
};
|
|
4904
|
-
PrismaTenantSubscriptionWriteAdapter =
|
|
4905
|
-
(0,
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
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", [
|
|
4911
5112
|
typeof TransactionalPrismaClient === "undefined" ? Object : TransactionalPrismaClient,
|
|
4912
5113
|
typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
|
|
4913
5114
|
])
|
|
@@ -4926,24 +5127,24 @@ function clearedPendingVersionData() {
|
|
|
4926
5127
|
__name(clearedPendingVersionData, "clearedPendingVersionData");
|
|
4927
5128
|
|
|
4928
5129
|
// src/prisma-transaction-runner.adapter.ts
|
|
4929
|
-
var
|
|
4930
|
-
function
|
|
5130
|
+
var import_common27 = require("@nestjs/common");
|
|
5131
|
+
function _ts_decorate27(decorators, target, key, desc) {
|
|
4931
5132
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4932
5133
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4933
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;
|
|
4934
5135
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4935
5136
|
}
|
|
4936
|
-
__name(
|
|
4937
|
-
function
|
|
5137
|
+
__name(_ts_decorate27, "_ts_decorate");
|
|
5138
|
+
function _ts_metadata26(k, v) {
|
|
4938
5139
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4939
5140
|
}
|
|
4940
|
-
__name(
|
|
4941
|
-
function
|
|
5141
|
+
__name(_ts_metadata26, "_ts_metadata");
|
|
5142
|
+
function _ts_param26(paramIndex, decorator) {
|
|
4942
5143
|
return function(target, key) {
|
|
4943
5144
|
decorator(target, key, paramIndex);
|
|
4944
5145
|
};
|
|
4945
5146
|
}
|
|
4946
|
-
__name(
|
|
5147
|
+
__name(_ts_param26, "_ts_param");
|
|
4947
5148
|
var PrismaTransactionRunner = class {
|
|
4948
5149
|
static {
|
|
4949
5150
|
__name(this, "PrismaTransactionRunner");
|
|
@@ -4957,24 +5158,24 @@ var PrismaTransactionRunner = class {
|
|
|
4957
5158
|
return transaction((tx) => fn(tx));
|
|
4958
5159
|
}
|
|
4959
5160
|
};
|
|
4960
|
-
PrismaTransactionRunner =
|
|
4961
|
-
(0,
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
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", [
|
|
4965
5166
|
typeof Record === "undefined" ? Object : Record
|
|
4966
5167
|
])
|
|
4967
5168
|
], PrismaTransactionRunner);
|
|
4968
5169
|
|
|
4969
5170
|
// src/zero-promo-revenue-aggregator.adapter.ts
|
|
4970
|
-
var
|
|
4971
|
-
function
|
|
5171
|
+
var import_common28 = require("@nestjs/common");
|
|
5172
|
+
function _ts_decorate28(decorators, target, key, desc) {
|
|
4972
5173
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4973
5174
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4974
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;
|
|
4975
5176
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4976
5177
|
}
|
|
4977
|
-
__name(
|
|
5178
|
+
__name(_ts_decorate28, "_ts_decorate");
|
|
4978
5179
|
var ZeroPromoRevenueDeductionAggregator = class {
|
|
4979
5180
|
static {
|
|
4980
5181
|
__name(this, "ZeroPromoRevenueDeductionAggregator");
|
|
@@ -4983,8 +5184,8 @@ var ZeroPromoRevenueDeductionAggregator = class {
|
|
|
4983
5184
|
return "0.00";
|
|
4984
5185
|
}
|
|
4985
5186
|
};
|
|
4986
|
-
ZeroPromoRevenueDeductionAggregator =
|
|
4987
|
-
(0,
|
|
5187
|
+
ZeroPromoRevenueDeductionAggregator = _ts_decorate28([
|
|
5188
|
+
(0, import_common28.Injectable)()
|
|
4988
5189
|
], ZeroPromoRevenueDeductionAggregator);
|
|
4989
5190
|
|
|
4990
5191
|
// src/prisma-persistence.ts
|
|
@@ -5017,6 +5218,7 @@ function prismaPersistence(options) {
|
|
|
5017
5218
|
subscriptionRepository: provide((prisma) => new PrismaSubscriptionRepository(prisma, options.schema)),
|
|
5018
5219
|
planVersionRepository: provide((prisma) => new PrismaPlanVersionRepository(prisma, options.schema)),
|
|
5019
5220
|
subscriptionContractRepository: provide((prisma) => new PrismaSubscriptionContractRepository(prisma)),
|
|
5221
|
+
subscriberRepository: provide((prisma) => new PrismaSubscriberRepository(canonical(prisma))),
|
|
5020
5222
|
subscriptionBundleRepository: provide((prisma) => new PrismaSubscriptionBundleRepository(canonical(prisma))),
|
|
5021
5223
|
bundleRepository: provide((prisma) => new PrismaBundleRepository(canonical(prisma), options.bundle))
|
|
5022
5224
|
},
|
|
@@ -5114,6 +5316,7 @@ __name(buildProvisioning, "buildProvisioning");
|
|
|
5114
5316
|
PrismaPromoCodeValidationLogRepository,
|
|
5115
5317
|
PrismaPromoSubscriptionLookup,
|
|
5116
5318
|
PrismaPromotionRepository,
|
|
5319
|
+
PrismaSubscriberRepository,
|
|
5117
5320
|
PrismaSubscriptionBundleRepository,
|
|
5118
5321
|
PrismaSubscriptionContractRepository,
|
|
5119
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. */
|
|
@@ -1602,10 +1602,38 @@ declare class PrismaSubscriptionContractRepository implements SubscriptionContra
|
|
|
1602
1602
|
list(filter: SubscriptionContractFilter): Promise<SubscriptionContractRecord[]>;
|
|
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: NewSubscriptionContractData, tx?: TransactionContext): Promise<SubscriptionContractRecord>;
|
|
1606
1607
|
terminate(contractId: string, data: TerminateSubscriptionContractData): Promise<SubscriptionContractRecord>;
|
|
1607
1608
|
}
|
|
1608
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
|
+
|
|
1609
1637
|
/** Root-client fields used directly: the two delegates and the interactive transaction. */
|
|
1610
1638
|
interface AppliedSettingsRepositoryClient {
|
|
1611
1639
|
appliedSettings: unknown;
|
|
@@ -1627,4 +1655,4 @@ declare class PrismaAppliedSettingsRepository implements AppliedSettingsPort {
|
|
|
1627
1655
|
acknowledgeChange(id: string, acknowledgedBy: string, acknowledgedAt: Date): Promise<SettingsChangeRecord | null>;
|
|
1628
1656
|
}
|
|
1629
1657
|
|
|
1630
|
-
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. */
|
|
@@ -1602,10 +1602,38 @@ declare class PrismaSubscriptionContractRepository implements SubscriptionContra
|
|
|
1602
1602
|
list(filter: SubscriptionContractFilter): Promise<SubscriptionContractRecord[]>;
|
|
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: NewSubscriptionContractData, tx?: TransactionContext): Promise<SubscriptionContractRecord>;
|
|
1606
1607
|
terminate(contractId: string, data: TerminateSubscriptionContractData): Promise<SubscriptionContractRecord>;
|
|
1607
1608
|
}
|
|
1608
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
|
+
|
|
1609
1637
|
/** Root-client fields used directly: the two delegates and the interactive transaction. */
|
|
1610
1638
|
interface AppliedSettingsRepositoryClient {
|
|
1611
1639
|
appliedSettings: unknown;
|
|
@@ -1627,4 +1655,4 @@ declare class PrismaAppliedSettingsRepository implements AppliedSettingsPort {
|
|
|
1627
1655
|
acknowledgeChange(id: string, acknowledgedBy: string, acknowledgedAt: Date): Promise<SettingsChangeRecord | null>;
|
|
1628
1656
|
}
|
|
1629
1657
|
|
|
1630
|
-
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
|
@@ -3933,10 +3933,31 @@ var PrismaSubscriptionContractRepository = class {
|
|
|
3933
3933
|
});
|
|
3934
3934
|
return row ? toSubscriptionContractRecord(row, row.lineItems) : null;
|
|
3935
3935
|
}
|
|
3936
|
-
async
|
|
3937
|
-
const row = await this.db().subscriptionContract.
|
|
3936
|
+
async findByOriginalOfferId(offerId, tx) {
|
|
3937
|
+
const row = await this.db(tx).subscriptionContract.findFirst({
|
|
3938
|
+
where: {
|
|
3939
|
+
originalOfferId: offerId
|
|
3940
|
+
},
|
|
3941
|
+
include: {
|
|
3942
|
+
lineItems: true
|
|
3943
|
+
},
|
|
3944
|
+
orderBy: [
|
|
3945
|
+
{
|
|
3946
|
+
createdAt: "asc"
|
|
3947
|
+
},
|
|
3948
|
+
{
|
|
3949
|
+
id: "asc"
|
|
3950
|
+
}
|
|
3951
|
+
]
|
|
3952
|
+
});
|
|
3953
|
+
return row ? toSubscriptionContractRecord(row, row.lineItems) : null;
|
|
3954
|
+
}
|
|
3955
|
+
async create(data, tx) {
|
|
3956
|
+
const row = await this.db(tx).subscriptionContract.create({
|
|
3938
3957
|
data: {
|
|
3939
3958
|
tenantId: data.tenantId,
|
|
3959
|
+
subscriberId: data.parties.subscriberId,
|
|
3960
|
+
subscriberSnapshot: data.parties.subscriber,
|
|
3940
3961
|
status: data.status ?? "active",
|
|
3941
3962
|
effectiveFrom: data.effectiveFrom,
|
|
3942
3963
|
effectiveUntil: data.effectiveUntil ?? null,
|
|
@@ -3954,6 +3975,9 @@ var PrismaSubscriptionContractRepository = class {
|
|
|
3954
3975
|
...data.termsSnapshot != null ? {
|
|
3955
3976
|
termsSnapshot: data.termsSnapshot
|
|
3956
3977
|
} : {},
|
|
3978
|
+
...data.parties.issuer != null ? {
|
|
3979
|
+
issuerSnapshot: data.parties.issuer
|
|
3980
|
+
} : {},
|
|
3957
3981
|
lineItems: {
|
|
3958
3982
|
create: data.lineItems.map(toLineItemCreate)
|
|
3959
3983
|
}
|
|
@@ -4018,8 +4042,9 @@ function toLineItemCreate(item) {
|
|
|
4018
4042
|
}
|
|
4019
4043
|
__name(toLineItemCreate, "toLineItemCreate");
|
|
4020
4044
|
|
|
4021
|
-
// src/prisma-
|
|
4022
|
-
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";
|
|
4023
4048
|
function _ts_decorate22(decorators, target, key, desc) {
|
|
4024
4049
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4025
4050
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -4037,6 +4062,181 @@ function _ts_param21(paramIndex, decorator) {
|
|
|
4037
4062
|
};
|
|
4038
4063
|
}
|
|
4039
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");
|
|
4040
4240
|
var ACTIVE_STATUSES = [
|
|
4041
4241
|
"ACTIVE",
|
|
4042
4242
|
"TRIAL"
|
|
@@ -4271,37 +4471,37 @@ var PrismaSubscriptionRepository = class {
|
|
|
4271
4471
|
]));
|
|
4272
4472
|
}
|
|
4273
4473
|
};
|
|
4274
|
-
PrismaSubscriptionRepository =
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
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", [
|
|
4281
4481
|
typeof SubscriptionRepositoryClient === "undefined" ? Object : SubscriptionRepositoryClient,
|
|
4282
4482
|
typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
|
|
4283
4483
|
])
|
|
4284
4484
|
], PrismaSubscriptionRepository);
|
|
4285
4485
|
|
|
4286
4486
|
// src/prisma-subscription-usage.adapter.ts
|
|
4287
|
-
import { Inject as
|
|
4288
|
-
function
|
|
4487
|
+
import { Inject as Inject23, Injectable as Injectable24, Optional as Optional7 } from "@nestjs/common";
|
|
4488
|
+
function _ts_decorate24(decorators, target, key, desc) {
|
|
4289
4489
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4290
4490
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4291
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;
|
|
4292
4492
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4293
4493
|
}
|
|
4294
|
-
__name(
|
|
4295
|
-
function
|
|
4494
|
+
__name(_ts_decorate24, "_ts_decorate");
|
|
4495
|
+
function _ts_metadata23(k, v) {
|
|
4296
4496
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4297
4497
|
}
|
|
4298
|
-
__name(
|
|
4299
|
-
function
|
|
4498
|
+
__name(_ts_metadata23, "_ts_metadata");
|
|
4499
|
+
function _ts_param23(paramIndex, decorator) {
|
|
4300
4500
|
return function(target, key) {
|
|
4301
4501
|
decorator(target, key, paramIndex);
|
|
4302
4502
|
};
|
|
4303
4503
|
}
|
|
4304
|
-
__name(
|
|
4504
|
+
__name(_ts_param23, "_ts_param");
|
|
4305
4505
|
var PrismaSubscriptionUsageAdapter = class {
|
|
4306
4506
|
static {
|
|
4307
4507
|
__name(this, "PrismaSubscriptionUsageAdapter");
|
|
@@ -4392,38 +4592,38 @@ var PrismaSubscriptionUsageAdapter = class {
|
|
|
4392
4592
|
return getPrismaDelegate(this.prisma, this.planVersionDelegateName);
|
|
4393
4593
|
}
|
|
4394
4594
|
};
|
|
4395
|
-
PrismaSubscriptionUsageAdapter =
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
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", [
|
|
4402
4602
|
typeof SubscriptionUsageClient === "undefined" ? Object : SubscriptionUsageClient,
|
|
4403
4603
|
typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
|
|
4404
4604
|
])
|
|
4405
4605
|
], PrismaSubscriptionUsageAdapter);
|
|
4406
4606
|
|
|
4407
4607
|
// src/prisma-super-admin-bootstrap.adapter.ts
|
|
4408
|
-
import { Inject as
|
|
4608
|
+
import { Inject as Inject24, Injectable as Injectable25 } from "@nestjs/common";
|
|
4409
4609
|
import { PlatformUserExistsError } from "@saasicat/core";
|
|
4410
|
-
function
|
|
4610
|
+
function _ts_decorate25(decorators, target, key, desc) {
|
|
4411
4611
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4412
4612
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4413
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;
|
|
4414
4614
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4415
4615
|
}
|
|
4416
|
-
__name(
|
|
4417
|
-
function
|
|
4616
|
+
__name(_ts_decorate25, "_ts_decorate");
|
|
4617
|
+
function _ts_metadata24(k, v) {
|
|
4418
4618
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4419
4619
|
}
|
|
4420
|
-
__name(
|
|
4421
|
-
function
|
|
4620
|
+
__name(_ts_metadata24, "_ts_metadata");
|
|
4621
|
+
function _ts_param24(paramIndex, decorator) {
|
|
4422
4622
|
return function(target, key) {
|
|
4423
4623
|
decorator(target, key, paramIndex);
|
|
4424
4624
|
};
|
|
4425
4625
|
}
|
|
4426
|
-
__name(
|
|
4626
|
+
__name(_ts_param24, "_ts_param");
|
|
4427
4627
|
var PASSWORD_HASHER_TOKEN = /* @__PURE__ */ Symbol.for("saasicat/adapter-prisma/PasswordHasher");
|
|
4428
4628
|
var PrismaSuperAdminBootstrapAdapter = class {
|
|
4429
4629
|
static {
|
|
@@ -4473,37 +4673,37 @@ var PrismaSuperAdminBootstrapAdapter = class {
|
|
|
4473
4673
|
};
|
|
4474
4674
|
}
|
|
4475
4675
|
};
|
|
4476
|
-
PrismaSuperAdminBootstrapAdapter =
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
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", [
|
|
4482
4682
|
typeof PrismaLike === "undefined" ? Object : PrismaLike,
|
|
4483
4683
|
typeof PasswordHasher === "undefined" ? Object : PasswordHasher
|
|
4484
4684
|
])
|
|
4485
4685
|
], PrismaSuperAdminBootstrapAdapter);
|
|
4486
4686
|
|
|
4487
4687
|
// src/prisma-tenant-subscription-write.adapter.ts
|
|
4488
|
-
import { Inject as
|
|
4688
|
+
import { Inject as Inject25, Injectable as Injectable26, Optional as Optional8 } from "@nestjs/common";
|
|
4489
4689
|
import { buildActivePlanVersionWhere as buildActivePlanVersionWhere3 } from "@saasicat/core";
|
|
4490
|
-
function
|
|
4690
|
+
function _ts_decorate26(decorators, target, key, desc) {
|
|
4491
4691
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4492
4692
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4493
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;
|
|
4494
4694
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4495
4695
|
}
|
|
4496
|
-
__name(
|
|
4497
|
-
function
|
|
4696
|
+
__name(_ts_decorate26, "_ts_decorate");
|
|
4697
|
+
function _ts_metadata25(k, v) {
|
|
4498
4698
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4499
4699
|
}
|
|
4500
|
-
__name(
|
|
4501
|
-
function
|
|
4700
|
+
__name(_ts_metadata25, "_ts_metadata");
|
|
4701
|
+
function _ts_param25(paramIndex, decorator) {
|
|
4502
4702
|
return function(target, key) {
|
|
4503
4703
|
decorator(target, key, paramIndex);
|
|
4504
4704
|
};
|
|
4505
4705
|
}
|
|
4506
|
-
__name(
|
|
4706
|
+
__name(_ts_param25, "_ts_param");
|
|
4507
4707
|
var PrismaTenantSubscriptionWriteAdapter = class {
|
|
4508
4708
|
static {
|
|
4509
4709
|
__name(this, "PrismaTenantSubscriptionWriteAdapter");
|
|
@@ -4839,13 +5039,13 @@ var PrismaTenantSubscriptionWriteAdapter = class {
|
|
|
4839
5039
|
}
|
|
4840
5040
|
}
|
|
4841
5041
|
};
|
|
4842
|
-
PrismaTenantSubscriptionWriteAdapter =
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
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", [
|
|
4849
5049
|
typeof TransactionalPrismaClient === "undefined" ? Object : TransactionalPrismaClient,
|
|
4850
5050
|
typeof PrismaSchemaOptions === "undefined" ? Object : PrismaSchemaOptions
|
|
4851
5051
|
])
|
|
@@ -4864,24 +5064,24 @@ function clearedPendingVersionData() {
|
|
|
4864
5064
|
__name(clearedPendingVersionData, "clearedPendingVersionData");
|
|
4865
5065
|
|
|
4866
5066
|
// src/prisma-transaction-runner.adapter.ts
|
|
4867
|
-
import { Inject as
|
|
4868
|
-
function
|
|
5067
|
+
import { Inject as Inject26, Injectable as Injectable27 } from "@nestjs/common";
|
|
5068
|
+
function _ts_decorate27(decorators, target, key, desc) {
|
|
4869
5069
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4870
5070
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4871
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;
|
|
4872
5072
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4873
5073
|
}
|
|
4874
|
-
__name(
|
|
4875
|
-
function
|
|
5074
|
+
__name(_ts_decorate27, "_ts_decorate");
|
|
5075
|
+
function _ts_metadata26(k, v) {
|
|
4876
5076
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
4877
5077
|
}
|
|
4878
|
-
__name(
|
|
4879
|
-
function
|
|
5078
|
+
__name(_ts_metadata26, "_ts_metadata");
|
|
5079
|
+
function _ts_param26(paramIndex, decorator) {
|
|
4880
5080
|
return function(target, key) {
|
|
4881
5081
|
decorator(target, key, paramIndex);
|
|
4882
5082
|
};
|
|
4883
5083
|
}
|
|
4884
|
-
__name(
|
|
5084
|
+
__name(_ts_param26, "_ts_param");
|
|
4885
5085
|
var PrismaTransactionRunner = class {
|
|
4886
5086
|
static {
|
|
4887
5087
|
__name(this, "PrismaTransactionRunner");
|
|
@@ -4895,24 +5095,24 @@ var PrismaTransactionRunner = class {
|
|
|
4895
5095
|
return transaction((tx) => fn(tx));
|
|
4896
5096
|
}
|
|
4897
5097
|
};
|
|
4898
|
-
PrismaTransactionRunner =
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
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", [
|
|
4903
5103
|
typeof Record === "undefined" ? Object : Record
|
|
4904
5104
|
])
|
|
4905
5105
|
], PrismaTransactionRunner);
|
|
4906
5106
|
|
|
4907
5107
|
// src/zero-promo-revenue-aggregator.adapter.ts
|
|
4908
|
-
import { Injectable as
|
|
4909
|
-
function
|
|
5108
|
+
import { Injectable as Injectable28 } from "@nestjs/common";
|
|
5109
|
+
function _ts_decorate28(decorators, target, key, desc) {
|
|
4910
5110
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4911
5111
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4912
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;
|
|
4913
5113
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4914
5114
|
}
|
|
4915
|
-
__name(
|
|
5115
|
+
__name(_ts_decorate28, "_ts_decorate");
|
|
4916
5116
|
var ZeroPromoRevenueDeductionAggregator = class {
|
|
4917
5117
|
static {
|
|
4918
5118
|
__name(this, "ZeroPromoRevenueDeductionAggregator");
|
|
@@ -4921,8 +5121,8 @@ var ZeroPromoRevenueDeductionAggregator = class {
|
|
|
4921
5121
|
return "0.00";
|
|
4922
5122
|
}
|
|
4923
5123
|
};
|
|
4924
|
-
ZeroPromoRevenueDeductionAggregator =
|
|
4925
|
-
|
|
5124
|
+
ZeroPromoRevenueDeductionAggregator = _ts_decorate28([
|
|
5125
|
+
Injectable28()
|
|
4926
5126
|
], ZeroPromoRevenueDeductionAggregator);
|
|
4927
5127
|
|
|
4928
5128
|
// src/prisma-persistence.ts
|
|
@@ -4955,6 +5155,7 @@ function prismaPersistence(options) {
|
|
|
4955
5155
|
subscriptionRepository: provide((prisma) => new PrismaSubscriptionRepository(prisma, options.schema)),
|
|
4956
5156
|
planVersionRepository: provide((prisma) => new PrismaPlanVersionRepository(prisma, options.schema)),
|
|
4957
5157
|
subscriptionContractRepository: provide((prisma) => new PrismaSubscriptionContractRepository(prisma)),
|
|
5158
|
+
subscriberRepository: provide((prisma) => new PrismaSubscriberRepository(canonical(prisma))),
|
|
4958
5159
|
subscriptionBundleRepository: provide((prisma) => new PrismaSubscriptionBundleRepository(canonical(prisma))),
|
|
4959
5160
|
bundleRepository: provide((prisma) => new PrismaBundleRepository(canonical(prisma), options.bundle))
|
|
4960
5161
|
},
|
|
@@ -5051,6 +5252,7 @@ export {
|
|
|
5051
5252
|
PrismaPromoCodeValidationLogRepository,
|
|
5052
5253
|
PrismaPromoSubscriptionLookup,
|
|
5053
5254
|
PrismaPromotionRepository,
|
|
5255
|
+
PrismaSubscriberRepository,
|
|
5054
5256
|
PrismaSubscriptionBundleRepository,
|
|
5055
5257
|
PrismaSubscriptionContractRepository,
|
|
5056
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",
|