@saasicat/nest 0.7.0 → 0.9.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 (59) hide show
  1. package/dist/admin/index.cjs +262 -7
  2. package/dist/admin/index.d.cts +6 -4
  3. package/dist/admin/index.d.ts +6 -4
  4. package/dist/admin/index.js +12 -4
  5. package/dist/{admin-manifest.service-Cp6uwvmt.d.cts → admin-manifest.service-BMeSLRW4.d.ts} +1 -1
  6. package/dist/{admin-manifest.service-UGgzR1x-.d.ts → admin-manifest.service-StAQe6QO.d.cts} +1 -1
  7. package/dist/admin-resources.module-BybEjZs-.d.cts +40 -0
  8. package/dist/admin-resources.module-CUCLlUAi.d.ts +40 -0
  9. package/dist/billing/index.cjs +3 -1
  10. package/dist/billing/index.d.cts +5 -287
  11. package/dist/billing/index.d.ts +5 -287
  12. package/dist/billing/index.js +5 -8
  13. package/dist/catalog/index.d.cts +4 -101
  14. package/dist/catalog/index.d.ts +4 -101
  15. package/dist/catalog/index.js +12 -10
  16. package/dist/catalog.module-BKObceo0.d.ts +103 -0
  17. package/dist/catalog.module-Dw2Hrbyu.d.cts +103 -0
  18. package/dist/{chunk-U6HT27J7.js → chunk-3M6VLT5N.js} +257 -6
  19. package/dist/chunk-7K5PT2LX.js +211 -0
  20. package/dist/{chunk-RZU4HIAN.js → chunk-GW2I3JZD.js} +25 -22
  21. package/dist/{chunk-6LP7CDS2.js → chunk-HXAWPPFW.js} +10 -5
  22. package/dist/chunk-OFBDEO45.js +755 -0
  23. package/dist/{chunk-5DDCSGZC.js → chunk-PBQRPDO2.js} +142 -354
  24. package/dist/{chunk-SD3TT2BR.js → chunk-WGVTXSYW.js} +1 -1
  25. package/dist/{chunk-A2QBXDJC.js → chunk-ZZMAHX22.js} +343 -16
  26. package/dist/{enforce-quota.interceptor-Dj1Kusr5.d.ts → enforce-quota.interceptor-B3CL5MSw.d.ts} +94 -12
  27. package/dist/{enforce-quota.interceptor-cv7r80VM.d.cts → enforce-quota.interceptor-SqrQVF91.d.cts} +94 -12
  28. package/dist/entitlement/index.cjs +1 -0
  29. package/dist/entitlement/index.d.cts +3 -1
  30. package/dist/entitlement/index.d.ts +3 -1
  31. package/dist/entitlement/index.js +1 -2
  32. package/dist/index.cjs +3503 -2811
  33. package/dist/index.d.cts +9 -6
  34. package/dist/index.d.ts +9 -6
  35. package/dist/index.js +75 -61
  36. package/dist/module-B5m080F0.d.ts +39 -0
  37. package/dist/module-DeH_Jkcq.d.cts +39 -0
  38. package/dist/platform/index.cjs +11113 -971
  39. package/dist/platform/index.d.cts +41 -7
  40. package/dist/platform/index.d.ts +41 -7
  41. package/dist/platform/index.js +26 -6
  42. package/dist/promo/index.cjs +530 -5
  43. package/dist/promo/index.d.cts +47 -30
  44. package/dist/promo/index.d.ts +47 -30
  45. package/dist/promo/index.js +9 -1
  46. package/dist/{service-DX8KbGXl.d.cts → service-DlhMnYjW.d.cts} +1 -1
  47. package/dist/{service-DX8KbGXl.d.ts → service-DlhMnYjW.d.ts} +1 -1
  48. package/dist/subscription-bundles.module-BQmoozm5.d.ts +291 -0
  49. package/dist/subscription-bundles.module-DCpV-Pb5.d.cts +291 -0
  50. package/dist/testing/index.cjs +11101 -973
  51. package/dist/testing/index.d.cts +9 -4
  52. package/dist/testing/index.d.ts +9 -4
  53. package/dist/testing/index.js +10 -4
  54. package/package.json +4 -4
  55. package/dist/admin-manifest.config-DyrQNT7M.d.cts +0 -10
  56. package/dist/admin-manifest.config-DyrQNT7M.d.ts +0 -10
  57. package/dist/chunk-52UTQRD3.js +0 -326
  58. package/dist/chunk-Q53N43LQ.js +0 -13
  59. /package/dist/{chunk-2FR6ZL7R.js → chunk-HWGIMNWR.js} +0 -0
@@ -1,12 +1,17 @@
1
1
  import { BundleRepository, BundleRow, BundleVersionRow, BundleListFilter, CreateBundleData, UpdateBundleData, CreateBundleVersionDraftData, UpdateBundleVersionDraftData, VersionChange, MarketingProjectionRepository, MarketingProjectionRow, MarketingProjectionFilter, CreateMarketingProjectionData, UpdateMarketingProjectionData, PlanRepository, PlanRow, PlanVersionRow, PlanListFilter, CreatePlanData, UpdatePlanData, CreatePlanVersionDraftData, UpdatePlanVersionDraftData, PlanVersionRepository, PlanVersionRecord, TransactionContext, SubscriptionBundleRepository, SubscriptionBundleRecord, CreateSubscriptionBundleData, CancelSubscriptionBundleData, SubscriptionContractRepository, SubscriptionContractFilter, SubscriptionContractRecord, CreateSubscriptionContractData, TerminateSubscriptionContractData, SubscriptionRepository, SubscriptionRecord, TransactionRunner, PlanCatalog, QuotaProvider } from '@saasicat/types';
2
2
  import { Type, DynamicModule } from '@nestjs/common';
3
- import { c as SaasPlatformAdapters } from '../enforce-quota.interceptor-cv7r80VM.cjs';
4
- export { E as EnforceQuotaInterceptor, P as PLAN_RESOLVER_PORT_TOKEN, S as StaticEntitlementService, g as StaticFeatureGuard, i as StaticPlanResolver } from '../enforce-quota.interceptor-cv7r80VM.cjs';
3
+ import { S as SaasPlatformAdapters } from '../enforce-quota.interceptor-SqrQVF91.cjs';
4
+ export { E as EnforceQuotaInterceptor, P as PLAN_RESOLVER_PORT_TOKEN, a as StaticEntitlementService, b as StaticFeatureGuard, c as StaticPlanResolver } from '../enforce-quota.interceptor-SqrQVF91.cjs';
5
5
  import '../di-CcNeq9v-.cjs';
6
- import '../admin-manifest.config-DyrQNT7M.cjs';
6
+ import '../admin-resources.module-BybEjZs-.cjs';
7
+ import '../admin-audit.service-9IqXMlZm.cjs';
8
+ import '../plan-resolution-CFCoUkrE.cjs';
9
+ import '../module-DeH_Jkcq.cjs';
10
+ import '../service-DlhMnYjW.cjs';
7
11
  import '../discovery.scanner-DLgEvuoy.cjs';
8
12
  import '@nestjs/core';
9
- import '../plan-resolution-CFCoUkrE.cjs';
13
+ import '../catalog.module-Dw2Hrbyu.cjs';
14
+ import '../subscription-bundles.module-DCpV-Pb5.cjs';
10
15
  import 'rxjs';
11
16
 
12
17
  /**
@@ -1,12 +1,17 @@
1
1
  import { BundleRepository, BundleRow, BundleVersionRow, BundleListFilter, CreateBundleData, UpdateBundleData, CreateBundleVersionDraftData, UpdateBundleVersionDraftData, VersionChange, MarketingProjectionRepository, MarketingProjectionRow, MarketingProjectionFilter, CreateMarketingProjectionData, UpdateMarketingProjectionData, PlanRepository, PlanRow, PlanVersionRow, PlanListFilter, CreatePlanData, UpdatePlanData, CreatePlanVersionDraftData, UpdatePlanVersionDraftData, PlanVersionRepository, PlanVersionRecord, TransactionContext, SubscriptionBundleRepository, SubscriptionBundleRecord, CreateSubscriptionBundleData, CancelSubscriptionBundleData, SubscriptionContractRepository, SubscriptionContractFilter, SubscriptionContractRecord, CreateSubscriptionContractData, TerminateSubscriptionContractData, SubscriptionRepository, SubscriptionRecord, TransactionRunner, PlanCatalog, QuotaProvider } from '@saasicat/types';
2
2
  import { Type, DynamicModule } from '@nestjs/common';
3
- import { c as SaasPlatformAdapters } from '../enforce-quota.interceptor-Dj1Kusr5.js';
4
- export { E as EnforceQuotaInterceptor, P as PLAN_RESOLVER_PORT_TOKEN, S as StaticEntitlementService, g as StaticFeatureGuard, i as StaticPlanResolver } from '../enforce-quota.interceptor-Dj1Kusr5.js';
3
+ import { S as SaasPlatformAdapters } from '../enforce-quota.interceptor-B3CL5MSw.js';
4
+ export { E as EnforceQuotaInterceptor, P as PLAN_RESOLVER_PORT_TOKEN, a as StaticEntitlementService, b as StaticFeatureGuard, c as StaticPlanResolver } from '../enforce-quota.interceptor-B3CL5MSw.js';
5
5
  import '../di-CcNeq9v-.js';
6
- import '../admin-manifest.config-DyrQNT7M.js';
6
+ import '../admin-resources.module-CUCLlUAi.js';
7
+ import '../admin-audit.service-9IqXMlZm.js';
8
+ import '../plan-resolution-CFCoUkrE.js';
9
+ import '../module-B5m080F0.js';
10
+ import '../service-DlhMnYjW.js';
7
11
  import '../discovery.scanner-DLgEvuoy.js';
8
12
  import '@nestjs/core';
9
- import '../plan-resolution-CFCoUkrE.js';
13
+ import '../catalog.module-BKObceo0.js';
14
+ import '../subscription-bundles.module-BQmoozm5.js';
10
15
  import 'rxjs';
11
16
 
12
17
  /**
@@ -5,13 +5,19 @@ import {
5
5
  StaticEntitlementService,
6
6
  StaticFeatureGuard,
7
7
  StaticPlanResolver
8
- } from "../chunk-A2QBXDJC.js";
9
- import "../chunk-U6HT27J7.js";
10
- import "../chunk-Q53N43LQ.js";
8
+ } from "../chunk-ZZMAHX22.js";
9
+ import "../chunk-OFBDEO45.js";
10
+ import "../chunk-3M6VLT5N.js";
11
+ import "../chunk-HXAWPPFW.js";
12
+ import "../chunk-ZLUGQE5D.js";
13
+ import "../chunk-2PNX2QL2.js";
14
+ import "../chunk-PBQRPDO2.js";
15
+ import "../chunk-WPUVJRIN.js";
11
16
  import "../chunk-E56W4U2P.js";
17
+ import "../chunk-MDIZUVIK.js";
12
18
  import "../chunk-AJ3EPELS.js";
13
19
  import "../chunk-M6CZQYPY.js";
14
- import "../chunk-RZU4HIAN.js";
20
+ import "../chunk-GW2I3JZD.js";
15
21
  import "../chunk-R2QOSVAA.js";
16
22
  import "../chunk-NYLON2VC.js";
17
23
  import "../chunk-WKVBNTYC.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@saasicat/nest",
3
- "version": "0.7.0",
4
- "description": "NestJS implementation of the SaaS platform: billing, promo codes, admin backend, audit, MFA, adapter ports.",
3
+ "version": "0.9.0",
4
+ "description": "NestJS implementation of SaaSiCat: capability discovery, catalog packaging, contracts, entitlement enforcement, billing and admin APIs.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
@@ -137,8 +137,8 @@
137
137
  "js-yaml": "^4.1.0",
138
138
  "otplib": "^13.4.1",
139
139
  "qrcode": "^1.5.4",
140
- "@saasicat/spec": "^0.7.0",
141
- "@saasicat/types": "^0.7.0"
140
+ "@saasicat/spec": "^0.9.0",
141
+ "@saasicat/types": "^0.9.0"
142
142
  },
143
143
  "peerDependencies": {
144
144
  "@nestjs/common": "^11.0.0",
@@ -1,10 +0,0 @@
1
- import { AdminManifest } from '@saasicat/types';
2
-
3
- declare const ADMIN_MANIFEST_CONFIG: unique symbol;
4
- interface AdminManifestConfig {
5
- project: AdminManifest['project'];
6
- build: Omit<AdminManifest['build'], 'manifestHash'>;
7
- planCatalogSnapshot: AdminManifest['planCatalogSnapshot'];
8
- }
9
-
10
- export { type AdminManifestConfig as A, ADMIN_MANIFEST_CONFIG as a };
@@ -1,10 +0,0 @@
1
- import { AdminManifest } from '@saasicat/types';
2
-
3
- declare const ADMIN_MANIFEST_CONFIG: unique symbol;
4
- interface AdminManifestConfig {
5
- project: AdminManifest['project'];
6
- build: Omit<AdminManifest['build'], 'manifestHash'>;
7
- planCatalogSnapshot: AdminManifest['planCatalogSnapshot'];
8
- }
9
-
10
- export { type AdminManifestConfig as A, ADMIN_MANIFEST_CONFIG as a };
@@ -1,326 +0,0 @@
1
- import {
2
- PROMO_CODE_REDEMPTION_REPOSITORY_TOKEN,
3
- PROMO_CODE_REPOSITORY_TOKEN,
4
- PROMO_CODE_VALIDATION_LOG_REPOSITORY_TOKEN,
5
- PROMO_FIRST_TIME_CUSTOMER_CHECK_TOKEN,
6
- PROMO_REVENUE_DEDUCTION_AGGREGATOR_TOKEN,
7
- PROMO_SERVICE_CONFIG_TOKEN,
8
- PROMO_SUBSCRIPTION_LOOKUP_TOKEN,
9
- PROMO_TRANSACTION_RUNNER_TOKEN,
10
- PromoCodesService
11
- } from "./chunk-ZLUGQE5D.js";
12
- import {
13
- asProvider
14
- } from "./chunk-SABTXESR.js";
15
- import {
16
- __name
17
- } from "./chunk-SHUYVCID.js";
18
-
19
- // src/promo/expirer.ts
20
- import { Inject, Injectable, Logger } from "@nestjs/common";
21
- import { Cron, CronExpression } from "@nestjs/schedule";
22
- function _ts_decorate(decorators, target, key, desc) {
23
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
24
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
25
- 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;
26
- return c > 3 && r && Object.defineProperty(target, key, r), r;
27
- }
28
- __name(_ts_decorate, "_ts_decorate");
29
- function _ts_metadata(k, v) {
30
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
31
- }
32
- __name(_ts_metadata, "_ts_metadata");
33
- function _ts_param(paramIndex, decorator) {
34
- return function(target, key) {
35
- decorator(target, key, paramIndex);
36
- };
37
- }
38
- __name(_ts_param, "_ts_param");
39
- var PromoCodeExpirer = class _PromoCodeExpirer {
40
- static {
41
- __name(this, "PromoCodeExpirer");
42
- }
43
- promoRepo;
44
- redemptionRepo;
45
- logger = new Logger(_PromoCodeExpirer.name);
46
- constructor(promoRepo, redemptionRepo) {
47
- this.promoRepo = promoRepo;
48
- this.redemptionRepo = redemptionRepo;
49
- }
50
- async expirePromoCodes() {
51
- const now = /* @__PURE__ */ new Date();
52
- const codes = await this.promoRepo.expireDueCodes(now);
53
- const redemptions = await this.redemptionRepo.expireDueRedemptions(now);
54
- if (codes > 0 || redemptions > 0) {
55
- this.logger.log(`PromoCodeExpirer: ${codes} Codes, ${redemptions} Redemptions abgelaufen.`);
56
- }
57
- }
58
- };
59
- _ts_decorate([
60
- Cron(CronExpression.EVERY_DAY_AT_3AM, {
61
- name: "promoCodeExpirer",
62
- timeZone: "Europe/Berlin"
63
- }),
64
- _ts_metadata("design:type", Function),
65
- _ts_metadata("design:paramtypes", []),
66
- _ts_metadata("design:returntype", Promise)
67
- ], PromoCodeExpirer.prototype, "expirePromoCodes", null);
68
- PromoCodeExpirer = _ts_decorate([
69
- Injectable(),
70
- _ts_param(0, Inject(PROMO_CODE_REPOSITORY_TOKEN)),
71
- _ts_param(1, Inject(PROMO_CODE_REDEMPTION_REPOSITORY_TOKEN)),
72
- _ts_metadata("design:type", Function),
73
- _ts_metadata("design:paramtypes", [
74
- typeof PromoCodeRepository === "undefined" ? Object : PromoCodeRepository,
75
- typeof PromoCodeRedemptionRepository === "undefined" ? Object : PromoCodeRedemptionRepository
76
- ])
77
- ], PromoCodeExpirer);
78
-
79
- // src/promo/rate-limit.guard.ts
80
- import { HttpException, HttpStatus, Injectable as Injectable2 } from "@nestjs/common";
81
- function _ts_decorate2(decorators, target, key, desc) {
82
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
83
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
84
- 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;
85
- return c > 3 && r && Object.defineProperty(target, key, r), r;
86
- }
87
- __name(_ts_decorate2, "_ts_decorate");
88
- var IP_WINDOW_MS = 6e4;
89
- var IP_LIMIT = 20;
90
- var SESSION_WINDOW_MS = 60 * 6e4;
91
- var SESSION_LIMIT = 50;
92
- var PromoCodeRateLimitGuard = class {
93
- static {
94
- __name(this, "PromoCodeRateLimitGuard");
95
- }
96
- ipBuckets = /* @__PURE__ */ new Map();
97
- sessionBuckets = /* @__PURE__ */ new Map();
98
- canActivate(context) {
99
- const req = context.switchToHttp().getRequest();
100
- const ipKey = ipFingerprint(req);
101
- const sessionKey = req.user?.id ?? null;
102
- if (this.exceeded(this.ipBuckets, ipKey, IP_WINDOW_MS, IP_LIMIT)) {
103
- throw new HttpException({
104
- valid: false,
105
- reason: "RATE_LIMITED"
106
- }, HttpStatus.TOO_MANY_REQUESTS);
107
- }
108
- if (sessionKey && this.exceeded(this.sessionBuckets, sessionKey, SESSION_WINDOW_MS, SESSION_LIMIT)) {
109
- throw new HttpException({
110
- valid: false,
111
- reason: "RATE_LIMITED"
112
- }, HttpStatus.TOO_MANY_REQUESTS);
113
- }
114
- return true;
115
- }
116
- exceeded(map, key, windowMs, limit) {
117
- const now = Date.now();
118
- const b = map.get(key);
119
- if (!b || now - b.windowStart > windowMs) {
120
- map.set(key, {
121
- count: 1,
122
- windowStart: now
123
- });
124
- return false;
125
- }
126
- b.count += 1;
127
- return b.count > limit;
128
- }
129
- };
130
- PromoCodeRateLimitGuard = _ts_decorate2([
131
- Injectable2()
132
- ], PromoCodeRateLimitGuard);
133
- function ipFingerprint(req) {
134
- const fwd = req.headers["x-forwarded-for"];
135
- const first = Array.isArray(fwd) ? fwd[0] : fwd?.split(",")[0]?.trim();
136
- return first || req.ip || "unknown";
137
- }
138
- __name(ipFingerprint, "ipFingerprint");
139
- function hashIp(req) {
140
- const fp = ipFingerprint(req);
141
- let h = 0;
142
- for (let i = 0; i < fp.length; i++) {
143
- h = h * 31 + fp.charCodeAt(i) | 0;
144
- }
145
- return `ip${(h >>> 0).toString(16)}`;
146
- }
147
- __name(hashIp, "hashIp");
148
-
149
- // src/promo/controller.ts
150
- import { Body, Controller, HttpCode, HttpStatus as HttpStatus2, Inject as Inject2, Post, Req, UseGuards } from "@nestjs/common";
151
-
152
- // src/promo/dto/promo-public.dto.ts
153
- import { IsEmail, IsOptional, IsString, Matches, MaxLength } from "class-validator";
154
- function _ts_decorate3(decorators, target, key, desc) {
155
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
156
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
157
- 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;
158
- return c > 3 && r && Object.defineProperty(target, key, r), r;
159
- }
160
- __name(_ts_decorate3, "_ts_decorate");
161
- function _ts_metadata2(k, v) {
162
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
163
- }
164
- __name(_ts_metadata2, "_ts_metadata");
165
- var PLAN_OR_CYCLE_PATTERN = /^[A-Z][A-Z0-9_]*$/;
166
- var CODE_PATTERN = /^[A-Z0-9_-]{4,32}$/i;
167
- var PreviewPromoCodeDto = class {
168
- static {
169
- __name(this, "PreviewPromoCodeDto");
170
- }
171
- code;
172
- plan;
173
- billingCycle;
174
- email;
175
- };
176
- _ts_decorate3([
177
- IsString(),
178
- Matches(CODE_PATTERN, {
179
- message: 'code muss aus A\u2013Z, 0\u20139, "-" und "_" bestehen (4\u201332 Zeichen)'
180
- }),
181
- _ts_metadata2("design:type", String)
182
- ], PreviewPromoCodeDto.prototype, "code", void 0);
183
- _ts_decorate3([
184
- IsString(),
185
- Matches(PLAN_OR_CYCLE_PATTERN, {
186
- message: "plan muss SCREAMING_SNAKE_CASE sein"
187
- }),
188
- _ts_metadata2("design:type", String)
189
- ], PreviewPromoCodeDto.prototype, "plan", void 0);
190
- _ts_decorate3([
191
- IsString(),
192
- Matches(PLAN_OR_CYCLE_PATTERN, {
193
- message: "billingCycle muss SCREAMING_SNAKE_CASE sein (z. B. MONTHLY, YEARLY)"
194
- }),
195
- _ts_metadata2("design:type", String)
196
- ], PreviewPromoCodeDto.prototype, "billingCycle", void 0);
197
- _ts_decorate3([
198
- IsOptional(),
199
- IsEmail(),
200
- MaxLength(254),
201
- _ts_metadata2("design:type", String)
202
- ], PreviewPromoCodeDto.prototype, "email", void 0);
203
-
204
- // src/promo/controller.ts
205
- function _ts_decorate4(decorators, target, key, desc) {
206
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
207
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
208
- 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;
209
- return c > 3 && r && Object.defineProperty(target, key, r), r;
210
- }
211
- __name(_ts_decorate4, "_ts_decorate");
212
- function _ts_metadata3(k, v) {
213
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
214
- }
215
- __name(_ts_metadata3, "_ts_metadata");
216
- function _ts_param2(paramIndex, decorator) {
217
- return function(target, key) {
218
- decorator(target, key, paramIndex);
219
- };
220
- }
221
- __name(_ts_param2, "_ts_param");
222
- var PromoCodePublicController = class {
223
- static {
224
- __name(this, "PromoCodePublicController");
225
- }
226
- promo;
227
- constructor(promo) {
228
- this.promo = promo;
229
- }
230
- async preview(dto, req) {
231
- return this.promo.preview({
232
- code: dto.code,
233
- planId: dto.plan,
234
- billingCycle: dto.billingCycle,
235
- email: dto.email,
236
- ipHash: hashIp(req),
237
- sessionId: req.user?.id ?? req.user?.sub
238
- });
239
- }
240
- };
241
- _ts_decorate4([
242
- Post("preview"),
243
- HttpCode(HttpStatus2.OK),
244
- UseGuards(PromoCodeRateLimitGuard),
245
- _ts_param2(0, Body()),
246
- _ts_param2(1, Req()),
247
- _ts_metadata3("design:type", Function),
248
- _ts_metadata3("design:paramtypes", [
249
- typeof PreviewPromoCodeDto === "undefined" ? Object : PreviewPromoCodeDto,
250
- typeof RequestLike === "undefined" ? Object : RequestLike
251
- ]),
252
- _ts_metadata3("design:returntype", Promise)
253
- ], PromoCodePublicController.prototype, "preview", null);
254
- PromoCodePublicController = _ts_decorate4([
255
- Controller("billing/promo"),
256
- _ts_param2(0, Inject2(PromoCodesService)),
257
- _ts_metadata3("design:type", Function),
258
- _ts_metadata3("design:paramtypes", [
259
- typeof PromoCodesService === "undefined" ? Object : PromoCodesService
260
- ])
261
- ], PromoCodePublicController);
262
-
263
- // src/promo/module.ts
264
- import { Module } from "@nestjs/common";
265
- function _ts_decorate5(decorators, target, key, desc) {
266
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
267
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
268
- 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;
269
- return c > 3 && r && Object.defineProperty(target, key, r), r;
270
- }
271
- __name(_ts_decorate5, "_ts_decorate");
272
- var PromoCodesModule = class _PromoCodesModule {
273
- static {
274
- __name(this, "PromoCodesModule");
275
- }
276
- static forRoot(options) {
277
- const includeCron = options.includeExpirerCron ?? true;
278
- const includePublic = options.includePublicController ?? true;
279
- const providers = [
280
- asProvider(PROMO_CODE_REPOSITORY_TOKEN, options.promoCodeRepository),
281
- asProvider(PROMO_CODE_REDEMPTION_REPOSITORY_TOKEN, options.redemptionRepository),
282
- asProvider(PROMO_CODE_VALIDATION_LOG_REPOSITORY_TOKEN, options.validationLogRepository),
283
- asProvider(PROMO_FIRST_TIME_CUSTOMER_CHECK_TOKEN, options.firstTimeCustomerCheck),
284
- asProvider(PROMO_SUBSCRIPTION_LOOKUP_TOKEN, options.subscriptionLookup),
285
- asProvider(PROMO_REVENUE_DEDUCTION_AGGREGATOR_TOKEN, options.revenueAggregator),
286
- asProvider(PROMO_TRANSACTION_RUNNER_TOKEN, options.transactionRunner),
287
- {
288
- provide: PROMO_SERVICE_CONFIG_TOKEN,
289
- useValue: options.config ?? {}
290
- },
291
- PromoCodesService,
292
- PromoCodeRateLimitGuard
293
- ];
294
- if (includeCron) {
295
- providers.push(PromoCodeExpirer);
296
- }
297
- return {
298
- module: _PromoCodesModule,
299
- global: options.global ?? false,
300
- controllers: includePublic ? [
301
- PromoCodePublicController
302
- ] : [],
303
- providers,
304
- exports: [
305
- PromoCodesService,
306
- PromoCodeRateLimitGuard,
307
- PROMO_CODE_REPOSITORY_TOKEN,
308
- PROMO_CODE_REDEMPTION_REPOSITORY_TOKEN,
309
- PROMO_CODE_VALIDATION_LOG_REPOSITORY_TOKEN
310
- ]
311
- };
312
- }
313
- };
314
- PromoCodesModule = _ts_decorate5([
315
- Module({})
316
- ], PromoCodesModule);
317
-
318
- export {
319
- PromoCodeExpirer,
320
- PromoCodeRateLimitGuard,
321
- ipFingerprint,
322
- hashIp,
323
- PreviewPromoCodeDto,
324
- PromoCodePublicController,
325
- PromoCodesModule
326
- };
@@ -1,13 +0,0 @@
1
- import {
2
- __name
3
- } from "./chunk-SHUYVCID.js";
4
-
5
- // src/billing/require-feature.decorator.ts
6
- import { SetMetadata } from "@nestjs/common";
7
- var REQUIRE_FEATURE_KEY = "require-feature";
8
- var RequireFeature = /* @__PURE__ */ __name((...features) => SetMetadata(REQUIRE_FEATURE_KEY, features), "RequireFeature");
9
-
10
- export {
11
- REQUIRE_FEATURE_KEY,
12
- RequireFeature
13
- };
File without changes