@saasicat/nest 0.18.0 → 0.19.0
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/_entries.cjs +1309 -519
- package/dist/admin/index.js +1 -1
- package/dist/billing/index.d.cts +7 -4
- package/dist/billing/index.d.ts +7 -4
- package/dist/billing/index.js +6 -6
- package/dist/catalog/index.js +4 -4
- package/dist/checkout-offer/index.js +2 -2
- package/dist/{chunk-Z3FWN3HJ.js → chunk-5ZXBXYXU.js} +3 -3
- package/dist/{chunk-RZVSKKXX.js → chunk-6WA4X5U3.js} +46 -45
- package/dist/{chunk-V34AA7C7.js → chunk-6WL6VQ7Z.js} +1 -1
- package/dist/{chunk-ABB2CRAS.js → chunk-74SCJ4HF.js} +1 -1
- package/dist/{chunk-PLJEAUFU.js → chunk-7JIHG53V.js} +76 -39
- package/dist/{chunk-7RRWI5LH.js → chunk-AFK2IE2L.js} +10 -10
- package/dist/{chunk-32EMXPU2.js → chunk-B7NRY2LV.js} +48 -17
- package/dist/{chunk-MDIZUVIK.js → chunk-BSK6YBLI.js} +1 -1
- package/dist/{chunk-R2QOSVAA.js → chunk-DQKCK7DX.js} +1 -1
- package/dist/{chunk-GLLCB4BP.js → chunk-EUU3B6NB.js} +17 -13
- package/dist/{chunk-EXOLOJFZ.js → chunk-F6DCLVBB.js} +29 -8
- package/dist/{chunk-5KH2O4SF.js → chunk-I77VS3YH.js} +287 -105
- package/dist/{chunk-YITTE646.js → chunk-KUDKD7ZG.js} +34 -14
- package/dist/{chunk-P3DP6GJE.js → chunk-LXUBCLRK.js} +486 -160
- package/dist/{chunk-GJBXOCRZ.js → chunk-ORWIGSNN.js} +45 -17
- package/dist/{chunk-E7AJ42AB.js → chunk-QLJHIIOY.js} +168 -28
- package/dist/{chunk-BOADBIGB.js → chunk-YYUXKLXK.js} +2 -2
- package/dist/{define-saasicat-Rc0rXrYG.d.ts → define-saasicat-CqkhnHn-.d.ts} +1 -1
- package/dist/{define-saasicat-CeDBX9ji.d.cts → define-saasicat-D8c6Bs4T.d.cts} +1 -1
- package/dist/discovery/index.d.cts +2 -2
- package/dist/discovery/index.d.ts +2 -2
- package/dist/discovery/index.js +4 -4
- package/dist/{enforce-quota.interceptor-DMw-bPyk.d.cts → enforce-quota.interceptor-Dk0eEtzV.d.cts} +1 -1
- package/dist/{enforce-quota.interceptor-CmbWX39L.d.ts → enforce-quota.interceptor-Dp8wTYro.d.ts} +1 -1
- package/dist/entitlement/index.js +2 -2
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +17 -17
- package/dist/{module-DgYJur6f.d.ts → module-BwD-wAor.d.ts} +1 -1
- package/dist/{module-CSN8j8Tp.d.cts → module-DsDkbawm.d.cts} +1 -1
- package/dist/platform/index.d.cts +8 -8
- package/dist/platform/index.d.ts +8 -8
- package/dist/platform/index.js +13 -13
- package/dist/promo/index.d.cts +3 -3
- package/dist/promo/index.d.ts +3 -3
- package/dist/promo/index.js +3 -3
- package/dist/registration/index.js +1 -1
- package/dist/{saas-platform.module-DLhoqKNA.d.ts → saas-platform.module-BQmrDGVU.d.ts} +1 -1
- package/dist/{saas-platform.module-D3rUTiho.d.cts → saas-platform.module-DducnQ9s.d.cts} +1 -1
- package/dist/{service-DX8KbGXl.d.cts → service-DPZ2W1E-.d.cts} +2 -2
- package/dist/{service-DX8KbGXl.d.ts → service-DPZ2W1E-.d.ts} +2 -2
- package/dist/subscription-contract/index.js +2 -2
- package/dist/{tenant-billing.controller-BwZRnJ3q.d.ts → tenant-billing.controller-b1G1yB09.d.ts} +2 -2
- package/dist/{tenant-billing.controller-CG4CaFUP.d.cts → tenant-billing.controller-m42YQ_Ei.d.cts} +2 -2
- package/dist/testing/index.d.cts +5 -5
- package/dist/testing/index.d.ts +5 -5
- package/dist/testing/index.js +33 -33
- package/package.json +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PLAN_CATALOG_TOKEN,
|
|
3
3
|
isFeaturePlannedOnly
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-DQKCK7DX.js";
|
|
5
5
|
import {
|
|
6
6
|
SUBSCRIPTION_CONTRACT_REPOSITORY_TOKEN
|
|
7
7
|
} from "./chunk-NYLON2VC.js";
|
|
@@ -250,7 +250,7 @@ function assertNoReplacesCycle(index) {
|
|
|
250
250
|
...path.slice(cycleStart),
|
|
251
251
|
key
|
|
252
252
|
].join(" \u2192 ");
|
|
253
|
-
throw new Error(`replaces
|
|
253
|
+
throw new Error(`replaces cycle in the discovery metadata: ${cycle}. Feature replacements must be acyclic \u2014 fix the replaces declarations in code (#39).`);
|
|
254
254
|
}
|
|
255
255
|
state.set(key, IN_PROGRESS);
|
|
256
256
|
for (const successor of index.get(key) ?? []) {
|
|
@@ -294,7 +294,7 @@ var LimitExceededError = class extends Error {
|
|
|
294
294
|
used;
|
|
295
295
|
code = LIMIT_EXCEEDED;
|
|
296
296
|
constructor(dimension, max, used) {
|
|
297
|
-
super(`Limit
|
|
297
|
+
super(`Limit for ${dimension} reached: ${used}/${max}.`), this.dimension = dimension, this.max = max, this.used = used;
|
|
298
298
|
this.name = "LimitExceededError";
|
|
299
299
|
}
|
|
300
300
|
};
|
|
@@ -305,6 +305,7 @@ __name(isLimitExceededError, "isLimitExceededError");
|
|
|
305
305
|
|
|
306
306
|
// src/entitlement/service.ts
|
|
307
307
|
import { Inject, Injectable, NotFoundException, Optional } from "@nestjs/common";
|
|
308
|
+
import { BILLING_ERROR_CODES } from "@saasicat/types";
|
|
308
309
|
|
|
309
310
|
// src/billing/subscription-bundles.tokens.ts
|
|
310
311
|
var SUBSCRIPTION_BUNDLE_REPOSITORY_TOKEN = /* @__PURE__ */ Symbol.for("saas-platform/SubscriptionBundleRepository");
|
|
@@ -371,7 +372,13 @@ var EntitlementService = class {
|
|
|
371
372
|
if (cached) return cached;
|
|
372
373
|
const sub = await this.subscriptions.findByTenantId(tenantId);
|
|
373
374
|
if (!sub) {
|
|
374
|
-
throw new NotFoundException(
|
|
375
|
+
throw new NotFoundException({
|
|
376
|
+
code: BILLING_ERROR_CODES.SUBSCRIPTION_NOT_FOUND,
|
|
377
|
+
message: `No subscription for tenant ${tenantId}`,
|
|
378
|
+
params: {
|
|
379
|
+
tenantId
|
|
380
|
+
}
|
|
381
|
+
});
|
|
375
382
|
}
|
|
376
383
|
const limits = await this.deriveLimits(sub, now);
|
|
377
384
|
this.writeCache(tenantId, limits, now.getTime());
|
|
@@ -444,7 +451,7 @@ var EntitlementService = class {
|
|
|
444
451
|
return Promise.all(active.map(async (booking) => {
|
|
445
452
|
const bv = await this.bundles.findVersionById(booking.bundleVersionId, tx);
|
|
446
453
|
if (!bv) {
|
|
447
|
-
throw new Error(`BundleVersion '${booking.bundleVersionId}'
|
|
454
|
+
throw new Error(`BundleVersion '${booking.bundleVersionId}' from an active subscription bundle not found`);
|
|
448
455
|
}
|
|
449
456
|
return {
|
|
450
457
|
bundleKey: bv.bundleKey,
|
|
@@ -466,12 +473,18 @@ var EntitlementService = class {
|
|
|
466
473
|
return this.tx.run(async (tx) => {
|
|
467
474
|
const sub = await this.subscriptions.findByTenantIdLocked(input.tenantId, tx);
|
|
468
475
|
if (!sub) {
|
|
469
|
-
throw new NotFoundException(
|
|
476
|
+
throw new NotFoundException({
|
|
477
|
+
code: BILLING_ERROR_CODES.SUBSCRIPTION_NOT_FOUND,
|
|
478
|
+
message: `No subscription for tenant ${input.tenantId}`,
|
|
479
|
+
params: {
|
|
480
|
+
tenantId: input.tenantId
|
|
481
|
+
}
|
|
482
|
+
});
|
|
470
483
|
}
|
|
471
484
|
const limits = await this.deriveLimits(sub, now, tx);
|
|
472
485
|
const max = limits.quotas[input.dimension];
|
|
473
486
|
if (max === void 0) {
|
|
474
|
-
throw new Error(`Quota-Dimension "${input.dimension}"
|
|
487
|
+
throw new Error(`Quota-Dimension "${input.dimension}" is not in the plan catalog (${this.catalog.projectKey}).`);
|
|
475
488
|
}
|
|
476
489
|
const used = await input.currentUsage(tx, input.tenantId);
|
|
477
490
|
if (max !== -1 && used + delta > max) {
|
|
@@ -492,7 +505,15 @@ var EntitlementService = class {
|
|
|
492
505
|
async findActivePlanVersionOrFallback(planId, asOf, tx) {
|
|
493
506
|
const v = this.planVersions.findActive ? await this.planVersions.findActive(planId, asOf, tx) : await this.planVersions.findLatestLive(planId, tx);
|
|
494
507
|
if (!v) {
|
|
495
|
-
|
|
508
|
+
const asOfDate = asOf.toISOString().slice(0, 10);
|
|
509
|
+
throw new NotFoundException({
|
|
510
|
+
code: BILLING_ERROR_CODES.NO_ACTIVE_PLAN_VERSION,
|
|
511
|
+
message: `No plan version for ${planId} active as of ${asOfDate} \u2014 neither the validFrom window is satisfied nor is a latest-live version available.`,
|
|
512
|
+
params: {
|
|
513
|
+
planId,
|
|
514
|
+
asOf: asOfDate
|
|
515
|
+
}
|
|
516
|
+
});
|
|
496
517
|
}
|
|
497
518
|
return v;
|
|
498
519
|
}
|