import { SmartObjectManifest } from '@happyvertical/smrt-core/manifest'; import { SmrtClassOptions } from '@happyvertical/smrt-core'; import { SmrtCollection } from '@happyvertical/smrt-core'; import { SmrtObject } from '@happyvertical/smrt-core'; export declare function createFeatureKey(qualifiedClassName: string, localId: string): string; export declare class FeatureDefinition extends SmrtObject { featureKey: string; packageName: string; qualifiedClassName: string; className: string; localId: string; defaultEnabled: boolean; label: string; description: string; metadata: string; visibility: string; constructor(options?: FeatureDefinitionOptions); getMetadata(): FeatureMetadata; setMetadata(metadata: FeatureMetadata | null): void; } export declare class FeatureDefinitionCollection extends SmrtCollection { static readonly _itemClass: typeof FeatureDefinition; findByFeatureKey(featureKey: string): Promise; findByPackageName(packageName: string): Promise; upsertDefinition(seed: FeatureDefinitionSeed): Promise<{ definition: FeatureDefinition; status: 'created' | 'updated' | 'unchanged'; }>; } export declare interface FeatureDefinitionOptions { id?: string; featureKey?: string; packageName?: string; qualifiedClassName?: string; className?: string; localId?: string; defaultEnabled?: boolean; label?: string; description?: string; metadata?: FeatureMetadata | string | null; visibility?: string; createdAt?: Date; updatedAt?: Date; } export declare interface FeatureDefinitionSeed { featureKey: string; packageName: string; qualifiedClassName: string; className: string; localId: string; defaultEnabled: boolean; label?: string; description?: string; metadata?: FeatureMetadata; visibility?: string; } export declare interface FeatureMetadata { [key: string]: unknown; } export declare class FeatureOverride extends SmrtObject { featureKey: string; scopeType: FeatureScopeType; scopeId: string; effect: FeatureOverrideEffect; constructor(options?: FeatureOverrideOptions); isInherit(): boolean; isEnabled(): boolean; isDisabled(): boolean; } export declare class FeatureOverrideCollection extends SmrtCollection { static readonly _itemClass: typeof FeatureOverride; findByFeatureKey(featureKey: string): Promise; findByFeatureAndScope(featureKey: string, scopeType: FeatureScopeType, scopeId: string): Promise; getGlobalOverride(featureKey: string): Promise; getTenantOverride(featureKey: string, tenantId: string): Promise; getOverrideMap(featureKey: string, scopeType: FeatureScopeType, scopeIds: string[]): Promise>; setOverride(featureKey: string, scopeType: FeatureScopeType, scopeId: string, effect: FeatureOverrideEffect): Promise; setGlobalOverride(featureKey: string, effect: FeatureOverrideEffect): Promise; setTenantOverride(featureKey: string, tenantId: string, effect: FeatureOverrideEffect): Promise; removeOverride(featureKey: string, scopeType: FeatureScopeType, scopeId: string): Promise; } export declare enum FeatureOverrideEffect { INHERIT = "inherit", ENABLE = "enable", DISABLE = "disable" } export declare interface FeatureOverrideOptions { id?: string; featureKey?: string; scopeType?: FeatureScopeType; scopeId?: string; effect?: FeatureOverrideEffect; createdAt?: Date; updatedAt?: Date; } export declare interface FeatureResolutionContext { tenantId?: string; } export declare class FeatureResolver { private readonly options; private readonly resolverOptions; private featureDefinitions; private featureOverrides; private initializationPromise; private tenantHierarchyPromise; constructor(options?: SmrtClassOptions, resolverOptions?: FeatureResolverOptions); isEnabled(featureKey: string, context?: FeatureResolutionContext): Promise; isEnabledFor(classOrInstance: object | FeatureTargetConstructor, localId: string, context?: FeatureResolutionContext): Promise; private ensureInitialized; private resolveBaseState; private applyOverride; private getTenantHierarchy; } export declare interface FeatureResolverOptions { tenantHierarchyLoader?: FeatureTenantHierarchyLoader; } export declare type FeatureScopeType = 'global' | 'tenant'; export declare interface FeatureSyncResult { total: number; created: number; updated: number; unchanged: number; deleted: number; featureKeys: string[]; } export declare class FeatureSyncService { private readonly options; private featureDefinitions; private initializationPromise; constructor(options?: SmrtClassOptions); syncDefinitions(options?: SyncDefinitionsOptions): Promise; syncManifest(manifest: SmartObjectManifest, options?: SyncManifestOptions): Promise; private ensureInitialized; private collectDefinitionsFromRegistrations; private collectTouchedPackagesFromRegistrations; private collectRegistrations; private applyDefinitions; } /** * Constructor type for any `@smrt()`-decorated class that may declare feature * toggles. Feature targets always extend `SmrtObject`, so this mirrors * `@happyvertical/smrt-core`'s internal (non-exported) `SmrtObjectConstructor` * and remains assignable to it for `ObjectRegistry.getClassByConstructor`. */ declare type FeatureTargetConstructor = new (...args: unknown[]) => SmrtObject; export declare type FeatureTenantHierarchyLoader = (options: SmrtClassOptions) => Promise; export declare interface FeatureTenantHierarchyProvider { getChain(tenantId: string): Promise; } export declare interface FeatureTenantNode { id: string; inheritPermissions: boolean; cascadePermissions: boolean; } export declare interface FeatureUsersModule { TenantCollection: { create(options: SmrtClassOptions): Promise<{ get(criteria: { id: string; }): Promise; getAncestorsFromRoot(tenantId: string): Promise; }>; }; } /** * Minimal structural shape of a tenant record returned by * `@happyvertical/smrt-users`. Only the permission-cascade fields consumed by * feature resolution are modeled; everything else is left unconstrained. */ declare interface FeatureUsersTenantRecord { id: string; inheritPermissions?: boolean; cascadePermissions?: boolean; } export declare function findFeatureDefaultInRegistry(featureKey: string): boolean | undefined; export declare const GLOBAL_FEATURE_SCOPE_ID = "*"; export declare function parseFeatureKey(featureKey: string): { qualifiedClassName: string; localId: string; }; export declare function resolveFeatureKeyForTarget(classOrInstance: object | FeatureTargetConstructor, localId: string): { featureKey: string; defaultEnabled: boolean; }; export declare interface SyncDefinitionsOptions { classNames?: string[]; constructors?: FeatureTargetConstructor[]; pruneStale?: boolean; } export declare interface SyncManifestOptions { pruneStale?: boolean; } export { }