@saasicat/nest 0.2.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 (96) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +53 -0
  3. package/dist/admin/index.cjs +1283 -0
  4. package/dist/admin/index.d.cts +225 -0
  5. package/dist/admin/index.d.ts +225 -0
  6. package/dist/admin/index.js +58 -0
  7. package/dist/admin-audit.service-9IqXMlZm.d.cts +30 -0
  8. package/dist/admin-audit.service-9IqXMlZm.d.ts +30 -0
  9. package/dist/admin-manifest.config-DyrQNT7M.d.cts +10 -0
  10. package/dist/admin-manifest.config-DyrQNT7M.d.ts +10 -0
  11. package/dist/aggregation-CJ3qQf92.d.cts +288 -0
  12. package/dist/aggregation-Dvz9e8X2.d.ts +288 -0
  13. package/dist/billing/index.cjs +5205 -0
  14. package/dist/billing/index.d.cts +1326 -0
  15. package/dist/billing/index.d.ts +1326 -0
  16. package/dist/billing/index.js +197 -0
  17. package/dist/catalog/index.cjs +6449 -0
  18. package/dist/catalog/index.d.cts +1073 -0
  19. package/dist/catalog/index.d.ts +1073 -0
  20. package/dist/catalog/index.js +158 -0
  21. package/dist/checkout-offer/index.cjs +807 -0
  22. package/dist/checkout-offer/index.d.cts +120 -0
  23. package/dist/checkout-offer/index.d.ts +120 -0
  24. package/dist/checkout-offer/index.js +20 -0
  25. package/dist/chunk-2FR6ZL7R.js +0 -0
  26. package/dist/chunk-2PNX2QL2.js +347 -0
  27. package/dist/chunk-2VNZYRDV.js +326 -0
  28. package/dist/chunk-7MLGHWKO.js +12 -0
  29. package/dist/chunk-ABB2CRAS.js +31 -0
  30. package/dist/chunk-AJ3EPELS.js +157 -0
  31. package/dist/chunk-E56W4U2P.js +90 -0
  32. package/dist/chunk-HRU3CP57.js +71 -0
  33. package/dist/chunk-L4SUWH5B.js +14 -0
  34. package/dist/chunk-M6CZQYPY.js +314 -0
  35. package/dist/chunk-MDIZUVIK.js +87 -0
  36. package/dist/chunk-MV6LW5UB.js +217 -0
  37. package/dist/chunk-NYLON2VC.js +6 -0
  38. package/dist/chunk-P6MYZMXQ.js +951 -0
  39. package/dist/chunk-Q53N43LQ.js +13 -0
  40. package/dist/chunk-QJVPRD3R.js +573 -0
  41. package/dist/chunk-RIGLQ4BV.js +3367 -0
  42. package/dist/chunk-SABTXESR.js +24 -0
  43. package/dist/chunk-SHUYVCID.js +6 -0
  44. package/dist/chunk-SYEVGPFC.js +686 -0
  45. package/dist/chunk-V7HUZ6UQ.js +5923 -0
  46. package/dist/chunk-WPUVJRIN.js +29 -0
  47. package/dist/chunk-XCZ3TTFK.js +22 -0
  48. package/dist/chunk-XSGU2Y2O.js +1611 -0
  49. package/dist/chunk-YNEW3L63.js +190 -0
  50. package/dist/chunk-YXGHPILG.js +614 -0
  51. package/dist/chunk-ZL4LLE2Z.js +465 -0
  52. package/dist/di-CcNeq9v-.d.cts +16 -0
  53. package/dist/di-CcNeq9v-.d.ts +16 -0
  54. package/dist/discovery/index.cjs +588 -0
  55. package/dist/discovery/index.d.cts +299 -0
  56. package/dist/discovery/index.d.ts +299 -0
  57. package/dist/discovery/index.js +49 -0
  58. package/dist/discovery.scanner-CUYLKlYT.d.cts +59 -0
  59. package/dist/discovery.scanner-CUYLKlYT.d.ts +59 -0
  60. package/dist/entitlement/index.cjs +805 -0
  61. package/dist/entitlement/index.d.cts +60 -0
  62. package/dist/entitlement/index.d.ts +60 -0
  63. package/dist/entitlement/index.js +57 -0
  64. package/dist/index.cjs +15918 -0
  65. package/dist/index.d.cts +85 -0
  66. package/dist/index.d.ts +85 -0
  67. package/dist/index.js +956 -0
  68. package/dist/plan-resolution-CFCoUkrE.d.cts +41 -0
  69. package/dist/plan-resolution-CFCoUkrE.d.ts +41 -0
  70. package/dist/platform/index.cjs +2772 -0
  71. package/dist/platform/index.d.cts +118 -0
  72. package/dist/platform/index.d.ts +118 -0
  73. package/dist/platform/index.js +37 -0
  74. package/dist/promo/index.cjs +995 -0
  75. package/dist/promo/index.d.cts +121 -0
  76. package/dist/promo/index.d.ts +121 -0
  77. package/dist/promo/index.js +58 -0
  78. package/dist/registration/index.cjs +1687 -0
  79. package/dist/registration/index.d.cts +444 -0
  80. package/dist/registration/index.d.ts +444 -0
  81. package/dist/registration/index.js +82 -0
  82. package/dist/saas-platform.module-CgZ2omgg.d.cts +180 -0
  83. package/dist/saas-platform.module-DT9TnCzk.d.ts +180 -0
  84. package/dist/service-DX8KbGXl.d.cts +109 -0
  85. package/dist/service-DX8KbGXl.d.ts +109 -0
  86. package/dist/subscription-contract/index.cjs +471 -0
  87. package/dist/subscription-contract/index.d.cts +17 -0
  88. package/dist/subscription-contract/index.d.ts +17 -0
  89. package/dist/subscription-contract/index.js +21 -0
  90. package/dist/subscription-contract.service--cm47ZJJ.d.cts +39 -0
  91. package/dist/subscription-contract.service--cm47ZJJ.d.ts +39 -0
  92. package/dist/testing/index.cjs +3942 -0
  93. package/dist/testing/index.d.cts +279 -0
  94. package/dist/testing/index.d.ts +279 -0
  95. package/dist/testing/index.js +1195 -0
  96. package/package.json +185 -0
@@ -0,0 +1,121 @@
1
+ import { PromoCodeValueType, PromoCodeDurationType, BillingCycle, PromoCodeRepository, PromoCodeRedemptionRepository, PromoCodeValidationLogRepository, FirstTimeCustomerCheck, PromoSubscriptionLookup, PromoRevenueDeductionAggregator, TransactionRunner } from '@saasicat/types';
2
+ import { f as PromoCodesService, c as PreviewResult, g as PromoServiceConfig } from '../service-DX8KbGXl.cjs';
3
+ export { P as PreviewInput, a as PreviewInvalid, b as PreviewReason, d as PreviewValid, e as PromoCodeStats, R as RedeemInput } from '../service-DX8KbGXl.cjs';
4
+ import { CanActivate, ExecutionContext, DynamicModule } from '@nestjs/common';
5
+ import { P as ProviderSpec } from '../di-CcNeq9v-.cjs';
6
+
7
+ /** Structural view of a PromoCode for the calculator functions.
8
+ *
9
+ * `value` deliberately accepts `number | string | { toString(): string }`, so
10
+ * that a Prisma `Decimal` (its own class with `toString()`) can be passed
11
+ * without a cast. Internally `Number(...)` is called.
12
+ */
13
+ interface PromoCodeForCalc {
14
+ valueType: PromoCodeValueType | string;
15
+ value: number | string | {
16
+ toString(): string;
17
+ };
18
+ durationType?: PromoCodeDurationType | string;
19
+ durationValue?: number | null;
20
+ }
21
+ declare function computeDiscountGross(plan: {
22
+ gross: number;
23
+ }, code: Pick<PromoCodeForCalc, 'valueType' | 'value'>): number;
24
+ declare function computeDiscountedGross(planGross: number, discountGross: number): number;
25
+ /**
26
+ * Next date on which the list price applies again (= end of the discount
27
+ * period). For ONCE: the first invoice is discounted, all others are
28
+ * regular — so directly the second period.
29
+ */
30
+ declare function computeRegularStartsAt(startsAt: Date, cycle: BillingCycle, durationType: PromoCodeDurationType, durationValue: number | null): Date;
31
+ declare function addCycles(date: Date, cycle: BillingCycle, n: number): Date;
32
+ declare function buildLabel(code: Pick<PromoCodeForCalc, 'valueType' | 'value' | 'durationType' | 'durationValue'>, cycle: BillingCycle): string;
33
+
34
+ declare function round2(n: number): number;
35
+ /** Gross = net * (1 + vatRate/100). */
36
+ declare function grossFromNet(net: number, vatRate: number): number;
37
+ /** VAT included in the gross amount: gross * (vatRate / (100 + vatRate)). */
38
+ declare function computeIncludedVat(grossAmount: number, vatRate: number): number;
39
+
40
+ declare class PromoCodeExpirer {
41
+ private readonly promoRepo;
42
+ private readonly redemptionRepo;
43
+ private readonly logger;
44
+ constructor(promoRepo: PromoCodeRepository, redemptionRepo: PromoCodeRedemptionRepository);
45
+ expirePromoCodes(): Promise<void>;
46
+ }
47
+
48
+ interface RequestLike$1 {
49
+ headers: Record<string, string | string[] | undefined>;
50
+ ip?: string;
51
+ user?: {
52
+ id?: string;
53
+ };
54
+ }
55
+ declare class PromoCodeRateLimitGuard implements CanActivate {
56
+ private ipBuckets;
57
+ private sessionBuckets;
58
+ canActivate(context: ExecutionContext): boolean;
59
+ private exceeded;
60
+ }
61
+ declare function ipFingerprint(req: RequestLike$1): string;
62
+ declare function hashIp(req: RequestLike$1): string;
63
+
64
+ declare const PROMO_CODE_REPOSITORY_TOKEN: unique symbol;
65
+ declare const PROMO_CODE_REDEMPTION_REPOSITORY_TOKEN: unique symbol;
66
+ declare const PROMO_CODE_VALIDATION_LOG_REPOSITORY_TOKEN: unique symbol;
67
+ declare const PROMO_FIRST_TIME_CUSTOMER_CHECK_TOKEN: unique symbol;
68
+ declare const PROMO_SUBSCRIPTION_LOOKUP_TOKEN: unique symbol;
69
+ declare const PROMO_REVENUE_DEDUCTION_AGGREGATOR_TOKEN: unique symbol;
70
+ declare const PROMO_TRANSACTION_RUNNER_TOKEN: unique symbol;
71
+ declare const PROMO_SERVICE_CONFIG_TOKEN: unique symbol;
72
+
73
+ declare class PreviewPromoCodeDto {
74
+ code: string;
75
+ plan: string;
76
+ billingCycle: string;
77
+ email?: string;
78
+ }
79
+
80
+ interface RequestLike {
81
+ headers: Record<string, string | string[] | undefined>;
82
+ ip?: string;
83
+ user?: {
84
+ id?: string;
85
+ sub?: string;
86
+ };
87
+ }
88
+ declare class PromoCodePublicController {
89
+ private readonly promo;
90
+ constructor(promo: PromoCodesService);
91
+ preview(dto: PreviewPromoCodeDto, req: RequestLike): Promise<PreviewResult>;
92
+ }
93
+
94
+ interface PromoCodesModuleOptions {
95
+ promoCodeRepository: ProviderSpec<PromoCodeRepository>;
96
+ redemptionRepository: ProviderSpec<PromoCodeRedemptionRepository>;
97
+ validationLogRepository: ProviderSpec<PromoCodeValidationLogRepository>;
98
+ firstTimeCustomerCheck: ProviderSpec<FirstTimeCustomerCheck>;
99
+ subscriptionLookup: ProviderSpec<PromoSubscriptionLookup>;
100
+ revenueAggregator: ProviderSpec<PromoRevenueDeductionAggregator>;
101
+ transactionRunner: ProviderSpec<TransactionRunner>;
102
+ config?: PromoServiceConfig;
103
+ /**
104
+ * Default `true`. Set to `false` if the consumer wants to disable the cron
105
+ * (e.g. CLI boot, test setups without ScheduleModule).
106
+ */
107
+ includeExpirerCron?: boolean;
108
+ /**
109
+ * Default `true`. Registers `PromoCodePublicController` with
110
+ * `POST /billing/promo/preview`. Set to `false` if the consumer does not
111
+ * want to expose a public preview API (e.g. SuperAdmin-only deploy).
112
+ */
113
+ includePublicController?: boolean;
114
+ /** Register the module globally — default `false`. */
115
+ global?: boolean;
116
+ }
117
+ declare class PromoCodesModule {
118
+ static forRoot(options: PromoCodesModuleOptions): DynamicModule;
119
+ }
120
+
121
+ export { PROMO_CODE_REDEMPTION_REPOSITORY_TOKEN, PROMO_CODE_REPOSITORY_TOKEN, PROMO_CODE_VALIDATION_LOG_REPOSITORY_TOKEN, PROMO_FIRST_TIME_CUSTOMER_CHECK_TOKEN, PROMO_REVENUE_DEDUCTION_AGGREGATOR_TOKEN, PROMO_SERVICE_CONFIG_TOKEN, PROMO_SUBSCRIPTION_LOOKUP_TOKEN, PROMO_TRANSACTION_RUNNER_TOKEN, PreviewPromoCodeDto, PreviewResult, PromoCodeExpirer, type PromoCodeForCalc, PromoCodePublicController, PromoCodeRateLimitGuard, PromoCodesModule, type PromoCodesModuleOptions, PromoCodesService, PromoServiceConfig, addCycles, buildLabel, computeDiscountGross, computeDiscountedGross, computeIncludedVat, computeRegularStartsAt, grossFromNet, hashIp, ipFingerprint, round2 };
@@ -0,0 +1,121 @@
1
+ import { PromoCodeValueType, PromoCodeDurationType, BillingCycle, PromoCodeRepository, PromoCodeRedemptionRepository, PromoCodeValidationLogRepository, FirstTimeCustomerCheck, PromoSubscriptionLookup, PromoRevenueDeductionAggregator, TransactionRunner } from '@saasicat/types';
2
+ import { f as PromoCodesService, c as PreviewResult, g as PromoServiceConfig } from '../service-DX8KbGXl.js';
3
+ export { P as PreviewInput, a as PreviewInvalid, b as PreviewReason, d as PreviewValid, e as PromoCodeStats, R as RedeemInput } from '../service-DX8KbGXl.js';
4
+ import { CanActivate, ExecutionContext, DynamicModule } from '@nestjs/common';
5
+ import { P as ProviderSpec } from '../di-CcNeq9v-.js';
6
+
7
+ /** Structural view of a PromoCode for the calculator functions.
8
+ *
9
+ * `value` deliberately accepts `number | string | { toString(): string }`, so
10
+ * that a Prisma `Decimal` (its own class with `toString()`) can be passed
11
+ * without a cast. Internally `Number(...)` is called.
12
+ */
13
+ interface PromoCodeForCalc {
14
+ valueType: PromoCodeValueType | string;
15
+ value: number | string | {
16
+ toString(): string;
17
+ };
18
+ durationType?: PromoCodeDurationType | string;
19
+ durationValue?: number | null;
20
+ }
21
+ declare function computeDiscountGross(plan: {
22
+ gross: number;
23
+ }, code: Pick<PromoCodeForCalc, 'valueType' | 'value'>): number;
24
+ declare function computeDiscountedGross(planGross: number, discountGross: number): number;
25
+ /**
26
+ * Next date on which the list price applies again (= end of the discount
27
+ * period). For ONCE: the first invoice is discounted, all others are
28
+ * regular — so directly the second period.
29
+ */
30
+ declare function computeRegularStartsAt(startsAt: Date, cycle: BillingCycle, durationType: PromoCodeDurationType, durationValue: number | null): Date;
31
+ declare function addCycles(date: Date, cycle: BillingCycle, n: number): Date;
32
+ declare function buildLabel(code: Pick<PromoCodeForCalc, 'valueType' | 'value' | 'durationType' | 'durationValue'>, cycle: BillingCycle): string;
33
+
34
+ declare function round2(n: number): number;
35
+ /** Gross = net * (1 + vatRate/100). */
36
+ declare function grossFromNet(net: number, vatRate: number): number;
37
+ /** VAT included in the gross amount: gross * (vatRate / (100 + vatRate)). */
38
+ declare function computeIncludedVat(grossAmount: number, vatRate: number): number;
39
+
40
+ declare class PromoCodeExpirer {
41
+ private readonly promoRepo;
42
+ private readonly redemptionRepo;
43
+ private readonly logger;
44
+ constructor(promoRepo: PromoCodeRepository, redemptionRepo: PromoCodeRedemptionRepository);
45
+ expirePromoCodes(): Promise<void>;
46
+ }
47
+
48
+ interface RequestLike$1 {
49
+ headers: Record<string, string | string[] | undefined>;
50
+ ip?: string;
51
+ user?: {
52
+ id?: string;
53
+ };
54
+ }
55
+ declare class PromoCodeRateLimitGuard implements CanActivate {
56
+ private ipBuckets;
57
+ private sessionBuckets;
58
+ canActivate(context: ExecutionContext): boolean;
59
+ private exceeded;
60
+ }
61
+ declare function ipFingerprint(req: RequestLike$1): string;
62
+ declare function hashIp(req: RequestLike$1): string;
63
+
64
+ declare const PROMO_CODE_REPOSITORY_TOKEN: unique symbol;
65
+ declare const PROMO_CODE_REDEMPTION_REPOSITORY_TOKEN: unique symbol;
66
+ declare const PROMO_CODE_VALIDATION_LOG_REPOSITORY_TOKEN: unique symbol;
67
+ declare const PROMO_FIRST_TIME_CUSTOMER_CHECK_TOKEN: unique symbol;
68
+ declare const PROMO_SUBSCRIPTION_LOOKUP_TOKEN: unique symbol;
69
+ declare const PROMO_REVENUE_DEDUCTION_AGGREGATOR_TOKEN: unique symbol;
70
+ declare const PROMO_TRANSACTION_RUNNER_TOKEN: unique symbol;
71
+ declare const PROMO_SERVICE_CONFIG_TOKEN: unique symbol;
72
+
73
+ declare class PreviewPromoCodeDto {
74
+ code: string;
75
+ plan: string;
76
+ billingCycle: string;
77
+ email?: string;
78
+ }
79
+
80
+ interface RequestLike {
81
+ headers: Record<string, string | string[] | undefined>;
82
+ ip?: string;
83
+ user?: {
84
+ id?: string;
85
+ sub?: string;
86
+ };
87
+ }
88
+ declare class PromoCodePublicController {
89
+ private readonly promo;
90
+ constructor(promo: PromoCodesService);
91
+ preview(dto: PreviewPromoCodeDto, req: RequestLike): Promise<PreviewResult>;
92
+ }
93
+
94
+ interface PromoCodesModuleOptions {
95
+ promoCodeRepository: ProviderSpec<PromoCodeRepository>;
96
+ redemptionRepository: ProviderSpec<PromoCodeRedemptionRepository>;
97
+ validationLogRepository: ProviderSpec<PromoCodeValidationLogRepository>;
98
+ firstTimeCustomerCheck: ProviderSpec<FirstTimeCustomerCheck>;
99
+ subscriptionLookup: ProviderSpec<PromoSubscriptionLookup>;
100
+ revenueAggregator: ProviderSpec<PromoRevenueDeductionAggregator>;
101
+ transactionRunner: ProviderSpec<TransactionRunner>;
102
+ config?: PromoServiceConfig;
103
+ /**
104
+ * Default `true`. Set to `false` if the consumer wants to disable the cron
105
+ * (e.g. CLI boot, test setups without ScheduleModule).
106
+ */
107
+ includeExpirerCron?: boolean;
108
+ /**
109
+ * Default `true`. Registers `PromoCodePublicController` with
110
+ * `POST /billing/promo/preview`. Set to `false` if the consumer does not
111
+ * want to expose a public preview API (e.g. SuperAdmin-only deploy).
112
+ */
113
+ includePublicController?: boolean;
114
+ /** Register the module globally — default `false`. */
115
+ global?: boolean;
116
+ }
117
+ declare class PromoCodesModule {
118
+ static forRoot(options: PromoCodesModuleOptions): DynamicModule;
119
+ }
120
+
121
+ export { PROMO_CODE_REDEMPTION_REPOSITORY_TOKEN, PROMO_CODE_REPOSITORY_TOKEN, PROMO_CODE_VALIDATION_LOG_REPOSITORY_TOKEN, PROMO_FIRST_TIME_CUSTOMER_CHECK_TOKEN, PROMO_REVENUE_DEDUCTION_AGGREGATOR_TOKEN, PROMO_SERVICE_CONFIG_TOKEN, PROMO_SUBSCRIPTION_LOOKUP_TOKEN, PROMO_TRANSACTION_RUNNER_TOKEN, PreviewPromoCodeDto, PreviewResult, PromoCodeExpirer, type PromoCodeForCalc, PromoCodePublicController, PromoCodeRateLimitGuard, PromoCodesModule, type PromoCodesModuleOptions, PromoCodesService, PromoServiceConfig, addCycles, buildLabel, computeDiscountGross, computeDiscountedGross, computeIncludedVat, computeRegularStartsAt, grossFromNet, hashIp, ipFingerprint, round2 };
@@ -0,0 +1,58 @@
1
+ import {
2
+ PreviewPromoCodeDto,
3
+ PromoCodeExpirer,
4
+ PromoCodePublicController,
5
+ PromoCodeRateLimitGuard,
6
+ PromoCodesModule,
7
+ hashIp,
8
+ ipFingerprint
9
+ } from "../chunk-2VNZYRDV.js";
10
+ import {
11
+ PROMO_CODE_REDEMPTION_REPOSITORY_TOKEN,
12
+ PROMO_CODE_REPOSITORY_TOKEN,
13
+ PROMO_CODE_VALIDATION_LOG_REPOSITORY_TOKEN,
14
+ PROMO_FIRST_TIME_CUSTOMER_CHECK_TOKEN,
15
+ PROMO_REVENUE_DEDUCTION_AGGREGATOR_TOKEN,
16
+ PROMO_SERVICE_CONFIG_TOKEN,
17
+ PROMO_SUBSCRIPTION_LOOKUP_TOKEN,
18
+ PROMO_TRANSACTION_RUNNER_TOKEN,
19
+ PromoCodesService,
20
+ addCycles,
21
+ buildLabel,
22
+ computeDiscountGross,
23
+ computeDiscountedGross,
24
+ computeRegularStartsAt
25
+ } from "../chunk-ZL4LLE2Z.js";
26
+ import {
27
+ computeIncludedVat,
28
+ grossFromNet,
29
+ round2
30
+ } from "../chunk-MV6LW5UB.js";
31
+ import "../chunk-SABTXESR.js";
32
+ import "../chunk-SHUYVCID.js";
33
+ export {
34
+ PROMO_CODE_REDEMPTION_REPOSITORY_TOKEN,
35
+ PROMO_CODE_REPOSITORY_TOKEN,
36
+ PROMO_CODE_VALIDATION_LOG_REPOSITORY_TOKEN,
37
+ PROMO_FIRST_TIME_CUSTOMER_CHECK_TOKEN,
38
+ PROMO_REVENUE_DEDUCTION_AGGREGATOR_TOKEN,
39
+ PROMO_SERVICE_CONFIG_TOKEN,
40
+ PROMO_SUBSCRIPTION_LOOKUP_TOKEN,
41
+ PROMO_TRANSACTION_RUNNER_TOKEN,
42
+ PreviewPromoCodeDto,
43
+ PromoCodeExpirer,
44
+ PromoCodePublicController,
45
+ PromoCodeRateLimitGuard,
46
+ PromoCodesModule,
47
+ PromoCodesService,
48
+ addCycles,
49
+ buildLabel,
50
+ computeDiscountGross,
51
+ computeDiscountedGross,
52
+ computeIncludedVat,
53
+ computeRegularStartsAt,
54
+ grossFromNet,
55
+ hashIp,
56
+ ipFingerprint,
57
+ round2
58
+ };