@saasicat/nest 0.26.1 → 1.0.0-rc.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/LICENSE +90 -201
- package/dist/.build-stamp +1 -0
- package/dist/_entries.cjs +3175 -2756
- package/dist/admin/index.d.cts +2 -2
- package/dist/admin/index.d.ts +2 -2
- package/dist/admin/index.js +2 -2
- package/dist/{admin-stats.service-HUZIU448.d.cts → admin-stats.service-BroyovpL.d.cts} +1 -1
- package/dist/{admin-stats.service-Db2exT_d.d.ts → admin-stats.service-G53IEkkt.d.ts} +1 -1
- package/dist/billing/index.d.cts +7 -7
- package/dist/billing/index.d.ts +7 -7
- package/dist/billing/index.js +38 -36
- package/dist/catalog/index.d.cts +13 -1
- package/dist/catalog/index.d.ts +13 -1
- package/dist/catalog/index.js +10 -8
- package/dist/checkout-offer/index.js +2 -2
- package/dist/chunk-2FR6ZL7R.js +0 -0
- package/dist/chunk-2SLTRKXC.js +0 -0
- package/dist/{chunk-7ZPFQXHM.js → chunk-3UZW7TU4.js} +1 -1
- package/dist/{chunk-XTVAFJ3P.js → chunk-AEEK64XD.js} +3 -3
- package/dist/chunk-AOQJEYOL.js +20 -0
- package/dist/chunk-H3W6QDQH.js +85 -0
- package/dist/{chunk-YYUXKLXK.js → chunk-I7GTA3RX.js} +2 -2
- package/dist/{chunk-SN5UOC43.js → chunk-IPOLCDKN.js} +11 -11
- package/dist/{chunk-B7NRY2LV.js → chunk-IVEA6M3B.js} +2 -40
- package/dist/chunk-JCAZT727.js +1883 -0
- package/dist/chunk-JTLKWP3Q.js +792 -0
- package/dist/{chunk-E56W4U2P.js → chunk-O2J2HDXA.js} +4 -4
- package/dist/{chunk-WKVBNTYC.js → chunk-OUDSQ3PU.js} +6 -6
- package/dist/{chunk-MJ32VNZD.js → chunk-P5D5CYO2.js} +18 -18
- package/dist/{chunk-L4SUWH5B.js → chunk-QUZU2M33.js} +2 -2
- package/dist/{chunk-WPUVJRIN.js → chunk-S6BAD5XM.js} +10 -10
- package/dist/{chunk-7X5MSAIL.js → chunk-SH7J5IU7.js} +9 -9
- package/dist/{chunk-37HEKVDH.js → chunk-V4OJ43K2.js} +10 -10
- package/dist/{chunk-NYLON2VC.js → chunk-VBRYPU7V.js} +2 -2
- package/dist/{chunk-B6IWLV7R.js → chunk-VTMCMVYQ.js} +6 -6
- package/dist/{chunk-YWDLYOFN.js → chunk-WSPHIIGS.js} +429 -1205
- package/dist/{chunk-5ZXBXYXU.js → chunk-WXYJHZCN.js} +3 -3
- package/dist/{chunk-6WL6VQ7Z.js → chunk-XBYAFEOR.js} +2 -2
- package/dist/{chunk-NNNXXUPT.js → chunk-XEW6YXL5.js} +28 -93
- package/dist/chunk-Y43SGD5J.js +50 -0
- package/dist/{define-saasicat-BK6RRWWG.d.ts → define-saasicat-BFgeoVG9.d.ts} +28 -5
- package/dist/{define-saasicat-D30I-WET.d.cts → define-saasicat-CNUWjfNK.d.cts} +28 -5
- package/dist/discovery/index.js +4 -4
- package/dist/{enforce-quota.interceptor-B9QueAFf.d.ts → enforce-quota.interceptor-BYqmdFB5.d.ts} +3 -3
- package/dist/{enforce-quota.interceptor-DY6CLjoP.d.cts → enforce-quota.interceptor-BxIR63Wn.d.cts} +3 -3
- package/dist/entitlement/index.js +9 -6
- package/dist/index.d.cts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +61 -52
- package/dist/{saas-platform.module-D1mUZPrz.d.ts → module-options-BymIkAsh.d.ts} +68 -55
- package/dist/{saas-platform.module-CgalxzcT.d.cts → module-options-DgwBKVpC.d.cts} +68 -55
- package/dist/platform/index.d.cts +204 -22
- package/dist/platform/index.d.ts +204 -22
- package/dist/platform/index.js +49 -25
- package/dist/promo/index.d.cts +3 -3
- package/dist/promo/index.d.ts +3 -3
- package/dist/promo/index.js +3 -3
- package/dist/{module-BE17XFLg.d.ts → promo.module-CnzddtJ0.d.ts} +1 -1
- package/dist/{module-CHMIyWlf.d.cts → promo.module-DokmUGmm.d.cts} +1 -1
- package/dist/registration/index.d.cts +1 -1
- package/dist/registration/index.d.ts +1 -1
- package/dist/registration/index.js +1 -1
- package/dist/subscription-contract/index.js +6 -3
- package/dist/{tenant-billing.controller-BSlpFqVA.d.ts → tenant-billing.controller-BQPy5yXh.d.ts} +2 -2
- package/dist/{tenant-billing.controller-DHSUrT_N.d.cts → tenant-billing.controller-CODIYzlI.d.cts} +2 -2
- package/dist/{subscription-bundles.module-BDbODWvA.d.ts → tenant-billing.module-B0stLoJn.d.ts} +51 -51
- package/dist/{subscription-bundles.module-Cfi-lFWF.d.cts → tenant-billing.module-BxJS6fX4.d.cts} +51 -51
- package/dist/testing/index.d.cts +14 -14
- package/dist/testing/index.d.ts +14 -14
- package/dist/testing/index.js +31 -29
- package/package.json +6 -6
- package/dist/chunk-L4KTQ6CL.js +0 -20
- package/dist/chunk-TCBYOFAC.js +0 -1464
- /package/dist/{chunk-FY4EJTV4.js → chunk-OYNHOY45.js} +0 -0
- /package/dist/{service-D48clObR.d.cts → promo.service-D48clObR.d.cts} +0 -0
- /package/dist/{service-D48clObR.d.ts → promo.service-D48clObR.d.ts} +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Type, DynamicModule, ForwardReference, Provider, CanActivate, FactoryProvider } from '@nestjs/common';
|
|
2
|
-
import { SuperAdminProvisioningPort,
|
|
2
|
+
import { SuperAdminProvisioningPort, MfaPort, AuditPort, RlsBypassPort, PlanCatalogReadSink, SubscriptionRepository, PlanVersionRepository, TransactionRunner, AdminResourcesPort, FeatureUiRegistry, PlanCatalog, SaaSiCatPersistenceAdapter, QuotaProvider, SubscriptionUsagePort, UsageSnapshotPort, TenantSubscriptionWritePort, FirstTimeCustomerCheck } from '@saasicat/types';
|
|
3
3
|
import { P as ProviderSpec } from './di-CcNeq9v-.cjs';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { a as SubscriptionContractModuleOptions } from './subscription-contract.module-B2uNvUJL.cjs';
|
|
7
|
-
import { a as PromoCodesModuleOptions } from './module-CHMIyWlf.cjs';
|
|
8
|
-
import { b as DiscoveryAppInfo } from './discovery.scanner-DLgEvuoy.cjs';
|
|
4
|
+
import { d as AdminResourcesModuleOptions, g as AdminStatsModuleOptions, b as AdminManifestConfig } from './admin-resources.module-DGgGSdzN.cjs';
|
|
5
|
+
import { t as TenantBillingModuleOptions, p as SubscriptionBundleModuleOptions, n as SubscriptionBundleControllerOptions } from './tenant-billing.module-BxJS6fX4.cjs';
|
|
9
6
|
import { b as CatalogModuleOptions } from './catalog.module-D-_pQDNA.cjs';
|
|
7
|
+
import { b as DiscoveryAppInfo } from './discovery.scanner-DLgEvuoy.cjs';
|
|
8
|
+
import { E as EntitlementResolutionConfig } from './plan-resolution-CFCoUkrE.cjs';
|
|
9
|
+
import { a as PromoCodesModuleOptions } from './promo.module-DokmUGmm.cjs';
|
|
10
10
|
import { b as CheckoutOfferModuleOptions } from './checkout-offer.module-DmlpPevf.cjs';
|
|
11
|
-
import {
|
|
11
|
+
import { a as SubscriptionContractModuleOptions } from './subscription-contract.module-B2uNvUJL.cjs';
|
|
12
12
|
|
|
13
13
|
interface SetupModuleOptions {
|
|
14
14
|
/**
|
|
@@ -46,7 +46,7 @@ interface PlanResolverPort {
|
|
|
46
46
|
* for local development and for apps that do not yet have a contract concept.
|
|
47
47
|
*
|
|
48
48
|
* The quickstart path uses this implicitly when `adapters.planResolver` is
|
|
49
|
-
* not set and `defaultPlanId` was provided in
|
|
49
|
+
* not set and `defaultPlanId` was provided in SaaSiCatModule.forRoot().
|
|
50
50
|
*/
|
|
51
51
|
declare class StaticPlanResolver implements PlanResolverPort {
|
|
52
52
|
private readonly planId;
|
|
@@ -78,7 +78,7 @@ declare function buildTenantManifestController(options: TenantManifestController
|
|
|
78
78
|
* when wiring adapters without a bundle. The module validates that each port
|
|
79
79
|
* ends up provided by exactly one of the two paths.
|
|
80
80
|
*/
|
|
81
|
-
interface
|
|
81
|
+
interface SaaSiCatAdapters {
|
|
82
82
|
mfa?: ProviderSpec<MfaPort>;
|
|
83
83
|
audit?: ProviderSpec<AuditPort>;
|
|
84
84
|
rlsBypass?: ProviderSpec<RlsBypassPort>;
|
|
@@ -105,7 +105,7 @@ interface SaasPlatformAdapters {
|
|
|
105
105
|
transactionRunner?: ProviderSpec<TransactionRunner>;
|
|
106
106
|
}
|
|
107
107
|
type PlatformImports = Array<Type<unknown> | DynamicModule | Promise<DynamicModule> | ForwardReference>;
|
|
108
|
-
interface
|
|
108
|
+
interface SaaSiCatCatalogOptions extends Pick<CatalogModuleOptions, 'strictModeCheckMode' | 'autoSyncDiscoveryAtBoot' | 'marketedOnlyFeatures' | 'publicMarketingCatalog' | 'extraProviders'> {
|
|
109
109
|
/** Labels/icons used by discovery review and the public catalog. */
|
|
110
110
|
featureUiRegistry: FeatureUiRegistry;
|
|
111
111
|
/** Mount the SuperAdmin catalog controllers. Default `true`. */
|
|
@@ -115,31 +115,31 @@ interface SaasPlatformCatalogOptions extends Pick<CatalogModuleOptions, 'strictM
|
|
|
115
115
|
/** Override the top-level module imports for catalog adapter factories. */
|
|
116
116
|
imports?: PlatformImports;
|
|
117
117
|
}
|
|
118
|
-
type
|
|
119
|
-
interface
|
|
118
|
+
type SaaSiCatTenantAuthGuards = Array<Type<CanActivate>> | ProviderSpec<ReadonlyArray<CanActivate>>;
|
|
119
|
+
interface SaaSiCatTenantBillingOptions extends Omit<TenantBillingModuleOptions, 'authGuards' | 'subscriptionUsagePort' | 'usageSnapshotPort' | 'subscriptionWritePort' | 'global'> {
|
|
120
120
|
/**
|
|
121
121
|
* Tenant guards as classes (the common path) or as a custom provider
|
|
122
122
|
* factory. Guard classes are resolved from `imports`.
|
|
123
123
|
*/
|
|
124
|
-
authGuards:
|
|
124
|
+
authGuards: SaaSiCatTenantAuthGuards;
|
|
125
125
|
/** Optional overrides; otherwise the persistence bundle supplies them. */
|
|
126
126
|
subscriptionUsagePort?: ProviderSpec<SubscriptionUsagePort>;
|
|
127
127
|
usageSnapshotPort?: ProviderSpec<UsageSnapshotPort>;
|
|
128
128
|
subscriptionWritePort?: ProviderSpec<TenantSubscriptionWritePort>;
|
|
129
129
|
}
|
|
130
|
-
interface
|
|
130
|
+
interface SaaSiCatSubscriptionBundlesOptions extends Omit<SubscriptionBundleModuleOptions, 'subscriptionBundleRepository' | 'bundleRepository' | 'controller' | 'imports' | 'extraProviders' | 'global'> {
|
|
131
131
|
/** Default mounts the tenant controller and reuses tenant-billing auth. */
|
|
132
132
|
controller?: false | Omit<SubscriptionBundleControllerOptions, 'authGuards' | 'subscriptionUsagePort'>;
|
|
133
133
|
imports?: PlatformImports;
|
|
134
134
|
extraProviders?: Provider[];
|
|
135
135
|
}
|
|
136
|
-
interface
|
|
136
|
+
interface SaaSiCatAdminResourcesOptions extends Omit<AdminResourcesModuleOptions, 'resources' | 'guards' | 'global'> {
|
|
137
137
|
/** Override the default controller guards + `SuperAdminGuard` chain. */
|
|
138
138
|
guards?: Array<Type<CanActivate>>;
|
|
139
139
|
/** Custom schema override; the persistence bundle supplies the default. */
|
|
140
140
|
resources?: ProviderSpec<AdminResourcesPort>;
|
|
141
141
|
}
|
|
142
|
-
interface
|
|
142
|
+
interface SaaSiCatPromoCodesOptions extends Omit<PromoCodesModuleOptions, 'promoCodeRepository' | 'redemptionRepository' | 'validationLogRepository' | 'subscriptionLookup' | 'revenueAggregator' | 'transactionRunner' | 'firstTimeCustomerCheck' | 'adminController' | 'global'> {
|
|
143
143
|
/**
|
|
144
144
|
* Required when the public preview/redeem flow is enabled. Admin-only
|
|
145
145
|
* setups do not need an app-specific customer-history check.
|
|
@@ -158,27 +158,44 @@ interface SaasPlatformPromoCodesOptions extends Omit<PromoCodesModuleOptions, 'p
|
|
|
158
158
|
adminController?: false;
|
|
159
159
|
}
|
|
160
160
|
/** First-run setup, deriving the provisioning adapter from persistence by default. */
|
|
161
|
-
interface
|
|
161
|
+
interface SaaSiCatSetupOptions extends Omit<SetupModuleOptions, 'provisioningPort' | 'global'> {
|
|
162
162
|
provisioningPort?: SetupModuleOptions['provisioningPort'];
|
|
163
163
|
}
|
|
164
164
|
/** Admin dashboard statistics; the audit port can come from persistence. */
|
|
165
|
-
interface
|
|
165
|
+
interface SaaSiCatAdminStatsOptions extends Omit<AdminStatsModuleOptions, 'auditStatsPort' | 'global'> {
|
|
166
166
|
auditStatsPort?: AdminStatsModuleOptions['auditStatsPort'];
|
|
167
167
|
}
|
|
168
168
|
/**
|
|
169
169
|
* Public checkout-offer flow. Catalog repositories default to the persistence
|
|
170
170
|
* bundle, while the app still supplies its checkout-offer repository.
|
|
171
171
|
*/
|
|
172
|
-
interface
|
|
172
|
+
interface SaaSiCatCheckoutOfferOptions extends Omit<CheckoutOfferModuleOptions, 'bundleRepository' | 'planRepository' | 'catalogEntryRepository' | 'global'> {
|
|
173
173
|
bundleRepository?: CheckoutOfferModuleOptions['bundleRepository'];
|
|
174
174
|
planRepository?: CheckoutOfferModuleOptions['planRepository'];
|
|
175
175
|
catalogEntryRepository?: CheckoutOfferModuleOptions['catalogEntryRepository'];
|
|
176
176
|
}
|
|
177
177
|
/** Subscription-contract service, deriving its repository from persistence by default. */
|
|
178
|
-
interface
|
|
178
|
+
interface SaaSiCatSubscriptionContractOptions extends Omit<SubscriptionContractModuleOptions, 'subscriptionContractRepository' | 'global'> {
|
|
179
179
|
subscriptionContractRepository?: SubscriptionContractModuleOptions['subscriptionContractRepository'];
|
|
180
180
|
}
|
|
181
|
-
|
|
181
|
+
/**
|
|
182
|
+
* What `SaaSiCatModule.forRoot()` composes.
|
|
183
|
+
*
|
|
184
|
+
* One subsystem is deliberately absent: **self-registration**. A prospect
|
|
185
|
+
* signing themselves up — mail address, OTP, plan choice, payment, activation —
|
|
186
|
+
* is `RegistrationModule` from `@saasicat/nest/registration`, and it is
|
|
187
|
+
* hand-wired: ten required ports, none of which a persistence bundle supplies.
|
|
188
|
+
*
|
|
189
|
+
* That is a decision with a reason and a plan, not an omission: the ten ports
|
|
190
|
+
* have no executable contract yet (`@saasicat/persistence-testing` covers the
|
|
191
|
+
* catalogue, subscription, promo and audit ports and none of these), and
|
|
192
|
+
* folding unverified ports into a bundle would move the problem rather than
|
|
193
|
+
* check it. See `docs/self-registration.md`.
|
|
194
|
+
*
|
|
195
|
+
* Everything else — an operator creating tenants through the SuperAdmin UI, a
|
|
196
|
+
* CLI, or your own onboarding form — is composed here.
|
|
197
|
+
*/
|
|
198
|
+
interface SaaSiCatModuleOptions {
|
|
182
199
|
/**
|
|
183
200
|
* Plan catalog. Either as an already-loaded object (quickstart, comes
|
|
184
201
|
* directly from `loadPlanCatalogFromFile('config/saas.yaml')`) or via DB
|
|
@@ -207,12 +224,12 @@ interface SaasPlatformModuleOptions {
|
|
|
207
224
|
* `capabilities` are validated fail-fast against the enabled feature set
|
|
208
225
|
* (e.g. `entitlement: true` requires transactions + pessimistic locking).
|
|
209
226
|
*/
|
|
210
|
-
persistence?:
|
|
227
|
+
persistence?: SaaSiCatPersistenceAdapter;
|
|
211
228
|
/**
|
|
212
229
|
* Individual adapter bindings. Optional when `persistence` provides the
|
|
213
230
|
* respective port; explicit entries take precedence over the bundle.
|
|
214
231
|
*/
|
|
215
|
-
adapters?:
|
|
232
|
+
adapters?: SaaSiCatAdapters;
|
|
216
233
|
/**
|
|
217
234
|
* Class-level guards for the platform controllers (`GET /admin/discovery`
|
|
218
235
|
* and `GET /admin/manifest`). REQUIRED — otherwise the platform throws at
|
|
@@ -299,43 +316,43 @@ interface SaasPlatformModuleOptions {
|
|
|
299
316
|
* Standard DB-backed catalog stack. Repositories are taken from
|
|
300
317
|
* `persistence.catalog`; no consumer forwarding module is needed.
|
|
301
318
|
*/
|
|
302
|
-
catalog?: false |
|
|
319
|
+
catalog?: false | SaaSiCatCatalogOptions;
|
|
303
320
|
/**
|
|
304
321
|
* Standard tenant self-service stack. Subscription read/write adapters
|
|
305
322
|
* come from `persistence.tenantBilling`; usage is derived from
|
|
306
323
|
* `quotaProviders` unless explicitly overridden.
|
|
307
324
|
*/
|
|
308
|
-
tenantBilling?: false |
|
|
325
|
+
tenantBilling?: false | SaaSiCatTenantBillingOptions;
|
|
309
326
|
/**
|
|
310
327
|
* Add-on bundle service and tenant controller. `true` uses defaults and
|
|
311
328
|
* reuses tenant-billing auth/usage; an object customizes policy.
|
|
312
329
|
*/
|
|
313
|
-
subscriptionBundles?: false | true |
|
|
330
|
+
subscriptionBundles?: false | true | SaaSiCatSubscriptionBundlesOptions;
|
|
314
331
|
/**
|
|
315
332
|
* Standard SuperAdmin Tenant/User/Audit/Subscription endpoints. `true`
|
|
316
333
|
* uses `persistence.adminResources` and the standard guard chain.
|
|
317
334
|
*/
|
|
318
|
-
adminResources?: false | true |
|
|
335
|
+
adminResources?: false | true | SaaSiCatAdminResourcesOptions;
|
|
319
336
|
/**
|
|
320
337
|
* Promo-code domain and SuperAdmin CRUD. `true` enables the admin API
|
|
321
338
|
* without the public preview endpoint; pass an object to enable preview.
|
|
322
339
|
*/
|
|
323
|
-
promoCodes?: false | true |
|
|
340
|
+
promoCodes?: false | true | SaaSiCatPromoCodesOptions;
|
|
324
341
|
/**
|
|
325
342
|
* First-run SuperAdmin setup. `true` uses
|
|
326
343
|
* `persistence.core.superAdminProvisioning`; an object customizes it or
|
|
327
344
|
* supplies an app-specific provisioning adapter.
|
|
328
345
|
*/
|
|
329
|
-
setup?: false | true |
|
|
346
|
+
setup?: false | true | SaaSiCatSetupOptions;
|
|
330
347
|
/** SuperAdmin dashboard statistics with app-specific subscription/promo ports. */
|
|
331
|
-
adminStats?: false |
|
|
348
|
+
adminStats?: false | SaaSiCatAdminStatsOptions;
|
|
332
349
|
/** Public checkout-offer flow; catalog repositories reuse `persistence.catalog`. */
|
|
333
|
-
checkoutOffer?: false |
|
|
350
|
+
checkoutOffer?: false | SaaSiCatCheckoutOfferOptions;
|
|
334
351
|
/**
|
|
335
352
|
* Subscription-contract service. `true` reuses
|
|
336
353
|
* `persistence.entitlement.subscriptionContractRepository`.
|
|
337
354
|
*/
|
|
338
|
-
subscriptionContract?: false | true |
|
|
355
|
+
subscriptionContract?: false | true | SaaSiCatSubscriptionContractOptions;
|
|
339
356
|
/**
|
|
340
357
|
* Enable the tenant manifest — the app UI gets a filtered manifest per
|
|
341
358
|
* tenant with features, quotas and visible navigation. Requires that
|
|
@@ -366,28 +383,24 @@ interface SaasPlatformModuleOptions {
|
|
|
366
383
|
* authenticated request.
|
|
367
384
|
*/
|
|
368
385
|
globalFeatureGuard?: boolean;
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
* and override bundle slices field by field.
|
|
388
|
-
*/
|
|
389
|
-
declare class SaasPlatformModule {
|
|
390
|
-
static forRoot(options: SaasPlatformModuleOptions): DynamicModule;
|
|
386
|
+
/**
|
|
387
|
+
* Run the enforcement-chain check at bootstrap. Default `true`.
|
|
388
|
+
*
|
|
389
|
+
* It refuses to start an application whose `@RequireFeature` routes have
|
|
390
|
+
* nothing enforcing them — the failure that otherwise shows up as a
|
|
391
|
+
* customer using a feature they never bought.
|
|
392
|
+
*
|
|
393
|
+
* Two shapes it cannot recognise, and they are the reason this switch
|
|
394
|
+
* exists rather than being an argument about the check: a feature guard of
|
|
395
|
+
* your own that WRAPS ours without carrying `FEATURE_GUARD_MARKER`, and one
|
|
396
|
+
* you bind globally as an `APP_GUARD` instead of per controller. Both are
|
|
397
|
+
* correctly enforced and both look uncovered from here.
|
|
398
|
+
*
|
|
399
|
+
* Turning it off buys silence, not safety: those routes are then unchecked
|
|
400
|
+
* by anything, and whether they are covered is back to being something you
|
|
401
|
+
* know rather than something the boot verifies.
|
|
402
|
+
*/
|
|
403
|
+
enforcementChainCheck?: boolean;
|
|
391
404
|
}
|
|
392
405
|
|
|
393
|
-
export { PLAN_RESOLVER_PORT_TOKEN as P,
|
|
406
|
+
export { PLAN_RESOLVER_PORT_TOKEN as P, type SaaSiCatAdapters as S, type TenantManifestControllerOptions as T, type SaaSiCatAdminResourcesOptions as a, type SaaSiCatAdminStatsOptions as b, type SaaSiCatCatalogOptions as c, type SaaSiCatCheckoutOfferOptions as d, type SaaSiCatModuleOptions as e, type SaaSiCatPromoCodesOptions as f, type SaaSiCatSetupOptions as g, type SaaSiCatSubscriptionBundlesOptions as h, type SaaSiCatSubscriptionContractOptions as i, type SaaSiCatTenantAuthGuards as j, type SaaSiCatTenantBillingOptions as k, SetupModule as l, type SetupModuleOptions as m, StaticPlanResolver as n, type PlanResolverPort as o, buildTenantManifestController as p };
|
|
@@ -1,31 +1,179 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
export {
|
|
7
|
-
import {
|
|
1
|
+
export { a as SAASICAT_PUBLIC_ROUTE_KEY, d as SaaSiCatModule, e as SaaSiCatPublicRoute, S as SetupService, g as defineSaaSiCat, i as isSaaSiCatPublicRoute } from '../define-saasicat-CNUWjfNK.cjs';
|
|
2
|
+
import { CanActivate, DynamicModule, OnApplicationBootstrap } from '@nestjs/common';
|
|
3
|
+
import { SaaSiCatPersistenceAdapter, SubscriptionUsagePort, SubscriptionRepository, UsageSnapshotPort, QuotaProvider } from '@saasicat/types';
|
|
4
|
+
import { P as ProviderSpec } from '../di-CcNeq9v-.cjs';
|
|
5
|
+
import { b as DiscoveryAppInfo } from '../discovery.scanner-DLgEvuoy.cjs';
|
|
6
|
+
export { c as DiscoveryScanner } from '../discovery.scanner-DLgEvuoy.cjs';
|
|
7
|
+
import { e as SaaSiCatModuleOptions, S as SaaSiCatAdapters, o as PlanResolverPort } from '../module-options-DgwBKVpC.cjs';
|
|
8
|
+
export { P as PLAN_RESOLVER_PORT_TOKEN, a as SaaSiCatAdminResourcesOptions, b as SaaSiCatAdminStatsOptions, c as SaaSiCatCatalogOptions, d as SaaSiCatCheckoutOfferOptions, f as SaaSiCatPromoCodesOptions, g as SaaSiCatSetupOptions, h as SaaSiCatSubscriptionBundlesOptions, i as SaaSiCatSubscriptionContractOptions, j as SaaSiCatTenantAuthGuards, k as SaaSiCatTenantBillingOptions, l as SetupModule, m as SetupModuleOptions, n as StaticPlanResolver, T as TenantManifestControllerOptions, p as buildTenantManifestController } from '../module-options-DgwBKVpC.cjs';
|
|
9
|
+
import { S as StaticEntitlementService } from '../enforce-quota.interceptor-BxIR63Wn.cjs';
|
|
10
|
+
export { E as EnforceQuotaInterceptor, Q as QUOTA_PROVIDERS_TOKEN, b as STATIC_FEATURE_GUARD_CONFIG_TOKEN, c as StaticEntitlementSnapshot, a as StaticFeatureGuard, d as StaticFeatureGuardConfig } from '../enforce-quota.interceptor-BxIR63Wn.cjs';
|
|
8
11
|
import { DiscoveryService, MetadataScanner } from '@nestjs/core';
|
|
9
|
-
export { A as AdminBypassRlsInterceptor, a as AdminManifestModule, b as AdminManifestModuleOptions, c as AdminManifestService, d as AdminModule, e as AdminModuleOptions, f as AdminStatsService, M as MfaGuard, h as MfaService, S as SuperAdminGuard } from '../admin-stats.service-
|
|
12
|
+
export { A as AdminBypassRlsInterceptor, a as AdminManifestModule, b as AdminManifestModuleOptions, c as AdminManifestService, d as AdminModule, e as AdminModuleOptions, f as AdminStatsService, M as MfaGuard, h as MfaService, S as SuperAdminGuard } from '../admin-stats.service-BroyovpL.cjs';
|
|
10
13
|
export { A as AdminAuditService } from '../admin-audit.service-9IqXMlZm.cjs';
|
|
11
14
|
export { e as AdminResourcesService, f as AdminStatsModule, g as AdminStatsModuleOptions } from '../admin-resources.module-DGgGSdzN.cjs';
|
|
12
15
|
export { c as EntitlementService } from '../aggregation-mZ7WZROK.cjs';
|
|
13
|
-
export { d as ComposedTenantAuthGuard, P as PendingPlanMaterializationService, h as PlanChangePreviewService, r as SubscriptionBundlePreviewService, s as SubscriptionBundlesService, T as TenantAdminGuard, t as TenantBillingController } from '../tenant-billing.controller-
|
|
16
|
+
export { d as ComposedTenantAuthGuard, P as PendingPlanMaterializationService, h as PlanChangePreviewService, r as SubscriptionBundlePreviewService, s as SubscriptionBundlesService, T as TenantAdminGuard, t as TenantBillingController } from '../tenant-billing.controller-CODIYzlI.cjs';
|
|
14
17
|
export { B as BundlesService, C as CatalogEntriesService, M as MarketingProjectionsService, b as MarketingSettingsService, P as PlanVersionsService, c as PlansService, d as PromotionsService, e as PublicMarketingCatalogService } from '../plan-versions.service-_saKzb50.cjs';
|
|
15
|
-
export { c as DiscoveryScanner } from '../discovery.scanner-DLgEvuoy.cjs';
|
|
16
18
|
export { P as PromoCodeRateLimitGuard } from '../rate-limit.guard-dntqAlfZ.cjs';
|
|
17
|
-
export { g as PromoCodesService } from '../service-D48clObR.cjs';
|
|
19
|
+
export { g as PromoCodesService } from '../promo.service-D48clObR.cjs';
|
|
18
20
|
export { a as CheckoutOfferModule, b as CheckoutOfferModuleOptions } from '../checkout-offer.module-DmlpPevf.cjs';
|
|
19
21
|
export { C as CheckoutOfferService } from '../checkout-offer.service-BX51dljL.cjs';
|
|
20
22
|
export { S as SubscriptionContractModule, a as SubscriptionContractModuleOptions } from '../subscription-contract.module-B2uNvUJL.cjs';
|
|
21
23
|
export { S as SubscriptionContractService } from '../subscription-contract.service--cm47ZJJ.cjs';
|
|
22
|
-
import '../
|
|
23
|
-
import '../plan-resolution-CFCoUkrE.cjs';
|
|
24
|
-
import '../module-CHMIyWlf.cjs';
|
|
24
|
+
import '../tenant-billing.module-BxJS6fX4.cjs';
|
|
25
25
|
import '../catalog.module-D-_pQDNA.cjs';
|
|
26
|
-
import '../
|
|
26
|
+
import '../plan-resolution-CFCoUkrE.cjs';
|
|
27
|
+
import '../promo.module-DokmUGmm.cjs';
|
|
27
28
|
import 'rxjs';
|
|
28
29
|
|
|
30
|
+
/**
|
|
31
|
+
* What `tenantBilling` resolved and its two dependants need.
|
|
32
|
+
*
|
|
33
|
+
* Mutable, and the only mutable thing here: `composeTenantBilling` writes it,
|
|
34
|
+
* `composeSubscriptionBundles` and the entitlement runtime read it. A composer
|
|
35
|
+
* that runs before tenant billing sees the initial values, which is correct —
|
|
36
|
+
* there was no tenant billing to resolve anything.
|
|
37
|
+
*/
|
|
38
|
+
interface SharedTenantBinding {
|
|
39
|
+
/** Normalised `authGuards`, shared with the bundle controller. */
|
|
40
|
+
authGuards?: ProviderSpec<ReadonlyArray<CanActivate>>;
|
|
41
|
+
/** The usage port both controllers report against. */
|
|
42
|
+
subscriptionUsagePort?: ProviderSpec<SubscriptionUsagePort>;
|
|
43
|
+
/**
|
|
44
|
+
* Whether the tenant-billing module already registered the app's quota
|
|
45
|
+
* providers.
|
|
46
|
+
*
|
|
47
|
+
* It registers them as its own providers and exports, so the entitlement
|
|
48
|
+
* runtime must not register them a second time — two instances of a
|
|
49
|
+
* `QuotaProvider` are two counters over the same rows.
|
|
50
|
+
*/
|
|
51
|
+
quotaProvidersHostedByTenantBilling: boolean;
|
|
52
|
+
}
|
|
53
|
+
interface CompositionContext {
|
|
54
|
+
readonly options: SaaSiCatModuleOptions;
|
|
55
|
+
/** After the bundle slices and the explicit entries have been merged. */
|
|
56
|
+
readonly adapters: SaaSiCatAdapters;
|
|
57
|
+
readonly persistence: SaaSiCatPersistenceAdapter | undefined;
|
|
58
|
+
/** App key and version, for discovery and the public catalogue. */
|
|
59
|
+
readonly appInfo: DiscoveryAppInfo;
|
|
60
|
+
/** Entitlement is needed directly, or by tenant billing / bundles. */
|
|
61
|
+
readonly requiresFullEntitlement: boolean;
|
|
62
|
+
readonly shared: SharedTenantBinding;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** One feature's contribution: the modules it adds, or none. */
|
|
66
|
+
type Composer = (ctx: CompositionContext) => DynamicModule[];
|
|
67
|
+
declare const FEATURE_COMPOSERS: readonly Composer[];
|
|
68
|
+
/** Every module the enabled features contribute, in composer order. */
|
|
69
|
+
declare function composeFeatures(ctx: CompositionContext): DynamicModule[];
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Mounted on purpose and deliberately not re-exported.
|
|
73
|
+
*
|
|
74
|
+
* Declared here rather than left as an absence, because the guard in
|
|
75
|
+
* `tests/platform-composition.test.js` otherwise reports it every time and the
|
|
76
|
+
* next person has to re-derive whether it is a bug.
|
|
77
|
+
*
|
|
78
|
+
* `PublicCatalogModule` is a controller and one token, `FEATURE_UI_REGISTRY` —
|
|
79
|
+
* which the APP supplies through `catalog: { featureUiRegistry }` rather than
|
|
80
|
+
* injects. Re-exporting it would also collide with the identically named token
|
|
81
|
+
* from `billing`, which means something else (see CONTRIBUTING, "One bundle,
|
|
82
|
+
* many entries").
|
|
83
|
+
*/
|
|
84
|
+
declare const MOUNTED_BUT_NOT_EXPORTED: readonly string[];
|
|
85
|
+
/** The `exports` of the assembled module, plus whatever it provides itself. */
|
|
86
|
+
declare function composeModuleExports(ctx: CompositionContext, ownExports: NonNullable<DynamicModule['exports']>): NonNullable<DynamicModule['exports']>;
|
|
87
|
+
|
|
88
|
+
/** Everything a rule may look at: the options as given, the adapters as resolved. */
|
|
89
|
+
interface PlatformConfiguration {
|
|
90
|
+
readonly options: SaaSiCatModuleOptions;
|
|
91
|
+
/** After the bundle slices and the explicit entries have been merged. */
|
|
92
|
+
readonly adapters: SaaSiCatAdapters;
|
|
93
|
+
}
|
|
94
|
+
interface PlatformRule {
|
|
95
|
+
/** Stable id — `<area>.<what-it-requires>`. Appears in the boot error. */
|
|
96
|
+
readonly id: string;
|
|
97
|
+
/** Whether this rule has anything to say about this configuration. */
|
|
98
|
+
readonly when: (c: PlatformConfiguration) => boolean;
|
|
99
|
+
/** True when the configuration satisfies it. */
|
|
100
|
+
readonly assert: (c: PlatformConfiguration) => boolean;
|
|
101
|
+
/**
|
|
102
|
+
* What is wrong and what to do about it.
|
|
103
|
+
*
|
|
104
|
+
* A function only where it has to be: several of these name which of a set
|
|
105
|
+
* is missing, and "adapters are missing: subscriptionRepository,
|
|
106
|
+
* transactionRunner" is worth more than "adapters are missing". The rest
|
|
107
|
+
* are the same sentence every time, and a closure that ignores its argument
|
|
108
|
+
* is one more thing a reader has to check for.
|
|
109
|
+
*/
|
|
110
|
+
readonly message: string | ((c: PlatformConfiguration) => string);
|
|
111
|
+
/**
|
|
112
|
+
* Where the option is documented.
|
|
113
|
+
*
|
|
114
|
+
* Derived from the id rather than written beside it — see `docsUrlFor`.
|
|
115
|
+
*/
|
|
116
|
+
readonly docs: string;
|
|
117
|
+
/**
|
|
118
|
+
* The typed error this rule threw before the table existed, when it has
|
|
119
|
+
* one.
|
|
120
|
+
*
|
|
121
|
+
* Used only when this rule is the ONLY violation — and that is not a
|
|
122
|
+
* compromise, it is the exact set of cases where the typed error was ever
|
|
123
|
+
* observable. A configuration with two problems used to throw whichever
|
|
124
|
+
* check ran first and stop, so nothing could catch the second one by type
|
|
125
|
+
* either. Where a consumer could see `PersistenceCapabilityError`, it still
|
|
126
|
+
* sees it; where it could not, it now gets the full list instead of one
|
|
127
|
+
* arbitrary problem.
|
|
128
|
+
*/
|
|
129
|
+
readonly error?: (c: PlatformConfiguration) => Error;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* GitHub's heading slug for `text`: lowercased, punctuation dropped, spaces
|
|
133
|
+
* hyphenated.
|
|
134
|
+
*
|
|
135
|
+
* Written out because the anchor has to match a heading nobody types — the
|
|
136
|
+
* page is generated. `tests/options-reference-is-generated.test.js` asserts
|
|
137
|
+
* every rule's anchor is a heading in the file, so a wrong slug fails the build
|
|
138
|
+
* rather than producing a link that lands at the top of the page.
|
|
139
|
+
*/
|
|
140
|
+
declare const headingSlug: (text: string) => string;
|
|
141
|
+
/**
|
|
142
|
+
* The documentation link for a rule.
|
|
143
|
+
*
|
|
144
|
+
* Derived from the id, so the two cannot disagree. They did, on the first
|
|
145
|
+
* attempt: eleven hand-written anchors against headings the generator names
|
|
146
|
+
* after the ids, and every one of them landed at the top of the page.
|
|
147
|
+
*/
|
|
148
|
+
declare const docsUrlFor: (id: string) => string;
|
|
149
|
+
declare const PLATFORM_RULES: readonly PlatformRule[];
|
|
150
|
+
|
|
151
|
+
interface PlatformViolation {
|
|
152
|
+
readonly id: string;
|
|
153
|
+
readonly message: string;
|
|
154
|
+
readonly docs: string;
|
|
155
|
+
}
|
|
156
|
+
/** Every rule that applies to this configuration and is not satisfied by it. */
|
|
157
|
+
declare function findViolations(configuration: PlatformConfiguration, rules?: readonly PlatformRule[]): PlatformViolation[];
|
|
158
|
+
/**
|
|
159
|
+
* The error a misconfigured application boots into.
|
|
160
|
+
*
|
|
161
|
+
* Carries the violations as data as well as prose: a consumer's own boot
|
|
162
|
+
* diagnostics can group them, and the rule ids are stable enough to assert on.
|
|
163
|
+
*/
|
|
164
|
+
declare class SaaSiCatConfigurationError extends Error {
|
|
165
|
+
readonly violations: readonly PlatformViolation[];
|
|
166
|
+
constructor(violations: readonly PlatformViolation[]);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Throws once, naming every problem, or returns.
|
|
170
|
+
*
|
|
171
|
+
* A single violation from a rule that owns a typed error raises that error
|
|
172
|
+
* instead of the aggregate — see `PlatformRule.error` for why that is the
|
|
173
|
+
* whole of the previous behaviour rather than part of it.
|
|
174
|
+
*/
|
|
175
|
+
declare function assertConfiguration(configuration: PlatformConfiguration, rules?: readonly PlatformRule[]): void;
|
|
176
|
+
|
|
29
177
|
/**
|
|
30
178
|
* Standard `tenantId → planId` resolver backed by the canonical subscription
|
|
31
179
|
* repository. This removes the identical resolver class most applications
|
|
@@ -48,22 +196,56 @@ declare class QuotaProvidersUsageSnapshot implements UsageSnapshotPort {
|
|
|
48
196
|
snapshot(tenantId: string): Promise<Record<string, number>>;
|
|
49
197
|
}
|
|
50
198
|
|
|
51
|
-
|
|
199
|
+
/** What the module knows at composition time and this check cannot see. */
|
|
200
|
+
interface EnforcementChainState {
|
|
201
|
+
/**
|
|
202
|
+
* Whether anything can enforce `@RequireFeature`.
|
|
203
|
+
*
|
|
204
|
+
* True on the static path, and also on the V3 path, where the application
|
|
205
|
+
* binds `FeatureGuard` from `@saasicat/nest/billing` itself.
|
|
206
|
+
*/
|
|
207
|
+
readonly featureEnforcementActive: boolean;
|
|
208
|
+
/**
|
|
209
|
+
* Whether anything can enforce `@EnforceQuota`.
|
|
210
|
+
*
|
|
211
|
+
* Narrower than the field above, and the two were one field until an app
|
|
212
|
+
* on the V3 path with no plan resolver booted with every quota unenforced:
|
|
213
|
+
* `EnforceQuotaInterceptor` comes from `composeEnforcementRuntime`, which
|
|
214
|
+
* registers nothing unless a plan resolver exists. A flag named for
|
|
215
|
+
* "entitlement" answered a question about features and was read as an
|
|
216
|
+
* answer about quotas.
|
|
217
|
+
*/
|
|
218
|
+
readonly quotaEnforcementActive: boolean;
|
|
219
|
+
/** Whether the platform bound its own global feature guard. */
|
|
220
|
+
readonly globalGuardBound: boolean;
|
|
221
|
+
/**
|
|
222
|
+
* Whether `globalFeatureGuard: false` is what unbound it.
|
|
223
|
+
*
|
|
224
|
+
* Distinct from `globalGuardBound` because the two have different causes
|
|
225
|
+
* and the message has to say the true one. On the V3 entitlement path the
|
|
226
|
+
* platform binds no global guard either — it never registers the static
|
|
227
|
+
* stack — and naming an option the application did not set sends the reader
|
|
228
|
+
* to look for a line that is not in their file.
|
|
229
|
+
*/
|
|
230
|
+
readonly globalGuardOptedOut: boolean;
|
|
231
|
+
}
|
|
232
|
+
declare const ENFORCEMENT_CHAIN_STATE_TOKEN: unique symbol;
|
|
233
|
+
declare class EnforcementChainCheck implements OnApplicationBootstrap {
|
|
52
234
|
private readonly discoveryService;
|
|
53
235
|
private readonly metadataScanner;
|
|
54
|
-
private readonly
|
|
55
|
-
constructor(discoveryService: DiscoveryService, metadataScanner: MetadataScanner);
|
|
236
|
+
private readonly state;
|
|
237
|
+
constructor(discoveryService: DiscoveryService, metadataScanner: MetadataScanner, state?: EnforcementChainState);
|
|
56
238
|
onApplicationBootstrap(): void;
|
|
57
239
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
240
|
+
* Every route carrying an enforcement annotation, with whether a
|
|
241
|
+
* recognisable feature guard covers it.
|
|
60
242
|
*
|
|
61
243
|
* Deliberately conservative in one direction only: an unrecognised wrapper
|
|
62
244
|
* is reported (and the message says so) rather than assumed safe, because
|
|
63
245
|
* the named route is cheap to check. The reverse — staying silent about a
|
|
64
246
|
* route with no guard at all — is the failure this exists to prevent.
|
|
65
247
|
*/
|
|
66
|
-
private
|
|
248
|
+
private findAnnotatedRoutes;
|
|
67
249
|
}
|
|
68
250
|
|
|
69
251
|
interface TenantNavItem {
|
|
@@ -119,4 +301,4 @@ declare class TenantManifestService {
|
|
|
119
301
|
getManifest(tenantId: string): Promise<TenantManifest>;
|
|
120
302
|
}
|
|
121
303
|
|
|
122
|
-
export {
|
|
304
|
+
export { type Composer, type CompositionContext, ENFORCEMENT_CHAIN_STATE_TOKEN, EnforcementChainCheck, type EnforcementChainState, FEATURE_COMPOSERS, MOUNTED_BUT_NOT_EXPORTED, PLATFORM_RULES, PlanResolverPort, type PlatformConfiguration, type PlatformRule, type PlatformViolation, QuotaProvidersUsageSnapshot, SaaSiCatAdapters, SaaSiCatConfigurationError, SaaSiCatModuleOptions, StaticEntitlementService, SubscriptionPlanResolver, type TenantManifest, TenantManifestService, type TenantNavItem, assertConfiguration, composeFeatures, composeModuleExports, docsUrlFor, findViolations, headingSlug };
|