@saasicat/nest 0.9.0 → 0.10.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 (86) hide show
  1. package/dist/_entries.cjs +17678 -0
  2. package/dist/admin/index.cjs +4 -1533
  3. package/dist/admin/index.d.cts +10 -173
  4. package/dist/admin/index.d.ts +10 -173
  5. package/dist/admin/index.js +3 -2
  6. package/dist/{admin-resources.module-BybEjZs-.d.cts → admin-resources.module-BZN_yBFj.d.cts} +1 -1
  7. package/dist/{admin-resources.module-CUCLlUAi.d.ts → admin-resources.module-Cms8MY6h.d.ts} +1 -1
  8. package/dist/admin-stats.module-15ac5KY3.d.ts +201 -0
  9. package/dist/admin-stats.module-v4SVvWzj.d.cts +201 -0
  10. package/dist/billing/index.cjs +4 -5130
  11. package/dist/billing/index.d.cts +8 -437
  12. package/dist/billing/index.d.ts +8 -437
  13. package/dist/billing/index.js +4 -4
  14. package/dist/catalog/index.cjs +4 -5624
  15. package/dist/catalog/index.d.cts +5 -328
  16. package/dist/catalog/index.d.ts +5 -328
  17. package/dist/catalog/index.js +4 -4
  18. package/dist/checkout-offer/index.cjs +4 -807
  19. package/dist/checkout-offer/index.d.cts +5 -84
  20. package/dist/checkout-offer/index.d.ts +5 -84
  21. package/dist/checkout-offer/index.js +3 -2
  22. package/dist/checkout-offer.module-Y0hDOVrq.d.ts +85 -0
  23. package/dist/checkout-offer.module-ZYF5IsDY.d.cts +85 -0
  24. package/dist/{chunk-PBQRPDO2.js → chunk-33TP26MR.js} +2 -2
  25. package/dist/{chunk-CK54YKVK.js → chunk-75JABGZK.js} +16 -16
  26. package/dist/{chunk-HRU3CP57.js → chunk-BOADBIGB.js} +1 -1
  27. package/dist/chunk-DBZGV3HC.js +0 -0
  28. package/dist/{chunk-ZLUGQE5D.js → chunk-E7AJ42AB.js} +8 -8
  29. package/dist/{chunk-HXAWPPFW.js → chunk-F3VV6EXG.js} +9 -9
  30. package/dist/{chunk-3M6VLT5N.js → chunk-FVT7KTUI.js} +2 -2
  31. package/dist/{chunk-GW2I3JZD.js → chunk-GBDUH6DO.js} +1 -1
  32. package/dist/{chunk-K3OPNVFR.js → chunk-HBFU5AN3.js} +5 -9
  33. package/dist/{chunk-OFBDEO45.js → chunk-IRWZC3GC.js} +1 -1
  34. package/dist/chunk-L4KTQ6CL.js +20 -0
  35. package/dist/{chunk-WGVTXSYW.js → chunk-LZHLGUQI.js} +1 -1
  36. package/dist/{chunk-ZZMAHX22.js → chunk-PUXLPUVH.js} +15 -12
  37. package/dist/{chunk-7K5PT2LX.js → chunk-TXDH4FUA.js} +1 -1
  38. package/dist/chunk-UF53DWWR.js +0 -0
  39. package/dist/{chunk-AJ3EPELS.js → chunk-V34AA7C7.js} +1 -1
  40. package/dist/chunk-WJ6BMDL3.js +313 -0
  41. package/dist/{chunk-M6CZQYPY.js → chunk-Z3FWN3HJ.js} +2 -2
  42. package/dist/discovery/index.cjs +4 -588
  43. package/dist/discovery/index.js +3 -3
  44. package/dist/{enforce-quota.interceptor-SqrQVF91.d.cts → enforce-quota.interceptor-BhkX5nq2.d.cts} +35 -2
  45. package/dist/{enforce-quota.interceptor-B3CL5MSw.d.ts → enforce-quota.interceptor-CcqZc0Yu.d.ts} +35 -2
  46. package/dist/entitlement/index.cjs +4 -781
  47. package/dist/entitlement/index.js +2 -2
  48. package/dist/index.cjs +4 -15671
  49. package/dist/index.d.cts +21 -56
  50. package/dist/index.d.ts +21 -56
  51. package/dist/index.js +39 -334
  52. package/dist/{module-DeH_Jkcq.d.cts → module-CSN8j8Tp.d.cts} +1 -1
  53. package/dist/{module-B5m080F0.d.ts → module-DgYJur6f.d.ts} +1 -1
  54. package/dist/plan-versions.service-BB36Q1bg.d.ts +329 -0
  55. package/dist/plan-versions.service-CUR2Whyr.d.cts +329 -0
  56. package/dist/platform/index.cjs +4 -12925
  57. package/dist/platform/index.d.cts +17 -9
  58. package/dist/platform/index.d.ts +17 -9
  59. package/dist/platform/index.js +98 -14
  60. package/dist/promo/index.cjs +4 -1520
  61. package/dist/promo/index.d.cts +6 -21
  62. package/dist/promo/index.d.ts +6 -21
  63. package/dist/promo/index.js +2 -2
  64. package/dist/rate-limit.guard-dntqAlfZ.d.cts +19 -0
  65. package/dist/rate-limit.guard-dntqAlfZ.d.ts +19 -0
  66. package/dist/registration/index.cjs +4 -1655
  67. package/dist/registration/index.js +1 -1
  68. package/dist/{service-DlhMnYjW.d.ts → service-DX8KbGXl.d.cts} +1 -1
  69. package/dist/{service-DlhMnYjW.d.cts → service-DX8KbGXl.d.ts} +1 -1
  70. package/dist/setup.service-BPwJ7My_.d.cts +45 -0
  71. package/dist/setup.service-D2mrdDDB.d.ts +45 -0
  72. package/dist/subscription-bundle-preview.service-BkJXHAeP.d.cts +438 -0
  73. package/dist/subscription-bundle-preview.service-DBbrE_cw.d.ts +438 -0
  74. package/dist/subscription-contract/index.cjs +4 -471
  75. package/dist/subscription-contract/index.d.cts +5 -13
  76. package/dist/subscription-contract/index.d.ts +5 -13
  77. package/dist/subscription-contract.module-CG9fPKAr.d.cts +14 -0
  78. package/dist/subscription-contract.module-CVebZzHR.d.ts +14 -0
  79. package/dist/testing/index.cjs +4 -13888
  80. package/dist/testing/index.d.cts +5 -5
  81. package/dist/testing/index.d.ts +5 -5
  82. package/dist/testing/index.js +10 -10
  83. package/package.json +4 -4
  84. package/dist/admin-manifest.service-BMeSLRW4.d.ts +0 -33
  85. package/dist/admin-manifest.service-StAQe6QO.d.cts +0 -33
  86. package/dist/chunk-N3WANKSA.js +0 -20
@@ -0,0 +1,201 @@
1
+ import { CanActivate, ExecutionContext, NestInterceptor, CallHandler, Type, DynamicModule, ForwardReference, FactoryProvider, Provider } from '@nestjs/common';
2
+ import { Reflector } from '@nestjs/core';
3
+ import { MfaPort, RlsBypassPort, AuditPort, ManifestContribution, AdminManifest, SubscriptionStatsPort, PromoCodeStatsPort, AuditStatsPort, SubscriptionStatsSnapshot, PromoCodeStatsSnapshot, AuditStatsSnapshot } from '@saasicat/types';
4
+ import { Observable } from 'rxjs';
5
+ import { P as ProviderSpec } from './di-CcNeq9v-.cjs';
6
+ import { b as AdminManifestConfig } from './admin-resources.module-BZN_yBFj.cjs';
7
+
8
+ declare class SuperAdminGuard implements CanActivate {
9
+ canActivate(context: ExecutionContext): boolean;
10
+ }
11
+
12
+ interface TotpSetupResult {
13
+ /** Base32-encoded TOTP secret (persisted in the MfaPort). */
14
+ secret: string;
15
+ /** otpauth:// URI for the QR code generator (authenticator app). */
16
+ otpauthUri: string;
17
+ }
18
+ interface VerifyTotpInput {
19
+ userId: string;
20
+ code: string;
21
+ }
22
+ declare class MfaService {
23
+ private readonly mfa;
24
+ private readonly logger;
25
+ constructor(mfa: MfaPort);
26
+ /**
27
+ * Generates a new TOTP secret, persists it via `MfaPort.setSecret`
28
+ * and returns the secret + the otpauth URI for the QR code.
29
+ *
30
+ * `issuer` and `label` shape the display in the authenticator (e.g.
31
+ * "DemoApp:taci@example.com").
32
+ */
33
+ setup(userId: string, label: string, issuer: string): Promise<TotpSetupResult>;
34
+ /**
35
+ * Verifies the entered code against the stored secret,
36
+ * clock-drift-tolerant by ±1 time step.
37
+ */
38
+ verify(input: VerifyTotpInput): Promise<boolean>;
39
+ /**
40
+ * Deletes a user's secret — used by `ahp admin mfa-reset`.
41
+ */
42
+ disable(userId: string): Promise<void>;
43
+ /** Delegates to `MfaPort.isEnabled`. */
44
+ isEnabled(userId: string): Promise<boolean>;
45
+ }
46
+
47
+ declare const REQUIRE_MFA_KEY = "saas-platform/require-mfa";
48
+ /**
49
+ * Marks an endpoint as MFA-required. The frontend sends the TOTP code
50
+ * in the `X-Mfa-Code` header.
51
+ */
52
+ declare const RequireMfa: () => MethodDecorator & ClassDecorator;
53
+ declare class MfaGuard implements CanActivate {
54
+ private readonly reflector;
55
+ private readonly mfaService;
56
+ private readonly logger;
57
+ constructor(reflector: Reflector, mfaService: MfaService);
58
+ canActivate(context: ExecutionContext): Promise<boolean>;
59
+ }
60
+
61
+ declare class AdminBypassRlsInterceptor implements NestInterceptor {
62
+ private readonly port;
63
+ constructor(port: RlsBypassPort);
64
+ intercept(_context: ExecutionContext, next: CallHandler): Observable<unknown>;
65
+ }
66
+
67
+ interface AdminModuleOptions {
68
+ mfaPort: ProviderSpec<MfaPort>;
69
+ auditPort: ProviderSpec<AuditPort>;
70
+ rlsBypassPort: ProviderSpec<RlsBypassPort>;
71
+ /** Modules required by adapter factory `inject` tokens. */
72
+ imports?: Array<Type<unknown> | DynamicModule | Promise<DynamicModule> | ForwardReference>;
73
+ /** Register the module globally — default `false`. */
74
+ global?: boolean;
75
+ }
76
+ declare class AdminModule {
77
+ static forRoot(options: AdminModuleOptions): DynamicModule;
78
+ }
79
+
80
+ /**
81
+ * DI token for the platform core contribution. When `AdminManifestModule` is
82
+ * configured with `registerPlatformCore: true` (default), the module provides
83
+ * `PLATFORM_CORE_MANIFEST_CONTRIBUTION` under this token. The service
84
+ * registers the contribution in the constructor — before all app `register()`
85
+ * calls from `onModuleInit`.
86
+ */
87
+ declare const PLATFORM_CORE_CONTRIBUTION_TOKEN: unique symbol;
88
+ declare class AdminManifestService {
89
+ private readonly config;
90
+ private readonly logger;
91
+ private readonly contributions;
92
+ private cached;
93
+ constructor(config: AdminManifestConfig, platformCore?: ManifestContribution | null);
94
+ register(contribution: ManifestContribution): void;
95
+ getManifest(): AdminManifest;
96
+ rebuild(): AdminManifest;
97
+ private build;
98
+ private mergeContributions;
99
+ /**
100
+ * Deterministic SHA-256 hash over the manifest. Uses the insertion
101
+ * order of the object keys — so that semantically meaningful reorders (e.g.
102
+ * the order of the sidebar items in `navigation.standardPages`) change the
103
+ * hash and invalidate the browser ETag cache. The manifest's own
104
+ * `manifestHash` field is hidden before serialization.
105
+ */
106
+ private computeHash;
107
+ }
108
+
109
+ type ConfigSpec = AdminManifestConfig | Pick<FactoryProvider<AdminManifestConfig>, 'useFactory' | 'inject'>;
110
+ interface AdminManifestModuleOptions {
111
+ /** AdminManifestConfig as a value or via a factory (e.g. with a PLAN_CATALOG_TOKEN inject). */
112
+ config: ConfigSpec;
113
+ /**
114
+ * Default `true`. Set to `false` when the consumer registers its own
115
+ * manifest controller with app-specific guards entirely on its own.
116
+ */
117
+ includeManifestController?: boolean;
118
+ /**
119
+ * Class-level guards for GET /admin/manifest and POST /admin/manifest/reload,
120
+ * when `includeManifestController === true`. REQUIRED — otherwise
121
+ * `forRoot()` throws at boot.
122
+ *
123
+ * Pass `[]` explicitly when the endpoint should intentionally be auth-free
124
+ * (e.g. CI smoke tests, public demo). This makes the choice visible in the
125
+ * code rather than a silent default.
126
+ */
127
+ guards?: Array<Type<CanActivate>>;
128
+ /**
129
+ * Additional guards that apply ONLY to POST /admin/manifest/reload
130
+ * (typically `MfaGuard`). Placed after `guards` in the chain. Must be made
131
+ * available by the consumer as a provider.
132
+ */
133
+ reloadGuards?: Array<Type<CanActivate>>;
134
+ /**
135
+ * Default `true`. When active, the module automatically hooks
136
+ * `PLATFORM_CORE_MANIFEST_CONTRIBUTION` (StandardPage spine, generic tenant
137
+ * actions, platform audit action labels) into the `AdminManifestService` —
138
+ * before all app `register()` calls from `onModuleInit`. Consumers without
139
+ * a SuperAdmin need set this to `false`.
140
+ */
141
+ registerPlatformCore?: boolean;
142
+ /**
143
+ * Modules whose providers must be visible in the DI scope of this
144
+ * DynamicModule — typically: the app module that registers the
145
+ * factory-inject provider (e.g. `AdminManifestConfigFactory`). Without this
146
+ * entry, NestJS 11.1.19 cannot resolve the `inject:[...]` of the config
147
+ * factory (UnknownDependenciesException for ADMIN_MANIFEST_CONFIG).
148
+ */
149
+ imports?: Array<Type<unknown> | DynamicModule | Promise<DynamicModule> | ForwardReference>;
150
+ /** Additional providers that are registered in the DynamicModule itself. */
151
+ extraProviders?: Provider[];
152
+ /** Register the module globally — default `false`. */
153
+ global?: boolean;
154
+ }
155
+ declare class AdminManifestModule {
156
+ static forRoot(options: AdminManifestModuleOptions): DynamicModule;
157
+ }
158
+
159
+ /**
160
+ * Platform stats for the SuperAdmin dashboard page.
161
+ *
162
+ * Contains subscription/promo/audit aggregates that are equally meaningful
163
+ * across all consuming apps. App-specific KPIs (e.g. DATEV or Bundles/Members)
164
+ * remain extra endpoints in the respective app.
165
+ */
166
+ interface AdminStatsSnapshot {
167
+ subscriptions: SubscriptionStatsSnapshot;
168
+ promos: PromoCodeStatsSnapshot;
169
+ audit: AuditStatsSnapshot;
170
+ }
171
+ declare class AdminStatsService {
172
+ private readonly subscriptions;
173
+ private readonly promos;
174
+ private readonly audit;
175
+ private readonly auditWindowDays;
176
+ constructor(subscriptions: SubscriptionStatsPort, promos: PromoCodeStatsPort, audit: AuditStatsPort, auditWindowDays?: number);
177
+ getSnapshot(): Promise<AdminStatsSnapshot>;
178
+ }
179
+
180
+ interface AdminStatsModuleOptions {
181
+ subscriptionStatsPort: ProviderSpec<SubscriptionStatsPort>;
182
+ promoCodeStatsPort: ProviderSpec<PromoCodeStatsPort>;
183
+ auditStatsPort: ProviderSpec<AuditStatsPort>;
184
+ /** Audit window in days for the "last N days" KPI. Default 7. */
185
+ auditWindowDays?: number;
186
+ /**
187
+ * Modules whose providers must be visible in the DI scope of this
188
+ * DynamicModule — e.g. the app module that registers the adapter classes
189
+ * referenced by the factory `inject` lists.
190
+ */
191
+ imports?: Array<Type<unknown> | DynamicModule | Promise<DynamicModule> | ForwardReference>;
192
+ /** Additional providers registered in the DynamicModule itself. */
193
+ extraProviders?: Provider[];
194
+ /** Register the module globally — default `false`. */
195
+ global?: boolean;
196
+ }
197
+ declare class AdminStatsModule {
198
+ static forRoot(options: AdminStatsModuleOptions): DynamicModule;
199
+ }
200
+
201
+ export { AdminBypassRlsInterceptor as A, MfaGuard as M, PLATFORM_CORE_CONTRIBUTION_TOKEN as P, REQUIRE_MFA_KEY as R, SuperAdminGuard as S, type TotpSetupResult as T, type VerifyTotpInput as V, AdminManifestModule as a, type AdminManifestModuleOptions as b, AdminManifestService as c, AdminModule as d, type AdminModuleOptions as e, AdminStatsModule as f, type AdminStatsModuleOptions as g, AdminStatsService as h, type AdminStatsSnapshot as i, MfaService as j, RequireMfa as k };