@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.
- package/LICENSE +202 -0
- package/README.md +53 -0
- package/dist/admin/index.cjs +1283 -0
- package/dist/admin/index.d.cts +225 -0
- package/dist/admin/index.d.ts +225 -0
- package/dist/admin/index.js +58 -0
- package/dist/admin-audit.service-9IqXMlZm.d.cts +30 -0
- package/dist/admin-audit.service-9IqXMlZm.d.ts +30 -0
- package/dist/admin-manifest.config-DyrQNT7M.d.cts +10 -0
- package/dist/admin-manifest.config-DyrQNT7M.d.ts +10 -0
- package/dist/aggregation-CJ3qQf92.d.cts +288 -0
- package/dist/aggregation-Dvz9e8X2.d.ts +288 -0
- package/dist/billing/index.cjs +5205 -0
- package/dist/billing/index.d.cts +1326 -0
- package/dist/billing/index.d.ts +1326 -0
- package/dist/billing/index.js +197 -0
- package/dist/catalog/index.cjs +6449 -0
- package/dist/catalog/index.d.cts +1073 -0
- package/dist/catalog/index.d.ts +1073 -0
- package/dist/catalog/index.js +158 -0
- package/dist/checkout-offer/index.cjs +807 -0
- package/dist/checkout-offer/index.d.cts +120 -0
- package/dist/checkout-offer/index.d.ts +120 -0
- package/dist/checkout-offer/index.js +20 -0
- package/dist/chunk-2FR6ZL7R.js +0 -0
- package/dist/chunk-2PNX2QL2.js +347 -0
- package/dist/chunk-2VNZYRDV.js +326 -0
- package/dist/chunk-7MLGHWKO.js +12 -0
- package/dist/chunk-ABB2CRAS.js +31 -0
- package/dist/chunk-AJ3EPELS.js +157 -0
- package/dist/chunk-E56W4U2P.js +90 -0
- package/dist/chunk-HRU3CP57.js +71 -0
- package/dist/chunk-L4SUWH5B.js +14 -0
- package/dist/chunk-M6CZQYPY.js +314 -0
- package/dist/chunk-MDIZUVIK.js +87 -0
- package/dist/chunk-MV6LW5UB.js +217 -0
- package/dist/chunk-NYLON2VC.js +6 -0
- package/dist/chunk-P6MYZMXQ.js +951 -0
- package/dist/chunk-Q53N43LQ.js +13 -0
- package/dist/chunk-QJVPRD3R.js +573 -0
- package/dist/chunk-RIGLQ4BV.js +3367 -0
- package/dist/chunk-SABTXESR.js +24 -0
- package/dist/chunk-SHUYVCID.js +6 -0
- package/dist/chunk-SYEVGPFC.js +686 -0
- package/dist/chunk-V7HUZ6UQ.js +5923 -0
- package/dist/chunk-WPUVJRIN.js +29 -0
- package/dist/chunk-XCZ3TTFK.js +22 -0
- package/dist/chunk-XSGU2Y2O.js +1611 -0
- package/dist/chunk-YNEW3L63.js +190 -0
- package/dist/chunk-YXGHPILG.js +614 -0
- package/dist/chunk-ZL4LLE2Z.js +465 -0
- package/dist/di-CcNeq9v-.d.cts +16 -0
- package/dist/di-CcNeq9v-.d.ts +16 -0
- package/dist/discovery/index.cjs +588 -0
- package/dist/discovery/index.d.cts +299 -0
- package/dist/discovery/index.d.ts +299 -0
- package/dist/discovery/index.js +49 -0
- package/dist/discovery.scanner-CUYLKlYT.d.cts +59 -0
- package/dist/discovery.scanner-CUYLKlYT.d.ts +59 -0
- package/dist/entitlement/index.cjs +805 -0
- package/dist/entitlement/index.d.cts +60 -0
- package/dist/entitlement/index.d.ts +60 -0
- package/dist/entitlement/index.js +57 -0
- package/dist/index.cjs +15918 -0
- package/dist/index.d.cts +85 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.js +956 -0
- package/dist/plan-resolution-CFCoUkrE.d.cts +41 -0
- package/dist/plan-resolution-CFCoUkrE.d.ts +41 -0
- package/dist/platform/index.cjs +2772 -0
- package/dist/platform/index.d.cts +118 -0
- package/dist/platform/index.d.ts +118 -0
- package/dist/platform/index.js +37 -0
- package/dist/promo/index.cjs +995 -0
- package/dist/promo/index.d.cts +121 -0
- package/dist/promo/index.d.ts +121 -0
- package/dist/promo/index.js +58 -0
- package/dist/registration/index.cjs +1687 -0
- package/dist/registration/index.d.cts +444 -0
- package/dist/registration/index.d.ts +444 -0
- package/dist/registration/index.js +82 -0
- package/dist/saas-platform.module-CgZ2omgg.d.cts +180 -0
- package/dist/saas-platform.module-DT9TnCzk.d.ts +180 -0
- package/dist/service-DX8KbGXl.d.cts +109 -0
- package/dist/service-DX8KbGXl.d.ts +109 -0
- package/dist/subscription-contract/index.cjs +471 -0
- package/dist/subscription-contract/index.d.cts +17 -0
- package/dist/subscription-contract/index.d.ts +17 -0
- package/dist/subscription-contract/index.js +21 -0
- package/dist/subscription-contract.service--cm47ZJJ.d.cts +39 -0
- package/dist/subscription-contract.service--cm47ZJJ.d.ts +39 -0
- package/dist/testing/index.cjs +3942 -0
- package/dist/testing/index.d.cts +279 -0
- package/dist/testing/index.d.ts +279 -0
- package/dist/testing/index.js +1195 -0
- package/package.json +185 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { P as PlanResolverPort } from '../saas-platform.module-CgZ2omgg.cjs';
|
|
2
|
+
export { a as PLAN_RESOLVER_PORT_TOKEN, b as SaasPlatformAdapters, c as SaasPlatformModule, S as SaasPlatformModuleOptions, d as StaticPlanResolver, T as TenantManifestControllerOptions, e as buildTenantManifestController } from '../saas-platform.module-CgZ2omgg.cjs';
|
|
3
|
+
import { PlanCatalog, QuotaProvider } from '@saasicat/types';
|
|
4
|
+
import { CanActivate, ExecutionContext, NestInterceptor, CallHandler } from '@nestjs/common';
|
|
5
|
+
import { Reflector } from '@nestjs/core';
|
|
6
|
+
import { Observable } from 'rxjs';
|
|
7
|
+
import '../di-CcNeq9v-.cjs';
|
|
8
|
+
import '../admin-manifest.config-DyrQNT7M.cjs';
|
|
9
|
+
import '../discovery.scanner-CUYLKlYT.cjs';
|
|
10
|
+
import '../plan-resolution-CFCoUkrE.cjs';
|
|
11
|
+
|
|
12
|
+
interface StaticEntitlementSnapshot {
|
|
13
|
+
planId: string | null;
|
|
14
|
+
features: readonly string[];
|
|
15
|
+
/** quotaKey → limit (`-1` = unlimited). */
|
|
16
|
+
quotas: Readonly<Record<string, number>>;
|
|
17
|
+
}
|
|
18
|
+
declare class StaticEntitlementService {
|
|
19
|
+
private readonly catalog;
|
|
20
|
+
private readonly resolver;
|
|
21
|
+
constructor(catalog: PlanCatalog, resolver: PlanResolverPort);
|
|
22
|
+
/**
|
|
23
|
+
* Returns the effective features + quotas of a tenant from the
|
|
24
|
+
* plan catalog. When the plan is missing: an empty snapshot (no feature,
|
|
25
|
+
* all quotas at 0).
|
|
26
|
+
*/
|
|
27
|
+
snapshot(tenantId: string): Promise<StaticEntitlementSnapshot>;
|
|
28
|
+
/** Convenience helper for tests / synchronous checks in the UI manifest. */
|
|
29
|
+
hasFeature(tenantId: string, featureKey: string): Promise<boolean>;
|
|
30
|
+
quotaLimit(tenantId: string, quotaKey: string): Promise<number | null>;
|
|
31
|
+
private findPlan;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare const STATIC_FEATURE_GUARD_CONFIG_TOKEN: unique symbol;
|
|
35
|
+
interface StaticFeatureGuardConfig {
|
|
36
|
+
/**
|
|
37
|
+
* Resolver for the user role (e.g. `(user) => user.platformRole`).
|
|
38
|
+
* SUPER_ADMIN gets a bypass.
|
|
39
|
+
*/
|
|
40
|
+
userRoleResolver?: (user: unknown) => string | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Resolver for the tenant ID from the request. Default:
|
|
43
|
+
* `request.tenantId ?? request.user?.tenantId`.
|
|
44
|
+
*/
|
|
45
|
+
tenantIdResolver?: (request: unknown) => string | undefined;
|
|
46
|
+
}
|
|
47
|
+
declare class StaticFeatureGuard implements CanActivate {
|
|
48
|
+
private readonly reflector;
|
|
49
|
+
private readonly entitlements;
|
|
50
|
+
private readonly config;
|
|
51
|
+
constructor(reflector: Reflector, entitlements: StaticEntitlementService, config?: StaticFeatureGuardConfig | null);
|
|
52
|
+
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
declare const QUOTA_PROVIDERS_TOKEN: unique symbol;
|
|
56
|
+
declare class EnforceQuotaInterceptor implements NestInterceptor {
|
|
57
|
+
private readonly reflector;
|
|
58
|
+
private readonly entitlements;
|
|
59
|
+
private readonly providers;
|
|
60
|
+
constructor(reflector: Reflector, entitlements: StaticEntitlementService, providers?: ReadonlyArray<QuotaProvider> | null);
|
|
61
|
+
intercept(context: ExecutionContext, next: CallHandler): Observable<unknown>;
|
|
62
|
+
private check;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
interface TenantNavItem {
|
|
66
|
+
/** Unique slug, e.g. "notes", "billing", "settings". */
|
|
67
|
+
id: string;
|
|
68
|
+
/** Display label (translatable — see AdminManifest for the pattern). */
|
|
69
|
+
label: string;
|
|
70
|
+
/** Frontend route, e.g. "/notes". */
|
|
71
|
+
path: string;
|
|
72
|
+
/** Optional: Quasar/Material icon. */
|
|
73
|
+
icon?: string;
|
|
74
|
+
/** Sort priority, lower = higher up. Default 100. */
|
|
75
|
+
order?: number;
|
|
76
|
+
/**
|
|
77
|
+
* When set, the item is only visible if the tenant has **one** of these
|
|
78
|
+
* features. The backend filters server-side — the app can rely on only
|
|
79
|
+
* permitted items being present in the manifest.
|
|
80
|
+
*/
|
|
81
|
+
requiresFeature?: string | readonly string[];
|
|
82
|
+
}
|
|
83
|
+
interface TenantManifest {
|
|
84
|
+
schemaVersion: 1;
|
|
85
|
+
/** Tenant identity the manifest is bound to. */
|
|
86
|
+
tenant: {
|
|
87
|
+
id: string;
|
|
88
|
+
};
|
|
89
|
+
/** Active plan (from PlanResolverPort or SubscriptionContract). */
|
|
90
|
+
planId: string | null;
|
|
91
|
+
/** Unlocked features (set as array). */
|
|
92
|
+
features: readonly string[];
|
|
93
|
+
/** quotaKey → limit (`-1` = unlimited). */
|
|
94
|
+
quotas: Readonly<Record<string, number>>;
|
|
95
|
+
/** Visible navigation, already filtered by feature. */
|
|
96
|
+
navigation: TenantNavItem[];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
declare class TenantManifestService {
|
|
100
|
+
private readonly entitlements;
|
|
101
|
+
private readonly navItems;
|
|
102
|
+
constructor(entitlements: StaticEntitlementService);
|
|
103
|
+
/**
|
|
104
|
+
* Call in the app's `OnModuleInit`: registers app navigation for the
|
|
105
|
+
* Tenant UI. Idempotent: the same `id` overwrites.
|
|
106
|
+
*/
|
|
107
|
+
registerNavItem(item: TenantNavItem): void;
|
|
108
|
+
/** Bulk variant. */
|
|
109
|
+
registerNavItems(items: TenantNavItem[]): void;
|
|
110
|
+
/**
|
|
111
|
+
* Returns the filtered manifest for a Tenant. NavItems with
|
|
112
|
+
* `requiresFeature` are filtered out server-side as soon as none of the
|
|
113
|
+
* required features are present in the entitlement snapshot.
|
|
114
|
+
*/
|
|
115
|
+
getManifest(tenantId: string): Promise<TenantManifest>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export { EnforceQuotaInterceptor, PlanResolverPort, QUOTA_PROVIDERS_TOKEN, STATIC_FEATURE_GUARD_CONFIG_TOKEN, StaticEntitlementService, type StaticEntitlementSnapshot, StaticFeatureGuard, type StaticFeatureGuardConfig, type TenantManifest, TenantManifestService, type TenantNavItem };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { P as PlanResolverPort } from '../saas-platform.module-DT9TnCzk.js';
|
|
2
|
+
export { a as PLAN_RESOLVER_PORT_TOKEN, b as SaasPlatformAdapters, c as SaasPlatformModule, S as SaasPlatformModuleOptions, d as StaticPlanResolver, T as TenantManifestControllerOptions, e as buildTenantManifestController } from '../saas-platform.module-DT9TnCzk.js';
|
|
3
|
+
import { PlanCatalog, QuotaProvider } from '@saasicat/types';
|
|
4
|
+
import { CanActivate, ExecutionContext, NestInterceptor, CallHandler } from '@nestjs/common';
|
|
5
|
+
import { Reflector } from '@nestjs/core';
|
|
6
|
+
import { Observable } from 'rxjs';
|
|
7
|
+
import '../di-CcNeq9v-.js';
|
|
8
|
+
import '../admin-manifest.config-DyrQNT7M.js';
|
|
9
|
+
import '../discovery.scanner-CUYLKlYT.js';
|
|
10
|
+
import '../plan-resolution-CFCoUkrE.js';
|
|
11
|
+
|
|
12
|
+
interface StaticEntitlementSnapshot {
|
|
13
|
+
planId: string | null;
|
|
14
|
+
features: readonly string[];
|
|
15
|
+
/** quotaKey → limit (`-1` = unlimited). */
|
|
16
|
+
quotas: Readonly<Record<string, number>>;
|
|
17
|
+
}
|
|
18
|
+
declare class StaticEntitlementService {
|
|
19
|
+
private readonly catalog;
|
|
20
|
+
private readonly resolver;
|
|
21
|
+
constructor(catalog: PlanCatalog, resolver: PlanResolverPort);
|
|
22
|
+
/**
|
|
23
|
+
* Returns the effective features + quotas of a tenant from the
|
|
24
|
+
* plan catalog. When the plan is missing: an empty snapshot (no feature,
|
|
25
|
+
* all quotas at 0).
|
|
26
|
+
*/
|
|
27
|
+
snapshot(tenantId: string): Promise<StaticEntitlementSnapshot>;
|
|
28
|
+
/** Convenience helper for tests / synchronous checks in the UI manifest. */
|
|
29
|
+
hasFeature(tenantId: string, featureKey: string): Promise<boolean>;
|
|
30
|
+
quotaLimit(tenantId: string, quotaKey: string): Promise<number | null>;
|
|
31
|
+
private findPlan;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare const STATIC_FEATURE_GUARD_CONFIG_TOKEN: unique symbol;
|
|
35
|
+
interface StaticFeatureGuardConfig {
|
|
36
|
+
/**
|
|
37
|
+
* Resolver for the user role (e.g. `(user) => user.platformRole`).
|
|
38
|
+
* SUPER_ADMIN gets a bypass.
|
|
39
|
+
*/
|
|
40
|
+
userRoleResolver?: (user: unknown) => string | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Resolver for the tenant ID from the request. Default:
|
|
43
|
+
* `request.tenantId ?? request.user?.tenantId`.
|
|
44
|
+
*/
|
|
45
|
+
tenantIdResolver?: (request: unknown) => string | undefined;
|
|
46
|
+
}
|
|
47
|
+
declare class StaticFeatureGuard implements CanActivate {
|
|
48
|
+
private readonly reflector;
|
|
49
|
+
private readonly entitlements;
|
|
50
|
+
private readonly config;
|
|
51
|
+
constructor(reflector: Reflector, entitlements: StaticEntitlementService, config?: StaticFeatureGuardConfig | null);
|
|
52
|
+
canActivate(context: ExecutionContext): Promise<boolean>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
declare const QUOTA_PROVIDERS_TOKEN: unique symbol;
|
|
56
|
+
declare class EnforceQuotaInterceptor implements NestInterceptor {
|
|
57
|
+
private readonly reflector;
|
|
58
|
+
private readonly entitlements;
|
|
59
|
+
private readonly providers;
|
|
60
|
+
constructor(reflector: Reflector, entitlements: StaticEntitlementService, providers?: ReadonlyArray<QuotaProvider> | null);
|
|
61
|
+
intercept(context: ExecutionContext, next: CallHandler): Observable<unknown>;
|
|
62
|
+
private check;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
interface TenantNavItem {
|
|
66
|
+
/** Unique slug, e.g. "notes", "billing", "settings". */
|
|
67
|
+
id: string;
|
|
68
|
+
/** Display label (translatable — see AdminManifest for the pattern). */
|
|
69
|
+
label: string;
|
|
70
|
+
/** Frontend route, e.g. "/notes". */
|
|
71
|
+
path: string;
|
|
72
|
+
/** Optional: Quasar/Material icon. */
|
|
73
|
+
icon?: string;
|
|
74
|
+
/** Sort priority, lower = higher up. Default 100. */
|
|
75
|
+
order?: number;
|
|
76
|
+
/**
|
|
77
|
+
* When set, the item is only visible if the tenant has **one** of these
|
|
78
|
+
* features. The backend filters server-side — the app can rely on only
|
|
79
|
+
* permitted items being present in the manifest.
|
|
80
|
+
*/
|
|
81
|
+
requiresFeature?: string | readonly string[];
|
|
82
|
+
}
|
|
83
|
+
interface TenantManifest {
|
|
84
|
+
schemaVersion: 1;
|
|
85
|
+
/** Tenant identity the manifest is bound to. */
|
|
86
|
+
tenant: {
|
|
87
|
+
id: string;
|
|
88
|
+
};
|
|
89
|
+
/** Active plan (from PlanResolverPort or SubscriptionContract). */
|
|
90
|
+
planId: string | null;
|
|
91
|
+
/** Unlocked features (set as array). */
|
|
92
|
+
features: readonly string[];
|
|
93
|
+
/** quotaKey → limit (`-1` = unlimited). */
|
|
94
|
+
quotas: Readonly<Record<string, number>>;
|
|
95
|
+
/** Visible navigation, already filtered by feature. */
|
|
96
|
+
navigation: TenantNavItem[];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
declare class TenantManifestService {
|
|
100
|
+
private readonly entitlements;
|
|
101
|
+
private readonly navItems;
|
|
102
|
+
constructor(entitlements: StaticEntitlementService);
|
|
103
|
+
/**
|
|
104
|
+
* Call in the app's `OnModuleInit`: registers app navigation for the
|
|
105
|
+
* Tenant UI. Idempotent: the same `id` overwrites.
|
|
106
|
+
*/
|
|
107
|
+
registerNavItem(item: TenantNavItem): void;
|
|
108
|
+
/** Bulk variant. */
|
|
109
|
+
registerNavItems(items: TenantNavItem[]): void;
|
|
110
|
+
/**
|
|
111
|
+
* Returns the filtered manifest for a Tenant. NavItems with
|
|
112
|
+
* `requiresFeature` are filtered out server-side as soon as none of the
|
|
113
|
+
* required features are present in the entitlement snapshot.
|
|
114
|
+
*/
|
|
115
|
+
getManifest(tenantId: string): Promise<TenantManifest>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export { EnforceQuotaInterceptor, PlanResolverPort, QUOTA_PROVIDERS_TOKEN, STATIC_FEATURE_GUARD_CONFIG_TOKEN, StaticEntitlementService, type StaticEntitlementSnapshot, StaticFeatureGuard, type StaticFeatureGuardConfig, type TenantManifest, TenantManifestService, type TenantNavItem };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EnforceQuotaInterceptor,
|
|
3
|
+
PLAN_RESOLVER_PORT_TOKEN,
|
|
4
|
+
QUOTA_PROVIDERS_TOKEN,
|
|
5
|
+
STATIC_FEATURE_GUARD_CONFIG_TOKEN,
|
|
6
|
+
SaasPlatformModule,
|
|
7
|
+
StaticEntitlementService,
|
|
8
|
+
StaticFeatureGuard,
|
|
9
|
+
StaticPlanResolver,
|
|
10
|
+
TenantManifestService,
|
|
11
|
+
buildTenantManifestController
|
|
12
|
+
} from "../chunk-QJVPRD3R.js";
|
|
13
|
+
import "../chunk-P6MYZMXQ.js";
|
|
14
|
+
import "../chunk-Q53N43LQ.js";
|
|
15
|
+
import "../chunk-E56W4U2P.js";
|
|
16
|
+
import "../chunk-AJ3EPELS.js";
|
|
17
|
+
import "../chunk-M6CZQYPY.js";
|
|
18
|
+
import "../chunk-YXGHPILG.js";
|
|
19
|
+
import "../chunk-MV6LW5UB.js";
|
|
20
|
+
import "../chunk-NYLON2VC.js";
|
|
21
|
+
import "../chunk-7MLGHWKO.js";
|
|
22
|
+
import "../chunk-XCZ3TTFK.js";
|
|
23
|
+
import "../chunk-SABTXESR.js";
|
|
24
|
+
import "../chunk-L4SUWH5B.js";
|
|
25
|
+
import "../chunk-SHUYVCID.js";
|
|
26
|
+
export {
|
|
27
|
+
EnforceQuotaInterceptor,
|
|
28
|
+
PLAN_RESOLVER_PORT_TOKEN,
|
|
29
|
+
QUOTA_PROVIDERS_TOKEN,
|
|
30
|
+
STATIC_FEATURE_GUARD_CONFIG_TOKEN,
|
|
31
|
+
SaasPlatformModule,
|
|
32
|
+
StaticEntitlementService,
|
|
33
|
+
StaticFeatureGuard,
|
|
34
|
+
StaticPlanResolver,
|
|
35
|
+
TenantManifestService,
|
|
36
|
+
buildTenantManifestController
|
|
37
|
+
};
|