@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,190 @@
1
+ import {
2
+ SuperAdminGuard
3
+ } from "./chunk-P6MYZMXQ.js";
4
+ import {
5
+ asProvider
6
+ } from "./chunk-SABTXESR.js";
7
+ import {
8
+ __name
9
+ } from "./chunk-SHUYVCID.js";
10
+
11
+ // src/admin/admin-stats.tokens.ts
12
+ var SUBSCRIPTION_STATS_PORT_TOKEN = /* @__PURE__ */ Symbol.for("saas-platform/SubscriptionStatsPort");
13
+ var PROMO_CODE_STATS_PORT_TOKEN = /* @__PURE__ */ Symbol.for("saas-platform/PromoCodeStatsPort");
14
+ var AUDIT_STATS_PORT_TOKEN = /* @__PURE__ */ Symbol.for("saas-platform/AuditStatsPort");
15
+ var ADMIN_STATS_AUDIT_WINDOW_DAYS_TOKEN = /* @__PURE__ */ Symbol.for("saas-platform/AdminStatsAuditWindowDays");
16
+
17
+ // src/admin/admin-stats.service.ts
18
+ import { Inject, Injectable, Optional } from "@nestjs/common";
19
+ function _ts_decorate(decorators, target, key, desc) {
20
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
21
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
22
+ 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;
23
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
24
+ }
25
+ __name(_ts_decorate, "_ts_decorate");
26
+ function _ts_metadata(k, v) {
27
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
28
+ }
29
+ __name(_ts_metadata, "_ts_metadata");
30
+ function _ts_param(paramIndex, decorator) {
31
+ return function(target, key) {
32
+ decorator(target, key, paramIndex);
33
+ };
34
+ }
35
+ __name(_ts_param, "_ts_param");
36
+ var DAY_MS = 864e5;
37
+ var DEFAULT_AUDIT_WINDOW_DAYS = 7;
38
+ var AdminStatsService = class {
39
+ static {
40
+ __name(this, "AdminStatsService");
41
+ }
42
+ subscriptions;
43
+ promos;
44
+ audit;
45
+ auditWindowDays;
46
+ constructor(subscriptions, promos, audit, auditWindowDays = DEFAULT_AUDIT_WINDOW_DAYS) {
47
+ this.subscriptions = subscriptions;
48
+ this.promos = promos;
49
+ this.audit = audit;
50
+ this.auditWindowDays = auditWindowDays;
51
+ }
52
+ async getSnapshot() {
53
+ const since = new Date(Date.now() - this.auditWindowDays * DAY_MS);
54
+ const [subscriptions, promos, auditCount] = await Promise.all([
55
+ this.subscriptions.getStats(),
56
+ this.promos.getStats(),
57
+ this.audit.countSince(since)
58
+ ]);
59
+ return {
60
+ subscriptions,
61
+ promos,
62
+ audit: {
63
+ countLastNDays: auditCount,
64
+ nDays: this.auditWindowDays
65
+ }
66
+ };
67
+ }
68
+ };
69
+ AdminStatsService = _ts_decorate([
70
+ Injectable(),
71
+ _ts_param(0, Inject(SUBSCRIPTION_STATS_PORT_TOKEN)),
72
+ _ts_param(1, Inject(PROMO_CODE_STATS_PORT_TOKEN)),
73
+ _ts_param(2, Inject(AUDIT_STATS_PORT_TOKEN)),
74
+ _ts_param(3, Optional()),
75
+ _ts_param(3, Inject(ADMIN_STATS_AUDIT_WINDOW_DAYS_TOKEN)),
76
+ _ts_metadata("design:type", Function),
77
+ _ts_metadata("design:paramtypes", [
78
+ typeof SubscriptionStatsPort === "undefined" ? Object : SubscriptionStatsPort,
79
+ typeof PromoCodeStatsPort === "undefined" ? Object : PromoCodeStatsPort,
80
+ typeof AuditStatsPort === "undefined" ? Object : AuditStatsPort,
81
+ Number
82
+ ])
83
+ ], AdminStatsService);
84
+
85
+ // src/admin/admin-stats.controller.ts
86
+ import { Controller, Get, Inject as Inject2, UseGuards } from "@nestjs/common";
87
+ function _ts_decorate2(decorators, target, key, desc) {
88
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
89
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
90
+ 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;
91
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
92
+ }
93
+ __name(_ts_decorate2, "_ts_decorate");
94
+ function _ts_metadata2(k, v) {
95
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
96
+ }
97
+ __name(_ts_metadata2, "_ts_metadata");
98
+ function _ts_param2(paramIndex, decorator) {
99
+ return function(target, key) {
100
+ decorator(target, key, paramIndex);
101
+ };
102
+ }
103
+ __name(_ts_param2, "_ts_param");
104
+ var AdminStatsController = class {
105
+ static {
106
+ __name(this, "AdminStatsController");
107
+ }
108
+ stats;
109
+ // Explicit @Inject instead of type reflection: tsup/esbuild do not emit
110
+ // `design:paramtypes` metadata, so Nest could otherwise not resolve the
111
+ // service type at the constructor.
112
+ constructor(stats) {
113
+ this.stats = stats;
114
+ }
115
+ async getDashboardSnapshot() {
116
+ return this.stats.getSnapshot();
117
+ }
118
+ };
119
+ _ts_decorate2([
120
+ Get("dashboard"),
121
+ _ts_metadata2("design:type", Function),
122
+ _ts_metadata2("design:paramtypes", []),
123
+ _ts_metadata2("design:returntype", Promise)
124
+ ], AdminStatsController.prototype, "getDashboardSnapshot", null);
125
+ AdminStatsController = _ts_decorate2([
126
+ Controller("admin/stats"),
127
+ UseGuards(SuperAdminGuard),
128
+ _ts_param2(0, Inject2(AdminStatsService)),
129
+ _ts_metadata2("design:type", Function),
130
+ _ts_metadata2("design:paramtypes", [
131
+ typeof AdminStatsService === "undefined" ? Object : AdminStatsService
132
+ ])
133
+ ], AdminStatsController);
134
+
135
+ // src/admin/admin-stats.module.ts
136
+ import { Module } from "@nestjs/common";
137
+ function _ts_decorate3(decorators, target, key, desc) {
138
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
139
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
140
+ 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;
141
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
142
+ }
143
+ __name(_ts_decorate3, "_ts_decorate");
144
+ var AdminStatsModule = class _AdminStatsModule {
145
+ static {
146
+ __name(this, "AdminStatsModule");
147
+ }
148
+ static forRoot(options) {
149
+ const providers = [
150
+ asProvider(SUBSCRIPTION_STATS_PORT_TOKEN, options.subscriptionStatsPort),
151
+ asProvider(PROMO_CODE_STATS_PORT_TOKEN, options.promoCodeStatsPort),
152
+ asProvider(AUDIT_STATS_PORT_TOKEN, options.auditStatsPort),
153
+ AdminStatsService,
154
+ SuperAdminGuard
155
+ ];
156
+ if (options.auditWindowDays !== void 0) {
157
+ providers.push({
158
+ provide: ADMIN_STATS_AUDIT_WINDOW_DAYS_TOKEN,
159
+ useValue: options.auditWindowDays
160
+ });
161
+ }
162
+ if (options.extraProviders) providers.push(...options.extraProviders);
163
+ return {
164
+ module: _AdminStatsModule,
165
+ global: options.global ?? false,
166
+ imports: options.imports ?? [],
167
+ controllers: [
168
+ AdminStatsController
169
+ ],
170
+ providers,
171
+ exports: [
172
+ AdminStatsService,
173
+ SuperAdminGuard
174
+ ]
175
+ };
176
+ }
177
+ };
178
+ AdminStatsModule = _ts_decorate3([
179
+ Module({})
180
+ ], AdminStatsModule);
181
+
182
+ export {
183
+ SUBSCRIPTION_STATS_PORT_TOKEN,
184
+ PROMO_CODE_STATS_PORT_TOKEN,
185
+ AUDIT_STATS_PORT_TOKEN,
186
+ ADMIN_STATS_AUDIT_WINDOW_DAYS_TOKEN,
187
+ AdminStatsService,
188
+ AdminStatsController,
189
+ AdminStatsModule
190
+ };