@saasicat/nest 0.8.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.
- package/dist/_entries.cjs +17678 -0
- package/dist/admin/index.cjs +4 -1274
- package/dist/admin/index.d.cts +10 -171
- package/dist/admin/index.d.ts +10 -171
- package/dist/admin/index.js +13 -4
- package/dist/admin-resources.module-BZN_yBFj.d.cts +40 -0
- package/dist/admin-resources.module-Cms8MY6h.d.ts +40 -0
- package/dist/admin-stats.module-15ac5KY3.d.ts +201 -0
- package/dist/admin-stats.module-v4SVvWzj.d.cts +201 -0
- package/dist/billing/index.cjs +4 -5128
- package/dist/billing/index.d.cts +8 -719
- package/dist/billing/index.d.ts +8 -719
- package/dist/billing/index.js +7 -10
- package/dist/catalog/index.cjs +4 -5624
- package/dist/catalog/index.d.cts +7 -427
- package/dist/catalog/index.d.ts +7 -427
- package/dist/catalog/index.js +14 -12
- package/dist/catalog.module-BKObceo0.d.ts +103 -0
- package/dist/catalog.module-Dw2Hrbyu.d.cts +103 -0
- package/dist/checkout-offer/index.cjs +4 -807
- package/dist/checkout-offer/index.d.cts +5 -84
- package/dist/checkout-offer/index.d.ts +5 -84
- package/dist/checkout-offer/index.js +3 -2
- package/dist/checkout-offer.module-Y0hDOVrq.d.ts +85 -0
- package/dist/checkout-offer.module-ZYF5IsDY.d.cts +85 -0
- package/dist/{chunk-5DDCSGZC.js → chunk-33TP26MR.js} +144 -356
- package/dist/{chunk-CK54YKVK.js → chunk-75JABGZK.js} +16 -16
- package/dist/{chunk-HRU3CP57.js → chunk-BOADBIGB.js} +1 -1
- package/dist/{chunk-ZLUGQE5D.js → chunk-E7AJ42AB.js} +8 -8
- package/dist/{chunk-6LP7CDS2.js → chunk-F3VV6EXG.js} +18 -13
- package/dist/{chunk-PLDHI6NA.js → chunk-FVT7KTUI.js} +258 -3
- package/dist/{chunk-RZU4HIAN.js → chunk-GBDUH6DO.js} +26 -23
- package/dist/{chunk-K3OPNVFR.js → chunk-HBFU5AN3.js} +5 -9
- package/dist/chunk-HWGIMNWR.js +0 -0
- package/dist/chunk-IRWZC3GC.js +755 -0
- package/dist/chunk-L4KTQ6CL.js +20 -0
- package/dist/{chunk-T5SXXAKG.js → chunk-LZHLGUQI.js} +1 -1
- package/dist/{chunk-YHHE4KDA.js → chunk-PUXLPUVH.js} +351 -21
- package/dist/chunk-TXDH4FUA.js +211 -0
- package/dist/chunk-UF53DWWR.js +0 -0
- package/dist/{chunk-AJ3EPELS.js → chunk-V34AA7C7.js} +1 -1
- package/dist/chunk-WJ6BMDL3.js +313 -0
- package/dist/{chunk-M6CZQYPY.js → chunk-Z3FWN3HJ.js} +2 -2
- package/dist/discovery/index.cjs +4 -588
- package/dist/discovery/index.js +3 -3
- package/dist/{enforce-quota.interceptor-cv7r80VM.d.cts → enforce-quota.interceptor-BhkX5nq2.d.cts} +127 -12
- package/dist/{enforce-quota.interceptor-Dj1Kusr5.d.ts → enforce-quota.interceptor-CcqZc0Yu.d.ts} +127 -12
- package/dist/entitlement/index.cjs +4 -780
- package/dist/entitlement/index.d.cts +3 -1
- package/dist/entitlement/index.d.ts +3 -1
- package/dist/entitlement/index.js +2 -3
- package/dist/index.cjs +4 -14975
- package/dist/index.d.cts +22 -54
- package/dist/index.d.ts +22 -54
- package/dist/index.js +88 -369
- package/dist/module-CSN8j8Tp.d.cts +39 -0
- package/dist/module-DgYJur6f.d.ts +39 -0
- package/dist/plan-versions.service-BB36Q1bg.d.ts +329 -0
- package/dist/plan-versions.service-CUR2Whyr.d.cts +329 -0
- package/dist/platform/index.cjs +4 -2779
- package/dist/platform/index.d.cts +50 -8
- package/dist/platform/index.d.ts +50 -8
- package/dist/platform/index.js +116 -12
- package/dist/promo/index.cjs +4 -995
- package/dist/promo/index.d.cts +48 -46
- package/dist/promo/index.d.ts +48 -46
- package/dist/promo/index.js +10 -2
- package/dist/rate-limit.guard-dntqAlfZ.d.cts +19 -0
- package/dist/rate-limit.guard-dntqAlfZ.d.ts +19 -0
- package/dist/registration/index.cjs +4 -1655
- package/dist/registration/index.js +1 -1
- package/dist/setup.service-BPwJ7My_.d.cts +45 -0
- package/dist/setup.service-D2mrdDDB.d.ts +45 -0
- package/dist/subscription-bundle-preview.service-BkJXHAeP.d.cts +438 -0
- package/dist/subscription-bundle-preview.service-DBbrE_cw.d.ts +438 -0
- package/dist/subscription-bundles.module-BQmoozm5.d.ts +291 -0
- package/dist/subscription-bundles.module-DCpV-Pb5.d.cts +291 -0
- package/dist/subscription-contract/index.cjs +4 -471
- package/dist/subscription-contract/index.d.cts +5 -13
- package/dist/subscription-contract/index.d.ts +5 -13
- package/dist/subscription-contract.module-CG9fPKAr.d.cts +14 -0
- package/dist/subscription-contract.module-CVebZzHR.d.ts +14 -0
- package/dist/testing/index.cjs +4 -3756
- package/dist/testing/index.d.cts +9 -4
- package/dist/testing/index.d.ts +9 -4
- package/dist/testing/index.js +13 -7
- package/package.json +5 -5
- package/dist/admin-manifest.config-DyrQNT7M.d.cts +0 -10
- package/dist/admin-manifest.config-DyrQNT7M.d.ts +0 -10
- package/dist/admin-manifest.service-Cp6uwvmt.d.cts +0 -33
- package/dist/admin-manifest.service-UGgzR1x-.d.ts +0 -33
- package/dist/chunk-52UTQRD3.js +0 -326
- package/dist/chunk-N3WANKSA.js +0 -20
- package/dist/chunk-Q53N43LQ.js +0 -13
- /package/dist/{chunk-2FR6ZL7R.js → chunk-DBZGV3HC.js} +0 -0
package/dist/{enforce-quota.interceptor-cv7r80VM.d.cts → enforce-quota.interceptor-BhkX5nq2.d.cts}
RENAMED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { Type, CanActivate, DynamicModule, ForwardReference, FactoryProvider, ExecutionContext, NestInterceptor, CallHandler } from '@nestjs/common';
|
|
2
|
-
import { MfaPort, AuditPort, RlsBypassPort, PlanCatalogReadSink, SubscriptionRepository, PlanVersionRepository, TransactionRunner,
|
|
1
|
+
import { Type, CanActivate, DynamicModule, ForwardReference, FactoryProvider, Provider, ExecutionContext, NestInterceptor, CallHandler } from '@nestjs/common';
|
|
2
|
+
import { PlanCatalog, SaasicatPersistenceAdapter, MfaPort, AuditPort, RlsBypassPort, PlanCatalogReadSink, SubscriptionRepository, PlanVersionRepository, TransactionRunner, QuotaProvider, FeatureUiRegistry, SubscriptionUsagePort, UsageSnapshotPort, TenantSubscriptionWritePort, AdminResourcesPort, FirstTimeCustomerCheck } from '@saasicat/types';
|
|
3
3
|
import { P as ProviderSpec } from './di-CcNeq9v-.cjs';
|
|
4
|
-
import {
|
|
5
|
-
import { b as DiscoveryAppInfo } from './discovery.scanner-DLgEvuoy.cjs';
|
|
4
|
+
import { b as AdminManifestConfig, d as AdminResourcesModuleOptions } from './admin-resources.module-BZN_yBFj.cjs';
|
|
6
5
|
import { E as EntitlementResolutionConfig } from './plan-resolution-CFCoUkrE.cjs';
|
|
6
|
+
import { a as PromoCodesModuleOptions } from './module-CSN8j8Tp.cjs';
|
|
7
|
+
import { b as DiscoveryAppInfo } from './discovery.scanner-DLgEvuoy.cjs';
|
|
8
|
+
import { b as CatalogModuleOptions } from './catalog.module-Dw2Hrbyu.cjs';
|
|
9
|
+
import { t as TenantBillingModuleOptions, p as SubscriptionBundleModuleOptions, n as SubscriptionBundleControllerOptions } from './subscription-bundles.module-DCpV-Pb5.cjs';
|
|
7
10
|
import { Reflector } from '@nestjs/core';
|
|
8
11
|
import { Observable } from 'rxjs';
|
|
9
12
|
|
|
@@ -67,8 +70,8 @@ interface SaasPlatformAdapters {
|
|
|
67
70
|
* Optional — resolver `tenantId → planId`. The quickstart path uses this
|
|
68
71
|
* together with the `StaticEntitlementService` to automatically check
|
|
69
72
|
* `@RequireFeature` and `@EnforceQuota` against the plan catalog limit.
|
|
70
|
-
* If not set, `
|
|
71
|
-
*
|
|
73
|
+
* If not set, `tenantBilling` derives the resolver from the subscription
|
|
74
|
+
* repository. Lightweight setups can instead set `defaultPlanId`.
|
|
72
75
|
*/
|
|
73
76
|
planResolver?: ProviderSpec<PlanResolverPort>;
|
|
74
77
|
/**
|
|
@@ -79,6 +82,59 @@ interface SaasPlatformAdapters {
|
|
|
79
82
|
planVersionRepository?: ProviderSpec<PlanVersionRepository>;
|
|
80
83
|
transactionRunner?: ProviderSpec<TransactionRunner>;
|
|
81
84
|
}
|
|
85
|
+
type PlatformImports = Array<Type<unknown> | DynamicModule | Promise<DynamicModule> | ForwardReference>;
|
|
86
|
+
interface SaasPlatformCatalogOptions extends Pick<CatalogModuleOptions, 'strictModeCheckMode' | 'autoSyncDiscoveryAtBoot' | 'marketedOnlyFeatures' | 'publicMarketingCatalog' | 'extraProviders'> {
|
|
87
|
+
/** Labels/icons used by discovery review and the public catalog. */
|
|
88
|
+
featureUiRegistry: FeatureUiRegistry;
|
|
89
|
+
/** Mount the SuperAdmin catalog controllers. Default `true`. */
|
|
90
|
+
adminControllers?: boolean;
|
|
91
|
+
/** Mount `/billing/plans|bundles|feature-registry`. Default `true`. */
|
|
92
|
+
publicCatalog?: boolean;
|
|
93
|
+
/** Override the top-level module imports for catalog adapter factories. */
|
|
94
|
+
imports?: PlatformImports;
|
|
95
|
+
}
|
|
96
|
+
type SaasPlatformTenantAuthGuards = Array<Type<CanActivate>> | ProviderSpec<ReadonlyArray<CanActivate>>;
|
|
97
|
+
interface SaasPlatformTenantBillingOptions extends Omit<TenantBillingModuleOptions, 'authGuards' | 'subscriptionUsagePort' | 'usageSnapshotPort' | 'subscriptionWritePort' | 'global'> {
|
|
98
|
+
/**
|
|
99
|
+
* Tenant guards as classes (the common path) or as a custom provider
|
|
100
|
+
* factory. Guard classes are resolved from `imports`.
|
|
101
|
+
*/
|
|
102
|
+
authGuards: SaasPlatformTenantAuthGuards;
|
|
103
|
+
/** Optional overrides; otherwise the persistence bundle supplies them. */
|
|
104
|
+
subscriptionUsagePort?: ProviderSpec<SubscriptionUsagePort>;
|
|
105
|
+
usageSnapshotPort?: ProviderSpec<UsageSnapshotPort>;
|
|
106
|
+
subscriptionWritePort?: ProviderSpec<TenantSubscriptionWritePort>;
|
|
107
|
+
}
|
|
108
|
+
interface SaasPlatformSubscriptionBundlesOptions extends Omit<SubscriptionBundleModuleOptions, 'subscriptionBundleRepository' | 'bundleRepository' | 'controller' | 'imports' | 'extraProviders' | 'global'> {
|
|
109
|
+
/** Default mounts the tenant controller and reuses tenant-billing auth. */
|
|
110
|
+
controller?: false | Omit<SubscriptionBundleControllerOptions, 'authGuards' | 'subscriptionUsagePort'>;
|
|
111
|
+
imports?: PlatformImports;
|
|
112
|
+
extraProviders?: Provider[];
|
|
113
|
+
}
|
|
114
|
+
interface SaasPlatformAdminResourcesOptions extends Omit<AdminResourcesModuleOptions, 'resources' | 'guards' | 'global'> {
|
|
115
|
+
/** Override the default controller guards + `SuperAdminGuard` chain. */
|
|
116
|
+
guards?: Array<Type<CanActivate>>;
|
|
117
|
+
/** Custom schema override; the persistence bundle supplies the default. */
|
|
118
|
+
resources?: ProviderSpec<AdminResourcesPort>;
|
|
119
|
+
}
|
|
120
|
+
interface SaasPlatformPromoCodesOptions extends Omit<PromoCodesModuleOptions, 'promoCodeRepository' | 'redemptionRepository' | 'validationLogRepository' | 'subscriptionLookup' | 'revenueAggregator' | 'transactionRunner' | 'firstTimeCustomerCheck' | 'adminController' | 'global'> {
|
|
121
|
+
/**
|
|
122
|
+
* Required when the public preview/redeem flow is enabled. Admin-only
|
|
123
|
+
* setups do not need an app-specific customer-history check.
|
|
124
|
+
*/
|
|
125
|
+
firstTimeCustomerCheck?: ProviderSpec<FirstTimeCustomerCheck>;
|
|
126
|
+
/** Override the default controller guards + `SuperAdminGuard` chain. */
|
|
127
|
+
adminGuards?: Array<Type<CanActivate>>;
|
|
128
|
+
/**
|
|
129
|
+
* Mount the SuperAdmin promo-code CRUD controller. Default `true`.
|
|
130
|
+
*
|
|
131
|
+
* Set `false` when the app serves `/admin/promo-codes` itself — two
|
|
132
|
+
* controllers on one path abort the boot with a duplicate-route error.
|
|
133
|
+
* The promo domain service stays available either way, so an app-owned
|
|
134
|
+
* controller can still delegate its validation to the platform.
|
|
135
|
+
*/
|
|
136
|
+
adminController?: false;
|
|
137
|
+
}
|
|
82
138
|
interface SaasPlatformModuleOptions {
|
|
83
139
|
/**
|
|
84
140
|
* Plan catalog. Either as an already-loaded object (quickstart, comes
|
|
@@ -131,11 +187,21 @@ interface SaasPlatformModuleOptions {
|
|
|
131
187
|
* `MfaGuard`). Optional.
|
|
132
188
|
*/
|
|
133
189
|
reloadGuards?: Array<Type<CanActivate>>;
|
|
190
|
+
/**
|
|
191
|
+
* Mount the platform's `GET /admin/manifest` + `POST /admin/manifest/reload`
|
|
192
|
+
* controller. Default `true`.
|
|
193
|
+
*
|
|
194
|
+
* Set `false` when the app serves those routes from its own controller —
|
|
195
|
+
* two controllers on one path abort the boot with a duplicate-route error
|
|
196
|
+
* (`FST_ERR_DUPLICATED_ROUTE` under Fastify), so this is not something the
|
|
197
|
+
* app can simply override.
|
|
198
|
+
*/
|
|
199
|
+
includeManifestController?: boolean;
|
|
134
200
|
/**
|
|
135
201
|
* Modules whose providers must be visible in the DI scope (typically:
|
|
136
202
|
* `AuthModule` with the `JwtAuthGuard`).
|
|
137
203
|
*/
|
|
138
|
-
imports?:
|
|
204
|
+
imports?: PlatformImports;
|
|
139
205
|
/**
|
|
140
206
|
* App identity for the DiscoveryScanner. If omitted, `planCatalog.app` is
|
|
141
207
|
* used (recommendation: simply declare it in the YAML).
|
|
@@ -154,10 +220,17 @@ interface SaasPlatformModuleOptions {
|
|
|
154
220
|
*/
|
|
155
221
|
adminManifestConfig?: AdminManifestConfig | Pick<FactoryProvider<AdminManifestConfig>, 'useFactory' | 'inject'>;
|
|
156
222
|
/**
|
|
157
|
-
*
|
|
223
|
+
* Infer manifest capabilities for platform endpoints mounted by this
|
|
224
|
+
* module. Default `true`; set `false` only when the app owns the complete
|
|
225
|
+
* manifest capability policy.
|
|
226
|
+
*/
|
|
227
|
+
autoManifest?: boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Default `false`. When set, `EntitlementModule.forRoot({...})` is called
|
|
158
230
|
* with the repositories from `adapters` — only meaningful if the app
|
|
159
231
|
* implements the V3 contract path (`subscriptionRepository` & co. must then
|
|
160
|
-
* be set).
|
|
232
|
+
* be set). `tenantBilling` and `subscriptionBundles` enable it
|
|
233
|
+
* automatically.
|
|
161
234
|
*/
|
|
162
235
|
entitlement?: false | {
|
|
163
236
|
resolutionConfig?: EntitlementResolutionConfig;
|
|
@@ -177,12 +250,54 @@ interface SaasPlatformModuleOptions {
|
|
|
177
250
|
* `QUOTA_PROVIDERS_TOKEN`.
|
|
178
251
|
*/
|
|
179
252
|
quotaProviders?: Array<Type<QuotaProvider>>;
|
|
253
|
+
/**
|
|
254
|
+
* Standard DB-backed catalog stack. Repositories are taken from
|
|
255
|
+
* `persistence.catalog`; no consumer forwarding module is needed.
|
|
256
|
+
*/
|
|
257
|
+
catalog?: false | SaasPlatformCatalogOptions;
|
|
258
|
+
/**
|
|
259
|
+
* Standard tenant self-service stack. Subscription read/write adapters
|
|
260
|
+
* come from `persistence.tenantBilling`; usage is derived from
|
|
261
|
+
* `quotaProviders` unless explicitly overridden.
|
|
262
|
+
*/
|
|
263
|
+
tenantBilling?: false | SaasPlatformTenantBillingOptions;
|
|
264
|
+
/**
|
|
265
|
+
* Add-on bundle service and tenant controller. `true` uses defaults and
|
|
266
|
+
* reuses tenant-billing auth/usage; an object customizes policy.
|
|
267
|
+
*/
|
|
268
|
+
subscriptionBundles?: false | true | SaasPlatformSubscriptionBundlesOptions;
|
|
269
|
+
/**
|
|
270
|
+
* Standard SuperAdmin Tenant/User/Audit/Subscription endpoints. `true`
|
|
271
|
+
* uses `persistence.adminResources` and the standard guard chain.
|
|
272
|
+
*/
|
|
273
|
+
adminResources?: false | true | SaasPlatformAdminResourcesOptions;
|
|
274
|
+
/**
|
|
275
|
+
* Promo-code domain and SuperAdmin CRUD. `true` enables the admin API
|
|
276
|
+
* without the public preview endpoint; pass an object to enable preview.
|
|
277
|
+
*/
|
|
278
|
+
promoCodes?: false | true | SaasPlatformPromoCodesOptions;
|
|
180
279
|
/**
|
|
181
280
|
* Enable the tenant manifest — the app UI gets a filtered manifest per
|
|
182
281
|
* tenant with features, quotas and visible navigation. Requires that
|
|
183
|
-
* `defaultPlanId
|
|
282
|
+
* `defaultPlanId`, `adapters.planResolver` or `tenantBilling` is set.
|
|
283
|
+
* `true` reuses tenant-billing guard classes when available, otherwise
|
|
284
|
+
* `controller.guards`.
|
|
285
|
+
*/
|
|
286
|
+
tenantManifest?: true | TenantManifestControllerOptions;
|
|
287
|
+
/**
|
|
288
|
+
* Bind `StaticFeatureGuard` as a global `APP_GUARD`. Default `true`.
|
|
289
|
+
*
|
|
290
|
+
* Set `false` when the app authenticates in a controller-local guard.
|
|
291
|
+
* Nest runs every global guard before every controller-local one, so a
|
|
292
|
+
* global feature guard sees no `request.user` and rejects with 403 before
|
|
293
|
+
* authentication has run. Apps in that shape bind the guard themselves,
|
|
294
|
+
* behind their auth guard: `@UseGuards(JwtAuthGuard, FeatureGuard)`.
|
|
295
|
+
*
|
|
296
|
+
* Only the guard is affected. `EnforceQuotaInterceptor` stays global
|
|
297
|
+
* either way — interceptors run after all guards, so it does see the
|
|
298
|
+
* authenticated request.
|
|
184
299
|
*/
|
|
185
|
-
|
|
300
|
+
globalFeatureGuard?: boolean;
|
|
186
301
|
}
|
|
187
302
|
/**
|
|
188
303
|
* Bundles PlanCatalog + Discovery + Admin + AdminManifest (+ optionally
|
|
@@ -260,4 +375,4 @@ declare class EnforceQuotaInterceptor implements NestInterceptor {
|
|
|
260
375
|
private check;
|
|
261
376
|
}
|
|
262
377
|
|
|
263
|
-
export { EnforceQuotaInterceptor as E, PLAN_RESOLVER_PORT_TOKEN as P, QUOTA_PROVIDERS_TOKEN as Q,
|
|
378
|
+
export { EnforceQuotaInterceptor as E, PLAN_RESOLVER_PORT_TOKEN as P, QUOTA_PROVIDERS_TOKEN as Q, type SaasPlatformAdapters as S, type TenantManifestControllerOptions as T, StaticEntitlementService as a, StaticFeatureGuard as b, StaticPlanResolver as c, type SaasPlatformModuleOptions as d, type PlanResolverPort as e, STATIC_FEATURE_GUARD_CONFIG_TOKEN as f, SaasPlatformModule as g, type SaasPlatformAdminResourcesOptions as h, type SaasPlatformCatalogOptions as i, type SaasPlatformPromoCodesOptions as j, type SaasPlatformSubscriptionBundlesOptions as k, type SaasPlatformTenantAuthGuards as l, type SaasPlatformTenantBillingOptions as m, type StaticEntitlementSnapshot as n, type StaticFeatureGuardConfig as o, buildTenantManifestController as p };
|
package/dist/{enforce-quota.interceptor-Dj1Kusr5.d.ts → enforce-quota.interceptor-CcqZc0Yu.d.ts}
RENAMED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { Type, CanActivate, DynamicModule, ForwardReference, FactoryProvider, ExecutionContext, NestInterceptor, CallHandler } from '@nestjs/common';
|
|
2
|
-
import { MfaPort, AuditPort, RlsBypassPort, PlanCatalogReadSink, SubscriptionRepository, PlanVersionRepository, TransactionRunner,
|
|
1
|
+
import { Type, CanActivate, DynamicModule, ForwardReference, FactoryProvider, Provider, ExecutionContext, NestInterceptor, CallHandler } from '@nestjs/common';
|
|
2
|
+
import { PlanCatalog, SaasicatPersistenceAdapter, MfaPort, AuditPort, RlsBypassPort, PlanCatalogReadSink, SubscriptionRepository, PlanVersionRepository, TransactionRunner, QuotaProvider, FeatureUiRegistry, SubscriptionUsagePort, UsageSnapshotPort, TenantSubscriptionWritePort, AdminResourcesPort, FirstTimeCustomerCheck } from '@saasicat/types';
|
|
3
3
|
import { P as ProviderSpec } from './di-CcNeq9v-.js';
|
|
4
|
-
import {
|
|
5
|
-
import { b as DiscoveryAppInfo } from './discovery.scanner-DLgEvuoy.js';
|
|
4
|
+
import { b as AdminManifestConfig, d as AdminResourcesModuleOptions } from './admin-resources.module-Cms8MY6h.js';
|
|
6
5
|
import { E as EntitlementResolutionConfig } from './plan-resolution-CFCoUkrE.js';
|
|
6
|
+
import { a as PromoCodesModuleOptions } from './module-DgYJur6f.js';
|
|
7
|
+
import { b as DiscoveryAppInfo } from './discovery.scanner-DLgEvuoy.js';
|
|
8
|
+
import { b as CatalogModuleOptions } from './catalog.module-BKObceo0.js';
|
|
9
|
+
import { t as TenantBillingModuleOptions, p as SubscriptionBundleModuleOptions, n as SubscriptionBundleControllerOptions } from './subscription-bundles.module-BQmoozm5.js';
|
|
7
10
|
import { Reflector } from '@nestjs/core';
|
|
8
11
|
import { Observable } from 'rxjs';
|
|
9
12
|
|
|
@@ -67,8 +70,8 @@ interface SaasPlatformAdapters {
|
|
|
67
70
|
* Optional — resolver `tenantId → planId`. The quickstart path uses this
|
|
68
71
|
* together with the `StaticEntitlementService` to automatically check
|
|
69
72
|
* `@RequireFeature` and `@EnforceQuota` against the plan catalog limit.
|
|
70
|
-
* If not set, `
|
|
71
|
-
*
|
|
73
|
+
* If not set, `tenantBilling` derives the resolver from the subscription
|
|
74
|
+
* repository. Lightweight setups can instead set `defaultPlanId`.
|
|
72
75
|
*/
|
|
73
76
|
planResolver?: ProviderSpec<PlanResolverPort>;
|
|
74
77
|
/**
|
|
@@ -79,6 +82,59 @@ interface SaasPlatformAdapters {
|
|
|
79
82
|
planVersionRepository?: ProviderSpec<PlanVersionRepository>;
|
|
80
83
|
transactionRunner?: ProviderSpec<TransactionRunner>;
|
|
81
84
|
}
|
|
85
|
+
type PlatformImports = Array<Type<unknown> | DynamicModule | Promise<DynamicModule> | ForwardReference>;
|
|
86
|
+
interface SaasPlatformCatalogOptions extends Pick<CatalogModuleOptions, 'strictModeCheckMode' | 'autoSyncDiscoveryAtBoot' | 'marketedOnlyFeatures' | 'publicMarketingCatalog' | 'extraProviders'> {
|
|
87
|
+
/** Labels/icons used by discovery review and the public catalog. */
|
|
88
|
+
featureUiRegistry: FeatureUiRegistry;
|
|
89
|
+
/** Mount the SuperAdmin catalog controllers. Default `true`. */
|
|
90
|
+
adminControllers?: boolean;
|
|
91
|
+
/** Mount `/billing/plans|bundles|feature-registry`. Default `true`. */
|
|
92
|
+
publicCatalog?: boolean;
|
|
93
|
+
/** Override the top-level module imports for catalog adapter factories. */
|
|
94
|
+
imports?: PlatformImports;
|
|
95
|
+
}
|
|
96
|
+
type SaasPlatformTenantAuthGuards = Array<Type<CanActivate>> | ProviderSpec<ReadonlyArray<CanActivate>>;
|
|
97
|
+
interface SaasPlatformTenantBillingOptions extends Omit<TenantBillingModuleOptions, 'authGuards' | 'subscriptionUsagePort' | 'usageSnapshotPort' | 'subscriptionWritePort' | 'global'> {
|
|
98
|
+
/**
|
|
99
|
+
* Tenant guards as classes (the common path) or as a custom provider
|
|
100
|
+
* factory. Guard classes are resolved from `imports`.
|
|
101
|
+
*/
|
|
102
|
+
authGuards: SaasPlatformTenantAuthGuards;
|
|
103
|
+
/** Optional overrides; otherwise the persistence bundle supplies them. */
|
|
104
|
+
subscriptionUsagePort?: ProviderSpec<SubscriptionUsagePort>;
|
|
105
|
+
usageSnapshotPort?: ProviderSpec<UsageSnapshotPort>;
|
|
106
|
+
subscriptionWritePort?: ProviderSpec<TenantSubscriptionWritePort>;
|
|
107
|
+
}
|
|
108
|
+
interface SaasPlatformSubscriptionBundlesOptions extends Omit<SubscriptionBundleModuleOptions, 'subscriptionBundleRepository' | 'bundleRepository' | 'controller' | 'imports' | 'extraProviders' | 'global'> {
|
|
109
|
+
/** Default mounts the tenant controller and reuses tenant-billing auth. */
|
|
110
|
+
controller?: false | Omit<SubscriptionBundleControllerOptions, 'authGuards' | 'subscriptionUsagePort'>;
|
|
111
|
+
imports?: PlatformImports;
|
|
112
|
+
extraProviders?: Provider[];
|
|
113
|
+
}
|
|
114
|
+
interface SaasPlatformAdminResourcesOptions extends Omit<AdminResourcesModuleOptions, 'resources' | 'guards' | 'global'> {
|
|
115
|
+
/** Override the default controller guards + `SuperAdminGuard` chain. */
|
|
116
|
+
guards?: Array<Type<CanActivate>>;
|
|
117
|
+
/** Custom schema override; the persistence bundle supplies the default. */
|
|
118
|
+
resources?: ProviderSpec<AdminResourcesPort>;
|
|
119
|
+
}
|
|
120
|
+
interface SaasPlatformPromoCodesOptions extends Omit<PromoCodesModuleOptions, 'promoCodeRepository' | 'redemptionRepository' | 'validationLogRepository' | 'subscriptionLookup' | 'revenueAggregator' | 'transactionRunner' | 'firstTimeCustomerCheck' | 'adminController' | 'global'> {
|
|
121
|
+
/**
|
|
122
|
+
* Required when the public preview/redeem flow is enabled. Admin-only
|
|
123
|
+
* setups do not need an app-specific customer-history check.
|
|
124
|
+
*/
|
|
125
|
+
firstTimeCustomerCheck?: ProviderSpec<FirstTimeCustomerCheck>;
|
|
126
|
+
/** Override the default controller guards + `SuperAdminGuard` chain. */
|
|
127
|
+
adminGuards?: Array<Type<CanActivate>>;
|
|
128
|
+
/**
|
|
129
|
+
* Mount the SuperAdmin promo-code CRUD controller. Default `true`.
|
|
130
|
+
*
|
|
131
|
+
* Set `false` when the app serves `/admin/promo-codes` itself — two
|
|
132
|
+
* controllers on one path abort the boot with a duplicate-route error.
|
|
133
|
+
* The promo domain service stays available either way, so an app-owned
|
|
134
|
+
* controller can still delegate its validation to the platform.
|
|
135
|
+
*/
|
|
136
|
+
adminController?: false;
|
|
137
|
+
}
|
|
82
138
|
interface SaasPlatformModuleOptions {
|
|
83
139
|
/**
|
|
84
140
|
* Plan catalog. Either as an already-loaded object (quickstart, comes
|
|
@@ -131,11 +187,21 @@ interface SaasPlatformModuleOptions {
|
|
|
131
187
|
* `MfaGuard`). Optional.
|
|
132
188
|
*/
|
|
133
189
|
reloadGuards?: Array<Type<CanActivate>>;
|
|
190
|
+
/**
|
|
191
|
+
* Mount the platform's `GET /admin/manifest` + `POST /admin/manifest/reload`
|
|
192
|
+
* controller. Default `true`.
|
|
193
|
+
*
|
|
194
|
+
* Set `false` when the app serves those routes from its own controller —
|
|
195
|
+
* two controllers on one path abort the boot with a duplicate-route error
|
|
196
|
+
* (`FST_ERR_DUPLICATED_ROUTE` under Fastify), so this is not something the
|
|
197
|
+
* app can simply override.
|
|
198
|
+
*/
|
|
199
|
+
includeManifestController?: boolean;
|
|
134
200
|
/**
|
|
135
201
|
* Modules whose providers must be visible in the DI scope (typically:
|
|
136
202
|
* `AuthModule` with the `JwtAuthGuard`).
|
|
137
203
|
*/
|
|
138
|
-
imports?:
|
|
204
|
+
imports?: PlatformImports;
|
|
139
205
|
/**
|
|
140
206
|
* App identity for the DiscoveryScanner. If omitted, `planCatalog.app` is
|
|
141
207
|
* used (recommendation: simply declare it in the YAML).
|
|
@@ -154,10 +220,17 @@ interface SaasPlatformModuleOptions {
|
|
|
154
220
|
*/
|
|
155
221
|
adminManifestConfig?: AdminManifestConfig | Pick<FactoryProvider<AdminManifestConfig>, 'useFactory' | 'inject'>;
|
|
156
222
|
/**
|
|
157
|
-
*
|
|
223
|
+
* Infer manifest capabilities for platform endpoints mounted by this
|
|
224
|
+
* module. Default `true`; set `false` only when the app owns the complete
|
|
225
|
+
* manifest capability policy.
|
|
226
|
+
*/
|
|
227
|
+
autoManifest?: boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Default `false`. When set, `EntitlementModule.forRoot({...})` is called
|
|
158
230
|
* with the repositories from `adapters` — only meaningful if the app
|
|
159
231
|
* implements the V3 contract path (`subscriptionRepository` & co. must then
|
|
160
|
-
* be set).
|
|
232
|
+
* be set). `tenantBilling` and `subscriptionBundles` enable it
|
|
233
|
+
* automatically.
|
|
161
234
|
*/
|
|
162
235
|
entitlement?: false | {
|
|
163
236
|
resolutionConfig?: EntitlementResolutionConfig;
|
|
@@ -177,12 +250,54 @@ interface SaasPlatformModuleOptions {
|
|
|
177
250
|
* `QUOTA_PROVIDERS_TOKEN`.
|
|
178
251
|
*/
|
|
179
252
|
quotaProviders?: Array<Type<QuotaProvider>>;
|
|
253
|
+
/**
|
|
254
|
+
* Standard DB-backed catalog stack. Repositories are taken from
|
|
255
|
+
* `persistence.catalog`; no consumer forwarding module is needed.
|
|
256
|
+
*/
|
|
257
|
+
catalog?: false | SaasPlatformCatalogOptions;
|
|
258
|
+
/**
|
|
259
|
+
* Standard tenant self-service stack. Subscription read/write adapters
|
|
260
|
+
* come from `persistence.tenantBilling`; usage is derived from
|
|
261
|
+
* `quotaProviders` unless explicitly overridden.
|
|
262
|
+
*/
|
|
263
|
+
tenantBilling?: false | SaasPlatformTenantBillingOptions;
|
|
264
|
+
/**
|
|
265
|
+
* Add-on bundle service and tenant controller. `true` uses defaults and
|
|
266
|
+
* reuses tenant-billing auth/usage; an object customizes policy.
|
|
267
|
+
*/
|
|
268
|
+
subscriptionBundles?: false | true | SaasPlatformSubscriptionBundlesOptions;
|
|
269
|
+
/**
|
|
270
|
+
* Standard SuperAdmin Tenant/User/Audit/Subscription endpoints. `true`
|
|
271
|
+
* uses `persistence.adminResources` and the standard guard chain.
|
|
272
|
+
*/
|
|
273
|
+
adminResources?: false | true | SaasPlatformAdminResourcesOptions;
|
|
274
|
+
/**
|
|
275
|
+
* Promo-code domain and SuperAdmin CRUD. `true` enables the admin API
|
|
276
|
+
* without the public preview endpoint; pass an object to enable preview.
|
|
277
|
+
*/
|
|
278
|
+
promoCodes?: false | true | SaasPlatformPromoCodesOptions;
|
|
180
279
|
/**
|
|
181
280
|
* Enable the tenant manifest — the app UI gets a filtered manifest per
|
|
182
281
|
* tenant with features, quotas and visible navigation. Requires that
|
|
183
|
-
* `defaultPlanId
|
|
282
|
+
* `defaultPlanId`, `adapters.planResolver` or `tenantBilling` is set.
|
|
283
|
+
* `true` reuses tenant-billing guard classes when available, otherwise
|
|
284
|
+
* `controller.guards`.
|
|
285
|
+
*/
|
|
286
|
+
tenantManifest?: true | TenantManifestControllerOptions;
|
|
287
|
+
/**
|
|
288
|
+
* Bind `StaticFeatureGuard` as a global `APP_GUARD`. Default `true`.
|
|
289
|
+
*
|
|
290
|
+
* Set `false` when the app authenticates in a controller-local guard.
|
|
291
|
+
* Nest runs every global guard before every controller-local one, so a
|
|
292
|
+
* global feature guard sees no `request.user` and rejects with 403 before
|
|
293
|
+
* authentication has run. Apps in that shape bind the guard themselves,
|
|
294
|
+
* behind their auth guard: `@UseGuards(JwtAuthGuard, FeatureGuard)`.
|
|
295
|
+
*
|
|
296
|
+
* Only the guard is affected. `EnforceQuotaInterceptor` stays global
|
|
297
|
+
* either way — interceptors run after all guards, so it does see the
|
|
298
|
+
* authenticated request.
|
|
184
299
|
*/
|
|
185
|
-
|
|
300
|
+
globalFeatureGuard?: boolean;
|
|
186
301
|
}
|
|
187
302
|
/**
|
|
188
303
|
* Bundles PlanCatalog + Discovery + Admin + AdminManifest (+ optionally
|
|
@@ -260,4 +375,4 @@ declare class EnforceQuotaInterceptor implements NestInterceptor {
|
|
|
260
375
|
private check;
|
|
261
376
|
}
|
|
262
377
|
|
|
263
|
-
export { EnforceQuotaInterceptor as E, PLAN_RESOLVER_PORT_TOKEN as P, QUOTA_PROVIDERS_TOKEN as Q,
|
|
378
|
+
export { EnforceQuotaInterceptor as E, PLAN_RESOLVER_PORT_TOKEN as P, QUOTA_PROVIDERS_TOKEN as Q, type SaasPlatformAdapters as S, type TenantManifestControllerOptions as T, StaticEntitlementService as a, StaticFeatureGuard as b, StaticPlanResolver as c, type SaasPlatformModuleOptions as d, type PlanResolverPort as e, STATIC_FEATURE_GUARD_CONFIG_TOKEN as f, SaasPlatformModule as g, type SaasPlatformAdminResourcesOptions as h, type SaasPlatformCatalogOptions as i, type SaasPlatformPromoCodesOptions as j, type SaasPlatformSubscriptionBundlesOptions as k, type SaasPlatformTenantAuthGuards as l, type SaasPlatformTenantBillingOptions as m, type StaticEntitlementSnapshot as n, type StaticFeatureGuardConfig as o, buildTenantManifestController as p };
|