import { ComponentSpec } from "./component-spec.js"; import { ComponentEntitySimplePermission } from "./data-requirements.js"; import { ComponentLibraryDependency } from "./library-dependency.js"; import { UserInfo, IMetadataProvider } from "@memberjunction/core"; /** * Runtime extension of ComponentSpec that provides helper methods for permission checking, * validation, and other runtime operations. This class is not included in AI prompts * to keep token usage efficient. */ export declare class ComponentSpecRuntime extends ComponentSpec { private _provider; /** * Optional metadata provider override. Callers should set * `instance.Provider = providerToUse` before invoking permission-checking methods * in multi-provider contexts. Falls back to the global default provider when unset. */ get Provider(): IMetadataProvider; set Provider(value: IMetadataProvider | null); /** * Get all unique permissions required by this component across all entities. * This aggregates permissions from all entity data requirements to provide * a complete picture of what the component needs. * * @returns Array of unique permission types required by the component */ GetRequiredPermissions(): ComponentEntitySimplePermission[]; /** * Check if the component only requires read permissions across all entities. * This is useful for determining if a component is effectively read-only * from a permissions perspective. * * @returns true if the component only requires 'read' permissions */ IsEffectivelyReadOnly(): boolean; /** * Get all entity names that this component accesses. * Useful for pre-loading permissions or understanding component data dependencies. * * @returns Array of entity names accessed by the component */ GetAccessedEntities(): string[]; /** * Check if the component has any write capabilities (create, update, or delete). * This helps determine if the component can modify data or is purely read-only. * * @returns true if the component requires any write permissions */ HasWriteCapabilities(): boolean; /** * Convert component permission types to MemberJunction EntityPermissionType. * This enables integration with MJ's permission system. * * @param permission - Component permission type * @returns MemberJunction EntityPermissionType */ private convertToEntityPermissionType; /** * Validate that a user has all required permissions to use this component. * This method checks each entity's permission requirements against the user's * actual permissions in MemberJunction using the Metadata system. * * @param user - The MemberJunction UserInfo object * @returns Validation result with details about any missing permissions */ ValidateUserPermissions(user: UserInfo): Promise<{ canRender: boolean; missingPermissions: Array<{ entity: string; permission: ComponentEntitySimplePermission; }>; degradedPermissions: Array<{ entity: string; permission: ComponentEntitySimplePermission; reason: string; }>; }>; /** * Get a summary of all data access patterns for this component. * Useful for documentation and understanding component behavior. * * @returns Object describing all data access patterns */ GetDataAccessSummary(): { mode: string; entityCount: number; queryCount: number; requiresWrite: boolean; entities: Array<{ name: string; permissions: string[]; }>; queries: Array<{ name: string; category: string; }>; }; /** * Create a ComponentSpecRuntime instance from a plain object. * Useful when deserializing from JSON or database storage. * * @param obj - Plain object with ComponentSpec properties * @returns New ComponentSpecRuntime instance */ static FromObject(obj: ComponentSpec): ComponentSpecRuntime; /** * Create a ComponentSpecRuntime instance from JSON string. * Handles parsing and object conversion in one step. * * @param json - JSON string representation of a ComponentSpec * @returns New ComponentSpecRuntime instance */ static FromJSON(json: string): ComponentSpecRuntime; /** * Get all external library dependencies for this component. * Returns both the library names and their global variables. * * @returns Array of library dependencies with details */ GetLibraryDependencies(): ComponentLibraryDependency[]; /** * Check if this component depends on a specific library. * Can check by either library name or global variable. * * @param libraryNameOrGlobal - Library name or global variable to check * @returns true if the component depends on the specified library */ DependsOnLibrary(libraryNameOrGlobal: string): boolean; /** * Get all component dependencies recursively. * Traverses the entire dependency tree to return a flat list of all * components this one depends on, directly or indirectly. * * @param visitedNames - Set of already visited component names (for cycle detection) * @returns Array of all component dependencies */ GetAllDependencies(visitedNames?: Set): ComponentSpec[]; } //# sourceMappingURL=component-spec-runtime.d.ts.map