@memberjunction/react-runtime 5.33.0 → 5.34.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/.turbo/turbo-build.log +14 -14
- package/CHANGELOG.md +21 -0
- package/dist/324.runtime.umd.js +148 -103
- package/dist/component-manager/component-manager.d.ts.map +1 -1
- package/dist/component-manager/component-manager.js +16 -11
- package/dist/component-manager/component-manager.js.map +1 -1
- package/dist/registry/component-registry-service.d.ts.map +1 -1
- package/dist/registry/component-registry-service.js +5 -6
- package/dist/registry/component-registry-service.js.map +1 -1
- package/dist/registry/component-resolver.d.ts.map +1 -1
- package/dist/registry/component-resolver.js +3 -21
- package/dist/registry/component-resolver.js.map +1 -1
- package/dist/runtime.umd.js +4554 -2577
- package/package.json +6 -6
- package/src/component-manager/component-manager.ts +36 -41
- package/src/registry/component-registry-service.ts +14 -20
- package/src/registry/component-resolver.ts +11 -32
|
@@ -40,7 +40,7 @@ export class ComponentResolver {
|
|
|
40
40
|
}
|
|
41
41
|
await this.componentEngine.Config(false, contextUser);
|
|
42
42
|
if (this.debug) {
|
|
43
|
-
console.log(`✅ [ComponentResolver] Component engine initialized
|
|
43
|
+
console.log(`✅ [ComponentResolver] Component engine initialized`);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
await this.resolveComponentHierarchy(spec, resolved, namespace, new Set(), contextUser);
|
|
@@ -141,24 +141,9 @@ export class ComponentResolver {
|
|
|
141
141
|
}
|
|
142
142
|
else {
|
|
143
143
|
if (this.debug) {
|
|
144
|
-
console.log(`💾 [ComponentResolver] Looking for locally registered component`);
|
|
144
|
+
console.log(`💾 [ComponentResolver] Looking for locally registered component: ${spec.name}`);
|
|
145
145
|
}
|
|
146
|
-
const
|
|
147
|
-
if (this.debug) {
|
|
148
|
-
console.log(`📊 [ComponentResolver] Total components in engine: ${allComponents.length}`);
|
|
149
|
-
}
|
|
150
|
-
const matchingNames = allComponents.filter((c) => c.Name === spec.name);
|
|
151
|
-
if (matchingNames.length > 0 && this.debug) {
|
|
152
|
-
console.log(`🔎 [ComponentResolver] Found ${matchingNames.length} components with name "${spec.name}":`, matchingNames.map((c) => ({
|
|
153
|
-
ID: c.ID,
|
|
154
|
-
Name: c.Name,
|
|
155
|
-
Namespace: c.Namespace,
|
|
156
|
-
Version: c.Version,
|
|
157
|
-
Status: c.Status
|
|
158
|
-
})));
|
|
159
|
-
}
|
|
160
|
-
const component = this.componentEngine.Components?.find((c) => c.Name === spec.name &&
|
|
161
|
-
c.Namespace === (spec.namespace || namespace));
|
|
146
|
+
const component = await this.componentEngine.FindComponent(spec.name, spec.namespace || namespace, undefined, contextUser);
|
|
162
147
|
if (component) {
|
|
163
148
|
if (this.debug) {
|
|
164
149
|
console.log(`✅ [ComponentResolver] Found component in local DB:`, {
|
|
@@ -176,9 +161,6 @@ export class ComponentResolver {
|
|
|
176
161
|
}
|
|
177
162
|
else {
|
|
178
163
|
console.error(`❌ [ComponentResolver] Local registry component NOT found in database: ${spec.name} with namespace: ${spec.namespace || namespace}`);
|
|
179
|
-
if (this.debug) {
|
|
180
|
-
console.warn(`Local registry component not found in database: ${spec.name}`);
|
|
181
|
-
}
|
|
182
164
|
}
|
|
183
165
|
}
|
|
184
166
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-resolver.js","sourceRoot":"","sources":["../../src/registry/component-resolver.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAKxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAaxE,MAAM,OAAO,iBAAiB;IAgB5B,YACE,QAA2B,EAC3B,QAA4B,EAC5B,cAA+B,EAC/B,QAAiB,KAAK;QAlBhB,oBAAe,GAAoC,IAAI,CAAC;QAExD,aAAQ,GAA6B,IAAI,CAAC;QAC1C,mBAAc,GAA0B,IAAI,CAAC;QAC7C,oBAAe,GAAG,uBAAuB,CAAC,QAAQ,C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for managing component relationships.\n * Handles resolution of child components and dependency graphs.\n * @module @memberjunction/react-runtime/registry\n */\n\nimport { ComponentRegistry } from './component-registry';\nimport { ComponentRegistryService } from './component-registry-service';\nimport { ComponentSpec } from '@memberjunction/interactive-component-types';\nimport { ComponentCompiler } from '../compiler';\nimport { RuntimeContext } from '../types';\nimport { UserInfo } from '@memberjunction/core';\nimport { ComponentMetadataEngine } from '@memberjunction/core-entities';\n\n/**\n * Resolved component map for passing to React components\n */\nexport interface ResolvedComponents {\n [componentName: string]: any;\n}\n\n/**\n * Component dependency resolver.\n * Resolves component hierarchies and manages dependencies between components.\n */\nexport class ComponentResolver {\n private registry: ComponentRegistry;\n private registryService: ComponentRegistryService | null = null;\n private resolverInstanceId: string;\n private compiler: ComponentCompiler | null = null;\n private runtimeContext: RuntimeContext | null = null;\n private componentEngine = ComponentMetadataEngine.Instance;\n private debug: boolean = false;\n\n /**\n * Creates a new ComponentResolver instance\n * @param registry - Component registry to use for resolution\n * @param compiler - Optional compiler for registry-based components\n * @param runtimeContext - Optional runtime context for registry-based components\n * @param debug - Enable debug logging (defaults to false)\n */\n constructor(\n registry: ComponentRegistry,\n compiler?: ComponentCompiler,\n runtimeContext?: RuntimeContext,\n debug: boolean = false\n ) {\n this.registry = registry;\n this.resolverInstanceId = `resolver-${Date.now()}-${Math.random()}`;\n this.debug = debug;\n \n if (compiler && runtimeContext) {\n this.compiler = compiler;\n this.runtimeContext = runtimeContext;\n this.registryService = ComponentRegistryService.getInstance(compiler, runtimeContext, debug);\n }\n }\n\n /**\n * Resolves all components for a given component specification\n * @param spec - Root component specification\n * @param namespace - Namespace for component resolution\n * @param contextUser - Optional user context for database operations\n * @returns Map of component names to resolved components\n */\n async resolveComponents(\n spec: ComponentSpec, \n namespace: string = 'Global',\n contextUser?: UserInfo\n ): Promise<ResolvedComponents> {\n console.log(`🚀 [ComponentResolver] Starting component resolution for: ${spec.name}`);\n console.log(`📋 [ComponentResolver] Root component spec:`, {\n name: spec.name,\n location: spec.location,\n registry: spec.registry,\n namespace: spec.namespace,\n hasCode: !!spec.code,\n hasDependencies: !!(spec.dependencies && spec.dependencies.length > 0)\n });\n \n if (this.debug) {\n console.log(`📋 [ComponentResolver] Dependencies to resolve:`, (spec.dependencies || []).map(d => ({\n name: d.name,\n location: d.location,\n namespace: d.namespace\n })));\n }\n \n const resolved: ResolvedComponents = {};\n \n // Initialize component engine if we have registry service\n if (this.registryService) {\n if (this.debug) {\n console.log(`🔄 [ComponentResolver] Initializing component engine...`);\n }\n await this.componentEngine.Config(false, contextUser);\n if (this.debug) {\n console.log(`✅ [ComponentResolver] Component engine initialized with ${this.componentEngine.Components?.length || 0} components`);\n }\n }\n \n // Resolve the component hierarchy\n await this.resolveComponentHierarchy(spec, resolved, namespace, new Set(), contextUser);\n \n if (!resolved[spec.name]) {\n console.error(`❌ [ComponentResolver] Root component '${spec.name}' was NOT added to resolved map!`);\n console.log(`📦 [ComponentResolver] What IS in resolved map:`, Object.keys(resolved));\n }\n \n if (this.debug) {\n console.log(`📊 [ComponentResolver] Resolved components before unwrapping:`, Object.keys(resolved));\n }\n \n // Unwrap component wrappers before returning\n // Components from the registry come as objects with component/print/refresh properties\n // We need to extract just the component function for use in child components\n const unwrapped: ResolvedComponents = {};\n for (const [name, value] of Object.entries(resolved)) {\n if (value && typeof value === 'object' && 'component' in value) {\n if (typeof value.component === 'function') {\n // This is a wrapped component - extract the actual React component function\n unwrapped[name] = value.component;\n if (this.debug) {\n console.log(`✅ [ComponentResolver] Unwrapped component: ${name} (was object with .component)`);\n }\n } else {\n // ComponentObject has a component property but it's not a function\n console.error(`❌ [ComponentResolver] Component ${name} has invalid component property:`, typeof value.component, value);\n unwrapped[name] = value; // Pass through the problematic value so we can see the error\n }\n } else if (typeof value === 'function') {\n // Already a function - use as is\n unwrapped[name] = value;\n if (this.debug) {\n console.log(`✅ [ComponentResolver] Component already a function: ${name}`);\n }\n } else {\n // Something else - could be undefined or an error\n console.warn(`⚠️ [ComponentResolver] Component ${name} is not a function or wrapped component:`, typeof value, value);\n unwrapped[name] = value; // Pass through for debugging\n }\n }\n \n if (this.debug) {\n console.log(`🎯 [ComponentResolver] Final resolved components:`, Object.keys(unwrapped).map(name => ({\n name,\n type: typeof unwrapped[name],\n isUndefined: unwrapped[name] === undefined\n })));\n }\n \n return unwrapped;\n }\n\n /**\n * Recursively resolves a component hierarchy\n * @param spec - Component specification\n * @param resolved - Map to store resolved components\n * @param namespace - Namespace for resolution\n * @param visited - Set of visited component names to prevent cycles\n * @param contextUser - Optional user context for database operations\n */\n private async resolveComponentHierarchy(\n spec: ComponentSpec,\n resolved: ResolvedComponents,\n namespace: string,\n visited: Set<string> = new Set(),\n contextUser?: UserInfo\n ): Promise<void> {\n // Create a unique identifier for this component\n const componentId = `${spec.namespace || namespace}/${spec.name}@${spec.version || 'latest'}`;\n \n // Check if already resolved (not just visited)\n if (resolved[spec.name]) {\n if (this.debug) {\n console.log(`⏭️ [ComponentResolver] Component already resolved: ${spec.name}`);\n }\n return;\n }\n \n // Prevent circular dependencies\n if (visited.has(componentId)) {\n if (this.debug) {\n console.warn(`Circular dependency detected for component: ${componentId}`);\n }\n return;\n }\n visited.add(componentId);\n\n // *** CRITICAL: Process child components FIRST (depth-first, post-order) ***\n if (this.debug) {\n console.log(`🔄 [ComponentResolver] Resolving dependencies for ${spec.name} BEFORE resolving itself`);\n }\n const children = spec.dependencies || [];\n for (const child of children) {\n if (this.debug) {\n console.log(` ↳ [ComponentResolver] Resolving dependency: ${child.name} for parent ${spec.name}`);\n }\n await this.resolveComponentHierarchy(child, resolved, namespace, visited, contextUser);\n }\n if (children.length > 0 && this.debug) {\n console.log(`✅ [ComponentResolver] All ${children.length} dependencies resolved for ${spec.name}, now resolving itself`);\n }\n\n // NOW resolve the current component (it can access its dependencies)\n // Handle based on location\n if (spec.location === 'registry' && this.registryService) {\n // Registry component - need to load from database or external source\n if (this.debug) {\n console.log(`🔍 [ComponentResolver] Looking for registry component: ${spec.name} in namespace: ${spec.namespace || namespace}`);\n if (spec.registry) {\n console.log(` 📍 [ComponentResolver] External registry specified: ${spec.registry}`);\n } else {\n console.log(` 📍 [ComponentResolver] Local registry (no registry field specified)`);\n }\n }\n \n try {\n // If spec.registry is populated, this is an external registry component\n // If spec.registry is blank/undefined, this is a local registry component\n if (spec.registry) {\n // EXTERNAL REGISTRY: Need to fetch from external registry via GraphQL\n if (this.debug) {\n console.log(`🌐 [ComponentResolver] Fetching from external registry: ${spec.registry}`);\n }\n \n // Get compiled component from registry service (which will handle the external fetch)\n const compiledComponent = await this.registryService.getCompiledComponentFromRegistry(\n spec.registry, // Registry name\n spec.namespace || namespace,\n spec.name,\n spec.version || 'latest',\n this.resolverInstanceId,\n contextUser\n );\n \n if (compiledComponent) {\n resolved[spec.name] = compiledComponent;\n if (this.debug) {\n console.log(`✅ [ComponentResolver] Successfully fetched and compiled from external registry: ${spec.name}`);\n }\n } else {\n console.error(`❌ [ComponentResolver] Failed to fetch from external registry: ${spec.name} from ${spec.registry}`);\n }\n } else {\n // LOCAL REGISTRY: Get from local database\n if (this.debug) {\n console.log(`💾 [ComponentResolver] Looking for locally registered component`);\n }\n \n // First, try to find the component in the metadata engine\n const allComponents = this.componentEngine.Components || [];\n if (this.debug) {\n console.log(`📊 [ComponentResolver] Total components in engine: ${allComponents.length}`);\n }\n \n // Log all matching names to see duplicates\n const matchingNames = allComponents.filter((c: any) => c.Name === spec.name);\n if (matchingNames.length > 0 && this.debug) {\n console.log(`🔎 [ComponentResolver] Found ${matchingNames.length} components with name \"${spec.name}\":`, \n matchingNames.map((c: any) => ({\n ID: c.ID,\n Name: c.Name,\n Namespace: c.Namespace,\n Version: c.Version,\n Status: c.Status\n }))\n );\n }\n \n const component = this.componentEngine.Components?.find(\n (c: any) => c.Name === spec.name && \n c.Namespace === (spec.namespace || namespace)\n );\n \n if (component) {\n if (this.debug) {\n console.log(`✅ [ComponentResolver] Found component in local DB:`, {\n ID: component.ID,\n Name: component.Name,\n Namespace: component.Namespace,\n Version: component.Version\n });\n }\n \n // Get compiled component from registry service (local compilation)\n const compiledComponent = await this.registryService.getCompiledComponent(\n component.ID,\n this.resolverInstanceId,\n contextUser\n );\n resolved[spec.name] = compiledComponent;\n if (this.debug) {\n console.log(`📦 [ComponentResolver] Successfully compiled and resolved local component: ${spec.name}, type: ${typeof compiledComponent}`);\n }\n } else {\n console.error(`❌ [ComponentResolver] Local registry component NOT found in database: ${spec.name} with namespace: ${spec.namespace || namespace}`);\n if (this.debug) {\n console.warn(`Local registry component not found in database: ${spec.name}`);\n }\n }\n }\n } catch (error) {\n if (this.debug) {\n console.error(`Failed to load registry component ${spec.name}:`, error);\n }\n }\n } else {\n // Embedded/Local component\n // Use the component's specified namespace if it has one, otherwise use parent's namespace\n const componentNamespace = spec.namespace || namespace;\n \n // First check if component has inline code that needs compilation\n if (spec.code && this.compiler) {\n if (this.debug) {\n console.log(`🔨 [ComponentResolver] Component ${spec.name} has inline code, compiling...`);\n }\n \n try {\n // Compile the component with its code\n const compilationResult = await this.compiler.compile({\n componentName: spec.name,\n componentCode: spec.code,\n libraries: spec.libraries,\n dependencies: spec.dependencies,\n allLibraries: [] // TODO: Get from ComponentMetadataEngine if needed\n });\n \n if (compilationResult.success && compilationResult.component) {\n // Get the component object from the factory (only if we have runtimeContext)\n if (!this.runtimeContext) {\n console.error(`❌ [ComponentResolver] Cannot compile without runtime context`);\n return;\n }\n const componentObject = compilationResult.component.factory(this.runtimeContext);\n \n // Register it in the local registry for future use\n this.registry.register(spec.name, componentObject, componentNamespace, spec.version || 'latest');\n \n // Add to resolved\n resolved[spec.name] = componentObject;\n \n if (this.debug) {\n console.log(`✅ [ComponentResolver] Successfully compiled and registered inline component: ${spec.name}`);\n }\n } else {\n console.error(`❌ [ComponentResolver] Failed to compile inline component ${spec.name}:`, compilationResult.error);\n }\n } catch (error) {\n console.error(`❌ [ComponentResolver] Error compiling inline component ${spec.name}:`, error);\n }\n } else {\n // No inline code, try to get from local registry\n if (this.debug) {\n console.log(`🔍 [ComponentResolver] Looking for embedded component: ${spec.name} in namespace: ${componentNamespace}`);\n }\n \n const component = this.registry.get(spec.name, componentNamespace);\n if (component) {\n resolved[spec.name] = component;\n if (this.debug) {\n console.log(`✅ [ComponentResolver] Found embedded component: ${spec.name}, type: ${typeof component}`);\n }\n if (this.debug) {\n console.log(`📄 Resolved embedded component: ${spec.name} from namespace ${componentNamespace}, type:`, typeof component);\n }\n } else {\n // If not found with specified namespace, try the parent namespace as fallback\n if (this.debug) {\n console.log(`⚠️ [ComponentResolver] Not found in namespace ${componentNamespace}, trying fallback namespace: ${namespace}`);\n }\n const fallbackComponent = this.registry.get(spec.name, namespace);\n if (fallbackComponent) {\n resolved[spec.name] = fallbackComponent;\n if (this.debug) {\n console.log(`✅ [ComponentResolver] Found embedded component in fallback namespace: ${spec.name}, type: ${typeof fallbackComponent}`);\n }\n if (this.debug) {\n console.log(`📄 Resolved embedded component: ${spec.name} from fallback namespace ${namespace}, type:`, typeof fallbackComponent);\n }\n } else {\n // Component not found - this might cause issues later\n console.error(`❌ [ComponentResolver] Could not resolve embedded component: ${spec.name} in namespace ${componentNamespace} or ${namespace}`);\n if (this.debug) {\n console.warn(`⚠️ Could not resolve embedded component: ${spec.name} in namespace ${componentNamespace} or ${namespace}`);\n }\n // Store undefined explicitly so we know it failed to resolve\n resolved[spec.name] = undefined;\n }\n }\n }\n }\n \n // Child components have already been processed at the beginning of this method\n // No need to process them again - we're using depth-first, post-order traversal\n }\n\n /**\n * Cleanup resolver resources\n */\n cleanup(): void {\n // Remove our references when resolver is destroyed\n if (this.registryService) {\n // This would allow the registry service to clean up unused components\n // Implementation would track which components this resolver referenced\n if (this.debug) {\n console.log(`Cleaning up resolver: ${this.resolverInstanceId}`);\n }\n }\n }\n\n /**\n * Validates that all required components are available\n * @param spec - Component specification to validate\n * @param namespace - Namespace for validation\n * @returns Array of missing component names\n */\n validateDependencies(spec: ComponentSpec, namespace: string = 'Global'): string[] {\n const missing: string[] = [];\n const checked = new Set<string>();\n \n this.checkDependencies(spec, namespace, missing, checked);\n \n return missing;\n }\n\n /**\n * Recursively checks for missing dependencies\n * @param spec - Component specification\n * @param namespace - Namespace for checking\n * @param missing - Array to collect missing components\n * @param checked - Set of already checked components\n */\n private checkDependencies(\n spec: ComponentSpec,\n namespace: string,\n missing: string[],\n checked: Set<string>\n ): void {\n if (checked.has(spec.name)) return;\n checked.add(spec.name);\n\n // Check if component exists in registry\n if (!this.registry.has(spec.name, namespace)) {\n missing.push(spec.name);\n }\n\n // Check children\n const children = spec.dependencies || [];\n for (const child of children) {\n this.checkDependencies(child, namespace, missing, checked);\n }\n }\n\n /**\n * Gets the dependency graph for a component specification\n * @param spec - Component specification\n * @returns Dependency graph as adjacency list\n */\n getDependencyGraph(spec: ComponentSpec): Map<string, string[]> {\n const graph = new Map<string, string[]>();\n const visited = new Set<string>();\n \n this.buildDependencyGraph(spec, graph, visited);\n \n return graph;\n }\n\n /**\n * Recursively builds the dependency graph\n * @param spec - Component specification\n * @param graph - Graph to build\n * @param visited - Set of visited components\n */\n private buildDependencyGraph(\n spec: ComponentSpec,\n graph: Map<string, string[]>,\n visited: Set<string>\n ): void {\n if (visited.has(spec.name)) return;\n visited.add(spec.name);\n\n const children = spec.dependencies || [];\n const dependencies = children.map(child => child.name);\n \n graph.set(spec.name, dependencies);\n\n // Recursively process children\n for (const child of children) {\n this.buildDependencyGraph(child, graph, visited);\n }\n }\n\n /**\n * Performs topological sort on component dependencies\n * @param spec - Root component specification\n * @returns Array of component names in dependency order\n */\n getLoadOrder(spec: ComponentSpec): string[] {\n const graph = this.getDependencyGraph(spec);\n const visited = new Set<string>();\n const stack: string[] = [];\n\n // Perform DFS on all nodes\n for (const node of graph.keys()) {\n if (!visited.has(node)) {\n this.topologicalSortDFS(node, graph, visited, stack);\n }\n }\n\n // Reverse to get correct load order\n return stack.reverse();\n }\n\n /**\n * DFS helper for topological sort\n * @param node - Current node\n * @param graph - Dependency graph\n * @param visited - Set of visited nodes\n * @param stack - Result stack\n */\n private topologicalSortDFS(\n node: string,\n graph: Map<string, string[]>,\n visited: Set<string>,\n stack: string[]\n ): void {\n visited.add(node);\n\n const dependencies = graph.get(node) || [];\n for (const dep of dependencies) {\n if (!visited.has(dep)) {\n this.topologicalSortDFS(dep, graph, visited, stack);\n }\n }\n\n stack.push(node);\n }\n\n /**\n * Resolves components in the correct dependency order\n * @param spec - Root component specification\n * @param namespace - Namespace for resolution\n * @returns Ordered array of resolved components\n */\n resolveInOrder(spec: ComponentSpec, namespace: string = 'Global'): Array<{\n name: string;\n component: any;\n }> {\n const loadOrder = this.getLoadOrder(spec);\n const resolved: Array<{ name: string; component: any }> = [];\n\n for (const name of loadOrder) {\n const component = this.registry.get(name, namespace);\n if (component) {\n resolved.push({ name, component });\n }\n }\n\n return resolved;\n }\n\n /**\n * Creates a flattened list of all component specifications\n * @param spec - Root component specification\n * @returns Array of all component specs in the hierarchy\n */\n flattenComponentSpecs(spec: ComponentSpec): ComponentSpec[] {\n const flattened: ComponentSpec[] = [];\n const visited = new Set<string>();\n\n this.collectComponentSpecs(spec, flattened, visited);\n\n return flattened;\n }\n\n /**\n * Recursively collects component specifications\n * @param spec - Current component specification\n * @param collected - Array to collect specs\n * @param visited - Set of visited component names\n */\n private collectComponentSpecs(\n spec: ComponentSpec,\n collected: ComponentSpec[],\n visited: Set<string>\n ): void {\n if (visited.has(spec.name)) return;\n visited.add(spec.name);\n\n collected.push(spec);\n\n const children = spec.dependencies || [];\n for (const child of children) {\n this.collectComponentSpecs(child, collected, visited);\n }\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"component-resolver.js","sourceRoot":"","sources":["../../src/registry/component-resolver.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAKxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAaxE,MAAM,OAAO,iBAAiB;IAgB5B,YACE,QAA2B,EAC3B,QAA4B,EAC5B,cAA+B,EAC/B,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GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEvB,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAErB,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC;QACzC,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC7B,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;CACF","sourcesContent":["/**\n * @fileoverview Component dependency resolver for managing component relationships.\n * Handles resolution of child components and dependency graphs.\n * @module @memberjunction/react-runtime/registry\n */\n\nimport { ComponentRegistry } from './component-registry';\nimport { ComponentRegistryService } from './component-registry-service';\nimport { ComponentSpec } from '@memberjunction/interactive-component-types';\nimport { ComponentCompiler } from '../compiler';\nimport { RuntimeContext } from '../types';\nimport { UserInfo } from '@memberjunction/core';\nimport { ComponentMetadataEngine } from '@memberjunction/core-entities';\n\n/**\n * Resolved component map for passing to React components\n */\nexport interface ResolvedComponents {\n [componentName: string]: any;\n}\n\n/**\n * Component dependency resolver.\n * Resolves component hierarchies and manages dependencies between components.\n */\nexport class ComponentResolver {\n private registry: ComponentRegistry;\n private registryService: ComponentRegistryService | null = null;\n private resolverInstanceId: string;\n private compiler: ComponentCompiler | null = null;\n private runtimeContext: RuntimeContext | null = null;\n private componentEngine = ComponentMetadataEngine.Instance;\n private debug: boolean = false;\n\n /**\n * Creates a new ComponentResolver instance\n * @param registry - Component registry to use for resolution\n * @param compiler - Optional compiler for registry-based components\n * @param runtimeContext - Optional runtime context for registry-based components\n * @param debug - Enable debug logging (defaults to false)\n */\n constructor(\n registry: ComponentRegistry,\n compiler?: ComponentCompiler,\n runtimeContext?: RuntimeContext,\n debug: boolean = false\n ) {\n this.registry = registry;\n this.resolverInstanceId = `resolver-${Date.now()}-${Math.random()}`;\n this.debug = debug;\n \n if (compiler && runtimeContext) {\n this.compiler = compiler;\n this.runtimeContext = runtimeContext;\n this.registryService = ComponentRegistryService.getInstance(compiler, runtimeContext, debug);\n }\n }\n\n /**\n * Resolves all components for a given component specification\n * @param spec - Root component specification\n * @param namespace - Namespace for component resolution\n * @param contextUser - Optional user context for database operations\n * @returns Map of component names to resolved components\n */\n async resolveComponents(\n spec: ComponentSpec, \n namespace: string = 'Global',\n contextUser?: UserInfo\n ): Promise<ResolvedComponents> {\n console.log(`🚀 [ComponentResolver] Starting component resolution for: ${spec.name}`);\n console.log(`📋 [ComponentResolver] Root component spec:`, {\n name: spec.name,\n location: spec.location,\n registry: spec.registry,\n namespace: spec.namespace,\n hasCode: !!spec.code,\n hasDependencies: !!(spec.dependencies && spec.dependencies.length > 0)\n });\n \n if (this.debug) {\n console.log(`📋 [ComponentResolver] Dependencies to resolve:`, (spec.dependencies || []).map(d => ({\n name: d.name,\n location: d.location,\n namespace: d.namespace\n })));\n }\n \n const resolved: ResolvedComponents = {};\n \n // Initialize component engine if we have registry service\n if (this.registryService) {\n if (this.debug) {\n console.log(`🔄 [ComponentResolver] Initializing component engine...`);\n }\n await this.componentEngine.Config(false, contextUser);\n if (this.debug) {\n console.log(`✅ [ComponentResolver] Component engine initialized`);\n }\n }\n \n // Resolve the component hierarchy\n await this.resolveComponentHierarchy(spec, resolved, namespace, new Set(), contextUser);\n \n if (!resolved[spec.name]) {\n console.error(`❌ [ComponentResolver] Root component '${spec.name}' was NOT added to resolved map!`);\n console.log(`📦 [ComponentResolver] What IS in resolved map:`, Object.keys(resolved));\n }\n \n if (this.debug) {\n console.log(`📊 [ComponentResolver] Resolved components before unwrapping:`, Object.keys(resolved));\n }\n \n // Unwrap component wrappers before returning\n // Components from the registry come as objects with component/print/refresh properties\n // We need to extract just the component function for use in child components\n const unwrapped: ResolvedComponents = {};\n for (const [name, value] of Object.entries(resolved)) {\n if (value && typeof value === 'object' && 'component' in value) {\n if (typeof value.component === 'function') {\n // This is a wrapped component - extract the actual React component function\n unwrapped[name] = value.component;\n if (this.debug) {\n console.log(`✅ [ComponentResolver] Unwrapped component: ${name} (was object with .component)`);\n }\n } else {\n // ComponentObject has a component property but it's not a function\n console.error(`❌ [ComponentResolver] Component ${name} has invalid component property:`, typeof value.component, value);\n unwrapped[name] = value; // Pass through the problematic value so we can see the error\n }\n } else if (typeof value === 'function') {\n // Already a function - use as is\n unwrapped[name] = value;\n if (this.debug) {\n console.log(`✅ [ComponentResolver] Component already a function: ${name}`);\n }\n } else {\n // Something else - could be undefined or an error\n console.warn(`⚠️ [ComponentResolver] Component ${name} is not a function or wrapped component:`, typeof value, value);\n unwrapped[name] = value; // Pass through for debugging\n }\n }\n \n if (this.debug) {\n console.log(`🎯 [ComponentResolver] Final resolved components:`, Object.keys(unwrapped).map(name => ({\n name,\n type: typeof unwrapped[name],\n isUndefined: unwrapped[name] === undefined\n })));\n }\n \n return unwrapped;\n }\n\n /**\n * Recursively resolves a component hierarchy\n * @param spec - Component specification\n * @param resolved - Map to store resolved components\n * @param namespace - Namespace for resolution\n * @param visited - Set of visited component names to prevent cycles\n * @param contextUser - Optional user context for database operations\n */\n private async resolveComponentHierarchy(\n spec: ComponentSpec,\n resolved: ResolvedComponents,\n namespace: string,\n visited: Set<string> = new Set(),\n contextUser?: UserInfo\n ): Promise<void> {\n // Create a unique identifier for this component\n const componentId = `${spec.namespace || namespace}/${spec.name}@${spec.version || 'latest'}`;\n \n // Check if already resolved (not just visited)\n if (resolved[spec.name]) {\n if (this.debug) {\n console.log(`⏭️ [ComponentResolver] Component already resolved: ${spec.name}`);\n }\n return;\n }\n \n // Prevent circular dependencies\n if (visited.has(componentId)) {\n if (this.debug) {\n console.warn(`Circular dependency detected for component: ${componentId}`);\n }\n return;\n }\n visited.add(componentId);\n\n // *** CRITICAL: Process child components FIRST (depth-first, post-order) ***\n if (this.debug) {\n console.log(`🔄 [ComponentResolver] Resolving dependencies for ${spec.name} BEFORE resolving itself`);\n }\n const children = spec.dependencies || [];\n for (const child of children) {\n if (this.debug) {\n console.log(` ↳ [ComponentResolver] Resolving dependency: ${child.name} for parent ${spec.name}`);\n }\n await this.resolveComponentHierarchy(child, resolved, namespace, visited, contextUser);\n }\n if (children.length > 0 && this.debug) {\n console.log(`✅ [ComponentResolver] All ${children.length} dependencies resolved for ${spec.name}, now resolving itself`);\n }\n\n // NOW resolve the current component (it can access its dependencies)\n // Handle based on location\n if (spec.location === 'registry' && this.registryService) {\n // Registry component - need to load from database or external source\n if (this.debug) {\n console.log(`🔍 [ComponentResolver] Looking for registry component: ${spec.name} in namespace: ${spec.namespace || namespace}`);\n if (spec.registry) {\n console.log(` 📍 [ComponentResolver] External registry specified: ${spec.registry}`);\n } else {\n console.log(` 📍 [ComponentResolver] Local registry (no registry field specified)`);\n }\n }\n \n try {\n // If spec.registry is populated, this is an external registry component\n // If spec.registry is blank/undefined, this is a local registry component\n if (spec.registry) {\n // EXTERNAL REGISTRY: Need to fetch from external registry via GraphQL\n if (this.debug) {\n console.log(`🌐 [ComponentResolver] Fetching from external registry: ${spec.registry}`);\n }\n \n // Get compiled component from registry service (which will handle the external fetch)\n const compiledComponent = await this.registryService.getCompiledComponentFromRegistry(\n spec.registry, // Registry name\n spec.namespace || namespace,\n spec.name,\n spec.version || 'latest',\n this.resolverInstanceId,\n contextUser\n );\n \n if (compiledComponent) {\n resolved[spec.name] = compiledComponent;\n if (this.debug) {\n console.log(`✅ [ComponentResolver] Successfully fetched and compiled from external registry: ${spec.name}`);\n }\n } else {\n console.error(`❌ [ComponentResolver] Failed to fetch from external registry: ${spec.name} from ${spec.registry}`);\n }\n } else {\n // LOCAL REGISTRY: Get from local database via targeted RunView\n if (this.debug) {\n console.log(`💾 [ComponentResolver] Looking for locally registered component: ${spec.name}`);\n }\n\n const component = await this.componentEngine.FindComponent(\n spec.name,\n spec.namespace || namespace,\n undefined,\n contextUser\n );\n\n if (component) {\n if (this.debug) {\n console.log(`✅ [ComponentResolver] Found component in local DB:`, {\n ID: component.ID,\n Name: component.Name,\n Namespace: component.Namespace,\n Version: component.Version\n });\n }\n\n // Get compiled component from registry service (local compilation)\n const compiledComponent = await this.registryService.getCompiledComponent(\n component.ID,\n this.resolverInstanceId,\n contextUser\n );\n resolved[spec.name] = compiledComponent;\n if (this.debug) {\n console.log(`📦 [ComponentResolver] Successfully compiled and resolved local component: ${spec.name}, type: ${typeof compiledComponent}`);\n }\n } else {\n console.error(`❌ [ComponentResolver] Local registry component NOT found in database: ${spec.name} with namespace: ${spec.namespace || namespace}`);\n }\n }\n } catch (error) {\n if (this.debug) {\n console.error(`Failed to load registry component ${spec.name}:`, error);\n }\n }\n } else {\n // Embedded/Local component\n // Use the component's specified namespace if it has one, otherwise use parent's namespace\n const componentNamespace = spec.namespace || namespace;\n \n // First check if component has inline code that needs compilation\n if (spec.code && this.compiler) {\n if (this.debug) {\n console.log(`🔨 [ComponentResolver] Component ${spec.name} has inline code, compiling...`);\n }\n \n try {\n // Compile the component with its code\n const compilationResult = await this.compiler.compile({\n componentName: spec.name,\n componentCode: spec.code,\n libraries: spec.libraries,\n dependencies: spec.dependencies,\n allLibraries: [] // TODO: Get from ComponentMetadataEngine if needed\n });\n \n if (compilationResult.success && compilationResult.component) {\n // Get the component object from the factory (only if we have runtimeContext)\n if (!this.runtimeContext) {\n console.error(`❌ [ComponentResolver] Cannot compile without runtime context`);\n return;\n }\n const componentObject = compilationResult.component.factory(this.runtimeContext);\n \n // Register it in the local registry for future use\n this.registry.register(spec.name, componentObject, componentNamespace, spec.version || 'latest');\n \n // Add to resolved\n resolved[spec.name] = componentObject;\n \n if (this.debug) {\n console.log(`✅ [ComponentResolver] Successfully compiled and registered inline component: ${spec.name}`);\n }\n } else {\n console.error(`❌ [ComponentResolver] Failed to compile inline component ${spec.name}:`, compilationResult.error);\n }\n } catch (error) {\n console.error(`❌ [ComponentResolver] Error compiling inline component ${spec.name}:`, error);\n }\n } else {\n // No inline code, try to get from local registry\n if (this.debug) {\n console.log(`🔍 [ComponentResolver] Looking for embedded component: ${spec.name} in namespace: ${componentNamespace}`);\n }\n \n const component = this.registry.get(spec.name, componentNamespace);\n if (component) {\n resolved[spec.name] = component;\n if (this.debug) {\n console.log(`✅ [ComponentResolver] Found embedded component: ${spec.name}, type: ${typeof component}`);\n }\n if (this.debug) {\n console.log(`📄 Resolved embedded component: ${spec.name} from namespace ${componentNamespace}, type:`, typeof component);\n }\n } else {\n // If not found with specified namespace, try the parent namespace as fallback\n if (this.debug) {\n console.log(`⚠️ [ComponentResolver] Not found in namespace ${componentNamespace}, trying fallback namespace: ${namespace}`);\n }\n const fallbackComponent = this.registry.get(spec.name, namespace);\n if (fallbackComponent) {\n resolved[spec.name] = fallbackComponent;\n if (this.debug) {\n console.log(`✅ [ComponentResolver] Found embedded component in fallback namespace: ${spec.name}, type: ${typeof fallbackComponent}`);\n }\n if (this.debug) {\n console.log(`📄 Resolved embedded component: ${spec.name} from fallback namespace ${namespace}, type:`, typeof fallbackComponent);\n }\n } else {\n // Component not found - this might cause issues later\n console.error(`❌ [ComponentResolver] Could not resolve embedded component: ${spec.name} in namespace ${componentNamespace} or ${namespace}`);\n if (this.debug) {\n console.warn(`⚠️ Could not resolve embedded component: ${spec.name} in namespace ${componentNamespace} or ${namespace}`);\n }\n // Store undefined explicitly so we know it failed to resolve\n resolved[spec.name] = undefined;\n }\n }\n }\n }\n \n // Child components have already been processed at the beginning of this method\n // No need to process them again - we're using depth-first, post-order traversal\n }\n\n /**\n * Cleanup resolver resources\n */\n cleanup(): void {\n // Remove our references when resolver is destroyed\n if (this.registryService) {\n // This would allow the registry service to clean up unused components\n // Implementation would track which components this resolver referenced\n if (this.debug) {\n console.log(`Cleaning up resolver: ${this.resolverInstanceId}`);\n }\n }\n }\n\n /**\n * Validates that all required components are available\n * @param spec - Component specification to validate\n * @param namespace - Namespace for validation\n * @returns Array of missing component names\n */\n validateDependencies(spec: ComponentSpec, namespace: string = 'Global'): string[] {\n const missing: string[] = [];\n const checked = new Set<string>();\n \n this.checkDependencies(spec, namespace, missing, checked);\n \n return missing;\n }\n\n /**\n * Recursively checks for missing dependencies\n * @param spec - Component specification\n * @param namespace - Namespace for checking\n * @param missing - Array to collect missing components\n * @param checked - Set of already checked components\n */\n private checkDependencies(\n spec: ComponentSpec,\n namespace: string,\n missing: string[],\n checked: Set<string>\n ): void {\n if (checked.has(spec.name)) return;\n checked.add(spec.name);\n\n // Check if component exists in registry\n if (!this.registry.has(spec.name, namespace)) {\n missing.push(spec.name);\n }\n\n // Check children\n const children = spec.dependencies || [];\n for (const child of children) {\n this.checkDependencies(child, namespace, missing, checked);\n }\n }\n\n /**\n * Gets the dependency graph for a component specification\n * @param spec - Component specification\n * @returns Dependency graph as adjacency list\n */\n getDependencyGraph(spec: ComponentSpec): Map<string, string[]> {\n const graph = new Map<string, string[]>();\n const visited = new Set<string>();\n \n this.buildDependencyGraph(spec, graph, visited);\n \n return graph;\n }\n\n /**\n * Recursively builds the dependency graph\n * @param spec - Component specification\n * @param graph - Graph to build\n * @param visited - Set of visited components\n */\n private buildDependencyGraph(\n spec: ComponentSpec,\n graph: Map<string, string[]>,\n visited: Set<string>\n ): void {\n if (visited.has(spec.name)) return;\n visited.add(spec.name);\n\n const children = spec.dependencies || [];\n const dependencies = children.map(child => child.name);\n \n graph.set(spec.name, dependencies);\n\n // Recursively process children\n for (const child of children) {\n this.buildDependencyGraph(child, graph, visited);\n }\n }\n\n /**\n * Performs topological sort on component dependencies\n * @param spec - Root component specification\n * @returns Array of component names in dependency order\n */\n getLoadOrder(spec: ComponentSpec): string[] {\n const graph = this.getDependencyGraph(spec);\n const visited = new Set<string>();\n const stack: string[] = [];\n\n // Perform DFS on all nodes\n for (const node of graph.keys()) {\n if (!visited.has(node)) {\n this.topologicalSortDFS(node, graph, visited, stack);\n }\n }\n\n // Reverse to get correct load order\n return stack.reverse();\n }\n\n /**\n * DFS helper for topological sort\n * @param node - Current node\n * @param graph - Dependency graph\n * @param visited - Set of visited nodes\n * @param stack - Result stack\n */\n private topologicalSortDFS(\n node: string,\n graph: Map<string, string[]>,\n visited: Set<string>,\n stack: string[]\n ): void {\n visited.add(node);\n\n const dependencies = graph.get(node) || [];\n for (const dep of dependencies) {\n if (!visited.has(dep)) {\n this.topologicalSortDFS(dep, graph, visited, stack);\n }\n }\n\n stack.push(node);\n }\n\n /**\n * Resolves components in the correct dependency order\n * @param spec - Root component specification\n * @param namespace - Namespace for resolution\n * @returns Ordered array of resolved components\n */\n resolveInOrder(spec: ComponentSpec, namespace: string = 'Global'): Array<{\n name: string;\n component: any;\n }> {\n const loadOrder = this.getLoadOrder(spec);\n const resolved: Array<{ name: string; component: any }> = [];\n\n for (const name of loadOrder) {\n const component = this.registry.get(name, namespace);\n if (component) {\n resolved.push({ name, component });\n }\n }\n\n return resolved;\n }\n\n /**\n * Creates a flattened list of all component specifications\n * @param spec - Root component specification\n * @returns Array of all component specs in the hierarchy\n */\n flattenComponentSpecs(spec: ComponentSpec): ComponentSpec[] {\n const flattened: ComponentSpec[] = [];\n const visited = new Set<string>();\n\n this.collectComponentSpecs(spec, flattened, visited);\n\n return flattened;\n }\n\n /**\n * Recursively collects component specifications\n * @param spec - Current component specification\n * @param collected - Array to collect specs\n * @param visited - Set of visited component names\n */\n private collectComponentSpecs(\n spec: ComponentSpec,\n collected: ComponentSpec[],\n visited: Set<string>\n ): void {\n if (visited.has(spec.name)) return;\n visited.add(spec.name);\n\n collected.push(spec);\n\n const children = spec.dependencies || [];\n for (const child of children) {\n this.collectComponentSpecs(child, collected, visited);\n }\n }\n}"]}
|