@memberjunction/ng-artifacts 5.47.0 → 5.48.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.
@@ -3,6 +3,7 @@ import { BaseArtifactViewerPluginComponent, ArtifactViewerTab } from '../base-ar
3
3
  import { MJReactComponent, AngularAdapterService } from '@memberjunction/ng-react';
4
4
  import { ComponentSpec } from '@memberjunction/interactive-component-types';
5
5
  import { BaseEntity, CompositeKey, DataSnapshot, EntityInfo } from '@memberjunction/core';
6
+ import { InteractiveFormComponent } from '@memberjunction/ng-base-forms';
6
7
  import { PermissionEvaluationResult } from './component-permission-evaluation';
7
8
  import * as i0 from "@angular/core";
8
9
  /**
@@ -17,6 +18,7 @@ export declare class ComponentArtifactViewerComponent extends BaseArtifactViewer
17
18
  private adapter;
18
19
  private cdr;
19
20
  reactComponent?: MJReactComponent;
21
+ interactiveForm?: InteractiveFormComponent;
20
22
  tabsChanged: EventEmitter<void>;
21
23
  openEntityRecord: EventEmitter<{
22
24
  entityName: string;
@@ -168,8 +170,27 @@ export declare class ComponentArtifactViewerComponent extends BaseArtifactViewer
168
170
  ID: string;
169
171
  Label: string;
170
172
  }): Promise<void>;
171
- /** Bubble Apply intent up to the host (Form Builder dashboard / Sage chat). */
172
- onApplyClicked(): void;
173
+ /**
174
+ * Bubble Apply intent up to the host (Form Builder dashboard / Sage chat).
175
+ *
176
+ * Resolves the full ComponentSpec (with code) from multiple sources:
177
+ * 1. resolvedComponentSpec — live React bridge or cached copy (best for non-form artifacts)
178
+ * 2. Re-parse artifact version Content — the agent stores the full spec including code
179
+ * 3. DB fallback — fetch from MJ: Components by name
180
+ *
181
+ * Source #2 covers the common form-artifact case where the React component lives inside
182
+ * <mj-interactive-form> and resolvedComponentSpec falls back to the stripped local spec.
183
+ */
184
+ onApplyClicked(): Promise<void>;
185
+ /**
186
+ * Resolve a ComponentSpec that includes code, trying multiple sources in order.
187
+ */
188
+ private resolveSpecWithCode;
189
+ /**
190
+ * Fetch the full ComponentSpec (including code) from the MJ: Components table
191
+ * by component name. Returns null if not found or on error.
192
+ */
193
+ private fetchFullSpecByName;
173
194
  static ɵfac: i0.ɵɵFactoryDeclaration<ComponentArtifactViewerComponent, never>;
174
195
  static ɵcmp: i0.ɵɵComponentDeclaration<ComponentArtifactViewerComponent, "mj-component-artifact-viewer", never, {}, { "tabsChanged": "tabsChanged"; "openEntityRecord": "openEntityRecord"; "applyFormRequested": "applyFormRequested"; }, never, never, false, never>;
175
196
  }
@@ -1 +1 @@
1
- {"version":3,"file":"component-artifact-viewer.component.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/plugins/component-artifact-viewer.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAU,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE/I,OAAO,EAAE,iCAAiC,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACzG,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAA8B,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAExG,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAqB,MAAM,sBAAsB,CAAC;AAE7G,OAAO,EAAgC,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;;AAE7G;;;;;;;GAOG;AACH,qBAOa,gCAAiC,SAAQ,iCAAkC,YAAW,MAAM,EAAE,aAAa,EAAE,SAAS;IA+ErH,OAAO,CAAC,OAAO;IAAyB,OAAO,CAAC,GAAG;IA9ElC,cAAc,CAAC,EAAE,gBAAgB,CAAC;IACrD,WAAW,qBAA4B;IACvC,gBAAgB;oBAAiC,MAAM;sBAAgB,YAAY;OAAK;IAElG;;;;;OAKG;IACO,kBAAkB;cAA4B,aAAa;oBAAc,MAAM;OAAM;IAI/F,uEAAuE;IAChE,cAAc,UAAS;IA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AAsB,IAAI,MAAM,EAAE;IAIzC,OAAO,CAAC,qBAAqB;IAS7B;;;;;;OAMG;IACH,2BAA2B,IAAI,IAAI;IAenC,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAYtC;;;OAGG;IACH,kBAAkB,CAAC,KAAK,EAAE;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,YAAY,CAAA;KAAC,GAAG,IAAI;IAQxD,uBAAuB,IAAI,YAAY,GAAG,IAAI;IA8B9D;;OAEG;IACH,IAAoB,gBAAgB,IAAI,OAAO,CAE9C;IAED;;OAEG;IACa,kBAAkB,IAAI,IAAI;IAgB1C;;;;;OAKG;YACW,yBAAyB;IA+CvC;;;;;OAKG;YACW,gBAAgB;IAqB9B,gFAAgF;YAClE,kBAAkB;IAWhC,mFAAmF;IACnF,OAAO,CAAC,kBAAkB;IAU1B;;;OAGG;IACU,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkC7D,gFAAgF;IACnE,cAAc,CAAC,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAsB/E,+EAA+E;IACxE,cAAc,IAAI,IAAI;yCA5gBlB,gCAAgC;2CAAhC,gCAAgC;CAmhB5C"}
1
+ {"version":3,"file":"component-artifact-viewer.component.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/plugins/component-artifact-viewer.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAU,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE/I,OAAO,EAAE,iCAAiC,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACzG,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAA8B,aAA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C,IAAI,CAAC;IAkC7D,gFAAgF;IACnE,cAAc,CAAC,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAsB/E;;;;;;;;;;OAUG;IACU,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IAY5C;;OAEG;YACW,mBAAmB;IA8BjC;;;OAGG;YACW,mBAAmB;yCAxkBtB,gCAAgC;2CAAhC,gCAAgC;CA2lB5C"}
@@ -18,9 +18,10 @@ import * as i2 from "@angular/common";
18
18
  import * as i3 from "@memberjunction/ng-base-forms";
19
19
  import * as i4 from "./component-feedback-panel/component-feedback-panel.component";
20
20
  const _c0 = ["reactComponent"];
21
+ const _c1 = ["interactiveForm"];
21
22
  const _forTrack0 = ($index, $item) => $item.ID;
22
23
  function ComponentArtifactViewerComponent_Conditional_2_Conditional_13_Template(rf, ctx) { if (rf & 1) {
23
- i0.ɵɵelementStart(0, "details", 8)(1, "summary");
24
+ i0.ɵɵelementStart(0, "details", 9)(1, "summary");
24
25
  i0.ɵɵtext(2, "Technical Details");
25
26
  i0.ɵɵelementEnd();
26
27
  i0.ɵɵelementStart(3, "pre");
@@ -32,15 +33,15 @@ function ComponentArtifactViewerComponent_Conditional_2_Conditional_13_Template(
32
33
  i0.ɵɵtextInterpolate(ctx_r0.errorDetails);
33
34
  } }
34
35
  function ComponentArtifactViewerComponent_Conditional_2_Template(rf, ctx) { if (rf & 1) {
35
- i0.ɵɵelementStart(0, "div", 3);
36
- i0.ɵɵelement(1, "i", 6);
36
+ i0.ɵɵelementStart(0, "div", 4);
37
+ i0.ɵɵelement(1, "i", 7);
37
38
  i0.ɵɵelementStart(2, "h3");
38
39
  i0.ɵɵtext(3);
39
40
  i0.ɵɵelementEnd();
40
41
  i0.ɵɵelementStart(4, "p");
41
42
  i0.ɵɵtext(5, "This component could not be loaded. This usually happens when:");
42
43
  i0.ɵɵelementEnd();
43
- i0.ɵɵelementStart(6, "ul", 7)(7, "li");
44
+ i0.ɵɵelementStart(6, "ul", 8)(7, "li");
44
45
  i0.ɵɵtext(8, "The component registry is unavailable or unreachable");
45
46
  i0.ɵɵelementEnd();
46
47
  i0.ɵɵelementStart(9, "li");
@@ -49,7 +50,7 @@ function ComponentArtifactViewerComponent_Conditional_2_Template(rf, ctx) { if (
49
50
  i0.ɵɵelementStart(11, "li");
50
51
  i0.ɵɵtext(12, "There was a network error during component retrieval");
51
52
  i0.ɵɵelementEnd()();
52
- i0.ɵɵconditionalCreate(13, ComponentArtifactViewerComponent_Conditional_2_Conditional_13_Template, 5, 1, "details", 8);
53
+ i0.ɵɵconditionalCreate(13, ComponentArtifactViewerComponent_Conditional_2_Conditional_13_Template, 5, 1, "details", 9);
53
54
  i0.ɵɵelementEnd();
54
55
  } if (rf & 2) {
55
56
  const ctx_r0 = i0.ɵɵnextContext();
@@ -59,12 +60,12 @@ function ComponentArtifactViewerComponent_Conditional_2_Template(rf, ctx) { if (
59
60
  i0.ɵɵconditional(ctx_r0.errorDetails ? 13 : -1);
60
61
  } }
61
62
  function ComponentArtifactViewerComponent_Conditional_3_Conditional_8_Template(rf, ctx) { if (rf & 1) {
62
- i0.ɵɵelementStart(0, "span", 14);
63
+ i0.ɵɵelementStart(0, "span", 15);
63
64
  i0.ɵɵtext(1, "Mock");
64
65
  i0.ɵɵelementEnd();
65
66
  } }
66
67
  function ComponentArtifactViewerComponent_Conditional_3_Conditional_10_Template(rf, ctx) { if (rf & 1) {
67
- i0.ɵɵelementStart(0, "span", 16);
68
+ i0.ɵɵelementStart(0, "span", 17);
68
69
  i0.ɵɵtext(1);
69
70
  i0.ɵɵelementEnd();
70
71
  } if (rf & 2) {
@@ -73,8 +74,8 @@ function ComponentArtifactViewerComponent_Conditional_3_Conditional_10_Template(
73
74
  i0.ɵɵtextInterpolate(ctx_r0.formEntityInfo.DisplayName || ctx_r0.formEntityInfo.Name);
74
75
  } }
75
76
  function ComponentArtifactViewerComponent_Conditional_3_Conditional_11_Template(rf, ctx) { if (rf & 1) {
76
- i0.ɵɵelementStart(0, "span", 17);
77
- i0.ɵɵelement(1, "i", 22);
77
+ i0.ɵɵelementStart(0, "span", 18);
78
+ i0.ɵɵelement(1, "i", 23);
78
79
  i0.ɵɵelementEnd();
79
80
  } if (rf & 2) {
80
81
  const ctx_r0 = i0.ɵɵnextContext(2);
@@ -82,17 +83,17 @@ function ComponentArtifactViewerComponent_Conditional_3_Conditional_11_Template(
82
83
  } }
83
84
  function ComponentArtifactViewerComponent_Conditional_3_Conditional_13_Template(rf, ctx) { if (rf & 1) {
84
85
  const _r3 = i0.ɵɵgetCurrentView();
85
- i0.ɵɵelementStart(0, "button", 23);
86
+ i0.ɵɵelementStart(0, "button", 24);
86
87
  i0.ɵɵlistener("click", function ComponentArtifactViewerComponent_Conditional_3_Conditional_13_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r3); const ctx_r0 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r0.onApplyClicked()); });
87
- i0.ɵɵelement(1, "i", 24);
88
+ i0.ɵɵelement(1, "i", 25);
88
89
  i0.ɵɵtext(2, " Apply to my form ");
89
90
  i0.ɵɵelementEnd();
90
91
  } }
91
92
  function ComponentArtifactViewerComponent_Conditional_3_Conditional_14_Conditional_2_For_2_Template(rf, ctx) { if (rf & 1) {
92
93
  const _r5 = i0.ɵɵgetCurrentView();
93
- i0.ɵɵelementStart(0, "li", 30);
94
+ i0.ɵɵelementStart(0, "li", 31);
94
95
  i0.ɵɵlistener("click", function ComponentArtifactViewerComponent_Conditional_3_Conditional_14_Conditional_2_For_2_Template_li_click_0_listener() { const r_r6 = i0.ɵɵrestoreView(_r5).$implicit; const ctx_r0 = i0.ɵɵnextContext(4); return i0.ɵɵresetView(ctx_r0.onPickerSelect(r_r6)); });
95
- i0.ɵɵelement(1, "i", 31);
96
+ i0.ɵɵelement(1, "i", 32);
96
97
  i0.ɵɵelementStart(2, "span");
97
98
  i0.ɵɵtext(3);
98
99
  i0.ɵɵelementEnd()();
@@ -102,8 +103,8 @@ function ComponentArtifactViewerComponent_Conditional_3_Conditional_14_Condition
102
103
  i0.ɵɵtextInterpolate(r_r6.Label);
103
104
  } }
104
105
  function ComponentArtifactViewerComponent_Conditional_3_Conditional_14_Conditional_2_Template(rf, ctx) { if (rf & 1) {
105
- i0.ɵɵelementStart(0, "ul", 27);
106
- i0.ɵɵrepeaterCreate(1, ComponentArtifactViewerComponent_Conditional_3_Conditional_14_Conditional_2_For_2_Template, 4, 1, "li", 29, _forTrack0);
106
+ i0.ɵɵelementStart(0, "ul", 28);
107
+ i0.ɵɵrepeaterCreate(1, ComponentArtifactViewerComponent_Conditional_3_Conditional_14_Conditional_2_For_2_Template, 4, 1, "li", 30, _forTrack0);
107
108
  i0.ɵɵelementEnd();
108
109
  } if (rf & 2) {
109
110
  const ctx_r0 = i0.ɵɵnextContext(3);
@@ -111,23 +112,23 @@ function ComponentArtifactViewerComponent_Conditional_3_Conditional_14_Condition
111
112
  i0.ɵɵrepeater(ctx_r0.recordSearchResults);
112
113
  } }
113
114
  function ComponentArtifactViewerComponent_Conditional_3_Conditional_14_Conditional_3_Template(rf, ctx) { if (rf & 1) {
114
- i0.ɵɵelementStart(0, "div", 28);
115
+ i0.ɵɵelementStart(0, "div", 29);
115
116
  i0.ɵɵtext(1, "No matches.");
116
117
  i0.ɵɵelementEnd();
117
118
  } }
118
119
  function ComponentArtifactViewerComponent_Conditional_3_Conditional_14_Conditional_4_Template(rf, ctx) { if (rf & 1) {
119
- i0.ɵɵelementStart(0, "div", 28);
120
+ i0.ɵɵelementStart(0, "div", 29);
120
121
  i0.ɵɵtext(1, "Start typing to search.");
121
122
  i0.ɵɵelementEnd();
122
123
  } }
123
124
  function ComponentArtifactViewerComponent_Conditional_3_Conditional_14_Template(rf, ctx) { if (rf & 1) {
124
125
  const _r4 = i0.ɵɵgetCurrentView();
125
- i0.ɵɵelementStart(0, "div", 25);
126
+ i0.ɵɵelementStart(0, "div", 26);
126
127
  i0.ɵɵlistener("click", function ComponentArtifactViewerComponent_Conditional_3_Conditional_14_Template_div_click_0_listener($event) { i0.ɵɵrestoreView(_r4); return i0.ɵɵresetView($event.stopPropagation()); });
127
- i0.ɵɵelementStart(1, "input", 26);
128
+ i0.ɵɵelementStart(1, "input", 27);
128
129
  i0.ɵɵlistener("input", function ComponentArtifactViewerComponent_Conditional_3_Conditional_14_Template_input_input_1_listener($event) { i0.ɵɵrestoreView(_r4); const ctx_r0 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r0.onPickerSearchInput($event.target.value)); });
129
130
  i0.ɵɵelementEnd();
130
- i0.ɵɵconditionalCreate(2, ComponentArtifactViewerComponent_Conditional_3_Conditional_14_Conditional_2_Template, 3, 0, "ul", 27)(3, ComponentArtifactViewerComponent_Conditional_3_Conditional_14_Conditional_3_Template, 2, 0, "div", 28)(4, ComponentArtifactViewerComponent_Conditional_3_Conditional_14_Conditional_4_Template, 2, 0, "div", 28);
131
+ i0.ɵɵconditionalCreate(2, ComponentArtifactViewerComponent_Conditional_3_Conditional_14_Conditional_2_Template, 3, 0, "ul", 28)(3, ComponentArtifactViewerComponent_Conditional_3_Conditional_14_Conditional_3_Template, 2, 0, "div", 29)(4, ComponentArtifactViewerComponent_Conditional_3_Conditional_14_Conditional_4_Template, 2, 0, "div", 29);
131
132
  i0.ɵɵelementEnd();
132
133
  } if (rf & 2) {
133
134
  const ctx_r0 = i0.ɵɵnextContext(2);
@@ -137,8 +138,8 @@ function ComponentArtifactViewerComponent_Conditional_3_Conditional_14_Template(
137
138
  i0.ɵɵconditional(ctx_r0.recordSearchResults.length > 0 ? 2 : ctx_r0.recordSearchTerm.length > 0 ? 3 : 4);
138
139
  } }
139
140
  function ComponentArtifactViewerComponent_Conditional_3_Conditional_15_Template(rf, ctx) { if (rf & 1) {
140
- i0.ɵɵelementStart(0, "div", 21);
141
- i0.ɵɵelement(1, "mj-interactive-form", 32);
141
+ i0.ɵɵelementStart(0, "div", 22);
142
+ i0.ɵɵelement(1, "mj-interactive-form", 33, 0);
142
143
  i0.ɵɵelementEnd();
143
144
  } if (rf & 2) {
144
145
  const ctx_r0 = i0.ɵɵnextContext(2);
@@ -146,8 +147,8 @@ function ComponentArtifactViewerComponent_Conditional_3_Conditional_15_Template(
146
147
  i0.ɵɵproperty("componentSpec", ctx_r0.component)("record", ctx_r0.formRecord);
147
148
  } }
148
149
  function ComponentArtifactViewerComponent_Conditional_3_Conditional_16_Template(rf, ctx) { if (rf & 1) {
149
- i0.ɵɵelementStart(0, "div", 3);
150
- i0.ɵɵelement(1, "i", 33);
150
+ i0.ɵɵelementStart(0, "div", 4);
151
+ i0.ɵɵelement(1, "i", 34);
151
152
  i0.ɵɵelementStart(2, "h3");
152
153
  i0.ɵɵtext(3, "Form preview unavailable");
153
154
  i0.ɵɵelementEnd();
@@ -161,27 +162,27 @@ function ComponentArtifactViewerComponent_Conditional_3_Conditional_16_Template(
161
162
  } }
162
163
  function ComponentArtifactViewerComponent_Conditional_3_Template(rf, ctx) { if (rf & 1) {
163
164
  const _r2 = i0.ɵɵgetCurrentView();
164
- i0.ɵɵelementStart(0, "div", 9);
165
- i0.ɵɵelement(1, "i", 10);
166
- i0.ɵɵelementStart(2, "span", 11);
165
+ i0.ɵɵelementStart(0, "div", 10);
166
+ i0.ɵɵelement(1, "i", 11);
167
+ i0.ɵɵelementStart(2, "span", 12);
167
168
  i0.ɵɵtext(3, "Previewing record:");
168
169
  i0.ɵɵelementEnd();
169
- i0.ɵɵelementStart(4, "button", 12);
170
+ i0.ɵɵelementStart(4, "button", 13);
170
171
  i0.ɵɵlistener("click", function ComponentArtifactViewerComponent_Conditional_3_Template_button_click_4_listener() { i0.ɵɵrestoreView(_r2); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.showRecordPicker = !ctx_r0.showRecordPicker); });
171
- i0.ɵɵelement(5, "i", 13);
172
+ i0.ɵɵelement(5, "i", 14);
172
173
  i0.ɵɵelementStart(6, "strong");
173
174
  i0.ɵɵtext(7);
174
175
  i0.ɵɵelementEnd();
175
- i0.ɵɵconditionalCreate(8, ComponentArtifactViewerComponent_Conditional_3_Conditional_8_Template, 2, 0, "span", 14);
176
- i0.ɵɵelement(9, "i", 15);
176
+ i0.ɵɵconditionalCreate(8, ComponentArtifactViewerComponent_Conditional_3_Conditional_8_Template, 2, 0, "span", 15);
177
+ i0.ɵɵelement(9, "i", 16);
177
178
  i0.ɵɵelementEnd();
178
- i0.ɵɵconditionalCreate(10, ComponentArtifactViewerComponent_Conditional_3_Conditional_10_Template, 2, 1, "span", 16);
179
- i0.ɵɵconditionalCreate(11, ComponentArtifactViewerComponent_Conditional_3_Conditional_11_Template, 2, 1, "span", 17);
180
- i0.ɵɵelement(12, "span", 18);
181
- i0.ɵɵconditionalCreate(13, ComponentArtifactViewerComponent_Conditional_3_Conditional_13_Template, 3, 0, "button", 19);
179
+ i0.ɵɵconditionalCreate(10, ComponentArtifactViewerComponent_Conditional_3_Conditional_10_Template, 2, 1, "span", 17);
180
+ i0.ɵɵconditionalCreate(11, ComponentArtifactViewerComponent_Conditional_3_Conditional_11_Template, 2, 1, "span", 18);
181
+ i0.ɵɵelement(12, "span", 19);
182
+ i0.ɵɵconditionalCreate(13, ComponentArtifactViewerComponent_Conditional_3_Conditional_13_Template, 3, 0, "button", 20);
182
183
  i0.ɵɵelementEnd();
183
- i0.ɵɵconditionalCreate(14, ComponentArtifactViewerComponent_Conditional_3_Conditional_14_Template, 5, 2, "div", 20);
184
- i0.ɵɵconditionalCreate(15, ComponentArtifactViewerComponent_Conditional_3_Conditional_15_Template, 2, 2, "div", 21)(16, ComponentArtifactViewerComponent_Conditional_3_Conditional_16_Template, 6, 1, "div", 3);
184
+ i0.ɵɵconditionalCreate(14, ComponentArtifactViewerComponent_Conditional_3_Conditional_14_Template, 5, 2, "div", 21);
185
+ i0.ɵɵconditionalCreate(15, ComponentArtifactViewerComponent_Conditional_3_Conditional_15_Template, 3, 2, "div", 22)(16, ComponentArtifactViewerComponent_Conditional_3_Conditional_16_Template, 6, 1, "div", 4);
185
186
  } if (rf & 2) {
186
187
  const ctx_r0 = i0.ɵɵnextContext();
187
188
  i0.ɵɵadvance(7);
@@ -201,7 +202,7 @@ function ComponentArtifactViewerComponent_Conditional_3_Template(rf, ctx) { if (
201
202
  } }
202
203
  function ComponentArtifactViewerComponent_Conditional_4_Conditional_7_For_5_Template(rf, ctx) { if (rf & 1) {
203
204
  i0.ɵɵelementStart(0, "li");
204
- i0.ɵɵelement(1, "i", 39);
205
+ i0.ɵɵelement(1, "i", 40);
205
206
  i0.ɵɵtext(2);
206
207
  i0.ɵɵelementEnd();
207
208
  } if (rf & 2) {
@@ -210,7 +211,7 @@ function ComponentArtifactViewerComponent_Conditional_4_Conditional_7_For_5_Temp
210
211
  i0.ɵɵtextInterpolate1(" ", entity_r7);
211
212
  } }
212
213
  function ComponentArtifactViewerComponent_Conditional_4_Conditional_7_Template(rf, ctx) { if (rf & 1) {
213
- i0.ɵɵelementStart(0, "div", 36)(1, "span", 38);
214
+ i0.ɵɵelementStart(0, "div", 37)(1, "span", 39);
214
215
  i0.ɵɵtext(2, "Entities");
215
216
  i0.ɵɵelementEnd();
216
217
  i0.ɵɵelementStart(3, "ul");
@@ -223,7 +224,7 @@ function ComponentArtifactViewerComponent_Conditional_4_Conditional_7_Template(r
223
224
  } }
224
225
  function ComponentArtifactViewerComponent_Conditional_4_Conditional_8_For_5_Template(rf, ctx) { if (rf & 1) {
225
226
  i0.ɵɵelementStart(0, "li");
226
- i0.ɵɵelement(1, "i", 40);
227
+ i0.ɵɵelement(1, "i", 41);
227
228
  i0.ɵɵtext(2);
228
229
  i0.ɵɵelementEnd();
229
230
  } if (rf & 2) {
@@ -232,7 +233,7 @@ function ComponentArtifactViewerComponent_Conditional_4_Conditional_8_For_5_Temp
232
233
  i0.ɵɵtextInterpolate1(" ", query_r8);
233
234
  } }
234
235
  function ComponentArtifactViewerComponent_Conditional_4_Conditional_8_Template(rf, ctx) { if (rf & 1) {
235
- i0.ɵɵelementStart(0, "div", 36)(1, "span", 38);
236
+ i0.ɵɵelementStart(0, "div", 37)(1, "span", 39);
236
237
  i0.ɵɵtext(2, "Queries");
237
238
  i0.ɵɵelementEnd();
238
239
  i0.ɵɵelementStart(3, "ul");
@@ -244,8 +245,8 @@ function ComponentArtifactViewerComponent_Conditional_4_Conditional_8_Template(r
244
245
  i0.ɵɵrepeater(ctx_r0.permissionResult.missingQueries);
245
246
  } }
246
247
  function ComponentArtifactViewerComponent_Conditional_4_Template(rf, ctx) { if (rf & 1) {
247
- i0.ɵɵelementStart(0, "div", 4)(1, "div", 34);
248
- i0.ɵɵelement(2, "i", 35);
248
+ i0.ɵɵelementStart(0, "div", 5)(1, "div", 35);
249
+ i0.ɵɵelement(2, "i", 36);
249
250
  i0.ɵɵelementEnd();
250
251
  i0.ɵɵelementStart(3, "h3");
251
252
  i0.ɵɵtext(4, "Insufficient Permissions");
@@ -253,9 +254,9 @@ function ComponentArtifactViewerComponent_Conditional_4_Template(rf, ctx) { if (
253
254
  i0.ɵɵelementStart(5, "p");
254
255
  i0.ɵɵtext(6, "This component requires data access that you don't currently have:");
255
256
  i0.ɵɵelementEnd();
256
- i0.ɵɵconditionalCreate(7, ComponentArtifactViewerComponent_Conditional_4_Conditional_7_Template, 6, 0, "div", 36);
257
- i0.ɵɵconditionalCreate(8, ComponentArtifactViewerComponent_Conditional_4_Conditional_8_Template, 6, 0, "div", 36);
258
- i0.ɵɵelementStart(9, "p", 37);
257
+ i0.ɵɵconditionalCreate(7, ComponentArtifactViewerComponent_Conditional_4_Conditional_7_Template, 6, 0, "div", 37);
258
+ i0.ɵɵconditionalCreate(8, ComponentArtifactViewerComponent_Conditional_4_Conditional_8_Template, 6, 0, "div", 37);
259
+ i0.ɵɵelementStart(9, "p", 38);
259
260
  i0.ɵɵtext(10, "Contact your administrator to request access.");
260
261
  i0.ɵɵelementEnd()();
261
262
  } if (rf & 2) {
@@ -267,7 +268,7 @@ function ComponentArtifactViewerComponent_Conditional_4_Template(rf, ctx) { if (
267
268
  } }
268
269
  function ComponentArtifactViewerComponent_Conditional_5_Conditional_0_Template(rf, ctx) { if (rf & 1) {
269
270
  const _r9 = i0.ɵɵgetCurrentView();
270
- i0.ɵɵelementStart(0, "mj-react-component", 43, 0);
271
+ i0.ɵɵelementStart(0, "mj-react-component", 44, 1);
271
272
  i0.ɵɵlistener("componentEvent", function ComponentArtifactViewerComponent_Conditional_5_Conditional_0_Template_mj_react_component_componentEvent_0_listener($event) { i0.ɵɵrestoreView(_r9); const ctx_r0 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r0.onComponentEvent($event)); })("openEntityRecord", function ComponentArtifactViewerComponent_Conditional_5_Conditional_0_Template_mj_react_component_openEntityRecord_0_listener($event) { i0.ɵɵrestoreView(_r9); const ctx_r0 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r0.onOpenEntityRecord($event)); })("initialized", function ComponentArtifactViewerComponent_Conditional_5_Conditional_0_Template_mj_react_component_initialized_0_listener() { i0.ɵɵrestoreView(_r9); const ctx_r0 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r0.onReactComponentInitialized()); });
272
273
  i0.ɵɵelementEnd();
273
274
  } if (rf & 2) {
@@ -275,8 +276,8 @@ function ComponentArtifactViewerComponent_Conditional_5_Conditional_0_Template(r
275
276
  i0.ɵɵproperty("component", ctx_r0.component);
276
277
  } }
277
278
  function ComponentArtifactViewerComponent_Conditional_5_Conditional_1_Template(rf, ctx) { if (rf & 1) {
278
- i0.ɵɵelementStart(0, "div", 42);
279
- i0.ɵɵelement(1, "i", 44);
279
+ i0.ɵɵelementStart(0, "div", 43);
280
+ i0.ɵɵelement(1, "i", 45);
280
281
  i0.ɵɵelementStart(2, "h3");
281
282
  i0.ɵɵtext(3, "Component Specification");
282
283
  i0.ɵɵelementEnd();
@@ -288,8 +289,8 @@ function ComponentArtifactViewerComponent_Conditional_5_Conditional_1_Template(r
288
289
  i0.ɵɵelementEnd()();
289
290
  } }
290
291
  function ComponentArtifactViewerComponent_Conditional_5_Conditional_2_Template(rf, ctx) { if (rf & 1) {
291
- i0.ɵɵelementStart(0, "div", 3);
292
- i0.ɵɵelement(1, "i", 33);
292
+ i0.ɵɵelementStart(0, "div", 4);
293
+ i0.ɵɵelement(1, "i", 34);
293
294
  i0.ɵɵelementStart(2, "h3");
294
295
  i0.ɵɵtext(3, "No Component Loaded");
295
296
  i0.ɵɵelementEnd();
@@ -298,14 +299,14 @@ function ComponentArtifactViewerComponent_Conditional_5_Conditional_2_Template(r
298
299
  i0.ɵɵelementEnd()();
299
300
  } }
300
301
  function ComponentArtifactViewerComponent_Conditional_5_Template(rf, ctx) { if (rf & 1) {
301
- i0.ɵɵconditionalCreate(0, ComponentArtifactViewerComponent_Conditional_5_Conditional_0_Template, 2, 1, "mj-react-component", 41)(1, ComponentArtifactViewerComponent_Conditional_5_Conditional_1_Template, 8, 0, "div", 42)(2, ComponentArtifactViewerComponent_Conditional_5_Conditional_2_Template, 6, 0, "div", 3);
302
+ i0.ɵɵconditionalCreate(0, ComponentArtifactViewerComponent_Conditional_5_Conditional_0_Template, 2, 1, "mj-react-component", 42)(1, ComponentArtifactViewerComponent_Conditional_5_Conditional_1_Template, 8, 0, "div", 43)(2, ComponentArtifactViewerComponent_Conditional_5_Conditional_2_Template, 6, 0, "div", 4);
302
303
  } if (rf & 2) {
303
304
  const ctx_r0 = i0.ɵɵnextContext();
304
305
  i0.ɵɵconditional(ctx_r0.component && (ctx_r0.component.code || ctx_r0.component.namespace) ? 0 : ctx_r0.component ? 1 : 2);
305
306
  } }
306
307
  function ComponentArtifactViewerComponent_Conditional_6_Template(rf, ctx) { if (rf & 1) {
307
308
  const _r10 = i0.ɵɵgetCurrentView();
308
- i0.ɵɵelementStart(0, "mj-component-feedback-panel", 45);
309
+ i0.ɵɵelementStart(0, "mj-component-feedback-panel", 46);
309
310
  i0.ɵɵlistener("Closed", function ComponentArtifactViewerComponent_Conditional_6_Template_mj_component_feedback_panel_Closed_0_listener() { i0.ɵɵrestoreView(_r10); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.ShowFeedbackPanel = false); });
310
311
  i0.ɵɵelementEnd();
311
312
  } if (rf & 2) {
@@ -324,6 +325,7 @@ let ComponentArtifactViewerComponent = class ComponentArtifactViewerComponent ex
324
325
  adapter;
325
326
  cdr;
326
327
  reactComponent;
328
+ interactiveForm;
327
329
  tabsChanged = new EventEmitter();
328
330
  openEntityRecord = new EventEmitter();
329
331
  /**
@@ -801,26 +803,96 @@ let ComponentArtifactViewerComponent = class ComponentArtifactViewerComponent ex
801
803
  LogError(`ComponentArtifactViewer: failed to load picked record ${item.ID}: ${err instanceof Error ? err.message : String(err)}`);
802
804
  }
803
805
  }
804
- /** Bubble Apply intent up to the host (Form Builder dashboard / Sage chat). */
805
- onApplyClicked() {
806
- if (!this.component || !this.formEntityInfo)
806
+ /**
807
+ * Bubble Apply intent up to the host (Form Builder dashboard / Sage chat).
808
+ *
809
+ * Resolves the full ComponentSpec (with code) from multiple sources:
810
+ * 1. resolvedComponentSpec — live React bridge or cached copy (best for non-form artifacts)
811
+ * 2. Re-parse artifact version Content — the agent stores the full spec including code
812
+ * 3. DB fallback — fetch from MJ: Components by name
813
+ *
814
+ * Source #2 covers the common form-artifact case where the React component lives inside
815
+ * <mj-interactive-form> and resolvedComponentSpec falls back to the stripped local spec.
816
+ */
817
+ async onApplyClicked() {
818
+ if (!this.formEntityInfo)
819
+ return;
820
+ const spec = await this.resolveSpecWithCode();
821
+ if (!spec)
807
822
  return;
808
823
  this.applyFormRequested.emit({
809
- spec: this.component,
824
+ spec,
810
825
  entityName: this.formEntityInfo.Name,
811
826
  });
812
827
  }
828
+ /**
829
+ * Resolve a ComponentSpec that includes code, trying multiple sources in order.
830
+ */
831
+ async resolveSpecWithCode() {
832
+ // 1. Prefer the live React bridge's resolved spec (non-form path).
833
+ const resolved = this.resolvedComponentSpec;
834
+ if (resolved?.code)
835
+ return resolved;
836
+ // 2. For form artifacts, the React component lives inside <mj-interactive-form>.
837
+ // Reach into it to get the resolved spec from the component registry.
838
+ const formReactSpec = this.interactiveForm?.reactComponent?.resolvedComponentSpec;
839
+ if (formReactSpec?.code)
840
+ return formReactSpec;
841
+ // 3. Re-parse the artifact version's Content directly — the agent stores the
842
+ // full spec including code. This handles the case where loadComponentSpec()
843
+ // parsed early (before Content was fully populated) and the in-memory
844
+ // `this.component` ended up without code.
845
+ if (this.artifactVersion?.Content) {
846
+ const freshParse = SafeJSONParse(this.artifactVersion.Content);
847
+ if (freshParse?.code)
848
+ return freshParse;
849
+ }
850
+ // 4. DB fallback — fetch from MJ: Components by name.
851
+ const name = resolved?.name ?? this.component?.name;
852
+ if (name) {
853
+ const dbSpec = await this.fetchFullSpecByName(name);
854
+ if (dbSpec?.code)
855
+ return dbSpec;
856
+ }
857
+ LogError('ComponentArtifactViewer: could not resolve spec with code for Apply');
858
+ return null;
859
+ }
860
+ /**
861
+ * Fetch the full ComponentSpec (including code) from the MJ: Components table
862
+ * by component name. Returns null if not found or on error.
863
+ */
864
+ async fetchFullSpecByName(name) {
865
+ try {
866
+ const rv = new RunView();
867
+ const result = await rv.RunView({
868
+ EntityName: 'MJ: Components',
869
+ ExtraFilter: `Name='${name.replace(/'/g, "''")}'`,
870
+ Fields: ['Specification'],
871
+ OrderBy: 'VersionSequence DESC',
872
+ MaxRows: 1,
873
+ ResultType: 'simple',
874
+ });
875
+ if (result.Success && result.Results?.length > 0 && result.Results[0].Specification) {
876
+ return JSON.parse(result.Results[0].Specification);
877
+ }
878
+ }
879
+ catch (err) {
880
+ LogError(`ComponentArtifactViewer: failed to fetch full spec for '${name}': ${err instanceof Error ? err.message : String(err)}`);
881
+ }
882
+ return null;
883
+ }
813
884
  static ɵfac = function ComponentArtifactViewerComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ComponentArtifactViewerComponent)(i0.ɵɵdirectiveInject(i1.AngularAdapterService), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
814
885
  static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ComponentArtifactViewerComponent, selectors: [["mj-component-artifact-viewer"]], viewQuery: function ComponentArtifactViewerComponent_Query(rf, ctx) { if (rf & 1) {
815
- i0.ɵɵviewQuery(_c0, 5);
886
+ i0.ɵɵviewQuery(_c0, 5)(_c1, 5);
816
887
  } if (rf & 2) {
817
888
  let _t;
818
889
  i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.reactComponent = _t.first);
819
- } }, outputs: { tabsChanged: "tabsChanged", openEntityRecord: "openEntityRecord", applyFormRequested: "applyFormRequested" }, standalone: false, features: [i0.ɵɵInheritDefinitionFeature, i0.ɵɵNgOnChangesFeature], decls: 7, vars: 3, consts: [["reactComponent", ""], [1, "component-artifact-viewer", 3, "ngClass"], [1, "component-preview"], [1, "error-state"], [1, "permission-warning"], [3, "ComponentSpec", "ReactContainerElement"], [1, "fa-solid", "fa-exclamation-triangle"], [2, "text-align", "left", "max-width", "500px", "color", "var(--mj-text-muted)", "line-height", "1.6"], [2, "margin-top", "20px"], [1, "form-artifact-toolstrip"], ["aria-hidden", "true", 1, "fa-solid", "fa-circle-info"], [1, "form-artifact-toolstrip-label"], ["type", "button", 1, "form-artifact-picker-chip", 3, "click"], [1, "fa-solid", "fa-magnifying-glass"], [1, "form-artifact-picker-chip-badge"], [1, "fa-solid", "fa-chevron-down"], [1, "form-artifact-toolstrip-entity"], [1, "form-artifact-toolstrip-warning", 3, "title"], [2, "flex", "1"], ["type", "button", 1, "form-artifact-apply-btn"], [1, "form-artifact-picker-panel"], [1, "form-artifact-form-host"], [1, "fa-solid", "fa-triangle-exclamation"], ["type", "button", 1, "form-artifact-apply-btn", 3, "click"], [1, "fa-solid", "fa-circle-check"], [1, "form-artifact-picker-panel", 3, "click"], ["type", "text", "placeholder", "Search records by name\u2026", 1, "form-artifact-picker-search", 3, "input", "value"], [1, "form-artifact-picker-results"], [1, "form-artifact-picker-empty"], [1, "form-artifact-picker-row"], [1, "form-artifact-picker-row", 3, "click"], [1, "fa-solid", "fa-circle-dot"], [3, "componentSpec", "record"], [1, "fa-solid", "fa-exclamation-circle"], [1, "permission-warning-icon"], [1, "fa-solid", "fa-shield-halved"], [1, "permission-warning-section"], [1, "permission-warning-hint"], [1, "permission-warning-section-label"], [1, "fa-solid", "fa-table"], [1, "fa-solid", "fa-database"], [3, "component"], [1, "no-code-state"], [3, "componentEvent", "openEntityRecord", "initialized", "component"], [1, "fa-solid", "fa-file-lines"], [3, "Closed", "ComponentSpec", "ReactContainerElement"]], template: function ComponentArtifactViewerComponent_Template(rf, ctx) { if (rf & 1) {
820
- i0.ɵɵelementStart(0, "div", 1)(1, "div", 2);
821
- i0.ɵɵconditionalCreate(2, ComponentArtifactViewerComponent_Conditional_2_Template, 14, 2, "div", 3)(3, ComponentArtifactViewerComponent_Conditional_3_Template, 17, 7)(4, ComponentArtifactViewerComponent_Conditional_4_Template, 11, 2, "div", 4)(5, ComponentArtifactViewerComponent_Conditional_5_Template, 3, 1);
890
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.interactiveForm = _t.first);
891
+ } }, outputs: { tabsChanged: "tabsChanged", openEntityRecord: "openEntityRecord", applyFormRequested: "applyFormRequested" }, standalone: false, features: [i0.ɵɵInheritDefinitionFeature, i0.ɵɵNgOnChangesFeature], decls: 7, vars: 3, consts: [["interactiveForm", ""], ["reactComponent", ""], [1, "component-artifact-viewer", 3, "ngClass"], [1, "component-preview"], [1, "error-state"], [1, "permission-warning"], [3, "ComponentSpec", "ReactContainerElement"], [1, "fa-solid", "fa-exclamation-triangle"], [2, "text-align", "left", "max-width", "500px", "color", "var(--mj-text-muted)", "line-height", "1.6"], [2, "margin-top", "20px"], [1, "form-artifact-toolstrip"], ["aria-hidden", "true", 1, "fa-solid", "fa-circle-info"], [1, "form-artifact-toolstrip-label"], ["type", "button", 1, "form-artifact-picker-chip", 3, "click"], [1, "fa-solid", "fa-magnifying-glass"], [1, "form-artifact-picker-chip-badge"], [1, "fa-solid", "fa-chevron-down"], [1, "form-artifact-toolstrip-entity"], [1, "form-artifact-toolstrip-warning", 3, "title"], [2, "flex", "1"], ["type", "button", 1, "form-artifact-apply-btn"], [1, "form-artifact-picker-panel"], [1, "form-artifact-form-host"], [1, "fa-solid", "fa-triangle-exclamation"], ["type", "button", 1, "form-artifact-apply-btn", 3, "click"], [1, "fa-solid", "fa-circle-check"], [1, "form-artifact-picker-panel", 3, "click"], ["type", "text", "placeholder", "Search records by name\u2026", 1, "form-artifact-picker-search", 3, "input", "value"], [1, "form-artifact-picker-results"], [1, "form-artifact-picker-empty"], [1, "form-artifact-picker-row"], [1, "form-artifact-picker-row", 3, "click"], [1, "fa-solid", "fa-circle-dot"], [3, "componentSpec", "record"], [1, "fa-solid", "fa-exclamation-circle"], [1, "permission-warning-icon"], [1, "fa-solid", "fa-shield-halved"], [1, "permission-warning-section"], [1, "permission-warning-hint"], [1, "permission-warning-section-label"], [1, "fa-solid", "fa-table"], [1, "fa-solid", "fa-database"], [3, "component"], [1, "no-code-state"], [3, "componentEvent", "openEntityRecord", "initialized", "component"], [1, "fa-solid", "fa-file-lines"], [3, "Closed", "ComponentSpec", "ReactContainerElement"]], template: function ComponentArtifactViewerComponent_Template(rf, ctx) { if (rf & 1) {
892
+ i0.ɵɵelementStart(0, "div", 2)(1, "div", 3);
893
+ i0.ɵɵconditionalCreate(2, ComponentArtifactViewerComponent_Conditional_2_Template, 14, 2, "div", 4)(3, ComponentArtifactViewerComponent_Conditional_3_Template, 17, 7)(4, ComponentArtifactViewerComponent_Conditional_4_Template, 11, 2, "div", 5)(5, ComponentArtifactViewerComponent_Conditional_5_Template, 3, 1);
822
894
  i0.ɵɵelementEnd();
823
- i0.ɵɵconditionalCreate(6, ComponentArtifactViewerComponent_Conditional_6_Template, 1, 2, "mj-component-feedback-panel", 5);
895
+ i0.ɵɵconditionalCreate(6, ComponentArtifactViewerComponent_Conditional_6_Template, 1, 2, "mj-component-feedback-panel", 6);
824
896
  i0.ɵɵelementEnd();
825
897
  } if (rf & 2) {
826
898
  i0.ɵɵproperty("ngClass", ctx.cssClass);
@@ -828,7 +900,7 @@ let ComponentArtifactViewerComponent = class ComponentArtifactViewerComponent ex
828
900
  i0.ɵɵconditional(ctx.hasError ? 2 : ctx.isFormArtifact ? 3 : ctx.isPermissionBlocked ? 4 : 5);
829
901
  i0.ɵɵadvance(4);
830
902
  i0.ɵɵconditional(ctx.ShowFeedbackPanel && ctx.resolvedComponentSpec ? 6 : -1);
831
- } }, dependencies: [i2.NgClass, i1.MJReactComponent, i3.InteractiveFormComponent, i4.ComponentFeedbackPanelComponent], styles: [".component-artifact-viewer[_ngcontent-%COMP%] {\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n background: var(--mj-bg-surface);\n}\n\n.component-preview[_ngcontent-%COMP%] {\n flex: 1;\n padding: 15px;\n overflow: auto;\n display: flex;\n flex-direction: column;\n min-height: 0;\n}\n\n\n\n.component-preview[_ngcontent-%COMP%] mj-react-component[_ngcontent-%COMP%] {\n flex: 1;\n min-height: 0;\n display: flex;\n flex-direction: column;\n}\n\n.error-state[_ngcontent-%COMP%] {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 40px;\n text-align: center;\n color: var(--mj-status-error);\n flex: 1;\n min-height: 300px;\n}\n.error-state[_ngcontent-%COMP%] i[_ngcontent-%COMP%] {\n font-size: 48px;\n margin-bottom: 16px;\n}\n.error-state[_ngcontent-%COMP%] h3[_ngcontent-%COMP%] {\n margin: 0 0 8px 0;\n font-size: 20px;\n}\n.error-state[_ngcontent-%COMP%] p[_ngcontent-%COMP%] {\n margin: 0 0 12px 0;\n color: var(--mj-text-muted);\n}\n.error-state[_ngcontent-%COMP%] details[_ngcontent-%COMP%] {\n margin-top: 16px;\n text-align: left;\n max-width: 600px;\n}\n.error-state[_ngcontent-%COMP%] details[_ngcontent-%COMP%] summary[_ngcontent-%COMP%] {\n cursor: pointer;\n color: var(--mj-text-secondary);\n font-weight: 500;\n margin-bottom: 8px;\n}\n.error-state[_ngcontent-%COMP%] details[_ngcontent-%COMP%] summary[_ngcontent-%COMP%]:hover {\n color: var(--mj-text-primary);\n}\n.error-state[_ngcontent-%COMP%] details[_ngcontent-%COMP%] pre[_ngcontent-%COMP%] {\n background: var(--mj-bg-surface-sunken);\n padding: 12px;\n border-radius: 4px;\n overflow-x: auto;\n font-size: 12px;\n color: var(--mj-text-secondary);\n margin: 0;\n}\n\n\n\n.no-code-state[_ngcontent-%COMP%] {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 40px;\n text-align: center;\n color: var(--mj-text-muted);\n flex: 1;\n}\n.no-code-state[_ngcontent-%COMP%] i[_ngcontent-%COMP%] {\n font-size: 48px;\n margin-bottom: 16px;\n color: var(--mj-brand-primary);\n}\n.no-code-state[_ngcontent-%COMP%] h3[_ngcontent-%COMP%] {\n margin: 0 0 8px 0;\n font-size: 20px;\n color: var(--mj-text-secondary);\n}\n.no-code-state[_ngcontent-%COMP%] p[_ngcontent-%COMP%] {\n margin: 0 0 8px 0;\n color: var(--mj-text-muted);\n}\n\n\n\n\n\n\n\n\n\n\n.form-artifact-toolstrip[_ngcontent-%COMP%] {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 8px 14px;\n background: var(--mj-bg-surface-card);\n border-bottom: 1px solid var(--mj-border-default);\n font-size: 12px;\n color: var(--mj-text-secondary);\n}\n.form-artifact-toolstrip-label[_ngcontent-%COMP%] {\n font-weight: 600;\n}\n.form-artifact-toolstrip-entity[_ngcontent-%COMP%] {\n margin-left: 4px;\n padding: 2px 8px;\n background: color-mix(in srgb, var(--mj-brand-primary) 10%, var(--mj-bg-surface));\n color: var(--mj-brand-primary);\n border: 1px solid color-mix(in srgb, var(--mj-brand-primary) 30%, var(--mj-bg-surface));\n border-radius: 999px;\n font-size: 11px;\n font-weight: 600;\n}\n.form-artifact-toolstrip-warning[_ngcontent-%COMP%] {\n color: var(--mj-status-warning-text);\n}\n\n.form-artifact-picker-chip[_ngcontent-%COMP%] {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n background: var(--mj-bg-surface);\n border: 1px solid var(--mj-border-default);\n border-radius: var(--mj-radius-md, 8px);\n padding: 4px 10px;\n font-size: 12px;\n color: var(--mj-text-primary);\n cursor: pointer;\n}\n.form-artifact-picker-chip[_ngcontent-%COMP%]:hover, \n.form-artifact-picker-chip[_ngcontent-%COMP%]:focus {\n border-color: var(--mj-border-focus);\n outline: none;\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--mj-brand-primary) 15%, transparent);\n}\n.form-artifact-picker-chip[_ngcontent-%COMP%] strong[_ngcontent-%COMP%] {\n color: var(--mj-text-primary);\n font-weight: 600;\n}\n.form-artifact-picker-chip-badge[_ngcontent-%COMP%] {\n background: var(--mj-status-warning-bg);\n color: var(--mj-status-warning-text);\n border: 1px solid var(--mj-status-warning-border);\n font-size: 10px;\n font-weight: 700;\n padding: 1px 6px;\n border-radius: 999px;\n}\n\n.form-artifact-apply-btn[_ngcontent-%COMP%] {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n background: var(--mj-brand-primary);\n color: var(--mj-text-inverse, #ffffff);\n border: 1px solid var(--mj-brand-primary);\n border-radius: var(--mj-radius-md, 8px);\n padding: 5px 12px;\n font-size: 12px;\n font-weight: 600;\n cursor: pointer;\n}\n.form-artifact-apply-btn[_ngcontent-%COMP%]:hover {\n background: var(--mj-brand-primary-hover, var(--mj-brand-primary));\n}\n\n.form-artifact-picker-panel[_ngcontent-%COMP%] {\n background: var(--mj-bg-surface);\n border-bottom: 1px solid var(--mj-border-default);\n padding: 10px 14px;\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n.form-artifact-picker-search[_ngcontent-%COMP%] {\n width: 100%;\n padding: 7px 10px;\n border: 1px solid var(--mj-border-default);\n border-radius: var(--mj-radius-md, 8px);\n background: var(--mj-bg-surface);\n font-size: 13px;\n color: var(--mj-text-primary);\n}\n.form-artifact-picker-search[_ngcontent-%COMP%]:focus {\n outline: none;\n border-color: var(--mj-border-focus);\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--mj-brand-primary) 15%, transparent);\n}\n.form-artifact-picker-results[_ngcontent-%COMP%] {\n list-style: none;\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n.form-artifact-picker-row[_ngcontent-%COMP%] {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 6px 8px;\n border-radius: 6px;\n cursor: pointer;\n font-size: 13px;\n}\n.form-artifact-picker-row[_ngcontent-%COMP%]:hover {\n background: var(--mj-bg-surface-hover);\n}\n.form-artifact-picker-row[_ngcontent-%COMP%] i[_ngcontent-%COMP%] {\n color: var(--mj-text-muted);\n font-size: 10px;\n}\n.form-artifact-picker-empty[_ngcontent-%COMP%] {\n color: var(--mj-text-muted);\n font-size: 12px;\n font-style: italic;\n}\n\n.form-artifact-form-host[_ngcontent-%COMP%] {\n flex: 1;\n overflow: auto;\n background: var(--mj-bg-page);\n}\n\n\n\n\n\n\n\n\n.permission-warning[_ngcontent-%COMP%] {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 40px;\n text-align: center;\n flex: 1;\n min-height: 300px;\n}\n.permission-warning-icon[_ngcontent-%COMP%] {\n font-size: 48px;\n margin-bottom: 16px;\n color: var(--mj-status-warning-text, #b45309);\n}\n.permission-warning[_ngcontent-%COMP%] h3[_ngcontent-%COMP%] {\n margin: 0 0 8px 0;\n font-size: 20px;\n color: var(--mj-text-primary);\n}\n.permission-warning[_ngcontent-%COMP%] > p[_ngcontent-%COMP%] {\n margin: 0 0 16px 0;\n color: var(--mj-text-muted);\n}\n.permission-warning-section[_ngcontent-%COMP%] {\n text-align: left;\n max-width: 400px;\n width: 100%;\n margin-bottom: 12px;\n}\n.permission-warning-section-label[_ngcontent-%COMP%] {\n display: block;\n font-size: 11px;\n font-weight: 700;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n color: var(--mj-text-muted);\n margin-bottom: 4px;\n}\n.permission-warning-section[_ngcontent-%COMP%] ul[_ngcontent-%COMP%] {\n list-style: none;\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n.permission-warning-section[_ngcontent-%COMP%] li[_ngcontent-%COMP%] {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 6px 10px;\n font-size: 13px;\n color: var(--mj-text-primary);\n background: var(--mj-bg-surface-sunken, var(--mj-bg-surface));\n border-radius: 6px;\n}\n.permission-warning-section[_ngcontent-%COMP%] li[_ngcontent-%COMP%] i[_ngcontent-%COMP%] {\n color: var(--mj-status-warning-text, #b45309);\n font-size: 12px;\n}\n.permission-warning-hint[_ngcontent-%COMP%] {\n margin-top: 8px;\n font-size: 12px;\n color: var(--mj-text-muted);\n}"] });
903
+ } }, dependencies: [i2.NgClass, i1.MJReactComponent, i3.InteractiveFormComponent, i4.ComponentFeedbackPanelComponent], styles: [".component-artifact-viewer[_ngcontent-%COMP%] {\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n background: var(--mj-bg-surface);\n}\n\n.component-preview[_ngcontent-%COMP%] {\n flex: 1;\n padding: 15px;\n overflow: auto;\n display: flex;\n flex-direction: column;\n min-height: 0;\n min-width: 0;\n width: 100%;\n box-sizing: border-box;\n}\n\n\n\n.component-preview[_ngcontent-%COMP%] mj-react-component[_ngcontent-%COMP%] {\n flex: 1;\n min-height: 0;\n display: flex;\n flex-direction: column;\n}\n\n.error-state[_ngcontent-%COMP%] {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 40px;\n text-align: center;\n color: var(--mj-status-error);\n flex: 1;\n min-height: 300px;\n}\n.error-state[_ngcontent-%COMP%] i[_ngcontent-%COMP%] {\n font-size: 48px;\n margin-bottom: 16px;\n}\n.error-state[_ngcontent-%COMP%] h3[_ngcontent-%COMP%] {\n margin: 0 0 8px 0;\n font-size: 20px;\n}\n.error-state[_ngcontent-%COMP%] p[_ngcontent-%COMP%] {\n margin: 0 0 12px 0;\n color: var(--mj-text-muted);\n}\n.error-state[_ngcontent-%COMP%] details[_ngcontent-%COMP%] {\n margin-top: 16px;\n text-align: left;\n max-width: 600px;\n}\n.error-state[_ngcontent-%COMP%] details[_ngcontent-%COMP%] summary[_ngcontent-%COMP%] {\n cursor: pointer;\n color: var(--mj-text-secondary);\n font-weight: 500;\n margin-bottom: 8px;\n}\n.error-state[_ngcontent-%COMP%] details[_ngcontent-%COMP%] summary[_ngcontent-%COMP%]:hover {\n color: var(--mj-text-primary);\n}\n.error-state[_ngcontent-%COMP%] details[_ngcontent-%COMP%] pre[_ngcontent-%COMP%] {\n background: var(--mj-bg-surface-sunken);\n padding: 12px;\n border-radius: 4px;\n overflow-x: auto;\n font-size: 12px;\n color: var(--mj-text-secondary);\n margin: 0;\n}\n\n\n\n.no-code-state[_ngcontent-%COMP%] {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 40px;\n text-align: center;\n color: var(--mj-text-muted);\n flex: 1;\n}\n.no-code-state[_ngcontent-%COMP%] i[_ngcontent-%COMP%] {\n font-size: 48px;\n margin-bottom: 16px;\n color: var(--mj-brand-primary);\n}\n.no-code-state[_ngcontent-%COMP%] h3[_ngcontent-%COMP%] {\n margin: 0 0 8px 0;\n font-size: 20px;\n color: var(--mj-text-secondary);\n}\n.no-code-state[_ngcontent-%COMP%] p[_ngcontent-%COMP%] {\n margin: 0 0 8px 0;\n color: var(--mj-text-muted);\n}\n\n\n\n\n\n\n\n\n\n\n.form-artifact-toolstrip[_ngcontent-%COMP%] {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 8px 14px;\n background: var(--mj-bg-surface-card);\n border-bottom: 1px solid var(--mj-border-default);\n font-size: 12px;\n color: var(--mj-text-secondary);\n}\n.form-artifact-toolstrip-label[_ngcontent-%COMP%] {\n font-weight: 600;\n}\n.form-artifact-toolstrip-entity[_ngcontent-%COMP%] {\n margin-left: 4px;\n padding: 2px 8px;\n background: color-mix(in srgb, var(--mj-brand-primary) 10%, var(--mj-bg-surface));\n color: var(--mj-brand-primary);\n border: 1px solid color-mix(in srgb, var(--mj-brand-primary) 30%, var(--mj-bg-surface));\n border-radius: 999px;\n font-size: 11px;\n font-weight: 600;\n}\n.form-artifact-toolstrip-warning[_ngcontent-%COMP%] {\n color: var(--mj-status-warning-text);\n}\n\n.form-artifact-picker-chip[_ngcontent-%COMP%] {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n background: var(--mj-bg-surface);\n border: 1px solid var(--mj-border-default);\n border-radius: var(--mj-radius-md, 8px);\n padding: 4px 10px;\n font-size: 12px;\n color: var(--mj-text-primary);\n cursor: pointer;\n}\n.form-artifact-picker-chip[_ngcontent-%COMP%]:hover, \n.form-artifact-picker-chip[_ngcontent-%COMP%]:focus {\n border-color: var(--mj-border-focus);\n outline: none;\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--mj-brand-primary) 15%, transparent);\n}\n.form-artifact-picker-chip[_ngcontent-%COMP%] strong[_ngcontent-%COMP%] {\n color: var(--mj-text-primary);\n font-weight: 600;\n}\n.form-artifact-picker-chip-badge[_ngcontent-%COMP%] {\n background: var(--mj-status-warning-bg);\n color: var(--mj-status-warning-text);\n border: 1px solid var(--mj-status-warning-border);\n font-size: 10px;\n font-weight: 700;\n padding: 1px 6px;\n border-radius: 999px;\n}\n\n.form-artifact-apply-btn[_ngcontent-%COMP%] {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n background: var(--mj-brand-primary);\n color: var(--mj-text-inverse, #ffffff);\n border: 1px solid var(--mj-brand-primary);\n border-radius: var(--mj-radius-md, 8px);\n padding: 5px 12px;\n font-size: 12px;\n font-weight: 600;\n cursor: pointer;\n}\n.form-artifact-apply-btn[_ngcontent-%COMP%]:hover {\n background: var(--mj-brand-primary-hover, var(--mj-brand-primary));\n}\n\n.form-artifact-picker-panel[_ngcontent-%COMP%] {\n background: var(--mj-bg-surface);\n border-bottom: 1px solid var(--mj-border-default);\n padding: 10px 14px;\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n.form-artifact-picker-search[_ngcontent-%COMP%] {\n width: 100%;\n padding: 7px 10px;\n border: 1px solid var(--mj-border-default);\n border-radius: var(--mj-radius-md, 8px);\n background: var(--mj-bg-surface);\n font-size: 13px;\n color: var(--mj-text-primary);\n}\n.form-artifact-picker-search[_ngcontent-%COMP%]:focus {\n outline: none;\n border-color: var(--mj-border-focus);\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--mj-brand-primary) 15%, transparent);\n}\n.form-artifact-picker-results[_ngcontent-%COMP%] {\n list-style: none;\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n.form-artifact-picker-row[_ngcontent-%COMP%] {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 6px 8px;\n border-radius: 6px;\n cursor: pointer;\n font-size: 13px;\n}\n.form-artifact-picker-row[_ngcontent-%COMP%]:hover {\n background: var(--mj-bg-surface-hover);\n}\n.form-artifact-picker-row[_ngcontent-%COMP%] i[_ngcontent-%COMP%] {\n color: var(--mj-text-muted);\n font-size: 10px;\n}\n.form-artifact-picker-empty[_ngcontent-%COMP%] {\n color: var(--mj-text-muted);\n font-size: 12px;\n font-style: italic;\n}\n\n.form-artifact-form-host[_ngcontent-%COMP%] {\n flex: 1;\n overflow: auto;\n background: var(--mj-bg-page);\n min-width: 0;\n width: 100%;\n box-sizing: border-box;\n}\n\n\n\n\n\n\n\n\n.permission-warning[_ngcontent-%COMP%] {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 40px;\n text-align: center;\n flex: 1;\n min-height: 300px;\n}\n.permission-warning-icon[_ngcontent-%COMP%] {\n font-size: 48px;\n margin-bottom: 16px;\n color: var(--mj-status-warning-text, #b45309);\n}\n.permission-warning[_ngcontent-%COMP%] h3[_ngcontent-%COMP%] {\n margin: 0 0 8px 0;\n font-size: 20px;\n color: var(--mj-text-primary);\n}\n.permission-warning[_ngcontent-%COMP%] > p[_ngcontent-%COMP%] {\n margin: 0 0 16px 0;\n color: var(--mj-text-muted);\n}\n.permission-warning-section[_ngcontent-%COMP%] {\n text-align: left;\n max-width: 400px;\n width: 100%;\n margin-bottom: 12px;\n}\n.permission-warning-section-label[_ngcontent-%COMP%] {\n display: block;\n font-size: 11px;\n font-weight: 700;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n color: var(--mj-text-muted);\n margin-bottom: 4px;\n}\n.permission-warning-section[_ngcontent-%COMP%] ul[_ngcontent-%COMP%] {\n list-style: none;\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n.permission-warning-section[_ngcontent-%COMP%] li[_ngcontent-%COMP%] {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 6px 10px;\n font-size: 13px;\n color: var(--mj-text-primary);\n background: var(--mj-bg-surface-sunken, var(--mj-bg-surface));\n border-radius: 6px;\n}\n.permission-warning-section[_ngcontent-%COMP%] li[_ngcontent-%COMP%] i[_ngcontent-%COMP%] {\n color: var(--mj-status-warning-text, #b45309);\n font-size: 12px;\n}\n.permission-warning-hint[_ngcontent-%COMP%] {\n margin-top: 8px;\n font-size: 12px;\n color: var(--mj-text-muted);\n}"] });
832
904
  };
833
905
  ComponentArtifactViewerComponent = __decorate([
834
906
  RegisterClass(BaseArtifactViewerPluginComponent, 'ComponentArtifactViewerPlugin')
@@ -836,10 +908,13 @@ ComponentArtifactViewerComponent = __decorate([
836
908
  export { ComponentArtifactViewerComponent };
837
909
  (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ComponentArtifactViewerComponent, [{
838
910
  type: Component,
839
- args: [{ standalone: false, selector: 'mj-component-artifact-viewer', template: "<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 <!-- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\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 \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550 -->\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\u2026\"\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 \u2014 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", styles: [".component-artifact-viewer {\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n background: var(--mj-bg-surface);\n}\n\n.component-preview {\n flex: 1;\n padding: 15px;\n overflow: auto;\n display: flex;\n flex-direction: column;\n min-height: 0;\n}\n\n/* Ensure React component takes full height */\n.component-preview mj-react-component {\n flex: 1;\n min-height: 0;\n display: flex;\n flex-direction: column;\n}\n\n.error-state {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 40px;\n text-align: center;\n color: var(--mj-status-error);\n flex: 1;\n min-height: 300px;\n}\n.error-state i {\n font-size: 48px;\n margin-bottom: 16px;\n}\n.error-state h3 {\n margin: 0 0 8px 0;\n font-size: 20px;\n}\n.error-state p {\n margin: 0 0 12px 0;\n color: var(--mj-text-muted);\n}\n.error-state details {\n margin-top: 16px;\n text-align: left;\n max-width: 600px;\n}\n.error-state details summary {\n cursor: pointer;\n color: var(--mj-text-secondary);\n font-weight: 500;\n margin-bottom: 8px;\n}\n.error-state details summary:hover {\n color: var(--mj-text-primary);\n}\n.error-state details pre {\n background: var(--mj-bg-surface-sunken);\n padding: 12px;\n border-radius: 4px;\n overflow-x: auto;\n font-size: 12px;\n color: var(--mj-text-secondary);\n margin: 0;\n}\n\n/* State for component spec without executable code */\n.no-code-state {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 40px;\n text-align: center;\n color: var(--mj-text-muted);\n flex: 1;\n}\n.no-code-state i {\n font-size: 48px;\n margin-bottom: 16px;\n color: var(--mj-brand-primary);\n}\n.no-code-state h3 {\n margin: 0 0 8px 0;\n font-size: 20px;\n color: var(--mj-text-secondary);\n}\n.no-code-state p {\n margin: 0 0 8px 0;\n color: var(--mj-text-muted);\n}\n\n\n/* ====================================================================\n FORM-AWARE BRANCH (componentRole === 'form')\n Top strip: record-picker chip + Apply button.\n Below: dropdown picker panel.\n Below: <mj-interactive-form> bound to the picked record.\n ==================================================================== */\n\n.form-artifact-toolstrip {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 8px 14px;\n background: var(--mj-bg-surface-card);\n border-bottom: 1px solid var(--mj-border-default);\n font-size: 12px;\n color: var(--mj-text-secondary);\n}\n.form-artifact-toolstrip-label {\n font-weight: 600;\n}\n.form-artifact-toolstrip-entity {\n margin-left: 4px;\n padding: 2px 8px;\n background: color-mix(in srgb, var(--mj-brand-primary) 10%, var(--mj-bg-surface));\n color: var(--mj-brand-primary);\n border: 1px solid color-mix(in srgb, var(--mj-brand-primary) 30%, var(--mj-bg-surface));\n border-radius: 999px;\n font-size: 11px;\n font-weight: 600;\n}\n.form-artifact-toolstrip-warning {\n color: var(--mj-status-warning-text);\n}\n\n.form-artifact-picker-chip {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n background: var(--mj-bg-surface);\n border: 1px solid var(--mj-border-default);\n border-radius: var(--mj-radius-md, 8px);\n padding: 4px 10px;\n font-size: 12px;\n color: var(--mj-text-primary);\n cursor: pointer;\n}\n.form-artifact-picker-chip:hover,\n.form-artifact-picker-chip:focus {\n border-color: var(--mj-border-focus);\n outline: none;\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--mj-brand-primary) 15%, transparent);\n}\n.form-artifact-picker-chip strong {\n color: var(--mj-text-primary);\n font-weight: 600;\n}\n.form-artifact-picker-chip-badge {\n background: var(--mj-status-warning-bg);\n color: var(--mj-status-warning-text);\n border: 1px solid var(--mj-status-warning-border);\n font-size: 10px;\n font-weight: 700;\n padding: 1px 6px;\n border-radius: 999px;\n}\n\n.form-artifact-apply-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n background: var(--mj-brand-primary);\n color: var(--mj-text-inverse, #ffffff);\n border: 1px solid var(--mj-brand-primary);\n border-radius: var(--mj-radius-md, 8px);\n padding: 5px 12px;\n font-size: 12px;\n font-weight: 600;\n cursor: pointer;\n}\n.form-artifact-apply-btn:hover {\n background: var(--mj-brand-primary-hover, var(--mj-brand-primary));\n}\n\n.form-artifact-picker-panel {\n background: var(--mj-bg-surface);\n border-bottom: 1px solid var(--mj-border-default);\n padding: 10px 14px;\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n.form-artifact-picker-search {\n width: 100%;\n padding: 7px 10px;\n border: 1px solid var(--mj-border-default);\n border-radius: var(--mj-radius-md, 8px);\n background: var(--mj-bg-surface);\n font-size: 13px;\n color: var(--mj-text-primary);\n}\n.form-artifact-picker-search:focus {\n outline: none;\n border-color: var(--mj-border-focus);\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--mj-brand-primary) 15%, transparent);\n}\n.form-artifact-picker-results {\n list-style: none;\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n.form-artifact-picker-row {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 6px 8px;\n border-radius: 6px;\n cursor: pointer;\n font-size: 13px;\n}\n.form-artifact-picker-row:hover {\n background: var(--mj-bg-surface-hover);\n}\n.form-artifact-picker-row i {\n color: var(--mj-text-muted);\n font-size: 10px;\n}\n.form-artifact-picker-empty {\n color: var(--mj-text-muted);\n font-size: 12px;\n font-style: italic;\n}\n\n.form-artifact-form-host {\n flex: 1;\n overflow: auto;\n background: var(--mj-bg-page);\n}\n\n/* ====================================================================\n PERMISSION WARNING\n Shown before rendering when the user lacks read access to one or\n more entities/queries required by the component.\n ==================================================================== */\n\n.permission-warning {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 40px;\n text-align: center;\n flex: 1;\n min-height: 300px;\n}\n.permission-warning-icon {\n font-size: 48px;\n margin-bottom: 16px;\n color: var(--mj-status-warning-text, #b45309);\n}\n.permission-warning h3 {\n margin: 0 0 8px 0;\n font-size: 20px;\n color: var(--mj-text-primary);\n}\n.permission-warning > p {\n margin: 0 0 16px 0;\n color: var(--mj-text-muted);\n}\n.permission-warning-section {\n text-align: left;\n max-width: 400px;\n width: 100%;\n margin-bottom: 12px;\n}\n.permission-warning-section-label {\n display: block;\n font-size: 11px;\n font-weight: 700;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n color: var(--mj-text-muted);\n margin-bottom: 4px;\n}\n.permission-warning-section ul {\n list-style: none;\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n.permission-warning-section li {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 6px 10px;\n font-size: 13px;\n color: var(--mj-text-primary);\n background: var(--mj-bg-surface-sunken, var(--mj-bg-surface));\n border-radius: 6px;\n}\n.permission-warning-section li i {\n color: var(--mj-status-warning-text, #b45309);\n font-size: 12px;\n}\n.permission-warning-hint {\n margin-top: 8px;\n font-size: 12px;\n color: var(--mj-text-muted);\n}\n"] }]
911
+ args: [{ standalone: false, selector: 'mj-component-artifact-viewer', template: "<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 <!-- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\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 \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550 -->\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\u2026\"\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 #interactiveForm\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 \u2014 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", styles: [".component-artifact-viewer {\n display: flex;\n flex-direction: column;\n height: 100%;\n width: 100%;\n background: var(--mj-bg-surface);\n}\n\n.component-preview {\n flex: 1;\n padding: 15px;\n overflow: auto;\n display: flex;\n flex-direction: column;\n min-height: 0;\n min-width: 0;\n width: 100%;\n box-sizing: border-box;\n}\n\n/* Ensure React component takes full height */\n.component-preview mj-react-component {\n flex: 1;\n min-height: 0;\n display: flex;\n flex-direction: column;\n}\n\n.error-state {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 40px;\n text-align: center;\n color: var(--mj-status-error);\n flex: 1;\n min-height: 300px;\n}\n.error-state i {\n font-size: 48px;\n margin-bottom: 16px;\n}\n.error-state h3 {\n margin: 0 0 8px 0;\n font-size: 20px;\n}\n.error-state p {\n margin: 0 0 12px 0;\n color: var(--mj-text-muted);\n}\n.error-state details {\n margin-top: 16px;\n text-align: left;\n max-width: 600px;\n}\n.error-state details summary {\n cursor: pointer;\n color: var(--mj-text-secondary);\n font-weight: 500;\n margin-bottom: 8px;\n}\n.error-state details summary:hover {\n color: var(--mj-text-primary);\n}\n.error-state details pre {\n background: var(--mj-bg-surface-sunken);\n padding: 12px;\n border-radius: 4px;\n overflow-x: auto;\n font-size: 12px;\n color: var(--mj-text-secondary);\n margin: 0;\n}\n\n/* State for component spec without executable code */\n.no-code-state {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 40px;\n text-align: center;\n color: var(--mj-text-muted);\n flex: 1;\n}\n.no-code-state i {\n font-size: 48px;\n margin-bottom: 16px;\n color: var(--mj-brand-primary);\n}\n.no-code-state h3 {\n margin: 0 0 8px 0;\n font-size: 20px;\n color: var(--mj-text-secondary);\n}\n.no-code-state p {\n margin: 0 0 8px 0;\n color: var(--mj-text-muted);\n}\n\n\n/* ====================================================================\n FORM-AWARE BRANCH (componentRole === 'form')\n Top strip: record-picker chip + Apply button.\n Below: dropdown picker panel.\n Below: <mj-interactive-form> bound to the picked record.\n ==================================================================== */\n\n.form-artifact-toolstrip {\n display: flex;\n align-items: center;\n gap: 10px;\n padding: 8px 14px;\n background: var(--mj-bg-surface-card);\n border-bottom: 1px solid var(--mj-border-default);\n font-size: 12px;\n color: var(--mj-text-secondary);\n}\n.form-artifact-toolstrip-label {\n font-weight: 600;\n}\n.form-artifact-toolstrip-entity {\n margin-left: 4px;\n padding: 2px 8px;\n background: color-mix(in srgb, var(--mj-brand-primary) 10%, var(--mj-bg-surface));\n color: var(--mj-brand-primary);\n border: 1px solid color-mix(in srgb, var(--mj-brand-primary) 30%, var(--mj-bg-surface));\n border-radius: 999px;\n font-size: 11px;\n font-weight: 600;\n}\n.form-artifact-toolstrip-warning {\n color: var(--mj-status-warning-text);\n}\n\n.form-artifact-picker-chip {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n background: var(--mj-bg-surface);\n border: 1px solid var(--mj-border-default);\n border-radius: var(--mj-radius-md, 8px);\n padding: 4px 10px;\n font-size: 12px;\n color: var(--mj-text-primary);\n cursor: pointer;\n}\n.form-artifact-picker-chip:hover,\n.form-artifact-picker-chip:focus {\n border-color: var(--mj-border-focus);\n outline: none;\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--mj-brand-primary) 15%, transparent);\n}\n.form-artifact-picker-chip strong {\n color: var(--mj-text-primary);\n font-weight: 600;\n}\n.form-artifact-picker-chip-badge {\n background: var(--mj-status-warning-bg);\n color: var(--mj-status-warning-text);\n border: 1px solid var(--mj-status-warning-border);\n font-size: 10px;\n font-weight: 700;\n padding: 1px 6px;\n border-radius: 999px;\n}\n\n.form-artifact-apply-btn {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n background: var(--mj-brand-primary);\n color: var(--mj-text-inverse, #ffffff);\n border: 1px solid var(--mj-brand-primary);\n border-radius: var(--mj-radius-md, 8px);\n padding: 5px 12px;\n font-size: 12px;\n font-weight: 600;\n cursor: pointer;\n}\n.form-artifact-apply-btn:hover {\n background: var(--mj-brand-primary-hover, var(--mj-brand-primary));\n}\n\n.form-artifact-picker-panel {\n background: var(--mj-bg-surface);\n border-bottom: 1px solid var(--mj-border-default);\n padding: 10px 14px;\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n.form-artifact-picker-search {\n width: 100%;\n padding: 7px 10px;\n border: 1px solid var(--mj-border-default);\n border-radius: var(--mj-radius-md, 8px);\n background: var(--mj-bg-surface);\n font-size: 13px;\n color: var(--mj-text-primary);\n}\n.form-artifact-picker-search:focus {\n outline: none;\n border-color: var(--mj-border-focus);\n box-shadow: 0 0 0 3px color-mix(in srgb, var(--mj-brand-primary) 15%, transparent);\n}\n.form-artifact-picker-results {\n list-style: none;\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n.form-artifact-picker-row {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 6px 8px;\n border-radius: 6px;\n cursor: pointer;\n font-size: 13px;\n}\n.form-artifact-picker-row:hover {\n background: var(--mj-bg-surface-hover);\n}\n.form-artifact-picker-row i {\n color: var(--mj-text-muted);\n font-size: 10px;\n}\n.form-artifact-picker-empty {\n color: var(--mj-text-muted);\n font-size: 12px;\n font-style: italic;\n}\n\n.form-artifact-form-host {\n flex: 1;\n overflow: auto;\n background: var(--mj-bg-page);\n min-width: 0;\n width: 100%;\n box-sizing: border-box;\n}\n\n/* ====================================================================\n PERMISSION WARNING\n Shown before rendering when the user lacks read access to one or\n more entities/queries required by the component.\n ==================================================================== */\n\n.permission-warning {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 40px;\n text-align: center;\n flex: 1;\n min-height: 300px;\n}\n.permission-warning-icon {\n font-size: 48px;\n margin-bottom: 16px;\n color: var(--mj-status-warning-text, #b45309);\n}\n.permission-warning h3 {\n margin: 0 0 8px 0;\n font-size: 20px;\n color: var(--mj-text-primary);\n}\n.permission-warning > p {\n margin: 0 0 16px 0;\n color: var(--mj-text-muted);\n}\n.permission-warning-section {\n text-align: left;\n max-width: 400px;\n width: 100%;\n margin-bottom: 12px;\n}\n.permission-warning-section-label {\n display: block;\n font-size: 11px;\n font-weight: 700;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n color: var(--mj-text-muted);\n margin-bottom: 4px;\n}\n.permission-warning-section ul {\n list-style: none;\n margin: 0;\n padding: 0;\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n.permission-warning-section li {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 6px 10px;\n font-size: 13px;\n color: var(--mj-text-primary);\n background: var(--mj-bg-surface-sunken, var(--mj-bg-surface));\n border-radius: 6px;\n}\n.permission-warning-section li i {\n color: var(--mj-status-warning-text, #b45309);\n font-size: 12px;\n}\n.permission-warning-hint {\n margin-top: 8px;\n font-size: 12px;\n color: var(--mj-text-muted);\n}\n"] }]
840
912
  }], () => [{ type: i1.AngularAdapterService }, { type: i0.ChangeDetectorRef }], { reactComponent: [{
841
913
  type: ViewChild,
842
914
  args: ['reactComponent']
915
+ }], interactiveForm: [{
916
+ type: ViewChild,
917
+ args: ['interactiveForm']
843
918
  }], tabsChanged: [{
844
919
  type: Output
845
920
  }], openEntityRecord: [{
@@ -847,5 +922,5 @@ export { ComponentArtifactViewerComponent };
847
922
  }], applyFormRequested: [{
848
923
  type: Output
849
924
  }] }); })();
850
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ComponentArtifactViewerComponent, { className: "ComponentArtifactViewerComponent", filePath: "src/lib/components/plugins/component-artifact-viewer.component.ts", lineNumber: 26 }); })();
925
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ComponentArtifactViewerComponent, { className: "ComponentArtifactViewerComponent", filePath: "src/lib/components/plugins/component-artifact-viewer.component.ts", lineNumber: 27 }); })();
851
926
  //# sourceMappingURL=component-artifact-viewer.component.js.map
@@ -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,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;;;IAZ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Ac;QACnB,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,cAAc;YAAE,OAAO;QACpD,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC;YAC3B,IAAI,EAAE,IAAI,CAAC,SAAS;YACpB,UAAU,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI;SACrC,CAAC,CAAC;IACL,CAAC;0HAlhBU,gCAAgC;6DAAhC,gCAAgC;;;;;;YCvB3C,AAFF,8BAA4D,aAE3B;YAuI3B,AAjCA,AApFA,AAjBF,mGAAgB,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"]}
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,a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Aa,CAAkB,CAAC;YACtE,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,QAAQ,CAAC,2DAA2D,IAAI,MAAM,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACpI,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;0HA1lBU,gCAAgC;6DAAhC,gCAAgC;;;;;;;YCxB3C,AAFF,8BAA4D,aAE3B;YAwI3B,AAjCA,AArFA,AAjBF,mGAAgB,mEAiBa,6EAqFK,kEAiCzB;YA0BX,iBAAM;YAGN,0HAAkD;YAOpD,iBAAM;;YA9KiC,sCAAoB;YAGvD,eAgKC;YAhKD,6FAgKC;YAIH,eAMC;YAND,6EAMC;;;ADnJU,gCAAgC;IAD5C,aAAa,CAAC,iCAAiC,EAAE,+BAA+B,CAAC;GACrE,gCAAgC,CA2lB5C;;iFA3lBY,gCAAgC;cAP5C,SAAS;6BACI,KAAK,YACP,8BAA8B;;kBAMvC,SAAS;mBAAC,gBAAgB;;kBAC1B,SAAS;mBAAC,iBAAiB;;kBAC3B,MAAM;;kBACN,MAAM;;kBAQN,MAAM;;kFAZI,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 { InteractiveFormComponent } from '@memberjunction/ng-base-forms';\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 @ViewChild('interactiveForm') interactiveForm?: InteractiveFormComponent;\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 /**\n * Bubble Apply intent up to the host (Form Builder dashboard / Sage chat).\n *\n * Resolves the full ComponentSpec (with code) from multiple sources:\n * 1. resolvedComponentSpec — live React bridge or cached copy (best for non-form artifacts)\n * 2. Re-parse artifact version Content — the agent stores the full spec including code\n * 3. DB fallback — fetch from MJ: Components by name\n *\n * Source #2 covers the common form-artifact case where the React component lives inside\n * <mj-interactive-form> and resolvedComponentSpec falls back to the stripped local spec.\n */\n public async onApplyClicked(): Promise<void> {\n if (!this.formEntityInfo) return;\n\n const spec = await this.resolveSpecWithCode();\n if (!spec) return;\n\n this.applyFormRequested.emit({\n spec,\n entityName: this.formEntityInfo.Name,\n });\n }\n\n /**\n * Resolve a ComponentSpec that includes code, trying multiple sources in order.\n */\n private async resolveSpecWithCode(): Promise<ComponentSpec | null> {\n // 1. Prefer the live React bridge's resolved spec (non-form path).\n const resolved = this.resolvedComponentSpec;\n if (resolved?.code) return resolved;\n\n // 2. For form artifacts, the React component lives inside <mj-interactive-form>.\n // Reach into it to get the resolved spec from the component registry.\n const formReactSpec = this.interactiveForm?.reactComponent?.resolvedComponentSpec;\n if (formReactSpec?.code) return formReactSpec;\n\n // 3. Re-parse the artifact version's Content directly — the agent stores the\n // full spec including code. This handles the case where loadComponentSpec()\n // parsed early (before Content was fully populated) and the in-memory\n // `this.component` ended up without code.\n if (this.artifactVersion?.Content) {\n const freshParse = SafeJSONParse(this.artifactVersion.Content) as ComponentSpec | null;\n if (freshParse?.code) return freshParse;\n }\n\n // 4. DB fallback — fetch from MJ: Components by name.\n const name = resolved?.name ?? this.component?.name;\n if (name) {\n const dbSpec = await this.fetchFullSpecByName(name);\n if (dbSpec?.code) return dbSpec;\n }\n\n LogError('ComponentArtifactViewer: could not resolve spec with code for Apply');\n return null;\n }\n\n /**\n * Fetch the full ComponentSpec (including code) from the MJ: Components table\n * by component name. Returns null if not found or on error.\n */\n private async fetchFullSpecByName(name: string): Promise<ComponentSpec | null> {\n try {\n const rv = new RunView();\n const result = await rv.RunView<{ Specification: string }>({\n EntityName: 'MJ: Components',\n ExtraFilter: `Name='${name.replace(/'/g, \"''\")}'`,\n Fields: ['Specification'],\n OrderBy: 'VersionSequence DESC',\n MaxRows: 1,\n ResultType: 'simple',\n });\n if (result.Success && result.Results?.length > 0 && result.Results[0].Specification) {\n return JSON.parse(result.Results[0].Specification) as ComponentSpec;\n }\n } catch (err) {\n LogError(`ComponentArtifactViewer: failed to fetch full spec for '${name}': ${err instanceof Error ? err.message : String(err)}`);\n }\n return null;\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 #interactiveForm\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"]}
@@ -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;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"}
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;IA8FtC;;;;;;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;IAezB,OAAO,CAAC,SAAS;IAsCjB,OAAO,CAAC,IAAI;yCAzSH,2BAA2B;6CAA3B,2BAA2B;CA6SvC"}
@@ -55,25 +55,32 @@ export class InteractiveFormApplyService {
55
55
  return this.fail(`Could not check for existing override: ${activeResult.Message ?? 'unknown error'}`);
56
56
  }
57
57
  const payload = this.parseActiveResult(activeResult.Message);
58
- const hasExistingActive = !!payload?.Active?.OverrideID;
58
+ const existingOverride = payload?.Active
59
+ ?? payload?.Variants?.find(v => v.Status === 'Pending')
60
+ ?? null;
61
+ const hasExistingOverride = !!existingOverride?.OverrideID;
59
62
  // Step 2: confirm with the user.
60
- const proceed = await this.confirm(hasExistingActive, entityName, payload?.Active?.ComponentVersion);
63
+ const proceed = await this.confirm(hasExistingOverride, entityName, existingOverride?.ComponentVersion);
61
64
  if (!proceed) {
62
65
  return { Success: false, Message: 'Cancelled by user.' };
63
66
  }
64
67
  // Step 3: run Create or Modify.
65
68
  const formName = spec.name ?? 'Custom Form';
66
- if (hasExistingActive) {
69
+ if (hasExistingOverride) {
67
70
  // MJ's Modify operates on a Component *lineage* keyed by Name — the spec
68
71
  // name must match the existing Component across versions. A freshly
69
72
  // generated form usually has a different name, so align it to the existing
70
73
  // lineage (spec.name + the root `function` declaration the linter checks)
71
74
  // before modifying.
72
- if (payload?.Active?.ComponentName) {
73
- this.alignSpecToLineage(spec, payload.Active.ComponentName);
75
+ if (existingOverride.ComponentName) {
76
+ this.alignSpecToLineage(spec, existingOverride.ComponentName);
74
77
  }
78
+ // For Pending overrides, use in-place modification (keep iterating on
79
+ // the same version). For Active overrides, bump a new version so the
80
+ // prior version is preserved.
81
+ const isPending = existingOverride.Status === 'Pending';
75
82
  const modifyResult = await this.runActionByName(client, 'Modify Interactive Form', [
76
- { Name: 'OverrideID', Value: payload.Active.OverrideID, Type: 'Input' },
83
+ { Name: 'OverrideID', Value: existingOverride.OverrideID, Type: 'Input' },
77
84
  { Name: 'Spec', Value: JSON.stringify(spec), Type: 'Input' },
78
85
  { Name: 'Notes', Value: `Applied from chat artifact at ${new Date().toISOString()}`, Type: 'Input' },
79
86
  // A user "Apply" is a deliberate save, never an in-flight refinement —
@@ -81,9 +88,10 @@ export class InteractiveFormApplyService {
81
88
  // in-place overwrite. Passing an explicit bump makes this deterministic
82
89
  // across every source status (the 'in-place' default only applies to a
83
90
  // 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' },
91
+ // Exception: if the existing override is already Pending (no Active
92
+ // version exists yet), use in-place to avoid creating unnecessary
93
+ // version history.
94
+ { Name: 'VersionBumpKind', Value: isPending ? 'in-place' : 'minor', Type: 'Input' },
87
95
  ]);
88
96
  // Auto-activate the resulting version too. "Apply to my form" is an explicit
89
97
  // user action — they expect the applied form to go live, not sit as a Pending
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-form-apply.service.js","sourceRoot":"","sources":["../../../src/lib/services/interactive-form-apply.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAyC,MAAM,sBAAsB,CAAC;AACjG,OAAO,EAAE,mBAAmB,EAAuB,MAAM,sCAAsC,CAAC;AAChG,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;;AAkBnE,MAAM,OAAO,2BAA2B;IACnB,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;IACjC,aAAa,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;IAE/D;;;OAGG;IACI,KAAK,CAAC,eAAe,CACxB,IAAmB,EACnB,UAAkB,EAClB,QAA4B;QAE5B,MAAM,CAAC,GAAG,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC;QACxC,IAAI,CAAC,CAAC,EAAE,CAAC;YACL,OAAO,IAAI,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;QACzD,CAAC;QACD,MAAM,MAAM,GAAG,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAC1C,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW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C,CAAC,CAAC,IAAI,KAAK,iBAAiB;oBACzB,CAAC,CAAC,oEAAoE;oBACtE,CAAC,CAAC,YAAY,OAAO,CAAC,OAAO,IAAI,GAAG,qDAAqD,CAAC,CAAC,CAAC;QACxG,IAAI,CAAC,aAAa,CAAC,wBAAwB,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;QACnE,OAAO;YACH,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,IAAI;YACV,UAAU,EAAE,OAAO,CAAC,UAAgC;YACpD,WAAW,EAAE,OAAO,CAAC,WAAiC;YACtD,OAAO,EAAE,OAAO,CAAC,OAA6B;YAC9C,OAAO,EAAE,MAAM,CAAC,OAAO;SAC1B,CAAC;IACN,CAAC;IAEO,IAAI,CAAC,OAAe;QACxB,IAAI,CAAC,aAAa,CAAC,wBAAwB,CAAC,iBAAiB,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;QACvF,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;IAChD,CAAC;qHAhSQ,2BAA2B;gEAA3B,2BAA2B,WAA3B,2BAA2B,mBADd,MAAM;;iFACnB,2BAA2B;cADvC,UAAU;eAAC,EAAE,UAAU,EAAE,MAAM,EAAE","sourcesContent":["/**\n * Apply-to-my-form service.\n *\n * When the form-aware artifact viewer's \"Apply to my form\" button fires\n * `applyFormRequested`, the host calls this service. It:\n * 1. Looks up the entity to confirm it's registered.\n * 2. Reads the current Active override for the (entity, user) pair via\n * the `Get Active Form For Entity` action.\n * 3. Shows a confirmation dialog explaining what's about to happen\n * (Create new vs. Modify existing → Pending).\n * 4. On confirmation, runs `Create Interactive Form` or\n * `Modify Interactive Form` accordingly.\n * 5. Surfaces success / failure via the notification service.\n *\n * The service centralizes the Create-vs-Modify decision so every host\n * (standalone artifact viewer in Explorer, chat conversation surfaces,\n * eventually the cockpit's chat-pane Apply flow) follows the same rules.\n */\nimport { Injectable, inject } from '@angular/core';\nimport { Metadata, LogError, type IMetadataProvider, type UserInfo } from '@memberjunction/core';\nimport { GraphQLActionClient, GraphQLDataProvider } from '@memberjunction/graphql-dataprovider';\nimport { MJNotificationService } from '@memberjunction/ng-notifications';\nimport { MJDialogService } from '@memberjunction/ng-ui-components';\nimport type { ComponentSpec } from '@memberjunction/interactive-component-types';\n\n/** Result of an apply attempt — surfaced to the caller for any post-apply UI. */\nexport interface InteractiveFormApplyResult {\n Success: boolean;\n /** Mode the server ran: 'create' / 'modify-new-version' / 'modify-in-place'. */\n Mode?: 'create' | 'modify-new-version' | 'modify-in-place';\n /** OverrideID the user can now reference. */\n OverrideID?: string;\n /** ComponentID that now holds the spec. */\n ComponentID?: string;\n /** Version string (e.g. '1.0.0' for create, '1.1.0' for modify-new). */\n Version?: string;\n Message?: string;\n}\n\n@Injectable({ providedIn: 'root' })\nexport class InteractiveFormApplyService {\n private readonly dialog = inject(MJDialogService);\n private readonly notifications = inject(MJNotificationService);\n\n /**\n * Confirm with the user and apply the spec. Routes to Create / Modify\n * automatically based on whether an Active override already exists.\n */\n public async ConfirmAndApply(\n spec: ComponentSpec,\n entityName: string,\n provider?: IMetadataProvider,\n ): Promise<InteractiveFormApplyResult> {\n const p = provider ?? Metadata.Provider;\n if (!p) {\n return this.fail('No metadata provider configured.');\n }\n const entity = p.EntityByName(entityName);\n if (!entity) {\n return this.fail(`Entity '${entityName}' is not registered.`);\n }\n const user = p.CurrentUser;\n if (!user) {\n return this.fail('No current user.');\n }\n const gqlProvider = p as unknown as GraphQLDataProvider;\n if (!gqlProvider || typeof (gqlProvider as { ExecuteGQL?: unknown }).ExecuteGQL !== 'function') {\n return this.fail('Action invocation requires a GraphQL provider.');\n }\n\n const client = new GraphQLActionClient(gqlProvider);\n\n // Step 1: detect existing state via Get Active Form For Entity.\n const activeResult = await this.runActionByName(client, 'Get Active Form For Entity', [\n { Name: 'EntityName', Value: entityName, Type: 'Input' },\n ]);\n if (!activeResult.Success) {\n return this.fail(`Could not check for existing override: ${activeResult.Message ?? 'unknown error'}`);\n }\n const payload = this.parseActiveResult(activeResult.Message);\n const hasExistingActive = !!payload?.Active?.OverrideID;\n\n // Step 2: confirm with the user.\n const proceed = await this.confirm(hasExistingActive, entityName, payload?.Active?.ComponentVersion);\n if (!proceed) {\n return { Success: false, Message: 'Cancelled by user.' };\n }\n\n // Step 3: run Create or Modify.\n const formName = (spec as unknown as { name?: string }).name ?? 'Custom Form';\n if (hasExistingActive) {\n // MJ's Modify operates on a Component *lineage* keyed by Name — the spec\n // name must match the existing Component across versions. A freshly\n // generated form usually has a different name, so align it to the existing\n // lineage (spec.name + the root `function` declaration the linter checks)\n // before modifying.\n if (payload?.Active?.ComponentName) {\n this.alignSpecToLineage(spec, payload.Active.ComponentName);\n }\n const modifyResult = await this.runActionByName(client, 'Modify Interactive Form', [\n { Name: 'OverrideID', Value: payload!.Active!.OverrideID!, Type: 'Input' },\n { Name: 'Spec', Value: JSON.stringify(spec), Type: 'Input' },\n { Name: 'Notes', Value: `Applied from chat artifact at ${new Date().toISOString()}`, Type: 'Input' },\n // A user \"Apply\" is a deliberate save, never an in-flight refinement —\n // so always snapshot a new restorable version rather than risk an\n // in-place overwrite. Passing an explicit bump makes this deterministic\n // across every source status (the 'in-place' default only applies to a\n // Pending source, which is the agent's iteration loop, not this path).\n // The prior version is demoted to Inactive on activation and stays in\n // Form Builder's version rail.\n { Name: 'VersionBumpKind', Value: 'minor', Type: 'Input' },\n ]);\n // Auto-activate the resulting version too. \"Apply to my form\" is an explicit\n // user action — they expect the applied form to go live, not sit as a Pending\n // draft the runtime variant switcher (Active variants only) can't reach. The\n // prior version is preserved as history and restorable from Form Builder.\n const modifyActivated = modifyResult.Success\n ? await this.activateCreatedOverride(client, modifyResult.Message)\n : false;\n return this.summarize(modifyResult, 'modify', user, modifyActivated);\n }\n const createResult = await this.runActionByName(client, 'Create Interactive Form', [\n { Name: 'EntityName', Value: entityName, Type: 'Input' },\n { Name: 'Name', Value: formName, Type: 'Input' },\n { Name: 'Spec', Value: JSON.stringify(spec), Type: 'Input' },\n ]);\n // Net-new \"Apply to my form\" is an explicit, confirmed user action, so we\n // activate the freshly-created (Pending) override immediately — the form goes\n // live in one step. Refining an EXISTING active form (the branch above) stays\n // Pending so a live form is never silently replaced.\n const activated = createResult.Success\n ? await this.activateCreatedOverride(client, createResult.Message)\n : false;\n return this.summarize(createResult, 'create', user, activated);\n }\n\n // ── internals ────────────────────────────────────────────────────────\n\n /**\n * Look up an action by name and run it. The actions module ships with\n * `__CreateInteractiveForm` / `__ModifyInteractiveForm` / etc. as their\n * DriverClass names but registers under the human-readable form name.\n * GraphQLActionClient.RunAction() takes the action ID; we fetch it by\n * name from the action metadata loaded on the provider.\n */\n private async runActionByName(\n client: GraphQLActionClient,\n actionName: string,\n params: Array<{ Name: string; Value: string; Type: 'Input' }>,\n ): Promise<{ Success: boolean; Message?: string; ResultCode?: string }> {\n try {\n // The action ID is required by RunAction. We look it up from the\n // action engine's cached metadata if available; otherwise we ask\n // the GraphQL provider directly.\n const actionId = await this.resolveActionIdByName(actionName);\n if (!actionId) {\n return { Success: false, Message: `Action '${actionName}' not found.` };\n }\n const result = await client.RunAction(actionId, params);\n // ActionResult.Result is the MJActionResultCodeEntity carrying\n // the string ResultCode; surface it on the failure path for\n // diagnostic messaging. ActionResult itself doesn't expose\n // ResultCode directly.\n const resultCode = (result as { Result?: { ResultCode?: string } })?.Result?.ResultCode;\n return {\n Success: !!result.Success,\n Message: result.Message ?? undefined,\n ResultCode: resultCode ?? undefined,\n };\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n LogError(`InteractiveFormApplyService.runActionByName(${actionName}): ${message}`);\n return { Success: false, Message: message };\n }\n }\n\n /**\n * Resolve an action ID by Name. Falls back to a direct RunView against\n * the Action entity when ActionEngine isn't loaded.\n */\n private async resolveActionIdByName(name: string): Promise<string | null> {\n try {\n // ActionEngine may not be initialised in the chat surface — query directly.\n // The core Action table is registered as the \"MJ: Actions\" entity.\n const { RunView } = await import('@memberjunction/core');\n const rv = new RunView();\n const result = await rv.RunView<{ ID: string }>({\n EntityName: 'MJ: Actions',\n ExtraFilter: `Name='${name.replace(/'/g, \"''\")}'`,\n Fields: ['ID'],\n MaxRows: 1,\n ResultType: 'simple',\n });\n return result.Success ? (result.Results?.[0]?.ID ?? null) : null;\n } catch (err) {\n LogError(`InteractiveFormApplyService.resolveActionIdByName(${name}): ${err instanceof Error ? err.message : String(err)}`);\n return null;\n }\n }\n\n /**\n * Activate the override produced by a successful Create so a net-new form goes\n * live immediately. Best-effort: on failure the form stays a Pending draft the\n * user can activate manually, so we log and return false rather than failing the\n * whole apply.\n */\n private async activateCreatedOverride(\n client: GraphQLActionClient,\n createMessage: string | undefined,\n ): Promise<boolean> {\n let overrideId: string | undefined;\n try {\n overrideId = (JSON.parse(createMessage ?? '{}') as { OverrideID?: string }).OverrideID;\n } catch {\n overrideId = undefined;\n }\n if (!overrideId) return false;\n const activateResult = await this.runActionByName(client, 'Activate Interactive Form Version', [\n { Name: 'OverrideID', Value: overrideId, Type: 'Input' },\n ]);\n if (!activateResult.Success) {\n LogError(`InteractiveFormApplyService: created override ${overrideId} but auto-activation failed: ${activateResult.Message ?? 'unknown error'}`);\n }\n return activateResult.Success;\n }\n\n /**\n * Align a freshly generated spec to an existing Component lineage before Modify.\n * MJ identifies a form lineage by Component Name and refuses to change it between\n * versions, so we rename the incoming spec — both `spec.name` and the root\n * `function` declaration in `spec.code` (the linter requires them to match) — to\n * the existing lineage name.\n */\n private alignSpecToLineage(spec: ComponentSpec, existingName: string): void {\n const s = spec as { name?: string; code?: string };\n const currentName = s.name;\n if (!currentName || currentName === existingName) return;\n s.name = existingName;\n if (typeof s.code === 'string' && s.code.length > 0) {\n const escaped = currentName.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n s.code = s.code.replace(new RegExp(`function\\\\s+${escaped}\\\\s*\\\\(`), `function ${existingName}(`);\n }\n }\n\n /** Show a confirmation dialog explaining what's about to happen. */\n private async confirm(\n hasExistingActive: boolean,\n entityName: string,\n currentVersion: string | null | undefined,\n ): Promise<boolean> {\n // The dialog renders string content as plain text (not innerHTML), so use\n // plain text here — HTML tags would show raw.\n const content = hasExistingActive\n ? `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.`\n : `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.`;\n // MJDialogAction surface is {text, primary?, themeColor?}; the\n // dialog's Result observable emits the entire clicked action (or\n // undefined for backdrop/X dismissal). Detect intent via the\n // `primary` flag — Apply / Create Pending are the primary actions;\n // Cancel and dismissal both resolve false.\n const ref = this.dialog.Open({\n title: 'Apply this form?',\n content,\n width: 540,\n actions: [\n { text: 'Apply', primary: true, themeColor: 'primary' },\n { text: 'Cancel' },\n ],\n });\n return new Promise<boolean>(resolve => {\n ref.Result.subscribe((res: unknown) => {\n resolve((res as { primary?: boolean })?.primary === true);\n });\n });\n }\n\n private parseActiveResult(message: string | undefined): {\n Active?: { OverrideID?: string; ComponentVersion?: string; ComponentName?: string };\n } | null {\n if (!message) return null;\n try {\n return JSON.parse(message) as { Active?: { OverrideID?: string; ComponentVersion?: string; ComponentName?: string } };\n } catch {\n return null;\n }\n }\n\n private summarize(\n result: { Success: boolean; Message?: string; ResultCode?: string },\n kind: 'create' | 'modify',\n _user: UserInfo,\n activated: boolean = false,\n ): InteractiveFormApplyResult {\n if (!result.Success) {\n this.notifications.CreateSimpleNotification(\n `Apply failed: ${result.Message ?? result.ResultCode ?? 'unknown error'}`,\n 'error', 5000,\n );\n return { Success: false, Message: result.Message };\n }\n let payload: Record<string, unknown> = {};\n try { payload = JSON.parse(result.Message ?? '{}'); } catch { /* best effort */ }\n const mode: InteractiveFormApplyResult['Mode'] = kind === 'create'\n ? 'create'\n : (payload.Mode === 'in-place' ? 'modify-in-place' : 'modify-new-version');\n const note = kind === 'create'\n ? (activated\n ? 'Custom form is now active for your user.'\n : 'Custom form created as a Pending draft — activate it from Form Builder to go live.')\n : (activated\n ? `Updated form is now active${payload.Version ? ` (v${payload.Version})` : ''} for your user.`\n : (mode === 'modify-in-place'\n ? 'Pending version updated. Activate it from Form Builder when ready.'\n : `Pending v${payload.Version ?? '?'} created. Activate it from Form Builder when ready.`));\n this.notifications.CreateSimpleNotification(note, 'success', 4000);\n return {\n Success: true,\n Mode: mode,\n OverrideID: payload.OverrideID as string | undefined,\n ComponentID: payload.ComponentID as string | undefined,\n Version: payload.Version as string | undefined,\n Message: result.Message,\n };\n }\n\n private fail(message: string): InteractiveFormApplyResult {\n this.notifications.CreateSimpleNotification(`Apply failed: ${message}`, 'error', 5000);\n return { Success: false, Message: message };\n }\n}\n"]}
1
+ {"version":3,"file":"interactive-form-apply.service.js","sourceRoot":"","sources":["../../../src/lib/services/interactive-form-apply.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAyC,MAAM,sBAAsB,CAAC;AACjG,OAAO,EAAE,mBAAmB,EAAuB,MAAM,sCAAsC,CAAC;AAChG,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;;AAkBnE,MAAM,OAAO,2BAA2B;IACnB,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;IACjC,aAAa,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;IAE/D;;;OAGG;IACI,KAAK,CAAC,eAAe,CACxB,IAAmB,EACnB,UAAkB,EAClB,QAA4B;QAE5B,MAAM,CAAC,GAAG,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC;QACxC,IAAI,CAAC,CAAC,EAAE,CAAC;YACL,OAAO,IAAI,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;QAC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","sourcesContent":["/**\n * Apply-to-my-form service.\n *\n * When the form-aware artifact viewer's \"Apply to my form\" button fires\n * `applyFormRequested`, the host calls this service. It:\n * 1. Looks up the entity to confirm it's registered.\n * 2. Reads the current Active override for the (entity, user) pair via\n * the `Get Active Form For Entity` action.\n * 3. Shows a confirmation dialog explaining what's about to happen\n * (Create new vs. Modify existing → Pending).\n * 4. On confirmation, runs `Create Interactive Form` or\n * `Modify Interactive Form` accordingly.\n * 5. Surfaces success / failure via the notification service.\n *\n * The service centralizes the Create-vs-Modify decision so every host\n * (standalone artifact viewer in Explorer, chat conversation surfaces,\n * eventually the cockpit's chat-pane Apply flow) follows the same rules.\n */\nimport { Injectable, inject } from '@angular/core';\nimport { Metadata, LogError, type IMetadataProvider, type UserInfo } from '@memberjunction/core';\nimport { GraphQLActionClient, GraphQLDataProvider } from '@memberjunction/graphql-dataprovider';\nimport { MJNotificationService } from '@memberjunction/ng-notifications';\nimport { MJDialogService } from '@memberjunction/ng-ui-components';\nimport type { ComponentSpec } from '@memberjunction/interactive-component-types';\n\n/** Result of an apply attempt — surfaced to the caller for any post-apply UI. */\nexport interface InteractiveFormApplyResult {\n Success: boolean;\n /** Mode the server ran: 'create' / 'modify-new-version' / 'modify-in-place'. */\n Mode?: 'create' | 'modify-new-version' | 'modify-in-place';\n /** OverrideID the user can now reference. */\n OverrideID?: string;\n /** ComponentID that now holds the spec. */\n ComponentID?: string;\n /** Version string (e.g. '1.0.0' for create, '1.1.0' for modify-new). */\n Version?: string;\n Message?: string;\n}\n\n@Injectable({ providedIn: 'root' })\nexport class InteractiveFormApplyService {\n private readonly dialog = inject(MJDialogService);\n private readonly notifications = inject(MJNotificationService);\n\n /**\n * Confirm with the user and apply the spec. Routes to Create / Modify\n * automatically based on whether an Active override already exists.\n */\n public async ConfirmAndApply(\n spec: ComponentSpec,\n entityName: string,\n provider?: IMetadataProvider,\n ): Promise<InteractiveFormApplyResult> {\n const p = provider ?? Metadata.Provider;\n if (!p) {\n return this.fail('No metadata provider configured.');\n }\n const entity = p.EntityByName(entityName);\n if (!entity) {\n return this.fail(`Entity '${entityName}' is not registered.`);\n }\n const user = p.CurrentUser;\n if (!user) {\n return this.fail('No current user.');\n }\n const gqlProvider = p as unknown as GraphQLDataProvider;\n if (!gqlProvider || typeof (gqlProvider as { ExecuteGQL?: unknown }).ExecuteGQL !== 'function') {\n return this.fail('Action invocation requires a GraphQL provider.');\n }\n\n const client = new GraphQLActionClient(gqlProvider);\n\n // Step 1: detect existing state via Get Active Form For Entity.\n const activeResult = await this.runActionByName(client, 'Get Active Form For Entity', [\n { Name: 'EntityName', Value: entityName, Type: 'Input' },\n ]);\n if (!activeResult.Success) {\n return this.fail(`Could not check for existing override: ${activeResult.Message ?? 'unknown error'}`);\n }\n const payload = this.parseActiveResult(activeResult.Message);\n const existingOverride = payload?.Active\n ?? payload?.Variants?.find(v => v.Status === 'Pending')\n ?? null;\n const hasExistingOverride = !!existingOverride?.OverrideID;\n\n // Step 2: confirm with the user.\n const proceed = await this.confirm(hasExistingOverride, entityName, existingOverride?.ComponentVersion);\n if (!proceed) {\n return { Success: false, Message: 'Cancelled by user.' };\n }\n\n // Step 3: run Create or Modify.\n const formName = (spec as unknown as { name?: string }).name ?? 'Custom Form';\n if (hasExistingOverride) {\n // MJ's Modify operates on a Component *lineage* keyed by Name — the spec\n // name must match the existing Component across versions. A freshly\n // generated form usually has a different name, so align it to the existing\n // lineage (spec.name + the root `function` declaration the linter checks)\n // before modifying.\n if (existingOverride!.ComponentName) {\n this.alignSpecToLineage(spec, existingOverride!.ComponentName);\n }\n // For Pending overrides, use in-place modification (keep iterating on\n // the same version). For Active overrides, bump a new version so the\n // prior version is preserved.\n const isPending = existingOverride!.Status === 'Pending';\n const modifyResult = await this.runActionByName(client, 'Modify Interactive Form', [\n { Name: 'OverrideID', Value: existingOverride!.OverrideID!, Type: 'Input' },\n { Name: 'Spec', Value: JSON.stringify(spec), Type: 'Input' },\n { Name: 'Notes', Value: `Applied from chat artifact at ${new Date().toISOString()}`, Type: 'Input' },\n // A user \"Apply\" is a deliberate save, never an in-flight refinement —\n // so always snapshot a new restorable version rather than risk an\n // in-place overwrite. Passing an explicit bump makes this deterministic\n // across every source status (the 'in-place' default only applies to a\n // Pending source, which is the agent's iteration loop, not this path).\n // Exception: if the existing override is already Pending (no Active\n // version exists yet), use in-place to avoid creating unnecessary\n // version history.\n { Name: 'VersionBumpKind', Value: isPending ? 'in-place' : 'minor', Type: 'Input' },\n ]);\n // Auto-activate the resulting version too. \"Apply to my form\" is an explicit\n // user action — they expect the applied form to go live, not sit as a Pending\n // draft the runtime variant switcher (Active variants only) can't reach. The\n // prior version is preserved as history and restorable from Form Builder.\n const modifyActivated = modifyResult.Success\n ? await this.activateCreatedOverride(client, modifyResult.Message)\n : false;\n return this.summarize(modifyResult, 'modify', user, modifyActivated);\n }\n const createResult = await this.runActionByName(client, 'Create Interactive Form', [\n { Name: 'EntityName', Value: entityName, Type: 'Input' },\n { Name: 'Name', Value: formName, Type: 'Input' },\n { Name: 'Spec', Value: JSON.stringify(spec), Type: 'Input' },\n ]);\n // Net-new \"Apply to my form\" is an explicit, confirmed user action, so we\n // activate the freshly-created (Pending) override immediately — the form goes\n // live in one step. Refining an EXISTING active form (the branch above) stays\n // Pending so a live form is never silently replaced.\n const activated = createResult.Success\n ? await this.activateCreatedOverride(client, createResult.Message)\n : false;\n return this.summarize(createResult, 'create', user, activated);\n }\n\n // ── internals ────────────────────────────────────────────────────────\n\n /**\n * Look up an action by name and run it. The actions module ships with\n * `__CreateInteractiveForm` / `__ModifyInteractiveForm` / etc. as their\n * DriverClass names but registers under the human-readable form name.\n * GraphQLActionClient.RunAction() takes the action ID; we fetch it by\n * name from the action metadata loaded on the provider.\n */\n private async runActionByName(\n client: GraphQLActionClient,\n actionName: string,\n params: Array<{ Name: string; Value: string; Type: 'Input' }>,\n ): Promise<{ Success: boolean; Message?: string; ResultCode?: string }> {\n try {\n // The action ID is required by RunAction. We look it up from the\n // action engine's cached metadata if available; otherwise we ask\n // the GraphQL provider directly.\n const actionId = await this.resolveActionIdByName(actionName);\n if (!actionId) {\n return { Success: false, Message: `Action '${actionName}' not found.` };\n }\n const result = await client.RunAction(actionId, params);\n // ActionResult.Result is the MJActionResultCodeEntity carrying\n // the string ResultCode; surface it on the failure path for\n // diagnostic messaging. ActionResult itself doesn't expose\n // ResultCode directly.\n const resultCode = (result as { Result?: { ResultCode?: string } })?.Result?.ResultCode;\n return {\n Success: !!result.Success,\n Message: result.Message ?? undefined,\n ResultCode: resultCode ?? undefined,\n };\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n LogError(`InteractiveFormApplyService.runActionByName(${actionName}): ${message}`);\n return { Success: false, Message: message };\n }\n }\n\n /**\n * Resolve an action ID by Name. Falls back to a direct RunView against\n * the Action entity when ActionEngine isn't loaded.\n */\n private async resolveActionIdByName(name: string): Promise<string | null> {\n try {\n // ActionEngine may not be initialised in the chat surface — query directly.\n // The core Action table is registered as the \"MJ: Actions\" entity.\n const { RunView } = await import('@memberjunction/core');\n const rv = new RunView();\n const result = await rv.RunView<{ ID: string }>({\n EntityName: 'MJ: Actions',\n ExtraFilter: `Name='${name.replace(/'/g, \"''\")}'`,\n Fields: ['ID'],\n MaxRows: 1,\n ResultType: 'simple',\n });\n return result.Success ? (result.Results?.[0]?.ID ?? null) : null;\n } catch (err) {\n LogError(`InteractiveFormApplyService.resolveActionIdByName(${name}): ${err instanceof Error ? err.message : String(err)}`);\n return null;\n }\n }\n\n /**\n * Activate the override produced by a successful Create so a net-new form goes\n * live immediately. Best-effort: on failure the form stays a Pending draft the\n * user can activate manually, so we log and return false rather than failing the\n * whole apply.\n */\n private async activateCreatedOverride(\n client: GraphQLActionClient,\n createMessage: string | undefined,\n ): Promise<boolean> {\n let overrideId: string | undefined;\n try {\n overrideId = (JSON.parse(createMessage ?? '{}') as { OverrideID?: string }).OverrideID;\n } catch {\n overrideId = undefined;\n }\n if (!overrideId) return false;\n const activateResult = await this.runActionByName(client, 'Activate Interactive Form Version', [\n { Name: 'OverrideID', Value: overrideId, Type: 'Input' },\n ]);\n if (!activateResult.Success) {\n LogError(`InteractiveFormApplyService: created override ${overrideId} but auto-activation failed: ${activateResult.Message ?? 'unknown error'}`);\n }\n return activateResult.Success;\n }\n\n /**\n * Align a freshly generated spec to an existing Component lineage before Modify.\n * MJ identifies a form lineage by Component Name and refuses to change it between\n * versions, so we rename the incoming spec — both `spec.name` and the root\n * `function` declaration in `spec.code` (the linter requires them to match) — to\n * the existing lineage name.\n */\n private alignSpecToLineage(spec: ComponentSpec, existingName: string): void {\n const s = spec as { name?: string; code?: string };\n const currentName = s.name;\n if (!currentName || currentName === existingName) return;\n s.name = existingName;\n if (typeof s.code === 'string' && s.code.length > 0) {\n const escaped = currentName.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n s.code = s.code.replace(new RegExp(`function\\\\s+${escaped}\\\\s*\\\\(`), `function ${existingName}(`);\n }\n }\n\n /** Show a confirmation dialog explaining what's about to happen. */\n private async confirm(\n hasExistingActive: boolean,\n entityName: string,\n currentVersion: string | null | undefined,\n ): Promise<boolean> {\n // The dialog renders string content as plain text (not innerHTML), so use\n // plain text here — HTML tags would show raw.\n const content = hasExistingActive\n ? `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.`\n : `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.`;\n // MJDialogAction surface is {text, primary?, themeColor?}; the\n // dialog's Result observable emits the entire clicked action (or\n // undefined for backdrop/X dismissal). Detect intent via the\n // `primary` flag — Apply / Create Pending are the primary actions;\n // Cancel and dismissal both resolve false.\n const ref = this.dialog.Open({\n title: 'Apply this form?',\n content,\n width: 540,\n actions: [\n { text: 'Apply', primary: true, themeColor: 'primary' },\n { text: 'Cancel' },\n ],\n });\n return new Promise<boolean>(resolve => {\n ref.Result.subscribe((res: unknown) => {\n resolve((res as { primary?: boolean })?.primary === true);\n });\n });\n }\n\n private parseActiveResult(message: string | undefined): {\n Active?: { OverrideID?: string; ComponentVersion?: string; ComponentName?: string; Status?: string };\n Variants?: Array<{ OverrideID?: string; ComponentVersion?: string; ComponentName?: string; Status?: string }>;\n } | null {\n if (!message) return null;\n try {\n return JSON.parse(message) as {\n Active?: { OverrideID?: string; ComponentVersion?: string; ComponentName?: string; Status?: string };\n Variants?: Array<{ OverrideID?: string; ComponentVersion?: string; ComponentName?: string; Status?: string }>;\n };\n } catch {\n return null;\n }\n }\n\n private summarize(\n result: { Success: boolean; Message?: string; ResultCode?: string },\n kind: 'create' | 'modify',\n _user: UserInfo,\n activated: boolean = false,\n ): InteractiveFormApplyResult {\n if (!result.Success) {\n this.notifications.CreateSimpleNotification(\n `Apply failed: ${result.Message ?? result.ResultCode ?? 'unknown error'}`,\n 'error', 5000,\n );\n return { Success: false, Message: result.Message };\n }\n let payload: Record<string, unknown> = {};\n try { payload = JSON.parse(result.Message ?? '{}'); } catch { /* best effort */ }\n const mode: InteractiveFormApplyResult['Mode'] = kind === 'create'\n ? 'create'\n : (payload.Mode === 'in-place' ? 'modify-in-place' : 'modify-new-version');\n const note = kind === 'create'\n ? (activated\n ? 'Custom form is now active for your user.'\n : 'Custom form created as a Pending draft — activate it from Form Builder to go live.')\n : (activated\n ? `Updated form is now active${payload.Version ? ` (v${payload.Version})` : ''} for your user.`\n : (mode === 'modify-in-place'\n ? 'Pending version updated. Activate it from Form Builder when ready.'\n : `Pending v${payload.Version ?? '?'} created. Activate it from Form Builder when ready.`));\n this.notifications.CreateSimpleNotification(note, 'success', 4000);\n return {\n Success: true,\n Mode: mode,\n OverrideID: payload.OverrideID as string | undefined,\n ComponentID: payload.ComponentID as string | undefined,\n Version: payload.Version as string | undefined,\n Message: result.Message,\n };\n }\n\n private fail(message: string): InteractiveFormApplyResult {\n this.notifications.CreateSimpleNotification(`Apply failed: ${message}`, 'error', 5000);\n return { Success: false, Message: message };\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/ng-artifacts",
3
- "version": "5.47.0",
3
+ "version": "5.48.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",
@@ -18,8 +18,8 @@
18
18
  "devDependencies": {
19
19
  "@angular/compiler": "21.1.3",
20
20
  "@angular/compiler-cli": "21.1.3",
21
- "@memberjunction/core": "5.47.0",
22
- "@memberjunction/ng-test-utils": "5.47.0",
21
+ "@memberjunction/core": "5.48.0",
22
+ "@memberjunction/ng-test-utils": "5.48.0",
23
23
  "sass": "^1.97.3",
24
24
  "vitest": "^4.0.18"
25
25
  },
@@ -34,24 +34,24 @@
34
34
  "dependencies": {
35
35
  "@angular/cdk": "21.1.3",
36
36
  "@angular/forms": "21.1.3",
37
- "@memberjunction/core": "5.47.0",
38
- "@memberjunction/core-entities": "5.47.0",
39
- "@memberjunction/global": "5.47.0",
40
- "@memberjunction/graphql-dataprovider": "5.47.0",
41
- "@memberjunction/interactive-component-types": "5.47.0",
42
- "@memberjunction/ng-base-forms": "5.47.0",
43
- "@memberjunction/ng-base-types": "5.47.0",
44
- "@memberjunction/ng-code-editor": "5.47.0",
45
- "@memberjunction/ng-export-service": "5.47.0",
46
- "@memberjunction/ng-markdown": "5.47.0",
47
- "@memberjunction/ng-media-player": "5.47.0",
48
- "@memberjunction/ng-notifications": "5.47.0",
49
- "@memberjunction/ng-pagination": "5.47.0",
50
- "@memberjunction/ng-query-viewer": "5.47.0",
51
- "@memberjunction/ng-react": "5.47.0",
52
- "@memberjunction/ng-shared-generic": "5.47.0",
53
- "@memberjunction/ng-trees": "5.47.0",
54
- "@memberjunction/ng-ui-components": "5.47.0",
37
+ "@memberjunction/core": "5.48.0",
38
+ "@memberjunction/core-entities": "5.48.0",
39
+ "@memberjunction/global": "5.48.0",
40
+ "@memberjunction/graphql-dataprovider": "5.48.0",
41
+ "@memberjunction/interactive-component-types": "5.48.0",
42
+ "@memberjunction/ng-base-forms": "5.48.0",
43
+ "@memberjunction/ng-base-types": "5.48.0",
44
+ "@memberjunction/ng-code-editor": "5.48.0",
45
+ "@memberjunction/ng-export-service": "5.48.0",
46
+ "@memberjunction/ng-markdown": "5.48.0",
47
+ "@memberjunction/ng-media-player": "5.48.0",
48
+ "@memberjunction/ng-notifications": "5.48.0",
49
+ "@memberjunction/ng-pagination": "5.48.0",
50
+ "@memberjunction/ng-query-viewer": "5.48.0",
51
+ "@memberjunction/ng-react": "5.48.0",
52
+ "@memberjunction/ng-shared-generic": "5.48.0",
53
+ "@memberjunction/ng-trees": "5.48.0",
54
+ "@memberjunction/ng-ui-components": "5.48.0",
55
55
  "mammoth": "^1.8.0",
56
56
  "pdfjs-dist": "^4.10.38",
57
57
  "rxjs": "^7.8.2",