@memberjunction/ng-artifacts 5.40.1 → 5.41.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.
@@ -1 +1 @@
1
- {"version":3,"file":"component-artifact-viewer.component.js","sourceRoot":"","sources":["../../../../src/lib/components/plugins/component-artifact-viewer.component.ts","../../../../src/lib/components/plugins/component-artifact-viewer.component.html"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAmD,MAAM,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC5H,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,iCAAiC,EAAqB,MAAM,mCAAmC,CAAC;AAEzG,OAAO,EAAE,0BAA0B,EAAiB,MAAM,6CAA6C,CAAC;AACxG,OAAO,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,mDAAmD,CAAC;AAC1G,OAAO,EAAc,YAAY,EAAE,YAAY,EAAc,QAAQ,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC7G,OAAO,EAAE,+BAA+B,EAAE,MAAM,+DAA+D,CAAC;;;;;;;;;ICQpG,AADF,kCAAmC,cACxB;IAAA,iCAAiB;IAAA,iBAAU;IACpC,2BAAK;IAAA,YAAkB;IACzB,AADyB,iBAAM,EACrB;;;IADH,eAAkB;IAAlB,yCAAkB;;;IAZ7B,8BAAyB;IACvB,uBAAgD;IAChD,0BAAI;IAAA,YAAkB;IAAA,iBAAK;IAC3B,yBAAG;IAAA,8EAA8D;IAAA,iBAAI;IAEnE,AADF,6BAA+F,SACzF;IAAA,oEAAoD;IAAA,iBAAK;IAC7D,0BAAI;IAAA,qEAAoD;IAAA,iBAAK;IAC7D,2BAAI;IAAA,qEAAoD;IAC1D,AAD0D,iBAAK,EAC1D;IACL,sHAAoB;IAMtB,iBAAM;;;IAbA,eAAkB;IAAlB,yCAAkB;IAOtB,gBAKC;IALD,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import { Component, ViewChild, AfterViewInit, OnInit, OnChanges, SimpleChanges, Output, EventEmitter } from '@angular/core';\nimport { RegisterClass, SafeJSONParse } from '@memberjunction/global';\nimport { BaseArtifactViewerPluginComponent, ArtifactViewerTab } from '../base-artifact-viewer.component';\nimport { MJReactComponent, AngularAdapterService } from '@memberjunction/ng-react';\nimport { BuildComponentCompleteCode, ComponentSpec } from '@memberjunction/interactive-component-types';\nimport { isFormRole, getDeclaredFormEntityName } from '@memberjunction/interactive-component-types/forms';\nimport { BaseEntity, CompositeKey, DataSnapshot, EntityInfo, LogError, RunView } from '@memberjunction/core';\nimport { DataRequirementsViewerComponent } from './data-requirements-viewer/data-requirements-viewer.component';\n\n/**\n * Viewer component for interactive Component artifacts (React-based UI components)\n *\n * Features:\n * - Live component preview with React rendering\n * - Dynamic tabs for component metadata (via GetAdditionalTabs)\n * - Provides tabs for: Code, Functional Requirements, Technical Design, Data Requirements\n */\n@Component({\n standalone: false,\n selector: 'mj-component-artifact-viewer',\n templateUrl: './component-artifact-viewer.component.html',\n styleUrls: ['./component-artifact-viewer.component.css']\n})\n@RegisterClass(BaseArtifactViewerPluginComponent, 'ComponentArtifactViewerPlugin')\nexport class ComponentArtifactViewerComponent extends BaseArtifactViewerPluginComponent implements OnInit, AfterViewInit, OnChanges {\n @ViewChild('reactComponent') reactComponent?: MJReactComponent;\n @Output() tabsChanged = new EventEmitter<void>();\n @Output() openEntityRecord = new EventEmitter<{entityName: string; compositeKey: CompositeKey}>();\n\n /**\n * Emitted when the user clicks \"Apply to my form\" on a form-role artifact.\n * Carries the spec (ready to hand to the agent's Create/Modify action) and\n * the entity name. The host is responsible for confirming + invoking the\n * actual server action.\n */\n @Output() applyFormRequested = new EventEmitter<{ spec: ComponentSpec; entityName: string }>();\n\n // ── Form-aware state (only populated when componentRole === 'form') ──\n\n /** True when this artifact's spec declares `componentRole: 'form'`. */\n public isFormArtifact = false;\n\n /** Entity the form targets — resolved from spec.entityName / dataRequirements. */\n public formEntityInfo: EntityInfo | null = null;\n\n /** The real or fixture record currently bound to the form preview. */\n public formRecord: BaseEntity | null = null;\n\n /** True iff `formRecord` is a real DB row (vs a fixture NewRecord()). */\n public formRecordIsReal = false;\n\n /** Label for the chip (e.g. the record's Name field). */\n public formRecordLabel = '';\n\n /** Picker UI state. */\n public showRecordPicker = false;\n public recordSearchTerm = '';\n public recordSearchResults: Array<{ ID: string; Label: string }> = [];\n public formInitError: string | null = null;\n\n // Component data\n public component: ComponentSpec | null = null;\n public componentCode: string = \"\";\n public componentName: string = '';\n\n /**\n * Cached resolved spec from the registry, preserved even after the React component\n * is destroyed (e.g., when a render error removes <mj-react-component> from the DOM).\n */\n private _cachedResolvedSpec: ComponentSpec | null = null;\n\n public get resolvedComponentSpec(): ComponentSpec | null {\n // Prefer the live React component's resolved spec (most up-to-date),\n // then fall back to our cached copy (survives DOM destruction),\n // then fall back to the stripped local spec as last resort.\n return this.reactComponent?.resolvedComponentSpec || this._cachedResolvedSpec || this.component;\n }\n\n // Feedback panel\n public ShowFeedbackPanel = false;\n\n // Error state\n public hasError = false;\n public errorMessage = '';\n public errorDetails = '';\n\n /**\n * Whether this plugin has content to display in the Display tab.\n * Returns true only if the component has code that can be rendered.\n *\n * IMPORTANT: Uses this.component (synchronously loaded from artifact JSON)\n * instead of resolvedComponentSpec (which depends on async React loading).\n * This ensures hasDisplayContent returns correct value immediately when\n * pluginLoaded fires, before React component finishes loading.\n */\n public override get hasDisplayContent(): boolean {\n // Use this.component directly - it's available synchronously after loadComponentSpec()\n return !!this.component?.namespace || !!this.component?.code\n }\n\n constructor(private adapter: AngularAdapterService) {\n super();\n }\n\n async ngOnChanges(changes: SimpleChanges): Promise<void> {\n // When artifactVersion input changes, reload the component spec\n if (changes['artifactVersion']) {\n this.loadComponentSpec();\n // Notify parent that tabs may have changed (on subsequent changes)\n if (!changes['artifactVersion'].firstChange) {\n this.tabsChanged.emit();\n }\n }\n }\n\n /**\n * Synchronously load the component spec from artifact content.\n * This is intentionally synchronous so that tabs are available immediately\n * when the parent queries GetAdditionalTabs() after pluginLoaded fires.\n *\n * The bridge purges the runtime registry + manager fetch cache itself when\n * it (re)initializes for the new spec, so we don't need to clear caches\n * from here — the bridge instance may not even exist yet when ngOnChanges\n * fires for the first time.\n */\n private loadComponentSpec(): void {\n try {\n // Clear cached resolved spec from previous version so stale data doesn't persist\n this._cachedResolvedSpec = null;\n\n if (this.artifactVersion?.Content) {\n this.component = SafeJSONParse(this.artifactVersion.Content) as ComponentSpec;\n this.extractComponentParts();\n // Form-aware detection. Done here (not in ngAfterViewInit) so the\n // template's `@if (isFormArtifact)` branch decides which preview\n // to mount on the very first render — no flash of the non-form\n // path before the form-aware UI takes over.\n this.detectAndInitFormArtifact();\n } else {\n throw new Error('Artifact content is empty');\n }\n } catch (error) {\n console.error('Failed to load component spec:', error);\n this.hasError = true;\n this.errorMessage = 'Failed to load component';\n this.errorDetails = error instanceof Error ? error.message : String(error);\n }\n }\n\n /**\n * Component initialization.\n * Note: loadComponentSpec() is called in ngOnChanges which runs before ngOnInit,\n * ensuring tabs are available when pluginLoaded fires.\n * The async adapter initialization happens here and doesn't block tab availability.\n */\n async ngOnInit(): Promise<void> {\n // Initialize Angular adapter for React components (async operation)\n try {\n await this.adapter.initialize();\n } catch (error) {\n console.error('Failed to initialize Angular adapter:', error);\n this.hasError = true;\n this.errorMessage = 'Failed to initialize component runtime';\n this.errorDetails = error instanceof Error ? error.message : String(error);\n }\n }\n\n async ngAfterViewInit(): Promise<void> {\n // Component initialization happens automatically via mj-react-component\n }\n\n /**\n * Provide additional tabs for viewing component metadata\n */\n public GetAdditionalTabs(): ArtifactViewerTab[] {\n const tabs: ArtifactViewerTab[] = [];\n\n const resolvedComponent = this.resolvedComponentSpec;\n\n if (!resolvedComponent) {\n return tabs;\n }\n\n // Functional Requirements tab\n if (resolvedComponent.functionalRequirements) {\n tabs.push({\n label: 'Functional',\n icon: 'fa-clipboard-list',\n contentType: 'markdown',\n content: resolvedComponent.functionalRequirements\n });\n }\n\n // Technical Design tab\n if (resolvedComponent.technicalDesign) {\n tabs.push({\n label: 'Technical',\n icon: 'fa-wrench',\n contentType: 'markdown',\n content: resolvedComponent.technicalDesign\n });\n }\n\n // Data Requirements tab - uses custom component for rich visualization\n if (resolvedComponent.dataRequirements) {\n tabs.push({\n label: 'Data',\n icon: 'fa-database',\n contentType: 'component',\n component: DataRequirementsViewerComponent,\n componentInputs: { dataRequirements: resolvedComponent.dataRequirements }\n });\n }\n\n // Code tab (lazy-loaded) - only show if there's actual code\n if (resolvedComponent.code && resolvedComponent.code.trim()) {\n tabs.push({\n label: 'Code',\n icon: 'fa-code',\n contentType: 'code',\n language: 'typescript',\n content: () => BuildComponentCompleteCode(resolvedComponent)\n });\n }\n\n // Spec tab - Shows fully resolved component spec in JSON format (rightmost)\n tabs.push({\n label: 'Spec',\n icon: 'fa-file-code',\n contentType: 'json',\n content: () => JSON.stringify(resolvedComponent, null, 2),\n language: 'json'\n });\n\n return tabs;\n }\n\n /**\n * Remove standard JSON tab since we provide \"Resolved JSON\" custom tab\n * The custom tab shows the fully resolved component spec instead of raw artifact JSON\n */\n public GetStandardTabRemovals(): string[] {\n return ['JSON'];\n }\n\n private extractComponentParts(): void {\n if (this.resolvedComponentSpec?.name) {\n this.componentName = this.resolvedComponentSpec.name;\n }\n if (this.resolvedComponentSpec?.code) {\n this.componentCode = BuildComponentCompleteCode(this.resolvedComponentSpec);\n }\n }\n\n /**\n * Called when MJReactComponent finishes loading the full component spec from the registry.\n * The full spec may contain Functional, Technical, and Data tabs not in the stripped spec.\n * Caches the resolved spec so it survives DOM destruction (e.g., if the component fails to\n * render and <mj-react-component> is removed by the @if/else block).\n * Emits tabsChanged so the parent panel re-evaluates allTabs and renders the new tab labels.\n */\n onReactComponentInitialized(): void {\n if (this.reactComponent?.resolvedComponentSpec &&\n this.reactComponent.resolvedComponentSpec !== this.component) {\n // Cache the resolved spec so it's available even after the React component is destroyed\n this._cachedResolvedSpec = this.reactComponent.resolvedComponentSpec;\n this.tabsChanged.emit();\n }\n }\n\n onComponentEvent(event: unknown): void {\n console.log('Component event:', event);\n\n // Handle error events from React component\n if (event && typeof event === 'object' && 'type' in event && event.type === 'error') {\n const errorEvent = event as { type: 'error'; payload: { error: string; source: string } };\n this.hasError = true;\n this.errorMessage = 'Component Failed to Load';\n this.errorDetails = errorEvent.payload.error || 'Unknown error occurred while loading the component';\n }\n }\n\n /**\n * Handle entity record open request from React component\n * Propagates the event up to parent components\n */\n onOpenEntityRecord(event: {entityName: string; key: CompositeKey}): void {\n // Transform to use 'compositeKey' name for consistency with Angular components\n this.openEntityRecord.emit({\n entityName: event.entityName,\n compositeKey: event.key\n });\n }\n\n public override GetCurrentStateSnapshot(): DataSnapshot | null {\n // First try the component's explicit or auto-captured data state.\n // MJReactComponent.getCurrentDataState() already includes the fallback\n // to intercepted RunView/RunQuery results when the React component\n // doesn't register getCurrentDataState() via callbacks.RegisterMethod.\n const dataState = this.reactComponent?.getCurrentDataState?.();\n if (dataState && typeof dataState === 'object') {\n return dataState as DataSnapshot;\n }\n\n // Fallback for components with no captured data — static mockups,\n // pure-display components, or components whose data hooks haven't fired.\n // Rather than short-circuit Analyze with \"No data available\", emit a\n // minimal snapshot so the user can still open an agent conversation about\n // the component. The artifact itself is attached to the conversation as an\n // Input junction, so the agent can reason from the spec + any static data\n // baked into the component code.\n const spec = this.resolvedComponentSpec;\n if (!spec) return null;\n\n const snap = new DataSnapshot();\n snap.title = spec.title || spec.name || this.getDisplayTitle() || undefined;\n snap.interpretation =\n `Interactive component artifact${spec.name ? ` \"${spec.name}\"` : ''}. ` +\n `No live data was captured — the component either has no data-fetching ` +\n `hooks or has not yet run its queries. The component specification is ` +\n `attached to this conversation; the agent should inspect it directly.`;\n return snap;\n }\n\n /**\n * Component artifacts support feedback when a resolved spec is available.\n */\n public override get SupportsFeedback(): boolean {\n return !!this.resolvedComponentSpec;\n }\n\n /**\n * Toggle the feedback panel open. Called from the artifact viewer header button.\n */\n public override AskUserForFeedback(): void {\n this.ShowFeedbackPanel = !this.ShowFeedbackPanel;\n }\n\n // ════════════════════════════════════════════════════════════════════\n // FORM-AWARE BRANCH\n //\n // When the artifact's spec declares `componentRole: 'form'`, the viewer\n // delegates rendering to `<mj-interactive-form>` instead of the raw\n // `<mj-react-component>` path. This gives the React form a proper\n // FormHostProps binding (bound to a real DB record by default) and lets\n // the user swap records via a search picker before applying.\n //\n // Triggered from `loadComponentSpec()` after the spec parses.\n // ════════════════════════════════════════════════════════════════════\n\n /**\n * Detect form-role and kick off entity + record resolution. Failure modes\n * (missing entity, RunView failure, entity has no rows) fall back to a\n * synthetic record from `BaseEntity.NewRecord()` so the form still mounts\n * against type-appropriate empty values.\n */\n private async detectAndInitFormArtifact(): Promise<void> {\n this.isFormArtifact = false;\n this.formEntityInfo = null;\n this.formRecord = null;\n this.formRecordIsReal = false;\n this.formRecordLabel = '';\n this.formInitError = null;\n\n const spec = this.component;\n if (!spec || !isFormRole(spec)) return;\n\n this.isFormArtifact = true;\n\n const entityName = getDeclaredFormEntityName(spec);\n if (!entityName) {\n this.formInitError = 'Form artifact has no declared entity. Showing without record context.';\n return;\n }\n\n const provider = this.ProviderToUse;\n const entity = provider?.EntityByName(entityName);\n if (!entity) {\n this.formInitError = `Entity \"${entityName}\" not registered with the active provider.`;\n return;\n }\n this.formEntityInfo = entity;\n\n // Load Top-1 record by default. If empty / fails, fall back to a fresh\n // synthetic record. Either way the form mounts — failure to find a real\n // record is informational, not fatal.\n const record = await this.loadTopOneRecord(entity);\n if (record) {\n this.formRecord = record;\n this.formRecordIsReal = true;\n this.formRecordLabel = this.computeRecordLabel(record);\n } else {\n this.formRecord = await this.buildFixtureRecord(entity);\n this.formRecordIsReal = false;\n this.formRecordLabel = 'Mock data';\n }\n }\n\n /**\n * Load the first row by NameField (then __mj_CreatedAt) so different users\n * opening the same form-role artifact see the same record bound to the\n * preview. (Retrospective fix #7 — un-ordered Top-1 was physical-order\n * and non-deterministic.)\n */\n private async loadTopOneRecord(entity: EntityInfo): Promise<BaseEntity | null> {\n try {\n const orderBy = entity.NameField?.Name\n ? `${entity.NameField.Name} ASC`\n : `__mj_CreatedAt DESC`;\n const rv = RunView.FromMetadataProvider(this.ProviderToUse);\n const result = await rv.RunView<BaseEntity>({\n EntityName: entity.Name,\n MaxRows: 1,\n OrderBy: orderBy,\n ResultType: 'entity_object',\n }, this.ProviderToUse.CurrentUser);\n if (result.Success && (result.Results?.length ?? 0) > 0) {\n return result.Results[0];\n }\n } catch (err) {\n LogError(`ComponentArtifactViewer: Top-1 RunView failed for ${entity.Name}: ${err instanceof Error ? err.message : String(err)}`);\n }\n return null;\n }\n\n /** Synthetic \"create-mode\" record when no real row exists or RunView failed. */\n private async buildFixtureRecord(entity: EntityInfo): Promise<BaseEntity | null> {\n try {\n const fresh = await this.ProviderToUse.GetEntityObject<BaseEntity>(entity.Name, this.ProviderToUse.CurrentUser);\n fresh.NewRecord();\n return fresh;\n } catch (err) {\n LogError(`ComponentArtifactViewer: failed to build fixture record for ${entity.Name}: ${err instanceof Error ? err.message : String(err)}`);\n return null;\n }\n }\n\n /** Pull a human-readable label from the record's NameField or first text field. */\n private computeRecordLabel(record: BaseEntity): string {\n const nameField = record.EntityInfo.NameField?.Name;\n if (nameField) {\n const v = record.Get(nameField);\n if (v != null && String(v).trim().length > 0) return String(v);\n }\n if (record.PrimaryKey?.HasValue) return record.PrimaryKey.ToConcatenatedString();\n return record.EntityInfo.Name;\n }\n\n /**\n * Search-as-you-type for the picker. Queries by name field (or any\n * indexed string field, best-effort). Limits to 8 hits for tightness.\n */\n public async onPickerSearchInput(term: string): Promise<void> {\n this.recordSearchTerm = term;\n if (!this.formEntityInfo || term.trim().length === 0) {\n this.recordSearchResults = [];\n return;\n }\n const nameField = this.formEntityInfo.NameField?.Name;\n if (!nameField) {\n this.recordSearchResults = [];\n return;\n }\n try {\n const rv = RunView.FromMetadataProvider(this.ProviderToUse);\n // Best-effort LIKE filter against the entity's name field. Wrap the\n // term so we don't break SQL — RunView passes ExtraFilter as-is.\n const safe = term.replace(/'/g, \"''\");\n const result = await rv.RunView<BaseEntity>({\n EntityName: this.formEntityInfo.Name,\n ExtraFilter: `${nameField} LIKE '%${safe}%'`,\n MaxRows: 8,\n ResultType: 'entity_object',\n }, this.ProviderToUse.CurrentUser);\n if (result.Success) {\n this.recordSearchResults = (result.Results ?? []).map(r => ({\n ID: r.PrimaryKey?.ToConcatenatedString() ?? '',\n Label: this.computeRecordLabel(r),\n }));\n }\n } catch (err) {\n LogError(`ComponentArtifactViewer: picker search failed: ${err instanceof Error ? err.message : String(err)}`);\n this.recordSearchResults = [];\n }\n }\n\n /** User picked a different record from the search results. Re-bind the form. */\n public async onPickerSelect(item: { ID: string; Label: string }): Promise<void> {\n if (!this.formEntityInfo) return;\n try {\n const rec = await this.ProviderToUse.GetEntityObject<BaseEntity>(\n this.formEntityInfo.Name, this.ProviderToUse.CurrentUser,\n );\n const pk = new CompositeKey();\n pk.LoadFromURLSegment(this.formEntityInfo, item.ID);\n const loaded = await rec.InnerLoad(pk);\n if (loaded) {\n this.formRecord = rec;\n this.formRecordIsReal = true;\n this.formRecordLabel = item.Label;\n this.showRecordPicker = false;\n this.recordSearchTerm = '';\n this.recordSearchResults = [];\n }\n } catch (err) {\n LogError(`ComponentArtifactViewer: failed to load picked record ${item.ID}: ${err instanceof Error ? err.message : String(err)}`);\n }\n }\n\n /** Bubble Apply intent up to the host (Form Builder dashboard / Sage chat). */\n public onApplyClicked(): void {\n if (!this.component || !this.formEntityInfo) return;\n this.applyFormRequested.emit({\n spec: this.component,\n entityName: this.formEntityInfo.Name,\n });\n }\n}\n","<div class=\"component-artifact-viewer\" [ngClass]=\"cssClass\">\n <!-- Component Preview (full screen) -->\n <div class=\"component-preview\">\n @if (hasError) {\n <div class=\"error-state\">\n <i class=\"fa-solid fa-exclamation-triangle\"></i>\n <h3>{{ errorMessage }}</h3>\n <p>This component could not be loaded. This usually happens when:</p>\n <ul style=\"text-align: left; max-width: 500px; color: var(--mj-text-muted); line-height: 1.6;\">\n <li>The component registry is unavailable or unreachable</li>\n <li>The component version does not exist in the registry</li>\n <li>There was a network error during component retrieval</li>\n </ul>\n @if (errorDetails) {\n <details style=\"margin-top: 20px;\">\n <summary>Technical Details</summary>\n <pre>{{ errorDetails }}</pre>\n </details>\n }\n </div>\n } @else if (isFormArtifact) {\n <!-- ════════════════════════════════════════════════\n FORM-AWARE BRANCH\n Spec declares componentRole: 'form'. Render via\n <mj-interactive-form> bound to a real Top-1 record\n (or a synthetic NewRecord fallback). Picker chip\n lets the user swap records; Apply promotes the\n spec to an EntityFormOverride.\n ════════════════════════════════════════════════ -->\n <div class=\"form-artifact-toolstrip\">\n <i class=\"fa-solid fa-circle-info\" aria-hidden=\"true\"></i>\n <span class=\"form-artifact-toolstrip-label\">Previewing record:</span>\n <button\n type=\"button\"\n class=\"form-artifact-picker-chip\"\n (click)=\"showRecordPicker = !showRecordPicker\">\n <i class=\"fa-solid fa-magnifying-glass\"></i>\n <strong>{{ formRecordLabel || 'No record' }}</strong>\n @if (!formRecordIsReal) {\n <span class=\"form-artifact-picker-chip-badge\">Mock</span>\n }\n <i class=\"fa-solid fa-chevron-down\"></i>\n </button>\n @if (formEntityInfo) {\n <span class=\"form-artifact-toolstrip-entity\">{{ formEntityInfo.DisplayName || formEntityInfo.Name }}</span>\n }\n @if (formInitError) {\n <span class=\"form-artifact-toolstrip-warning\" [title]=\"formInitError\">\n <i class=\"fa-solid fa-triangle-exclamation\"></i>\n </span>\n }\n <span style=\"flex: 1;\"></span>\n @if (formEntityInfo) {\n <button\n type=\"button\"\n class=\"form-artifact-apply-btn\"\n (click)=\"onApplyClicked()\">\n <i class=\"fa-solid fa-circle-check\"></i>\n Apply to my form\n </button>\n }\n </div>\n\n @if (showRecordPicker && formEntityInfo) {\n <div class=\"form-artifact-picker-panel\" (click)=\"$event.stopPropagation()\">\n <input\n type=\"text\"\n class=\"form-artifact-picker-search\"\n placeholder=\"Search records by name…\"\n [value]=\"recordSearchTerm\"\n (input)=\"onPickerSearchInput($any($event.target).value)\" />\n @if (recordSearchResults.length > 0) {\n <ul class=\"form-artifact-picker-results\">\n @for (r of recordSearchResults; track r.ID) {\n <li\n class=\"form-artifact-picker-row\"\n (click)=\"onPickerSelect(r)\">\n <i class=\"fa-solid fa-circle-dot\"></i>\n <span>{{ r.Label }}</span>\n </li>\n }\n </ul>\n } @else if (recordSearchTerm.length > 0) {\n <div class=\"form-artifact-picker-empty\">No matches.</div>\n } @else {\n <div class=\"form-artifact-picker-empty\">Start typing to search.</div>\n }\n </div>\n }\n\n @if (formRecord && component) {\n <div class=\"form-artifact-form-host\">\n <mj-interactive-form\n [componentSpec]=\"component\"\n [record]=\"formRecord\">\n </mj-interactive-form>\n </div>\n } @else {\n <div class=\"error-state\">\n <i class=\"fa-solid fa-exclamation-circle\"></i>\n <h3>Form preview unavailable</h3>\n <p>{{ formInitError || 'Could not bind a record to this form.' }}</p>\n </div>\n }\n } @else {\n <!-- Default (non-form) interactive component path -->\n @if (component && (component.code || component.namespace)) {\n <mj-react-component\n #reactComponent\n [component]=\"component\"\n (componentEvent)=\"onComponentEvent($event)\"\n (openEntityRecord)=\"onOpenEntityRecord($event)\"\n (initialized)=\"onReactComponentInitialized()\">\n </mj-react-component>\n } @else if (component) {\n <!-- Component spec exists but no code - show informational message -->\n <div class=\"no-code-state\">\n <i class=\"fa-solid fa-file-lines\"></i>\n <h3>Component Specification</h3>\n <p>This component has specifications but no executable code yet.</p>\n <p>View the Functional, Data, or Spec tabs for details.</p>\n </div>\n } @else {\n <div class=\"error-state\">\n <i class=\"fa-solid fa-exclamation-circle\"></i>\n <h3>No Component Loaded</h3>\n <p>The component data is missing or invalid.</p>\n </div>\n }\n }\n </div>\n\n <!-- Feedback overlay panel (invoked from header button via AskUserForFeedback) -->\n @if (ShowFeedbackPanel && resolvedComponentSpec) {\n <mj-component-feedback-panel\n [ComponentSpec]=\"resolvedComponentSpec\"\n [ReactContainerElement]=\"reactComponent?.container?.nativeElement || null\"\n (Closed)=\"ShowFeedbackPanel = false\">\n </mj-component-feedback-panel>\n }\n</div>\n"]}
1
+ {"version":3,"file":"component-artifact-viewer.component.js","sourceRoot":"","sources":["../../../../src/lib/components/plugins/component-artifact-viewer.component.ts","../../../../src/lib/components/plugins/component-artifact-viewer.component.html"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAmD,MAAM,EAAE,YAAY,EAAqB,MAAM,eAAe,CAAC;AAC/I,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,iCAAiC,EAAqB,MAAM,mCAAmC,CAAC;AAEzG,OAAO,EAAE,0BAA0B,EAAiB,MAAM,6CAA6C,CAAC;AACxG,OAAO,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,mDAAmD,CAAC;AAC1G,OAAO,EAAc,YAAY,EAAE,YAAY,EAAc,QAAQ,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC7G,OAAO,EAAE,+BAA+B,EAAE,MAAM,+DAA+D,CAAC;AAChH,OAAO,EAAE,4BAA4B,EAA8B,MAAM,mCAAmC,CAAC;;;;;;;;;ICOjG,AADF,kCAAmC,cACxB;IAAA,iCAAiB;IAAA,iBAAU;IACpC,2BAAK;IAAA,YAAkB;IACzB,AADyB,iBAAM,EACrB;;;IADH,eAAkB;IAAlB,yCAAkB;;;IAZ7B,8BAAyB;IACvB,uBAAgD;IAChD,0BAAI;IAAA,YAAkB;IAAA,iBAAK;IAC3B,yBAAG;IAAA,8EAA8D;IAAA,iBAAI;IAEnE,AADF,6BAA+F,SACzF;IAAA,oEAAoD;IAAA,iBAAK;IAC7D,0BAAI;IAAA,qEAAoD;IAAA,iBAAK;IAC7D,2BAAI;IAAA,qEAAoD;IAC1D,AAD0D,iBAAK,EAC1D;IACL,sHAAoB;IAMtB,iBAAM;;;IAbA,eAAkB;IAAlB,yCAAkB;IAOtB,gBAKC;IALD,+C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AAgB,mEAiBa,6EAoFK,kEAiCzB;YA0BX,iBAAM;YAGN,0HAAkD;YAOpD,iBAAM;;YA7KiC,sCAAoB;YAGvD,eA+JC;YA/JD,6FA+JC;YAIH,eAMC;YAND,6EAMC;;;ADnJU,gCAAgC;IAD5C,aAAa,CAAC,iCAAiC,EAAE,+BAA+B,CAAC;GACrE,gCAAgC,CAmhB5C;;iFAnhBY,gCAAgC;cAP5C,SAAS;6BACI,KAAK,YACP,8BAA8B;;kBAMvC,SAAS;mBAAC,gBAAgB;;kBAC1B,MAAM;;kBACN,MAAM;;kBAQN,MAAM;;kFAXI,gCAAgC","sourcesContent":["import { Component, ViewChild, AfterViewInit, OnInit, OnChanges, SimpleChanges, Output, EventEmitter, ChangeDetectorRef } from '@angular/core';\nimport { RegisterClass, SafeJSONParse } from '@memberjunction/global';\nimport { BaseArtifactViewerPluginComponent, ArtifactViewerTab } from '../base-artifact-viewer.component';\nimport { MJReactComponent, AngularAdapterService } from '@memberjunction/ng-react';\nimport { BuildComponentCompleteCode, ComponentSpec } from '@memberjunction/interactive-component-types';\nimport { isFormRole, getDeclaredFormEntityName } from '@memberjunction/interactive-component-types/forms';\nimport { BaseEntity, CompositeKey, DataSnapshot, EntityInfo, LogError, RunView } from '@memberjunction/core';\nimport { DataRequirementsViewerComponent } from './data-requirements-viewer/data-requirements-viewer.component';\nimport { evaluateComponentPermissions, PermissionEvaluationResult } from './component-permission-evaluation';\n\n/**\n * Viewer component for interactive Component artifacts (React-based UI components)\n *\n * Features:\n * - Live component preview with React rendering\n * - Dynamic tabs for component metadata (via GetAdditionalTabs)\n * - Provides tabs for: Code, Functional Requirements, Technical Design, Data Requirements\n */\n@Component({\n standalone: false,\n selector: 'mj-component-artifact-viewer',\n templateUrl: './component-artifact-viewer.component.html',\n styleUrls: ['./component-artifact-viewer.component.css']\n})\n@RegisterClass(BaseArtifactViewerPluginComponent, 'ComponentArtifactViewerPlugin')\nexport class ComponentArtifactViewerComponent extends BaseArtifactViewerPluginComponent implements OnInit, AfterViewInit, OnChanges {\n @ViewChild('reactComponent') reactComponent?: MJReactComponent;\n @Output() tabsChanged = new EventEmitter<void>();\n @Output() openEntityRecord = new EventEmitter<{entityName: string; compositeKey: CompositeKey}>();\n\n /**\n * Emitted when the user clicks \"Apply to my form\" on a form-role artifact.\n * Carries the spec (ready to hand to the agent's Create/Modify action) and\n * the entity name. The host is responsible for confirming + invoking the\n * actual server action.\n */\n @Output() applyFormRequested = new EventEmitter<{ spec: ComponentSpec; entityName: string }>();\n\n // ── Form-aware state (only populated when componentRole === 'form') ──\n\n /** True when this artifact's spec declares `componentRole: 'form'`. */\n public isFormArtifact = false;\n\n /** Entity the form targets — resolved from spec.entityName / dataRequirements. */\n public formEntityInfo: EntityInfo | null = null;\n\n /** The real or fixture record currently bound to the form preview. */\n public formRecord: BaseEntity | null = null;\n\n /** True iff `formRecord` is a real DB row (vs a fixture NewRecord()). */\n public formRecordIsReal = false;\n\n /** Label for the chip (e.g. the record's Name field). */\n public formRecordLabel = '';\n\n /** Picker UI state. */\n public showRecordPicker = false;\n public recordSearchTerm = '';\n public recordSearchResults: Array<{ ID: string; Label: string }> = [];\n public formInitError: string | null = null;\n\n // Component data\n public component: ComponentSpec | null = null;\n public componentCode: string = \"\";\n public componentName: string = '';\n\n /**\n * Cached resolved spec from the registry, preserved even after the React component\n * is destroyed (e.g., when a render error removes <mj-react-component> from the DOM).\n */\n private _cachedResolvedSpec: ComponentSpec | null = null;\n\n public get resolvedComponentSpec(): ComponentSpec | null {\n // Prefer the live React component's resolved spec (most up-to-date),\n // then fall back to our cached copy (survives DOM destruction),\n // then fall back to the stripped local spec as last resort.\n return this.reactComponent?.resolvedComponentSpec || this._cachedResolvedSpec || this.component;\n }\n\n // Feedback panel\n public ShowFeedbackPanel = false;\n\n // Error state\n public hasError = false;\n public errorMessage = '';\n public errorDetails = '';\n\n // Permission state\n public permissionResult: PermissionEvaluationResult | null = null;\n\n /**\n * Whether this plugin has content to display in the Display tab.\n * Returns true only if the component has code that can be rendered.\n *\n * IMPORTANT: Uses this.component (synchronously loaded from artifact JSON)\n * instead of resolvedComponentSpec (which depends on async React loading).\n * This ensures hasDisplayContent returns correct value immediately when\n * pluginLoaded fires, before React component finishes loading.\n */\n public override get hasDisplayContent(): boolean {\n // Use this.component directly - it's available synchronously after loadComponentSpec()\n return !!this.component?.namespace || !!this.component?.code\n }\n\n constructor(private adapter: AngularAdapterService, private cdr: ChangeDetectorRef) {\n super();\n }\n\n async ngOnChanges(changes: SimpleChanges): Promise<void> {\n // When artifactVersion input changes, reload the component spec\n if (changes['artifactVersion']) {\n this.loadComponentSpec();\n // Notify parent that tabs may have changed (on subsequent changes)\n if (!changes['artifactVersion'].firstChange) {\n this.tabsChanged.emit();\n }\n }\n }\n\n /**\n * Synchronously load the component spec from artifact content.\n * This is intentionally synchronous so that tabs are available immediately\n * when the parent queries GetAdditionalTabs() after pluginLoaded fires.\n *\n * The bridge purges the runtime registry + manager fetch cache itself when\n * it (re)initializes for the new spec, so we don't need to clear caches\n * from here — the bridge instance may not even exist yet when ngOnChanges\n * fires for the first time.\n */\n private loadComponentSpec(): void {\n try {\n // Clear cached resolved spec from previous version so stale data doesn't persist\n this._cachedResolvedSpec = null;\n this.permissionResult = null;\n\n if (this.artifactVersion?.Content) {\n this.component = SafeJSONParse(this.artifactVersion.Content) as ComponentSpec;\n this.extractComponentParts();\n this.evaluatePermissions();\n // Form-aware detection. Done here (not in ngAfterViewInit) so the\n // template's `@if (isFormArtifact)` branch decides which preview\n // to mount on the very first render — no flash of the non-form\n // path before the form-aware UI takes over.\n this.detectAndInitFormArtifact();\n } else {\n throw new Error('Artifact content is empty');\n }\n } catch (error) {\n console.error('Failed to load component spec:', error);\n this.hasError = true;\n this.errorMessage = 'Failed to load component';\n this.errorDetails = error instanceof Error ? error.message : String(error);\n }\n }\n\n /**\n * Evaluate whether the current user has sufficient permissions for\n * all entities and queries referenced in the component's dataRequirements.\n * Uses the best available spec: resolved (from registry) > cached > stripped artifact.\n * Runs synchronously against already-loaded client-side metadata.\n */\n private evaluatePermissions(): void {\n const spec = this.resolvedComponentSpec;\n if (!spec) return;\n\n const provider = this.ProviderToUse;\n const currentUser = provider.CurrentUser;\n if (!currentUser) return; // No user context — skip check\n\n this.permissionResult = evaluateComponentPermissions(spec, currentUser, provider);\n }\n\n /** Whether the component should be blocked from rendering due to missing permissions. */\n public get isPermissionBlocked(): boolean {\n return !!this.permissionResult && !this.permissionResult.canRun;\n }\n\n /**\n * Component initialization.\n * Note: loadComponentSpec() is called in ngOnChanges which runs before ngOnInit,\n * ensuring tabs are available when pluginLoaded fires.\n * The async adapter initialization happens here and doesn't block tab availability.\n */\n async ngOnInit(): Promise<void> {\n // Initialize Angular adapter for React components (async operation)\n try {\n await this.adapter.initialize();\n } catch (error) {\n console.error('Failed to initialize Angular adapter:', error);\n this.hasError = true;\n this.errorMessage = 'Failed to initialize component runtime';\n this.errorDetails = error instanceof Error ? error.message : String(error);\n }\n }\n\n async ngAfterViewInit(): Promise<void> {\n // Component initialization happens automatically via mj-react-component\n }\n\n /**\n * Provide additional tabs for viewing component metadata\n */\n public GetAdditionalTabs(): ArtifactViewerTab[] {\n const tabs: ArtifactViewerTab[] = [];\n\n const resolvedComponent = this.resolvedComponentSpec;\n\n if (!resolvedComponent) {\n return tabs;\n }\n\n // Functional Requirements tab\n if (resolvedComponent.functionalRequirements) {\n tabs.push({\n label: 'Functional',\n icon: 'fa-clipboard-list',\n contentType: 'markdown',\n content: resolvedComponent.functionalRequirements\n });\n }\n\n // Technical Design tab\n if (resolvedComponent.technicalDesign) {\n tabs.push({\n label: 'Technical',\n icon: 'fa-wrench',\n contentType: 'markdown',\n content: resolvedComponent.technicalDesign\n });\n }\n\n // Data Requirements tab - uses custom component for rich visualization\n if (resolvedComponent.dataRequirements) {\n tabs.push({\n label: 'Data',\n icon: 'fa-database',\n contentType: 'component',\n component: DataRequirementsViewerComponent,\n componentInputs: { dataRequirements: resolvedComponent.dataRequirements }\n });\n }\n\n // Code tab (lazy-loaded) - only show if there's actual code\n if (resolvedComponent.code && resolvedComponent.code.trim()) {\n tabs.push({\n label: 'Code',\n icon: 'fa-code',\n contentType: 'code',\n language: 'typescript',\n content: () => BuildComponentCompleteCode(resolvedComponent)\n });\n }\n\n // Spec tab - Shows fully resolved component spec in JSON format (rightmost)\n tabs.push({\n label: 'Spec',\n icon: 'fa-file-code',\n contentType: 'json',\n content: () => JSON.stringify(resolvedComponent, null, 2),\n language: 'json'\n });\n\n return tabs;\n }\n\n /**\n * Remove standard JSON tab since we provide \"Resolved JSON\" custom tab\n * The custom tab shows the fully resolved component spec instead of raw artifact JSON\n */\n public GetStandardTabRemovals(): string[] {\n return ['JSON'];\n }\n\n private extractComponentParts(): void {\n if (this.resolvedComponentSpec?.name) {\n this.componentName = this.resolvedComponentSpec.name;\n }\n if (this.resolvedComponentSpec?.code) {\n this.componentCode = BuildComponentCompleteCode(this.resolvedComponentSpec);\n }\n }\n\n /**\n * Called when MJReactComponent finishes loading the full component spec from the registry.\n * The full spec may contain Functional, Technical, and Data tabs not in the stripped spec.\n * Caches the resolved spec so it survives DOM destruction (e.g., if the component fails to\n * render and <mj-react-component> is removed by the @if/else block).\n * Emits tabsChanged so the parent panel re-evaluates allTabs and renders the new tab labels.\n */\n onReactComponentInitialized(): void {\n if (this.reactComponent?.resolvedComponentSpec &&\n this.reactComponent.resolvedComponentSpec !== this.component) {\n // Cache the resolved spec so it's available even after the React component is destroyed\n this._cachedResolvedSpec = this.reactComponent.resolvedComponentSpec;\n this.tabsChanged.emit();\n\n // Re-evaluate permissions against the resolved spec — the stripped artifact\n // spec has no dataRequirements, so the initial check in loadComponentSpec()\n // passes trivially. The resolved spec from the registry contains the full\n // dataRequirements with entity and query references.\n this.evaluatePermissions();\n }\n }\n\n onComponentEvent(event: unknown): void {\n console.log('Component event:', event);\n\n // Handle error events from React component\n if (event && typeof event === 'object' && 'type' in event && event.type === 'error') {\n const errorEvent = event as { type: 'error'; payload: { error: string; source: string } };\n this.hasError = true;\n this.errorMessage = 'Component Failed to Load';\n this.errorDetails = errorEvent.payload.error || 'Unknown error occurred while loading the component';\n }\n }\n\n /**\n * Handle entity record open request from React component\n * Propagates the event up to parent components\n */\n onOpenEntityRecord(event: {entityName: string; key: CompositeKey}): void {\n // Transform to use 'compositeKey' name for consistency with Angular components\n this.openEntityRecord.emit({\n entityName: event.entityName,\n compositeKey: event.key\n });\n }\n\n public override GetCurrentStateSnapshot(): DataSnapshot | null {\n // First try the component's explicit or auto-captured data state.\n // MJReactComponent.getCurrentDataState() already includes the fallback\n // to intercepted RunView/RunQuery results when the React component\n // doesn't register getCurrentDataState() via callbacks.RegisterMethod.\n const dataState = this.reactComponent?.getCurrentDataState?.();\n if (dataState && typeof dataState === 'object') {\n return dataState as DataSnapshot;\n }\n\n // Fallback for components with no captured data — static mockups,\n // pure-display components, or components whose data hooks haven't fired.\n // Rather than short-circuit Analyze with \"No data available\", emit a\n // minimal snapshot so the user can still open an agent conversation about\n // the component. The artifact itself is attached to the conversation as an\n // Input junction, so the agent can reason from the spec + any static data\n // baked into the component code.\n const spec = this.resolvedComponentSpec;\n if (!spec) return null;\n\n const snap = new DataSnapshot();\n snap.title = spec.title || spec.name || this.getDisplayTitle() || undefined;\n snap.interpretation =\n `Interactive component artifact${spec.name ? ` \"${spec.name}\"` : ''}. ` +\n `No live data was captured — the component either has no data-fetching ` +\n `hooks or has not yet run its queries. The component specification is ` +\n `attached to this conversation; the agent should inspect it directly.`;\n return snap;\n }\n\n /**\n * Component artifacts support feedback when a resolved spec is available.\n */\n public override get SupportsFeedback(): boolean {\n return !!this.resolvedComponentSpec;\n }\n\n /**\n * Toggle the feedback panel open. Called from the artifact viewer header button.\n */\n public override AskUserForFeedback(): void {\n this.ShowFeedbackPanel = !this.ShowFeedbackPanel;\n }\n\n // ════════════════════════════════════════════════════════════════════\n // FORM-AWARE BRANCH\n //\n // When the artifact's spec declares `componentRole: 'form'`, the viewer\n // delegates rendering to `<mj-interactive-form>` instead of the raw\n // `<mj-react-component>` path. This gives the React form a proper\n // FormHostProps binding (bound to a real DB record by default) and lets\n // the user swap records via a search picker before applying.\n //\n // Triggered from `loadComponentSpec()` after the spec parses.\n // ════════════════════════════════════════════════════════════════════\n\n /**\n * Detect form-role and kick off entity + record resolution. Failure modes\n * (missing entity, RunView failure, entity has no rows) fall back to a\n * synthetic record from `BaseEntity.NewRecord()` so the form still mounts\n * against type-appropriate empty values.\n */\n private async detectAndInitFormArtifact(): Promise<void> {\n this.isFormArtifact = false;\n this.formEntityInfo = null;\n this.formRecord = null;\n this.formRecordIsReal = false;\n this.formRecordLabel = '';\n this.formInitError = null;\n\n const spec = this.component;\n if (!spec || !isFormRole(spec)) return;\n\n this.isFormArtifact = true;\n\n const entityName = getDeclaredFormEntityName(spec);\n if (!entityName) {\n this.formInitError = 'Form artifact has no declared entity. Showing without record context.';\n return;\n }\n\n const provider = this.ProviderToUse;\n const entity = provider?.EntityByName(entityName);\n if (!entity) {\n this.formInitError = `Entity \"${entityName}\" not registered with the active provider.`;\n return;\n }\n this.formEntityInfo = entity;\n\n // Load Top-1 record by default. If empty / fails, fall back to a fresh\n // synthetic record. Either way the form mounts — failure to find a real\n // record is informational, not fatal.\n const record = await this.loadTopOneRecord(entity);\n if (record) {\n this.formRecord = record;\n this.formRecordIsReal = true;\n this.formRecordLabel = this.computeRecordLabel(record);\n } else {\n this.formRecord = await this.buildFixtureRecord(entity);\n this.formRecordIsReal = false;\n this.formRecordLabel = 'Mock data';\n }\n // This runs after an await on a RunView that resolves outside Angular's zone,\n // so nothing would refresh the view until the next user event — leaving the\n // \"Could not bind a record\" message up until the user clicks. Force CD so the\n // auto-loaded record binds and the form mounts immediately on first render.\n this.cdr.detectChanges();\n }\n\n /**\n * Load the first row by NameField (then __mj_CreatedAt) so different users\n * opening the same form-role artifact see the same record bound to the\n * preview. (Retrospective fix #7 — un-ordered Top-1 was physical-order\n * and non-deterministic.)\n */\n private async loadTopOneRecord(entity: EntityInfo): Promise<BaseEntity | null> {\n try {\n const orderBy = entity.NameField?.Name\n ? `${entity.NameField.Name} ASC`\n : `__mj_CreatedAt DESC`;\n const rv = RunView.FromMetadataProvider(this.ProviderToUse);\n const result = await rv.RunView<BaseEntity>({\n EntityName: entity.Name,\n MaxRows: 1,\n OrderBy: orderBy,\n ResultType: 'entity_object',\n }, this.ProviderToUse.CurrentUser);\n if (result.Success && (result.Results?.length ?? 0) > 0) {\n return result.Results[0];\n }\n } catch (err) {\n LogError(`ComponentArtifactViewer: Top-1 RunView failed for ${entity.Name}: ${err instanceof Error ? err.message : String(err)}`);\n }\n return null;\n }\n\n /** Synthetic \"create-mode\" record when no real row exists or RunView failed. */\n private async buildFixtureRecord(entity: EntityInfo): Promise<BaseEntity | null> {\n try {\n const fresh = await this.ProviderToUse.GetEntityObject<BaseEntity>(entity.Name, this.ProviderToUse.CurrentUser);\n fresh.NewRecord();\n return fresh;\n } catch (err) {\n LogError(`ComponentArtifactViewer: failed to build fixture record for ${entity.Name}: ${err instanceof Error ? err.message : String(err)}`);\n return null;\n }\n }\n\n /** Pull a human-readable label from the record's NameField or first text field. */\n private computeRecordLabel(record: BaseEntity): string {\n const nameField = record.EntityInfo.NameField?.Name;\n if (nameField) {\n const v = record.Get(nameField);\n if (v != null && String(v).trim().length > 0) return String(v);\n }\n if (record.PrimaryKey?.HasValue) return record.PrimaryKey.ToConcatenatedString();\n return record.EntityInfo.Name;\n }\n\n /**\n * Search-as-you-type for the picker. Queries by name field (or any\n * indexed string field, best-effort). Limits to 8 hits for tightness.\n */\n public async onPickerSearchInput(term: string): Promise<void> {\n this.recordSearchTerm = term;\n if (!this.formEntityInfo || term.trim().length === 0) {\n this.recordSearchResults = [];\n return;\n }\n const nameField = this.formEntityInfo.NameField?.Name;\n if (!nameField) {\n this.recordSearchResults = [];\n return;\n }\n try {\n const rv = RunView.FromMetadataProvider(this.ProviderToUse);\n // Best-effort LIKE filter against the entity's name field. Wrap the\n // term so we don't break SQL — RunView passes ExtraFilter as-is.\n const safe = term.replace(/'/g, \"''\");\n const result = await rv.RunView<BaseEntity>({\n EntityName: this.formEntityInfo.Name,\n ExtraFilter: `${nameField} LIKE '%${safe}%'`,\n MaxRows: 8,\n ResultType: 'entity_object',\n }, this.ProviderToUse.CurrentUser);\n if (result.Success) {\n this.recordSearchResults = (result.Results ?? []).map(r => ({\n ID: r.PrimaryKey?.ToConcatenatedString() ?? '',\n Label: this.computeRecordLabel(r),\n }));\n }\n } catch (err) {\n LogError(`ComponentArtifactViewer: picker search failed: ${err instanceof Error ? err.message : String(err)}`);\n this.recordSearchResults = [];\n }\n }\n\n /** User picked a different record from the search results. Re-bind the form. */\n public async onPickerSelect(item: { ID: string; Label: string }): Promise<void> {\n if (!this.formEntityInfo) return;\n try {\n const rec = await this.ProviderToUse.GetEntityObject<BaseEntity>(\n this.formEntityInfo.Name, this.ProviderToUse.CurrentUser,\n );\n const pk = new CompositeKey();\n pk.LoadFromURLSegment(this.formEntityInfo, item.ID);\n const loaded = await rec.InnerLoad(pk);\n if (loaded) {\n this.formRecord = rec;\n this.formRecordIsReal = true;\n this.formRecordLabel = item.Label;\n this.showRecordPicker = false;\n this.recordSearchTerm = '';\n this.recordSearchResults = [];\n }\n } catch (err) {\n LogError(`ComponentArtifactViewer: failed to load picked record ${item.ID}: ${err instanceof Error ? err.message : String(err)}`);\n }\n }\n\n /** Bubble Apply intent up to the host (Form Builder dashboard / Sage chat). */\n public onApplyClicked(): void {\n if (!this.component || !this.formEntityInfo) return;\n this.applyFormRequested.emit({\n spec: this.component,\n entityName: this.formEntityInfo.Name,\n });\n }\n}\n","<div class=\"component-artifact-viewer\" [ngClass]=\"cssClass\">\n <!-- Component Preview (full screen) -->\n <div class=\"component-preview\">\n @if (hasError) {\n <div class=\"error-state\">\n <i class=\"fa-solid fa-exclamation-triangle\"></i>\n <h3>{{ errorMessage }}</h3>\n <p>This component could not be loaded. This usually happens when:</p>\n <ul style=\"text-align: left; max-width: 500px; color: var(--mj-text-muted); line-height: 1.6;\">\n <li>The component registry is unavailable or unreachable</li>\n <li>The component version does not exist in the registry</li>\n <li>There was a network error during component retrieval</li>\n </ul>\n @if (errorDetails) {\n <details style=\"margin-top: 20px;\">\n <summary>Technical Details</summary>\n <pre>{{ errorDetails }}</pre>\n </details>\n }\n </div>\n } @else if (isFormArtifact) {\n <!-- ════════════════════════════════════════════════\n FORM-AWARE BRANCH\n Spec declares componentRole: 'form'. Render via\n <mj-interactive-form> bound to a real Top-1 record\n (or a synthetic NewRecord fallback). Picker chip\n lets the user swap records; Apply promotes the\n spec to an EntityFormOverride.\n ════════════════════════════════════════════════ -->\n <div class=\"form-artifact-toolstrip\">\n <i class=\"fa-solid fa-circle-info\" aria-hidden=\"true\"></i>\n <span class=\"form-artifact-toolstrip-label\">Previewing record:</span>\n <button\n type=\"button\"\n class=\"form-artifact-picker-chip\"\n (click)=\"showRecordPicker = !showRecordPicker\">\n <i class=\"fa-solid fa-magnifying-glass\"></i>\n <strong>{{ formRecordLabel || 'No record' }}</strong>\n @if (!formRecordIsReal) {\n <span class=\"form-artifact-picker-chip-badge\">Mock</span>\n }\n <i class=\"fa-solid fa-chevron-down\"></i>\n </button>\n @if (formEntityInfo) {\n <span class=\"form-artifact-toolstrip-entity\">{{ formEntityInfo.DisplayName || formEntityInfo.Name }}</span>\n }\n @if (formInitError) {\n <span class=\"form-artifact-toolstrip-warning\" [title]=\"formInitError\">\n <i class=\"fa-solid fa-triangle-exclamation\"></i>\n </span>\n }\n <span style=\"flex: 1;\"></span>\n @if (formEntityInfo) {\n <button\n type=\"button\"\n class=\"form-artifact-apply-btn\"\n (click)=\"onApplyClicked()\">\n <i class=\"fa-solid fa-circle-check\"></i>\n Apply to my form\n </button>\n }\n </div>\n\n @if (showRecordPicker && formEntityInfo) {\n <div class=\"form-artifact-picker-panel\" (click)=\"$event.stopPropagation()\">\n <input\n type=\"text\"\n class=\"form-artifact-picker-search\"\n placeholder=\"Search records by name…\"\n [value]=\"recordSearchTerm\"\n (input)=\"onPickerSearchInput($any($event.target).value)\" />\n @if (recordSearchResults.length > 0) {\n <ul class=\"form-artifact-picker-results\">\n @for (r of recordSearchResults; track r.ID) {\n <li\n class=\"form-artifact-picker-row\"\n (click)=\"onPickerSelect(r)\">\n <i class=\"fa-solid fa-circle-dot\"></i>\n <span>{{ r.Label }}</span>\n </li>\n }\n </ul>\n } @else if (recordSearchTerm.length > 0) {\n <div class=\"form-artifact-picker-empty\">No matches.</div>\n } @else {\n <div class=\"form-artifact-picker-empty\">Start typing to search.</div>\n }\n </div>\n }\n\n @if (formRecord && component) {\n <div class=\"form-artifact-form-host\">\n <mj-interactive-form\n [componentSpec]=\"component\"\n [record]=\"formRecord\">\n </mj-interactive-form>\n </div>\n } @else {\n <div class=\"error-state\">\n <i class=\"fa-solid fa-exclamation-circle\"></i>\n <h3>Form preview unavailable</h3>\n <p>{{ formInitError || 'Could not bind a record to this form.' }}</p>\n </div>\n }\n } @else if (isPermissionBlocked) {\n <!-- Permission warning — user lacks access to one or more data sources -->\n <div class=\"permission-warning\">\n <div class=\"permission-warning-icon\">\n <i class=\"fa-solid fa-shield-halved\"></i>\n </div>\n <h3>Insufficient Permissions</h3>\n <p>This component requires data access that you don't currently have:</p>\n\n @if (permissionResult!.missingEntities.length > 0) {\n <div class=\"permission-warning-section\">\n <span class=\"permission-warning-section-label\">Entities</span>\n <ul>\n @for (entity of permissionResult!.missingEntities; track entity) {\n <li><i class=\"fa-solid fa-table\"></i> {{ entity }}</li>\n }\n </ul>\n </div>\n }\n\n @if (permissionResult!.missingQueries.length > 0) {\n <div class=\"permission-warning-section\">\n <span class=\"permission-warning-section-label\">Queries</span>\n <ul>\n @for (query of permissionResult!.missingQueries; track query) {\n <li><i class=\"fa-solid fa-database\"></i> {{ query }}</li>\n }\n </ul>\n </div>\n }\n\n <p class=\"permission-warning-hint\">Contact your administrator to request access.</p>\n </div>\n } @else {\n <!-- Default (non-form) interactive component path -->\n @if (component && (component.code || component.namespace)) {\n <mj-react-component\n #reactComponent\n [component]=\"component\"\n (componentEvent)=\"onComponentEvent($event)\"\n (openEntityRecord)=\"onOpenEntityRecord($event)\"\n (initialized)=\"onReactComponentInitialized()\">\n </mj-react-component>\n } @else if (component) {\n <!-- Component spec exists but no code - show informational message -->\n <div class=\"no-code-state\">\n <i class=\"fa-solid fa-file-lines\"></i>\n <h3>Component Specification</h3>\n <p>This component has specifications but no executable code yet.</p>\n <p>View the Functional, Data, or Spec tabs for details.</p>\n </div>\n } @else {\n <div class=\"error-state\">\n <i class=\"fa-solid fa-exclamation-circle\"></i>\n <h3>No Component Loaded</h3>\n <p>The component data is missing or invalid.</p>\n </div>\n }\n }\n </div>\n\n <!-- Feedback overlay panel (invoked from header button via AskUserForFeedback) -->\n @if (ShowFeedbackPanel && resolvedComponentSpec) {\n <mj-component-feedback-panel\n [ComponentSpec]=\"resolvedComponentSpec\"\n [ReactContainerElement]=\"reactComponent?.container?.nativeElement || null\"\n (Closed)=\"ShowFeedbackPanel = false\">\n </mj-component-feedback-panel>\n }\n</div>\n"]}
@@ -0,0 +1,19 @@
1
+ import { IMetadataProvider, UserInfo } from '@memberjunction/core';
2
+ import { ComponentSpec } from '@memberjunction/interactive-component-types';
3
+ /**
4
+ * Result of evaluating a user's permissions against a component's data requirements.
5
+ */
6
+ export interface PermissionEvaluationResult {
7
+ /** Whether the user can run all data operations the component requires */
8
+ canRun: boolean;
9
+ /** Entity names the user lacks read permission for */
10
+ missingEntities: string[];
11
+ /** Query names the user lacks permission to execute */
12
+ missingQueries: string[];
13
+ }
14
+ /**
15
+ * Recursively evaluates permissions for a component and all its dependencies.
16
+ * Walks the full dependency tree, deduplicating results.
17
+ */
18
+ export declare function evaluateComponentPermissions(spec: ComponentSpec, currentUser: UserInfo, provider?: IMetadataProvider): PermissionEvaluationResult;
19
+ //# sourceMappingURL=component-permission-evaluation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-permission-evaluation.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/plugins/component-permission-evaluation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAY,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAG5E;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACvC,0EAA0E;IAC1E,MAAM,EAAE,OAAO,CAAC;IAChB,sDAAsD;IACtD,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,uDAAuD;IACvD,cAAc,EAAE,MAAM,EAAE,CAAC;CAC5B;AAuDD;;;GAGG;AACH,wBAAgB,4BAA4B,CACxC,IAAI,EAAE,aAAa,EACnB,WAAW,EAAE,QAAQ,EACrB,QAAQ,CAAC,EAAE,iBAAiB,GAC7B,0BAA0B,CAe5B"}
@@ -0,0 +1,64 @@
1
+ import { Metadata } from '@memberjunction/core';
2
+ import { QueryEngine } from '@memberjunction/core-entities';
3
+ /**
4
+ * Evaluates whether a user has sufficient permissions to run a component
5
+ * based on its declared dataRequirements. Checks both entity-level read
6
+ * permissions and query-level execution permissions.
7
+ *
8
+ * Runs entirely on client-side metadata — no additional server call needed.
9
+ */
10
+ function evaluateComponentPermissionsSingle(spec, currentUser, provider) {
11
+ const missingEntities = [];
12
+ const missingQueries = [];
13
+ const dataReqs = spec.dataRequirements;
14
+ if (!dataReqs) {
15
+ return { canRun: true, missingEntities: [], missingQueries: [] };
16
+ }
17
+ // Check entity permissions (all current components are read-only)
18
+ const md = provider ?? Metadata.Provider;
19
+ for (const entityReq of dataReqs.entities ?? []) {
20
+ const entityInfo = md.EntityByName(entityReq.name);
21
+ if (!entityInfo)
22
+ continue; // Unknown entity — skip (may be stale reference)
23
+ const perms = entityInfo.GetUserPermisions(currentUser);
24
+ if (!perms?.CanRead) {
25
+ missingEntities.push(entityReq.name);
26
+ }
27
+ }
28
+ // Check query permissions using centralized UserCanRun logic
29
+ const qe = QueryEngine.Instance;
30
+ for (const queryReq of dataReqs.queries ?? []) {
31
+ if (!queryReq.name)
32
+ continue;
33
+ const queryInfo = qe.FindQueryByName(queryReq.name);
34
+ if (!queryInfo)
35
+ continue; // Unknown query — skip
36
+ const result = queryInfo.UserCanRun(currentUser);
37
+ if (!result.canRun) {
38
+ missingQueries.push(queryReq.name);
39
+ }
40
+ }
41
+ return {
42
+ canRun: missingEntities.length === 0 && missingQueries.length === 0,
43
+ missingEntities,
44
+ missingQueries,
45
+ };
46
+ }
47
+ /**
48
+ * Recursively evaluates permissions for a component and all its dependencies.
49
+ * Walks the full dependency tree, deduplicating results.
50
+ */
51
+ export function evaluateComponentPermissions(spec, currentUser, provider) {
52
+ const result = evaluateComponentPermissionsSingle(spec, currentUser, provider);
53
+ for (const dep of spec.dependencies ?? []) {
54
+ const depResult = evaluateComponentPermissions(dep, currentUser, provider);
55
+ result.missingEntities.push(...depResult.missingEntities);
56
+ result.missingQueries.push(...depResult.missingQueries);
57
+ }
58
+ // Deduplicate
59
+ result.missingEntities = [...new Set(result.missingEntities)];
60
+ result.missingQueries = [...new Set(result.missingQueries)];
61
+ result.canRun = result.missingEntities.length === 0 && result.missingQueries.length === 0;
62
+ return result;
63
+ }
64
+ //# sourceMappingURL=component-permission-evaluation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-permission-evaluation.js","sourceRoot":"","sources":["../../../../src/lib/components/plugins/component-permission-evaluation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,QAAQ,EAAY,MAAM,sBAAsB,CAAC;AAE7E,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAc5D;;;;;;GAMG;AACH,SAAS,kCAAkC,CACvC,IAAmB,EACnB,WAAqB,EACrB,QAA4B;IAE5B,MAAM,eAAe,GAAa,EAAE,CAAC;IACrC,MAAM,cAAc,GAAa,EAAE,CAAC;IACpC,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC;IAEvC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACZ,OAAO,EAAE,MAAM,EAAE,IA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ACH,MAAM,UAAU,4BAA4B,CACxC,IAAmB,EACnB,WAAqB,EACrB,QAA4B;IAE5B,MAAM,MAAM,GAAG,kCAAkC,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;IAE/E,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,YAAY,IAAI,EAAE,EAAE,CAAC;QACxC,MAAM,SAAS,GAAG,4BAA4B,CAAC,GAAG,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;QAC3E,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,eAAe,CAAC,CAAC;QAC1D,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;IAC5D,CAAC;IAED,cAAc;IACd,MAAM,CAAC,eAAe,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC;IAC9D,MAAM,CAAC,cAAc,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC;IAC5D,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,cAAc,CAAC,MAAM,KAAK,CAAC,CAAC;IAE1F,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { IMetadataProvider, Metadata, UserInfo } from '@memberjunction/core';\nimport { ComponentSpec } from '@memberjunction/interactive-component-types';\nimport { QueryEngine } from '@memberjunction/core-entities';\n\n/**\n * Result of evaluating a user's permissions against a component's data requirements.\n */\nexport interface PermissionEvaluationResult {\n /** Whether the user can run all data operations the component requires */\n canRun: boolean;\n /** Entity names the user lacks read permission for */\n missingEntities: string[];\n /** Query names the user lacks permission to execute */\n missingQueries: string[];\n}\n\n/**\n * Evaluates whether a user has sufficient permissions to run a component\n * based on its declared dataRequirements. Checks both entity-level read\n * permissions and query-level execution permissions.\n *\n * Runs entirely on client-side metadata — no additional server call needed.\n */\nfunction evaluateComponentPermissionsSingle(\n spec: ComponentSpec,\n currentUser: UserInfo,\n provider?: IMetadataProvider\n): PermissionEvaluationResult {\n const missingEntities: string[] = [];\n const missingQueries: string[] = [];\n const dataReqs = spec.dataRequirements;\n\n if (!dataReqs) {\n return { canRun: true, missingEntities: [], missingQueries: [] };\n }\n\n // Check entity permissions (all current components are read-only)\n const md = provider ?? Metadata.Provider;\n for (const entityReq of dataReqs.entities ?? []) {\n const entityInfo = md.EntityByName(entityReq.name);\n if (!entityInfo) continue; // Unknown entity — skip (may be stale reference)\n\n const perms = entityInfo.GetUserPermisions(currentUser);\n if (!perms?.CanRead) {\n missingEntities.push(entityReq.name);\n }\n }\n\n // Check query permissions using centralized UserCanRun logic\n const qe = QueryEngine.Instance;\n for (const queryReq of dataReqs.queries ?? []) {\n if (!queryReq.name) continue;\n\n const queryInfo = qe.FindQueryByName(queryReq.name);\n if (!queryInfo) continue; // Unknown query — skip\n\n const result = queryInfo.UserCanRun(currentUser);\n if (!result.canRun) {\n missingQueries.push(queryReq.name);\n }\n }\n\n return {\n canRun: missingEntities.length === 0 && missingQueries.length === 0,\n missingEntities,\n missingQueries,\n };\n}\n\n/**\n * Recursively evaluates permissions for a component and all its dependencies.\n * Walks the full dependency tree, deduplicating results.\n */\nexport function evaluateComponentPermissions(\n spec: ComponentSpec,\n currentUser: UserInfo,\n provider?: IMetadataProvider\n): PermissionEvaluationResult {\n const result = evaluateComponentPermissionsSingle(spec, currentUser, provider);\n\n for (const dep of spec.dependencies ?? []) {\n const depResult = evaluateComponentPermissions(dep, currentUser, provider);\n result.missingEntities.push(...depResult.missingEntities);\n result.missingQueries.push(...depResult.missingQueries);\n }\n\n // Deduplicate\n result.missingEntities = [...new Set(result.missingEntities)];\n result.missingQueries = [...new Set(result.missingQueries)];\n result.canRun = result.missingEntities.length === 0 && result.missingQueries.length === 0;\n\n return result;\n}\n"]}
@@ -35,6 +35,21 @@ export declare class InteractiveFormApplyService {
35
35
  * the Action entity when ActionEngine isn't loaded.
36
36
  */
37
37
  private resolveActionIdByName;
38
+ /**
39
+ * Activate the override produced by a successful Create so a net-new form goes
40
+ * live immediately. Best-effort: on failure the form stays a Pending draft the
41
+ * user can activate manually, so we log and return false rather than failing the
42
+ * whole apply.
43
+ */
44
+ private activateCreatedOverride;
45
+ /**
46
+ * Align a freshly generated spec to an existing Component lineage before Modify.
47
+ * MJ identifies a form lineage by Component Name and refuses to change it between
48
+ * versions, so we rename the incoming spec — both `spec.name` and the root
49
+ * `function` declaration in `spec.code` (the linter requires them to match) — to
50
+ * the existing lineage name.
51
+ */
52
+ private alignSpecToLineage;
38
53
  /** Show a confirmation dialog explaining what's about to happen. */
39
54
  private confirm;
40
55
  private parseActiveResult;
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-form-apply.service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/interactive-form-apply.service.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAsB,KAAK,iBAAiB,EAAiB,MAAM,sBAAsB,CAAC;AAIjG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;;AAEjF,iFAAiF;AACjF,MAAM,WAAW,0BAA0B;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,gFAAgF;IAChF,IAAI,CAAC,EAAE,QAAQ,GAAG,oBAAoB,GAAG,iBAAiB,CAAC;IAC3D,6CAA6C;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qBACa,2BAA2B;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2B;IAClD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiC;IAE/D;;;OAGG;IACU,eAAe,CACxB,IAAI,EAAE,aAAa,EACnB,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,iBAAiB,GAC7B,OAAO,CAAC,0BAA0B,CAAC;IAwDtC;;;;;;OAMG;YACW,eAAe;IA+B7B;;;OAGG;YACW,qBAAqB;IAmBnC,oEAAoE;YACtD,OAAO;IA6BrB,OAAO,CAAC,iBAAiB;IAWzB,OAAO,CAAC,SAAS;IAiCjB,OAAO,CAAC,IAAI;yCA3MH,2BAA2B;6CAA3B,2BAA2B;CA+MvC"}
1
+ {"version":3,"file":"interactive-form-apply.service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/interactive-form-apply.service.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAsB,KAAK,iBAAiB,EAAiB,MAAM,sBAAsB,CAAC;AAIjG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;;AAEjF,iFAAiF;AACjF,MAAM,WAAW,0BAA0B;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,gFAAgF;IAChF,IAAI,CAAC,EAAE,QAAQ,GAAG,oBAAoB,GAAG,iBAAiB,CAAC;IAC3D,6CAA6C;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qBACa,2BAA2B;IACpC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2B;IAClD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAiC;IAE/D;;;OAGG;IACU,eAAe,CACxB,IAAI,EAAE,aAAa,EACnB,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,iBAAiB,GAC7B,OAAO,CAAC,0BAA0B,CAAC;IAsFtC;;;;;;OAMG;YACW,eAAe;IA+B7B;;;OAGG;YACW,qBAAqB;IAoBnC;;;;;OAKG;YACW,uBAAuB;IAoBrC;;;;;;OAMG;IACH,OAAO,CAAC,kBAAkB;IAW1B,oEAAoE;YACtD,OAAO;IA+BrB,OAAO,CAAC,iBAAiB;IAWzB,OAAO,CAAC,SAAS;IAsCjB,OAAO,CAAC,IAAI;yCA7RH,2BAA2B;6CAA3B,2BAA2B;CAiSvC"}
@@ -64,19 +64,49 @@ export class InteractiveFormApplyService {
64
64
  // Step 3: run Create or Modify.
65
65
  const formName = spec.name ?? 'Custom Form';
66
66
  if (hasExistingActive) {
67
+ // MJ's Modify operates on a Component *lineage* keyed by Name — the spec
68
+ // name must match the existing Component across versions. A freshly
69
+ // generated form usually has a different name, so align it to the existing
70
+ // lineage (spec.name + the root `function` declaration the linter checks)
71
+ // before modifying.
72
+ if (payload?.Active?.ComponentName) {
73
+ this.alignSpecToLineage(spec, payload.Active.ComponentName);
74
+ }
67
75
  const modifyResult = await this.runActionByName(client, 'Modify Interactive Form', [
68
76
  { Name: 'OverrideID', Value: payload.Active.OverrideID, Type: 'Input' },
69
77
  { Name: 'Spec', Value: JSON.stringify(spec), Type: 'Input' },
70
78
  { Name: 'Notes', Value: `Applied from chat artifact at ${new Date().toISOString()}`, Type: 'Input' },
79
+ // A user "Apply" is a deliberate save, never an in-flight refinement —
80
+ // so always snapshot a new restorable version rather than risk an
81
+ // in-place overwrite. Passing an explicit bump makes this deterministic
82
+ // across every source status (the 'in-place' default only applies to a
83
+ // Pending source, which is the agent's iteration loop, not this path).
84
+ // The prior version is demoted to Inactive on activation and stays in
85
+ // Form Builder's version rail.
86
+ { Name: 'VersionBumpKind', Value: 'minor', Type: 'Input' },
71
87
  ]);
72
- return this.summarize(modifyResult, 'modify', user);
88
+ // Auto-activate the resulting version too. "Apply to my form" is an explicit
89
+ // user action — they expect the applied form to go live, not sit as a Pending
90
+ // draft the runtime variant switcher (Active variants only) can't reach. The
91
+ // prior version is preserved as history and restorable from Form Builder.
92
+ const modifyActivated = modifyResult.Success
93
+ ? await this.activateCreatedOverride(client, modifyResult.Message)
94
+ : false;
95
+ return this.summarize(modifyResult, 'modify', user, modifyActivated);
73
96
  }
74
97
  const createResult = await this.runActionByName(client, 'Create Interactive Form', [
75
98
  { Name: 'EntityName', Value: entityName, Type: 'Input' },
76
99
  { Name: 'Name', Value: formName, Type: 'Input' },
77
100
  { Name: 'Spec', Value: JSON.stringify(spec), Type: 'Input' },
78
101
  ]);
79
- return this.summarize(createResult, 'create', user);
102
+ // Net-new "Apply to my form" is an explicit, confirmed user action, so we
103
+ // activate the freshly-created (Pending) override immediately — the form goes
104
+ // live in one step. Refining an EXISTING active form (the branch above) stays
105
+ // Pending so a live form is never silently replaced.
106
+ const activated = createResult.Success
107
+ ? await this.activateCreatedOverride(client, createResult.Message)
108
+ : false;
109
+ return this.summarize(createResult, 'create', user, activated);
80
110
  }
81
111
  // ── internals ────────────────────────────────────────────────────────
82
112
  /**
@@ -120,10 +150,11 @@ export class InteractiveFormApplyService {
120
150
  async resolveActionIdByName(name) {
121
151
  try {
122
152
  // ActionEngine may not be initialised in the chat surface — query directly.
153
+ // The core Action table is registered as the "MJ: Actions" entity.
123
154
  const { RunView } = await import('@memberjunction/core');
124
155
  const rv = new RunView();
125
156
  const result = await rv.RunView({
126
- EntityName: 'Actions',
157
+ EntityName: 'MJ: Actions',
127
158
  ExtraFilter: `Name='${name.replace(/'/g, "''")}'`,
128
159
  Fields: ['ID'],
129
160
  MaxRows: 1,
@@ -136,22 +167,66 @@ export class InteractiveFormApplyService {
136
167
  return null;
137
168
  }
138
169
  }
170
+ /**
171
+ * Activate the override produced by a successful Create so a net-new form goes
172
+ * live immediately. Best-effort: on failure the form stays a Pending draft the
173
+ * user can activate manually, so we log and return false rather than failing the
174
+ * whole apply.
175
+ */
176
+ async activateCreatedOverride(client, createMessage) {
177
+ let overrideId;
178
+ try {
179
+ overrideId = JSON.parse(createMessage ?? '{}').OverrideID;
180
+ }
181
+ catch {
182
+ overrideId = undefined;
183
+ }
184
+ if (!overrideId)
185
+ return false;
186
+ const activateResult = await this.runActionByName(client, 'Activate Interactive Form Version', [
187
+ { Name: 'OverrideID', Value: overrideId, Type: 'Input' },
188
+ ]);
189
+ if (!activateResult.Success) {
190
+ LogError(`InteractiveFormApplyService: created override ${overrideId} but auto-activation failed: ${activateResult.Message ?? 'unknown error'}`);
191
+ }
192
+ return activateResult.Success;
193
+ }
194
+ /**
195
+ * Align a freshly generated spec to an existing Component lineage before Modify.
196
+ * MJ identifies a form lineage by Component Name and refuses to change it between
197
+ * versions, so we rename the incoming spec — both `spec.name` and the root
198
+ * `function` declaration in `spec.code` (the linter requires them to match) — to
199
+ * the existing lineage name.
200
+ */
201
+ alignSpecToLineage(spec, existingName) {
202
+ const s = spec;
203
+ const currentName = s.name;
204
+ if (!currentName || currentName === existingName)
205
+ return;
206
+ s.name = existingName;
207
+ if (typeof s.code === 'string' && s.code.length > 0) {
208
+ const escaped = currentName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
209
+ s.code = s.code.replace(new RegExp(`function\\s+${escaped}\\s*\\(`), `function ${existingName}(`);
210
+ }
211
+ }
139
212
  /** Show a confirmation dialog explaining what's about to happen. */
140
213
  async confirm(hasExistingActive, entityName, currentVersion) {
214
+ // The dialog renders string content as plain text (not innerHTML), so use
215
+ // plain text here — HTML tags would show raw.
141
216
  const content = hasExistingActive
142
- ? `You already have an active custom form for <strong>${escape(entityName)}</strong> (v${escape(currentVersion ?? '?')}). Applying this artifact will create a <strong>new Pending version</strong> — your live form stays active until you explicitly activate the new version in Form Builder.`
143
- : `This will create a custom form for <strong>${escape(entityName)}</strong> scoped to your user. Other users will continue to see the default form.`;
217
+ ? `You already have a custom form for "${entityName}" (v${currentVersion ?? '?'}). Applying this will create a new version and make it your active form. The previous version is preserved and can be restored from Form Builder.`
218
+ : `This will create a custom form for "${entityName}" scoped to your user and make it active. Other users will continue to see the default form.`;
144
219
  // MJDialogAction surface is {text, primary?, themeColor?}; the
145
220
  // dialog's Result observable emits the entire clicked action (or
146
221
  // undefined for backdrop/X dismissal). Detect intent via the
147
222
  // `primary` flag — Apply / Create Pending are the primary actions;
148
223
  // Cancel and dismissal both resolve false.
149
224
  const ref = this.dialog.Open({
150
- title: hasExistingActive ? 'Apply as new Pending version?' : 'Apply this form?',
225
+ title: 'Apply this form?',
151
226
  content,
152
227
  width: 540,
153
228
  actions: [
154
- { text: hasExistingActive ? 'Create Pending' : 'Apply', primary: true, themeColor: 'primary' },
229
+ { text: 'Apply', primary: true, themeColor: 'primary' },
155
230
  { text: 'Cancel' },
156
231
  ],
157
232
  });
@@ -171,7 +246,7 @@ export class InteractiveFormApplyService {
171
246
  return null;
172
247
  }
173
248
  }
174
- summarize(result, kind, _user) {
249
+ summarize(result, kind, _user, activated = false) {
175
250
  if (!result.Success) {
176
251
  this.notifications.CreateSimpleNotification(`Apply failed: ${result.Message ?? result.ResultCode ?? 'unknown error'}`, 'error', 5000);
177
252
  return { Success: false, Message: result.Message };
@@ -185,10 +260,14 @@ export class InteractiveFormApplyService {
185
260
  ? 'create'
186
261
  : (payload.Mode === 'in-place' ? 'modify-in-place' : 'modify-new-version');
187
262
  const note = kind === 'create'
188
- ? 'Custom form is now active for your user.'
189
- : (mode === 'modify-in-place'
190
- ? 'Pending version updated. Activate it from Form Builder when ready.'
191
- : `Pending v${payload.Version ?? '?'} created. Activate it from Form Builder when ready.`);
263
+ ? (activated
264
+ ? 'Custom form is now active for your user.'
265
+ : 'Custom form created as a Pending draft — activate it from Form Builder to go live.')
266
+ : (activated
267
+ ? `Updated form is now active${payload.Version ? ` (v${payload.Version})` : ''} for your user.`
268
+ : (mode === 'modify-in-place'
269
+ ? 'Pending version updated. Activate it from Form Builder when ready.'
270
+ : `Pending v${payload.Version ?? '?'} created. Activate it from Form Builder when ready.`));
192
271
  this.notifications.CreateSimpleNotification(note, 'success', 4000);
193
272
  return {
194
273
  Success: true,
@@ -210,10 +289,4 @@ export class InteractiveFormApplyService {
210
289
  type: Injectable,
211
290
  args: [{ providedIn: 'root' }]
212
291
  }], null, null); })();
213
- /** Minimal HTML escape — the dialog content goes through `[innerHTML]` upstream. */
214
- function escape(s) {
215
- return s.replace(/[&<>"']/g, c => ({
216
- '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;',
217
- }[c] ?? c));
218
- }
219
292
  //# sourceMappingURL=interactive-form-apply.service.js.map