@saasicat/nest 0.26.1 → 0.27.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.
Files changed (37) hide show
  1. package/LICENSE +90 -201
  2. package/dist/_entries.cjs +3265 -2846
  3. package/dist/billing/index.d.cts +4 -4
  4. package/dist/billing/index.d.ts +4 -4
  5. package/dist/billing/index.js +29 -27
  6. package/dist/chunk-2FR6ZL7R.js +0 -0
  7. package/dist/chunk-2JTISFUZ.js +792 -0
  8. package/dist/chunk-2SLTRKXC.js +0 -0
  9. package/dist/chunk-3E6ONOMG.js +50 -0
  10. package/dist/{chunk-B7NRY2LV.js → chunk-CJFAOD7K.js} +1 -39
  11. package/dist/{chunk-TCBYOFAC.js → chunk-EHKMPP6J.js} +1164 -745
  12. package/dist/{chunk-NNNXXUPT.js → chunk-F4B2NJUZ.js} +23 -88
  13. package/dist/chunk-H4DOTO7S.js +85 -0
  14. package/dist/{chunk-YWDLYOFN.js → chunk-UHD6FJBQ.js} +412 -1188
  15. package/dist/{define-saasicat-BK6RRWWG.d.ts → define-saasicat-3ois8t8s.d.ts} +26 -3
  16. package/dist/{define-saasicat-D30I-WET.d.cts → define-saasicat-CFxut1VR.d.cts} +26 -3
  17. package/dist/{enforce-quota.interceptor-B9QueAFf.d.ts → enforce-quota.interceptor-CYDNvAQz.d.ts} +3 -3
  18. package/dist/{enforce-quota.interceptor-DY6CLjoP.d.cts → enforce-quota.interceptor-N80KC34N.d.cts} +3 -3
  19. package/dist/entitlement/index.js +5 -2
  20. package/dist/index.d.cts +5 -5
  21. package/dist/index.d.ts +5 -5
  22. package/dist/index.js +39 -31
  23. package/dist/{saas-platform.module-D1mUZPrz.d.ts → module-options-ByJL7FZm.d.ts} +40 -27
  24. package/dist/{saas-platform.module-CgalxzcT.d.cts → module-options-klrPnWGF.d.cts} +40 -27
  25. package/dist/platform/index.d.cts +201 -19
  26. package/dist/platform/index.d.ts +201 -19
  27. package/dist/platform/index.js +34 -9
  28. package/dist/subscription-contract/index.js +5 -2
  29. package/dist/{tenant-billing.controller-DHSUrT_N.d.cts → tenant-billing.controller-CAMMdfn1.d.cts} +1 -1
  30. package/dist/{tenant-billing.controller-BSlpFqVA.d.ts → tenant-billing.controller-CYYK0CpT.d.ts} +1 -1
  31. package/dist/{subscription-bundles.module-BDbODWvA.d.ts → tenant-billing.module-B0stLoJn.d.ts} +51 -51
  32. package/dist/{subscription-bundles.module-Cfi-lFWF.d.cts → tenant-billing.module-BxJS6fX4.d.cts} +51 -51
  33. package/dist/testing/index.d.cts +8 -8
  34. package/dist/testing/index.d.ts +8 -8
  35. package/dist/testing/index.js +6 -4
  36. package/package.json +4 -4
  37. /package/dist/{chunk-FY4EJTV4.js → chunk-OYNHOY45.js} +0 -0
@@ -10,7 +10,6 @@ import {
10
10
  } from "./chunk-EBJJNTW6.js";
11
11
  import {
12
12
  ENTITLEMENT_RESOLUTION_CONFIG_TOKEN,
13
- ENTITLEMENT_SERVICE_TOKEN,
14
13
  PLAN_VERSION_REPOSITORY_TOKEN,
15
14
  SUBSCRIPTION_REPOSITORY_TOKEN,
16
15
  TRANSACTION_RUNNER_TOKEN
@@ -18,9 +17,6 @@ import {
18
17
  import {
19
18
  BUNDLE_REPOSITORY_TOKEN
20
19
  } from "./chunk-L4KTQ6CL.js";
21
- import {
22
- asProvider
23
- } from "./chunk-SABTXESR.js";
24
20
  import {
25
21
  DISCOVERY_SNAPSHOT_TOKEN
26
22
  } from "./chunk-L4SUWH5B.js";
@@ -28,6 +24,10 @@ import {
28
24
  __name
29
25
  } from "./chunk-SHUYVCID.js";
30
26
 
27
+ // src/billing/subscription-bundles.tokens.ts
28
+ var SUBSCRIPTION_BUNDLE_REPOSITORY_TOKEN = /* @__PURE__ */ Symbol.for("saas-platform/SubscriptionBundleRepository");
29
+ var SUBSCRIPTION_BUNDLE_CONFIG_TOKEN = /* @__PURE__ */ Symbol.for("saas-platform/SubscriptionBundleConfig");
30
+
31
31
  // src/entitlement/aggregation.ts
32
32
  function filterActiveSubscriptionBundles(bundles, now) {
33
33
  return bundles.filter((b) => b.canceledEffectiveAt === null || b.canceledEffectiveAt > now);
@@ -268,24 +268,6 @@ function assertNoReplacesCycle(index) {
268
268
  }
269
269
  __name(assertNoReplacesCycle, "assertNoReplacesCycle");
270
270
 
271
- // src/entitlement/plan-resolution.ts
272
- function resolveEntitlementPlan(input, config, now) {
273
- if (input.isPilot && config.pilotEntitlementPlan !== void 0) {
274
- return config.pilotEntitlementPlan;
275
- }
276
- if (input.status === "TRIAL") {
277
- return input.trialEntitlementPlan ?? config.defaultTrialEntitlementPlan ?? input.plan;
278
- }
279
- if (input.status === "PENDING_SALES" && config.pendingSalesEntitlementPlan !== void 0) {
280
- return config.pendingSalesEntitlementPlan;
281
- }
282
- if (input.pendingPlan && input.pendingEffectiveAt && input.pendingEffectiveAt <= now) {
283
- return input.pendingPlan;
284
- }
285
- return input.plan;
286
- }
287
- __name(resolveEntitlementPlan, "resolveEntitlementPlan");
288
-
289
271
  // src/entitlement/limit-exceeded-error.ts
290
272
  var LIMIT_EXCEEDED = "LIMIT_EXCEEDED";
291
273
  var LimitExceededError = class extends Error {
@@ -306,15 +288,27 @@ function isLimitExceededError(err) {
306
288
  }
307
289
  __name(isLimitExceededError, "isLimitExceededError");
308
290
 
291
+ // src/entitlement/plan-resolution.ts
292
+ function resolveEntitlementPlan(input, config, now) {
293
+ if (input.isPilot && config.pilotEntitlementPlan !== void 0) {
294
+ return config.pilotEntitlementPlan;
295
+ }
296
+ if (input.status === "TRIAL") {
297
+ return input.trialEntitlementPlan ?? config.defaultTrialEntitlementPlan ?? input.plan;
298
+ }
299
+ if (input.status === "PENDING_SALES" && config.pendingSalesEntitlementPlan !== void 0) {
300
+ return config.pendingSalesEntitlementPlan;
301
+ }
302
+ if (input.pendingPlan && input.pendingEffectiveAt && input.pendingEffectiveAt <= now) {
303
+ return input.pendingPlan;
304
+ }
305
+ return input.plan;
306
+ }
307
+ __name(resolveEntitlementPlan, "resolveEntitlementPlan");
308
+
309
309
  // src/entitlement/service.ts
310
310
  import { Inject, Injectable, InternalServerErrorException, NotFoundException, Optional } from "@nestjs/common";
311
311
  import { BILLING_ERROR_CODES } from "@saasicat/types";
312
-
313
- // src/billing/subscription-bundles.tokens.ts
314
- var SUBSCRIPTION_BUNDLE_REPOSITORY_TOKEN = /* @__PURE__ */ Symbol.for("saas-platform/SubscriptionBundleRepository");
315
- var SUBSCRIPTION_BUNDLE_CONFIG_TOKEN = /* @__PURE__ */ Symbol.for("saas-platform/SubscriptionBundleConfig");
316
-
317
- // src/entitlement/service.ts
318
312
  function _ts_decorate(decorators, target, key, desc) {
319
313
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
320
314
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -577,64 +571,6 @@ EntitlementService = _ts_decorate([
577
571
  ])
578
572
  ], EntitlementService);
579
573
 
580
- // src/entitlement/module.ts
581
- import { Module } from "@nestjs/common";
582
- function _ts_decorate2(decorators, target, key, desc) {
583
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
584
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
585
- 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;
586
- return c > 3 && r && Object.defineProperty(target, key, r), r;
587
- }
588
- __name(_ts_decorate2, "_ts_decorate");
589
- var EntitlementModule = class _EntitlementModule {
590
- static {
591
- __name(this, "EntitlementModule");
592
- }
593
- static forRoot(options) {
594
- const providers = [
595
- asProvider(SUBSCRIPTION_REPOSITORY_TOKEN, options.subscriptionRepository),
596
- asProvider(PLAN_VERSION_REPOSITORY_TOKEN, options.planVersionRepository),
597
- asProvider(TRANSACTION_RUNNER_TOKEN, options.transactionRunner),
598
- EntitlementService,
599
- // Cross-bundle-stable alias so consumers in other subpath bundles
600
- // (billing/TenantBillingModule) can inject the same instance.
601
- {
602
- provide: ENTITLEMENT_SERVICE_TOKEN,
603
- useExisting: EntitlementService
604
- }
605
- ];
606
- if (options.resolutionConfig) {
607
- providers.push({
608
- provide: ENTITLEMENT_RESOLUTION_CONFIG_TOKEN,
609
- useValue: options.resolutionConfig
610
- });
611
- }
612
- if (options.subscriptionContractRepository) {
613
- providers.push(asProvider(SUBSCRIPTION_CONTRACT_REPOSITORY_TOKEN, options.subscriptionContractRepository));
614
- }
615
- if (options.subscriptionBundleRepository) {
616
- providers.push(asProvider(SUBSCRIPTION_BUNDLE_REPOSITORY_TOKEN, options.subscriptionBundleRepository));
617
- }
618
- if (options.bundleRepository) {
619
- providers.push(asProvider(BUNDLE_REPOSITORY_TOKEN, options.bundleRepository));
620
- }
621
- return {
622
- module: _EntitlementModule,
623
- global: options.global ?? false,
624
- imports: options.imports ?? [],
625
- providers,
626
- exports: [
627
- EntitlementService,
628
- ENTITLEMENT_SERVICE_TOKEN,
629
- SUBSCRIPTION_REPOSITORY_TOKEN
630
- ]
631
- };
632
- }
633
- };
634
- EntitlementModule = _ts_decorate2([
635
- Module({})
636
- ], EntitlementModule);
637
-
638
574
  export {
639
575
  SUBSCRIPTION_BUNDLE_REPOSITORY_TOKEN,
640
576
  SUBSCRIPTION_BUNDLE_CONFIG_TOKEN,
@@ -656,6 +592,5 @@ export {
656
592
  LimitExceededError,
657
593
  isLimitExceededError,
658
594
  resolveEntitlementPlan,
659
- EntitlementService,
660
- EntitlementModule
595
+ EntitlementService
661
596
  };
@@ -0,0 +1,85 @@
1
+ import {
2
+ EntitlementService,
3
+ SUBSCRIPTION_BUNDLE_REPOSITORY_TOKEN
4
+ } from "./chunk-F4B2NJUZ.js";
5
+ import {
6
+ SUBSCRIPTION_CONTRACT_REPOSITORY_TOKEN
7
+ } from "./chunk-NYLON2VC.js";
8
+ import {
9
+ ENTITLEMENT_RESOLUTION_CONFIG_TOKEN,
10
+ ENTITLEMENT_SERVICE_TOKEN,
11
+ PLAN_VERSION_REPOSITORY_TOKEN,
12
+ SUBSCRIPTION_REPOSITORY_TOKEN,
13
+ TRANSACTION_RUNNER_TOKEN
14
+ } from "./chunk-WKVBNTYC.js";
15
+ import {
16
+ BUNDLE_REPOSITORY_TOKEN
17
+ } from "./chunk-L4KTQ6CL.js";
18
+ import {
19
+ asProvider
20
+ } from "./chunk-SABTXESR.js";
21
+ import {
22
+ __name
23
+ } from "./chunk-SHUYVCID.js";
24
+
25
+ // src/entitlement/module.ts
26
+ import { Module } from "@nestjs/common";
27
+ function _ts_decorate(decorators, target, key, desc) {
28
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
29
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
30
+ 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;
31
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
32
+ }
33
+ __name(_ts_decorate, "_ts_decorate");
34
+ var EntitlementModule = class _EntitlementModule {
35
+ static {
36
+ __name(this, "EntitlementModule");
37
+ }
38
+ static forRoot(options) {
39
+ const providers = [
40
+ asProvider(SUBSCRIPTION_REPOSITORY_TOKEN, options.subscriptionRepository),
41
+ asProvider(PLAN_VERSION_REPOSITORY_TOKEN, options.planVersionRepository),
42
+ asProvider(TRANSACTION_RUNNER_TOKEN, options.transactionRunner),
43
+ EntitlementService,
44
+ // Cross-bundle-stable alias so consumers in other subpath bundles
45
+ // (billing/TenantBillingModule) can inject the same instance.
46
+ {
47
+ provide: ENTITLEMENT_SERVICE_TOKEN,
48
+ useExisting: EntitlementService
49
+ }
50
+ ];
51
+ if (options.resolutionConfig) {
52
+ providers.push({
53
+ provide: ENTITLEMENT_RESOLUTION_CONFIG_TOKEN,
54
+ useValue: options.resolutionConfig
55
+ });
56
+ }
57
+ if (options.subscriptionContractRepository) {
58
+ providers.push(asProvider(SUBSCRIPTION_CONTRACT_REPOSITORY_TOKEN, options.subscriptionContractRepository));
59
+ }
60
+ if (options.subscriptionBundleRepository) {
61
+ providers.push(asProvider(SUBSCRIPTION_BUNDLE_REPOSITORY_TOKEN, options.subscriptionBundleRepository));
62
+ }
63
+ if (options.bundleRepository) {
64
+ providers.push(asProvider(BUNDLE_REPOSITORY_TOKEN, options.bundleRepository));
65
+ }
66
+ return {
67
+ module: _EntitlementModule,
68
+ global: options.global ?? false,
69
+ imports: options.imports ?? [],
70
+ providers,
71
+ exports: [
72
+ EntitlementService,
73
+ ENTITLEMENT_SERVICE_TOKEN,
74
+ SUBSCRIPTION_REPOSITORY_TOKEN
75
+ ]
76
+ };
77
+ }
78
+ };
79
+ EntitlementModule = _ts_decorate([
80
+ Module({})
81
+ ], EntitlementModule);
82
+
83
+ export {
84
+ EntitlementModule
85
+ };