@memberjunction/ng-artifacts 6.1.2 → 6.2.0-edge.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.
@@ -142,16 +142,16 @@ export class ArtifactTypePluginViewerComponent extends BaseAngularComponent {
142
142
  this.isLoading = false;
143
143
  return;
144
144
  }
145
- // Get the component type using MJGlobal ClassFactory
146
- // CreateInstance returns the registered component class for the given DriverClass key
147
- const tempInstance = await MJGlobal.Instance.ClassFactory.CreateInstanceAsync(BaseArtifactViewerPluginComponent, driverClass);
148
- if (!tempInstance) {
145
+ // Look up the registered component class from ClassFactory WITHOUT instantiating it,
146
+ // so Angular's createComponent can properly instantiate it within the Angular injection context.
147
+ const registration = await MJGlobal.Instance.ClassFactory.GetRegistrationAsync(BaseArtifactViewerPluginComponent, driverClass);
148
+ if (!registration?.SubClass) {
149
149
  this.setError('Viewer Component Not Found', `The viewer component "${driverClass}" is not registered in the application. This usually means the required package or module hasn't been loaded.`, `Component "${driverClass}" not found in ClassFactory registry. Ensure it's registered with @RegisterClass(BaseArtifactViewerPluginComponent, '${driverClass}').`);
150
150
  this.isLoading = false;
151
151
  return;
152
152
  }
153
- // Get the component type from the instance
154
- const componentType = tempInstance.constructor;
153
+ // Get the component type from the registration
154
+ const componentType = registration.SubClass;
155
155
  // Destroy previous viewer if exists
156
156
  this.destroyCurrentViewer();
157
157
  // Create and configure the viewer component
@@ -1 +1 @@
1
- {"version":3,"file":"artifact-type-plugin-viewer.component.js","sourceRoot":"","sources":["../../../src/lib/components/artifact-type-plugin-viewer.component.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,EACL,MAAM,EACN,YAAY,EAIZ,SAAS,EACT,gBAAgB,EAGjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAiD,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACtH,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAY,Q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AAC;IACH,CAAC;IAED;;OAEG;IACK,oBAAoB;QAC1B,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;YAC5B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QAC3B,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;iTAnUU,iCAAiC,yBAAjC,iCAAiC;6DAAjC,iCAAiC;mCAoBN,gBAAgB;;;;;YA3GpD,8BAAyC;YACvC,mGAAiB;YAMjB,mGAAa;YAYb,iCAA8C;YAChD,iBAAM;;YAnBJ,cAKC;YALD,wCAKC;YACD,cAWC;YAXD,oCAWC;;;iFAqEM,iCAAiC;cA3F7C,SAAS;6BACI,KAAK,YACP,gCAAgC,YAChC;;;;;;;;;;;;;;;;;;;;;;GAsBT;;kBAmEA,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBAEL,MAAM;;kBACN,MAAM;;kBACN,MAAM;;kBACN,MAAM;;kBAON,MAAM;;kBAEN,SAAS;mBAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,IAAI,EAAE;;kFApB3D,iCAAiC","sourcesContent":["import {\n Component,\n Input,\n Output,\n EventEmitter,\n OnInit,\n OnChanges,\n SimpleChanges,\n ViewChild,\n ViewContainerRef,\n ComponentRef,\n Type\n} from '@angular/core';\nimport { MJArtifactVersionEntity, MJArtifactTypeEntity, ArtifactMetadataEngine } from '@memberjunction/core-entities';\nimport { BaseAngularComponent } from '@memberjunction/ng-base-types';\nimport { Metadata, LogError, RunView, CompositeKey } from '@memberjunction/core';\nimport { MJGlobal } from '@memberjunction/global';\nimport { IArtifactViewerComponent } from '../interfaces/artifact-viewer-plugin.interface';\nimport { BaseArtifactViewerPluginComponent, NavigationRequest } from './base-artifact-viewer.component';\n\n/**\n * Artifact type plugin viewer that loads the appropriate plugin based on the artifact's DriverClass.\n * Uses MJGlobal.Instance.ClassFactory.CreateInstance() to dynamically load viewer plugins.\n */\n@Component({\n standalone: false,\n selector: 'mj-artifact-type-plugin-viewer',\n template: `\n <div class=\"artifact-type-plugin-viewer\">\n @if (isLoading) {\n <div class=\"loading-state\">\n <i class=\"fas fa-spinner fa-spin\"></i>\n <span>Loading artifact viewer...</span>\n </div>\n }\n @if (error) {\n <div class=\"error-state\">\n <i class=\"fas fa-exclamation-triangle\"></i>\n @if (errorTitle) {\n <div class=\"error-title\">{{ errorTitle }}</div>\n }\n <div class=\"error-details\">{{ error }}</div>\n @if (errorDetails) {\n <div class=\"error-tech-details\">{{ errorDetails }}</div>\n }\n </div>\n }\n <ng-container #viewerContainer></ng-container>\n </div>\n `,\n styles: [`\n .artifact-type-plugin-viewer {\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n }\n\n .artifact-type-plugin-viewer ::ng-deep > * {\n flex: 1;\n min-height: 0;\n }\n\n .loading-state,\n .error-state {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 40px;\n gap: 16px;\n color: #6c757d;\n width: 100%;\n height: 100%;\n min-height: 200px;\n }\n\n .loading-state i {\n font-size: 32px;\n }\n\n .error-state {\n color: #dc3545;\n text-align: center;\n max-width: 600px;\n }\n\n .error-state i {\n font-size: 32px;\n }\n\n .error-state .error-title {\n font-weight: 600;\n font-size: 16px;\n margin-bottom: 8px;\n }\n\n .error-state .error-details {\n font-size: 14px;\n line-height: 1.5;\n color: #6c757d;\n }\n\n .error-state .error-tech-details {\n margin-top: 12px;\n padding: 12px;\n background: #f8f9fa;\n border-radius: 4px;\n font-family: monospace;\n font-size: 12px;\n color: #495057;\n word-break: break-word;\n }\n `]\n})\nexport class ArtifactTypePluginViewerComponent extends BaseAngularComponent implements OnInit, OnChanges {\n @Input() artifactVersion!: MJArtifactVersionEntity;\n @Input() artifactTypeName!: string;\n @Input() contentType?: string;\n @Input() height?: string;\n @Input() readonly: boolean = true;\n @Input() cssClass?: string;\n\n @Output() openEntityRecord = new EventEmitter<{entityName: string; compositeKey: CompositeKey}>();\n @Output() navigationRequest = new EventEmitter<NavigationRequest>();\n @Output() pluginLoaded = new EventEmitter<void>();\n @Output() tabsChanged = new EventEmitter<void>();\n /**\n * Bubbled up from the component-artifact-viewer's form-aware branch when\n * the user clicks \"Apply to my form\". Carries the spec + entity so the\n * consumer (chat message card, conversation host) can invoke the\n * Create-or-Modify Interactive Form action behind a confirmation dialog.\n */\n @Output() applyFormRequested = new EventEmitter<{ spec: unknown; entityName: string }>();\n\n @ViewChild('viewerContainer', { read: ViewContainerRef, static: true })\n viewerContainer!: ViewContainerRef;\n\n public isLoading = true;\n public error: string | null = null;\n public errorDetails: string | null = null;\n public errorTitle: string | null = null;\n\n private componentRef: ComponentRef<any> | null = null;\n\n /**\n * Get the loaded plugin instance (if available)\n */\n public get pluginInstance(): BaseArtifactViewerPluginComponent | null {\n return this.componentRef?.instance as BaseArtifactViewerPluginComponent || null;\n }\n\n /**\n * Whether the loaded plugin supports user feedback.\n * Pass-through to the plugin instance for use by the parent panel wrapper.\n */\n public get SupportsFeedback(): boolean {\n return this.pluginInstance?.SupportsFeedback ?? false;\n }\n\n /**\n * Ask the loaded plugin to show its feedback UX.\n * Pass-through to the plugin instance, called from the parent panel header.\n */\n public AskUserForFeedback(): void {\n this.pluginInstance?.AskUserForFeedback();\n }\n\n async ngOnInit(): Promise<void> {\n await this.loadViewer();\n }\n\n async ngOnChanges(changes: SimpleChanges): Promise<void> {\n if ((changes['artifactVersion'] || changes['artifactTypeName']) &&\n !changes['artifactVersion']?.firstChange) {\n await this.loadViewer();\n }\n }\n\n ngOnDestroy(): void {\n this.destroyCurrentViewer();\n }\n\n /**\n * Load the appropriate viewer plugin for the artifact\n */\n private async loadViewer(): Promise<void> {\n try {\n this.isLoading = true;\n this.error = null;\n this.errorTitle = null;\n this.errorDetails = null;\n\n if (!this.artifactVersion) {\n this.setError(\n 'Missing Artifact Data',\n 'Unable to display this artifact because the version information is missing.',\n 'artifactVersion is null or undefined'\n );\n this.isLoading = false;\n return;\n }\n\n if (!this.artifactTypeName) {\n this.setError(\n 'Missing Artifact Type',\n 'Unable to display this artifact because the type information is missing.',\n 'artifactTypeName is empty'\n );\n this.isLoading = false;\n return;\n }\n\n // Get the artifact type entity to find the DriverClass\n const artifactType = await this.getArtifactType();\n if (!artifactType) {\n this.setError(\n 'Unknown Artifact Type',\n `The artifact type \"${this.artifactTypeName}\" is not recognized. This might be a custom type that hasn't been properly configured.`,\n `Artifact type \"${this.artifactTypeName}\" not found in metadata`\n );\n this.isLoading = false;\n return;\n }\n\n // Resolve DriverClass by traversing parent hierarchy if needed\n const driverClass = await this.resolveDriverClass(artifactType);\n if (!driverClass) {\n this.setError(\n 'No Viewer Available',\n `This artifact type (${this.artifactTypeName}) doesn't have a viewer component configured. The artifact content may need to be viewed in the JSON tab.`,\n `No DriverClass in hierarchy and content is not valid JSON`\n );\n this.isLoading = false;\n return;\n }\n\n // Get the component type using MJGlobal ClassFactory\n // CreateInstance returns the registered component class for the given DriverClass key\n const tempInstance = await MJGlobal.Instance.ClassFactory.CreateInstanceAsync<BaseArtifactViewerPluginComponent>(\n BaseArtifactViewerPluginComponent,\n driverClass\n );\n\n if (!tempInstance) {\n this.setError(\n 'Viewer Component Not Found',\n `The viewer component \"${driverClass}\" is not registered in the application. This usually means the required package or module hasn't been loaded.`,\n `Component \"${driverClass}\" not found in ClassFactory registry. Ensure it's registered with @RegisterClass(BaseArtifactViewerPluginComponent, '${driverClass}').`\n );\n this.isLoading = false;\n return;\n }\n\n // Get the component type from the instance\n const componentType = tempInstance.constructor as Type<BaseArtifactViewerPluginComponent>;\n\n // Destroy previous viewer if exists\n this.destroyCurrentViewer();\n\n // Create and configure the viewer component\n this.componentRef = this.viewerContainer.createComponent(componentType);\n\n // Set inputs using setInput() which properly triggers ngOnChanges\n // This is critical for plugins like ComponentArtifactViewerComponent that\n // need to process the artifactVersion in ngOnChanges before pluginLoaded fires\n this.componentRef.setInput('artifactVersion', this.artifactVersion);\n if (this.height !== undefined) {\n this.componentRef.setInput('height', this.height);\n }\n if (this.readonly !== undefined) {\n this.componentRef.setInput('readonly', this.readonly);\n }\n if (this.cssClass !== undefined) {\n this.componentRef.setInput('cssClass', this.cssClass);\n }\n if (this.contentType !== undefined) {\n this.componentRef.setInput('contentType', this.contentType);\n }\n\n // Subscribe to openEntityRecord event if the plugin emits it\n const componentInstance = this.componentRef.instance;\n if (componentInstance.openEntityRecord) {\n componentInstance.openEntityRecord.subscribe((event: {entityName: string; compositeKey: CompositeKey}) => {\n this.openEntityRecord.emit(event);\n });\n }\n\n // Subscribe to navigationRequest event if the plugin emits it\n if (componentInstance.navigationRequest) {\n componentInstance.navigationRequest.subscribe((event: NavigationRequest) => {\n this.navigationRequest.emit(event);\n });\n }\n\n // Subscribe to tabsChanged event if the plugin emits it (e.g., after async spec loading)\n if (componentInstance.tabsChanged) {\n componentInstance.tabsChanged.subscribe(() => {\n this.tabsChanged.emit();\n });\n }\n\n // Subscribe to the form-aware \"Apply to my form\" event when the\n // underlying plugin is a component-artifact-viewer rendering a\n // form-role spec. Other plugin types don't have this output.\n if (componentInstance.applyFormRequested) {\n componentInstance.applyFormRequested.subscribe(\n (event: { spec: unknown; entityName: string }) => {\n this.applyFormRequested.emit(event);\n }\n );\n }\n\n // Trigger change detection\n this.componentRef.changeDetectorRef.detectChanges();\n\n this.isLoading = false;\n\n // Notify parent that plugin has loaded (for tab selection timing)\n this.pluginLoaded.emit();\n } catch (err) {\n console.error('Error loading artifact viewer:', err);\n LogError(err);\n const errorMessage = err instanceof Error ? err.message : String(err);\n const errorStack = err instanceof Error && err.stack ? err.stack : undefined;\n this.setError(\n 'Failed to Load Viewer',\n 'An unexpected error occurred while loading the artifact viewer. Please try refreshing the page or contact support if the problem persists.',\n errorStack || errorMessage\n );\n this.isLoading = false;\n }\n }\n\n /**\n * Set a structured error message with title, user-friendly description, and technical details\n */\n private setError(title: string, userMessage: string, technicalDetails: string): void {\n this.errorTitle = title;\n this.error = userMessage;\n this.errorDetails = technicalDetails;\n }\n\n /**\n * Get the artifact type entity for the current artifact using the cached ArtifactMetadataEngine\n */\n private async getArtifactType(): Promise<MJArtifactTypeEntity | null> {\n try {\n // Use the cached metadata engine instead of querying the database\n const artifactType = ArtifactMetadataEngine.Instance.FindArtifactType(this.artifactTypeName);\n return artifactType || null;\n } catch (err) {\n console.error('Error loading artifact type:', err);\n return null;\n }\n }\n\n /**\n * Resolves the DriverClass for an artifact type by traversing up the parent hierarchy.\n * Falls back to JSON viewer if content is valid JSON and no DriverClass is found.\n *\n * @param artifactType The artifact type to resolve the DriverClass for\n * @returns The DriverClass string, or null if none found and no JSON fallback available\n */\n private async resolveDriverClass(artifactType: MJArtifactTypeEntity): Promise<string | null> {\n // Check if current artifact type has a DriverClass\n if (artifactType.DriverClass) {\n console.log(`✅ Found DriverClass '${artifactType.DriverClass}' on artifact type '${artifactType.Name}'`);\n return artifactType.DriverClass;\n }\n\n // No DriverClass on current type - check if it has a parent\n if (artifactType.ParentID) {\n console.log(`🔍 No DriverClass on '${artifactType.Name}', checking parent...`);\n const parentType = await this.getArtifactTypeById(artifactType.ParentID);\n\n if (parentType) {\n // Recursively check parent\n return await this.resolveDriverClass(parentType);\n } else {\n console.warn(`⚠️ Parent artifact type '${artifactType.ParentID}' not found`);\n }\n }\n\n // Reached root with no DriverClass - check for JSON fallback\n console.log(`📄 No DriverClass found in hierarchy for '${artifactType.Name}', checking JSON fallback...`);\n return this.checkJsonFallback();\n }\n\n /**\n * Loads an artifact type by ID\n */\n private async getArtifactTypeById(id: string): Promise<MJArtifactTypeEntity | null> {\n try {\n const md = this.ProviderToUse;\n const artifactType = await md.GetEntityObject<MJArtifactTypeEntity>('MJ: Artifact Types');\n const loaded = await artifactType.Load(id);\n\n if (loaded) {\n return artifactType;\n }\n\n return null;\n } catch (err) {\n console.error('Error loading artifact type by ID:', err);\n return null;\n }\n }\n\n /**\n * Checks if the artifact content is valid JSON and returns the JSON viewer plugin if so\n */\n private checkJsonFallback(): string | null {\n if (!this.artifactVersion || !this.artifactVersion.Content) {\n console.log('❌ No content available for JSON fallback');\n return null;\n }\n\n try {\n // Try to parse the content as JSON\n JSON.parse(this.artifactVersion.Content);\n console.log('✅ Content is valid JSON, using JsonArtifactViewerPlugin as fallback');\n return 'JsonArtifactViewerPlugin';\n } catch {\n console.log('❌ Content is not valid JSON, no fallback available');\n return null;\n }\n }\n\n /**\n * Destroy the current viewer component\n */\n private destroyCurrentViewer(): void {\n if (this.componentRef) {\n this.componentRef.destroy();\n this.componentRef = null;\n }\n this.viewerContainer.clear();\n }\n}\n"]}
1
+ {"version":3,"file":"artifact-type-plugin-viewer.component.js","sourceRoot":"","sources":["../../../src/lib/components/artifact-type-plugin-viewer.component.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,EACL,MAAM,EACN,YAAY,EAIZ,SAAS,EACT,gBAAgB,EAGjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAiD,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AACtH,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAY,QAAQ,EAAyB,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,OAAO,EAAE,iCAAiC,EAAqB,MAAM,kCAAkC,CAAC;;;;IAYhG,8BAA2B;IACzB,uBAAsC;IACtC,4BAAM;IAAA,0CAA0B;IAClC,AADkC,iBAAO,EACnC;;;IAMF,8BAAyB;IAAA,YAAgB;IAAA,iBAAM;;;IAAtB,cAAgB;IAAhB,uCAAgB;;;IAIzC,8BAAgC;IAAA,YAAkB;IAAA,iBAAM;;;IAAxB,cAAkB;IAAlB,yCAAkB;;;IAPtD,8BAAyB;IACvB,uBAA2C;IAC3C,iHAAkB;IAGlB,8BAA2B;IAAA,YAAW;IAAA,iBAAM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qEM,iCAAiC;cA3F7C,SAAS;6BACI,KAAK,YACP,gCAAgC,YAChC;;;;;;;;;;;;;;;;;;;;;;GAsBT;;kBAmEA,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBACL,KAAK;;kBAEL,MAAM;;kBACN,MAAM;;kBACN,MAAM;;kBACN,MAAM;;kBAON,MAAM;;kBAEN,SAAS;mBAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,IAAI,EAAE;;kFApB3D,iCAAiC","sourcesContent":["import {\n Component,\n Input,\n Output,\n EventEmitter,\n OnInit,\n OnChanges,\n SimpleChanges,\n ViewChild,\n ViewContainerRef,\n ComponentRef,\n Type\n} from '@angular/core';\nimport { MJArtifactVersionEntity, MJArtifactTypeEntity, ArtifactMetadataEngine } from '@memberjunction/core-entities';\nimport { BaseAngularComponent } from '@memberjunction/ng-base-types';\nimport { Metadata, LogError, RunView, CompositeKey } from '@memberjunction/core';\nimport { MJGlobal } from '@memberjunction/global';\nimport { IArtifactViewerComponent } from '../interfaces/artifact-viewer-plugin.interface';\nimport { BaseArtifactViewerPluginComponent, NavigationRequest } from './base-artifact-viewer.component';\n\n/**\n * Artifact type plugin viewer that loads the appropriate plugin based on the artifact's DriverClass.\n * Uses MJGlobal.Instance.ClassFactory.CreateInstance() to dynamically load viewer plugins.\n */\n@Component({\n standalone: false,\n selector: 'mj-artifact-type-plugin-viewer',\n template: `\n <div class=\"artifact-type-plugin-viewer\">\n @if (isLoading) {\n <div class=\"loading-state\">\n <i class=\"fas fa-spinner fa-spin\"></i>\n <span>Loading artifact viewer...</span>\n </div>\n }\n @if (error) {\n <div class=\"error-state\">\n <i class=\"fas fa-exclamation-triangle\"></i>\n @if (errorTitle) {\n <div class=\"error-title\">{{ errorTitle }}</div>\n }\n <div class=\"error-details\">{{ error }}</div>\n @if (errorDetails) {\n <div class=\"error-tech-details\">{{ errorDetails }}</div>\n }\n </div>\n }\n <ng-container #viewerContainer></ng-container>\n </div>\n `,\n styles: [`\n .artifact-type-plugin-viewer {\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n }\n\n .artifact-type-plugin-viewer ::ng-deep > * {\n flex: 1;\n min-height: 0;\n }\n\n .loading-state,\n .error-state {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 40px;\n gap: 16px;\n color: #6c757d;\n width: 100%;\n height: 100%;\n min-height: 200px;\n }\n\n .loading-state i {\n font-size: 32px;\n }\n\n .error-state {\n color: #dc3545;\n text-align: center;\n max-width: 600px;\n }\n\n .error-state i {\n font-size: 32px;\n }\n\n .error-state .error-title {\n font-weight: 600;\n font-size: 16px;\n margin-bottom: 8px;\n }\n\n .error-state .error-details {\n font-size: 14px;\n line-height: 1.5;\n color: #6c757d;\n }\n\n .error-state .error-tech-details {\n margin-top: 12px;\n padding: 12px;\n background: #f8f9fa;\n border-radius: 4px;\n font-family: monospace;\n font-size: 12px;\n color: #495057;\n word-break: break-word;\n }\n `]\n})\nexport class ArtifactTypePluginViewerComponent extends BaseAngularComponent implements OnInit, OnChanges {\n @Input() artifactVersion!: MJArtifactVersionEntity;\n @Input() artifactTypeName!: string;\n @Input() contentType?: string;\n @Input() height?: string;\n @Input() readonly: boolean = true;\n @Input() cssClass?: string;\n\n @Output() openEntityRecord = new EventEmitter<{entityName: string; compositeKey: CompositeKey}>();\n @Output() navigationRequest = new EventEmitter<NavigationRequest>();\n @Output() pluginLoaded = new EventEmitter<void>();\n @Output() tabsChanged = new EventEmitter<void>();\n /**\n * Bubbled up from the component-artifact-viewer's form-aware branch when\n * the user clicks \"Apply to my form\". Carries the spec + entity so the\n * consumer (chat message card, conversation host) can invoke the\n * Create-or-Modify Interactive Form action behind a confirmation dialog.\n */\n @Output() applyFormRequested = new EventEmitter<{ spec: unknown; entityName: string }>();\n\n @ViewChild('viewerContainer', { read: ViewContainerRef, static: true })\n viewerContainer!: ViewContainerRef;\n\n public isLoading = true;\n public error: string | null = null;\n public errorDetails: string | null = null;\n public errorTitle: string | null = null;\n\n private componentRef: ComponentRef<any> | null = null;\n\n /**\n * Get the loaded plugin instance (if available)\n */\n public get pluginInstance(): BaseArtifactViewerPluginComponent | null {\n return this.componentRef?.instance as BaseArtifactViewerPluginComponent || null;\n }\n\n /**\n * Whether the loaded plugin supports user feedback.\n * Pass-through to the plugin instance for use by the parent panel wrapper.\n */\n public get SupportsFeedback(): boolean {\n return this.pluginInstance?.SupportsFeedback ?? false;\n }\n\n /**\n * Ask the loaded plugin to show its feedback UX.\n * Pass-through to the plugin instance, called from the parent panel header.\n */\n public AskUserForFeedback(): void {\n this.pluginInstance?.AskUserForFeedback();\n }\n\n async ngOnInit(): Promise<void> {\n await this.loadViewer();\n }\n\n async ngOnChanges(changes: SimpleChanges): Promise<void> {\n if ((changes['artifactVersion'] || changes['artifactTypeName']) &&\n !changes['artifactVersion']?.firstChange) {\n await this.loadViewer();\n }\n }\n\n ngOnDestroy(): void {\n this.destroyCurrentViewer();\n }\n\n /**\n * Load the appropriate viewer plugin for the artifact\n */\n private async loadViewer(): Promise<void> {\n try {\n this.isLoading = true;\n this.error = null;\n this.errorTitle = null;\n this.errorDetails = null;\n\n if (!this.artifactVersion) {\n this.setError(\n 'Missing Artifact Data',\n 'Unable to display this artifact because the version information is missing.',\n 'artifactVersion is null or undefined'\n );\n this.isLoading = false;\n return;\n }\n\n if (!this.artifactTypeName) {\n this.setError(\n 'Missing Artifact Type',\n 'Unable to display this artifact because the type information is missing.',\n 'artifactTypeName is empty'\n );\n this.isLoading = false;\n return;\n }\n\n // Get the artifact type entity to find the DriverClass\n const artifactType = await this.getArtifactType();\n if (!artifactType) {\n this.setError(\n 'Unknown Artifact Type',\n `The artifact type \"${this.artifactTypeName}\" is not recognized. This might be a custom type that hasn't been properly configured.`,\n `Artifact type \"${this.artifactTypeName}\" not found in metadata`\n );\n this.isLoading = false;\n return;\n }\n\n // Resolve DriverClass by traversing parent hierarchy if needed\n const driverClass = await this.resolveDriverClass(artifactType);\n if (!driverClass) {\n this.setError(\n 'No Viewer Available',\n `This artifact type (${this.artifactTypeName}) doesn't have a viewer component configured. The artifact content may need to be viewed in the JSON tab.`,\n `No DriverClass in hierarchy and content is not valid JSON`\n );\n this.isLoading = false;\n return;\n }\n\n // Look up the registered component class from ClassFactory WITHOUT instantiating it,\n // so Angular's createComponent can properly instantiate it within the Angular injection context.\n const registration = await MJGlobal.Instance.ClassFactory.GetRegistrationAsync(\n BaseArtifactViewerPluginComponent,\n driverClass\n );\n\n if (!registration?.SubClass) {\n this.setError(\n 'Viewer Component Not Found',\n `The viewer component \"${driverClass}\" is not registered in the application. This usually means the required package or module hasn't been loaded.`,\n `Component \"${driverClass}\" not found in ClassFactory registry. Ensure it's registered with @RegisterClass(BaseArtifactViewerPluginComponent, '${driverClass}').`\n );\n this.isLoading = false;\n return;\n }\n\n // Get the component type from the registration\n const componentType = registration.SubClass as Type<BaseArtifactViewerPluginComponent>;\n\n // Destroy previous viewer if exists\n this.destroyCurrentViewer();\n\n // Create and configure the viewer component\n this.componentRef = this.viewerContainer.createComponent(componentType);\n\n // Set inputs using setInput() which properly triggers ngOnChanges\n // This is critical for plugins like ComponentArtifactViewerComponent that\n // need to process the artifactVersion in ngOnChanges before pluginLoaded fires\n this.componentRef.setInput('artifactVersion', this.artifactVersion);\n if (this.height !== undefined) {\n this.componentRef.setInput('height', this.height);\n }\n if (this.readonly !== undefined) {\n this.componentRef.setInput('readonly', this.readonly);\n }\n if (this.cssClass !== undefined) {\n this.componentRef.setInput('cssClass', this.cssClass);\n }\n if (this.contentType !== undefined) {\n this.componentRef.setInput('contentType', this.contentType);\n }\n\n // Subscribe to openEntityRecord event if the plugin emits it\n const componentInstance = this.componentRef.instance;\n if (componentInstance.openEntityRecord) {\n componentInstance.openEntityRecord.subscribe((event: {entityName: string; compositeKey: CompositeKey}) => {\n this.openEntityRecord.emit(event);\n });\n }\n\n // Subscribe to navigationRequest event if the plugin emits it\n if (componentInstance.navigationRequest) {\n componentInstance.navigationRequest.subscribe((event: NavigationRequest) => {\n this.navigationRequest.emit(event);\n });\n }\n\n // Subscribe to tabsChanged event if the plugin emits it (e.g., after async spec loading)\n if (componentInstance.tabsChanged) {\n componentInstance.tabsChanged.subscribe(() => {\n this.tabsChanged.emit();\n });\n }\n\n // Subscribe to the form-aware \"Apply to my form\" event when the\n // underlying plugin is a component-artifact-viewer rendering a\n // form-role spec. Other plugin types don't have this output.\n if (componentInstance.applyFormRequested) {\n componentInstance.applyFormRequested.subscribe(\n (event: { spec: unknown; entityName: string }) => {\n this.applyFormRequested.emit(event);\n }\n );\n }\n\n // Trigger change detection\n this.componentRef.changeDetectorRef.detectChanges();\n\n this.isLoading = false;\n\n // Notify parent that plugin has loaded (for tab selection timing)\n this.pluginLoaded.emit();\n } catch (err) {\n console.error('Error loading artifact viewer:', err);\n LogError(err);\n const errorMessage = err instanceof Error ? err.message : String(err);\n const errorStack = err instanceof Error && err.stack ? err.stack : undefined;\n this.setError(\n 'Failed to Load Viewer',\n 'An unexpected error occurred while loading the artifact viewer. Please try refreshing the page or contact support if the problem persists.',\n errorStack || errorMessage\n );\n this.isLoading = false;\n }\n }\n\n /**\n * Set a structured error message with title, user-friendly description, and technical details\n */\n private setError(title: string, userMessage: string, technicalDetails: string): void {\n this.errorTitle = title;\n this.error = userMessage;\n this.errorDetails = technicalDetails;\n }\n\n /**\n * Get the artifact type entity for the current artifact using the cached ArtifactMetadataEngine\n */\n private async getArtifactType(): Promise<MJArtifactTypeEntity | null> {\n try {\n // Use the cached metadata engine instead of querying the database\n const artifactType = ArtifactMetadataEngine.Instance.FindArtifactType(this.artifactTypeName);\n return artifactType || null;\n } catch (err) {\n console.error('Error loading artifact type:', err);\n return null;\n }\n }\n\n /**\n * Resolves the DriverClass for an artifact type by traversing up the parent hierarchy.\n * Falls back to JSON viewer if content is valid JSON and no DriverClass is found.\n *\n * @param artifactType The artifact type to resolve the DriverClass for\n * @returns The DriverClass string, or null if none found and no JSON fallback available\n */\n private async resolveDriverClass(artifactType: MJArtifactTypeEntity): Promise<string | null> {\n // Check if current artifact type has a DriverClass\n if (artifactType.DriverClass) {\n console.log(`✅ Found DriverClass '${artifactType.DriverClass}' on artifact type '${artifactType.Name}'`);\n return artifactType.DriverClass;\n }\n\n // No DriverClass on current type - check if it has a parent\n if (artifactType.ParentID) {\n console.log(`🔍 No DriverClass on '${artifactType.Name}', checking parent...`);\n const parentType = await this.getArtifactTypeById(artifactType.ParentID);\n\n if (parentType) {\n // Recursively check parent\n return await this.resolveDriverClass(parentType);\n } else {\n console.warn(`⚠️ Parent artifact type '${artifactType.ParentID}' not found`);\n }\n }\n\n // Reached root with no DriverClass - check for JSON fallback\n console.log(`📄 No DriverClass found in hierarchy for '${artifactType.Name}', checking JSON fallback...`);\n return this.checkJsonFallback();\n }\n\n /**\n * Loads an artifact type by ID\n */\n private async getArtifactTypeById(id: string): Promise<MJArtifactTypeEntity | null> {\n try {\n const md = this.ProviderToUse;\n const artifactType = await md.GetEntityObject<MJArtifactTypeEntity>('MJ: Artifact Types');\n const loaded = await artifactType.Load(id);\n\n if (loaded) {\n return artifactType;\n }\n\n return null;\n } catch (err) {\n console.error('Error loading artifact type by ID:', err);\n return null;\n }\n }\n\n /**\n * Checks if the artifact content is valid JSON and returns the JSON viewer plugin if so\n */\n private checkJsonFallback(): string | null {\n if (!this.artifactVersion || !this.artifactVersion.Content) {\n console.log('❌ No content available for JSON fallback');\n return null;\n }\n\n try {\n // Try to parse the content as JSON\n JSON.parse(this.artifactVersion.Content);\n console.log('✅ Content is valid JSON, using JsonArtifactViewerPlugin as fallback');\n return 'JsonArtifactViewerPlugin';\n } catch {\n console.log('❌ Content is not valid JSON, no fallback available');\n return null;\n }\n }\n\n /**\n * Destroy the current viewer component\n */\n private destroyCurrentViewer(): void {\n if (this.componentRef) {\n this.componentRef.destroy();\n this.componentRef = null;\n }\n this.viewerContainer.clear();\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/ng-artifacts",
3
- "version": "6.1.2",
3
+ "version": "6.2.0-edge.0",
4
4
  "description": "MemberJunction: Artifact viewer plugin system for rendering different artifact types (JSON, Code, Markdown, HTML, SVG, Components)",
5
5
  "main": "./dist/public-api.js",
6
6
  "typings": "./dist/public-api.d.ts",
@@ -13,8 +13,8 @@
13
13
  "devDependencies": {
14
14
  "@angular/compiler": "21.2.22",
15
15
  "@angular/compiler-cli": "21.2.22",
16
- "@memberjunction/core": "6.1.2",
17
- "@memberjunction/ng-test-utils": "6.1.2",
16
+ "@memberjunction/core": "6.2.0-edge.0",
17
+ "@memberjunction/ng-test-utils": "6.2.0-edge.0",
18
18
  "sass": "^1.97.3",
19
19
  "vitest": "^4.0.18"
20
20
  },
@@ -29,24 +29,24 @@
29
29
  "ag-grid-community": "^35.0.1"
30
30
  },
31
31
  "dependencies": {
32
- "@memberjunction/core": "6.1.2",
33
- "@memberjunction/core-entities": "6.1.2",
34
- "@memberjunction/global": "6.1.2",
35
- "@memberjunction/graphql-dataprovider": "6.1.2",
36
- "@memberjunction/interactive-component-types": "6.1.2",
37
- "@memberjunction/ng-base-forms": "6.1.2",
38
- "@memberjunction/ng-base-types": "6.1.2",
39
- "@memberjunction/ng-code-editor": "6.1.2",
40
- "@memberjunction/ng-export-service": "6.1.2",
41
- "@memberjunction/ng-markdown": "6.1.2",
42
- "@memberjunction/ng-media-player": "6.1.2",
43
- "@memberjunction/ng-notifications": "6.1.2",
44
- "@memberjunction/ng-pagination": "6.1.2",
45
- "@memberjunction/ng-query-viewer": "6.1.2",
46
- "@memberjunction/ng-react": "6.1.2",
47
- "@memberjunction/ng-shared-generic": "6.1.2",
48
- "@memberjunction/ng-trees": "6.1.2",
49
- "@memberjunction/ng-ui-components": "6.1.2",
32
+ "@memberjunction/core": "6.2.0-edge.0",
33
+ "@memberjunction/core-entities": "6.2.0-edge.0",
34
+ "@memberjunction/global": "6.2.0-edge.0",
35
+ "@memberjunction/graphql-dataprovider": "6.2.0-edge.0",
36
+ "@memberjunction/interactive-component-types": "6.2.0-edge.0",
37
+ "@memberjunction/ng-base-forms": "6.2.0-edge.0",
38
+ "@memberjunction/ng-base-types": "6.2.0-edge.0",
39
+ "@memberjunction/ng-code-editor": "6.2.0-edge.0",
40
+ "@memberjunction/ng-export-service": "6.2.0-edge.0",
41
+ "@memberjunction/ng-markdown": "6.2.0-edge.0",
42
+ "@memberjunction/ng-media-player": "6.2.0-edge.0",
43
+ "@memberjunction/ng-notifications": "6.2.0-edge.0",
44
+ "@memberjunction/ng-pagination": "6.2.0-edge.0",
45
+ "@memberjunction/ng-query-viewer": "6.2.0-edge.0",
46
+ "@memberjunction/ng-react": "6.2.0-edge.0",
47
+ "@memberjunction/ng-shared-generic": "6.2.0-edge.0",
48
+ "@memberjunction/ng-trees": "6.2.0-edge.0",
49
+ "@memberjunction/ng-ui-components": "6.2.0-edge.0",
50
50
  "mammoth": "^1.8.0",
51
51
  "pdfjs-dist": "^4.10.38",
52
52
  "rxjs": "^7.8.2",