@memberjunction/react-runtime 2.99.0 → 2.100.1

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.
Files changed (61) hide show
  1. package/.turbo/turbo-build.log +15 -20
  2. package/CHANGELOG.md +24 -0
  3. package/README.md +171 -1
  4. package/dist/compiler/component-compiler.d.ts.map +1 -1
  5. package/dist/compiler/component-compiler.js +10 -1
  6. package/dist/compiler/component-compiler.js.map +1 -1
  7. package/dist/component-manager/component-manager.d.ts +39 -0
  8. package/dist/component-manager/component-manager.d.ts.map +1 -0
  9. package/dist/component-manager/component-manager.js +474 -0
  10. package/dist/component-manager/component-manager.js.map +1 -0
  11. package/dist/component-manager/index.d.ts +3 -0
  12. package/dist/component-manager/index.d.ts.map +1 -0
  13. package/dist/component-manager/index.js +6 -0
  14. package/dist/component-manager/index.js.map +1 -0
  15. package/dist/component-manager/types.d.ts +62 -0
  16. package/dist/component-manager/types.d.ts.map +1 -0
  17. package/dist/component-manager/types.js +3 -0
  18. package/dist/component-manager/types.js.map +1 -0
  19. package/dist/index.d.ts +6 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +11 -2
  22. package/dist/index.js.map +1 -1
  23. package/dist/registry/component-registry-service.d.ts +16 -1
  24. package/dist/registry/component-registry-service.d.ts.map +1 -1
  25. package/dist/registry/component-registry-service.js +212 -10
  26. package/dist/registry/component-registry-service.js.map +1 -1
  27. package/dist/registry/component-registry.d.ts +1 -1
  28. package/dist/registry/component-registry.d.ts.map +1 -1
  29. package/dist/registry/component-registry.js.map +1 -1
  30. package/dist/registry/component-resolver.d.ts.map +1 -1
  31. package/dist/registry/component-resolver.js +122 -52
  32. package/dist/registry/component-resolver.js.map +1 -1
  33. package/dist/registry/index.d.ts +1 -1
  34. package/dist/registry/index.d.ts.map +1 -1
  35. package/dist/registry/index.js.map +1 -1
  36. package/dist/runtime/component-hierarchy.d.ts +4 -0
  37. package/dist/runtime/component-hierarchy.d.ts.map +1 -1
  38. package/dist/runtime/component-hierarchy.js +127 -12
  39. package/dist/runtime/component-hierarchy.js.map +1 -1
  40. package/dist/runtime.umd.js +535 -1
  41. package/dist/types/index.d.ts +1 -0
  42. package/dist/types/index.d.ts.map +1 -1
  43. package/dist/types/index.js.map +1 -1
  44. package/dist/utilities/library-loader.d.ts +3 -0
  45. package/dist/utilities/library-loader.d.ts.map +1 -1
  46. package/dist/utilities/library-loader.js +85 -17
  47. package/dist/utilities/library-loader.js.map +1 -1
  48. package/examples/component-registry-integration.ts +191 -0
  49. package/package.json +6 -5
  50. package/src/compiler/component-compiler.ts +14 -1
  51. package/src/component-manager/component-manager.ts +736 -0
  52. package/src/component-manager/index.ts +13 -0
  53. package/src/component-manager/types.ts +204 -0
  54. package/src/index.ts +27 -1
  55. package/src/registry/component-registry-service.ts +315 -18
  56. package/src/registry/component-registry.ts +1 -1
  57. package/src/registry/component-resolver.ts +159 -67
  58. package/src/registry/index.ts +1 -1
  59. package/src/runtime/component-hierarchy.ts +124 -13
  60. package/src/types/index.ts +2 -0
  61. package/src/utilities/library-loader.ts +133 -22
@@ -1 +1 @@
1
- {"version":3,"file":"component-resolver.js","sourceRoot":"","sources":["../../src/registry/component-resolver.ts"],"names":[],"mappings":";;;AAOA,6EAAwE;AAKxE,iEAAwE;AAaxE,MAAa,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,uCAAuB,CAAC,QAAQ,CAAC;QACnD,UAAK,GAAY,KAAK,CAAC;QAe7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,kBAAkB,GAAG,YAAY,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;QACpE,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nB,CAAC;IAQO,qBAAqB,CAC3B,IAAmB,EACnB,SAA0B,EAC1B,OAAoB;QAEpB,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,OAAO;QACnC,OAAO,CAAC,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;AAneD,8CAmeC","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 if (this.debug) {\n console.log(`🚀 [ComponentResolver] Starting component resolution for: ${spec.name}`);\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 (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 }\n \n try {\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 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\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: ${spec.name}, type: ${typeof compiledComponent}`);\n }\n \n if (this.debug) {\n console.log(`📦 Resolved registry component: ${spec.name} from ${componentId}`);\n }\n } else {\n console.error(`❌❌❌❌❌ [ComponentResolver] Registry component NOT found in database: ${spec.name} with namespace: ${spec.namespace || namespace} ❌❌❌❌`);\n if (this.debug) {\n console.warn(`Registry component not found in database: ${spec.name}`);\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 component - get from local registry\n // Use the component's specified namespace if it has one, otherwise use parent's namespace\n const componentNamespace = spec.namespace || namespace;\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 // 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,6EAAwE;AAKxE,iEAAwE;AAaxE,MAAa,iBAAiB;IAgB5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3B,IAAmB,EACnB,SAA0B,EAC1B,OAAoB;QAEpB,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,OAAO;QACnC,OAAO,CAAC,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;AA/jBD,8CA+jBC","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 with ${this.componentEngine.Components?.length || 0} components`);\n }\n }\n \n // Resolve the component hierarchy\n console.log(`🔄 [ComponentResolver] About to call resolveComponentHierarchy for root: ${spec.name}`);\n await this.resolveComponentHierarchy(spec, resolved, namespace, new Set(), contextUser);\n console.log(`✅ [ComponentResolver] Returned from resolveComponentHierarchy`);\n console.log(`🔍 [ComponentResolver] Looking for root component '${spec.name}' in resolved:`, !!resolved[spec.name]);\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,6 +1,6 @@
1
1
  export { ComponentRegistry } from './component-registry';
2
2
  export { ComponentResolver, ResolvedComponents } from './component-resolver';
3
- export { ComponentRegistryService } from './component-registry-service';
3
+ export { ComponentRegistryService, IComponentRegistryClient } from './component-registry-service';
4
4
  export { RegistryProvider, RegistryComponentMetadata, RegistryComponentResponse, RegistrySearchFilters, ComponentDependencyInfo, DependencyTree } from './registry-provider';
5
5
  export { ComponentSpec } from '@memberjunction/interactive-component-types';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EACL,gBAAgB,EAChB,yBAAyB,EACzB,yBAAyB,EACzB,qBAAqB,EACrB,uBAAuB,EACvB,cAAc,EACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAClG,OAAO,EACL,gBAAgB,EAChB,yBAAyB,EACzB,yBAAyB,EACzB,qBAAqB,EACrB,uBAAuB,EACvB,cAAc,EACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":";;;AAKA,2DAAyD;AAAhD,uHAAA,iBAAiB,OAAA;AAC1B,2DAA6E;AAApE,uHAAA,iBAAiB,OAAA;AAC1B,2EAAwE;AAA/D,sIAAA,wBAAwB,OAAA;AASjC,2FAA4E;AAAnE,4HAAA,aAAa,OAAA","sourcesContent":["/**\n * @fileoverview Registry module exports\n * @module @memberjunction/react-runtime/registry\n */\n\nexport { ComponentRegistry } from './component-registry';\nexport { ComponentResolver, ResolvedComponents } from './component-resolver';\nexport { ComponentRegistryService } from './component-registry-service';\nexport { \n RegistryProvider,\n RegistryComponentMetadata,\n RegistryComponentResponse,\n RegistrySearchFilters,\n ComponentDependencyInfo,\n DependencyTree\n} from './registry-provider';\nexport { ComponentSpec } from '@memberjunction/interactive-component-types';"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":";;;AAKA,2DAAyD;AAAhD,uHAAA,iBAAiB,OAAA;AAC1B,2DAA6E;AAApE,uHAAA,iBAAiB,OAAA;AAC1B,2EAAkG;AAAzF,sIAAA,wBAAwB,OAAA;AASjC,2FAA4E;AAAnE,4HAAA,aAAa,OAAA","sourcesContent":["/**\n * @fileoverview Registry module exports\n * @module @memberjunction/react-runtime/registry\n */\n\nexport { ComponentRegistry } from './component-registry';\nexport { ComponentResolver, ResolvedComponents } from './component-resolver';\nexport { ComponentRegistryService, IComponentRegistryClient } from './component-registry-service';\nexport { \n RegistryProvider,\n RegistryComponentMetadata,\n RegistryComponentResponse,\n RegistrySearchFilters,\n ComponentDependencyInfo,\n DependencyTree\n} from './registry-provider';\nexport { ComponentSpec } from '@memberjunction/interactive-component-types';"]}
@@ -2,12 +2,14 @@ import { RuntimeContext } from '../types';
2
2
  import { ComponentCompiler } from '../compiler';
3
3
  import { ComponentRegistry } from '../registry';
4
4
  import { ComponentSpec, ComponentStyles } from '@memberjunction/interactive-component-types';
5
+ import { UserInfo } from '@memberjunction/core';
5
6
  import { ComponentLibraryEntity } from '@memberjunction/core-entities';
6
7
  export interface HierarchyRegistrationResult {
7
8
  success: boolean;
8
9
  registeredComponents: string[];
9
10
  errors: ComponentRegistrationError[];
10
11
  warnings: string[];
12
+ resolvedSpec?: ComponentSpec;
11
13
  }
12
14
  export interface ComponentRegistrationError {
13
15
  componentName: string;
@@ -22,12 +24,14 @@ export interface HierarchyRegistrationOptions {
22
24
  allowOverride?: boolean;
23
25
  allLibraries: ComponentLibraryEntity[];
24
26
  debug?: boolean;
27
+ contextUser?: UserInfo;
25
28
  }
26
29
  export declare class ComponentHierarchyRegistrar {
27
30
  private compiler;
28
31
  private registry;
29
32
  private runtimeContext;
30
33
  constructor(compiler: ComponentCompiler, registry: ComponentRegistry, runtimeContext: RuntimeContext);
34
+ private fetchExternalComponent;
31
35
  registerHierarchy(rootSpec: ComponentSpec, options: HierarchyRegistrationOptions): Promise<HierarchyRegistrationResult>;
32
36
  registerSingleComponent(spec: ComponentSpec, options: {
33
37
  styles?: ComponentStyles;
@@ -1 +1 @@
1
- {"version":3,"file":"component-hierarchy.d.ts","sourceRoot":"","sources":["../../src/runtime/component-hierarchy.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,cAAc,EAEf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,iBAAi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AiB,EAC3B,QAAQ,EAAE,iBAAiB,EAC3B,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,2BAA2B,CAAC,CAGtC;AAOD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,EAAE,CA2BnE;AAOD,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,aAAa,GAAG,aAAa,EAAE,CASlF;AAQD,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,aAAa,EACvB,YAAY,GAAE,OAAe,GAC5B,MAAM,CAaR"}
@@ -1,34 +1,102 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.countComponentsInHierarchy = exports.flattenComponentHierarchy = exports.validateComponentSpec = exports.registerComponentHierarchy = exports.ComponentHierarchyRegistrar = void 0;
27
+ const core_1 = require("@memberjunction/core");
4
28
  class ComponentHierarchyRegistrar {
5
29
  constructor(compiler, registry, runtimeContext) {
6
30
  this.compiler = compiler;
7
31
  this.registry = registry;
8
32
  this.runtimeContext = runtimeContext;
9
33
  }
34
+ async fetchExternalComponent(spec, contextUser) {
35
+ try {
36
+ const provider = core_1.Metadata?.Provider;
37
+ if (!provider || !provider.ExecuteGQL) {
38
+ console.warn('⚠️ [ComponentHierarchyRegistrar] No GraphQL provider available for external registry fetch');
39
+ return null;
40
+ }
41
+ const { GraphQLComponentRegistryClient } = await Promise.resolve().then(() => __importStar(require('@memberjunction/graphql-dataprovider')));
42
+ const graphQLClient = new GraphQLComponentRegistryClient(provider);
43
+ const fullSpec = await graphQLClient.GetRegistryComponent({
44
+ registryName: spec.registry,
45
+ namespace: spec.namespace || 'Global',
46
+ name: spec.name,
47
+ version: spec.version || 'latest'
48
+ });
49
+ if (fullSpec && fullSpec.code) {
50
+ console.log(`✅ [ComponentHierarchyRegistrar] Fetched external component ${spec.name} with code (${fullSpec.code.length} chars)`);
51
+ return fullSpec;
52
+ }
53
+ else {
54
+ console.warn(`⚠️ [ComponentHierarchyRegistrar] Failed to fetch external component ${spec.name} or no code`);
55
+ return null;
56
+ }
57
+ }
58
+ catch (error) {
59
+ console.error(`❌ [ComponentHierarchyRegistrar] Error fetching external component ${spec.name}:`, error);
60
+ return null;
61
+ }
62
+ }
10
63
  async registerHierarchy(rootSpec, options) {
64
+ let resolvedRootSpec = rootSpec;
65
+ if (rootSpec.location === 'registry' && rootSpec.registry && !rootSpec.code) {
66
+ console.log(`🌐 [ComponentHierarchyRegistrar] Fetching external registry component: ${rootSpec.registry}/${rootSpec.name}`);
67
+ resolvedRootSpec = await this.fetchExternalComponent(rootSpec, options.contextUser) || rootSpec;
68
+ }
11
69
  const { styles, namespace = 'Global', version = 'v1', continueOnError = true, allowOverride = true } = options;
12
70
  console.log('🌳 ComponentHierarchyRegistrar.registerHierarchy:', {
13
- rootComponent: rootSpec.name,
14
- hasLibraries: !!(rootSpec.libraries && rootSpec.libraries.length > 0),
15
- libraryCount: rootSpec.libraries?.length || 0,
16
- libraries: rootSpec.libraries?.map(l => l.name)
71
+ rootComponent: resolvedRootSpec.name,
72
+ hasLibraries: !!(resolvedRootSpec.libraries && resolvedRootSpec.libraries.length > 0),
73
+ libraryCount: resolvedRootSpec.libraries?.length || 0,
74
+ libraries: resolvedRootSpec.libraries?.map(l => l.name)
17
75
  });
18
76
  const registeredComponents = [];
19
77
  const errors = [];
20
78
  const warnings = [];
21
79
  const compiledMap = new Map();
22
80
  const specMap = new Map();
81
+ const allLoadedLibraries = new Map();
23
82
  const compileOnly = async (spec) => {
24
83
  if (!spec.code)
25
84
  return { success: true };
26
85
  try {
86
+ const validLibraries = spec.libraries?.filter(lib => {
87
+ if (!lib || typeof lib !== 'object')
88
+ return false;
89
+ if (!lib.name || lib.name === 'unknown' || lib.name === 'null' || lib.name === 'undefined')
90
+ return false;
91
+ if (!lib.globalVariable || lib.globalVariable === 'undefined' || lib.globalVariable === 'null')
92
+ return false;
93
+ return true;
94
+ });
27
95
  const compileOptions = {
28
96
  componentName: spec.name,
29
97
  componentCode: spec.code,
30
98
  styles,
31
- libraries: spec.libraries,
99
+ libraries: validLibraries,
32
100
  dependencies: spec.dependencies,
33
101
  allLibraries: options.allLibraries
34
102
  };
@@ -36,6 +104,14 @@ class ComponentHierarchyRegistrar {
36
104
  if (result.success && result.component) {
37
105
  compiledMap.set(spec.name, result.component);
38
106
  specMap.set(spec.name, spec);
107
+ if (result.loadedLibraries) {
108
+ result.loadedLibraries.forEach((value, key) => {
109
+ if (!allLoadedLibraries.has(key)) {
110
+ allLoadedLibraries.set(key, value);
111
+ console.log(`📚 [registerHierarchy] Added library ${key} to accumulated libraries`);
112
+ }
113
+ });
114
+ }
39
115
  return { success: true };
40
116
  }
41
117
  else {
@@ -60,24 +136,43 @@ class ComponentHierarchyRegistrar {
60
136
  };
61
137
  }
62
138
  };
63
- const compileQueue = [rootSpec];
139
+ const compileQueue = [resolvedRootSpec];
64
140
  const visited = new Set();
65
141
  while (compileQueue.length > 0) {
66
- const spec = compileQueue.shift();
142
+ let spec = compileQueue.shift();
67
143
  if (visited.has(spec.name))
68
144
  continue;
69
145
  visited.add(spec.name);
146
+ if (spec.location === 'registry' && spec.registry && !spec.code) {
147
+ const fetched = await this.fetchExternalComponent(spec, options.contextUser);
148
+ if (fetched) {
149
+ spec = fetched;
150
+ }
151
+ else {
152
+ console.warn(`⚠️ [ComponentHierarchyRegistrar] Could not fetch external component ${spec.name}, skipping`);
153
+ continue;
154
+ }
155
+ }
70
156
  const result = await compileOnly(spec);
71
157
  if (!result.success) {
72
158
  errors.push(result.error);
73
159
  if (!continueOnError) {
74
- return { success: false, registeredComponents, errors, warnings };
160
+ return { success: false, registeredComponents, errors, warnings, resolvedSpec: resolvedRootSpec };
75
161
  }
76
162
  }
77
163
  if (spec.dependencies) {
78
164
  compileQueue.push(...spec.dependencies);
79
165
  }
80
166
  }
167
+ if (allLoadedLibraries.size > 0) {
168
+ if (!this.runtimeContext.libraries) {
169
+ this.runtimeContext.libraries = {};
170
+ }
171
+ allLoadedLibraries.forEach((value, key) => {
172
+ this.runtimeContext.libraries[key] = value;
173
+ console.log(`✅ [registerHierarchy] Added ${key} to runtime context libraries`);
174
+ });
175
+ }
81
176
  for (const [name, compiled] of compiledMap) {
82
177
  const spec = specMap.get(name);
83
178
  const components = {};
@@ -93,7 +188,8 @@ class ComponentHierarchyRegistrar {
93
188
  success: errors.length === 0,
94
189
  registeredComponents,
95
190
  errors,
96
- warnings
191
+ warnings,
192
+ resolvedSpec: resolvedRootSpec
97
193
  };
98
194
  }
99
195
  async registerSingleComponent(spec, options) {
@@ -116,17 +212,27 @@ class ComponentHierarchyRegistrar {
116
212
  }
117
213
  };
118
214
  }
215
+ const validLibraries = spec.libraries?.filter(lib => {
216
+ if (!lib || typeof lib !== 'object')
217
+ return false;
218
+ if (!lib.name || lib.name === 'unknown' || lib.name === 'null' || lib.name === 'undefined')
219
+ return false;
220
+ if (!lib.globalVariable || lib.globalVariable === 'undefined' || lib.globalVariable === 'null')
221
+ return false;
222
+ return true;
223
+ });
119
224
  const compileOptions = {
120
225
  componentName: spec.name,
121
226
  componentCode: spec.code,
122
227
  styles,
123
- libraries: spec.libraries,
228
+ libraries: validLibraries,
124
229
  dependencies: spec.dependencies,
125
230
  allLibraries: options.allLibraries
126
231
  };
127
232
  console.log(`🔧 Compiling component ${spec.name} with libraries:`, {
128
- libraryCount: spec.libraries?.length || 0,
129
- libraries: spec.libraries?.map(l => ({ name: l.name, globalVariable: l.globalVariable }))
233
+ originalCount: spec.libraries?.length || 0,
234
+ filteredCount: validLibraries?.length || 0,
235
+ validLibraries: validLibraries?.map(l => ({ name: l.name, globalVariable: l.globalVariable }))
130
236
  });
131
237
  const compilationResult = await this.compiler.compile(compileOptions);
132
238
  if (!compilationResult.success) {
@@ -139,6 +245,15 @@ class ComponentHierarchyRegistrar {
139
245
  }
140
246
  };
141
247
  }
248
+ if (compilationResult.loadedLibraries && compilationResult.loadedLibraries.size > 0) {
249
+ if (!this.runtimeContext.libraries) {
250
+ this.runtimeContext.libraries = {};
251
+ }
252
+ compilationResult.loadedLibraries.forEach((value, key) => {
253
+ this.runtimeContext.libraries[key] = value;
254
+ console.log(`✅ [registerSingleComponent] Added ${key} to runtime context libraries`);
255
+ });
256
+ }
142
257
  console.log(`🏭 Calling factory for ${spec.name} with runtime context:`, {
143
258
  hasReact: !!this.runtimeContext.React,
144
259
  hasReactDOM: !!this.runtimeContext.ReactDOM,
@@ -1 +1 @@
1
- {"version":3,"file":"component-hierarchy.js","sourceRoot":"","sources":["../../src/runtime/component-hierarchy.ts"],"names":[],"mappings":";;;AA8DA,MAAa,2BAA2B;IACtC,YACU,QAA2B,EAC3B,QAA2B,EAC3B,cAA8B;QAF9B,aAAQ,GAAR,QAAQ,CAAmB;QAC3B,aAAQ,GAAR,QAAQ,CAAmB;QAC3B,mBAAc,GAAd,cAAc,CAAgB;IACrC,CAAC;IAQJ,KAAK,CAAC,iBAAiB,CACrB,QAAuB,EAC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,CAAC,CAAC;IAE/C,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,IAAI,EAAE,CAAC;IAC7C,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACvB,UAAU,CAAC,IAAI,CAAC,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACpB,CAAC;AATD,8DASC;AAQD,SAAgB,0BAA0B,CACxC,QAAuB,EACvB,eAAwB,KAAK;IAE7B,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,IAAI,YAAY,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;QAClC,KAAK,GAAG,CAAC,CAAC;IACZ,CAAC;IAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,IAAI,EAAE,CAAC;IAC7C,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACvB,KAAK,IAAI,0BAA0B,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC;AAhBD,gEAgBC","sourcesContent":["/**\n * @fileoverview Component hierarchy registration utilities for MemberJunction React Runtime.\n * Provides functionality to register a hierarchy of components from Skip component specifications.\n * @module @memberjunction/react-runtime/hierarchy\n */\n\nimport { \n CompilationResult,\n CompileOptions,\n RuntimeContext,\n CompiledComponent\n} from '../types';\nimport { ComponentCompiler } from '../compiler';\nimport { ComponentRegistry } from '../registry';\n\nimport { ComponentSpec, ComponentStyles } from '@memberjunction/interactive-component-types';\nimport { UserInfo } from '@memberjunction/core';\nimport { ComponentLibraryEntity } from '@memberjunction/core-entities';\n\n/**\n * Result of a hierarchy registration operation\n */\nexport interface HierarchyRegistrationResult {\n success: boolean;\n registeredComponents: string[];\n errors: ComponentRegistrationError[];\n warnings: string[];\n}\n\n/**\n * Error information for component registration\n */\nexport interface ComponentRegistrationError {\n componentName: string;\n error: string;\n phase: 'compilation' | 'registration' | 'validation';\n}\n\n/**\n * Options for hierarchy registration\n */\nexport interface HierarchyRegistrationOptions {\n /** Component styles to apply to all components */\n styles?: ComponentStyles;\n /** Namespace for component registration */\n namespace?: string;\n /** Version for component registration */\n version?: string;\n /** Whether to continue on errors */\n continueOnError?: boolean;\n /** Whether to override existing components */\n allowOverride?: boolean;\n /**\n * Required, metadata for all possible libraries allowed by the system\n */\n allLibraries: ComponentLibraryEntity[];\n debug?: boolean;\n}\n\n/**\n * Utility class for registering component hierarchies\n */\nexport class ComponentHierarchyRegistrar {\n constructor(\n private compiler: ComponentCompiler,\n private registry: ComponentRegistry,\n private runtimeContext: RuntimeContext\n ) {}\n\n /**\n * Registers a complete component hierarchy from a root specification\n * @param rootSpec - The root component specification\n * @param options - Registration options\n * @returns Registration result with details about success/failures\n */\n async registerHierarchy(\n rootSpec: ComponentSpec,\n options: HierarchyRegistrationOptions\n ): Promise<HierarchyRegistrationResult> {\n const {\n styles,\n namespace = 'Global',\n version = 'v1',\n continueOnError = true,\n allowOverride = true\n } = options;\n\n console.log('🌳 ComponentHierarchyRegistrar.registerHierarchy:', {\n rootComponent: rootSpec.name,\n hasLibraries: !!(rootSpec.libraries && rootSpec.libraries.length > 0),\n libraryCount: rootSpec.libraries?.length || 0,\n libraries: rootSpec.libraries?.map(l => l.name)\n });\n\n const registeredComponents: string[] = [];\n const errors: ComponentRegistrationError[] = [];\n const warnings: string[] = [];\n\n // PHASE 1: Compile all components first (but defer factory execution)\n const compiledMap = new Map<string, CompiledComponent>();\n const specMap = new Map<string, ComponentSpec>();\n \n // Helper to compile a component without calling its factory\n const compileOnly = async (spec: ComponentSpec): Promise<{ success: boolean; error?: ComponentRegistrationError }> => {\n if (!spec.code) return { success: true };\n \n try {\n const compileOptions: CompileOptions = {\n componentName: spec.name,\n componentCode: spec.code,\n styles,\n libraries: spec.libraries,\n dependencies: spec.dependencies,\n allLibraries: options.allLibraries\n };\n \n const result = await this.compiler.compile(compileOptions);\n if (result.success && result.component) {\n compiledMap.set(spec.name, result.component);\n specMap.set(spec.name, spec);\n return { success: true };\n } else {\n return {\n success: false,\n error: {\n componentName: spec.name,\n error: result.error?.message || 'Unknown compilation error',\n phase: 'compilation'\n }\n };\n }\n } catch (error) {\n return {\n success: false,\n error: {\n componentName: spec.name,\n error: error instanceof Error ? error.message : String(error),\n phase: 'compilation'\n }\n };\n }\n };\n \n // Compile all components in hierarchy\n const compileQueue = [rootSpec];\n const visited = new Set<string>();\n \n while (compileQueue.length > 0) {\n const spec = compileQueue.shift()!;\n if (visited.has(spec.name)) continue;\n visited.add(spec.name);\n \n const result = await compileOnly(spec);\n if (!result.success) {\n errors.push(result.error!);\n if (!continueOnError) {\n return { success: false, registeredComponents, errors, warnings };\n }\n }\n \n if (spec.dependencies) {\n compileQueue.push(...spec.dependencies);\n }\n }\n \n // PHASE 2: Execute all factories with components available\n for (const [name, compiled] of compiledMap) {\n const spec = specMap.get(name)!;\n \n // Build components object from all registered components\n const components: Record<string, any> = {};\n for (const [depName, depCompiled] of compiledMap) {\n // Call factory to get ComponentObject, then extract React component\n const depObject = depCompiled.factory(this.runtimeContext, styles);\n components[depName] = depObject.component;\n }\n \n // Now call factory with components available\n const componentObject = compiled.factory(this.runtimeContext, styles, components);\n \n // Register in registry\n this.registry.register(\n spec.name,\n componentObject,\n spec.namespace || namespace,\n version\n );\n \n registeredComponents.push(spec.name);\n }\n\n return {\n success: errors.length === 0,\n registeredComponents,\n errors,\n warnings\n };\n }\n\n /**\n * Registers a single component from a specification\n * @param spec - Component specification\n * @param options - Registration options\n * @returns Registration result for this component\n */\n async registerSingleComponent(\n spec: ComponentSpec,\n options: {\n styles?: ComponentStyles;\n namespace?: string;\n version?: string;\n allowOverride?: boolean;\n allLibraries: ComponentLibraryEntity[];\n }\n ): Promise<{ success: boolean; error?: ComponentRegistrationError }> {\n const { styles, namespace = 'Global', version = 'v1', allowOverride = true } = options;\n\n try {\n // Skip if no component code\n if (!spec.code) {\n return {\n success: true,\n error: undefined\n };\n }\n\n // Check if component already exists\n const existingComponent = this.registry.get(spec.name, namespace, version);\n if (existingComponent && !allowOverride) {\n return {\n success: false,\n error: {\n componentName: spec.name,\n error: `Component already registered in ${namespace}/${version}`,\n phase: 'registration'\n }\n };\n }\n\n // Compile the component\n const compileOptions: CompileOptions = {\n componentName: spec.name,\n componentCode: spec.code,\n styles,\n libraries: spec.libraries, // Pass along library dependencies from the spec\n dependencies: spec.dependencies, // Pass along child component dependencies\n allLibraries: options.allLibraries\n };\n\n console.log(`🔧 Compiling component ${spec.name} with libraries:`, {\n libraryCount: spec.libraries?.length || 0,\n libraries: spec.libraries?.map(l => ({ name: l.name, globalVariable: l.globalVariable }))\n });\n\n const compilationResult = await this.compiler.compile(compileOptions);\n\n if (!compilationResult.success) {\n return {\n success: false,\n error: {\n componentName: spec.name,\n error: compilationResult.error?.message || 'Unknown compilation error',\n phase: 'compilation'\n }\n };\n }\n\n // Call the factory to create the ComponentObject\n // IMPORTANT: We don't pass components here because child components may not be registered yet\n // Components are resolved later when the component is actually rendered\n console.log(`🏭 Calling factory for ${spec.name} with runtime context:`, {\n hasReact: !!this.runtimeContext.React,\n hasReactDOM: !!this.runtimeContext.ReactDOM,\n libraryKeys: Object.keys(this.runtimeContext.libraries || {})\n });\n const componentObject = compilationResult.component!.factory(this.runtimeContext, styles);\n\n // Register the full ComponentObject (not just the React component)\n this.registry.register(\n spec.name,\n componentObject,\n spec.namespace || namespace,\n version\n );\n\n return { success: true };\n\n } catch (error) {\n return {\n success: false,\n error: {\n componentName: spec.name,\n error: error instanceof Error ? error.message : String(error),\n phase: 'registration'\n }\n };\n }\n }\n\n /**\n * Recursively registers child components\n * @param children - Array of child component specifications\n * @param options - Registration options\n * @param registeredComponents - Array to track registered components\n * @param errors - Array to collect errors\n * @param warnings - Array to collect warnings\n */\n private async registerChildComponents(\n children: ComponentSpec[],\n options: HierarchyRegistrationOptions,\n registeredComponents: string[],\n errors: ComponentRegistrationError[],\n warnings: string[]\n ): Promise<void> {\n for (const child of children) {\n // Register this child\n const childResult = await this.registerSingleComponent(child, {\n styles: options.styles,\n namespace: options.namespace,\n version: options.version,\n allowOverride: options.allowOverride,\n allLibraries: options.allLibraries\n });\n\n if (childResult.success) {\n if (child.code) {\n registeredComponents.push(child.name);\n }\n } else {\n errors.push(childResult.error!);\n if (!options.continueOnError) {\n return;\n }\n }\n\n // Register nested children recursively\n const nestedChildren = child.dependencies || [];\n if (nestedChildren.length > 0) {\n await this.registerChildComponents(\n nestedChildren,\n options,\n registeredComponents,\n errors,\n warnings\n );\n }\n }\n }\n}\n\n/**\n * Convenience function to register a component hierarchy\n * @param rootSpec - The root component specification\n * @param compiler - Component compiler instance\n * @param registry - Component registry instance\n * @param runtimeContext - Runtime context with React and other libraries\n * @param options - Registration options\n * @returns Registration result\n */\nexport async function registerComponentHierarchy(\n rootSpec: ComponentSpec,\n compiler: ComponentCompiler,\n registry: ComponentRegistry,\n runtimeContext: RuntimeContext,\n options: HierarchyRegistrationOptions\n): Promise<HierarchyRegistrationResult> {\n const registrar = new ComponentHierarchyRegistrar(compiler, registry, runtimeContext);\n return registrar.registerHierarchy(rootSpec, options);\n}\n\n/**\n * Validates a component specification before registration\n * @param spec - Component specification to validate\n * @returns Array of validation errors (empty if valid)\n */\nexport function validateComponentSpec(spec: ComponentSpec): string[] {\n const errors: string[] = [];\n\n if (!spec.name) {\n errors.push('Component specification must have a name');\n }\n\n // If componentCode is provided, do basic validation\n if (spec.code) {\n if (typeof spec.code !== 'string') {\n errors.push(`Component code for ${spec.name} must be a string`);\n }\n if (spec.code.trim().length === 0) {\n errors.push(`Component code for ${spec.name} cannot be empty`);\n }\n }\n\n // Validate child components recursively\n const children = spec.dependencies || [];\n children.forEach((child, index) => {\n const childErrors = validateComponentSpec(child);\n childErrors.forEach(error => {\n errors.push(`Child ${index} (${child.name || 'unnamed'}): ${error}`);\n });\n });\n\n return errors;\n}\n\n/**\n * Flattens a component hierarchy into a list of all components\n * @param rootSpec - The root component specification\n * @returns Array of all component specifications in the hierarchy\n */\nexport function flattenComponentHierarchy(rootSpec: ComponentSpec): ComponentSpec[] {\n const components: ComponentSpec[] = [rootSpec];\n \n const children = rootSpec.dependencies || [];\n children.forEach(child => {\n components.push(...flattenComponentHierarchy(child));\n });\n\n return components;\n}\n\n/**\n * Counts the total number of components in a hierarchy\n * @param rootSpec - The root component specification\n * @param includeEmpty - Whether to include components without code\n * @returns Total component count\n */\nexport function countComponentsInHierarchy(\n rootSpec: ComponentSpec,\n includeEmpty: boolean = false\n): number {\n let count = 0;\n \n if (includeEmpty || rootSpec.code) {\n count = 1;\n }\n\n const children = rootSpec.dependencies || [];\n children.forEach(child => {\n count += countComponentsInHierarchy(child, includeEmpty);\n });\n\n return count;\n}"]}
1
+ {"version":3,"file":"component-hierarchy.js","sourceRoot":"","sources":["../../src/runtime/component-hierarchy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,+CAA0D;AAkD1D,MAAa,2BAA2B;IACtC,YACU,QAA2B,EAC3B,QAA2B,EAC3B,cAA8B;QAF9B,aAAQ,GAAR,QAAQ,CAAmB;QAC3B,aAAQ,GAAR,QAAQ,CAAmB;QAC3B,mBAAc,GAAd,cAAc,CAAgB;IACrC,CAAC;IAKI,KAAK,CAAC,sBAAsB,CAClC,IAAmB,EACnB,WAAsB;QAEtB,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,eAAQ,EAAE,QAAQ,CAAC;YACpC,IAAI,CAAC,QAAQ,IAAI,CAAE,QAAgB,CAAC,UAAU,EAAE,CAAC;gBAC/C,OAAO,CAAC,IAAI,CAAC,4FAA4F,CAAC,CAAC;gBAC3G,OAAO,IAAI,CAAC;YACd,CAAC;YAGD,MAAM,EAAE,8BAA8B,EAAE,GAAG,wDAAa,sCAAsC,GAAC,CAAC;YAChG,MAAM,aAAa,GAAG,IAAI,8BAA8B,CAAC,QAAe,CAAC,CAAC;YAE1E,MAAM,QAAQ,GAAG,MAAM,aAAa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C,KAAK,CAAC,EAAE;YAC1B,MAAM,CAAC,IAAI,CAAC,SAAS,KAAK,KAAK,KAAK,CAAC,IAAI,IAAI,SAAS,MAAM,KAAK,EAAE,CAAC,CAAC;QACvE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AA3BD,sDA2BC;AAOD,SAAgB,yBAAyB,CAAC,QAAuB;IAC/D,MAAM,UAAU,GAAoB,CAAC,QAAQ,CAAC,CAAC;IAE/C,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,IAAI,EAAE,CAAC;IAC7C,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACvB,UAAU,CAAC,IAAI,CAAC,GAAG,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,OAAO,UAAU,CAAC;AACpB,CAAC;AATD,8DASC;AAQD,SAAgB,0BAA0B,CACxC,QAAuB,EACvB,eAAwB,KAAK;IAE7B,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,IAAI,YAAY,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC;QAClC,KAAK,GAAG,CAAC,CAAC;IACZ,CAAC;IAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,IAAI,EAAE,CAAC;IAC7C,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACvB,KAAK,IAAI,0BAA0B,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC;AAhBD,gEAgBC","sourcesContent":["/**\n * @fileoverview Component hierarchy registration utilities for MemberJunction React Runtime.\n * Provides functionality to register a hierarchy of components from Skip component specifications.\n * @module @memberjunction/react-runtime/hierarchy\n */\n\nimport { \n CompilationResult,\n CompileOptions,\n RuntimeContext,\n CompiledComponent\n} from '../types';\nimport { ComponentCompiler } from '../compiler';\nimport { ComponentRegistry } from '../registry';\n\nimport { ComponentSpec, ComponentStyles } from '@memberjunction/interactive-component-types';\nimport { UserInfo, Metadata } from '@memberjunction/core';\nimport { ComponentLibraryEntity } from '@memberjunction/core-entities';\n\n/**\n * Result of a hierarchy registration operation\n */\nexport interface HierarchyRegistrationResult {\n success: boolean;\n registeredComponents: string[];\n errors: ComponentRegistrationError[];\n warnings: string[];\n /** The fully resolved component specification with all dependencies and libraries */\n resolvedSpec?: ComponentSpec;\n}\n\n/**\n * Error information for component registration\n */\nexport interface ComponentRegistrationError {\n componentName: string;\n error: string;\n phase: 'compilation' | 'registration' | 'validation';\n}\n\n/**\n * Options for hierarchy registration\n */\nexport interface HierarchyRegistrationOptions {\n /** Component styles to apply to all components */\n styles?: ComponentStyles;\n /** Namespace for component registration */\n namespace?: string;\n /** Version for component registration */\n version?: string;\n /** Whether to continue on errors */\n continueOnError?: boolean;\n /** Whether to override existing components */\n allowOverride?: boolean;\n /**\n * Required, metadata for all possible libraries allowed by the system\n */\n allLibraries: ComponentLibraryEntity[];\n debug?: boolean;\n /** Optional user context for fetching from external registries */\n contextUser?: UserInfo;\n}\n\n/**\n * Utility class for registering component hierarchies\n */\nexport class ComponentHierarchyRegistrar {\n constructor(\n private compiler: ComponentCompiler,\n private registry: ComponentRegistry,\n private runtimeContext: RuntimeContext\n ) {}\n \n /**\n * Fetches a component specification from an external registry\n */\n private async fetchExternalComponent(\n spec: ComponentSpec,\n contextUser?: UserInfo\n ): Promise<ComponentSpec | null> {\n try {\n const provider = Metadata?.Provider;\n if (!provider || !(provider as any).ExecuteGQL) {\n console.warn('⚠️ [ComponentHierarchyRegistrar] No GraphQL provider available for external registry fetch');\n return null;\n }\n \n // Dynamically import the GraphQL client to avoid circular dependencies\n const { GraphQLComponentRegistryClient } = await import('@memberjunction/graphql-dataprovider');\n const graphQLClient = new GraphQLComponentRegistryClient(provider as any);\n \n const fullSpec = await graphQLClient.GetRegistryComponent({\n registryName: spec.registry!,\n namespace: spec.namespace || 'Global',\n name: spec.name,\n version: spec.version || 'latest'\n });\n \n if (fullSpec && fullSpec.code) {\n console.log(`✅ [ComponentHierarchyRegistrar] Fetched external component ${spec.name} with code (${fullSpec.code.length} chars)`);\n return fullSpec;\n } else {\n console.warn(`⚠️ [ComponentHierarchyRegistrar] Failed to fetch external component ${spec.name} or no code`);\n return null;\n }\n } catch (error) {\n console.error(`❌ [ComponentHierarchyRegistrar] Error fetching external component ${spec.name}:`, error);\n return null;\n }\n }\n\n /**\n * Registers a complete component hierarchy from a root specification\n * @param rootSpec - The root component specification\n * @param options - Registration options\n * @returns Registration result with details about success/failures\n */\n async registerHierarchy(\n rootSpec: ComponentSpec,\n options: HierarchyRegistrationOptions\n ): Promise<HierarchyRegistrationResult> {\n // If this is an external registry component without code, fetch it first\n let resolvedRootSpec = rootSpec;\n if (rootSpec.location === 'registry' && rootSpec.registry && !rootSpec.code) {\n console.log(`🌐 [ComponentHierarchyRegistrar] Fetching external registry component: ${rootSpec.registry}/${rootSpec.name}`);\n resolvedRootSpec = await this.fetchExternalComponent(rootSpec, options.contextUser) || rootSpec;\n }\n const {\n styles,\n namespace = 'Global',\n version = 'v1',\n continueOnError = true,\n allowOverride = true\n } = options;\n\n console.log('🌳 ComponentHierarchyRegistrar.registerHierarchy:', {\n rootComponent: resolvedRootSpec.name,\n hasLibraries: !!(resolvedRootSpec.libraries && resolvedRootSpec.libraries.length > 0),\n libraryCount: resolvedRootSpec.libraries?.length || 0,\n libraries: resolvedRootSpec.libraries?.map(l => l.name)\n });\n\n const registeredComponents: string[] = [];\n const errors: ComponentRegistrationError[] = [];\n const warnings: string[] = [];\n\n // PHASE 1: Compile all components first (but defer factory execution)\n const compiledMap = new Map<string, CompiledComponent>();\n const specMap = new Map<string, ComponentSpec>();\n const allLoadedLibraries = new Map<string, any>(); // Track all loaded libraries\n \n // Helper to compile a component without calling its factory\n const compileOnly = async (spec: ComponentSpec): Promise<{ success: boolean; error?: ComponentRegistrationError }> => {\n if (!spec.code) return { success: true };\n \n try {\n // Filter out invalid library entries before compilation\n const validLibraries = spec.libraries?.filter(lib => {\n if (!lib || typeof lib !== 'object') return false;\n if (!lib.name || lib.name === 'unknown' || lib.name === 'null' || lib.name === 'undefined') return false;\n if (!lib.globalVariable || lib.globalVariable === 'undefined' || lib.globalVariable === 'null') return false;\n return true;\n });\n \n const compileOptions: CompileOptions = {\n componentName: spec.name,\n componentCode: spec.code,\n styles,\n libraries: validLibraries,\n dependencies: spec.dependencies,\n allLibraries: options.allLibraries\n };\n \n const result = await this.compiler.compile(compileOptions);\n if (result.success && result.component) {\n compiledMap.set(spec.name, result.component);\n specMap.set(spec.name, spec);\n \n // Extract and accumulate loaded libraries from the compilation\n if (result.loadedLibraries) {\n result.loadedLibraries.forEach((value, key) => {\n if (!allLoadedLibraries.has(key)) {\n allLoadedLibraries.set(key, value);\n console.log(`📚 [registerHierarchy] Added library ${key} to accumulated libraries`);\n }\n });\n }\n \n return { success: true };\n } else {\n return {\n success: false,\n error: {\n componentName: spec.name,\n error: result.error?.message || 'Unknown compilation error',\n phase: 'compilation'\n }\n };\n }\n } catch (error) {\n return {\n success: false,\n error: {\n componentName: spec.name,\n error: error instanceof Error ? error.message : String(error),\n phase: 'compilation'\n }\n };\n }\n };\n \n // Compile all components in hierarchy\n const compileQueue = [resolvedRootSpec];\n const visited = new Set<string>();\n \n while (compileQueue.length > 0) {\n let spec = compileQueue.shift()!;\n if (visited.has(spec.name)) continue;\n visited.add(spec.name);\n \n // If this is an external registry component without code, fetch it first\n if (spec.location === 'registry' && spec.registry && !spec.code) {\n const fetched = await this.fetchExternalComponent(spec, options.contextUser);\n if (fetched) {\n spec = fetched;\n } else {\n console.warn(`⚠️ [ComponentHierarchyRegistrar] Could not fetch external component ${spec.name}, skipping`);\n continue;\n }\n }\n \n const result = await compileOnly(spec);\n if (!result.success) {\n errors.push(result.error!);\n if (!continueOnError) {\n return { success: false, registeredComponents, errors, warnings, resolvedSpec: resolvedRootSpec };\n }\n }\n \n if (spec.dependencies) {\n compileQueue.push(...spec.dependencies);\n }\n }\n \n // Add all accumulated libraries to runtime context\n if (allLoadedLibraries.size > 0) {\n if (!this.runtimeContext.libraries) {\n this.runtimeContext.libraries = {};\n }\n allLoadedLibraries.forEach((value, key) => {\n this.runtimeContext.libraries![key] = value;\n console.log(`✅ [registerHierarchy] Added ${key} to runtime context libraries`);\n });\n }\n \n // PHASE 2: Execute all factories with components available\n for (const [name, compiled] of compiledMap) {\n const spec = specMap.get(name)!;\n \n // Build components object from all registered components\n const components: Record<string, any> = {};\n for (const [depName, depCompiled] of compiledMap) {\n // Call factory to get ComponentObject, then extract React component\n const depObject = depCompiled.factory(this.runtimeContext, styles);\n components[depName] = depObject.component;\n }\n \n // Now call factory with components available\n const componentObject = compiled.factory(this.runtimeContext, styles, components);\n \n // Register in registry\n this.registry.register(\n spec.name,\n componentObject,\n spec.namespace || namespace,\n version\n );\n \n registeredComponents.push(spec.name);\n }\n\n return {\n success: errors.length === 0,\n registeredComponents,\n errors,\n warnings,\n resolvedSpec: resolvedRootSpec\n };\n }\n\n /**\n * Registers a single component from a specification\n * @param spec - Component specification\n * @param options - Registration options\n * @returns Registration result for this component\n */\n async registerSingleComponent(\n spec: ComponentSpec,\n options: {\n styles?: ComponentStyles;\n namespace?: string;\n version?: string;\n allowOverride?: boolean;\n allLibraries: ComponentLibraryEntity[];\n }\n ): Promise<{ success: boolean; error?: ComponentRegistrationError }> {\n const { styles, namespace = 'Global', version = 'v1', allowOverride = true } = options;\n\n try {\n // Skip if no component code\n if (!spec.code) {\n return {\n success: true,\n error: undefined\n };\n }\n\n // Check if component already exists\n const existingComponent = this.registry.get(spec.name, namespace, version);\n if (existingComponent && !allowOverride) {\n return {\n success: false,\n error: {\n componentName: spec.name,\n error: `Component already registered in ${namespace}/${version}`,\n phase: 'registration'\n }\n };\n }\n\n // Filter out invalid library entries before compilation\n const validLibraries = spec.libraries?.filter(lib => {\n if (!lib || typeof lib !== 'object') return false;\n if (!lib.name || lib.name === 'unknown' || lib.name === 'null' || lib.name === 'undefined') return false;\n if (!lib.globalVariable || lib.globalVariable === 'undefined' || lib.globalVariable === 'null') return false;\n return true;\n });\n \n // Compile the component\n const compileOptions: CompileOptions = {\n componentName: spec.name,\n componentCode: spec.code,\n styles,\n libraries: validLibraries, // Pass along filtered library dependencies\n dependencies: spec.dependencies, // Pass along child component dependencies\n allLibraries: options.allLibraries\n };\n\n console.log(`🔧 Compiling component ${spec.name} with libraries:`, {\n originalCount: spec.libraries?.length || 0,\n filteredCount: validLibraries?.length || 0,\n validLibraries: validLibraries?.map(l => ({ name: l.name, globalVariable: l.globalVariable }))\n });\n\n const compilationResult = await this.compiler.compile(compileOptions);\n\n if (!compilationResult.success) {\n return {\n success: false,\n error: {\n componentName: spec.name,\n error: compilationResult.error?.message || 'Unknown compilation error',\n phase: 'compilation'\n }\n };\n }\n\n // Add loaded libraries to runtime context\n if (compilationResult.loadedLibraries && compilationResult.loadedLibraries.size > 0) {\n if (!this.runtimeContext.libraries) {\n this.runtimeContext.libraries = {};\n }\n compilationResult.loadedLibraries.forEach((value, key) => {\n this.runtimeContext.libraries![key] = value;\n console.log(`✅ [registerSingleComponent] Added ${key} to runtime context libraries`);\n });\n }\n\n // Call the factory to create the ComponentObject\n // IMPORTANT: We don't pass components here because child components may not be registered yet\n // Components are resolved later when the component is actually rendered\n console.log(`🏭 Calling factory for ${spec.name} with runtime context:`, {\n hasReact: !!this.runtimeContext.React,\n hasReactDOM: !!this.runtimeContext.ReactDOM,\n libraryKeys: Object.keys(this.runtimeContext.libraries || {})\n });\n const componentObject = compilationResult.component!.factory(this.runtimeContext, styles);\n\n // Register the full ComponentObject (not just the React component)\n this.registry.register(\n spec.name,\n componentObject,\n spec.namespace || namespace,\n version\n );\n\n return { success: true };\n\n } catch (error) {\n return {\n success: false,\n error: {\n componentName: spec.name,\n error: error instanceof Error ? error.message : String(error),\n phase: 'registration'\n }\n };\n }\n }\n\n /**\n * Recursively registers child components\n * @param children - Array of child component specifications\n * @param options - Registration options\n * @param registeredComponents - Array to track registered components\n * @param errors - Array to collect errors\n * @param warnings - Array to collect warnings\n */\n private async registerChildComponents(\n children: ComponentSpec[],\n options: HierarchyRegistrationOptions,\n registeredComponents: string[],\n errors: ComponentRegistrationError[],\n warnings: string[]\n ): Promise<void> {\n for (const child of children) {\n // Register this child\n const childResult = await this.registerSingleComponent(child, {\n styles: options.styles,\n namespace: options.namespace,\n version: options.version,\n allowOverride: options.allowOverride,\n allLibraries: options.allLibraries\n });\n\n if (childResult.success) {\n if (child.code) {\n registeredComponents.push(child.name);\n }\n } else {\n errors.push(childResult.error!);\n if (!options.continueOnError) {\n return;\n }\n }\n\n // Register nested children recursively\n const nestedChildren = child.dependencies || [];\n if (nestedChildren.length > 0) {\n await this.registerChildComponents(\n nestedChildren,\n options,\n registeredComponents,\n errors,\n warnings\n );\n }\n }\n }\n}\n\n/**\n * Convenience function to register a component hierarchy\n * @param rootSpec - The root component specification\n * @param compiler - Component compiler instance\n * @param registry - Component registry instance\n * @param runtimeContext - Runtime context with React and other libraries\n * @param options - Registration options\n * @returns Registration result\n */\nexport async function registerComponentHierarchy(\n rootSpec: ComponentSpec,\n compiler: ComponentCompiler,\n registry: ComponentRegistry,\n runtimeContext: RuntimeContext,\n options: HierarchyRegistrationOptions\n): Promise<HierarchyRegistrationResult> {\n const registrar = new ComponentHierarchyRegistrar(compiler, registry, runtimeContext);\n return registrar.registerHierarchy(rootSpec, options);\n}\n\n/**\n * Validates a component specification before registration\n * @param spec - Component specification to validate\n * @returns Array of validation errors (empty if valid)\n */\nexport function validateComponentSpec(spec: ComponentSpec): string[] {\n const errors: string[] = [];\n\n if (!spec.name) {\n errors.push('Component specification must have a name');\n }\n\n // If componentCode is provided, do basic validation\n if (spec.code) {\n if (typeof spec.code !== 'string') {\n errors.push(`Component code for ${spec.name} must be a string`);\n }\n if (spec.code.trim().length === 0) {\n errors.push(`Component code for ${spec.name} cannot be empty`);\n }\n }\n\n // Validate child components recursively\n const children = spec.dependencies || [];\n children.forEach((child, index) => {\n const childErrors = validateComponentSpec(child);\n childErrors.forEach(error => {\n errors.push(`Child ${index} (${child.name || 'unnamed'}): ${error}`);\n });\n });\n\n return errors;\n}\n\n/**\n * Flattens a component hierarchy into a list of all components\n * @param rootSpec - The root component specification\n * @returns Array of all component specifications in the hierarchy\n */\nexport function flattenComponentHierarchy(rootSpec: ComponentSpec): ComponentSpec[] {\n const components: ComponentSpec[] = [rootSpec];\n \n const children = rootSpec.dependencies || [];\n children.forEach(child => {\n components.push(...flattenComponentHierarchy(child));\n });\n\n return components;\n}\n\n/**\n * Counts the total number of components in a hierarchy\n * @param rootSpec - The root component specification\n * @param includeEmpty - Whether to include components without code\n * @returns Total component count\n */\nexport function countComponentsInHierarchy(\n rootSpec: ComponentSpec,\n includeEmpty: boolean = false\n): number {\n let count = 0;\n \n if (includeEmpty || rootSpec.code) {\n count = 1;\n }\n\n const children = rootSpec.dependencies || [];\n children.forEach(child => {\n count += countComponentsInHierarchy(child, includeEmpty);\n });\n\n return count;\n}"]}