@happyvertical/smrt-features 0.60.13 → 0.60.15
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/AGENTS.md +27 -4
- package/README.md +49 -3
- package/dist/feature-grants.d.ts +31 -0
- package/dist/feature-grants.d.ts.map +1 -0
- package/dist/feature-resolver.d.ts +20 -1
- package/dist/feature-resolver.d.ts.map +1 -1
- package/dist/feature-sync.d.ts +8 -0
- package/dist/feature-sync.d.ts.map +1 -1
- package/dist/framework-features.d.ts +27 -0
- package/dist/framework-features.d.ts.map +1 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +351 -16
- package/dist/index.js.map +1 -1
- package/dist/kill-switch.d.ts +77 -0
- package/dist/kill-switch.d.ts.map +1 -0
- package/dist/manifest.json +1 -1
- package/dist/require-feature.d.ts +102 -0
- package/dist/require-feature.d.ts.map +1 -0
- package/dist/smrt-knowledge.json +5 -5
- package/dist/smrt-knowledge.okf.md +2 -2
- package/dist/standard-features.d.ts +36 -0
- package/dist/standard-features.d.ts.map +1 -0
- package/dist/types.d.ts +58 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Operator kill switches (#4760).
|
|
3
|
+
*
|
|
4
|
+
* A kill switch is an incident lever, not a feature flag: it stores
|
|
5
|
+
* DISABLE rows in `_smrt_feature_overrides` (the same table, conflict key
|
|
6
|
+
* and write paths as flags) but reads them with stricter semantics than
|
|
7
|
+
* {@link FeatureResolver}:
|
|
8
|
+
*
|
|
9
|
+
* - A global DISABLE turns the switch off everywhere. No tenant row, plan
|
|
10
|
+
* grant or default can turn it back on (a flag's tenant override would).
|
|
11
|
+
* - Otherwise a DISABLE on the tenant itself turns it off for that tenant.
|
|
12
|
+
* - ENABLE and INHERIT rows are ignored: "on" is the absence of a DISABLE,
|
|
13
|
+
* so enabling means deleting the DISABLE row at that scope.
|
|
14
|
+
*
|
|
15
|
+
* Reads are uncached (one or two indexed lookups), so a switch takes effect
|
|
16
|
+
* on the next check in every process. Kill-switch keys have no
|
|
17
|
+
* `FeatureDefinition`: they never appear in `FeatureSettingsService` (whose
|
|
18
|
+
* tenant column would suggest a tenant ENABLE overrides a global DISABLE),
|
|
19
|
+
* and `FeatureResolver` refuses to read an undeclared key. Never define
|
|
20
|
+
* one as a feature.
|
|
21
|
+
*
|
|
22
|
+
* Keys belong to their consumer: `inference.hosted.enabled` is
|
|
23
|
+
* `HOSTED_INFERENCE_KILL_SWITCH` in `@happyvertical/smrt-inference/gate`
|
|
24
|
+
* (#4760). Keys are persisted identifiers: never rename one.
|
|
25
|
+
*
|
|
26
|
+
* Writing a switch is an operator act. `setKillSwitch()` writes through the
|
|
27
|
+
* collection directly, so its caller is the authorization (the CLI holds
|
|
28
|
+
* database credentials); hosts exposing a switch in an admin UI write the
|
|
29
|
+
* same rows through `FeatureOverrideService` with their authorizer.
|
|
30
|
+
*/
|
|
31
|
+
import { FeatureOverrideCollection } from './feature-overrides.js';
|
|
32
|
+
import { type FeatureHostOptions } from './list-bounds.js';
|
|
33
|
+
/** The state of one kill switch for one tenant (or globally). */
|
|
34
|
+
export interface KillSwitchState {
|
|
35
|
+
key: string;
|
|
36
|
+
/** `false` when a global or tenant DISABLE row exists. */
|
|
37
|
+
enabled: boolean;
|
|
38
|
+
/** The scope whose DISABLE row turned it off. */
|
|
39
|
+
disabledBy?: 'global' | 'tenant';
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Read a kill switch: global DISABLE first, then the tenant's own DISABLE
|
|
43
|
+
* (matched as given and lower-cased; `setKillSwitch()` stores tenant ids
|
|
44
|
+
* lower-cased, so a UUID typed in either case applies). No tenant: the
|
|
45
|
+
* global switch only.
|
|
46
|
+
*/
|
|
47
|
+
export declare function readKillSwitch(overrides: FeatureOverrideCollection, key: string, options?: {
|
|
48
|
+
tenantId?: string | null;
|
|
49
|
+
}): Promise<KillSwitchState>;
|
|
50
|
+
/**
|
|
51
|
+
* Turn a kill switch off (write a DISABLE row) or on (delete the DISABLE
|
|
52
|
+
* row) at the global scope, or for one tenant. Turning a tenant on does not
|
|
53
|
+
* lift a global DISABLE. Returns the switch's state afterwards.
|
|
54
|
+
*/
|
|
55
|
+
export declare function setKillSwitch(overrides: FeatureOverrideCollection, key: string, options: {
|
|
56
|
+
enabled: boolean;
|
|
57
|
+
tenantId?: string | null;
|
|
58
|
+
}): Promise<KillSwitchState>;
|
|
59
|
+
/**
|
|
60
|
+
* Kill switches over one database: `read(key, { tenantId })` and
|
|
61
|
+
* `set(key, { enabled, tenantId })`. The override collection is built once,
|
|
62
|
+
* lazily, without the host's list bounds (see `list-bounds.ts`).
|
|
63
|
+
*/
|
|
64
|
+
export declare class KillSwitchService {
|
|
65
|
+
private readonly options;
|
|
66
|
+
private overrides?;
|
|
67
|
+
constructor(options?: FeatureHostOptions);
|
|
68
|
+
private collection;
|
|
69
|
+
read(key: string, options?: {
|
|
70
|
+
tenantId?: string | null;
|
|
71
|
+
}): Promise<KillSwitchState>;
|
|
72
|
+
set(key: string, options: {
|
|
73
|
+
enabled: boolean;
|
|
74
|
+
tenantId?: string | null;
|
|
75
|
+
}): Promise<KillSwitchState>;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=kill-switch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kill-switch.d.ts","sourceRoot":"","sources":["../src/kill-switch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,KAAK,kBAAkB,EAAqB,MAAM,kBAAkB,CAAC;AAG9E,iEAAiE;AACjE,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,0DAA0D;IAC1D,OAAO,EAAE,OAAO,CAAC;IACjB,iDAAiD;IACjD,UAAU,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;CAClC;AAMD;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,SAAS,EAAE,yBAAyB,EACpC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAO,GACzC,OAAO,CAAC,eAAe,CAAC,CAgB1B;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,SAAS,EAAE,yBAAyB,EACpC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GACtD,OAAO,CAAC,eAAe,CAAC,CAuC1B;AAED;;;;GAIG;AACH,qBAAa,iBAAiB;IAGhB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAFpC,OAAO,CAAC,SAAS,CAAC,CAAqC;gBAE1B,OAAO,GAAE,kBAAuB;IAE7D,OAAO,CAAC,UAAU;IAaZ,IAAI,CACR,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAO,GACzC,OAAO,CAAC,eAAe,CAAC;IAIrB,GAAG,CACP,GAAG,EAAE,MAAM,EACX,OAAO,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GACtD,OAAO,CAAC,eAAe,CAAC;CAG5B"}
|
package/dist/manifest.json
CHANGED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Feature gates for routes and services (#4761), following the saas-starter
|
|
3
|
+
* `mcp.ts` pattern: a gated capability below the tenant's tier gets a
|
|
4
|
+
* structured "upgrade" answer naming the key and the plan that grants it,
|
|
5
|
+
* and a feature an operator disabled gets a structured "disabled" answer;
|
|
6
|
+
* never a bare 403.
|
|
7
|
+
*
|
|
8
|
+
* The gate's authorization semantics are "feature present" only. It is not an
|
|
9
|
+
* identity or permission check: callers still authenticate the principal and
|
|
10
|
+
* check its permissions, and must pass the tenant they already verified the
|
|
11
|
+
* principal belongs to.
|
|
12
|
+
*/
|
|
13
|
+
import type { FeatureResolver } from './feature-resolver.js';
|
|
14
|
+
import type { FeatureDecisionLayer, FeatureGrantingPlan, FeatureResolutionContext } from './types.js';
|
|
15
|
+
/** HTTP status of every gate denial: forbidden, with a reason in the body. */
|
|
16
|
+
export declare const FEATURE_GATE_STATUS = 403;
|
|
17
|
+
/** Denial code when a plan upgrade could turn the feature on. */
|
|
18
|
+
export declare const FEATURE_UPGRADE_REQUIRED_CODE = "feature_upgrade_required";
|
|
19
|
+
/**
|
|
20
|
+
* Denial code when an explicit DISABLE override turned the feature off. The
|
|
21
|
+
* global override outranks plan grants, and a tenant override outranks
|
|
22
|
+
* everything, so no upgrade would help; the body names no plan.
|
|
23
|
+
*/
|
|
24
|
+
export declare const FEATURE_DISABLED_CODE = "feature_disabled";
|
|
25
|
+
interface FeatureGateDenialBase {
|
|
26
|
+
featureKey: string;
|
|
27
|
+
/** Human label of the feature, when it is a known framework feature. */
|
|
28
|
+
label: string | null;
|
|
29
|
+
/** Whether the feature is a paid key (`metadata.paid`). */
|
|
30
|
+
paid: boolean;
|
|
31
|
+
tenantId: string | null;
|
|
32
|
+
message: string;
|
|
33
|
+
}
|
|
34
|
+
/** Denial body when the tenant's plan does not grant the key. JSON-safe. */
|
|
35
|
+
export interface FeatureUpgradeRequired extends FeatureGateDenialBase {
|
|
36
|
+
code: typeof FEATURE_UPGRADE_REQUIRED_CODE;
|
|
37
|
+
/** The plan that grants the key, when a grant source can name one. */
|
|
38
|
+
grantingPlan: FeatureGrantingPlan | null;
|
|
39
|
+
}
|
|
40
|
+
/** Denial body when an operator override disabled the key. JSON-safe. */
|
|
41
|
+
export interface FeatureDisabled extends FeatureGateDenialBase {
|
|
42
|
+
code: typeof FEATURE_DISABLED_CODE;
|
|
43
|
+
/** Which override turned the feature off. */
|
|
44
|
+
disabledBy: Extract<FeatureDecisionLayer, 'global_override' | 'tenant_override'>;
|
|
45
|
+
}
|
|
46
|
+
/** A gate denial, discriminated by `code`. */
|
|
47
|
+
export type FeatureGateDenial = FeatureUpgradeRequired | FeatureDisabled;
|
|
48
|
+
export interface FeatureGateOptions extends FeatureResolutionContext {
|
|
49
|
+
/** The request's resolver; reuse one per request. */
|
|
50
|
+
resolver: Pick<FeatureResolver, 'explain' | 'findGrantingPlan'>;
|
|
51
|
+
}
|
|
52
|
+
export type FeatureGateResult = {
|
|
53
|
+
allowed: true;
|
|
54
|
+
featureKey: string;
|
|
55
|
+
} | {
|
|
56
|
+
allowed: false;
|
|
57
|
+
featureKey: string;
|
|
58
|
+
denial: FeatureGateDenial;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Thrown by {@link requireFeature}; carries the structured denial body.
|
|
62
|
+
* Branch on `code` (or `denial.code`) to tell an upgrade from a disabled
|
|
63
|
+
* feature.
|
|
64
|
+
*/
|
|
65
|
+
export declare class FeatureUnavailableError extends Error {
|
|
66
|
+
readonly status = 403;
|
|
67
|
+
readonly denial: FeatureGateDenial;
|
|
68
|
+
constructor(denial: FeatureGateDenial);
|
|
69
|
+
get code(): FeatureGateDenial['code'];
|
|
70
|
+
get featureKey(): string;
|
|
71
|
+
/** The denial response for a SvelteKit `+server.ts` or any fetch handler. */
|
|
72
|
+
toResponse(init?: ResponseInit): Response;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Resolve `featureKey` for the context and describe the denial when it is
|
|
76
|
+
* off. An explicit DISABLE override answers {@link FEATURE_DISABLED_CODE};
|
|
77
|
+
* anything else answers {@link FEATURE_UPGRADE_REQUIRED_CODE} with the plan
|
|
78
|
+
* that grants the key. A failure to name the granting plan never turns a
|
|
79
|
+
* denial into an error: the plan is informational, so it falls back to `null`.
|
|
80
|
+
*/
|
|
81
|
+
export declare function checkFeature(featureKey: string, options: FeatureGateOptions): Promise<FeatureGateResult>;
|
|
82
|
+
/**
|
|
83
|
+
* Service gate: resolves when `featureKey` is on, otherwise throws
|
|
84
|
+
* {@link FeatureUnavailableError}.
|
|
85
|
+
*/
|
|
86
|
+
export declare function requireFeature(featureKey: string, options: FeatureGateOptions): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Route gate: `null` when `featureKey` is on, otherwise the JSON denial
|
|
89
|
+
* response to return from the handler.
|
|
90
|
+
*
|
|
91
|
+
* ```ts
|
|
92
|
+
* const denied = await featureGateResponse(FEATURE_SYNC_DEVICES, {
|
|
93
|
+
* resolver, tenantId, grantSource,
|
|
94
|
+
* });
|
|
95
|
+
* if (denied) return denied;
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
export declare function featureGateResponse(featureKey: string, options: FeatureGateOptions): Promise<Response | null>;
|
|
99
|
+
/** JSON response for a denial body (`403` with the reason in the body). */
|
|
100
|
+
export declare function featureDenialResponse(denial: FeatureGateDenial, init?: ResponseInit): Response;
|
|
101
|
+
export {};
|
|
102
|
+
//# sourceMappingURL=require-feature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"require-feature.d.ts","sourceRoot":"","sources":["../src/require-feature.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AAEpB,8EAA8E;AAC9E,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC,iEAAiE;AACjE,eAAO,MAAM,6BAA6B,6BAA6B,CAAC;AAExE;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,qBAAqB,CAAC;AAExD,UAAU,qBAAqB;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,wEAAwE;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I,GAAE,YAAiB,GAAG,QAAQ;CAG9C;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAChC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CAsD5B;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAKf;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAG1B;AAED,2EAA2E;AAC3E,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,iBAAiB,EACzB,IAAI,GAAE,YAAiB,GACtB,QAAQ,CAQV"}
|
package/dist/smrt-knowledge.json
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
"sensitiveFieldsExcluded": true,
|
|
4
4
|
"generatedAt": "1970-01-01T00:00:00.000Z",
|
|
5
5
|
"packageName": "@happyvertical/smrt-features",
|
|
6
|
-
"packageVersion": "0.60.
|
|
6
|
+
"packageVersion": "0.60.15",
|
|
7
7
|
"sourceManifestPath": "dist/manifest.json",
|
|
8
8
|
"agentDocPath": "AGENTS.md",
|
|
9
9
|
"sourceHashes": {
|
|
10
|
-
"manifest": "
|
|
11
|
-
"packageJson": "
|
|
12
|
-
"agents": "
|
|
10
|
+
"manifest": "cfceb17e44d039acfeb7e29de61dac8f018a62a98fae8ec04fb6f4edcfd7a25d",
|
|
11
|
+
"packageJson": "2f3a898f4f3566f25ed2c4a3f0f47da36d77974fd49906dc92cd5e545c9ff0cf",
|
|
12
|
+
"agents": "106078ed387ae4ef13599fbba50cbdbd00226a97b068f4a0230dc1ea0805c501"
|
|
13
13
|
},
|
|
14
14
|
"exports": [
|
|
15
15
|
".",
|
|
@@ -527,7 +527,7 @@
|
|
|
527
527
|
"polymorphicAssociations": 0,
|
|
528
528
|
"uuidColumns": 4
|
|
529
529
|
},
|
|
530
|
-
"agentDoc": "# smrt-features\n\nCode-first feature flag system with global and tenant-hierarchy resolution.\n\n## Core pieces\n\n- `FeatureDefinition` (`_smrt_feature_definitions` table) — code-owned definition mirrored to DB at registration\n- `FeatureOverride` (`_smrt_feature_overrides` table) — runtime override state, scoped by `(featureKey, scopeType, scopeId)`\n- `FeatureResolver` — resolves the effective state of a feature in a given context, walking the scope chain\n- `FeatureSyncService` — keeps `_smrt_feature_definitions` in sync with code-registered defaults at boot\n- `FeatureOverrideService` — the only write path; asks a host-supplied authorizer before every write and fails closed (#3013)\n- `FeatureSettingsService` — read/write helper for a management screen: `listFeatureSettings()` returns one row per definition (definition fields, `effectiveEnabled`, `globalEffect`, `tenantEffect`), `setFeatureOverride()` refuses unknown keys and scopes the resolver never reads back, then delegates to `FeatureOverrideService` (#3052)\n- `./svelte` subpath — `FeatureSettingsPanel`, the presentational management panel (#3052)\n\n## Resolution chain (priority high → low)\n\n1. Tenant scope (`scopeType: 'tenant'`) — root-to-leaf traversal; a child inherits only when its parent allows cascading and it allows inheritance, otherwise its baseline resets to global\n2. Global scope (`scopeType: 'global'`, `scopeId: GLOBAL_FEATURE_SCOPE_ID`)\n3. Boolean `defaultEnabled` from the registered class, falling back to its synced definition\n\n`FeatureResolver` is instantiated with database options; call `isEnabled(key, { tenantId })` or `isEnabledFor(Class, localId, { tenantId })` on that instance. With no tenant context only global/default apply. There is no user scope.\n\n## Conventions\n\n- Declare features in `@smrt({ features: { drafts: { defaultEnabled: false } } })`. Keys are `<qualifiedClassName>#<localId>`, e.g. `@your/app:Invoice#drafts`.\n- Definitions are code-owned. Construct `new FeatureSyncService(dbOptions)` and call `syncDefinitions({ classNames?, constructors?, pruneStale? })`; filtered syncs never prune siblings. `syncManifest(manifest)` accepts a SMRT class manifest with decorator metadata.\n- Neither object exposes generated REST routes, MCP tools, or CLI commands (`api: false`, `mcp: false`, `cli: false`, #3013): override rows can target any scope and the object is not tenant-scoped, so a generated authentication-only surface would let any signed-in principal set another tenant's flag. Hosts write overrides server-side with `FeatureOverrideService` (which requires an explicit authorizer for every write) or `FeatureOverrideCollection.setOverride()` / `removeOverride()` only after their own authorization decision.\n- `FeatureOverrideCollection.setOverride()` persists typed values but does not validate them against a definition. `FeatureOverrideService` adds authorization; `FeatureSettingsService` additionally rejects unknown keys and invalid scope shapes. Definitions have no `allowedScopes` or `defaultEffect` fields.\n- The default hierarchy loader dynamically discovers `@happyvertical/smrt-users`; a missing dependency falls back to flat tenant lookup. Hosts can override `tenantHierarchyLoader` with a provider or `null`. Other loading failures propagate.\n- Every collection this package builds internally (`FeatureResolver`'s ancestor-chain override read, `FeatureSettingsService`'s catalog enumeration, `FeatureSyncService`'s prune enumeration) is created through the internal `src/list-bounds.ts#withoutListBounds`, so a host-configured `defaultListLimit`/`maxListLimit` on the caller's options bag can never silently truncate one of these correctness-critical reads (#3056, same hazard class as `smrt-users`' `authorization-read-options.ts#withoutListBounds`, #3048). Neither object exposes a generated, paginated list surface (see above), so there is no legitimate internal read here that a host bound should reach. The helper is local to avoid a required dependency on `smrt-users`.\n\n## Management UI (`./svelte`)\n\n- Built like every other Svelte-shipping package here (`smrt-tenancy`/`smrt-personas` are the closest models): `vite build --mode library && svelte-package -i src/svelte -o dist/svelte`, an `./svelte` export with a `svelte` condition, `svelte` as an **optional** peer dependency — plus `scripts/prune-svelte-package-artifacts.js` (as `smrt-content` does), because `svelte-package` otherwise copies `__tests__/` and `*.test.*` into the published `dist/svelte`. The root export stays Svelte-free so server-only consumers are unaffected.\n- `FeatureSettingsPanel` is presentational: rows and callbacks in, no fetching, no authorization. `src/svelte/types.ts` deliberately imports nothing from `smrt-core` or the `@smrt()` models, so the browser bundle stays thin; `showKeys` (default true) hides the raw key/package lines for end-user surfaces while keeping the hidden `featureKey` input; `FeatureSettingsRow` is structurally assignable to `FeatureSettingsView`.\n- Each row is its own `<form>`, so `formAction` gives a working screen with no client JS; `onSave` intercepts the submit instead and reads the row's values straight off the form. The global column is opt-in (`showGlobal` / `globalEditable`) because most apps have no platform-admin tier.\n- Two invariants the selects have to keep, both regression-tested. (1) The tenant column's *Default* option must never name the code default: the tenant scope inherits the global override and, with a `FeatureTenantHierarchyProvider`, ancestor tenants' overrides too, so `defaultEnabled` would tell an operator the opposite of what choosing it does. `inheritedOptionLabel()` names `FeatureSettingsView.inheritedEnabled` when the row carries it and says \"Default (inherited)\" otherwise; `FeatureSettingsService` sets it only where it is exactly knowable (no tenant override → inherited is the effective state), never derived from `globalEffect`. The global column does name the code default — nothing sits above global. (2) The rows remount on `contextKey ?? features`, so an unsaved choice cannot survive a reload or a tenant switch and be submitted against the new rows.\n- Writes validate the **scope shape** before the authorizer runs: `scopeType` must be `global` or `tenant`, a global write must use `GLOBAL_FEATURE_SCOPE_ID`, and a tenant id must be non-blank and already trimmed. A host authorizer cannot catch this — `scopeType: 'global'` with someone else's tenant id reads as an ordinary global write to an authorizer that only gates the global scope — and the resolver looks rows up by the exact `(featureKey, scopeType, scopeId)` triple, so a row written elsewhere is invisible state, not a setting.\n- **Authorization stays with the consumer.** `FeatureSettingsService` reads are unfiltered and every write goes through `FeatureOverrideService`; constructing the settings service without an `authorize` option makes it read-only (writes fail closed). Never add an authorization decision to this package — hosts differ, and the generated surfaces are closed precisely so that decision has to be theirs.\n- `vitest.config.ts` runs two projects because the halves need incompatible resolution: `server` (node, `smrtVitestPlugin`) and `svelte` (jsdom, `@sveltejs/vite-plugin-svelte`, `conditions: ['browser']`). The browser condition would send `smrt-core` to its browser build, so it must not be global.\n\n## Feature keys are persisted identifiers\n\nOverrides are stored keyed by the exact `featureKey` string and the resolver looks them up by that string. **Renaming a key orphans every existing override and silently reverts all tenants to the definition default.** Treat a shipped key as immutable; a rename needs a data migration over `_smrt_feature_overrides.feature_key`, not an edit. Renaming the owning package is the usual trigger — migrate persisted keys when the qualified class identity changes.\n\n## Integration with `@happyvertical/smrt-users`\n\nWhen `smrt-users` is present, `FeatureResolver` uses it to walk the tenant hierarchy (parent → grandparent → root). The default loader discovers it dynamically; a custom `tenantHierarchyLoader` may supply a `FeatureTenantHierarchyProvider`. Without it, tenant lookup is single-level.\n",
|
|
530
|
+
"agentDoc": "# smrt-features\n\nCode-first feature flag system with global and tenant-hierarchy resolution.\n\n## Core pieces\n\n- `FeatureDefinition` (`_smrt_feature_definitions` table) — code-owned definition mirrored to DB at registration\n- `FeatureOverride` (`_smrt_feature_overrides` table) — runtime override state, scoped by `(featureKey, scopeType, scopeId)`\n- `FeatureResolver` — resolves the effective state of a feature in a given context, walking the scope chain\n- `FeatureSyncService` — keeps `_smrt_feature_definitions` in sync with code-registered defaults at boot\n- `FeatureOverrideService` — the only write path; asks a host-supplied authorizer before every write and fails closed (#3013)\n- `FeatureSettingsService` — read/write helper for a management screen: `listFeatureSettings()` returns one row per definition (definition fields, `effectiveEnabled`, `globalEffect`, `tenantEffect`), `setFeatureOverride()` refuses unknown keys and scopes the resolver never reads back, then delegates to `FeatureOverrideService` (#3052)\n- `./svelte` subpath — `FeatureSettingsPanel`, the presentational management panel (#3052)\n\n## Resolution chain (priority high → low)\n\n1. Tenant scope (`scopeType: 'tenant'`) — root-to-leaf traversal; a child inherits only when its parent allows cascading and it allows inheritance, otherwise its baseline resets to the post-global state (grant, then global override)\n2. Global scope (`scopeType: 'global'`, `scopeId: GLOBAL_FEATURE_SCOPE_ID`) — applies on top of the grant; `inherit` keeps the granted state\n3. Plan grant (#4761) — a key the tenant's plan grants becomes enabled; an ungranted key keeps its default\n4. Boolean `defaultEnabled` from the registered class or framework definition, falling back to its synced definition\n\n`FeatureResolver` is instantiated with database options; call `isEnabled(key, { tenantId, grantSource? })`, `explain(key, context)` (`{ enabled, decidedBy }`, the layer that set the state; the gate reads it), or `isEnabledFor(Class, localId, { tenantId })` on that instance. With no tenant context only global/default apply (grants are tenant-level). There is no user scope.\n\n## Plan grants, standard keys, gates (#4761)\n\n- **Grant source slot.** Features never imports `smrt-subscriptions`. A `FeatureGrantSource` (`getGrants(tenantId)`, optional `findGrantingPlan()`) is taken from `context.grantSource`, else `FeatureResolverOptions.grantSource`, else the global slot (`setFeatureGrantSource()`, stored under `Symbol.for(FEATURE_GRANT_SOURCE_SLOT_KEY)`; `smrt-subscriptions` writes the same key, so never rename it). `null` at either level disables grants. No source = no grants = pre-#4761 behavior. A global override outranks a plan grant: a global row is an explicit operator act, so a global DISABLE stops the feature fleet-wide, granted tenants included. Tenant overrides still beat both (the per-tenant escape hatch). Grant-source errors propagate (an outage must not read as \"no plan\").\n- **Framework features** (`framework-features.ts`): dotted keys (`inference.hosted`) owned by no class, registered on `globalThis` via `defineFrameworkFeature()` (identical re-definition is a no-op, a conflicting one throws). The resolver reads their default before the class registry. `FeatureSyncService.syncFrameworkDefinitions()` upserts them as rows with an empty `qualifiedClassName`; class-sync pruning skips those rows.\n- **Standard paid keys** (`standard-features.ts`): `FEATURE_SYNC_DEVICES`, `FEATURE_BACKUP_VAULT`, `FEATURE_CLOUD_HOSTED`, `FEATURE_INFERENCE_HOSTED`, `FEATURE_PLUGINS_REMOTE` (also `STANDARD_FEATURE_KEYS`, `STANDARD_FEATURES`); all `metadata.paid: true`, default off, seeded lazily (no import side effect). Gates import the constants, never string literals; plans grant the same strings.\n- **Gates** (`require-feature.ts`): `requireFeature(key, { resolver, tenantId, grantSource? })` throws `FeatureUnavailableError` (`status` 403, `.code`, `.denial`, `.toResponse()`) for services; `featureGateResponse()` returns `null` or the JSON denial `Response` (`featureDenialResponse()`) for SvelteKit routes; `checkFeature()` returns `{ allowed, featureKey, denial? }`. `FeatureGateDenial` is a union discriminated by `code`, sharing `featureKey`, `label`, `paid`, `tenantId`, `message`: `feature_upgrade_required` (`FEATURE_UPGRADE_REQUIRED_CODE`) adds `grantingPlan`; `feature_disabled` (`FEATURE_DISABLED_CODE`) adds `disabledBy` and names no plan. The gate answers `feature_disabled` when `explain()` reports a global or tenant DISABLE decided the state (no upgrade could help) and never calls `findGrantingPlan()` then; otherwise a failing plan lookup only nulls `grantingPlan`. Never a bare 403. Semantics are \"feature present\", not identity: callers authenticate and authorize the principal and pass the tenant they verified.\n\n## Kill switches (#4760)\n\n`src/kill-switch.ts`: `readKillSwitch()` / `setKillSwitch()` /\n`KillSwitchService` store DISABLE rows in `_smrt_feature_overrides` but\nread them as an incident lever, not a flag: a global DISABLE wins over\neverything, then the tenant's own DISABLE; ENABLE/INHERIT rows are\nignored, so \"on\" means no DISABLE row and enabling deletes it. Tenant rows\nare written lower-cased and read in either spelling; enabling clears every\nspelling. Reads are uncached. Kill-switch keys have no definition (so\n`FeatureResolver` refuses them and `FeatureSettingsService` never lists\nthem). Keys belong to their consumer: `inference.hosted.enabled` is\nsmrt-inference's `HOSTED_INFERENCE_KILL_SWITCH`. `KillSwitchService.set()`\nwrites without an authorizer (the CLI's database credentials are the\nauthorization); admin UIs write through `FeatureOverrideService`.\n\n## Conventions\n\n- Declare features in `@smrt({ features: { drafts: { defaultEnabled: false } } })`. Keys are `<qualifiedClassName>#<localId>`, e.g. `@your/app:Invoice#drafts`.\n- Definitions are code-owned. Construct `new FeatureSyncService(dbOptions)` and call `syncDefinitions({ classNames?, constructors?, pruneStale? })`; filtered syncs never prune siblings. `syncManifest(manifest)` accepts a SMRT class manifest with decorator metadata.\n- Neither object exposes generated REST routes, MCP tools, or CLI commands (`api: false`, `mcp: false`, `cli: false`, #3013): override rows can target any scope and the object is not tenant-scoped, so a generated authentication-only surface would let any signed-in principal set another tenant's flag. Hosts write overrides server-side with `FeatureOverrideService` (which requires an explicit authorizer for every write) or `FeatureOverrideCollection.setOverride()` / `removeOverride()` only after their own authorization decision.\n- `FeatureOverrideCollection.setOverride()` persists typed values but does not validate them against a definition. `FeatureOverrideService` adds authorization; `FeatureSettingsService` additionally rejects unknown keys and invalid scope shapes. Definitions have no `allowedScopes` or `defaultEffect` fields.\n- The default hierarchy loader dynamically discovers `@happyvertical/smrt-users`; a missing dependency falls back to flat tenant lookup. Hosts can override `tenantHierarchyLoader` with a provider or `null`. Other loading failures propagate.\n- Every collection this package builds internally (`FeatureResolver`'s ancestor-chain override read, `FeatureSettingsService`'s catalog enumeration, `FeatureSyncService`'s prune enumeration) is created through the internal `src/list-bounds.ts#withoutListBounds`, so a host-configured `defaultListLimit`/`maxListLimit` on the caller's options bag can never silently truncate one of these correctness-critical reads (#3056, same hazard class as `smrt-users`' `authorization-read-options.ts#withoutListBounds`, #3048). Neither object exposes a generated, paginated list surface (see above), so there is no legitimate internal read here that a host bound should reach. The helper is local to avoid a required dependency on `smrt-users`.\n\n## Management UI (`./svelte`)\n\n- Built like every other Svelte-shipping package here (`smrt-tenancy`/`smrt-personas` are the closest models): `vite build --mode library && svelte-package -i src/svelte -o dist/svelte`, an `./svelte` export with a `svelte` condition, `svelte` as an **optional** peer dependency — plus `scripts/prune-svelte-package-artifacts.js` (as `smrt-content` does), because `svelte-package` otherwise copies `__tests__/` and `*.test.*` into the published `dist/svelte`. The root export stays Svelte-free so server-only consumers are unaffected.\n- `FeatureSettingsPanel` is presentational: rows and callbacks in, no fetching, no authorization. `src/svelte/types.ts` deliberately imports nothing from `smrt-core` or the `@smrt()` models, so the browser bundle stays thin; `showKeys` (default true) hides the raw key/package lines for end-user surfaces while keeping the hidden `featureKey` input; `FeatureSettingsRow` is structurally assignable to `FeatureSettingsView`.\n- Each row is its own `<form>`, so `formAction` gives a working screen with no client JS; `onSave` intercepts the submit instead and reads the row's values straight off the form. The global column is opt-in (`showGlobal` / `globalEditable`) because most apps have no platform-admin tier.\n- Two invariants the selects have to keep, both regression-tested. (1) The tenant column's *Default* option must never name the code default: the tenant scope inherits the global override and, with a `FeatureTenantHierarchyProvider`, ancestor tenants' overrides too, so `defaultEnabled` would tell an operator the opposite of what choosing it does. `inheritedOptionLabel()` names `FeatureSettingsView.inheritedEnabled` when the row carries it and says \"Default (inherited)\" otherwise; `FeatureSettingsService` sets it only where it is exactly knowable (no tenant override → inherited is the effective state), never derived from `globalEffect`. The global column does name the code default — nothing sits above global. (2) The rows remount on `contextKey ?? features`, so an unsaved choice cannot survive a reload or a tenant switch and be submitted against the new rows.\n- Writes validate the **scope shape** before the authorizer runs: `scopeType` must be `global` or `tenant`, a global write must use `GLOBAL_FEATURE_SCOPE_ID`, and a tenant id must be non-blank and already trimmed. A host authorizer cannot catch this — `scopeType: 'global'` with someone else's tenant id reads as an ordinary global write to an authorizer that only gates the global scope — and the resolver looks rows up by the exact `(featureKey, scopeType, scopeId)` triple, so a row written elsewhere is invisible state, not a setting.\n- **Authorization stays with the consumer.** `FeatureSettingsService` reads are unfiltered and every write goes through `FeatureOverrideService`; constructing the settings service without an `authorize` option makes it read-only (writes fail closed). Never add an authorization decision to this package — hosts differ, and the generated surfaces are closed precisely so that decision has to be theirs.\n- `vitest.config.ts` runs two projects because the halves need incompatible resolution: `server` (node, `smrtVitestPlugin`) and `svelte` (jsdom, `@sveltejs/vite-plugin-svelte`, `conditions: ['browser']`). The browser condition would send `smrt-core` to its browser build, so it must not be global.\n\n## Feature keys are persisted identifiers\n\nOverrides are stored keyed by the exact `featureKey` string and the resolver looks them up by that string. **Renaming a key orphans every existing override and silently reverts all tenants to the definition default.** Treat a shipped key as immutable; a rename needs a data migration over `_smrt_feature_overrides.feature_key`, not an edit. Renaming the owning package is the usual trigger — migrate persisted keys when the qualified class identity changes.\n\n## Integration with `@happyvertical/smrt-users`\n\nWhen `smrt-users` is present, `FeatureResolver` uses it to walk the tenant hierarchy (parent → grandparent → root). The default loader discovers it dynamically; a custom `tenantHierarchyLoader` may supply a `FeatureTenantHierarchyProvider`. Without it, tenant lookup is single-level.\n",
|
|
531
531
|
"browser": {
|
|
532
532
|
"status": "server-only",
|
|
533
533
|
"issues": [
|
|
@@ -5,10 +5,10 @@ description: "Code-first feature flags and tenant-aware overrides for the SMRT f
|
|
|
5
5
|
status: "stable"
|
|
6
6
|
generated:
|
|
7
7
|
by: "smrt/scripts/generate-knowledge-okf.ts"
|
|
8
|
-
at: "2026-11-
|
|
8
|
+
at: "2026-11-08T20:27:51Z"
|
|
9
9
|
audience: "internal"
|
|
10
10
|
evidence_level: "source-inspected"
|
|
11
|
-
source_revision: "sha256:
|
|
11
|
+
source_revision: "sha256:091c74e62c455711943b3b4131a42dece91c8fdca52d638cc980418ea6068ed4"
|
|
12
12
|
sources:
|
|
13
13
|
- id: "manifest"
|
|
14
14
|
resource: "https://github.com/happyvertical/smrt/blob/main/packages/features/package.json"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard paid feature keys for the tier ladder (#4761, epic #4667).
|
|
3
|
+
*
|
|
4
|
+
* Gates reference these constants, never string literals. They are framework
|
|
5
|
+
* feature definitions (see `framework-features.ts`): dotted keys, not
|
|
6
|
+
* `<qualifiedClassName>#<localId>`, because a subscription plan grants them by
|
|
7
|
+
* the same string (`SubscriptionPlan.features[].featureKey`). Every standard
|
|
8
|
+
* key is `paid: true` and defaults off, so it is enabled only by a plan grant
|
|
9
|
+
* or an explicit override.
|
|
10
|
+
*
|
|
11
|
+
* Keys are persisted identifiers (plan grants and override rows store the
|
|
12
|
+
* string): never rename one.
|
|
13
|
+
*/
|
|
14
|
+
import type { FrameworkFeatureDefinition } from './framework-features.js';
|
|
15
|
+
/** Multi-device sync (#4668/#4670). */
|
|
16
|
+
export declare const FEATURE_SYNC_DEVICES = "sync.devices";
|
|
17
|
+
/** Encrypted cloud backup of the vault. */
|
|
18
|
+
export declare const FEATURE_BACKUP_VAULT = "backup.vault";
|
|
19
|
+
/** Hosted cloud deployment of the app. */
|
|
20
|
+
export declare const FEATURE_CLOUD_HOSTED = "cloud.hosted";
|
|
21
|
+
/** Hosted (platform-paid) AI inference (#4759, #4760). */
|
|
22
|
+
export declare const FEATURE_INFERENCE_HOSTED = "inference.hosted";
|
|
23
|
+
/** Remotely installed plugins. */
|
|
24
|
+
export declare const FEATURE_PLUGINS_REMOTE = "plugins.remote";
|
|
25
|
+
/** The standard keys by name, for iteration and typed lookups. */
|
|
26
|
+
export declare const STANDARD_FEATURE_KEYS: {
|
|
27
|
+
readonly syncDevices: "sync.devices";
|
|
28
|
+
readonly backupVault: "backup.vault";
|
|
29
|
+
readonly cloudHosted: "cloud.hosted";
|
|
30
|
+
readonly inferenceHosted: "inference.hosted";
|
|
31
|
+
readonly pluginsRemote: "plugins.remote";
|
|
32
|
+
};
|
|
33
|
+
export type StandardFeatureKey = (typeof STANDARD_FEATURE_KEYS)[keyof typeof STANDARD_FEATURE_KEYS];
|
|
34
|
+
/** Definitions of the standard keys; all `paid: true`, all default off. */
|
|
35
|
+
export declare const STANDARD_FEATURES: readonly FrameworkFeatureDefinition[];
|
|
36
|
+
//# sourceMappingURL=standard-features.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standard-features.d.ts","sourceRoot":"","sources":["../src/standard-features.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAE1E,uCAAuC;AACvC,eAAO,MAAM,oBAAoB,iBAAiB,CAAC;AACnD,2CAA2C;AAC3C,eAAO,MAAM,oBAAoB,iBAAiB,CAAC;AACnD,0CAA0C;AAC1C,eAAO,MAAM,oBAAoB,iBAAiB,CAAC;AACnD,0DAA0D;AAC1D,eAAO,MAAM,wBAAwB,qBAAqB,CAAC;AAC3D,kCAAkC;AAClC,eAAO,MAAM,sBAAsB,mBAAmB,CAAC;AAEvD,kEAAkE;AAClE,eAAO,MAAM,qBAAqB;;;;;;CAMxB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAC5B,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,OAAO,qBAAqB,CAAC,CAAC;AAIrE,2EAA2E;AAC3E,eAAO,MAAM,iBAAiB,EAAE,SAAS,0BAA0B,EAoDhE,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -70,6 +70,58 @@ export interface FeatureSyncResult {
|
|
|
70
70
|
}
|
|
71
71
|
export interface FeatureResolutionContext {
|
|
72
72
|
tenantId?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Per-request plan grant source (#4761). Takes precedence over the
|
|
75
|
+
* resolver's `grantSource` option and the registered global source. Build
|
|
76
|
+
* it once per request (for example one `SubscriptionFeatureSource` around
|
|
77
|
+
* one `SubscriptionResolver`) and pass the same object to every check.
|
|
78
|
+
*/
|
|
79
|
+
grantSource?: FeatureGrantSource | null;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Plan grants for one tenant, as reported by a {@link FeatureGrantSource}.
|
|
83
|
+
* Only keys listed here are granted; every other key keeps its code default.
|
|
84
|
+
* The global and tenant overrides apply on top either way.
|
|
85
|
+
*/
|
|
86
|
+
export interface FeatureGrantSnapshot {
|
|
87
|
+
featureKeys: readonly string[];
|
|
88
|
+
planId?: string | null;
|
|
89
|
+
planKey?: string | null;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The layer that last set a feature's state during resolution, low → high:
|
|
93
|
+
* code default, plan grant, global override, tenant override. An `inherit`
|
|
94
|
+
* override row sets nothing, so it never decides.
|
|
95
|
+
*/
|
|
96
|
+
export type FeatureDecisionLayer = 'default' | 'plan_grant' | 'global_override' | 'tenant_override';
|
|
97
|
+
/** Result of `FeatureResolver.explain()`. */
|
|
98
|
+
export interface FeatureResolution {
|
|
99
|
+
enabled: boolean;
|
|
100
|
+
decidedBy: FeatureDecisionLayer;
|
|
101
|
+
}
|
|
102
|
+
/** A plan that grants a feature key, for upgrade responses. */
|
|
103
|
+
export interface FeatureGrantingPlan {
|
|
104
|
+
planKey: string;
|
|
105
|
+
planId?: string | null;
|
|
106
|
+
name?: string | null;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Source of plan feature grants, consulted by `FeatureResolver` between the
|
|
110
|
+
* code default and the global override (#4761). `smrt-subscriptions` provides
|
|
111
|
+
* `SubscriptionFeatureSource`; features never imports it, so a local install
|
|
112
|
+
* with no source (or no subscription tables) simply has no grants.
|
|
113
|
+
*/
|
|
114
|
+
export interface FeatureGrantSource {
|
|
115
|
+
/**
|
|
116
|
+
* Grants for the tenant, or `null` when it has none (no subscription, no
|
|
117
|
+
* subscription tables). Must not throw for "no subscription".
|
|
118
|
+
*/
|
|
119
|
+
getGrants(tenantId: string): Promise<FeatureGrantSnapshot | null>;
|
|
120
|
+
/**
|
|
121
|
+
* Optional: the plan an upgrade response should name for `featureKey`, or
|
|
122
|
+
* `null` when no visible plan grants it.
|
|
123
|
+
*/
|
|
124
|
+
findGrantingPlan?(featureKey: string, tenantId: string | null): Promise<FeatureGrantingPlan | null>;
|
|
73
125
|
}
|
|
74
126
|
export interface FeatureTenantNode {
|
|
75
127
|
id: string;
|
|
@@ -82,6 +134,12 @@ export interface FeatureTenantHierarchyProvider {
|
|
|
82
134
|
export type FeatureTenantHierarchyLoader = (options: SmrtClassOptions) => Promise<FeatureTenantHierarchyProvider | null>;
|
|
83
135
|
export interface FeatureResolverOptions {
|
|
84
136
|
tenantHierarchyLoader?: FeatureTenantHierarchyLoader;
|
|
137
|
+
/**
|
|
138
|
+
* Grant source for this resolver instance. `null` disables grants even when
|
|
139
|
+
* a global source is registered; omitted falls back to the global source
|
|
140
|
+
* from `setFeatureGrantSource()`.
|
|
141
|
+
*/
|
|
142
|
+
grantSource?: FeatureGrantSource | null;
|
|
85
143
|
}
|
|
86
144
|
/**
|
|
87
145
|
* Minimal structural shape of a tenant record returned by
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EACX,MAAM,0BAA0B,CAAC;AAElC,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,MAAM,wBAAw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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":["FeatureOverrideEffect"],"sources":["../src/types.ts"],"sourcesContent":["import type {\n SmartObjectManifest,\n SmrtClassOptions,\n SmrtObject,\n} from '@happyvertical/smrt-core';\n\nexport const GLOBAL_FEATURE_SCOPE_ID = '*';\n\nexport type FeatureScopeType = 'global' | 'tenant';\n\n/**\n * Constructor type for any `@smrt()`-decorated class that may declare feature\n * toggles. Feature targets always extend `SmrtObject`, so this mirrors\n * `@happyvertical/smrt-core`'s internal (non-exported) `SmrtObjectConstructor`\n * and remains assignable to it for `ObjectRegistry.getClassByConstructor`.\n */\nexport type FeatureTargetConstructor = new (\n ...args: ConstructorParameters<typeof SmrtObject>\n) => SmrtObject;\n\nexport enum FeatureOverrideEffect {\n INHERIT = 'inherit',\n ENABLE = 'enable',\n DISABLE = 'disable',\n}\n\nexport interface FeatureMetadata {\n [key: string]: unknown;\n}\n\nexport interface FeatureDefinitionOptions {\n id?: string;\n featureKey?: string;\n packageName?: string;\n qualifiedClassName?: string;\n className?: string;\n localId?: string;\n defaultEnabled?: boolean;\n label?: string;\n description?: string;\n metadata?: FeatureMetadata | string | null;\n visibility?: string;\n createdAt?: Date;\n updatedAt?: Date;\n}\n\nexport interface FeatureOverrideOptions {\n id?: string;\n featureKey?: string;\n scopeType?: FeatureScopeType;\n scopeId?: string;\n effect?: FeatureOverrideEffect;\n createdAt?: Date;\n updatedAt?: Date;\n}\n\nexport interface FeatureDefinitionSeed {\n featureKey: string;\n packageName: string;\n qualifiedClassName: string;\n className: string;\n localId: string;\n defaultEnabled: boolean;\n label?: string;\n description?: string;\n metadata?: FeatureMetadata;\n visibility?: string;\n}\n\nexport interface SyncDefinitionsOptions {\n classNames?: string[];\n constructors?: FeatureTargetConstructor[];\n pruneStale?: boolean;\n}\n\nexport interface SyncManifestOptions {\n pruneStale?: boolean;\n}\n\nexport interface FeatureSyncResult {\n total: number;\n created: number;\n updated: number;\n unchanged: number;\n deleted: number;\n featureKeys: string[];\n}\n\nexport interface FeatureResolutionContext {\n tenantId?: string;\n}\n\nexport interface FeatureTenantNode {\n id: string;\n inheritPermissions: boolean;\n cascadePermissions: boolean;\n}\n\nexport interface FeatureTenantHierarchyProvider {\n getChain(tenantId: string): Promise<FeatureTenantNode[]>;\n}\n\nexport type FeatureTenantHierarchyLoader = (\n options: SmrtClassOptions,\n) => Promise<FeatureTenantHierarchyProvider | null>;\n\nexport interface FeatureResolverOptions {\n tenantHierarchyLoader?: FeatureTenantHierarchyLoader;\n}\n\n/**\n * Minimal structural shape of a tenant record returned by\n * `@happyvertical/smrt-users`. Only the permission-cascade fields consumed by\n * feature resolution are modeled; everything else is left unconstrained.\n */\nexport interface FeatureUsersTenantRecord {\n id: string;\n inheritPermissions?: boolean;\n cascadePermissions?: boolean;\n}\n\nexport interface FeatureUsersModule {\n TenantCollection: {\n create(options: SmrtClassOptions): Promise<{\n get(criteria: { id: string }): Promise<FeatureUsersTenantRecord | null>;\n getAncestorsFromRoot(\n tenantId: string,\n ): Promise<FeatureUsersTenantRecord[]>;\n }>;\n };\n}\n\nexport type { SmartObjectManifest, SmrtClassOptions };\n"],"mappings":";AAMO,IAAM,0BAA0B;AAchC,IAAK,wBAAL,kBAAKA,2BAAL;CACLA,uBAAA,aAAU;CACVA,uBAAA,YAAS;CACTA,uBAAA,aAAU;CAHA,OAAAA;AAAA,EAAA,CAAA,yBAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"types.js","names":["FeatureOverrideEffect"],"sources":["../src/types.ts"],"sourcesContent":["import type {\n SmartObjectManifest,\n SmrtClassOptions,\n SmrtObject,\n} from '@happyvertical/smrt-core';\n\nexport const GLOBAL_FEATURE_SCOPE_ID = '*';\n\nexport type FeatureScopeType = 'global' | 'tenant';\n\n/**\n * Constructor type for any `@smrt()`-decorated class that may declare feature\n * toggles. Feature targets always extend `SmrtObject`, so this mirrors\n * `@happyvertical/smrt-core`'s internal (non-exported) `SmrtObjectConstructor`\n * and remains assignable to it for `ObjectRegistry.getClassByConstructor`.\n */\nexport type FeatureTargetConstructor = new (\n ...args: ConstructorParameters<typeof SmrtObject>\n) => SmrtObject;\n\nexport enum FeatureOverrideEffect {\n INHERIT = 'inherit',\n ENABLE = 'enable',\n DISABLE = 'disable',\n}\n\nexport interface FeatureMetadata {\n [key: string]: unknown;\n}\n\nexport interface FeatureDefinitionOptions {\n id?: string;\n featureKey?: string;\n packageName?: string;\n qualifiedClassName?: string;\n className?: string;\n localId?: string;\n defaultEnabled?: boolean;\n label?: string;\n description?: string;\n metadata?: FeatureMetadata | string | null;\n visibility?: string;\n createdAt?: Date;\n updatedAt?: Date;\n}\n\nexport interface FeatureOverrideOptions {\n id?: string;\n featureKey?: string;\n scopeType?: FeatureScopeType;\n scopeId?: string;\n effect?: FeatureOverrideEffect;\n createdAt?: Date;\n updatedAt?: Date;\n}\n\nexport interface FeatureDefinitionSeed {\n featureKey: string;\n packageName: string;\n qualifiedClassName: string;\n className: string;\n localId: string;\n defaultEnabled: boolean;\n label?: string;\n description?: string;\n metadata?: FeatureMetadata;\n visibility?: string;\n}\n\nexport interface SyncDefinitionsOptions {\n classNames?: string[];\n constructors?: FeatureTargetConstructor[];\n pruneStale?: boolean;\n}\n\nexport interface SyncManifestOptions {\n pruneStale?: boolean;\n}\n\nexport interface FeatureSyncResult {\n total: number;\n created: number;\n updated: number;\n unchanged: number;\n deleted: number;\n featureKeys: string[];\n}\n\nexport interface FeatureResolutionContext {\n tenantId?: string;\n /**\n * Per-request plan grant source (#4761). Takes precedence over the\n * resolver's `grantSource` option and the registered global source. Build\n * it once per request (for example one `SubscriptionFeatureSource` around\n * one `SubscriptionResolver`) and pass the same object to every check.\n */\n grantSource?: FeatureGrantSource | null;\n}\n\n/**\n * Plan grants for one tenant, as reported by a {@link FeatureGrantSource}.\n * Only keys listed here are granted; every other key keeps its code default.\n * The global and tenant overrides apply on top either way.\n */\nexport interface FeatureGrantSnapshot {\n featureKeys: readonly string[];\n planId?: string | null;\n planKey?: string | null;\n}\n\n/**\n * The layer that last set a feature's state during resolution, low → high:\n * code default, plan grant, global override, tenant override. An `inherit`\n * override row sets nothing, so it never decides.\n */\nexport type FeatureDecisionLayer =\n | 'default'\n | 'plan_grant'\n | 'global_override'\n | 'tenant_override';\n\n/** Result of `FeatureResolver.explain()`. */\nexport interface FeatureResolution {\n enabled: boolean;\n decidedBy: FeatureDecisionLayer;\n}\n\n/** A plan that grants a feature key, for upgrade responses. */\nexport interface FeatureGrantingPlan {\n planKey: string;\n planId?: string | null;\n name?: string | null;\n}\n\n/**\n * Source of plan feature grants, consulted by `FeatureResolver` between the\n * code default and the global override (#4761). `smrt-subscriptions` provides\n * `SubscriptionFeatureSource`; features never imports it, so a local install\n * with no source (or no subscription tables) simply has no grants.\n */\nexport interface FeatureGrantSource {\n /**\n * Grants for the tenant, or `null` when it has none (no subscription, no\n * subscription tables). Must not throw for \"no subscription\".\n */\n getGrants(tenantId: string): Promise<FeatureGrantSnapshot | null>;\n /**\n * Optional: the plan an upgrade response should name for `featureKey`, or\n * `null` when no visible plan grants it.\n */\n findGrantingPlan?(\n featureKey: string,\n tenantId: string | null,\n ): Promise<FeatureGrantingPlan | null>;\n}\n\nexport interface FeatureTenantNode {\n id: string;\n inheritPermissions: boolean;\n cascadePermissions: boolean;\n}\n\nexport interface FeatureTenantHierarchyProvider {\n getChain(tenantId: string): Promise<FeatureTenantNode[]>;\n}\n\nexport type FeatureTenantHierarchyLoader = (\n options: SmrtClassOptions,\n) => Promise<FeatureTenantHierarchyProvider | null>;\n\nexport interface FeatureResolverOptions {\n tenantHierarchyLoader?: FeatureTenantHierarchyLoader;\n /**\n * Grant source for this resolver instance. `null` disables grants even when\n * a global source is registered; omitted falls back to the global source\n * from `setFeatureGrantSource()`.\n */\n grantSource?: FeatureGrantSource | null;\n}\n\n/**\n * Minimal structural shape of a tenant record returned by\n * `@happyvertical/smrt-users`. Only the permission-cascade fields consumed by\n * feature resolution are modeled; everything else is left unconstrained.\n */\nexport interface FeatureUsersTenantRecord {\n id: string;\n inheritPermissions?: boolean;\n cascadePermissions?: boolean;\n}\n\nexport interface FeatureUsersModule {\n TenantCollection: {\n create(options: SmrtClassOptions): Promise<{\n get(criteria: { id: string }): Promise<FeatureUsersTenantRecord | null>;\n getAncestorsFromRoot(\n tenantId: string,\n ): Promise<FeatureUsersTenantRecord[]>;\n }>;\n };\n}\n\nexport type { SmartObjectManifest, SmrtClassOptions };\n"],"mappings":";AAMO,IAAM,0BAA0B;AAchC,IAAK,wBAAL,kBAAKA,2BAAL;CACLA,uBAAA,aAAU;CACVA,uBAAA,YAAS;CACTA,uBAAA,aAAU;CAHA,OAAAA;AAAA,EAAA,CAAA,yBAAA,CAAA,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happyvertical/smrt-features",
|
|
3
|
-
"version": "0.60.
|
|
3
|
+
"version": "0.60.15",
|
|
4
4
|
"description": "Code-first feature flags and tenant-aware overrides for the SMRT framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
"./manifest.json": "./dist/manifest.json"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@happyvertical/smrt-core": "0.60.
|
|
28
|
-
"@happyvertical/smrt-ui": "0.60.
|
|
27
|
+
"@happyvertical/smrt-core": "0.60.15",
|
|
28
|
+
"@happyvertical/smrt-ui": "0.60.15"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@happyvertical/smrt-cli": "0.60.
|
|
32
|
-
"@happyvertical/smrt-users": "0.60.
|
|
33
|
-
"@happyvertical/smrt-vitest": "0.60.
|
|
31
|
+
"@happyvertical/smrt-cli": "0.60.15",
|
|
32
|
+
"@happyvertical/smrt-users": "0.60.15",
|
|
33
|
+
"@happyvertical/smrt-vitest": "0.60.15",
|
|
34
34
|
"@sveltejs/package": "^2.5.8",
|
|
35
35
|
"@sveltejs/vite-plugin-svelte": "^7.3.0",
|
|
36
36
|
"@types/node": "24.13.6",
|