@saasicat/nest 1.0.0-rc.21 → 1.0.0-rc.23

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 (101) hide show
  1. package/dist/.build-stamp +1 -1
  2. package/dist/_entries.cjs +15561 -12478
  3. package/dist/admin/index.d.cts +4 -4
  4. package/dist/admin/index.d.ts +4 -4
  5. package/dist/admin/index.js +8 -5
  6. package/dist/{admin-resources.module-CWqdI9BV.d.ts → admin-resources.module-DtWAFI-G.d.ts} +1 -1
  7. package/dist/{admin-resources.module-B4XNvdH-.d.cts → admin-resources.module-pS7LbdbI.d.cts} +1 -1
  8. package/dist/{admin-stats.service-CsLNt19Z.d.ts → admin-stats.service--1sRNpUx.d.ts} +2 -2
  9. package/dist/{admin-stats.service-DrZrU8IJ.d.cts → admin-stats.service-ChATI9YK.d.cts} +2 -2
  10. package/dist/{aggregation-ChpZDh0g.d.ts → aggregation-B8iZBesJ.d.ts} +63 -4
  11. package/dist/{aggregation-OpnhwzF5.d.cts → aggregation-BRzgRXDb.d.cts} +63 -4
  12. package/dist/billing/index.d.cts +280 -13
  13. package/dist/billing/index.d.ts +280 -13
  14. package/dist/billing/index.js +32 -8
  15. package/dist/catalog/index.d.cts +2 -2
  16. package/dist/catalog/index.d.ts +2 -2
  17. package/dist/catalog/index.js +4 -2
  18. package/dist/{catalog.module-T-I5Ricz.d.cts → catalog.module-CeKslGHW.d.cts} +1 -1
  19. package/dist/{catalog.module-C9O7BxRq.d.ts → catalog.module-CiurcIjI.d.ts} +1 -1
  20. package/dist/checkout-offer/index.d.cts +4 -4
  21. package/dist/checkout-offer/index.d.ts +4 -4
  22. package/dist/checkout-offer/index.js +5 -5
  23. package/dist/{checkout-offer.module-x7SP_dX4.d.ts → checkout-offer.module-C761mcEv.d.ts} +1 -1
  24. package/dist/{checkout-offer.module-DFhGy6JO.d.cts → checkout-offer.module-CSHB4bB8.d.cts} +1 -1
  25. package/dist/{checkout-offer.service-BeHgYikI.d.ts → checkout-offer.service-Dux8EgEM.d.ts} +3 -3
  26. package/dist/{checkout-offer.service-CCVxG9b2.d.cts → checkout-offer.service-HKoTZ3JH.d.cts} +3 -3
  27. package/dist/{chunk-F5X66HF5.js → chunk-2ECX7BST.js} +1 -1
  28. package/dist/{chunk-G6EZWECL.js → chunk-2XBWYMOL.js} +141 -26
  29. package/dist/{chunk-R5YCJBHY.js → chunk-3HBP2HK3.js} +6 -2
  30. package/dist/{chunk-S33SO5XX.js → chunk-4OFJLVVH.js} +4 -0
  31. package/dist/{chunk-AOS2JPDD.js → chunk-5LL2554P.js} +757 -163
  32. package/dist/chunk-5MZH3VVU.js +292 -0
  33. package/dist/{chunk-WHJSYKNC.js → chunk-7LHUENAT.js} +2 -2
  34. package/dist/{chunk-M47BNEY2.js → chunk-7MLB6T5B.js} +2072 -407
  35. package/dist/{chunk-NDLC5GYK.js → chunk-CVCKXKGT.js} +138 -21
  36. package/dist/{chunk-VBRYPU7V.js → chunk-E224LKO2.js} +3 -1
  37. package/dist/{chunk-QPVDCKYS.js → chunk-ESEWSAOV.js} +4 -3
  38. package/dist/{chunk-CQ2ZZMTD.js → chunk-MU4O4EKX.js} +711 -828
  39. package/dist/{chunk-JBCC6C3M.js → chunk-NQIPQI2Q.js} +26 -7
  40. package/dist/{chunk-4SDSYV4A.js → chunk-PBL7N5J3.js} +18 -2
  41. package/dist/{chunk-LLYVYRGJ.js → chunk-QTJEZDKC.js} +15 -275
  42. package/dist/{chunk-3RLWML2S.js → chunk-QWKBOLBH.js} +35 -0
  43. package/dist/{chunk-XSSWYPP5.js → chunk-TR3L6FRF.js} +6 -2
  44. package/dist/chunk-TSLGMPGZ.js +21 -0
  45. package/dist/chunk-UJZCESIC.js +466 -0
  46. package/dist/{chunk-TOEFN7DN.js → chunk-W6VNCMOQ.js} +3 -3
  47. package/dist/{chunk-7NJKVC5X.js → chunk-WQNOCOI2.js} +53 -6
  48. package/dist/chunk-YZSILFW4.js +142 -0
  49. package/dist/{chunk-55QEDAMX.js → chunk-ZCXW24NH.js} +4 -9
  50. package/dist/discovery/index.js +2 -1
  51. package/dist/{enforce-quota.interceptor-BFyVdWe8.d.cts → enforce-quota.interceptor-Dc-1_zQf.d.cts} +2 -2
  52. package/dist/{enforce-quota.interceptor-GaBXboGx.d.ts → enforce-quota.interceptor-MXpwsOJ2.d.ts} +2 -2
  53. package/dist/entitlement/index.d.cts +1 -1
  54. package/dist/entitlement/index.d.ts +1 -1
  55. package/dist/entitlement/index.js +5 -3
  56. package/dist/index.d.cts +62 -25
  57. package/dist/index.d.ts +62 -25
  58. package/dist/index.js +81 -26
  59. package/dist/{issuer-identity.check-CBO0vcsq.d.cts → issuer-identity.check-BrZXesOF.d.cts} +3 -3
  60. package/dist/{issuer-identity.check-Cz9CEMkZ.d.ts → issuer-identity.check-BzlFSmSZ.d.ts} +3 -3
  61. package/dist/maintenance.service-CNMI3tSm.d.cts +133 -0
  62. package/dist/maintenance.service-yx6fxjUj.d.ts +133 -0
  63. package/dist/{module-options-DmQ3G4sZ.d.ts → module-options-BSYxlA38.d.ts} +50 -9
  64. package/dist/{module-options-qAOwinHR.d.cts → module-options-BkufuqlM.d.cts} +50 -9
  65. package/dist/payments/index.d.cts +2 -2
  66. package/dist/payments/index.d.ts +2 -2
  67. package/dist/payments/index.js +2 -2
  68. package/dist/{payments.module-BdUq9ot_.d.cts → payments.module-CwLeaflk.d.cts} +1 -1
  69. package/dist/{payments.module-CQGv_VG7.d.ts → payments.module-DmIN-HWx.d.ts} +1 -1
  70. package/dist/{plan-versions.service-DARLh-qI.d.cts → plan-versions.service-2mD0iEvY.d.cts} +1 -1
  71. package/dist/{plan-versions.service-C0N-Em2W.d.ts → plan-versions.service-C4a9aCEU.d.ts} +1 -1
  72. package/dist/platform/index.d.cts +34 -25
  73. package/dist/platform/index.d.ts +34 -25
  74. package/dist/platform/index.js +22 -17
  75. package/dist/promo/index.d.cts +15 -5
  76. package/dist/promo/index.d.ts +15 -5
  77. package/dist/promo/index.js +9 -3
  78. package/dist/{promo.module-CKkECmU8.d.cts → promo.module-Ddx-swUV.d.cts} +1 -1
  79. package/dist/{promo.module-DuIJdK3U.d.ts → promo.module-PsIvDcUp.d.ts} +1 -1
  80. package/dist/{promo.service-BYBu6dy3.d.cts → promo.service-BextPvx5.d.cts} +23 -1
  81. package/dist/{promo.service-CFjfF0Xm.d.ts → promo.service-Dqqh0JXn.d.ts} +23 -1
  82. package/dist/registration/index.d.cts +7 -4
  83. package/dist/registration/index.d.ts +7 -4
  84. package/dist/registration/index.js +11 -6
  85. package/dist/subscription-contract/index.d.cts +13 -3
  86. package/dist/subscription-contract/index.d.ts +13 -3
  87. package/dist/subscription-contract/index.js +5 -3
  88. package/dist/{subscription-contract.module-BfIRpc1o.d.ts → subscription-contract.module-B5wrmzkz.d.ts} +8 -1
  89. package/dist/{subscription-contract.module-DTMuUJYd.d.cts → subscription-contract.module-qaswPXwT.d.cts} +8 -1
  90. package/dist/{subscription-contract.service-CfNApLuP.d.cts → subscription-contract.service-CH2TKw-j.d.cts} +45 -3
  91. package/dist/{subscription-contract.service-CPZrTM9C.d.ts → subscription-contract.service-Dm2xEFZi.d.ts} +45 -3
  92. package/dist/{tenant-billing.controller-BLqbsONe.d.ts → tenant-billing.controller-BMH9YODT.d.ts} +92 -11
  93. package/dist/{tenant-billing.controller-DKbAqTbM.d.cts → tenant-billing.controller-BX3VExL3.d.cts} +92 -11
  94. package/dist/{tenant-billing.module-ClbjzocC.d.cts → tenant-billing.module-Do3QyKbr.d.cts} +33 -3
  95. package/dist/{tenant-billing.module-DohgJJ2m.d.ts → tenant-billing.module-W5_Y4ogN.d.ts} +33 -3
  96. package/dist/{tenant-billing.tokens-G-1xOlMr.d.cts → tenant-billing.tokens-D0vr1lfj.d.cts} +1 -1
  97. package/dist/{tenant-billing.tokens-G-1xOlMr.d.ts → tenant-billing.tokens-D0vr1lfj.d.ts} +1 -1
  98. package/dist/testing/index.d.cts +14 -13
  99. package/dist/testing/index.d.ts +14 -13
  100. package/dist/testing/index.js +54 -35
  101. package/package.json +5 -3
@@ -0,0 +1,292 @@
1
+ import {
2
+ EnforceMfa
3
+ } from "./chunk-34XVPR6P.js";
4
+ import {
5
+ AdminAuditService
6
+ } from "./chunk-OOTEXP47.js";
7
+ import {
8
+ AllowDuringMaintenance
9
+ } from "./chunk-TSLGMPGZ.js";
10
+ import {
11
+ asProvider
12
+ } from "./chunk-J7NJRK3K.js";
13
+ import {
14
+ __name
15
+ } from "./chunk-SHUYVCID.js";
16
+
17
+ // src/admin/admin-resources.module.ts
18
+ import { Body, Controller, Get, Inject, Injectable, Module, NotFoundException, Param, Post, Query, Req, UseGuards } from "@nestjs/common";
19
+ import { IsOptional, IsString, MaxLength } from "class-validator";
20
+ import { BILLING_ERROR_CODES } from "@saasicat/core";
21
+ function _ts_decorate(decorators, target, key, desc) {
22
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
23
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
24
+ 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;
25
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
26
+ }
27
+ __name(_ts_decorate, "_ts_decorate");
28
+ function _ts_metadata(k, v) {
29
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
30
+ }
31
+ __name(_ts_metadata, "_ts_metadata");
32
+ function _ts_param(paramIndex, decorator) {
33
+ return function(target, key) {
34
+ decorator(target, key, paramIndex);
35
+ };
36
+ }
37
+ __name(_ts_param, "_ts_param");
38
+ var ADMIN_RESOURCES_PORT_TOKEN = /* @__PURE__ */ Symbol.for("saasicat/nest/AdminResourcesPort");
39
+ var SuspendTenantDto = class {
40
+ static {
41
+ __name(this, "SuspendTenantDto");
42
+ }
43
+ reason;
44
+ };
45
+ _ts_decorate([
46
+ IsOptional(),
47
+ IsString(),
48
+ MaxLength(500),
49
+ _ts_metadata("design:type", String)
50
+ ], SuspendTenantDto.prototype, "reason", void 0);
51
+ var AdminResourcesService = class {
52
+ static {
53
+ __name(this, "AdminResourcesService");
54
+ }
55
+ resources;
56
+ audit;
57
+ constructor(resources, audit) {
58
+ this.resources = resources;
59
+ this.audit = audit;
60
+ }
61
+ listTenants(filter) {
62
+ return this.resources.listTenants(filter);
63
+ }
64
+ async getTenantDetail(slug) {
65
+ const tenant = await this.resources.getTenantDetail(slug);
66
+ if (!tenant) {
67
+ throw new NotFoundException({
68
+ code: BILLING_ERROR_CODES.TENANT_NOT_FOUND,
69
+ message: `Tenant ${slug} not found`,
70
+ params: {
71
+ slug
72
+ }
73
+ });
74
+ }
75
+ return tenant;
76
+ }
77
+ listUsers(filter) {
78
+ return this.resources.listUsers(filter);
79
+ }
80
+ listAudit(filter) {
81
+ return this.resources.listAudit(filter);
82
+ }
83
+ listSubscriptions() {
84
+ return this.resources.listSubscriptions();
85
+ }
86
+ suspendTenant(slug, reason, actor) {
87
+ return this.setTenantActive(slug, false, "PAST_DUE", actor, {
88
+ action: "TENANT_SUSPEND",
89
+ reason: reason ?? ""
90
+ });
91
+ }
92
+ reactivateTenant(slug, actor) {
93
+ return this.setTenantActive(slug, true, "ACTIVE", actor, {
94
+ action: "TENANT_REACTIVATE",
95
+ reason: ""
96
+ });
97
+ }
98
+ async setTenantActive(slug, active, subscriptionStatus, actor, audit) {
99
+ const result = await this.resources.setTenantActive(slug, active, subscriptionStatus);
100
+ if (!result) {
101
+ throw new NotFoundException({
102
+ code: BILLING_ERROR_CODES.TENANT_NOT_FOUND,
103
+ message: `Tenant ${slug} not found`,
104
+ params: {
105
+ slug
106
+ }
107
+ });
108
+ }
109
+ await this.audit.log({
110
+ actor,
111
+ entity: "Tenant",
112
+ entityId: result.id,
113
+ action: audit.action,
114
+ changes: {
115
+ slug,
116
+ reason: audit.reason
117
+ }
118
+ });
119
+ return result;
120
+ }
121
+ };
122
+ AdminResourcesService = _ts_decorate([
123
+ Injectable(),
124
+ _ts_param(0, Inject(ADMIN_RESOURCES_PORT_TOKEN)),
125
+ _ts_param(1, Inject(AdminAuditService)),
126
+ _ts_metadata("design:type", Function),
127
+ _ts_metadata("design:paramtypes", [
128
+ typeof AdminResourcesPort === "undefined" ? Object : AdminResourcesPort,
129
+ typeof AdminAuditService === "undefined" ? Object : AdminAuditService
130
+ ])
131
+ ], AdminResourcesService);
132
+ function actorFromRequest(request) {
133
+ const userId = request.user?.id ?? request.user?.userId ?? "unknown";
134
+ return {
135
+ userId,
136
+ email: request.user?.email ?? `${userId}@unknown`,
137
+ source: "web",
138
+ context: request.user?.sessionId ?? "unknown"
139
+ };
140
+ }
141
+ __name(actorFromRequest, "actorFromRequest");
142
+ function buildAdminResourcesController(guards) {
143
+ let GeneratedAdminResourcesController = class GeneratedAdminResourcesController {
144
+ static {
145
+ __name(this, "GeneratedAdminResourcesController");
146
+ }
147
+ resources;
148
+ constructor(resources) {
149
+ this.resources = resources;
150
+ }
151
+ listTenants(query) {
152
+ return this.resources.listTenants(query);
153
+ }
154
+ getTenant(slug) {
155
+ return this.resources.getTenantDetail(slug);
156
+ }
157
+ suspendTenant(request, slug, dto) {
158
+ return this.resources.suspendTenant(slug, dto.reason, actorFromRequest(request));
159
+ }
160
+ reactivateTenant(request, slug) {
161
+ return this.resources.reactivateTenant(slug, actorFromRequest(request));
162
+ }
163
+ listUsers(query) {
164
+ return this.resources.listUsers(query);
165
+ }
166
+ listAudit(query) {
167
+ return this.resources.listAudit({
168
+ actor: query.actor,
169
+ action: query.action,
170
+ entity: query.entity,
171
+ since: query.since,
172
+ limit: query.limit ? Number.parseInt(query.limit, 10) : void 0
173
+ });
174
+ }
175
+ listSubscriptions() {
176
+ return this.resources.listSubscriptions();
177
+ }
178
+ };
179
+ _ts_decorate([
180
+ Get("tenants"),
181
+ _ts_param(0, Query()),
182
+ _ts_metadata("design:type", Function),
183
+ _ts_metadata("design:paramtypes", [
184
+ Object
185
+ ]),
186
+ _ts_metadata("design:returntype", typeof Promise === "undefined" ? Object : Promise)
187
+ ], GeneratedAdminResourcesController.prototype, "listTenants", null);
188
+ _ts_decorate([
189
+ Get("tenants/:slug"),
190
+ _ts_param(0, Param("slug")),
191
+ _ts_metadata("design:type", Function),
192
+ _ts_metadata("design:paramtypes", [
193
+ String
194
+ ]),
195
+ _ts_metadata("design:returntype", typeof Promise === "undefined" ? Object : Promise)
196
+ ], GeneratedAdminResourcesController.prototype, "getTenant", null);
197
+ _ts_decorate([
198
+ Post("tenants/:slug/suspend"),
199
+ EnforceMfa(),
200
+ _ts_param(0, Req()),
201
+ _ts_param(1, Param("slug")),
202
+ _ts_param(2, Body()),
203
+ _ts_metadata("design:type", Function),
204
+ _ts_metadata("design:paramtypes", [
205
+ typeof AdminRequest === "undefined" ? Object : AdminRequest,
206
+ String,
207
+ typeof SuspendTenantDto === "undefined" ? Object : SuspendTenantDto
208
+ ]),
209
+ _ts_metadata("design:returntype", typeof Promise === "undefined" ? Object : Promise)
210
+ ], GeneratedAdminResourcesController.prototype, "suspendTenant", null);
211
+ _ts_decorate([
212
+ Post("tenants/:slug/reactivate"),
213
+ EnforceMfa(),
214
+ _ts_param(0, Req()),
215
+ _ts_param(1, Param("slug")),
216
+ _ts_metadata("design:type", Function),
217
+ _ts_metadata("design:paramtypes", [
218
+ typeof AdminRequest === "undefined" ? Object : AdminRequest,
219
+ String
220
+ ]),
221
+ _ts_metadata("design:returntype", typeof Promise === "undefined" ? Object : Promise)
222
+ ], GeneratedAdminResourcesController.prototype, "reactivateTenant", null);
223
+ _ts_decorate([
224
+ Get("users"),
225
+ _ts_param(0, Query()),
226
+ _ts_metadata("design:type", Function),
227
+ _ts_metadata("design:paramtypes", [
228
+ Object
229
+ ]),
230
+ _ts_metadata("design:returntype", typeof Promise === "undefined" ? Object : Promise)
231
+ ], GeneratedAdminResourcesController.prototype, "listUsers", null);
232
+ _ts_decorate([
233
+ Get("audit"),
234
+ _ts_param(0, Query()),
235
+ _ts_metadata("design:type", Function),
236
+ _ts_metadata("design:paramtypes", [
237
+ Object
238
+ ]),
239
+ _ts_metadata("design:returntype", typeof Promise === "undefined" ? Object : Promise)
240
+ ], GeneratedAdminResourcesController.prototype, "listAudit", null);
241
+ _ts_decorate([
242
+ Get("subscriptions"),
243
+ _ts_metadata("design:type", Function),
244
+ _ts_metadata("design:paramtypes", []),
245
+ _ts_metadata("design:returntype", typeof Promise === "undefined" ? Object : Promise)
246
+ ], GeneratedAdminResourcesController.prototype, "listSubscriptions", null);
247
+ GeneratedAdminResourcesController = _ts_decorate([
248
+ Controller("admin"),
249
+ AllowDuringMaintenance(),
250
+ UseGuards(...guards),
251
+ _ts_param(0, Inject(AdminResourcesService)),
252
+ _ts_metadata("design:type", Function),
253
+ _ts_metadata("design:paramtypes", [
254
+ typeof AdminResourcesService === "undefined" ? Object : AdminResourcesService
255
+ ])
256
+ ], GeneratedAdminResourcesController);
257
+ return GeneratedAdminResourcesController;
258
+ }
259
+ __name(buildAdminResourcesController, "buildAdminResourcesController");
260
+ var AdminResourcesModule = class _AdminResourcesModule {
261
+ static {
262
+ __name(this, "AdminResourcesModule");
263
+ }
264
+ static forRoot(options) {
265
+ return {
266
+ module: _AdminResourcesModule,
267
+ global: options.global ?? false,
268
+ imports: options.imports ?? [],
269
+ controllers: [
270
+ buildAdminResourcesController(options.guards)
271
+ ],
272
+ providers: [
273
+ asProvider(ADMIN_RESOURCES_PORT_TOKEN, options.resources),
274
+ AdminResourcesService
275
+ ],
276
+ exports: [
277
+ ADMIN_RESOURCES_PORT_TOKEN,
278
+ AdminResourcesService
279
+ ]
280
+ };
281
+ }
282
+ };
283
+ AdminResourcesModule = _ts_decorate([
284
+ Module({})
285
+ ], AdminResourcesModule);
286
+
287
+ export {
288
+ ADMIN_RESOURCES_PORT_TOKEN,
289
+ SuspendTenantDto,
290
+ AdminResourcesService,
291
+ AdminResourcesModule
292
+ };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  EntitlementService,
3
3
  SUBSCRIPTION_BUNDLE_REPOSITORY_TOKEN
4
- } from "./chunk-G6EZWECL.js";
4
+ } from "./chunk-2XBWYMOL.js";
5
5
  import {
6
6
  ENTITLEMENT_RESOLUTION_CONFIG_TOKEN,
7
7
  ENTITLEMENT_SERVICE_TOKEN,
@@ -11,7 +11,7 @@ import {
11
11
  } from "./chunk-OUDSQ3PU.js";
12
12
  import {
13
13
  SUBSCRIPTION_CONTRACT_REPOSITORY_TOKEN
14
- } from "./chunk-VBRYPU7V.js";
14
+ } from "./chunk-E224LKO2.js";
15
15
  import {
16
16
  BUNDLE_REPOSITORY_TOKEN
17
17
  } from "./chunk-3QVGA6JX.js";