@masterteam/formula-builder 0.0.33 → 0.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/assets/i18n/ar.json
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
{
|
|
2
|
-
"formulaBuilder": {
|
|
3
|
-
"placeholder": "أدخل الصيغة...",
|
|
4
|
-
"codeMode": "وضع الكود",
|
|
5
|
-
"errors": {
|
|
6
|
-
"validationFailed": "فشل التحقق",
|
|
7
|
-
"required": "الصيغة مطلوبة"
|
|
8
|
-
},
|
|
9
|
-
"actions": {
|
|
10
|
-
"insert": "إدراج",
|
|
11
|
-
"insert-value": "إدراج القيمة",
|
|
12
|
-
"clear": "مسح"
|
|
13
|
-
},
|
|
14
|
-
"properties": {
|
|
15
|
-
"path": "المسار",
|
|
16
|
-
"field": "الحقل",
|
|
17
|
-
"value": "القيمة",
|
|
18
|
-
"no-path-configured": "لا يوجد مسار محدد",
|
|
19
|
-
"direct-access": "وصول مباشر",
|
|
20
|
-
"add-segment": "إضافة جزء",
|
|
21
|
-
"select": "اختر",
|
|
22
|
-
"select-value": "اختر القيمة"
|
|
23
|
-
},
|
|
24
|
-
"operatorNames": {
|
|
25
|
-
"level": "المستوى",
|
|
26
|
-
"current": "الحالي",
|
|
27
|
-
"host": "المضيف",
|
|
28
|
-
"parent": "الأصل",
|
|
29
|
-
"children": "الأبناء",
|
|
30
|
-
"descendants": "المتفرعات",
|
|
31
|
-
"modules": "الوحدات",
|
|
32
|
-
"schedule": "الجدول الزمني",
|
|
33
|
-
"phasegate": "بوابة المرحلة",
|
|
34
|
-
"taskbaseline": "خط الأساس للمهام"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"formulaBuilder": {
|
|
3
|
+
"placeholder": "أدخل الصيغة...",
|
|
4
|
+
"codeMode": "وضع الكود",
|
|
5
|
+
"errors": {
|
|
6
|
+
"validationFailed": "فشل التحقق",
|
|
7
|
+
"required": "الصيغة مطلوبة"
|
|
8
|
+
},
|
|
9
|
+
"actions": {
|
|
10
|
+
"insert": "إدراج",
|
|
11
|
+
"insert-value": "إدراج القيمة",
|
|
12
|
+
"clear": "مسح"
|
|
13
|
+
},
|
|
14
|
+
"properties": {
|
|
15
|
+
"path": "المسار",
|
|
16
|
+
"field": "الحقل",
|
|
17
|
+
"value": "القيمة",
|
|
18
|
+
"no-path-configured": "لا يوجد مسار محدد",
|
|
19
|
+
"direct-access": "وصول مباشر",
|
|
20
|
+
"add-segment": "إضافة جزء",
|
|
21
|
+
"select": "اختر",
|
|
22
|
+
"select-value": "اختر القيمة"
|
|
23
|
+
},
|
|
24
|
+
"operatorNames": {
|
|
25
|
+
"level": "المستوى",
|
|
26
|
+
"current": "الحالي",
|
|
27
|
+
"host": "المضيف",
|
|
28
|
+
"parent": "الأصل",
|
|
29
|
+
"children": "الأبناء",
|
|
30
|
+
"descendants": "المتفرعات",
|
|
31
|
+
"modules": "الوحدات",
|
|
32
|
+
"schedule": "الجدول الزمني",
|
|
33
|
+
"phasegate": "بوابة المرحلة",
|
|
34
|
+
"taskbaseline": "خط الأساس للمهام"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
package/assets/i18n/en.json
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
{
|
|
2
|
-
"formulaBuilder": {
|
|
3
|
-
"placeholder": "Enter formula...",
|
|
4
|
-
"codeMode": "Code mode",
|
|
5
|
-
"errors": {
|
|
6
|
-
"validationFailed": "Validation failed",
|
|
7
|
-
"required": "Formula is required"
|
|
8
|
-
},
|
|
9
|
-
"actions": {
|
|
10
|
-
"insert": "Insert",
|
|
11
|
-
"insert-value": "Insert value",
|
|
12
|
-
"clear": "Clear"
|
|
13
|
-
},
|
|
14
|
-
"properties": {
|
|
15
|
-
"path": "Path",
|
|
16
|
-
"field": "Field",
|
|
17
|
-
"value": "Value",
|
|
18
|
-
"no-path-configured": "No path configured",
|
|
19
|
-
"direct-access": "Direct Access",
|
|
20
|
-
"add-segment": "Add Segment",
|
|
21
|
-
"select": "Select",
|
|
22
|
-
"select-value": "Select value"
|
|
23
|
-
},
|
|
24
|
-
"operatorNames": {
|
|
25
|
-
"level": "Level",
|
|
26
|
-
"current": "Current",
|
|
27
|
-
"host": "Host",
|
|
28
|
-
"parent": "Parent",
|
|
29
|
-
"children": "Children",
|
|
30
|
-
"descendants": "Descendants",
|
|
31
|
-
"modules": "Modules",
|
|
32
|
-
"schedule": "Schedule",
|
|
33
|
-
"phasegate": "Phase Gate",
|
|
34
|
-
"taskbaseline": "Task Baseline"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"formulaBuilder": {
|
|
3
|
+
"placeholder": "Enter formula...",
|
|
4
|
+
"codeMode": "Code mode",
|
|
5
|
+
"errors": {
|
|
6
|
+
"validationFailed": "Validation failed",
|
|
7
|
+
"required": "Formula is required"
|
|
8
|
+
},
|
|
9
|
+
"actions": {
|
|
10
|
+
"insert": "Insert",
|
|
11
|
+
"insert-value": "Insert value",
|
|
12
|
+
"clear": "Clear"
|
|
13
|
+
},
|
|
14
|
+
"properties": {
|
|
15
|
+
"path": "Path",
|
|
16
|
+
"field": "Field",
|
|
17
|
+
"value": "Value",
|
|
18
|
+
"no-path-configured": "No path configured",
|
|
19
|
+
"direct-access": "Direct Access",
|
|
20
|
+
"add-segment": "Add Segment",
|
|
21
|
+
"select": "Select",
|
|
22
|
+
"select-value": "Select value"
|
|
23
|
+
},
|
|
24
|
+
"operatorNames": {
|
|
25
|
+
"level": "Level",
|
|
26
|
+
"current": "Current",
|
|
27
|
+
"host": "Host",
|
|
28
|
+
"parent": "Parent",
|
|
29
|
+
"children": "Children",
|
|
30
|
+
"descendants": "Descendants",
|
|
31
|
+
"modules": "Modules",
|
|
32
|
+
"schedule": "Schedule",
|
|
33
|
+
"phasegate": "Phase Gate",
|
|
34
|
+
"taskbaseline": "Task Baseline"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -141,8 +141,12 @@ class FormulaValidatorService {
|
|
|
141
141
|
/** Call validation API */
|
|
142
142
|
callValidateApi(request) {
|
|
143
143
|
const { apiMode, ...payload } = request;
|
|
144
|
+
// The result is shown inline under the editor, so a toast only repeats it.
|
|
145
|
+
// Hosts silence `api/formulas/validate` by URL, which misses current-only.
|
|
144
146
|
return this.http
|
|
145
|
-
.post(`${this.getBaseUrl(apiMode)}/validate`, payload
|
|
147
|
+
.post(`${this.getBaseUrl(apiMode)}/validate`, payload, {
|
|
148
|
+
headers: { noMessage: 'true' },
|
|
149
|
+
})
|
|
146
150
|
.pipe(map((response) => this.unwrapResponse(response) ?? this.buildErrorValidation()), catchError((error) => {
|
|
147
151
|
console.error('Validation API error:', error);
|
|
148
152
|
// Prefer the backend-localized message; fall back to the FE string.
|
|
@@ -370,8 +374,12 @@ class FormulaAutocompleteService {
|
|
|
370
374
|
...request,
|
|
371
375
|
formula: request.formula ?? '',
|
|
372
376
|
};
|
|
377
|
+
// A background read on every keystroke: the host's message interceptor
|
|
378
|
+
// must not toast its "Created successfully." or its 400s.
|
|
373
379
|
return this.http
|
|
374
|
-
.post(`${this.getBaseUrl(apiMode)}/autocomplete`, normalized
|
|
380
|
+
.post(`${this.getBaseUrl(apiMode)}/autocomplete`, normalized, {
|
|
381
|
+
headers: { noMessage: 'true' },
|
|
382
|
+
})
|
|
375
383
|
.pipe(map((response) => this.unwrapResponse(response)), catchError((error) => {
|
|
376
384
|
console.warn('Autocomplete API error:', error);
|
|
377
385
|
return of(null);
|
|
@@ -589,6 +597,13 @@ class FormulaBuilder {
|
|
|
589
597
|
valueMode = input('object', ...(ngDevMode ? [{ debugName: "valueMode" }] : /* istanbul ignore next */ []));
|
|
590
598
|
/** Use Process Builder current-only Formula Engine endpoints */
|
|
591
599
|
isProcessBuilder = input(false, ...(ngDevMode ? [{ debugName: "isProcessBuilder" }] : /* istanbul ignore next */ []));
|
|
600
|
+
/**
|
|
601
|
+
* Property keys the formula may reference, sent with every validation. For
|
|
602
|
+
* surfaces that author without a schema-context lookup (notification
|
|
603
|
+
* "send only when" conditions), this is how the backend learns which
|
|
604
|
+
* Current fields exist.
|
|
605
|
+
*/
|
|
606
|
+
knownProperties = input(...(ngDevMode ? [undefined, { debugName: "knownProperties" }] : /* istanbul ignore next */ []));
|
|
592
607
|
// ===== OUTPUTS =====
|
|
593
608
|
/** Emits validation result on change */
|
|
594
609
|
validationChange = output();
|
|
@@ -775,8 +790,9 @@ class FormulaBuilder {
|
|
|
775
790
|
const apiMode = this.formulaApiMode();
|
|
776
791
|
const contextKey = this.resolvedContextKey();
|
|
777
792
|
const addressedByContextKey = this.isAddressedByContextKey();
|
|
793
|
+
const knownProperties = this.knownProperties();
|
|
778
794
|
if (formula && formula.trim().length > 0) {
|
|
779
|
-
this.validatorService.validate(formula,
|
|
795
|
+
this.validatorService.validate(formula, knownProperties, addressedByContextKey ? undefined : this.levelSchemaId(), addressedByContextKey ? undefined : this.moduleId(), this.templateId(), apiMode, contextKey);
|
|
780
796
|
}
|
|
781
797
|
});
|
|
782
798
|
// Emit validation changes
|
|
@@ -1546,7 +1562,7 @@ class FormulaBuilder {
|
|
|
1546
1562
|
return translated && translated !== key ? translated : token;
|
|
1547
1563
|
}
|
|
1548
1564
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.8", ngImport: i0, type: FormulaBuilder, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1549
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: FormulaBuilder, isStandalone: true, selector: "mt-formula-builder", inputs: { propertiesByPath: { classPropertyName: "propertiesByPath", publicName: "propertiesByPath", isSignal: true, isRequired: false, transformFunction: null }, levelSchemaId: { classPropertyName: "levelSchemaId", publicName: "levelSchemaId", isSignal: true, isRequired: false, transformFunction: null }, moduleId: { classPropertyName: "moduleId", publicName: "moduleId", isSignal: true, isRequired: false, transformFunction: null }, contextKey: { classPropertyName: "contextKey", publicName: "contextKey", isSignal: true, isRequired: false, transformFunction: null }, contextEntityTypeKey: { classPropertyName: "contextEntityTypeKey", publicName: "contextEntityTypeKey", isSignal: true, isRequired: false, transformFunction: null }, templateId: { classPropertyName: "templateId", publicName: "templateId", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, hideToolbar: { classPropertyName: "hideToolbar", publicName: "hideToolbar", isSignal: true, isRequired: false, transformFunction: null }, hideStatusBar: { classPropertyName: "hideStatusBar", publicName: "hideStatusBar", isSignal: true, isRequired: false, transformFunction: null }, invalidWhenEmpty: { classPropertyName: "invalidWhenEmpty", publicName: "invalidWhenEmpty", isSignal: true, isRequired: false, transformFunction: null }, toolbarTabs: { classPropertyName: "toolbarTabs", publicName: "toolbarTabs", isSignal: true, isRequired: false, transformFunction: null }, functionCategories: { classPropertyName: "functionCategories", publicName: "functionCategories", isSignal: true, isRequired: false, transformFunction: null }, operators: { classPropertyName: "operators", publicName: "operators", isSignal: true, isRequired: false, transformFunction: null }, codeOnly: { classPropertyName: "codeOnly", publicName: "codeOnly", isSignal: true, isRequired: false, transformFunction: null }, builderOnly: { classPropertyName: "builderOnly", publicName: "builderOnly", isSignal: true, isRequired: false, transformFunction: null }, valueMode: { classPropertyName: "valueMode", publicName: "valueMode", isSignal: true, isRequired: false, transformFunction: null }, isProcessBuilder: { classPropertyName: "isProcessBuilder", publicName: "isProcessBuilder", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { validationChange: "validationChange", tokensChange: "tokensChange" }, host: { classAttribute: "block" }, providers: [
|
|
1565
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.8", type: FormulaBuilder, isStandalone: true, selector: "mt-formula-builder", inputs: { propertiesByPath: { classPropertyName: "propertiesByPath", publicName: "propertiesByPath", isSignal: true, isRequired: false, transformFunction: null }, levelSchemaId: { classPropertyName: "levelSchemaId", publicName: "levelSchemaId", isSignal: true, isRequired: false, transformFunction: null }, moduleId: { classPropertyName: "moduleId", publicName: "moduleId", isSignal: true, isRequired: false, transformFunction: null }, contextKey: { classPropertyName: "contextKey", publicName: "contextKey", isSignal: true, isRequired: false, transformFunction: null }, contextEntityTypeKey: { classPropertyName: "contextEntityTypeKey", publicName: "contextEntityTypeKey", isSignal: true, isRequired: false, transformFunction: null }, templateId: { classPropertyName: "templateId", publicName: "templateId", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, hideToolbar: { classPropertyName: "hideToolbar", publicName: "hideToolbar", isSignal: true, isRequired: false, transformFunction: null }, hideStatusBar: { classPropertyName: "hideStatusBar", publicName: "hideStatusBar", isSignal: true, isRequired: false, transformFunction: null }, invalidWhenEmpty: { classPropertyName: "invalidWhenEmpty", publicName: "invalidWhenEmpty", isSignal: true, isRequired: false, transformFunction: null }, toolbarTabs: { classPropertyName: "toolbarTabs", publicName: "toolbarTabs", isSignal: true, isRequired: false, transformFunction: null }, functionCategories: { classPropertyName: "functionCategories", publicName: "functionCategories", isSignal: true, isRequired: false, transformFunction: null }, operators: { classPropertyName: "operators", publicName: "operators", isSignal: true, isRequired: false, transformFunction: null }, codeOnly: { classPropertyName: "codeOnly", publicName: "codeOnly", isSignal: true, isRequired: false, transformFunction: null }, builderOnly: { classPropertyName: "builderOnly", publicName: "builderOnly", isSignal: true, isRequired: false, transformFunction: null }, valueMode: { classPropertyName: "valueMode", publicName: "valueMode", isSignal: true, isRequired: false, transformFunction: null }, isProcessBuilder: { classPropertyName: "isProcessBuilder", publicName: "isProcessBuilder", isSignal: true, isRequired: false, transformFunction: null }, knownProperties: { classPropertyName: "knownProperties", publicName: "knownProperties", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { validationChange: "validationChange", tokensChange: "tokensChange" }, host: { classAttribute: "block" }, providers: [
|
|
1550
1566
|
{
|
|
1551
1567
|
provide: NG_VALUE_ACCESSOR,
|
|
1552
1568
|
useExisting: forwardRef(() => FormulaBuilder),
|
|
@@ -1581,7 +1597,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.8", ngImpor
|
|
|
1581
1597
|
multi: true,
|
|
1582
1598
|
},
|
|
1583
1599
|
], template: "<mt-card\r\n headless\r\n [class.ring-2]=\"hasFocus()\"\r\n [class.ring-primary]=\"hasFocus()\"\r\n [paddingless]=\"true\"\r\n>\r\n <div\r\n *transloco=\"let t; prefix: 'formulaBuilder'\"\r\n class=\"flex flex-col overflow-hidden\"\r\n >\r\n <!-- Toolbar - Pass data via inputs (pure component) -->\r\n @if (!hideToolbar()) {\r\n <mt-formula-toolbar\r\n [functionCategories]=\"resolvedFunctionCategories()\"\r\n [operators]=\"operators()\"\r\n [visibleTabs]=\"resolvedToolbarTabs()\"\r\n (onBlockInsert)=\"onBlockInsert($event)\"\r\n >\r\n <ng-template #properties let-insertBlock=\"insertBlock\">\r\n @if (isContextLoading()) {\r\n <div class=\"flex flex-col gap-4 p-4\">\r\n <div class=\"flex items-center justify-between gap-4\">\r\n <p-skeleton\r\n width=\"18rem\"\r\n height=\"2.5rem\"\r\n styleClass=\"rounded-md\"\r\n />\r\n <p-skeleton\r\n width=\"7rem\"\r\n height=\"2.5rem\"\r\n styleClass=\"rounded-md\"\r\n />\r\n </div>\r\n <div class=\"flex items-center gap-4\">\r\n <div\r\n class=\"flex min-h-11 min-w-0 flex-1 flex-col gap-2 rounded-lg bg-slate-50 px-3 py-2 dark:bg-slate-800/50\"\r\n >\r\n <div class=\"flex items-center gap-2\">\r\n <p-skeleton\r\n width=\"3rem\"\r\n height=\"1rem\"\r\n styleClass=\"rounded-md\"\r\n />\r\n <div\r\n class=\"h-4 w-px shrink-0 bg-slate-200 dark:bg-slate-700\"\r\n ></div>\r\n <p-skeleton\r\n class=\"flex-1\"\r\n height=\"2rem\"\r\n styleClass=\"rounded-md\"\r\n />\r\n </div>\r\n <div\r\n class=\"flex items-center gap-2 border-t border-slate-200 pt-2 dark:border-slate-700\"\r\n >\r\n <p-skeleton\r\n width=\"3rem\"\r\n height=\"1rem\"\r\n styleClass=\"rounded-md\"\r\n />\r\n <div\r\n class=\"h-4 w-px shrink-0 bg-slate-200 dark:bg-slate-700\"\r\n ></div>\r\n <p-skeleton\r\n class=\"flex-1\"\r\n height=\"2.5rem\"\r\n styleClass=\"rounded-md\"\r\n />\r\n </div>\r\n <p-skeleton height=\"2rem\" styleClass=\"rounded-md\" />\r\n </div>\r\n </div>\r\n </div>\r\n } @else {\r\n <div class=\"flex flex-col gap-4 p-4\">\r\n <!-- Scope Selection - Full width, centered -->\r\n <div class=\"flex items-center justify-between gap-4\">\r\n <mt-radio-cards\r\n [options]=\"scopeOptions()\"\r\n [activeId]=\"propertyScope()\"\r\n (selectionChange)=\"onScopeChange($event)\"\r\n size=\"small\"\r\n />\r\n </div>\r\n\r\n <!-- Path + Field + Preview Row -->\r\n <div class=\"flex items-center gap-4\">\r\n <!-- Path Container - Flexible -->\r\n <div\r\n class=\"flex min-h-11 min-w-0 flex-1 flex-col gap-2 rounded-lg bg-slate-50 px-3 py-2 dark:bg-slate-800/50\"\r\n >\r\n <div class=\"flex items-center gap-2\">\r\n <span\r\n class=\"shrink-0 text-xs font-semibold uppercase tracking-wider text-slate-400\"\r\n >{{ t(\"properties.path\") }}</span\r\n >\r\n <div\r\n class=\"h-4 w-px shrink-0 bg-slate-200 dark:bg-slate-700\"\r\n ></div>\r\n <div class=\"flex min-w-0 flex-1 items-center gap-2\">\r\n @if (isDirectAccess()) {\r\n <span\r\n class=\"rounded-md bg-emerald-100 px-2.5 py-1 text-xs font-medium text-emerald-600 dark:bg-emerald-900/30 dark:text-emerald-400\"\r\n >\r\n \u2713 {{ t(\"properties.direct-access\") }}\r\n </span>\r\n } @else if (pathSegments().length === 0) {\r\n <span class=\"text-xs italic text-slate-400\">{{\r\n t(\"properties.no-path-configured\")\r\n }}</span>\r\n } @else {\r\n <div\r\n class=\"flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto\"\r\n >\r\n @for (\r\n segment of pathSegments();\r\n track $index;\r\n let segmentIndex = $index\r\n ) {\r\n @if (segmentIndex > 0) {\r\n <span\r\n class=\"shrink-0 text-slate-300 dark:text-slate-600\"\r\n >\u203A</span\r\n >\r\n }\r\n <mt-button\r\n type=\"button\"\r\n [label]=\"\r\n segment.value ||\r\n t('properties.select') +\r\n ' ' +\r\n getOperatorDisplayName(segment.operatorToken)\r\n \"\r\n icon=\"arrow.chevron-down\"\r\n [outlined]=\"true\"\r\n size=\"small\"\r\n [severity]=\"\r\n segment.value ? 'primary' : 'secondary'\r\n \"\r\n [iconPos]=\"'end'\"\r\n (onClick)=\"pathPopover.toggle($event)\"\r\n ></mt-button>\r\n\r\n <p-popover\r\n #pathPopover\r\n [style]=\"{ width: 'max-content' }\"\r\n appendTo=\"body\"\r\n >\r\n <div class=\"p-2\">\r\n <div\r\n class=\"mb-2 text-xs font-semibold uppercase text-slate-400\"\r\n >\r\n {{ t(\"properties.select\") }}\r\n {{\r\n getOperatorDisplayName(\r\n segment.operatorToken\r\n )\r\n }}\r\n </div>\r\n <div\r\n class=\"flex max-h-[min(24rem,calc(100vh-10rem))] flex-col gap-1 overflow-y-auto pr-1\"\r\n >\r\n @for (\r\n option of segmentOptions(segmentIndex);\r\n track option.key\r\n ) {\r\n <mt-button\r\n type=\"button\"\r\n [label]=\"option.name\"\r\n [icon]=\"\r\n segment.value === option.key\r\n ? 'general.check'\r\n : 'general.minus'\r\n \"\r\n [iconPos]=\"'end'\"\r\n size=\"small\"\r\n severity=\"secondary\"\r\n [styleClass]=\"\r\n 'w-full justify-start rounded-md px-2.5 py-1.5 text-left text-xs font-medium transition-colors ' +\r\n (segment.value === option.key\r\n ? 'bg-primary text-white'\r\n : 'text-slate-600 hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-700')\r\n \"\r\n (onClick)=\"\r\n setPathSegmentValue(\r\n segmentIndex,\r\n option.key\r\n );\r\n pathPopover.hide()\r\n \"\r\n ></mt-button>\r\n }\r\n </div>\r\n @if (segment.optional) {\r\n <mt-button\r\n type=\"button\"\r\n [label]=\"t('actions.clear')\"\r\n [outlined]=\"true\"\r\n icon=\"general.x-close\"\r\n [iconPos]=\"'end'\"\r\n size=\"small\"\r\n severity=\"danger\"\r\n styleClass=\"mt-2 w-full rounded-md border border-slate-200 py-1 text-xs text-slate-400 hover:bg-slate-50 dark:border-slate-700\"\r\n (onClick)=\"\r\n setPathSegmentValue(segmentIndex, null);\r\n pathPopover.hide()\r\n \"\r\n ></mt-button>\r\n }\r\n </div>\r\n </p-popover>\r\n\r\n @if (\r\n segment.canRemove &&\r\n segmentIndex === pathSegments().length - 1\r\n ) {\r\n <mt-button\r\n type=\"button\"\r\n icon=\"general.x-close\"\r\n size=\"small\"\r\n severity=\"danger\"\r\n styleClass=\"flex size-5 shrink-0 items-center justify-center rounded-full bg-red-500 text-white hover:bg-red-600\"\r\n (onClick)=\"removePathSegment(segmentIndex)\"\r\n ></mt-button>\r\n }\r\n }\r\n <mt-button\r\n type=\"button\"\r\n icon=\"general.plus\"\r\n size=\"small\"\r\n severity=\"primary\"\r\n [disabled]=\"!canAddNextSegment()\"\r\n [class.hidden]=\"!canAddNextSegment()\"\r\n styleClass=\"flex size-6 shrink-0 items-center justify-center rounded-md bg-primary text-xs font-bold text-white hover:opacity-90 disabled:opacity-50\"\r\n (onClick)=\"nextOperatorPopover.toggle($event)\"\r\n ></mt-button>\r\n </div>\r\n }\r\n <p-popover\r\n #nextOperatorPopover\r\n [style]=\"{ width: 'max-content' }\"\r\n appendTo=\"body\"\r\n >\r\n <div class=\"p-2\">\r\n <div\r\n class=\"mb-2 text-xs font-semibold uppercase text-slate-400\"\r\n >\r\n {{ t(\"properties.add-segment\") }}\r\n </div>\r\n <div\r\n class=\"flex max-h-[min(24rem,calc(100vh-10rem))] flex-col gap-1 overflow-y-auto pr-1\"\r\n >\r\n @for (\r\n option of nextOperatorOptions();\r\n track option.token\r\n ) {\r\n <mt-button\r\n type=\"button\"\r\n [label]=\"getOperatorDisplayName(option.token)\"\r\n icon=\"general.plus\"\r\n [iconPos]=\"'end'\"\r\n size=\"small\"\r\n severity=\"secondary\"\r\n styleClass=\"w-full justify-start rounded-md px-2.5 py-1.5 text-left text-xs font-medium transition-colors text-slate-600 hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-700\"\r\n (onClick)=\"\r\n onAddSegmentSelection(\r\n option.token,\r\n nextOperatorPopover\r\n )\r\n \"\r\n ></mt-button>\r\n }\r\n </div>\r\n </div>\r\n </p-popover>\r\n </div>\r\n </div>\r\n\r\n <!-- Field Selection - Under Path -->\r\n <div\r\n class=\"flex items-center gap-2 border-t border-slate-200 pt-2 dark:border-slate-700\"\r\n >\r\n <span\r\n class=\"shrink-0 text-xs font-semibold uppercase tracking-wider text-slate-400\"\r\n >{{ t(\"properties.field\") }}</span\r\n >\r\n <div\r\n class=\"h-4 w-px shrink-0 bg-slate-200 dark:bg-slate-700\"\r\n ></div>\r\n @if (isPropertyLoading()) {\r\n <p-skeleton\r\n class=\"flex-1\"\r\n height=\"2.5rem\"\r\n styleClass=\"rounded-md\"\r\n />\r\n } @else {\r\n <mt-select-field\r\n class=\"flex-1\"\r\n [label]=\"''\"\r\n [filter]=\"true\"\r\n [hasPlaceholderPrefix]=\"false\"\r\n [placeholder]=\"t('properties.select')\"\r\n [(ngModel)]=\"propertyFieldKey\"\r\n [options]=\"propertyOptions()\"\r\n optionLabel=\"name\"\r\n optionValue=\"key\"\r\n [size]=\"'small'\"\r\n />\r\n }\r\n </div>\r\n\r\n <!-- Value Selection - Only for lookup / status / lookup-matrix fields -->\r\n @if (isLookupProperty()) {\r\n <div\r\n class=\"flex items-center gap-2 border-t border-slate-200 pt-2 dark:border-slate-700\"\r\n >\r\n <span\r\n class=\"shrink-0 text-xs font-semibold uppercase tracking-wider text-slate-400\"\r\n >{{ t(\"properties.value\") }}</span\r\n >\r\n <div\r\n class=\"h-4 w-px shrink-0 bg-slate-200 dark:bg-slate-700\"\r\n ></div>\r\n @if (isLookupItemsLoading()) {\r\n <p-skeleton\r\n class=\"flex-1\"\r\n height=\"2.5rem\"\r\n styleClass=\"rounded-md\"\r\n />\r\n } @else {\r\n <mt-select-field\r\n class=\"flex-1\"\r\n [label]=\"''\"\r\n [filter]=\"true\"\r\n [hasPlaceholderPrefix]=\"false\"\r\n [placeholder]=\"t('properties.select-value')\"\r\n [(ngModel)]=\"lookupValueKey\"\r\n [options]=\"lookupItems()\"\r\n optionLabel=\"name\"\r\n optionValue=\"key\"\r\n [size]=\"'small'\"\r\n />\r\n }\r\n </div>\r\n }\r\n <div\r\n class=\"w-full truncate rounded-lg bg-amber-100 px-3 py-2 text-sm font-semibold text-amber-700 shadow-sm hover:bg-amber-200 dark:bg-amber-900/30 dark:text-amber-300 dark:hover:bg-amber-900/50\"\r\n [mtTooltip]=\"\r\n '@' +\r\n propertyTablePath() +\r\n '::' +\r\n (selectedProperty()?.key ?? '...')\r\n \"\r\n tooltipPosition=\"top\"\r\n >\r\n @{{ propertyTablePath() }}::{{\r\n selectedProperty()?.key ?? \"...\"\r\n }}\r\n </div>\r\n <div class=\"flex justify-end gap-2\">\r\n @if (isLookupProperty()) {\r\n <mt-button\r\n type=\"button\"\r\n [label]=\"t('actions.insert-value')\"\r\n icon=\"general.plus\"\r\n severity=\"secondary\"\r\n [outlined]=\"true\"\r\n [disabled]=\"!canInsertLookupValue()\"\r\n (onClick)=\"insertSelectedLookupValue(insertBlock)\"\r\n ></mt-button>\r\n }\r\n <mt-button\r\n type=\"button\"\r\n [label]=\"t('actions.insert')\"\r\n icon=\"general.plus\"\r\n severity=\"primary\"\r\n [disabled]=\"!canInsertProperty()\"\r\n (onClick)=\"insertSelectedProperty(insertBlock)\"\r\n ></mt-button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n }\r\n </ng-template>\r\n </mt-formula-toolbar>\r\n }\r\n\r\n <!-- Editor Area -->\r\n <div class=\"p-3\">\r\n <div\r\n class=\"overflow-hidden rounded-lg border border-surface-200 bg-white dark:border-surface-700 dark:bg-surface-800\"\r\n >\r\n @if (showModeToggle()) {\r\n <div\r\n class=\"flex items-center justify-end border-b border-surface-200 px-3 py-2 dark:border-surface-700\"\r\n >\r\n <mt-toggle-field\r\n [label]=\"t('codeMode')\"\r\n labelPosition=\"end\"\r\n size=\"small\"\r\n [ngModel]=\"isCodeMode()\"\r\n [disabled]=\"isDisabled()\"\r\n (ngModelChange)=\"onModeToggle($event)\"\r\n />\r\n </div>\r\n }\r\n <div class=\"p-0\">\r\n @if (isCodeMode()) {\r\n <mt-formula-editor-code\r\n #formulaEditorCode\r\n [placeholder]=\"placeholder() || t('placeholder')\"\r\n [initialFormula]=\"expression()\"\r\n [disabled]=\"isDisabled()\"\r\n [borderless]=\"true\"\r\n [autocompleteProvider]=\"autocompleteProvider\"\r\n (formulaChange)=\"onCodeFormulaChange($event)\"\r\n (onFocus)=\"onEditorFocus()\"\r\n (onBlur)=\"onEditorBlur()\"\r\n />\r\n } @else {\r\n <mt-formula-editor\r\n #formulaEditor\r\n [placeholder]=\"placeholder() || t('placeholder')\"\r\n [initialTokens]=\"tokens()\"\r\n [disabled]=\"isDisabled()\"\r\n [borderless]=\"true\"\r\n (formulaChange)=\"onFormulaChange($event)\"\r\n (tokensChange)=\"onTokensChange($event)\"\r\n (onFocus)=\"onEditorFocus()\"\r\n (onBlur)=\"onEditorBlur()\"\r\n />\r\n }\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <!-- Status Bar - Pass data via inputs (pure component) -->\r\n @if (!hideStatusBar()) {\r\n <mt-formula-status-bar [validation]=\"validation()\" />\r\n }\r\n </div>\r\n</mt-card>\r\n" }]
|
|
1584
|
-
}], ctorParameters: () => [], propDecorators: { editor: [{ type: i0.ViewChild, args: ['formulaEditor', { isSignal: true }] }], codeEditor: [{ type: i0.ViewChild, args: ['formulaEditorCode', { isSignal: true }] }], propertiesByPath: [{ type: i0.Input, args: [{ isSignal: true, alias: "propertiesByPath", required: false }] }], levelSchemaId: [{ type: i0.Input, args: [{ isSignal: true, alias: "levelSchemaId", required: false }] }], moduleId: [{ type: i0.Input, args: [{ isSignal: true, alias: "moduleId", required: false }] }], contextKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "contextKey", required: false }] }], contextEntityTypeKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "contextEntityTypeKey", required: false }] }], templateId: [{ type: i0.Input, args: [{ isSignal: true, alias: "templateId", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], hideToolbar: [{ type: i0.Input, args: [{ isSignal: true, alias: "hideToolbar", required: false }] }], hideStatusBar: [{ type: i0.Input, args: [{ isSignal: true, alias: "hideStatusBar", required: false }] }], invalidWhenEmpty: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalidWhenEmpty", required: false }] }], toolbarTabs: [{ type: i0.Input, args: [{ isSignal: true, alias: "toolbarTabs", required: false }] }], functionCategories: [{ type: i0.Input, args: [{ isSignal: true, alias: "functionCategories", required: false }] }], operators: [{ type: i0.Input, args: [{ isSignal: true, alias: "operators", required: false }] }], codeOnly: [{ type: i0.Input, args: [{ isSignal: true, alias: "codeOnly", required: false }] }], builderOnly: [{ type: i0.Input, args: [{ isSignal: true, alias: "builderOnly", required: false }] }], valueMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "valueMode", required: false }] }], isProcessBuilder: [{ type: i0.Input, args: [{ isSignal: true, alias: "isProcessBuilder", required: false }] }], validationChange: [{ type: i0.Output, args: ["validationChange"] }], tokensChange: [{ type: i0.Output, args: ["tokensChange"] }] } });
|
|
1600
|
+
}], ctorParameters: () => [], propDecorators: { editor: [{ type: i0.ViewChild, args: ['formulaEditor', { isSignal: true }] }], codeEditor: [{ type: i0.ViewChild, args: ['formulaEditorCode', { isSignal: true }] }], propertiesByPath: [{ type: i0.Input, args: [{ isSignal: true, alias: "propertiesByPath", required: false }] }], levelSchemaId: [{ type: i0.Input, args: [{ isSignal: true, alias: "levelSchemaId", required: false }] }], moduleId: [{ type: i0.Input, args: [{ isSignal: true, alias: "moduleId", required: false }] }], contextKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "contextKey", required: false }] }], contextEntityTypeKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "contextEntityTypeKey", required: false }] }], templateId: [{ type: i0.Input, args: [{ isSignal: true, alias: "templateId", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], hideToolbar: [{ type: i0.Input, args: [{ isSignal: true, alias: "hideToolbar", required: false }] }], hideStatusBar: [{ type: i0.Input, args: [{ isSignal: true, alias: "hideStatusBar", required: false }] }], invalidWhenEmpty: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalidWhenEmpty", required: false }] }], toolbarTabs: [{ type: i0.Input, args: [{ isSignal: true, alias: "toolbarTabs", required: false }] }], functionCategories: [{ type: i0.Input, args: [{ isSignal: true, alias: "functionCategories", required: false }] }], operators: [{ type: i0.Input, args: [{ isSignal: true, alias: "operators", required: false }] }], codeOnly: [{ type: i0.Input, args: [{ isSignal: true, alias: "codeOnly", required: false }] }], builderOnly: [{ type: i0.Input, args: [{ isSignal: true, alias: "builderOnly", required: false }] }], valueMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "valueMode", required: false }] }], isProcessBuilder: [{ type: i0.Input, args: [{ isSignal: true, alias: "isProcessBuilder", required: false }] }], knownProperties: [{ type: i0.Input, args: [{ isSignal: true, alias: "knownProperties", required: false }] }], validationChange: [{ type: i0.Output, args: ["validationChange"] }], tokensChange: [{ type: i0.Output, args: ["tokensChange"] }] } });
|
|
1585
1601
|
|
|
1586
1602
|
/**
|
|
1587
1603
|
* Services barrel export
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"masterteam-formula-builder.mjs","sources":["../../../../packages/masterteam/formula-builder/src/lib/services/formula-validator.service.ts","../../../../packages/masterteam/formula-builder/src/lib/services/formula-context.service.ts","../../../../packages/masterteam/formula-builder/src/lib/services/formula-autocomplete.service.ts","../../../../packages/masterteam/formula-builder/src/lib/utils/formula-path-builder.ts","../../../../packages/masterteam/formula-builder/src/lib/utils/formula-function-categories.ts","../../../../packages/masterteam/formula-builder/src/lib/formula-builder.ts","../../../../packages/masterteam/formula-builder/src/lib/formula-builder.html","../../../../packages/masterteam/formula-builder/src/lib/services/index.ts","../../../../packages/masterteam/formula-builder/src/public-api.ts","../../../../packages/masterteam/formula-builder/src/masterteam-formula-builder.ts"],"sourcesContent":["/**\r\n * Formula Validator Service\r\n * Handles real-time validation via API\r\n */\r\n\r\nimport { Injectable, inject, signal } from '@angular/core';\r\nimport { HttpClient, HttpErrorResponse } from '@angular/common/http';\r\nimport { TranslocoService } from '@jsverse/transloco';\r\nimport {\r\n Observable,\r\n Subject,\r\n of,\r\n catchError,\r\n debounceTime,\r\n distinctUntilChanged,\r\n map,\r\n switchMap,\r\n tap,\r\n} from 'rxjs';\r\nimport {\r\n ValidationResult,\r\n ValidationRequest,\r\n ApiErrorResponse,\r\n} from '../models/validation-result.model';\r\n\r\ntype FormulaApiMode = 'default' | 'current-only';\r\ntype ValidationJob = ValidationRequest & { apiMode: FormulaApiMode };\r\n\r\n/** Default validation result for empty formulas */\r\nconst EMPTY_VALIDATION: ValidationResult = {\r\n isValid: true,\r\n errors: [],\r\n warnings: [],\r\n dependencies: [],\r\n complexity: 0,\r\n};\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class FormulaValidatorService {\r\n private readonly http = inject(HttpClient);\r\n private readonly transloco = inject(TranslocoService);\r\n private readonly apiUrl = 'formulas';\r\n\r\n /**\r\n * Build an error validation result.\r\n * Real validation messages come from the backend; this only supplies the\r\n * localized FE fallback used when the request fails or returns no message.\r\n */\r\n private buildErrorValidation(message?: string | null): ValidationResult {\r\n return {\r\n isValid: false,\r\n errors: [\r\n {\r\n message:\r\n message ||\r\n this.transloco.translate('formulaBuilder.errors.validationFailed'),\r\n line: 1,\r\n column: 1,\r\n severity: 'Error',\r\n },\r\n ],\r\n warnings: [],\r\n dependencies: [],\r\n complexity: 0,\r\n };\r\n }\r\n\r\n private getBaseUrl(mode: FormulaApiMode): string {\r\n return mode === 'current-only'\r\n ? `${this.apiUrl}/current-only`\r\n : this.apiUrl;\r\n }\r\n\r\n /** Debounce time in ms */\r\n private readonly DEBOUNCE_MS = 300;\r\n\r\n /** Current validation result */\r\n private readonly _validation = signal<ValidationResult>(EMPTY_VALIDATION);\r\n\r\n /** Loading state */\r\n private readonly _isValidating = signal(false);\r\n\r\n /** Validation subject for debouncing */\r\n private readonly validateSubject = new Subject<ValidationJob>();\r\n\r\n private unwrapResponse<T>(response: T | { data: T } | null): T | null {\r\n if (!response) return null;\r\n if (\r\n typeof response === 'object' &&\r\n response !== null &&\r\n 'data' in response\r\n ) {\r\n return (response as { data: T }).data ?? null;\r\n }\r\n return response as T;\r\n }\r\n\r\n /** Public signals */\r\n readonly validation = this._validation.asReadonly();\r\n readonly isValidating = this._isValidating.asReadonly();\r\n\r\n constructor() {\r\n this.setupValidationStream();\r\n }\r\n\r\n /** Setup debounced validation stream */\r\n private setupValidationStream(): void {\r\n this.validateSubject\r\n .pipe(\r\n debounceTime(this.DEBOUNCE_MS),\r\n distinctUntilChanged(\r\n (a, b) =>\r\n a.formula === b.formula &&\r\n a.levelSchemaId === b.levelSchemaId &&\r\n a.moduleId === b.moduleId &&\r\n a.templateId === b.templateId &&\r\n a.contextKey === b.contextKey &&\r\n a.apiMode === b.apiMode &&\r\n JSON.stringify(a.knownProperties) ===\r\n JSON.stringify(b.knownProperties),\r\n ),\r\n tap(() => this._isValidating.set(true)),\r\n switchMap((request) => this.callValidateApi(request)),\r\n )\r\n .subscribe((result) => {\r\n this._validation.set(result);\r\n this._isValidating.set(false);\r\n });\r\n }\r\n\r\n /** Validate formula (debounced) */\r\n validate(\r\n formula: string,\r\n knownProperties?: string[],\r\n levelSchemaId?: number,\r\n moduleId?: number,\r\n templateId?: number,\r\n apiMode: FormulaApiMode = 'default',\r\n contextKey?: string,\r\n ): void {\r\n // Handle empty formula\r\n if (!formula || formula.trim() === '') {\r\n this._validation.set(EMPTY_VALIDATION);\r\n return;\r\n }\r\n\r\n // Push to debounced stream\r\n this.validateSubject.next({\r\n formula,\r\n knownProperties,\r\n levelSchemaId,\r\n moduleId,\r\n templateId,\r\n apiMode,\r\n contextKey,\r\n });\r\n }\r\n\r\n /** Validate formula immediately (no debounce) */\r\n validateImmediate(\r\n formula: string,\r\n knownProperties?: string[],\r\n levelSchemaId?: number,\r\n moduleId?: number,\r\n templateId?: number,\r\n apiMode: FormulaApiMode = 'default',\r\n contextKey?: string,\r\n ): Observable<ValidationResult> {\r\n if (!formula || formula.trim() === '') {\r\n return of(EMPTY_VALIDATION);\r\n }\r\n\r\n this._isValidating.set(true);\r\n\r\n return this.callValidateApi({\r\n formula,\r\n knownProperties,\r\n levelSchemaId,\r\n moduleId,\r\n templateId,\r\n apiMode,\r\n contextKey,\r\n }).pipe(\r\n tap((result) => {\r\n this._validation.set(result);\r\n this._isValidating.set(false);\r\n }),\r\n );\r\n }\r\n\r\n /** Call validation API */\r\n private callValidateApi(\r\n request: ValidationJob,\r\n ): Observable<ValidationResult> {\r\n const { apiMode, ...payload } = request;\r\n return this.http\r\n .post<\r\n ValidationResult | { data: ValidationResult }\r\n >(`${this.getBaseUrl(apiMode)}/validate`, payload)\r\n .pipe(\r\n map(\r\n (response) =>\r\n this.unwrapResponse(response) ?? this.buildErrorValidation(),\r\n ),\r\n catchError((error: HttpErrorResponse) => {\r\n console.error('Validation API error:', error);\r\n\r\n // Prefer the backend-localized message; fall back to the FE string.\r\n const apiError = error.error as ApiErrorResponse;\r\n const message = apiError?.message ?? apiError?.error;\r\n\r\n return of(this.buildErrorValidation(message));\r\n }),\r\n );\r\n }\r\n\r\n /** Reset validation state */\r\n reset(): void {\r\n this._validation.set(EMPTY_VALIDATION);\r\n this._isValidating.set(false);\r\n }\r\n\r\n /** Get current validation result */\r\n getCurrentValidation(): ValidationResult {\r\n return this._validation();\r\n }\r\n\r\n /** Check if formula is valid */\r\n isValid(): boolean {\r\n return this._validation().isValid;\r\n }\r\n\r\n /** Get validation errors */\r\n getErrors() {\r\n return this._validation().errors;\r\n }\r\n\r\n /** Get validation warnings */\r\n getWarnings() {\r\n return this._validation().warnings;\r\n }\r\n\r\n /** Get formula dependencies */\r\n getDependencies() {\r\n return this._validation().dependencies;\r\n }\r\n\r\n /** Get formula complexity */\r\n getComplexity() {\r\n return this._validation().complexity;\r\n }\r\n}\r\n","import { Injectable, inject } from '@angular/core';\r\nimport { HttpClient } from '@angular/common/http';\r\nimport { Observable, of, catchError, tap, map } from 'rxjs';\r\n\r\nimport type {\r\n FormulaBuilderContextResponse,\r\n FormulaBuilderNextTokensResponse,\r\n FormulaPropertyDescriptor,\r\n FormulaPropertyItem,\r\n FormulaPropertyItemsResponse,\r\n} from '../models/formula-context.model';\r\n\r\ntype FormulaApiMode = 'default' | 'current-only';\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class FormulaContextService {\r\n private readonly http = inject(HttpClient);\r\n private readonly apiUrl = 'formulas';\r\n\r\n private getBaseUrl(mode: FormulaApiMode): string {\r\n return mode === 'current-only'\r\n ? `${this.apiUrl}/current-only`\r\n : this.apiUrl;\r\n }\r\n\r\n private buildLegacyContextUrl(\r\n schemaId: number,\r\n moduleId: number | undefined,\r\n contextEntityTypeKey: string | undefined,\r\n mode: FormulaApiMode,\r\n ): string {\r\n const params = new URLSearchParams();\r\n if (mode === 'default' && contextEntityTypeKey) {\r\n params.set('contextEntityTypeKey', contextEntityTypeKey);\r\n }\r\n if (moduleId !== undefined) {\r\n params.set('moduleId', moduleId.toString());\r\n }\r\n const queryString = params.toString();\r\n const query = queryString ? `?${queryString}` : '';\r\n return `${this.getBaseUrl(mode)}/builder/context/${schemaId}${query}`;\r\n }\r\n\r\n private unwrapResponse<T>(response: T | { data: T } | null): T | null {\r\n if (!response) return null;\r\n if (\r\n typeof response === 'object' &&\r\n response !== null &&\r\n 'data' in response\r\n ) {\r\n return (response as { data: T }).data ?? null;\r\n }\r\n return response as T;\r\n }\r\n\r\n private readonly contextCache = new Map<\r\n string,\r\n FormulaBuilderContextResponse\r\n >();\r\n private readonly propertiesCache = new Map<\r\n string,\r\n FormulaPropertyDescriptor[]\r\n >();\r\n private readonly nextTokensCache = new Map<\r\n string,\r\n FormulaBuilderNextTokensResponse\r\n >();\r\n private readonly propertyItemsCache = new Map<\r\n string,\r\n FormulaPropertyItem[]\r\n >();\r\n\r\n /**\r\n * Load the builder context. When `contextKey` is provided it is the canonical\r\n * context identifier (`Module:123` / `Level:5` / `Level:5/Module:10`) and the\r\n * context-key endpoint is used — this is the only way to address a standalone\r\n * module, which has no workspace/level schema id. Otherwise the legacy\r\n * schema-id path endpoint is used unchanged.\r\n */\r\n loadContext(\r\n schemaId: number | undefined,\r\n moduleId?: number,\r\n contextEntityTypeKey?: string,\r\n mode: FormulaApiMode = 'default',\r\n contextKey?: string,\r\n ): Observable<FormulaBuilderContextResponse | null> {\r\n if (!schemaId && !contextKey) return of(null);\r\n\r\n const cacheKey = `${mode}:${schemaId ?? ''}:${moduleId ?? ''}:${contextEntityTypeKey ?? ''}:${contextKey ?? ''}`;\r\n const cached = this.contextCache.get(cacheKey);\r\n if (cached) {\r\n return of(cached);\r\n }\r\n\r\n // Context-key endpoint is authoritative for the context kind/execution\r\n // profile; the backend resolves the schema and scope tokens from the key.\r\n const url = contextKey\r\n ? `${this.getBaseUrl(mode)}/builder/context?contextKey=${encodeURIComponent(contextKey)}`\r\n : this.buildLegacyContextUrl(\r\n schemaId as number,\r\n moduleId,\r\n contextEntityTypeKey,\r\n mode,\r\n );\r\n\r\n return this.http\r\n .get<\r\n FormulaBuilderContextResponse | { data: FormulaBuilderContextResponse }\r\n >(url)\r\n .pipe(\r\n map((response) => this.unwrapResponse(response)),\r\n tap((context) => {\r\n if (context) {\r\n this.contextCache.set(cacheKey, context);\r\n }\r\n }),\r\n catchError((error) => {\r\n console.warn('Failed to load formula builder context:', error);\r\n return of(null);\r\n }),\r\n );\r\n }\r\n\r\n getScopeProperties(\r\n schemaId: number,\r\n component: string | undefined,\r\n tablePath: string,\r\n moduleId?: number,\r\n mode: FormulaApiMode = 'default',\r\n contextKey?: string,\r\n ): Observable<FormulaPropertyDescriptor[]> {\r\n if (!schemaId || !tablePath) return of([]);\r\n\r\n const cacheKey = `${mode}:${schemaId}:${moduleId ?? ''}:${component}:${tablePath}:${contextKey ?? ''}`;\r\n const cached = this.propertiesCache.get(cacheKey);\r\n if (cached) {\r\n return of(cached);\r\n }\r\n\r\n const params = new URLSearchParams({\r\n schemaId: schemaId.toString(),\r\n tablePath,\r\n });\r\n if (component) {\r\n params.set('component', component);\r\n }\r\n if (moduleId !== undefined) {\r\n params.set('moduleId', moduleId.toString());\r\n }\r\n if (contextKey) {\r\n params.set('contextKey', contextKey);\r\n }\r\n\r\n return this.http\r\n .get<\r\n FormulaPropertyDescriptor[] | { data: FormulaPropertyDescriptor[] }\r\n >(`${this.getBaseUrl(mode)}/builder/properties?${params.toString()}`)\r\n .pipe(\r\n map((response) => this.unwrapResponse(response) ?? []),\r\n tap((response) => {\r\n this.propertiesCache.set(cacheKey, response);\r\n }),\r\n catchError((error) => {\r\n console.warn('Failed to load formula properties:', error);\r\n return of([]);\r\n }),\r\n );\r\n }\r\n\r\n getNextTokens(\r\n schemaId: number,\r\n component: string,\r\n tablePath: string,\r\n moduleId?: number,\r\n mode: FormulaApiMode = 'default',\r\n contextKey?: string,\r\n ): Observable<FormulaBuilderNextTokensResponse | null> {\r\n if (!schemaId || !component || !tablePath) return of(null);\r\n\r\n const cacheKey = `${mode}:${schemaId}:${moduleId ?? ''}:${component}:${tablePath}:${contextKey ?? ''}`;\r\n const cached = this.nextTokensCache.get(cacheKey);\r\n if (cached) {\r\n return of(cached);\r\n }\r\n\r\n const params = new URLSearchParams({\r\n schemaId: schemaId.toString(),\r\n component,\r\n tablePath,\r\n });\r\n if (moduleId !== undefined) {\r\n params.set('moduleId', moduleId.toString());\r\n }\r\n if (contextKey) {\r\n params.set('contextKey', contextKey);\r\n }\r\n\r\n return this.http\r\n .get<\r\n | FormulaBuilderNextTokensResponse\r\n | { data: FormulaBuilderNextTokensResponse }\r\n >(`${this.getBaseUrl(mode)}/builder/next-tokens?${params.toString()}`)\r\n .pipe(\r\n map((response) => this.unwrapResponse(response)),\r\n tap((payload) => {\r\n if (payload) {\r\n this.nextTokensCache.set(cacheKey, payload);\r\n }\r\n }),\r\n catchError((error) => {\r\n console.warn('Failed to load formula next tokens:', error);\r\n return of(null);\r\n }),\r\n );\r\n }\r\n\r\n /**\r\n * Selectable values for a lookup / status / lookup-matrix property.\r\n * The backend responds 400 (VAL_001) for any non-lookup property, which we\r\n * swallow into an empty list — callers gate the value picker on a known\r\n * lookup view type, so an empty result simply means \"no picker\".\r\n */\r\n getPropertyItems(\r\n propertyKey: string,\r\n mode: FormulaApiMode = 'default',\r\n ): Observable<FormulaPropertyItem[]> {\r\n if (!propertyKey) return of([]);\r\n\r\n const cacheKey = `${mode}:${propertyKey}`;\r\n const cached = this.propertyItemsCache.get(cacheKey);\r\n if (cached) {\r\n return of(cached);\r\n }\r\n\r\n return this.http\r\n .get<\r\n FormulaPropertyItemsResponse | { data: FormulaPropertyItemsResponse }\r\n >(`${this.getBaseUrl(mode)}/builder/property-items/${encodeURIComponent(propertyKey)}`)\r\n .pipe(\r\n map((response) => this.unwrapResponse(response)?.items ?? []),\r\n tap((items) => {\r\n this.propertyItemsCache.set(cacheKey, items);\r\n }),\r\n catchError((error) => {\r\n console.warn('Failed to load formula property items:', error);\r\n return of([]);\r\n }),\r\n );\r\n }\r\n}\r\n","import { Injectable, inject } from '@angular/core';\r\nimport { HttpClient } from '@angular/common/http';\r\nimport { Observable, of, catchError, map } from 'rxjs';\r\nimport type {\r\n AutocompleteRequest,\r\n AutocompleteResponse,\r\n} from '../models/validation-result.model';\r\n\r\ntype FormulaApiMode = 'default' | 'current-only';\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class FormulaAutocompleteService {\r\n private readonly http = inject(HttpClient);\r\n private readonly apiUrl = 'formulas';\r\n\r\n private getBaseUrl(mode: FormulaApiMode): string {\r\n return mode === 'current-only'\r\n ? `${this.apiUrl}/current-only`\r\n : this.apiUrl;\r\n }\r\n\r\n private unwrapResponse<T>(response: T | { data: T } | null): T | null {\r\n if (!response) return null;\r\n if (\r\n typeof response === 'object' &&\r\n response !== null &&\r\n 'data' in response\r\n ) {\r\n return (response as { data: T }).data ?? null;\r\n }\r\n return response as T;\r\n }\r\n\r\n getSuggestions(\r\n request: AutocompleteRequest,\r\n apiMode: FormulaApiMode = 'default',\r\n ): Observable<AutocompleteResponse | null> {\r\n if (!request) {\r\n return of(null);\r\n }\r\n\r\n const normalized: AutocompleteRequest = {\r\n ...request,\r\n formula: request.formula ?? '',\r\n };\r\n\r\n return this.http\r\n .post<\r\n AutocompleteResponse | { data: AutocompleteResponse }\r\n >(`${this.getBaseUrl(apiMode)}/autocomplete`, normalized)\r\n .pipe(\r\n map((response) => this.unwrapResponse(response)),\r\n catchError((error) => {\r\n console.warn('Autocomplete API error:', error);\r\n return of(null);\r\n }),\r\n );\r\n }\r\n}\r\n","import type {\r\n NextTokenAllowedValueItem,\r\n NextTokenRule,\r\n OperatorDescriptor,\r\n} from '../models/formula-context.model';\r\n\r\nexport type PathSegment = {\r\n operatorToken: string;\r\n value: string;\r\n};\r\n\r\nexport type SegmentMeta = PathSegment & {\r\n parameterKind?: string | null;\r\n requiresParameter: boolean;\r\n allowedValues: string[];\r\n allowedValueItems: NextTokenAllowedValueItem[];\r\n optional: boolean;\r\n canRemove: boolean;\r\n};\r\n\r\nexport type ResolveSegmentsParams = {\r\n scope: string;\r\n segments: PathSegment[];\r\n operators: OperatorDescriptor[];\r\n baseRule?: NextTokenRule;\r\n rulesByPath: Record<string, Record<string, NextTokenRule>>;\r\n};\r\n\r\nexport function resolveSegmentsMeta({\r\n scope,\r\n segments,\r\n operators,\r\n baseRule,\r\n rulesByPath,\r\n}: ResolveSegmentsParams): SegmentMeta[] {\r\n if (!scope || segments.length === 0) {\r\n return [];\r\n }\r\n\r\n let pathBefore = scope;\r\n let blocked = false;\r\n\r\n return segments.map((segment, index) => {\r\n const isBase = index === 0 && segment.operatorToken === scope;\r\n const operator = operators.find((op) => op.token === segment.operatorToken);\r\n const rule = blocked\r\n ? undefined\r\n : isBase\r\n ? baseRule\r\n : rulesByPath[pathBefore]?.[segment.operatorToken];\r\n const parameterKind =\r\n rule?.parameterKind ?? operator?.parameterKind ?? null;\r\n const requiresParameter =\r\n operator?.requiresParameter ?? Boolean(parameterKind);\r\n const allowedValues = getAllowedValues(rule);\r\n const allowedValueItems = getAllowedValueItems(rule);\r\n const normalizedValue = segment.value;\r\n const isComplete = !requiresParameter || Boolean(normalizedValue);\r\n\r\n if (!blocked && isComplete) {\r\n pathBefore = appendToPath(\r\n pathBefore,\r\n segment.operatorToken,\r\n normalizedValue,\r\n isBase,\r\n );\r\n } else {\r\n blocked = true;\r\n }\r\n\r\n return {\r\n operatorToken: segment.operatorToken,\r\n value: normalizedValue,\r\n parameterKind,\r\n requiresParameter,\r\n allowedValues,\r\n allowedValueItems,\r\n optional: !requiresParameter,\r\n canRemove: !isBase,\r\n };\r\n });\r\n}\r\n\r\nexport function buildInitialSegments(\r\n scope: string,\r\n operator: OperatorDescriptor | undefined,\r\n rule: NextTokenRule | undefined,\r\n): PathSegment[] {\r\n if (!operator || !scope) return [];\r\n const parameterKind = operator.parameterKind ?? rule?.parameterKind ?? null;\r\n const requiresParameter =\r\n operator.requiresParameter ?? Boolean(parameterKind);\r\n const shouldHaveSegment = Boolean(parameterKind) || requiresParameter;\r\n if (!shouldHaveSegment) return [];\r\n\r\n return [{ operatorToken: scope, value: '' }];\r\n}\r\n\r\nexport function buildTablePath(\r\n scope: string,\r\n segments: SegmentMeta[],\r\n baseOperator: OperatorDescriptor | undefined,\r\n stopOnIncomplete: boolean,\r\n): string {\r\n if (!scope) return '';\r\n\r\n if (\r\n stopOnIncomplete &&\r\n segments.length === 0 &&\r\n (baseOperator?.requiresParameter || baseOperator?.parameterKind)\r\n ) {\r\n return '';\r\n }\r\n\r\n let path = scope;\r\n for (let index = 0; index < segments.length; index += 1) {\r\n const segment = segments[index];\r\n const isBase = index === 0 && segment.operatorToken === scope;\r\n if (!isBase) {\r\n path += `.${segment.operatorToken}`;\r\n }\r\n if (segment.value) {\r\n path += `.${segment.value}`;\r\n } else if (segment.requiresParameter && stopOnIncomplete) {\r\n return '';\r\n }\r\n }\r\n\r\n return path;\r\n}\r\n\r\nexport function getAllowedValues(rule: NextTokenRule | undefined): string[] {\r\n return rule?.allowedValues ?? [];\r\n}\r\n\r\nexport function getAllowedValueItems(\r\n rule: NextTokenRule | undefined,\r\n): NextTokenAllowedValueItem[] {\r\n if (rule?.allowedValueItems?.length) {\r\n return rule.allowedValueItems;\r\n }\r\n\r\n return getAllowedValues(rule).map((value) => ({\r\n key: value,\r\n name: value,\r\n }));\r\n}\r\n\r\nfunction appendToPath(\r\n basePath: string,\r\n operatorToken: string,\r\n value: string,\r\n isBase: boolean,\r\n): string {\r\n if (isBase) {\r\n if (!value) return basePath;\r\n if (!basePath) return value;\r\n return `${basePath}.${value}`;\r\n }\r\n if (!basePath) {\r\n return value ? `${operatorToken}.${value}` : operatorToken;\r\n }\r\n const withOperator = `${basePath}.${operatorToken}`;\r\n return value ? `${withOperator}.${value}` : withOperator;\r\n}\r\n","import type { FunctionCategoryGroup } from '@masterteam/components/formula';\r\n\r\n/** Resolve a host override before API context and the package fallback catalog. */\r\nexport function resolveFormulaFunctionCategories(\r\n configured: FunctionCategoryGroup[],\r\n context: FunctionCategoryGroup[],\r\n fallback: FunctionCategoryGroup[],\r\n): FunctionCategoryGroup[] {\r\n if (configured.length > 0) return configured;\r\n if (context.length > 0) return context;\r\n return fallback;\r\n}\r\n","import {\r\n Component,\r\n forwardRef,\r\n input,\r\n output,\r\n signal,\r\n computed,\r\n inject,\r\n effect,\r\n untracked,\r\n OnDestroy,\r\n viewChild,\r\n} from '@angular/core';\r\nimport { CommonModule } from '@angular/common';\r\nimport { TranslocoDirective, TranslocoService } from '@jsverse/transloco';\r\nimport {\r\n ControlValueAccessor,\r\n FormsModule,\r\n NG_VALUE_ACCESSOR,\r\n} from '@angular/forms';\r\nimport { Card } from '@masterteam/components/card';\r\nimport { Button } from '@masterteam/components/button';\r\nimport { SelectField } from '@masterteam/components/select-field';\r\nimport { Tooltip } from '@masterteam/components/tooltip';\r\nimport { RadioCards, type RadioItem } from '@masterteam/components/radio-cards';\r\nimport { ToggleField } from '@masterteam/components/toggle-field';\r\nimport type { MTIcon } from '@masterteam/icons';\r\nimport { PopoverModule } from 'primeng/popover';\r\nimport { Skeleton } from 'primeng/skeleton';\r\nimport { Observable, of, switchMap } from 'rxjs';\r\n\r\n// Import pure UI components from @masterteam/components/formula\r\nimport {\r\n FormulaToolbar,\r\n FormulaEditor,\r\n FormulaEditorCode,\r\n FormulaStatusBar,\r\n type SmartBlock,\r\n type FormulaToken,\r\n type ToolbarTab,\r\n type FunctionCategoryGroup,\r\n type OperatorDefinition,\r\n DEFAULT_OPERATORS,\r\n VALIDATION_FUNCTION_CATEGORIES,\r\n createPropertyBlock,\r\n createLiteralBlock,\r\n serializeTokens,\r\n tokenizeFormulaTemplate,\r\n} from '@masterteam/components/formula';\r\n\r\n// Services are kept in formula-builder (backend logic)\r\nimport { FormulaValidatorService } from './services/formula-validator.service';\r\nimport { FormulaContextService } from './services/formula-context.service';\r\nimport { FormulaAutocompleteService } from './services/formula-autocomplete.service';\r\nimport type {\r\n ValidationResult,\r\n AutocompleteRequest,\r\n AutocompleteResponse,\r\n AutocompleteSuggestion,\r\n} from './models/validation-result.model';\r\nimport type {\r\n FormulaBuilderContextResponse,\r\n FormulaPropertyDescriptor,\r\n FormulaPropertyItem,\r\n NextTokenRule,\r\n OperatorDescriptor,\r\n} from './models/formula-context.model';\r\nimport type { FormulaBuilderValue } from './models/formula-builder-value.model';\r\nimport {\r\n buildInitialSegments,\r\n buildTablePath,\r\n getAllowedValues,\r\n resolveSegmentsMeta,\r\n type PathSegment,\r\n type SegmentMeta,\r\n} from './utils/formula-path-builder';\r\nimport { resolveFormulaFunctionCategories } from './utils/formula-function-categories';\r\n\r\nconst DEFAULT_SCOPE_ICON: MTIcon = 'general.placeholder';\r\nconst DEFAULT_TOOLBAR_TABS: readonly ToolbarTab[] = [\r\n 'functions',\r\n 'properties',\r\n 'operators',\r\n];\r\nconst PROPERTY_SCOPE_PRIORITY = [\r\n 'Current',\r\n 'Host',\r\n 'Parent',\r\n 'Children',\r\n 'Descendants',\r\n 'Modules',\r\n 'Schedule',\r\n] as const;\r\n\r\n/**\r\n * View types whose values come from a fixed item set served by\r\n * `GET /api/formulas/builder/property-items/{propertyKey}`. Matched after\r\n * lower-casing and stripping spaces/underscores/dashes so \"Lookup Matrix\",\r\n * \"lookup_matrix\", etc. all resolve. Mirrors the backend gate\r\n * (`PropertyItemsLookupSourceResolver.IsLookupBacked` plus `Status`); it\r\n * rejects any other view type with VAL_001 \"… is not a lookup, lookup matrix,\r\n * or status type\".\r\n */\r\nconst LOOKUP_VIEW_TYPES = new Set([\r\n 'lookup',\r\n 'lookupmultiselect',\r\n 'lookupmatrix',\r\n 'status',\r\n]);\r\n\r\nexport interface FormulaBuilderUiConfig {\r\n toolbarTabs?: readonly ToolbarTab[];\r\n codeOnly?: boolean;\r\n builderOnly?: boolean;\r\n valueMode?: 'object' | 'expression';\r\n hideToolbar?: boolean;\r\n hideStatusBar?: boolean;\r\n invalidWhenEmpty?: boolean;\r\n isProcessBuilder?: boolean;\r\n contextEntityTypeKey?: string;\r\n}\r\n\r\nconst SCOPE_ICON_MAP: Record<string, MTIcon> = {\r\n Current: 'map.marker-pin-01',\r\n Host: 'map.marker-pin-01',\r\n Level: 'map.marker-pin-01',\r\n Parent: 'arrow.arrow-up',\r\n Children: 'user.users-01',\r\n Descendants: 'custom.hierarchy-structure',\r\n Modules: 'file.folder-closed',\r\n Schedule: 'general.placeholder',\r\n};\r\n\r\n@Component({\r\n selector: 'mt-formula-builder',\r\n standalone: true,\r\n imports: [\r\n CommonModule,\r\n TranslocoDirective,\r\n FormsModule,\r\n Card,\r\n Button,\r\n SelectField,\r\n Tooltip,\r\n RadioCards,\r\n ToggleField,\r\n PopoverModule,\r\n Skeleton,\r\n FormulaToolbar,\r\n FormulaStatusBar,\r\n FormulaEditor,\r\n FormulaEditorCode,\r\n ],\r\n templateUrl: './formula-builder.html',\r\n host: {\r\n class: 'block',\r\n },\r\n providers: [\r\n {\r\n provide: NG_VALUE_ACCESSOR,\r\n useExisting: forwardRef(() => FormulaBuilder),\r\n multi: true,\r\n },\r\n ],\r\n})\r\nexport class FormulaBuilder implements ControlValueAccessor, OnDestroy {\r\n private readonly validatorService = inject(FormulaValidatorService);\r\n private readonly contextService = inject(FormulaContextService);\r\n private readonly autocompleteService = inject(FormulaAutocompleteService);\r\n private readonly transloco = inject(TranslocoService);\r\n\r\n /** Reference to the formula editor */\r\n private readonly editor = viewChild<FormulaEditor>('formulaEditor');\r\n private readonly codeEditor =\r\n viewChild<FormulaEditorCode>('formulaEditorCode');\r\n\r\n // ===== INPUTS =====\r\n\r\n /** Properties per table path (e.g., \"Current\", \"Children.Project\") */\r\n readonly propertiesByPath = input<\r\n Record<string, { key: string; name?: string }[]>\r\n >({});\r\n\r\n /** Level schema ID for validation context */\r\n readonly levelSchemaId = input<number>();\r\n\r\n /** Optional module ID when the formula is scoped inside a level-linked module */\r\n readonly moduleId = input<number>();\r\n\r\n /**\r\n * Canonical context identifier — `Module:{id}` / `Level:{id}` /\r\n * `Level:{id}/Module:{id}`. When set it is the source of truth for the\r\n * context kind and execution profile: it is the only way to address a\r\n * standalone module (no workspace/level schema), and the builder loads its\r\n * context, scopes, functions and validation through it. When omitted the\r\n * legacy `levelSchemaId` + `moduleId` flow is used unchanged.\r\n */\r\n readonly contextKey = input<string>();\r\n\r\n /** Optional current context entity key, e.g. LevelData or Risk */\r\n readonly contextEntityTypeKey = input<string>();\r\n\r\n /** Template ID for validation context */\r\n readonly templateId = input<number>();\r\n\r\n /** Placeholder text */\r\n readonly placeholder = input('');\r\n\r\n /** Hide the top toolbar */\r\n readonly hideToolbar = input(false);\r\n\r\n /** Hide the status bar */\r\n readonly hideStatusBar = input(false);\r\n\r\n /**\r\n * Treat an empty expression as invalid (a required formula). When true, an\r\n * empty formula reports `isValid: false` with a localized \"required\" error so\r\n * the status bar shows Invalid and `validationChange` emits an invalid state.\r\n * Default `false` keeps an empty formula valid, so other consumers that allow\r\n * empty formulas are unaffected.\r\n */\r\n readonly invalidWhenEmpty = input(false);\r\n\r\n /** Visible toolbar tabs */\r\n readonly toolbarTabs = input<readonly ToolbarTab[]>(DEFAULT_TOOLBAR_TABS);\r\n\r\n /** Optional host-owned function catalog. Takes precedence over API context. */\r\n readonly functionCategories = input<FunctionCategoryGroup[]>([]);\r\n\r\n /** Operators shown in the formula toolbar. */\r\n readonly operators = input<OperatorDefinition[]>(DEFAULT_OPERATORS);\r\n\r\n /** Force code editor mode and hide the mode toggle */\r\n readonly codeOnly = input(false);\r\n\r\n /** Keep the block builder active and hide the code-mode toggle. */\r\n readonly builderOnly = input(false);\r\n\r\n /** ControlValueAccessor output shape. `expression` emits the formula string. */\r\n readonly valueMode = input<'object' | 'expression'>('object');\r\n\r\n /** Use Process Builder current-only Formula Engine endpoints */\r\n readonly isProcessBuilder = input(false);\r\n\r\n // ===== OUTPUTS =====\r\n\r\n /** Emits validation result on change */\r\n readonly validationChange = output<ValidationResult>();\r\n\r\n /** Emits when tokens change */\r\n readonly tokensChange = output<FormulaToken[]>();\r\n\r\n // ===== STATE =====\r\n\r\n /** Editor focus state */\r\n readonly hasFocus = signal(false);\r\n\r\n /** Form control value */\r\n private readonly expressionValue = signal('');\r\n private readonly builderValue = signal<FormulaToken[]>([]);\r\n\r\n /** Tokens for the editor */\r\n readonly tokens = signal<FormulaToken[]>([]);\r\n readonly expression = computed(() => this.expressionValue());\r\n readonly resolvedContextEntityTypeKey = computed(() => {\r\n const value = this.contextEntityTypeKey();\r\n if (typeof value !== 'string') {\r\n return undefined;\r\n }\r\n\r\n const normalized = value.trim();\r\n return normalized.length > 0 ? normalized : undefined;\r\n });\r\n readonly isModuleContext = computed(() => {\r\n const contextType =\r\n this.resolvedContextEntityTypeKey() ??\r\n this.builderContext()?.contextEntityTypeKey;\r\n\r\n if (typeof contextType !== 'string') {\r\n return false;\r\n }\r\n\r\n const normalized = contextType.trim().toLowerCase();\r\n return normalized.length > 0 && normalized !== 'leveldata';\r\n });\r\n\r\n /** Trimmed canonical context key, or undefined when not supplied. */\r\n readonly resolvedContextKey = computed(() => {\r\n const value = this.contextKey();\r\n if (typeof value !== 'string') {\r\n return undefined;\r\n }\r\n const normalized = value.trim();\r\n return normalized.length > 0 ? normalized : undefined;\r\n });\r\n\r\n /**\r\n * True when authoring is current-only (a standalone module / `Module:{id}`).\r\n * Prefers the resolved context (execution profile / kind) once loaded, and\r\n * falls back to the shape of the context key before the context arrives so\r\n * navigation scopes never flash for a standalone module.\r\n */\r\n readonly isCurrentOnlyContext = computed(() => {\r\n const context = this.builderContext();\r\n if (context?.executionProfile) {\r\n return context.executionProfile === 'InlineCurrentOnly';\r\n }\r\n if (context?.contextKind === 'StandaloneModule') {\r\n return true;\r\n }\r\n const key = this.resolvedContextKey();\r\n return key ? /^module:/i.test(key) : false;\r\n });\r\n\r\n /**\r\n * True when the scope is addressed by the context key alone — a standalone\r\n * module (`Module:{id}`), whose id is not a level schema id, so sending\r\n * `levelSchemaId` / `moduleId` alongside it is rejected by the backend.\r\n * Current-only surfaces without a context key (process / escalation builder)\r\n * are still addressed by `levelSchemaId` + `moduleId`, and must keep sending\r\n * them or validation and autocomplete resolve against no schema at all.\r\n */\r\n readonly isAddressedByContextKey = computed(\r\n () => this.isCurrentOnlyContext() && Boolean(this.resolvedContextKey()),\r\n );\r\n\r\n /**\r\n * Scope tokens the backend allows for this context, or null when it doesn't\r\n * constrain them (legacy contexts). Used to gate the visible navigation.\r\n */\r\n readonly supportedScopeTokens = computed(() => {\r\n const tokens = this.builderContext()?.supportedScopeTokens;\r\n return tokens && tokens.length > 0 ? tokens : null;\r\n });\r\n\r\n /**\r\n * Schema id for downstream properties / next-token / validation calls. The\r\n * context response is authoritative (a standalone module resolves its own\r\n * `formulaSchemaId`); falls back to the `levelSchemaId` input for legacy\r\n * flows and before the context loads.\r\n */\r\n readonly effectiveSchemaId = computed(() => {\r\n const context = this.builderContext();\r\n return (\r\n context?.formulaSchemaId ?? context?.schemaId ?? this.levelSchemaId()\r\n );\r\n });\r\n\r\n readonly autocompleteProvider = (\r\n request: AutocompleteRequest,\r\n ): Observable<AutocompleteResponse | null> => {\r\n const apiMode = this.formulaApiMode();\r\n\r\n // Code-mode value picking: when the cursor sits on the right-hand side of a\r\n // comparison against a lookup property, surface that property's values as\r\n // suggestions (the builder/blocks editor has no autocomplete — it uses the\r\n // toolbar Value row instead). The BE autocomplete rejects this cursor\r\n // position, so we return values directly and skip that doomed call; when the\r\n // property turns out not to be a lookup we fall back to normal suggestions.\r\n const valueContext = this.detectLookupValueContext(\r\n request.formula ?? '',\r\n request.cursorPosition,\r\n );\r\n if (valueContext && this.shouldFetchLookupItems(valueContext.propertyKey)) {\r\n return this.contextService\r\n .getPropertyItems(valueContext.propertyKey, apiMode)\r\n .pipe(\r\n switchMap((items) =>\r\n items.length\r\n ? of(this.buildLookupValueResponse(items, valueContext))\r\n : this.fetchAutocomplete$(request, apiMode),\r\n ),\r\n );\r\n }\r\n\r\n return this.fetchAutocomplete$(request, apiMode);\r\n };\r\n\r\n private fetchAutocomplete$(\r\n request: AutocompleteRequest,\r\n apiMode: 'default' | 'current-only',\r\n ): Observable<AutocompleteResponse | null> {\r\n const addressedByContextKey = this.isAddressedByContextKey();\r\n return this.autocompleteService.getSuggestions(\r\n {\r\n ...request,\r\n // A standalone module is addressed only by its context key; a\r\n // workspace/level schema id alongside it is rejected by the backend.\r\n levelSchemaId: addressedByContextKey ? undefined : this.levelSchemaId(),\r\n moduleId: addressedByContextKey ? undefined : this.moduleId(),\r\n contextKey: this.resolvedContextKey(),\r\n contextEntityTypeKey:\r\n this.resolvedContextEntityTypeKey() ??\r\n this.builderContext()?.contextEntityTypeKey,\r\n },\r\n apiMode,\r\n );\r\n }\r\n\r\n /** Editor mode */\r\n readonly editorMode = signal<'builder' | 'code'>('builder');\r\n readonly isCodeMode = computed(() => this.editorMode() === 'code');\r\n readonly showModeToggle = computed(\r\n () => !this.codeOnly() && !this.builderOnly(),\r\n );\r\n readonly formulaApiMode = computed<'default' | 'current-only'>(() =>\r\n this.isProcessBuilder() ? 'current-only' : 'default',\r\n );\r\n readonly resolvedToolbarTabs = computed(() => {\r\n const tabs = this.toolbarTabs();\r\n return tabs.length > 0 ? tabs : DEFAULT_TOOLBAR_TABS;\r\n });\r\n\r\n /** ControlValueAccessor callbacks */\r\n private onChange: (value: FormulaBuilderValue | string) => void = () => {};\r\n private onTouched: () => void = () => {};\r\n\r\n /** Disabled state */\r\n private readonly isDisabled = signal(false);\r\n\r\n /**\r\n * Validation result surfaced to the status bar and the `validationChange`\r\n * output. Normally mirrors the validator service; when `invalidWhenEmpty` is\r\n * set and the expression is empty it reports an invalid \"required\" result so\r\n * the status bar (Invalid + message) and any host-side validity agree that an\r\n * empty formula is not acceptable here. See `invalidWhenEmpty`.\r\n */\r\n readonly validation = computed<ValidationResult>(() => {\r\n const base = this.validatorService.validation();\r\n if (this.invalidWhenEmpty() && this.expressionValue().trim().length === 0) {\r\n return {\r\n isValid: false,\r\n errors: [\r\n {\r\n message: this.transloco.translate('formulaBuilder.errors.required'),\r\n line: 1,\r\n column: 1,\r\n severity: 'Error',\r\n },\r\n ],\r\n warnings: [],\r\n dependencies: [],\r\n complexity: 0,\r\n };\r\n }\r\n return base;\r\n });\r\n\r\n /** Is validation in progress */\r\n readonly isValidating = this.validatorService.isValidating;\r\n\r\n /** Builder context from API */\r\n readonly builderContext = signal<FormulaBuilderContextResponse | null>(null);\r\n\r\n /** Function categories from the host, context API, or validation fallback. */\r\n readonly resolvedFunctionCategories = computed(() =>\r\n resolveFormulaFunctionCategories(\r\n this.functionCategories(),\r\n this.builderContext()?.functions?.categories ?? [],\r\n VALIDATION_FUNCTION_CATEGORIES,\r\n ),\r\n );\r\n\r\n /** Is builder context loading */\r\n readonly isContextLoading = signal(false);\r\n\r\n private contextRequestId = 0;\r\n\r\n /** Properties loaded from API */\r\n private readonly propertiesByPathApi = signal<\r\n Record<string, FormulaPropertyDescriptor[]>\r\n >({});\r\n\r\n /** Current property list loading path */\r\n private readonly propertyLoadingPath = signal<string | null>(null);\r\n\r\n constructor() {\r\n effect(() => {\r\n const shouldUseCodeMode = this.shouldUseCodeMode();\r\n\r\n if (this.builderOnly() && this.editorMode() !== 'builder') {\r\n this.editorMode.set('builder');\r\n return;\r\n }\r\n\r\n if (shouldUseCodeMode && this.editorMode() !== 'code') {\r\n this.editorMode.set('code');\r\n }\r\n });\r\n\r\n // Validate when formula changes\r\n effect(() => {\r\n const formula = this.expressionValue();\r\n const apiMode = this.formulaApiMode();\r\n const contextKey = this.resolvedContextKey();\r\n const addressedByContextKey = this.isAddressedByContextKey();\r\n if (formula && formula.trim().length > 0) {\r\n this.validatorService.validate(\r\n formula,\r\n undefined,\r\n addressedByContextKey ? undefined : this.levelSchemaId(),\r\n addressedByContextKey ? undefined : this.moduleId(),\r\n this.templateId(),\r\n apiMode,\r\n contextKey,\r\n );\r\n }\r\n });\r\n\r\n // Emit validation changes\r\n effect(() => {\r\n const validation = this.validation();\r\n this.validationChange.emit(validation);\r\n });\r\n\r\n // Re-resolve friendly property display labels once the property map loads.\r\n // Properties arrive asynchronously, so tokens built before they were ready\r\n // (e.g. hydrating an expression-only formula, or a code->blocks switch)\r\n // initially show raw keys. Display is cosmetic — the executable expression\r\n // (token.value) and validation are unchanged — so this only refreshes the\r\n // visual chips and the friendly preview. Reading builderValue untracked +\r\n // the identity guard in enrichTokenDisplays keeps this loop-safe.\r\n effect(() => {\r\n this.mergedPropertiesByPath();\r\n const current = untracked(() => this.builderValue());\r\n const enriched = this.enrichTokenDisplays(current);\r\n if (enriched !== current) {\r\n this.setBuilderTokens(enriched, { writeVisualEditor: true });\r\n this.emitValueChange();\r\n }\r\n });\r\n\r\n // Load builder context when schema or context key changes\r\n effect(() => {\r\n const schemaId = this.levelSchemaId();\r\n const moduleId = this.moduleId();\r\n const apiMode = this.formulaApiMode();\r\n const contextEntityTypeKey = this.resolvedContextEntityTypeKey();\r\n const contextKey = this.resolvedContextKey();\r\n\r\n // A standalone module has no level schema id — the context key alone is\r\n // enough to load its context.\r\n if (!schemaId && !contextKey) {\r\n this.builderContext.set(null);\r\n this.propertiesByPathApi.set({});\r\n this.nextTokenRulesByPath.set({});\r\n this.isContextLoading.set(false);\r\n return;\r\n }\r\n\r\n const requestId = ++this.contextRequestId;\r\n this.isContextLoading.set(true);\r\n this.propertiesByPathApi.set({});\r\n this.nextTokenRulesByPath.set({});\r\n this.contextService\r\n .loadContext(\r\n schemaId,\r\n moduleId,\r\n contextEntityTypeKey,\r\n apiMode,\r\n contextKey,\r\n )\r\n .subscribe((context) => {\r\n if (requestId !== this.contextRequestId) {\r\n return;\r\n }\r\n\r\n this.builderContext.set(context);\r\n this.isContextLoading.set(false);\r\n\r\n if (!context) {\r\n return;\r\n }\r\n\r\n if (context.currentProperties?.length) {\r\n this.propertiesByPathApi.update((current) => ({\r\n ...current,\r\n Current: context.currentProperties,\r\n }));\r\n }\r\n });\r\n });\r\n\r\n // Load the value set of the selected field when it is a lookup-style\r\n // property (lookup / lookup matrix / status). Resets the picked value\r\n // whenever the field changes; a stale-request guard keeps the latest pick.\r\n effect(() => {\r\n const property = this.selectedProperty();\r\n const isLookup = this.isLookupProperty();\r\n const apiMode = this.formulaApiMode();\r\n\r\n this.lookupValueKey.set('');\r\n\r\n if (!property || !isLookup) {\r\n this.lookupItems.set([]);\r\n this.isLookupItemsLoading.set(false);\r\n return;\r\n }\r\n\r\n const requestId = ++this.lookupItemsRequestId;\r\n this.isLookupItemsLoading.set(true);\r\n this.lookupItems.set([]);\r\n this.contextService\r\n .getPropertyItems(property.key, apiMode)\r\n .subscribe((items) => {\r\n if (requestId !== this.lookupItemsRequestId) {\r\n return;\r\n }\r\n this.lookupItems.set(items);\r\n this.isLookupItemsLoading.set(false);\r\n });\r\n });\r\n\r\n // Ensure selected scope exists in available options\r\n effect(() => {\r\n const scopes = this.availableScopes();\r\n if (scopes.length === 0) return;\r\n const current = this.propertyScope();\r\n if (!scopes.some((scope) => scope.key === current)) {\r\n this.setPropertyScope(scopes[0].key);\r\n }\r\n });\r\n\r\n // Fetch properties for the selected table path\r\n effect(() => {\r\n const schemaId = this.effectiveSchemaId();\r\n const contextKey = this.resolvedContextKey();\r\n const moduleId = contextKey ? undefined : this.moduleId();\r\n const apiMode = this.formulaApiMode();\r\n const tablePath = this.resolvedTablePath();\r\n const component = this.propertiesComponent();\r\n const context = this.builderContext();\r\n\r\n if (!schemaId || !tablePath || !context) {\r\n this.propertyLoadingPath.set(null);\r\n return;\r\n }\r\n\r\n const existing = this.propertiesByPathApi()[tablePath];\r\n if (existing !== undefined) {\r\n this.propertyLoadingPath.set(null);\r\n return;\r\n }\r\n\r\n this.propertyLoadingPath.set(tablePath);\r\n this.contextService\r\n .getScopeProperties(\r\n schemaId,\r\n component,\r\n tablePath,\r\n moduleId,\r\n apiMode,\r\n contextKey,\r\n )\r\n .subscribe((props) => {\r\n this.propertiesByPathApi.update((current) => ({\r\n ...current,\r\n [tablePath]: props ?? [],\r\n }));\r\n if (this.propertyLoadingPath() === tablePath) {\r\n this.propertyLoadingPath.set(null);\r\n }\r\n });\r\n });\r\n\r\n // Fetch next-token rules for the selected base scope so the first\r\n // parameter popover can use localized allowedValueItems.\r\n effect(() => {\r\n const schemaId = this.effectiveSchemaId();\r\n const contextKey = this.resolvedContextKey();\r\n const moduleId = contextKey ? undefined : this.moduleId();\r\n const isProcessBuilder = this.isProcessBuilder();\r\n const scope = this.propertyScope();\r\n const component = this.propertiesComponent();\r\n const context = this.builderContext();\r\n const operator = this.baseOperator();\r\n const contextRule = this.contextBaseRule();\r\n const needsParameter =\r\n Boolean(operator?.parameterKind) ||\r\n Boolean(operator?.requiresParameter) ||\r\n Boolean(contextRule?.parameterKind);\r\n\r\n if (\r\n isProcessBuilder ||\r\n !schemaId ||\r\n !scope ||\r\n !component ||\r\n !context ||\r\n !needsParameter\r\n ) {\r\n return;\r\n }\r\n\r\n if (this.nextTokenRulesByPath()[scope]) return;\r\n\r\n this.contextService\r\n .getNextTokens(\r\n schemaId,\r\n component,\r\n scope,\r\n moduleId,\r\n 'default',\r\n contextKey,\r\n )\r\n .subscribe((response) => {\r\n if (!response) return;\r\n this.nextTokenRulesByPath.update((current) => ({\r\n ...current,\r\n [scope]: response.nextTokenRules ?? {},\r\n }));\r\n });\r\n });\r\n\r\n // Fetch next-token rules for the current table path\r\n effect(() => {\r\n const schemaId = this.effectiveSchemaId();\r\n const contextKey = this.resolvedContextKey();\r\n const moduleId = contextKey ? undefined : this.moduleId();\r\n const isProcessBuilder = this.isProcessBuilder();\r\n const tablePath = this.resolvedTablePath();\r\n const component = this.propertiesComponent();\r\n\r\n if (isProcessBuilder || !schemaId || !tablePath || !component) return;\r\n\r\n if (this.nextTokenRulesByPath()[tablePath]) return;\r\n\r\n this.contextService\r\n .getNextTokens(\r\n schemaId,\r\n component,\r\n tablePath,\r\n moduleId,\r\n 'default',\r\n contextKey,\r\n )\r\n .subscribe((response) => {\r\n if (!response) return;\r\n this.nextTokenRulesByPath.update((current) => ({\r\n ...current,\r\n [tablePath]: response.nextTokenRules ?? {},\r\n }));\r\n });\r\n });\r\n\r\n // Keep base segment in sync with scope metadata\r\n effect(() => {\r\n const scope = this.propertyScope();\r\n const operator = this.baseOperator();\r\n const shouldHaveSegment =\r\n Boolean(operator?.parameterKind) ||\r\n Boolean(operator?.requiresParameter);\r\n const segments = this.propertyPathSegments();\r\n const hasBase = segments[0]?.operatorToken === scope;\r\n\r\n if (shouldHaveSegment && !hasBase) {\r\n this.propertyPathSegments.set(\r\n buildInitialSegments(scope, operator, this.baseRule()),\r\n );\r\n return;\r\n }\r\n\r\n if (!shouldHaveSegment && hasBase) {\r\n this.propertyPathSegments.set(segments.slice(1));\r\n }\r\n });\r\n\r\n // Normalize segment values when allowed values change\r\n effect(() => {\r\n const meta = this.pathSegments();\r\n const segments = this.propertyPathSegments();\r\n if (meta.length !== segments.length) return;\r\n\r\n let changed = false;\r\n const next = segments.map((segment, index) => {\r\n const normalized = meta[index]?.value ?? segment.value;\r\n if (segment.value !== normalized) {\r\n changed = true;\r\n return { ...segment, value: normalized };\r\n }\r\n return segment;\r\n });\r\n\r\n if (changed) {\r\n this.propertyPathSegments.set(next);\r\n }\r\n });\r\n\r\n // Ensure selected field exists in current options\r\n effect(() => {\r\n const options = this.propertyOptions();\r\n const current = this.propertyFieldKey();\r\n\r\n if (options.length === 0) {\r\n if (current) this.propertyFieldKey.set('');\r\n return;\r\n }\r\n\r\n if (current && !options.some((prop) => prop.key === current)) {\r\n this.propertyFieldKey.set('');\r\n }\r\n });\r\n }\r\n\r\n ngOnDestroy(): void {\r\n this.validatorService.reset();\r\n }\r\n\r\n // ===== ControlValueAccessor =====\r\n\r\n writeValue(value: FormulaBuilderValue | string | null): void {\r\n if (!value) {\r\n this.expressionValue.set('');\r\n this.applyFormulaValue([], '', this.shouldUseCodeMode());\r\n this.validatorService.reset();\r\n return;\r\n }\r\n\r\n if (typeof value === 'string') {\r\n const expression = value;\r\n const builder = this.rebuildBuilderFromExpression(expression);\r\n this.expressionValue.set(expression);\r\n this.applyFormulaValue(builder, expression, this.shouldUseCodeMode());\r\n return;\r\n }\r\n\r\n const inputBuilder = Array.isArray(value.builder) ? value.builder : [];\r\n const expression = this.resolveExpressionValue(\r\n value.expression ?? '',\r\n inputBuilder,\r\n );\r\n const builder =\r\n inputBuilder.length > 0\r\n ? this.enrichTokenDisplays(inputBuilder)\r\n : this.rebuildBuilderFromExpression(expression);\r\n this.expressionValue.set(expression);\r\n\r\n if (this.shouldUseCodeMode()) {\r\n this.applyFormulaValue(builder, expression, true);\r\n return;\r\n }\r\n\r\n this.applyFormulaValue(builder, expression, false);\r\n }\r\n\r\n registerOnChange(fn: (value: FormulaBuilderValue | string) => void): void {\r\n this.onChange = fn;\r\n }\r\n\r\n registerOnTouched(fn: () => void): void {\r\n this.onTouched = fn;\r\n }\r\n\r\n setDisabledState(isDisabled: boolean): void {\r\n this.isDisabled.set(isDisabled);\r\n }\r\n\r\n /** Handle formula change from editor */\r\n onFormulaChange(newFormula: string): void {\r\n this.expressionValue.set(newFormula);\r\n this.emitValueChange();\r\n }\r\n\r\n /** Handle formula change from code editor */\r\n onCodeFormulaChange(newFormula: string): void {\r\n this.expressionValue.set(newFormula);\r\n this.syncBuilderFromExpression(newFormula, {\r\n emitTokensChange: true,\r\n writeVisualEditor: false,\r\n });\r\n this.emitValueChange();\r\n }\r\n\r\n /** Handle block insert from toolbar */\r\n onBlockInsert(block: SmartBlock): void {\r\n if (this.isDisabled()) return;\r\n if (this.isCodeMode()) {\r\n const editor = this.codeEditor();\r\n if (editor) {\r\n editor.addBlock(block);\r\n }\r\n return;\r\n }\r\n const editor = this.editor();\r\n if (editor) {\r\n editor.addBlock(block);\r\n }\r\n }\r\n\r\n /** Handle tokens change */\r\n onTokensChange(newTokens: FormulaToken[]): void {\r\n this.setBuilderTokens(newTokens, {\r\n emitTokensChange: true,\r\n writeVisualEditor: false,\r\n });\r\n this.emitValueChange();\r\n }\r\n\r\n onEditorFocus(): void {\r\n this.hasFocus.set(true);\r\n }\r\n\r\n onEditorBlur(): void {\r\n this.hasFocus.set(false);\r\n this.onTouched();\r\n }\r\n\r\n private emitValueChange(): void {\r\n if (this.valueMode() === 'expression') {\r\n this.onChange(this.expressionValue());\r\n return;\r\n }\r\n\r\n this.onChange({\r\n expression: this.expressionValue(),\r\n builder: this.builderValue(),\r\n });\r\n }\r\n\r\n onModeToggle(value: boolean): void {\r\n if (this.isDisabled() || this.codeOnly() || this.builderOnly()) {\r\n return;\r\n }\r\n const nextMode: 'builder' | 'code' = value ? 'code' : 'builder';\r\n this.setEditorMode(nextMode);\r\n }\r\n\r\n private setEditorMode(mode: 'builder' | 'code'): void {\r\n if (this.editorMode() === mode) return;\r\n\r\n if (mode === 'code') {\r\n this.enterCodeMode();\r\n return;\r\n }\r\n\r\n this.exitCodeMode();\r\n }\r\n\r\n private enterCodeMode(): void {\r\n const editor = this.editor();\r\n if (editor) {\r\n const formula = editor.serialize();\r\n this.expressionValue.set(formula);\r\n this.emitValueChange();\r\n }\r\n this.editorMode.set('code');\r\n }\r\n\r\n private exitCodeMode(): void {\r\n this.editorMode.set('builder');\r\n // An unchanged expression already has tokens with friendly lookup labels.\r\n // Rebuilding those on every toggle would discard that display metadata.\r\n if (serializeTokens(this.builderValue()) !== this.expressionValue()) {\r\n this.syncBuilderFromExpression(this.expressionValue(), {\r\n emitTokensChange: true,\r\n writeVisualEditor: true,\r\n });\r\n }\r\n this.emitValueChange();\r\n }\r\n\r\n // ===== PUBLIC METHODS =====\r\n\r\n /** Clear the formula */\r\n clear(): void {\r\n this.expressionValue.set('');\r\n this.applyFormulaValue([], '', this.shouldUseCodeMode());\r\n this.validatorService.reset();\r\n this.emitValueChange();\r\n }\r\n\r\n private shouldUseCodeMode(): boolean {\r\n return this.codeOnly() && !this.builderOnly();\r\n }\r\n\r\n private resolveExpressionValue(\r\n expression: string,\r\n builder: FormulaToken[],\r\n ): string {\r\n if (expression.trim().length > 0) {\r\n return expression;\r\n }\r\n return builder.length > 0 ? serializeTokens(builder) : '';\r\n }\r\n\r\n private applyFormulaValue(\r\n builder: FormulaToken[],\r\n expression: string,\r\n useCodeMode: boolean,\r\n ): void {\r\n this.setBuilderTokens(builder, { writeVisualEditor: true });\r\n\r\n const codeEditor = this.codeEditor();\r\n if (codeEditor) {\r\n codeEditor.writeValue(expression);\r\n }\r\n\r\n if (useCodeMode) {\r\n this.editorMode.set('code');\r\n return;\r\n }\r\n\r\n this.editorMode.set('builder');\r\n }\r\n\r\n private rebuildBuilderFromExpression(expression: string): FormulaToken[] {\r\n const normalized = expression.trim();\r\n return this.enrichTokenDisplays(\r\n normalized ? tokenizeFormulaTemplate(normalized) : [],\r\n );\r\n }\r\n\r\n /**\r\n * Resolve friendly display labels on property tokens from the loaded property\r\n * map (table path -> [{ key, name }]). This lets the visual builder render\r\n * \"Start Date\" instead of the raw \"@Current::dema_qa_portfolio_startdate\" key\r\n * after a code->blocks switch or when hydrating an expression-only formula.\r\n * Pure and loop-safe: returns the SAME array reference when nothing changed,\r\n * and only touches `display` — never `value` — so the executable expression\r\n * and validation are unaffected.\r\n */\r\n private enrichTokenDisplays(tokens: FormulaToken[]): FormulaToken[] {\r\n if (tokens.length === 0) {\r\n return tokens;\r\n }\r\n const byPath = this.mergedPropertiesByPath();\r\n let changed = false;\r\n const next = tokens.map((token) => {\r\n if (token.type !== 'property' || !token.value.startsWith('@')) {\r\n return token;\r\n }\r\n const separator = token.value.lastIndexOf('::');\r\n if (separator < 0) {\r\n return token;\r\n }\r\n const path = token.value.slice(1, separator);\r\n const key = token.value.slice(separator + 2);\r\n const match = byPath[path]?.find((prop) => prop.key === key);\r\n const display =\r\n match?.name?.trim() || match?.viewTypeName?.display || token.display;\r\n if (display && display !== token.display) {\r\n changed = true;\r\n return { ...token, display };\r\n }\r\n return token;\r\n });\r\n return changed ? next : tokens;\r\n }\r\n\r\n private syncBuilderFromExpression(\r\n expression: string,\r\n options?: {\r\n emitTokensChange?: boolean;\r\n writeVisualEditor?: boolean;\r\n },\r\n ): void {\r\n this.setBuilderTokens(this.rebuildBuilderFromExpression(expression), {\r\n emitTokensChange: options?.emitTokensChange,\r\n writeVisualEditor: options?.writeVisualEditor,\r\n });\r\n }\r\n\r\n private setBuilderTokens(\r\n builder: FormulaToken[],\r\n options?: {\r\n emitTokensChange?: boolean;\r\n writeVisualEditor?: boolean;\r\n },\r\n ): void {\r\n this.builderValue.set(builder);\r\n this.tokens.set(builder);\r\n\r\n if (options?.writeVisualEditor ?? true) {\r\n const editor = this.editor();\r\n if (editor) {\r\n editor.writeValue(builder);\r\n }\r\n }\r\n\r\n if (options?.emitTokensChange) {\r\n this.tokensChange.emit(builder);\r\n }\r\n }\r\n\r\n // ===== PROPERTY COMPOSER =====\r\n\r\n readonly propertyScope = signal<string>('');\r\n\r\n readonly propertyPathSegments = signal<PathSegment[]>([]);\r\n\r\n readonly propertyFieldKey = signal('');\r\n\r\n private readonly nextTokenRulesByPath = signal<\r\n Record<string, Record<string, NextTokenRule>>\r\n >({});\r\n\r\n readonly contextOperators = computed<OperatorDescriptor[]>(() => {\r\n return this.builderContext()?.schemaDescriptor?.operators ?? [];\r\n });\r\n\r\n readonly baseOperator = computed(() =>\r\n this.contextOperators().find((op) => op.token === this.propertyScope()),\r\n );\r\n\r\n readonly contextBaseRule = computed(() => {\r\n const scope = this.propertyScope();\r\n return this.builderContext()?.schemaDescriptor?.nextTokenRules?.[scope];\r\n });\r\n\r\n readonly baseRule = computed(() => {\r\n const scope = this.propertyScope();\r\n return (\r\n this.nextTokenRulesByPath()[scope]?.[scope] ?? this.contextBaseRule()\r\n );\r\n });\r\n\r\n readonly availableScopes = computed(() => {\r\n // When the backend constrains scope tokens (e.g. a standalone module allows\r\n // only `Current`), never surface a navigation scope outside that set.\r\n const allowedTokens = this.supportedScopeTokens();\r\n const isAllowedScope = (token: string) =>\r\n !allowedTokens || allowedTokens.includes(token);\r\n\r\n const operators = this.contextOperators();\r\n if (operators.length === 0) {\r\n const propertiesByPath = this.mergedPropertiesByPath();\r\n return Object.keys(propertiesByPath)\r\n .filter(\r\n (path) =>\r\n (propertiesByPath[path] ?? []).length > 0 && isAllowedScope(path),\r\n )\r\n .map((path) => ({\r\n key: path,\r\n label: `@${path}`,\r\n requiresParam: false,\r\n optional: true,\r\n }));\r\n }\r\n const baseRules =\r\n this.builderContext()?.schemaDescriptor?.nextTokenRules ?? {};\r\n const priority = new Map<string, number>(\r\n PROPERTY_SCOPE_PRIORITY.map((token, index) => [token, index]),\r\n );\r\n const scopedOperators = operators.filter(\r\n (operator) =>\r\n operator.token.trim().length > 0 && isAllowedScope(operator.token),\r\n );\r\n\r\n return [...scopedOperators]\r\n .filter((operator) => {\r\n const parameterKind =\r\n baseRules[operator.token]?.parameterKind ?? operator.parameterKind;\r\n const requiresParameter =\r\n operator.requiresParameter ?? Boolean(parameterKind);\r\n\r\n return (\r\n (!parameterKind && !requiresParameter) ||\r\n getAllowedValues(baseRules[operator.token]).length > 0\r\n );\r\n })\r\n .sort((a, b) => {\r\n const aPriority = priority.get(a.token) ?? Number.MAX_SAFE_INTEGER;\r\n const bPriority = priority.get(b.token) ?? Number.MAX_SAFE_INTEGER;\r\n if (aPriority !== bPriority) {\r\n return aPriority - bPriority;\r\n }\r\n return a.token.localeCompare(b.token);\r\n })\r\n .map((operator) => ({\r\n key: operator.token,\r\n label: `@${operator.token}`,\r\n requiresParam: operator.requiresParameter ?? false,\r\n optional: !operator.requiresParameter,\r\n }));\r\n });\r\n\r\n /** Radio card options for scope selection */\r\n readonly scopeOptions = computed<RadioItem[]>(() =>\r\n this.availableScopes().map((scope) => ({\r\n id: scope.key,\r\n name: this.getOperatorDisplayName(scope.key),\r\n icon: SCOPE_ICON_MAP[scope.key] ?? DEFAULT_SCOPE_ICON,\r\n })),\r\n );\r\n\r\n /** Handle scope selection from radio cards */\r\n onScopeChange(item: RadioItem): void {\r\n this.setPropertyScope(String(item.id));\r\n }\r\n\r\n readonly pathSegments = computed<SegmentMeta[]>(() => {\r\n const scope = this.propertyScope();\r\n return resolveSegmentsMeta({\r\n scope,\r\n segments: this.propertyPathSegments(),\r\n operators: this.contextOperators(),\r\n baseRule: this.baseRule(),\r\n rulesByPath: this.nextTokenRulesByPath(),\r\n });\r\n });\r\n\r\n readonly isDirectAccess = computed(() => {\r\n const operator = this.baseOperator();\r\n const needsParameter =\r\n Boolean(operator?.parameterKind) || Boolean(operator?.requiresParameter);\r\n return !needsParameter && this.pathSegments().length === 0;\r\n });\r\n\r\n readonly propertyTablePath = computed(() =>\r\n buildTablePath(\r\n this.propertyScope(),\r\n this.pathSegments(),\r\n this.baseOperator(),\r\n false,\r\n ),\r\n );\r\n\r\n readonly resolvedTablePath = computed(() =>\r\n buildTablePath(\r\n this.propertyScope(),\r\n this.pathSegments(),\r\n this.baseOperator(),\r\n true,\r\n ),\r\n );\r\n\r\n readonly currentNextTokenRules = computed(() => {\r\n const path = this.resolvedTablePath();\r\n if (!path) return {};\r\n return this.nextTokenRulesByPath()[path] ?? {};\r\n });\r\n\r\n readonly nextOperatorOptions = computed(() => {\r\n const rules = this.currentNextTokenRules();\r\n const operators = this.contextOperators();\r\n return Object.keys(rules)\r\n .map((token) => {\r\n const rule = rules[token];\r\n const operator = operators.find((item) => item.token === token);\r\n const parameterKind =\r\n rule?.parameterKind ?? operator?.parameterKind ?? null;\r\n const requiresParameter =\r\n operator?.requiresParameter ?? Boolean(parameterKind);\r\n const allowedValues = getAllowedValues(rule);\r\n return {\r\n token,\r\n rule,\r\n requiresParameter,\r\n allowedValues,\r\n };\r\n })\r\n .filter(\r\n (option) =>\r\n option.allowedValues.length > 0 || !option.requiresParameter,\r\n );\r\n });\r\n\r\n readonly canAddNextSegment = computed(() => {\r\n if (this.nextOperatorOptions().length === 0) return false;\r\n const segments = this.pathSegments();\r\n if (segments.length === 0 || !segments[0].value) {\r\n return false;\r\n }\r\n return segments.every(\r\n (segment) => !segment.requiresParameter || Boolean(segment.value),\r\n );\r\n });\r\n\r\n readonly propertiesComponent = computed(() => {\r\n return this.builderContext()?.contextEntityTypeKey;\r\n });\r\n\r\n readonly mergedPropertiesByPath = computed<\r\n Record<string, FormulaPropertyDescriptor[]>\r\n >(() => {\r\n const merged: Record<string, FormulaPropertyDescriptor[]> = {\r\n ...this.propertiesByPath(),\r\n };\r\n const apiProps = this.propertiesByPathApi();\r\n Object.entries(apiProps).forEach(([path, props]) => {\r\n if (props && props.length > 0) {\r\n merged[path] = props;\r\n }\r\n });\r\n return merged;\r\n });\r\n\r\n readonly isPropertyLoading = computed(() => {\r\n const path = this.resolvedTablePath();\r\n return Boolean(path) && this.propertyLoadingPath() === path;\r\n });\r\n\r\n readonly propertyOptions = computed(() => {\r\n const path = this.resolvedTablePath();\r\n if (!path) return [];\r\n const byPath = this.mergedPropertiesByPath()[path];\r\n const list = byPath && byPath.length > 0 ? byPath : [];\r\n return list.map((prop) => ({\r\n key: prop.key,\r\n name: prop.name?.trim() || prop.viewTypeName?.display || prop.key,\r\n viewType: prop.viewType,\r\n }));\r\n });\r\n\r\n readonly selectedProperty = computed(() => {\r\n const key = this.propertyFieldKey();\r\n return this.propertyOptions().find((prop) => prop.key === key) ?? null;\r\n });\r\n\r\n /** Selectable values of the chosen lookup/status/lookup-matrix property. */\r\n readonly lookupItems = signal<FormulaPropertyItem[]>([]);\r\n\r\n /** Whether the property-items request is in flight. */\r\n readonly isLookupItemsLoading = signal(false);\r\n\r\n /** Currently selected lookup value key (the form inserted into the formula). */\r\n readonly lookupValueKey = signal('');\r\n\r\n private lookupItemsRequestId = 0;\r\n\r\n /** True when the selected field draws its values from a fixed lookup set. */\r\n readonly isLookupProperty = computed(() => {\r\n const viewType = this.selectedProperty()?.viewType;\r\n if (!viewType) return false;\r\n return LOOKUP_VIEW_TYPES.has(viewType.toLowerCase().replace(/[\\s_-]/g, ''));\r\n });\r\n\r\n /** Insert-value action is enabled once a lookup value has been picked. */\r\n readonly canInsertLookupValue = computed(\r\n () => this.isLookupProperty() && Boolean(this.lookupValueKey()),\r\n );\r\n\r\n readonly canInsertProperty = computed(() => {\r\n if (!this.selectedProperty()) return false;\r\n return Boolean(this.resolvedTablePath());\r\n });\r\n\r\n setPropertyScope(scope: string): void {\r\n if (this.propertyScope() === scope) {\r\n return;\r\n }\r\n this.propertyScope.set(scope);\r\n this.propertyPathSegments.set(\r\n buildInitialSegments(\r\n scope,\r\n this.contextOperators().find((op) => op.token === scope),\r\n this.baseRule(),\r\n ),\r\n );\r\n this.propertyFieldKey.set('');\r\n }\r\n\r\n setPathSegmentValue(index: number, value: string | null): void {\r\n this.propertyPathSegments.update((segments) => {\r\n // Update the segment at the given index and remove all segments after it\r\n // because subsequent segments depend on previous values\r\n const updated = segments.slice(0, index + 1);\r\n updated[index] = { ...updated[index], value: value ?? '' };\r\n return updated;\r\n });\r\n }\r\n\r\n addNextSegment(operatorToken: string): void {\r\n const value = '';\r\n\r\n this.propertyPathSegments.update((segments) => [\r\n ...segments,\r\n { operatorToken, value },\r\n ]);\r\n }\r\n\r\n onAddSegmentSelection(\r\n operatorToken: string,\r\n popover: { hide: () => void },\r\n ): void {\r\n popover.hide();\r\n this.addNextSegment(operatorToken);\r\n }\r\n\r\n removePathSegment(index: number): void {\r\n this.propertyPathSegments.update((segments) =>\r\n segments.filter((_, i) => i !== index),\r\n );\r\n }\r\n\r\n segmentOptions(index: number): { key: string; name: string }[] {\r\n const segment = this.pathSegments()[index];\r\n if (!segment) return [];\r\n return segment.allowedValueItems;\r\n }\r\n\r\n insertSelectedProperty(insertBlock: (block: SmartBlock) => void): void {\r\n const prop = this.selectedProperty();\r\n if (!prop) return;\r\n\r\n if (!this.canInsertProperty()) return;\r\n\r\n const tablePath = this.resolvedTablePath();\r\n if (!tablePath) return;\r\n const display = prop.name ?? prop.key;\r\n const block = createPropertyBlock(\r\n `@${tablePath}::${prop.key}`,\r\n 'current',\r\n display,\r\n );\r\n insertBlock(block);\r\n }\r\n\r\n /**\r\n * Insert the picked lookup value as a string literal. The executable form\r\n * carries the stable lookup KEY (locale-independent) while the chip shows\r\n * the friendly NAME — e.g. `… == \"completed\"` rendered as `… == Completed`.\r\n */\r\n insertSelectedLookupValue(insertBlock: (block: SmartBlock) => void): void {\r\n if (!this.canInsertLookupValue()) return;\r\n\r\n const key = this.lookupValueKey();\r\n const item = this.lookupItems().find((value) => value.key === key);\r\n if (!item) return;\r\n\r\n insertBlock({ ...createLiteralBlock(item.key), display: item.name });\r\n }\r\n\r\n /**\r\n * Detect that the cursor (in the code editor) is positioned to type the\r\n * right-hand value of a comparison against a property, e.g.\r\n * `@Current::task_status == \"in_`. Returns the compared property key, whether\r\n * an opening quote was already typed, and the partial value typed so far.\r\n */\r\n private detectLookupValueContext(\r\n formula: string,\r\n cursorPosition: number,\r\n ): { propertyKey: string; partial: string; hasOpenQuote: boolean } | null {\r\n const before = formula.slice(0, Math.max(0, cursorPosition));\r\n const match = before.match(\r\n /@[A-Za-z][\\w.]*::([A-Za-z_]\\w*)\\s*(?:==|!=|<>|=|\\bin\\b)\\s*\\[?\\s*(\")?([^\"'\\]@]*)$/i,\r\n );\r\n if (!match) return null;\r\n return {\r\n propertyKey: match[1],\r\n hasOpenQuote: Boolean(match[2]),\r\n partial: match[3] ?? '',\r\n };\r\n }\r\n\r\n /**\r\n * Avoid a wasted request for properties we already know aren't lookups; for\r\n * keys whose view type isn't loaded yet, let property-items be the authority.\r\n */\r\n private shouldFetchLookupItems(propertyKey: string): boolean {\r\n const viewType = this.findLoadedPropertyViewType(propertyKey);\r\n if (!viewType) return true;\r\n return LOOKUP_VIEW_TYPES.has(viewType.toLowerCase().replace(/[\\s_-]/g, ''));\r\n }\r\n\r\n private findLoadedPropertyViewType(propertyKey: string): string | undefined {\r\n const byPath = this.mergedPropertiesByPath();\r\n for (const props of Object.values(byPath)) {\r\n const found = props.find((prop) => prop.key === propertyKey);\r\n if (found?.viewType) return found.viewType;\r\n }\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Build an autocomplete response from a lookup property's values. The inserted\r\n * text carries the stable key wrapped in quotes (the opening quote is dropped\r\n * when the user already typed one), matching the key-as-value contract used by\r\n * the toolbar Value row.\r\n */\r\n private buildLookupValueResponse(\r\n items: FormulaPropertyItem[],\r\n context: { partial: string; hasOpenQuote: boolean },\r\n ): AutocompleteResponse {\r\n const needle = context.partial.trim().toLowerCase();\r\n const valueLabel = this.transloco.translate(\r\n 'formulaBuilder.properties.value',\r\n );\r\n\r\n const suggestions: AutocompleteSuggestion[] = items\r\n .filter(\r\n (item) =>\r\n !needle ||\r\n item.name.toLowerCase().includes(needle) ||\r\n item.key.toLowerCase().includes(needle),\r\n )\r\n .map((item) => {\r\n const insertText = `${context.hasOpenQuote ? '' : '\"'}${item.key}\"`;\r\n return {\r\n text: insertText,\r\n displayText: item.name,\r\n type: 'Keyword',\r\n description: valueLabel,\r\n insertText,\r\n category: valueLabel,\r\n };\r\n });\r\n\r\n return {\r\n suggestions,\r\n context: { type: 'None', scope: '', prefix: '' },\r\n };\r\n }\r\n\r\n getOperatorDisplayName(token: string): string {\r\n if (token === 'Host' && this.isModuleContext()) {\r\n return this.transloco.translate('formulaBuilder.operatorNames.level');\r\n }\r\n\r\n const key = `formulaBuilder.operatorNames.${token.toLowerCase()}`;\r\n const translated = this.transloco.translate(key);\r\n return translated && translated !== key ? translated : token;\r\n }\r\n}\r\n","<mt-card\r\n headless\r\n [class.ring-2]=\"hasFocus()\"\r\n [class.ring-primary]=\"hasFocus()\"\r\n [paddingless]=\"true\"\r\n>\r\n <div\r\n *transloco=\"let t; prefix: 'formulaBuilder'\"\r\n class=\"flex flex-col overflow-hidden\"\r\n >\r\n <!-- Toolbar - Pass data via inputs (pure component) -->\r\n @if (!hideToolbar()) {\r\n <mt-formula-toolbar\r\n [functionCategories]=\"resolvedFunctionCategories()\"\r\n [operators]=\"operators()\"\r\n [visibleTabs]=\"resolvedToolbarTabs()\"\r\n (onBlockInsert)=\"onBlockInsert($event)\"\r\n >\r\n <ng-template #properties let-insertBlock=\"insertBlock\">\r\n @if (isContextLoading()) {\r\n <div class=\"flex flex-col gap-4 p-4\">\r\n <div class=\"flex items-center justify-between gap-4\">\r\n <p-skeleton\r\n width=\"18rem\"\r\n height=\"2.5rem\"\r\n styleClass=\"rounded-md\"\r\n />\r\n <p-skeleton\r\n width=\"7rem\"\r\n height=\"2.5rem\"\r\n styleClass=\"rounded-md\"\r\n />\r\n </div>\r\n <div class=\"flex items-center gap-4\">\r\n <div\r\n class=\"flex min-h-11 min-w-0 flex-1 flex-col gap-2 rounded-lg bg-slate-50 px-3 py-2 dark:bg-slate-800/50\"\r\n >\r\n <div class=\"flex items-center gap-2\">\r\n <p-skeleton\r\n width=\"3rem\"\r\n height=\"1rem\"\r\n styleClass=\"rounded-md\"\r\n />\r\n <div\r\n class=\"h-4 w-px shrink-0 bg-slate-200 dark:bg-slate-700\"\r\n ></div>\r\n <p-skeleton\r\n class=\"flex-1\"\r\n height=\"2rem\"\r\n styleClass=\"rounded-md\"\r\n />\r\n </div>\r\n <div\r\n class=\"flex items-center gap-2 border-t border-slate-200 pt-2 dark:border-slate-700\"\r\n >\r\n <p-skeleton\r\n width=\"3rem\"\r\n height=\"1rem\"\r\n styleClass=\"rounded-md\"\r\n />\r\n <div\r\n class=\"h-4 w-px shrink-0 bg-slate-200 dark:bg-slate-700\"\r\n ></div>\r\n <p-skeleton\r\n class=\"flex-1\"\r\n height=\"2.5rem\"\r\n styleClass=\"rounded-md\"\r\n />\r\n </div>\r\n <p-skeleton height=\"2rem\" styleClass=\"rounded-md\" />\r\n </div>\r\n </div>\r\n </div>\r\n } @else {\r\n <div class=\"flex flex-col gap-4 p-4\">\r\n <!-- Scope Selection - Full width, centered -->\r\n <div class=\"flex items-center justify-between gap-4\">\r\n <mt-radio-cards\r\n [options]=\"scopeOptions()\"\r\n [activeId]=\"propertyScope()\"\r\n (selectionChange)=\"onScopeChange($event)\"\r\n size=\"small\"\r\n />\r\n </div>\r\n\r\n <!-- Path + Field + Preview Row -->\r\n <div class=\"flex items-center gap-4\">\r\n <!-- Path Container - Flexible -->\r\n <div\r\n class=\"flex min-h-11 min-w-0 flex-1 flex-col gap-2 rounded-lg bg-slate-50 px-3 py-2 dark:bg-slate-800/50\"\r\n >\r\n <div class=\"flex items-center gap-2\">\r\n <span\r\n class=\"shrink-0 text-xs font-semibold uppercase tracking-wider text-slate-400\"\r\n >{{ t(\"properties.path\") }}</span\r\n >\r\n <div\r\n class=\"h-4 w-px shrink-0 bg-slate-200 dark:bg-slate-700\"\r\n ></div>\r\n <div class=\"flex min-w-0 flex-1 items-center gap-2\">\r\n @if (isDirectAccess()) {\r\n <span\r\n class=\"rounded-md bg-emerald-100 px-2.5 py-1 text-xs font-medium text-emerald-600 dark:bg-emerald-900/30 dark:text-emerald-400\"\r\n >\r\n ✓ {{ t(\"properties.direct-access\") }}\r\n </span>\r\n } @else if (pathSegments().length === 0) {\r\n <span class=\"text-xs italic text-slate-400\">{{\r\n t(\"properties.no-path-configured\")\r\n }}</span>\r\n } @else {\r\n <div\r\n class=\"flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto\"\r\n >\r\n @for (\r\n segment of pathSegments();\r\n track $index;\r\n let segmentIndex = $index\r\n ) {\r\n @if (segmentIndex > 0) {\r\n <span\r\n class=\"shrink-0 text-slate-300 dark:text-slate-600\"\r\n >›</span\r\n >\r\n }\r\n <mt-button\r\n type=\"button\"\r\n [label]=\"\r\n segment.value ||\r\n t('properties.select') +\r\n ' ' +\r\n getOperatorDisplayName(segment.operatorToken)\r\n \"\r\n icon=\"arrow.chevron-down\"\r\n [outlined]=\"true\"\r\n size=\"small\"\r\n [severity]=\"\r\n segment.value ? 'primary' : 'secondary'\r\n \"\r\n [iconPos]=\"'end'\"\r\n (onClick)=\"pathPopover.toggle($event)\"\r\n ></mt-button>\r\n\r\n <p-popover\r\n #pathPopover\r\n [style]=\"{ width: 'max-content' }\"\r\n appendTo=\"body\"\r\n >\r\n <div class=\"p-2\">\r\n <div\r\n class=\"mb-2 text-xs font-semibold uppercase text-slate-400\"\r\n >\r\n {{ t(\"properties.select\") }}\r\n {{\r\n getOperatorDisplayName(\r\n segment.operatorToken\r\n )\r\n }}\r\n </div>\r\n <div\r\n class=\"flex max-h-[min(24rem,calc(100vh-10rem))] flex-col gap-1 overflow-y-auto pr-1\"\r\n >\r\n @for (\r\n option of segmentOptions(segmentIndex);\r\n track option.key\r\n ) {\r\n <mt-button\r\n type=\"button\"\r\n [label]=\"option.name\"\r\n [icon]=\"\r\n segment.value === option.key\r\n ? 'general.check'\r\n : 'general.minus'\r\n \"\r\n [iconPos]=\"'end'\"\r\n size=\"small\"\r\n severity=\"secondary\"\r\n [styleClass]=\"\r\n 'w-full justify-start rounded-md px-2.5 py-1.5 text-left text-xs font-medium transition-colors ' +\r\n (segment.value === option.key\r\n ? 'bg-primary text-white'\r\n : 'text-slate-600 hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-700')\r\n \"\r\n (onClick)=\"\r\n setPathSegmentValue(\r\n segmentIndex,\r\n option.key\r\n );\r\n pathPopover.hide()\r\n \"\r\n ></mt-button>\r\n }\r\n </div>\r\n @if (segment.optional) {\r\n <mt-button\r\n type=\"button\"\r\n [label]=\"t('actions.clear')\"\r\n [outlined]=\"true\"\r\n icon=\"general.x-close\"\r\n [iconPos]=\"'end'\"\r\n size=\"small\"\r\n severity=\"danger\"\r\n styleClass=\"mt-2 w-full rounded-md border border-slate-200 py-1 text-xs text-slate-400 hover:bg-slate-50 dark:border-slate-700\"\r\n (onClick)=\"\r\n setPathSegmentValue(segmentIndex, null);\r\n pathPopover.hide()\r\n \"\r\n ></mt-button>\r\n }\r\n </div>\r\n </p-popover>\r\n\r\n @if (\r\n segment.canRemove &&\r\n segmentIndex === pathSegments().length - 1\r\n ) {\r\n <mt-button\r\n type=\"button\"\r\n icon=\"general.x-close\"\r\n size=\"small\"\r\n severity=\"danger\"\r\n styleClass=\"flex size-5 shrink-0 items-center justify-center rounded-full bg-red-500 text-white hover:bg-red-600\"\r\n (onClick)=\"removePathSegment(segmentIndex)\"\r\n ></mt-button>\r\n }\r\n }\r\n <mt-button\r\n type=\"button\"\r\n icon=\"general.plus\"\r\n size=\"small\"\r\n severity=\"primary\"\r\n [disabled]=\"!canAddNextSegment()\"\r\n [class.hidden]=\"!canAddNextSegment()\"\r\n styleClass=\"flex size-6 shrink-0 items-center justify-center rounded-md bg-primary text-xs font-bold text-white hover:opacity-90 disabled:opacity-50\"\r\n (onClick)=\"nextOperatorPopover.toggle($event)\"\r\n ></mt-button>\r\n </div>\r\n }\r\n <p-popover\r\n #nextOperatorPopover\r\n [style]=\"{ width: 'max-content' }\"\r\n appendTo=\"body\"\r\n >\r\n <div class=\"p-2\">\r\n <div\r\n class=\"mb-2 text-xs font-semibold uppercase text-slate-400\"\r\n >\r\n {{ t(\"properties.add-segment\") }}\r\n </div>\r\n <div\r\n class=\"flex max-h-[min(24rem,calc(100vh-10rem))] flex-col gap-1 overflow-y-auto pr-1\"\r\n >\r\n @for (\r\n option of nextOperatorOptions();\r\n track option.token\r\n ) {\r\n <mt-button\r\n type=\"button\"\r\n [label]=\"getOperatorDisplayName(option.token)\"\r\n icon=\"general.plus\"\r\n [iconPos]=\"'end'\"\r\n size=\"small\"\r\n severity=\"secondary\"\r\n styleClass=\"w-full justify-start rounded-md px-2.5 py-1.5 text-left text-xs font-medium transition-colors text-slate-600 hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-700\"\r\n (onClick)=\"\r\n onAddSegmentSelection(\r\n option.token,\r\n nextOperatorPopover\r\n )\r\n \"\r\n ></mt-button>\r\n }\r\n </div>\r\n </div>\r\n </p-popover>\r\n </div>\r\n </div>\r\n\r\n <!-- Field Selection - Under Path -->\r\n <div\r\n class=\"flex items-center gap-2 border-t border-slate-200 pt-2 dark:border-slate-700\"\r\n >\r\n <span\r\n class=\"shrink-0 text-xs font-semibold uppercase tracking-wider text-slate-400\"\r\n >{{ t(\"properties.field\") }}</span\r\n >\r\n <div\r\n class=\"h-4 w-px shrink-0 bg-slate-200 dark:bg-slate-700\"\r\n ></div>\r\n @if (isPropertyLoading()) {\r\n <p-skeleton\r\n class=\"flex-1\"\r\n height=\"2.5rem\"\r\n styleClass=\"rounded-md\"\r\n />\r\n } @else {\r\n <mt-select-field\r\n class=\"flex-1\"\r\n [label]=\"''\"\r\n [filter]=\"true\"\r\n [hasPlaceholderPrefix]=\"false\"\r\n [placeholder]=\"t('properties.select')\"\r\n [(ngModel)]=\"propertyFieldKey\"\r\n [options]=\"propertyOptions()\"\r\n optionLabel=\"name\"\r\n optionValue=\"key\"\r\n [size]=\"'small'\"\r\n />\r\n }\r\n </div>\r\n\r\n <!-- Value Selection - Only for lookup / status / lookup-matrix fields -->\r\n @if (isLookupProperty()) {\r\n <div\r\n class=\"flex items-center gap-2 border-t border-slate-200 pt-2 dark:border-slate-700\"\r\n >\r\n <span\r\n class=\"shrink-0 text-xs font-semibold uppercase tracking-wider text-slate-400\"\r\n >{{ t(\"properties.value\") }}</span\r\n >\r\n <div\r\n class=\"h-4 w-px shrink-0 bg-slate-200 dark:bg-slate-700\"\r\n ></div>\r\n @if (isLookupItemsLoading()) {\r\n <p-skeleton\r\n class=\"flex-1\"\r\n height=\"2.5rem\"\r\n styleClass=\"rounded-md\"\r\n />\r\n } @else {\r\n <mt-select-field\r\n class=\"flex-1\"\r\n [label]=\"''\"\r\n [filter]=\"true\"\r\n [hasPlaceholderPrefix]=\"false\"\r\n [placeholder]=\"t('properties.select-value')\"\r\n [(ngModel)]=\"lookupValueKey\"\r\n [options]=\"lookupItems()\"\r\n optionLabel=\"name\"\r\n optionValue=\"key\"\r\n [size]=\"'small'\"\r\n />\r\n }\r\n </div>\r\n }\r\n <div\r\n class=\"w-full truncate rounded-lg bg-amber-100 px-3 py-2 text-sm font-semibold text-amber-700 shadow-sm hover:bg-amber-200 dark:bg-amber-900/30 dark:text-amber-300 dark:hover:bg-amber-900/50\"\r\n [mtTooltip]=\"\r\n '@' +\r\n propertyTablePath() +\r\n '::' +\r\n (selectedProperty()?.key ?? '...')\r\n \"\r\n tooltipPosition=\"top\"\r\n >\r\n @{{ propertyTablePath() }}::{{\r\n selectedProperty()?.key ?? \"...\"\r\n }}\r\n </div>\r\n <div class=\"flex justify-end gap-2\">\r\n @if (isLookupProperty()) {\r\n <mt-button\r\n type=\"button\"\r\n [label]=\"t('actions.insert-value')\"\r\n icon=\"general.plus\"\r\n severity=\"secondary\"\r\n [outlined]=\"true\"\r\n [disabled]=\"!canInsertLookupValue()\"\r\n (onClick)=\"insertSelectedLookupValue(insertBlock)\"\r\n ></mt-button>\r\n }\r\n <mt-button\r\n type=\"button\"\r\n [label]=\"t('actions.insert')\"\r\n icon=\"general.plus\"\r\n severity=\"primary\"\r\n [disabled]=\"!canInsertProperty()\"\r\n (onClick)=\"insertSelectedProperty(insertBlock)\"\r\n ></mt-button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n }\r\n </ng-template>\r\n </mt-formula-toolbar>\r\n }\r\n\r\n <!-- Editor Area -->\r\n <div class=\"p-3\">\r\n <div\r\n class=\"overflow-hidden rounded-lg border border-surface-200 bg-white dark:border-surface-700 dark:bg-surface-800\"\r\n >\r\n @if (showModeToggle()) {\r\n <div\r\n class=\"flex items-center justify-end border-b border-surface-200 px-3 py-2 dark:border-surface-700\"\r\n >\r\n <mt-toggle-field\r\n [label]=\"t('codeMode')\"\r\n labelPosition=\"end\"\r\n size=\"small\"\r\n [ngModel]=\"isCodeMode()\"\r\n [disabled]=\"isDisabled()\"\r\n (ngModelChange)=\"onModeToggle($event)\"\r\n />\r\n </div>\r\n }\r\n <div class=\"p-0\">\r\n @if (isCodeMode()) {\r\n <mt-formula-editor-code\r\n #formulaEditorCode\r\n [placeholder]=\"placeholder() || t('placeholder')\"\r\n [initialFormula]=\"expression()\"\r\n [disabled]=\"isDisabled()\"\r\n [borderless]=\"true\"\r\n [autocompleteProvider]=\"autocompleteProvider\"\r\n (formulaChange)=\"onCodeFormulaChange($event)\"\r\n (onFocus)=\"onEditorFocus()\"\r\n (onBlur)=\"onEditorBlur()\"\r\n />\r\n } @else {\r\n <mt-formula-editor\r\n #formulaEditor\r\n [placeholder]=\"placeholder() || t('placeholder')\"\r\n [initialTokens]=\"tokens()\"\r\n [disabled]=\"isDisabled()\"\r\n [borderless]=\"true\"\r\n (formulaChange)=\"onFormulaChange($event)\"\r\n (tokensChange)=\"onTokensChange($event)\"\r\n (onFocus)=\"onEditorFocus()\"\r\n (onBlur)=\"onEditorBlur()\"\r\n />\r\n }\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <!-- Status Bar - Pass data via inputs (pure component) -->\r\n @if (!hideStatusBar()) {\r\n <mt-formula-status-bar [validation]=\"validation()\" />\r\n }\r\n </div>\r\n</mt-card>\r\n","/**\r\n * Services barrel export\r\n */\r\n\r\nexport * from './formula-context.service';\r\nexport * from './formula-validator.service';\r\n","/**\r\n * Public API Surface of @masterteam/formula-builder\r\n *\r\n * This package provides the FormulaBuilder component which wraps\r\n * pure UI components from @masterteam/components/formula with\r\n * backend services for validation and context loading.\r\n *\r\n * Architecture:\r\n * - UI Components: imported from @masterteam/components/formula (pure, no services)\r\n * - Services: FormulaContextService, FormulaValidatorService (backend logic)\r\n * - FormulaBuilder: Main wrapper that connects UI with services\r\n */\r\n\r\n// Main component\r\nexport * from './lib/formula-builder';\r\n\r\n// Services (backend logic only)\r\nexport * from './lib/services/index';\r\n\r\n// Re-export models from base package for convenience\r\nexport {\r\n type SmartBlock,\r\n type BlockType,\r\n type ArgumentSlot,\r\n type FormulaToken,\r\n type TokenType,\r\n type DragBehavior,\r\n type ValidationResult,\r\n type ValidationError,\r\n type FunctionDefinition,\r\n type FunctionCategoryGroup,\r\n type OperatorDefinition,\r\n createFunctionBlock,\r\n createPropertyBlock,\r\n createOperatorBlock,\r\n createLiteralBlock,\r\n} from '@masterteam/components/formula';\r\n\r\n// Export validation-specific models\r\nexport type {\r\n ValidationRequest,\r\n FunctionCatalogResponse,\r\n ApiErrorResponse,\r\n} from './lib/models/validation-result.model';\r\n\r\n// Export value model for ControlValueAccessor usage\r\nexport type { FormulaBuilderValue } from './lib/models/formula-builder-value.model';\r\n\r\n// Export builder context models\r\nexport type {\r\n FormulaBuilderContextResponse,\r\n FormulaPropertyDescriptor,\r\n FormulaEngineSchemaDescriptor,\r\n OperatorDescriptor,\r\n NextTokenRule,\r\n NextTokenAllowedValueItem,\r\n} from './lib/models/formula-context.model';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;AAGG;AAyBH;AACA,MAAM,gBAAgB,GAAqB;AACzC,IAAA,OAAO,EAAE,IAAI;AACb,IAAA,MAAM,EAAE,EAAE;AACV,IAAA,QAAQ,EAAE,EAAE;AACZ,IAAA,YAAY,EAAE,EAAE;AAChB,IAAA,UAAU,EAAE,CAAC;CACd;MAGY,uBAAuB,CAAA;AACjB,IAAA,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC;AACzB,IAAA,SAAS,GAAG,MAAM,CAAC,gBAAgB,CAAC;IACpC,MAAM,GAAG,UAAU;AAEpC;;;;AAIG;AACK,IAAA,oBAAoB,CAAC,OAAuB,EAAA;QAClD,OAAO;AACL,YAAA,OAAO,EAAE,KAAK;AACd,YAAA,MAAM,EAAE;AACN,gBAAA;AACE,oBAAA,OAAO,EACL,OAAO;AACP,wBAAA,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,wCAAwC,CAAC;AACpE,oBAAA,IAAI,EAAE,CAAC;AACP,oBAAA,MAAM,EAAE,CAAC;AACT,oBAAA,QAAQ,EAAE,OAAO;AAClB,iBAAA;AACF,aAAA;AACD,YAAA,QAAQ,EAAE,EAAE;AACZ,YAAA,YAAY,EAAE,EAAE;AAChB,YAAA,UAAU,EAAE,CAAC;SACd;IACH;AAEQ,IAAA,UAAU,CAAC,IAAoB,EAAA;QACrC,OAAO,IAAI,KAAK;AACd,cAAE,CAAA,EAAG,IAAI,CAAC,MAAM,CAAA,aAAA;AAChB,cAAE,IAAI,CAAC,MAAM;IACjB;;IAGiB,WAAW,GAAG,GAAG;;AAGjB,IAAA,WAAW,GAAG,MAAM,CAAmB,gBAAgB,kFAAC;;AAGxD,IAAA,aAAa,GAAG,MAAM,CAAC,KAAK,oFAAC;;AAG7B,IAAA,eAAe,GAAG,IAAI,OAAO,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AAA,CAAA,EAAA,CAAA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,MAAA,EAAA,IAAA,EAAA,CAAA,cAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AE9KpD;;AAEG;;ACFH;;;;;;;;;;;AAWG;AAEH;;ACbA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"masterteam-formula-builder.mjs","sources":["../../../../packages/masterteam/formula-builder/src/lib/services/formula-validator.service.ts","../../../../packages/masterteam/formula-builder/src/lib/services/formula-context.service.ts","../../../../packages/masterteam/formula-builder/src/lib/services/formula-autocomplete.service.ts","../../../../packages/masterteam/formula-builder/src/lib/utils/formula-path-builder.ts","../../../../packages/masterteam/formula-builder/src/lib/utils/formula-function-categories.ts","../../../../packages/masterteam/formula-builder/src/lib/formula-builder.ts","../../../../packages/masterteam/formula-builder/src/lib/formula-builder.html","../../../../packages/masterteam/formula-builder/src/lib/services/index.ts","../../../../packages/masterteam/formula-builder/src/public-api.ts","../../../../packages/masterteam/formula-builder/src/masterteam-formula-builder.ts"],"sourcesContent":["/**\r\n * Formula Validator Service\r\n * Handles real-time validation via API\r\n */\r\n\r\nimport { Injectable, inject, signal } from '@angular/core';\r\nimport { HttpClient, HttpErrorResponse } from '@angular/common/http';\r\nimport { TranslocoService } from '@jsverse/transloco';\r\nimport {\r\n Observable,\r\n Subject,\r\n of,\r\n catchError,\r\n debounceTime,\r\n distinctUntilChanged,\r\n map,\r\n switchMap,\r\n tap,\r\n} from 'rxjs';\r\nimport {\r\n ValidationResult,\r\n ValidationRequest,\r\n ApiErrorResponse,\r\n} from '../models/validation-result.model';\r\n\r\ntype FormulaApiMode = 'default' | 'current-only';\r\ntype ValidationJob = ValidationRequest & { apiMode: FormulaApiMode };\r\n\r\n/** Default validation result for empty formulas */\r\nconst EMPTY_VALIDATION: ValidationResult = {\r\n isValid: true,\r\n errors: [],\r\n warnings: [],\r\n dependencies: [],\r\n complexity: 0,\r\n};\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class FormulaValidatorService {\r\n private readonly http = inject(HttpClient);\r\n private readonly transloco = inject(TranslocoService);\r\n private readonly apiUrl = 'formulas';\r\n\r\n /**\r\n * Build an error validation result.\r\n * Real validation messages come from the backend; this only supplies the\r\n * localized FE fallback used when the request fails or returns no message.\r\n */\r\n private buildErrorValidation(message?: string | null): ValidationResult {\r\n return {\r\n isValid: false,\r\n errors: [\r\n {\r\n message:\r\n message ||\r\n this.transloco.translate('formulaBuilder.errors.validationFailed'),\r\n line: 1,\r\n column: 1,\r\n severity: 'Error',\r\n },\r\n ],\r\n warnings: [],\r\n dependencies: [],\r\n complexity: 0,\r\n };\r\n }\r\n\r\n private getBaseUrl(mode: FormulaApiMode): string {\r\n return mode === 'current-only'\r\n ? `${this.apiUrl}/current-only`\r\n : this.apiUrl;\r\n }\r\n\r\n /** Debounce time in ms */\r\n private readonly DEBOUNCE_MS = 300;\r\n\r\n /** Current validation result */\r\n private readonly _validation = signal<ValidationResult>(EMPTY_VALIDATION);\r\n\r\n /** Loading state */\r\n private readonly _isValidating = signal(false);\r\n\r\n /** Validation subject for debouncing */\r\n private readonly validateSubject = new Subject<ValidationJob>();\r\n\r\n private unwrapResponse<T>(response: T | { data: T } | null): T | null {\r\n if (!response) return null;\r\n if (\r\n typeof response === 'object' &&\r\n response !== null &&\r\n 'data' in response\r\n ) {\r\n return (response as { data: T }).data ?? null;\r\n }\r\n return response as T;\r\n }\r\n\r\n /** Public signals */\r\n readonly validation = this._validation.asReadonly();\r\n readonly isValidating = this._isValidating.asReadonly();\r\n\r\n constructor() {\r\n this.setupValidationStream();\r\n }\r\n\r\n /** Setup debounced validation stream */\r\n private setupValidationStream(): void {\r\n this.validateSubject\r\n .pipe(\r\n debounceTime(this.DEBOUNCE_MS),\r\n distinctUntilChanged(\r\n (a, b) =>\r\n a.formula === b.formula &&\r\n a.levelSchemaId === b.levelSchemaId &&\r\n a.moduleId === b.moduleId &&\r\n a.templateId === b.templateId &&\r\n a.contextKey === b.contextKey &&\r\n a.apiMode === b.apiMode &&\r\n JSON.stringify(a.knownProperties) ===\r\n JSON.stringify(b.knownProperties),\r\n ),\r\n tap(() => this._isValidating.set(true)),\r\n switchMap((request) => this.callValidateApi(request)),\r\n )\r\n .subscribe((result) => {\r\n this._validation.set(result);\r\n this._isValidating.set(false);\r\n });\r\n }\r\n\r\n /** Validate formula (debounced) */\r\n validate(\r\n formula: string,\r\n knownProperties?: string[],\r\n levelSchemaId?: number,\r\n moduleId?: number,\r\n templateId?: number,\r\n apiMode: FormulaApiMode = 'default',\r\n contextKey?: string,\r\n ): void {\r\n // Handle empty formula\r\n if (!formula || formula.trim() === '') {\r\n this._validation.set(EMPTY_VALIDATION);\r\n return;\r\n }\r\n\r\n // Push to debounced stream\r\n this.validateSubject.next({\r\n formula,\r\n knownProperties,\r\n levelSchemaId,\r\n moduleId,\r\n templateId,\r\n apiMode,\r\n contextKey,\r\n });\r\n }\r\n\r\n /** Validate formula immediately (no debounce) */\r\n validateImmediate(\r\n formula: string,\r\n knownProperties?: string[],\r\n levelSchemaId?: number,\r\n moduleId?: number,\r\n templateId?: number,\r\n apiMode: FormulaApiMode = 'default',\r\n contextKey?: string,\r\n ): Observable<ValidationResult> {\r\n if (!formula || formula.trim() === '') {\r\n return of(EMPTY_VALIDATION);\r\n }\r\n\r\n this._isValidating.set(true);\r\n\r\n return this.callValidateApi({\r\n formula,\r\n knownProperties,\r\n levelSchemaId,\r\n moduleId,\r\n templateId,\r\n apiMode,\r\n contextKey,\r\n }).pipe(\r\n tap((result) => {\r\n this._validation.set(result);\r\n this._isValidating.set(false);\r\n }),\r\n );\r\n }\r\n\r\n /** Call validation API */\r\n private callValidateApi(\r\n request: ValidationJob,\r\n ): Observable<ValidationResult> {\r\n const { apiMode, ...payload } = request;\r\n // The result is shown inline under the editor, so a toast only repeats it.\r\n // Hosts silence `api/formulas/validate` by URL, which misses current-only.\r\n return this.http\r\n .post<ValidationResult | { data: ValidationResult }>(\r\n `${this.getBaseUrl(apiMode)}/validate`,\r\n payload,\r\n {\r\n headers: { noMessage: 'true' },\r\n },\r\n )\r\n .pipe(\r\n map(\r\n (response) =>\r\n this.unwrapResponse(response) ?? this.buildErrorValidation(),\r\n ),\r\n catchError((error: HttpErrorResponse) => {\r\n console.error('Validation API error:', error);\r\n\r\n // Prefer the backend-localized message; fall back to the FE string.\r\n const apiError = error.error as ApiErrorResponse;\r\n const message = apiError?.message ?? apiError?.error;\r\n\r\n return of(this.buildErrorValidation(message));\r\n }),\r\n );\r\n }\r\n\r\n /** Reset validation state */\r\n reset(): void {\r\n this._validation.set(EMPTY_VALIDATION);\r\n this._isValidating.set(false);\r\n }\r\n\r\n /** Get current validation result */\r\n getCurrentValidation(): ValidationResult {\r\n return this._validation();\r\n }\r\n\r\n /** Check if formula is valid */\r\n isValid(): boolean {\r\n return this._validation().isValid;\r\n }\r\n\r\n /** Get validation errors */\r\n getErrors() {\r\n return this._validation().errors;\r\n }\r\n\r\n /** Get validation warnings */\r\n getWarnings() {\r\n return this._validation().warnings;\r\n }\r\n\r\n /** Get formula dependencies */\r\n getDependencies() {\r\n return this._validation().dependencies;\r\n }\r\n\r\n /** Get formula complexity */\r\n getComplexity() {\r\n return this._validation().complexity;\r\n }\r\n}\r\n","import { Injectable, inject } from '@angular/core';\r\nimport { HttpClient } from '@angular/common/http';\r\nimport { Observable, of, catchError, tap, map } from 'rxjs';\r\n\r\nimport type {\r\n FormulaBuilderContextResponse,\r\n FormulaBuilderNextTokensResponse,\r\n FormulaPropertyDescriptor,\r\n FormulaPropertyItem,\r\n FormulaPropertyItemsResponse,\r\n} from '../models/formula-context.model';\r\n\r\ntype FormulaApiMode = 'default' | 'current-only';\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class FormulaContextService {\r\n private readonly http = inject(HttpClient);\r\n private readonly apiUrl = 'formulas';\r\n\r\n private getBaseUrl(mode: FormulaApiMode): string {\r\n return mode === 'current-only'\r\n ? `${this.apiUrl}/current-only`\r\n : this.apiUrl;\r\n }\r\n\r\n private buildLegacyContextUrl(\r\n schemaId: number,\r\n moduleId: number | undefined,\r\n contextEntityTypeKey: string | undefined,\r\n mode: FormulaApiMode,\r\n ): string {\r\n const params = new URLSearchParams();\r\n if (mode === 'default' && contextEntityTypeKey) {\r\n params.set('contextEntityTypeKey', contextEntityTypeKey);\r\n }\r\n if (moduleId !== undefined) {\r\n params.set('moduleId', moduleId.toString());\r\n }\r\n const queryString = params.toString();\r\n const query = queryString ? `?${queryString}` : '';\r\n return `${this.getBaseUrl(mode)}/builder/context/${schemaId}${query}`;\r\n }\r\n\r\n private unwrapResponse<T>(response: T | { data: T } | null): T | null {\r\n if (!response) return null;\r\n if (\r\n typeof response === 'object' &&\r\n response !== null &&\r\n 'data' in response\r\n ) {\r\n return (response as { data: T }).data ?? null;\r\n }\r\n return response as T;\r\n }\r\n\r\n private readonly contextCache = new Map<\r\n string,\r\n FormulaBuilderContextResponse\r\n >();\r\n private readonly propertiesCache = new Map<\r\n string,\r\n FormulaPropertyDescriptor[]\r\n >();\r\n private readonly nextTokensCache = new Map<\r\n string,\r\n FormulaBuilderNextTokensResponse\r\n >();\r\n private readonly propertyItemsCache = new Map<\r\n string,\r\n FormulaPropertyItem[]\r\n >();\r\n\r\n /**\r\n * Load the builder context. When `contextKey` is provided it is the canonical\r\n * context identifier (`Module:123` / `Level:5` / `Level:5/Module:10`) and the\r\n * context-key endpoint is used — this is the only way to address a standalone\r\n * module, which has no workspace/level schema id. Otherwise the legacy\r\n * schema-id path endpoint is used unchanged.\r\n */\r\n loadContext(\r\n schemaId: number | undefined,\r\n moduleId?: number,\r\n contextEntityTypeKey?: string,\r\n mode: FormulaApiMode = 'default',\r\n contextKey?: string,\r\n ): Observable<FormulaBuilderContextResponse | null> {\r\n if (!schemaId && !contextKey) return of(null);\r\n\r\n const cacheKey = `${mode}:${schemaId ?? ''}:${moduleId ?? ''}:${contextEntityTypeKey ?? ''}:${contextKey ?? ''}`;\r\n const cached = this.contextCache.get(cacheKey);\r\n if (cached) {\r\n return of(cached);\r\n }\r\n\r\n // Context-key endpoint is authoritative for the context kind/execution\r\n // profile; the backend resolves the schema and scope tokens from the key.\r\n const url = contextKey\r\n ? `${this.getBaseUrl(mode)}/builder/context?contextKey=${encodeURIComponent(contextKey)}`\r\n : this.buildLegacyContextUrl(\r\n schemaId as number,\r\n moduleId,\r\n contextEntityTypeKey,\r\n mode,\r\n );\r\n\r\n return this.http\r\n .get<\r\n FormulaBuilderContextResponse | { data: FormulaBuilderContextResponse }\r\n >(url)\r\n .pipe(\r\n map((response) => this.unwrapResponse(response)),\r\n tap((context) => {\r\n if (context) {\r\n this.contextCache.set(cacheKey, context);\r\n }\r\n }),\r\n catchError((error) => {\r\n console.warn('Failed to load formula builder context:', error);\r\n return of(null);\r\n }),\r\n );\r\n }\r\n\r\n getScopeProperties(\r\n schemaId: number,\r\n component: string | undefined,\r\n tablePath: string,\r\n moduleId?: number,\r\n mode: FormulaApiMode = 'default',\r\n contextKey?: string,\r\n ): Observable<FormulaPropertyDescriptor[]> {\r\n if (!schemaId || !tablePath) return of([]);\r\n\r\n const cacheKey = `${mode}:${schemaId}:${moduleId ?? ''}:${component}:${tablePath}:${contextKey ?? ''}`;\r\n const cached = this.propertiesCache.get(cacheKey);\r\n if (cached) {\r\n return of(cached);\r\n }\r\n\r\n const params = new URLSearchParams({\r\n schemaId: schemaId.toString(),\r\n tablePath,\r\n });\r\n if (component) {\r\n params.set('component', component);\r\n }\r\n if (moduleId !== undefined) {\r\n params.set('moduleId', moduleId.toString());\r\n }\r\n if (contextKey) {\r\n params.set('contextKey', contextKey);\r\n }\r\n\r\n return this.http\r\n .get<\r\n FormulaPropertyDescriptor[] | { data: FormulaPropertyDescriptor[] }\r\n >(`${this.getBaseUrl(mode)}/builder/properties?${params.toString()}`)\r\n .pipe(\r\n map((response) => this.unwrapResponse(response) ?? []),\r\n tap((response) => {\r\n this.propertiesCache.set(cacheKey, response);\r\n }),\r\n catchError((error) => {\r\n console.warn('Failed to load formula properties:', error);\r\n return of([]);\r\n }),\r\n );\r\n }\r\n\r\n getNextTokens(\r\n schemaId: number,\r\n component: string,\r\n tablePath: string,\r\n moduleId?: number,\r\n mode: FormulaApiMode = 'default',\r\n contextKey?: string,\r\n ): Observable<FormulaBuilderNextTokensResponse | null> {\r\n if (!schemaId || !component || !tablePath) return of(null);\r\n\r\n const cacheKey = `${mode}:${schemaId}:${moduleId ?? ''}:${component}:${tablePath}:${contextKey ?? ''}`;\r\n const cached = this.nextTokensCache.get(cacheKey);\r\n if (cached) {\r\n return of(cached);\r\n }\r\n\r\n const params = new URLSearchParams({\r\n schemaId: schemaId.toString(),\r\n component,\r\n tablePath,\r\n });\r\n if (moduleId !== undefined) {\r\n params.set('moduleId', moduleId.toString());\r\n }\r\n if (contextKey) {\r\n params.set('contextKey', contextKey);\r\n }\r\n\r\n return this.http\r\n .get<\r\n | FormulaBuilderNextTokensResponse\r\n | { data: FormulaBuilderNextTokensResponse }\r\n >(`${this.getBaseUrl(mode)}/builder/next-tokens?${params.toString()}`)\r\n .pipe(\r\n map((response) => this.unwrapResponse(response)),\r\n tap((payload) => {\r\n if (payload) {\r\n this.nextTokensCache.set(cacheKey, payload);\r\n }\r\n }),\r\n catchError((error) => {\r\n console.warn('Failed to load formula next tokens:', error);\r\n return of(null);\r\n }),\r\n );\r\n }\r\n\r\n /**\r\n * Selectable values for a lookup / status / lookup-matrix property.\r\n * The backend responds 400 (VAL_001) for any non-lookup property, which we\r\n * swallow into an empty list — callers gate the value picker on a known\r\n * lookup view type, so an empty result simply means \"no picker\".\r\n */\r\n getPropertyItems(\r\n propertyKey: string,\r\n mode: FormulaApiMode = 'default',\r\n ): Observable<FormulaPropertyItem[]> {\r\n if (!propertyKey) return of([]);\r\n\r\n const cacheKey = `${mode}:${propertyKey}`;\r\n const cached = this.propertyItemsCache.get(cacheKey);\r\n if (cached) {\r\n return of(cached);\r\n }\r\n\r\n return this.http\r\n .get<\r\n FormulaPropertyItemsResponse | { data: FormulaPropertyItemsResponse }\r\n >(`${this.getBaseUrl(mode)}/builder/property-items/${encodeURIComponent(propertyKey)}`)\r\n .pipe(\r\n map((response) => this.unwrapResponse(response)?.items ?? []),\r\n tap((items) => {\r\n this.propertyItemsCache.set(cacheKey, items);\r\n }),\r\n catchError((error) => {\r\n console.warn('Failed to load formula property items:', error);\r\n return of([]);\r\n }),\r\n );\r\n }\r\n}\r\n","import { Injectable, inject } from '@angular/core';\r\nimport { HttpClient } from '@angular/common/http';\r\nimport { Observable, of, catchError, map } from 'rxjs';\r\nimport type {\r\n AutocompleteRequest,\r\n AutocompleteResponse,\r\n} from '../models/validation-result.model';\r\n\r\ntype FormulaApiMode = 'default' | 'current-only';\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class FormulaAutocompleteService {\r\n private readonly http = inject(HttpClient);\r\n private readonly apiUrl = 'formulas';\r\n\r\n private getBaseUrl(mode: FormulaApiMode): string {\r\n return mode === 'current-only'\r\n ? `${this.apiUrl}/current-only`\r\n : this.apiUrl;\r\n }\r\n\r\n private unwrapResponse<T>(response: T | { data: T } | null): T | null {\r\n if (!response) return null;\r\n if (\r\n typeof response === 'object' &&\r\n response !== null &&\r\n 'data' in response\r\n ) {\r\n return (response as { data: T }).data ?? null;\r\n }\r\n return response as T;\r\n }\r\n\r\n getSuggestions(\r\n request: AutocompleteRequest,\r\n apiMode: FormulaApiMode = 'default',\r\n ): Observable<AutocompleteResponse | null> {\r\n if (!request) {\r\n return of(null);\r\n }\r\n\r\n const normalized: AutocompleteRequest = {\r\n ...request,\r\n formula: request.formula ?? '',\r\n };\r\n\r\n // A background read on every keystroke: the host's message interceptor\r\n // must not toast its \"Created successfully.\" or its 400s.\r\n return this.http\r\n .post<AutocompleteResponse | { data: AutocompleteResponse }>(\r\n `${this.getBaseUrl(apiMode)}/autocomplete`,\r\n normalized,\r\n {\r\n headers: { noMessage: 'true' },\r\n },\r\n )\r\n .pipe(\r\n map((response) => this.unwrapResponse(response)),\r\n catchError((error) => {\r\n console.warn('Autocomplete API error:', error);\r\n return of(null);\r\n }),\r\n );\r\n }\r\n}\r\n","import type {\r\n NextTokenAllowedValueItem,\r\n NextTokenRule,\r\n OperatorDescriptor,\r\n} from '../models/formula-context.model';\r\n\r\nexport type PathSegment = {\r\n operatorToken: string;\r\n value: string;\r\n};\r\n\r\nexport type SegmentMeta = PathSegment & {\r\n parameterKind?: string | null;\r\n requiresParameter: boolean;\r\n allowedValues: string[];\r\n allowedValueItems: NextTokenAllowedValueItem[];\r\n optional: boolean;\r\n canRemove: boolean;\r\n};\r\n\r\nexport type ResolveSegmentsParams = {\r\n scope: string;\r\n segments: PathSegment[];\r\n operators: OperatorDescriptor[];\r\n baseRule?: NextTokenRule;\r\n rulesByPath: Record<string, Record<string, NextTokenRule>>;\r\n};\r\n\r\nexport function resolveSegmentsMeta({\r\n scope,\r\n segments,\r\n operators,\r\n baseRule,\r\n rulesByPath,\r\n}: ResolveSegmentsParams): SegmentMeta[] {\r\n if (!scope || segments.length === 0) {\r\n return [];\r\n }\r\n\r\n let pathBefore = scope;\r\n let blocked = false;\r\n\r\n return segments.map((segment, index) => {\r\n const isBase = index === 0 && segment.operatorToken === scope;\r\n const operator = operators.find((op) => op.token === segment.operatorToken);\r\n const rule = blocked\r\n ? undefined\r\n : isBase\r\n ? baseRule\r\n : rulesByPath[pathBefore]?.[segment.operatorToken];\r\n const parameterKind =\r\n rule?.parameterKind ?? operator?.parameterKind ?? null;\r\n const requiresParameter =\r\n operator?.requiresParameter ?? Boolean(parameterKind);\r\n const allowedValues = getAllowedValues(rule);\r\n const allowedValueItems = getAllowedValueItems(rule);\r\n const normalizedValue = segment.value;\r\n const isComplete = !requiresParameter || Boolean(normalizedValue);\r\n\r\n if (!blocked && isComplete) {\r\n pathBefore = appendToPath(\r\n pathBefore,\r\n segment.operatorToken,\r\n normalizedValue,\r\n isBase,\r\n );\r\n } else {\r\n blocked = true;\r\n }\r\n\r\n return {\r\n operatorToken: segment.operatorToken,\r\n value: normalizedValue,\r\n parameterKind,\r\n requiresParameter,\r\n allowedValues,\r\n allowedValueItems,\r\n optional: !requiresParameter,\r\n canRemove: !isBase,\r\n };\r\n });\r\n}\r\n\r\nexport function buildInitialSegments(\r\n scope: string,\r\n operator: OperatorDescriptor | undefined,\r\n rule: NextTokenRule | undefined,\r\n): PathSegment[] {\r\n if (!operator || !scope) return [];\r\n const parameterKind = operator.parameterKind ?? rule?.parameterKind ?? null;\r\n const requiresParameter =\r\n operator.requiresParameter ?? Boolean(parameterKind);\r\n const shouldHaveSegment = Boolean(parameterKind) || requiresParameter;\r\n if (!shouldHaveSegment) return [];\r\n\r\n return [{ operatorToken: scope, value: '' }];\r\n}\r\n\r\nexport function buildTablePath(\r\n scope: string,\r\n segments: SegmentMeta[],\r\n baseOperator: OperatorDescriptor | undefined,\r\n stopOnIncomplete: boolean,\r\n): string {\r\n if (!scope) return '';\r\n\r\n if (\r\n stopOnIncomplete &&\r\n segments.length === 0 &&\r\n (baseOperator?.requiresParameter || baseOperator?.parameterKind)\r\n ) {\r\n return '';\r\n }\r\n\r\n let path = scope;\r\n for (let index = 0; index < segments.length; index += 1) {\r\n const segment = segments[index];\r\n const isBase = index === 0 && segment.operatorToken === scope;\r\n if (!isBase) {\r\n path += `.${segment.operatorToken}`;\r\n }\r\n if (segment.value) {\r\n path += `.${segment.value}`;\r\n } else if (segment.requiresParameter && stopOnIncomplete) {\r\n return '';\r\n }\r\n }\r\n\r\n return path;\r\n}\r\n\r\nexport function getAllowedValues(rule: NextTokenRule | undefined): string[] {\r\n return rule?.allowedValues ?? [];\r\n}\r\n\r\nexport function getAllowedValueItems(\r\n rule: NextTokenRule | undefined,\r\n): NextTokenAllowedValueItem[] {\r\n if (rule?.allowedValueItems?.length) {\r\n return rule.allowedValueItems;\r\n }\r\n\r\n return getAllowedValues(rule).map((value) => ({\r\n key: value,\r\n name: value,\r\n }));\r\n}\r\n\r\nfunction appendToPath(\r\n basePath: string,\r\n operatorToken: string,\r\n value: string,\r\n isBase: boolean,\r\n): string {\r\n if (isBase) {\r\n if (!value) return basePath;\r\n if (!basePath) return value;\r\n return `${basePath}.${value}`;\r\n }\r\n if (!basePath) {\r\n return value ? `${operatorToken}.${value}` : operatorToken;\r\n }\r\n const withOperator = `${basePath}.${operatorToken}`;\r\n return value ? `${withOperator}.${value}` : withOperator;\r\n}\r\n","import type { FunctionCategoryGroup } from '@masterteam/components/formula';\r\n\r\n/** Resolve a host override before API context and the package fallback catalog. */\r\nexport function resolveFormulaFunctionCategories(\r\n configured: FunctionCategoryGroup[],\r\n context: FunctionCategoryGroup[],\r\n fallback: FunctionCategoryGroup[],\r\n): FunctionCategoryGroup[] {\r\n if (configured.length > 0) return configured;\r\n if (context.length > 0) return context;\r\n return fallback;\r\n}\r\n","import {\n Component,\n forwardRef,\n input,\n output,\n signal,\n computed,\n inject,\n effect,\n untracked,\n OnDestroy,\n viewChild,\n} from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { TranslocoDirective, TranslocoService } from '@jsverse/transloco';\nimport {\n ControlValueAccessor,\n FormsModule,\n NG_VALUE_ACCESSOR,\n} from '@angular/forms';\nimport { Card } from '@masterteam/components/card';\nimport { Button } from '@masterteam/components/button';\nimport { SelectField } from '@masterteam/components/select-field';\nimport { Tooltip } from '@masterteam/components/tooltip';\nimport { RadioCards, type RadioItem } from '@masterteam/components/radio-cards';\nimport { ToggleField } from '@masterteam/components/toggle-field';\nimport type { MTIcon } from '@masterteam/icons';\nimport { PopoverModule } from 'primeng/popover';\nimport { Skeleton } from 'primeng/skeleton';\nimport { Observable, of, switchMap } from 'rxjs';\n\n// Import pure UI components from @masterteam/components/formula\nimport {\n FormulaToolbar,\n FormulaEditor,\n FormulaEditorCode,\n FormulaStatusBar,\n type SmartBlock,\n type FormulaToken,\n type ToolbarTab,\n type FunctionCategoryGroup,\n type OperatorDefinition,\n DEFAULT_OPERATORS,\n VALIDATION_FUNCTION_CATEGORIES,\n createPropertyBlock,\n createLiteralBlock,\n serializeTokens,\n tokenizeFormulaTemplate,\n} from '@masterteam/components/formula';\n\n// Services are kept in formula-builder (backend logic)\nimport { FormulaValidatorService } from './services/formula-validator.service';\nimport { FormulaContextService } from './services/formula-context.service';\nimport { FormulaAutocompleteService } from './services/formula-autocomplete.service';\nimport type {\n ValidationResult,\n AutocompleteRequest,\n AutocompleteResponse,\n AutocompleteSuggestion,\n} from './models/validation-result.model';\nimport type {\n FormulaBuilderContextResponse,\n FormulaPropertyDescriptor,\n FormulaPropertyItem,\n NextTokenRule,\n OperatorDescriptor,\n} from './models/formula-context.model';\nimport type { FormulaBuilderValue } from './models/formula-builder-value.model';\nimport {\n buildInitialSegments,\n buildTablePath,\n getAllowedValues,\n resolveSegmentsMeta,\n type PathSegment,\n type SegmentMeta,\n} from './utils/formula-path-builder';\nimport { resolveFormulaFunctionCategories } from './utils/formula-function-categories';\n\nconst DEFAULT_SCOPE_ICON: MTIcon = 'general.placeholder';\nconst DEFAULT_TOOLBAR_TABS: readonly ToolbarTab[] = [\n 'functions',\n 'properties',\n 'operators',\n];\nconst PROPERTY_SCOPE_PRIORITY = [\n 'Current',\n 'Host',\n 'Parent',\n 'Children',\n 'Descendants',\n 'Modules',\n 'Schedule',\n] as const;\n\n/**\n * View types whose values come from a fixed item set served by\n * `GET /api/formulas/builder/property-items/{propertyKey}`. Matched after\n * lower-casing and stripping spaces/underscores/dashes so \"Lookup Matrix\",\n * \"lookup_matrix\", etc. all resolve. Mirrors the backend gate\n * (`PropertyItemsLookupSourceResolver.IsLookupBacked` plus `Status`); it\n * rejects any other view type with VAL_001 \"… is not a lookup, lookup matrix,\n * or status type\".\n */\nconst LOOKUP_VIEW_TYPES = new Set([\n 'lookup',\n 'lookupmultiselect',\n 'lookupmatrix',\n 'status',\n]);\n\nexport interface FormulaBuilderUiConfig {\n toolbarTabs?: readonly ToolbarTab[];\n codeOnly?: boolean;\n builderOnly?: boolean;\n valueMode?: 'object' | 'expression';\n hideToolbar?: boolean;\n hideStatusBar?: boolean;\n invalidWhenEmpty?: boolean;\n isProcessBuilder?: boolean;\n contextEntityTypeKey?: string;\n}\n\nconst SCOPE_ICON_MAP: Record<string, MTIcon> = {\n Current: 'map.marker-pin-01',\n Host: 'map.marker-pin-01',\n Level: 'map.marker-pin-01',\n Parent: 'arrow.arrow-up',\n Children: 'user.users-01',\n Descendants: 'custom.hierarchy-structure',\n Modules: 'file.folder-closed',\n Schedule: 'general.placeholder',\n};\n\n@Component({\n selector: 'mt-formula-builder',\n standalone: true,\n imports: [\n CommonModule,\n TranslocoDirective,\n FormsModule,\n Card,\n Button,\n SelectField,\n Tooltip,\n RadioCards,\n ToggleField,\n PopoverModule,\n Skeleton,\n FormulaToolbar,\n FormulaStatusBar,\n FormulaEditor,\n FormulaEditorCode,\n ],\n templateUrl: './formula-builder.html',\n host: {\n class: 'block',\n },\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => FormulaBuilder),\n multi: true,\n },\n ],\n})\nexport class FormulaBuilder implements ControlValueAccessor, OnDestroy {\n private readonly validatorService = inject(FormulaValidatorService);\n private readonly contextService = inject(FormulaContextService);\n private readonly autocompleteService = inject(FormulaAutocompleteService);\n private readonly transloco = inject(TranslocoService);\n\n /** Reference to the formula editor */\n private readonly editor = viewChild<FormulaEditor>('formulaEditor');\n private readonly codeEditor =\n viewChild<FormulaEditorCode>('formulaEditorCode');\n\n // ===== INPUTS =====\n\n /** Properties per table path (e.g., \"Current\", \"Children.Project\") */\n readonly propertiesByPath = input<\n Record<string, { key: string; name?: string }[]>\n >({});\n\n /** Level schema ID for validation context */\n readonly levelSchemaId = input<number>();\n\n /** Optional module ID when the formula is scoped inside a level-linked module */\n readonly moduleId = input<number>();\n\n /**\n * Canonical context identifier — `Module:{id}` / `Level:{id}` /\n * `Level:{id}/Module:{id}`. When set it is the source of truth for the\n * context kind and execution profile: it is the only way to address a\n * standalone module (no workspace/level schema), and the builder loads its\n * context, scopes, functions and validation through it. When omitted the\n * legacy `levelSchemaId` + `moduleId` flow is used unchanged.\n */\n readonly contextKey = input<string>();\n\n /** Optional current context entity key, e.g. LevelData or Risk */\n readonly contextEntityTypeKey = input<string>();\n\n /** Template ID for validation context */\n readonly templateId = input<number>();\n\n /** Placeholder text */\n readonly placeholder = input('');\n\n /** Hide the top toolbar */\n readonly hideToolbar = input(false);\n\n /** Hide the status bar */\n readonly hideStatusBar = input(false);\n\n /**\n * Treat an empty expression as invalid (a required formula). When true, an\n * empty formula reports `isValid: false` with a localized \"required\" error so\n * the status bar shows Invalid and `validationChange` emits an invalid state.\n * Default `false` keeps an empty formula valid, so other consumers that allow\n * empty formulas are unaffected.\n */\n readonly invalidWhenEmpty = input(false);\n\n /** Visible toolbar tabs */\n readonly toolbarTabs = input<readonly ToolbarTab[]>(DEFAULT_TOOLBAR_TABS);\n\n /** Optional host-owned function catalog. Takes precedence over API context. */\n readonly functionCategories = input<FunctionCategoryGroup[]>([]);\n\n /** Operators shown in the formula toolbar. */\n readonly operators = input<OperatorDefinition[]>(DEFAULT_OPERATORS);\n\n /** Force code editor mode and hide the mode toggle */\n readonly codeOnly = input(false);\n\n /** Keep the block builder active and hide the code-mode toggle. */\n readonly builderOnly = input(false);\n\n /** ControlValueAccessor output shape. `expression` emits the formula string. */\n readonly valueMode = input<'object' | 'expression'>('object');\n\n /** Use Process Builder current-only Formula Engine endpoints */\n readonly isProcessBuilder = input(false);\n\n /**\n * Property keys the formula may reference, sent with every validation. For\n * surfaces that author without a schema-context lookup (notification\n * \"send only when\" conditions), this is how the backend learns which\n * Current fields exist.\n */\n readonly knownProperties = input<string[]>();\n\n // ===== OUTPUTS =====\n\n /** Emits validation result on change */\n readonly validationChange = output<ValidationResult>();\n\n /** Emits when tokens change */\n readonly tokensChange = output<FormulaToken[]>();\n\n // ===== STATE =====\n\n /** Editor focus state */\n readonly hasFocus = signal(false);\n\n /** Form control value */\n private readonly expressionValue = signal('');\n private readonly builderValue = signal<FormulaToken[]>([]);\n\n /** Tokens for the editor */\n readonly tokens = signal<FormulaToken[]>([]);\n readonly expression = computed(() => this.expressionValue());\n readonly resolvedContextEntityTypeKey = computed(() => {\n const value = this.contextEntityTypeKey();\n if (typeof value !== 'string') {\n return undefined;\n }\n\n const normalized = value.trim();\n return normalized.length > 0 ? normalized : undefined;\n });\n readonly isModuleContext = computed(() => {\n const contextType =\n this.resolvedContextEntityTypeKey() ??\n this.builderContext()?.contextEntityTypeKey;\n\n if (typeof contextType !== 'string') {\n return false;\n }\n\n const normalized = contextType.trim().toLowerCase();\n return normalized.length > 0 && normalized !== 'leveldata';\n });\n\n /** Trimmed canonical context key, or undefined when not supplied. */\n readonly resolvedContextKey = computed(() => {\n const value = this.contextKey();\n if (typeof value !== 'string') {\n return undefined;\n }\n const normalized = value.trim();\n return normalized.length > 0 ? normalized : undefined;\n });\n\n /**\n * True when authoring is current-only (a standalone module / `Module:{id}`).\n * Prefers the resolved context (execution profile / kind) once loaded, and\n * falls back to the shape of the context key before the context arrives so\n * navigation scopes never flash for a standalone module.\n */\n readonly isCurrentOnlyContext = computed(() => {\n const context = this.builderContext();\n if (context?.executionProfile) {\n return context.executionProfile === 'InlineCurrentOnly';\n }\n if (context?.contextKind === 'StandaloneModule') {\n return true;\n }\n const key = this.resolvedContextKey();\n return key ? /^module:/i.test(key) : false;\n });\n\n /**\n * True when the scope is addressed by the context key alone — a standalone\n * module (`Module:{id}`), whose id is not a level schema id, so sending\n * `levelSchemaId` / `moduleId` alongside it is rejected by the backend.\n * Current-only surfaces without a context key (process / escalation builder)\n * are still addressed by `levelSchemaId` + `moduleId`, and must keep sending\n * them or validation and autocomplete resolve against no schema at all.\n */\n readonly isAddressedByContextKey = computed(\n () => this.isCurrentOnlyContext() && Boolean(this.resolvedContextKey()),\n );\n\n /**\n * Scope tokens the backend allows for this context, or null when it doesn't\n * constrain them (legacy contexts). Used to gate the visible navigation.\n */\n readonly supportedScopeTokens = computed(() => {\n const tokens = this.builderContext()?.supportedScopeTokens;\n return tokens && tokens.length > 0 ? tokens : null;\n });\n\n /**\n * Schema id for downstream properties / next-token / validation calls. The\n * context response is authoritative (a standalone module resolves its own\n * `formulaSchemaId`); falls back to the `levelSchemaId` input for legacy\n * flows and before the context loads.\n */\n readonly effectiveSchemaId = computed(() => {\n const context = this.builderContext();\n return (\n context?.formulaSchemaId ?? context?.schemaId ?? this.levelSchemaId()\n );\n });\n\n readonly autocompleteProvider = (\n request: AutocompleteRequest,\n ): Observable<AutocompleteResponse | null> => {\n const apiMode = this.formulaApiMode();\n\n // Code-mode value picking: when the cursor sits on the right-hand side of a\n // comparison against a lookup property, surface that property's values as\n // suggestions (the builder/blocks editor has no autocomplete — it uses the\n // toolbar Value row instead). The BE autocomplete rejects this cursor\n // position, so we return values directly and skip that doomed call; when the\n // property turns out not to be a lookup we fall back to normal suggestions.\n const valueContext = this.detectLookupValueContext(\n request.formula ?? '',\n request.cursorPosition,\n );\n if (valueContext && this.shouldFetchLookupItems(valueContext.propertyKey)) {\n return this.contextService\n .getPropertyItems(valueContext.propertyKey, apiMode)\n .pipe(\n switchMap((items) =>\n items.length\n ? of(this.buildLookupValueResponse(items, valueContext))\n : this.fetchAutocomplete$(request, apiMode),\n ),\n );\n }\n\n return this.fetchAutocomplete$(request, apiMode);\n };\n\n private fetchAutocomplete$(\n request: AutocompleteRequest,\n apiMode: 'default' | 'current-only',\n ): Observable<AutocompleteResponse | null> {\n const addressedByContextKey = this.isAddressedByContextKey();\n return this.autocompleteService.getSuggestions(\n {\n ...request,\n // A standalone module is addressed only by its context key; a\n // workspace/level schema id alongside it is rejected by the backend.\n levelSchemaId: addressedByContextKey ? undefined : this.levelSchemaId(),\n moduleId: addressedByContextKey ? undefined : this.moduleId(),\n contextKey: this.resolvedContextKey(),\n contextEntityTypeKey:\n this.resolvedContextEntityTypeKey() ??\n this.builderContext()?.contextEntityTypeKey,\n },\n apiMode,\n );\n }\n\n /** Editor mode */\n readonly editorMode = signal<'builder' | 'code'>('builder');\n readonly isCodeMode = computed(() => this.editorMode() === 'code');\n readonly showModeToggle = computed(\n () => !this.codeOnly() && !this.builderOnly(),\n );\n readonly formulaApiMode = computed<'default' | 'current-only'>(() =>\n this.isProcessBuilder() ? 'current-only' : 'default',\n );\n readonly resolvedToolbarTabs = computed(() => {\n const tabs = this.toolbarTabs();\n return tabs.length > 0 ? tabs : DEFAULT_TOOLBAR_TABS;\n });\n\n /** ControlValueAccessor callbacks */\n private onChange: (value: FormulaBuilderValue | string) => void = () => {};\n private onTouched: () => void = () => {};\n\n /** Disabled state */\n private readonly isDisabled = signal(false);\n\n /**\n * Validation result surfaced to the status bar and the `validationChange`\n * output. Normally mirrors the validator service; when `invalidWhenEmpty` is\n * set and the expression is empty it reports an invalid \"required\" result so\n * the status bar (Invalid + message) and any host-side validity agree that an\n * empty formula is not acceptable here. See `invalidWhenEmpty`.\n */\n readonly validation = computed<ValidationResult>(() => {\n const base = this.validatorService.validation();\n if (this.invalidWhenEmpty() && this.expressionValue().trim().length === 0) {\n return {\n isValid: false,\n errors: [\n {\n message: this.transloco.translate('formulaBuilder.errors.required'),\n line: 1,\n column: 1,\n severity: 'Error',\n },\n ],\n warnings: [],\n dependencies: [],\n complexity: 0,\n };\n }\n return base;\n });\n\n /** Is validation in progress */\n readonly isValidating = this.validatorService.isValidating;\n\n /** Builder context from API */\n readonly builderContext = signal<FormulaBuilderContextResponse | null>(null);\n\n /** Function categories from the host, context API, or validation fallback. */\n readonly resolvedFunctionCategories = computed(() =>\n resolveFormulaFunctionCategories(\n this.functionCategories(),\n this.builderContext()?.functions?.categories ?? [],\n VALIDATION_FUNCTION_CATEGORIES,\n ),\n );\n\n /** Is builder context loading */\n readonly isContextLoading = signal(false);\n\n private contextRequestId = 0;\n\n /** Properties loaded from API */\n private readonly propertiesByPathApi = signal<\n Record<string, FormulaPropertyDescriptor[]>\n >({});\n\n /** Current property list loading path */\n private readonly propertyLoadingPath = signal<string | null>(null);\n\n constructor() {\n effect(() => {\n const shouldUseCodeMode = this.shouldUseCodeMode();\n\n if (this.builderOnly() && this.editorMode() !== 'builder') {\n this.editorMode.set('builder');\n return;\n }\n\n if (shouldUseCodeMode && this.editorMode() !== 'code') {\n this.editorMode.set('code');\n }\n });\n\n // Validate when formula changes\n effect(() => {\n const formula = this.expressionValue();\n const apiMode = this.formulaApiMode();\n const contextKey = this.resolvedContextKey();\n const addressedByContextKey = this.isAddressedByContextKey();\n const knownProperties = this.knownProperties();\n if (formula && formula.trim().length > 0) {\n this.validatorService.validate(\n formula,\n knownProperties,\n addressedByContextKey ? undefined : this.levelSchemaId(),\n addressedByContextKey ? undefined : this.moduleId(),\n this.templateId(),\n apiMode,\n contextKey,\n );\n }\n });\n\n // Emit validation changes\n effect(() => {\n const validation = this.validation();\n this.validationChange.emit(validation);\n });\n\n // Re-resolve friendly property display labels once the property map loads.\n // Properties arrive asynchronously, so tokens built before they were ready\n // (e.g. hydrating an expression-only formula, or a code->blocks switch)\n // initially show raw keys. Display is cosmetic — the executable expression\n // (token.value) and validation are unchanged — so this only refreshes the\n // visual chips and the friendly preview. Reading builderValue untracked +\n // the identity guard in enrichTokenDisplays keeps this loop-safe.\n effect(() => {\n this.mergedPropertiesByPath();\n const current = untracked(() => this.builderValue());\n const enriched = this.enrichTokenDisplays(current);\n if (enriched !== current) {\n this.setBuilderTokens(enriched, { writeVisualEditor: true });\n this.emitValueChange();\n }\n });\n\n // Load builder context when schema or context key changes\n effect(() => {\n const schemaId = this.levelSchemaId();\n const moduleId = this.moduleId();\n const apiMode = this.formulaApiMode();\n const contextEntityTypeKey = this.resolvedContextEntityTypeKey();\n const contextKey = this.resolvedContextKey();\n\n // A standalone module has no level schema id — the context key alone is\n // enough to load its context.\n if (!schemaId && !contextKey) {\n this.builderContext.set(null);\n this.propertiesByPathApi.set({});\n this.nextTokenRulesByPath.set({});\n this.isContextLoading.set(false);\n return;\n }\n\n const requestId = ++this.contextRequestId;\n this.isContextLoading.set(true);\n this.propertiesByPathApi.set({});\n this.nextTokenRulesByPath.set({});\n this.contextService\n .loadContext(\n schemaId,\n moduleId,\n contextEntityTypeKey,\n apiMode,\n contextKey,\n )\n .subscribe((context) => {\n if (requestId !== this.contextRequestId) {\n return;\n }\n\n this.builderContext.set(context);\n this.isContextLoading.set(false);\n\n if (!context) {\n return;\n }\n\n if (context.currentProperties?.length) {\n this.propertiesByPathApi.update((current) => ({\n ...current,\n Current: context.currentProperties,\n }));\n }\n });\n });\n\n // Load the value set of the selected field when it is a lookup-style\n // property (lookup / lookup matrix / status). Resets the picked value\n // whenever the field changes; a stale-request guard keeps the latest pick.\n effect(() => {\n const property = this.selectedProperty();\n const isLookup = this.isLookupProperty();\n const apiMode = this.formulaApiMode();\n\n this.lookupValueKey.set('');\n\n if (!property || !isLookup) {\n this.lookupItems.set([]);\n this.isLookupItemsLoading.set(false);\n return;\n }\n\n const requestId = ++this.lookupItemsRequestId;\n this.isLookupItemsLoading.set(true);\n this.lookupItems.set([]);\n this.contextService\n .getPropertyItems(property.key, apiMode)\n .subscribe((items) => {\n if (requestId !== this.lookupItemsRequestId) {\n return;\n }\n this.lookupItems.set(items);\n this.isLookupItemsLoading.set(false);\n });\n });\n\n // Ensure selected scope exists in available options\n effect(() => {\n const scopes = this.availableScopes();\n if (scopes.length === 0) return;\n const current = this.propertyScope();\n if (!scopes.some((scope) => scope.key === current)) {\n this.setPropertyScope(scopes[0].key);\n }\n });\n\n // Fetch properties for the selected table path\n effect(() => {\n const schemaId = this.effectiveSchemaId();\n const contextKey = this.resolvedContextKey();\n const moduleId = contextKey ? undefined : this.moduleId();\n const apiMode = this.formulaApiMode();\n const tablePath = this.resolvedTablePath();\n const component = this.propertiesComponent();\n const context = this.builderContext();\n\n if (!schemaId || !tablePath || !context) {\n this.propertyLoadingPath.set(null);\n return;\n }\n\n const existing = this.propertiesByPathApi()[tablePath];\n if (existing !== undefined) {\n this.propertyLoadingPath.set(null);\n return;\n }\n\n this.propertyLoadingPath.set(tablePath);\n this.contextService\n .getScopeProperties(\n schemaId,\n component,\n tablePath,\n moduleId,\n apiMode,\n contextKey,\n )\n .subscribe((props) => {\n this.propertiesByPathApi.update((current) => ({\n ...current,\n [tablePath]: props ?? [],\n }));\n if (this.propertyLoadingPath() === tablePath) {\n this.propertyLoadingPath.set(null);\n }\n });\n });\n\n // Fetch next-token rules for the selected base scope so the first\n // parameter popover can use localized allowedValueItems.\n effect(() => {\n const schemaId = this.effectiveSchemaId();\n const contextKey = this.resolvedContextKey();\n const moduleId = contextKey ? undefined : this.moduleId();\n const isProcessBuilder = this.isProcessBuilder();\n const scope = this.propertyScope();\n const component = this.propertiesComponent();\n const context = this.builderContext();\n const operator = this.baseOperator();\n const contextRule = this.contextBaseRule();\n const needsParameter =\n Boolean(operator?.parameterKind) ||\n Boolean(operator?.requiresParameter) ||\n Boolean(contextRule?.parameterKind);\n\n if (\n isProcessBuilder ||\n !schemaId ||\n !scope ||\n !component ||\n !context ||\n !needsParameter\n ) {\n return;\n }\n\n if (this.nextTokenRulesByPath()[scope]) return;\n\n this.contextService\n .getNextTokens(\n schemaId,\n component,\n scope,\n moduleId,\n 'default',\n contextKey,\n )\n .subscribe((response) => {\n if (!response) return;\n this.nextTokenRulesByPath.update((current) => ({\n ...current,\n [scope]: response.nextTokenRules ?? {},\n }));\n });\n });\n\n // Fetch next-token rules for the current table path\n effect(() => {\n const schemaId = this.effectiveSchemaId();\n const contextKey = this.resolvedContextKey();\n const moduleId = contextKey ? undefined : this.moduleId();\n const isProcessBuilder = this.isProcessBuilder();\n const tablePath = this.resolvedTablePath();\n const component = this.propertiesComponent();\n\n if (isProcessBuilder || !schemaId || !tablePath || !component) return;\n\n if (this.nextTokenRulesByPath()[tablePath]) return;\n\n this.contextService\n .getNextTokens(\n schemaId,\n component,\n tablePath,\n moduleId,\n 'default',\n contextKey,\n )\n .subscribe((response) => {\n if (!response) return;\n this.nextTokenRulesByPath.update((current) => ({\n ...current,\n [tablePath]: response.nextTokenRules ?? {},\n }));\n });\n });\n\n // Keep base segment in sync with scope metadata\n effect(() => {\n const scope = this.propertyScope();\n const operator = this.baseOperator();\n const shouldHaveSegment =\n Boolean(operator?.parameterKind) ||\n Boolean(operator?.requiresParameter);\n const segments = this.propertyPathSegments();\n const hasBase = segments[0]?.operatorToken === scope;\n\n if (shouldHaveSegment && !hasBase) {\n this.propertyPathSegments.set(\n buildInitialSegments(scope, operator, this.baseRule()),\n );\n return;\n }\n\n if (!shouldHaveSegment && hasBase) {\n this.propertyPathSegments.set(segments.slice(1));\n }\n });\n\n // Normalize segment values when allowed values change\n effect(() => {\n const meta = this.pathSegments();\n const segments = this.propertyPathSegments();\n if (meta.length !== segments.length) return;\n\n let changed = false;\n const next = segments.map((segment, index) => {\n const normalized = meta[index]?.value ?? segment.value;\n if (segment.value !== normalized) {\n changed = true;\n return { ...segment, value: normalized };\n }\n return segment;\n });\n\n if (changed) {\n this.propertyPathSegments.set(next);\n }\n });\n\n // Ensure selected field exists in current options\n effect(() => {\n const options = this.propertyOptions();\n const current = this.propertyFieldKey();\n\n if (options.length === 0) {\n if (current) this.propertyFieldKey.set('');\n return;\n }\n\n if (current && !options.some((prop) => prop.key === current)) {\n this.propertyFieldKey.set('');\n }\n });\n }\n\n ngOnDestroy(): void {\n this.validatorService.reset();\n }\n\n // ===== ControlValueAccessor =====\n\n writeValue(value: FormulaBuilderValue | string | null): void {\n if (!value) {\n this.expressionValue.set('');\n this.applyFormulaValue([], '', this.shouldUseCodeMode());\n this.validatorService.reset();\n return;\n }\n\n if (typeof value === 'string') {\n const expression = value;\n const builder = this.rebuildBuilderFromExpression(expression);\n this.expressionValue.set(expression);\n this.applyFormulaValue(builder, expression, this.shouldUseCodeMode());\n return;\n }\n\n const inputBuilder = Array.isArray(value.builder) ? value.builder : [];\n const expression = this.resolveExpressionValue(\n value.expression ?? '',\n inputBuilder,\n );\n const builder =\n inputBuilder.length > 0\n ? this.enrichTokenDisplays(inputBuilder)\n : this.rebuildBuilderFromExpression(expression);\n this.expressionValue.set(expression);\n\n if (this.shouldUseCodeMode()) {\n this.applyFormulaValue(builder, expression, true);\n return;\n }\n\n this.applyFormulaValue(builder, expression, false);\n }\n\n registerOnChange(fn: (value: FormulaBuilderValue | string) => void): void {\n this.onChange = fn;\n }\n\n registerOnTouched(fn: () => void): void {\n this.onTouched = fn;\n }\n\n setDisabledState(isDisabled: boolean): void {\n this.isDisabled.set(isDisabled);\n }\n\n /** Handle formula change from editor */\n onFormulaChange(newFormula: string): void {\n this.expressionValue.set(newFormula);\n this.emitValueChange();\n }\n\n /** Handle formula change from code editor */\n onCodeFormulaChange(newFormula: string): void {\n this.expressionValue.set(newFormula);\n this.syncBuilderFromExpression(newFormula, {\n emitTokensChange: true,\n writeVisualEditor: false,\n });\n this.emitValueChange();\n }\n\n /** Handle block insert from toolbar */\n onBlockInsert(block: SmartBlock): void {\n if (this.isDisabled()) return;\n if (this.isCodeMode()) {\n const editor = this.codeEditor();\n if (editor) {\n editor.addBlock(block);\n }\n return;\n }\n const editor = this.editor();\n if (editor) {\n editor.addBlock(block);\n }\n }\n\n /** Handle tokens change */\n onTokensChange(newTokens: FormulaToken[]): void {\n this.setBuilderTokens(newTokens, {\n emitTokensChange: true,\n writeVisualEditor: false,\n });\n this.emitValueChange();\n }\n\n onEditorFocus(): void {\n this.hasFocus.set(true);\n }\n\n onEditorBlur(): void {\n this.hasFocus.set(false);\n this.onTouched();\n }\n\n private emitValueChange(): void {\n if (this.valueMode() === 'expression') {\n this.onChange(this.expressionValue());\n return;\n }\n\n this.onChange({\n expression: this.expressionValue(),\n builder: this.builderValue(),\n });\n }\n\n onModeToggle(value: boolean): void {\n if (this.isDisabled() || this.codeOnly() || this.builderOnly()) {\n return;\n }\n const nextMode: 'builder' | 'code' = value ? 'code' : 'builder';\n this.setEditorMode(nextMode);\n }\n\n private setEditorMode(mode: 'builder' | 'code'): void {\n if (this.editorMode() === mode) return;\n\n if (mode === 'code') {\n this.enterCodeMode();\n return;\n }\n\n this.exitCodeMode();\n }\n\n private enterCodeMode(): void {\n const editor = this.editor();\n if (editor) {\n const formula = editor.serialize();\n this.expressionValue.set(formula);\n this.emitValueChange();\n }\n this.editorMode.set('code');\n }\n\n private exitCodeMode(): void {\n this.editorMode.set('builder');\n // An unchanged expression already has tokens with friendly lookup labels.\n // Rebuilding those on every toggle would discard that display metadata.\n if (serializeTokens(this.builderValue()) !== this.expressionValue()) {\n this.syncBuilderFromExpression(this.expressionValue(), {\n emitTokensChange: true,\n writeVisualEditor: true,\n });\n }\n this.emitValueChange();\n }\n\n // ===== PUBLIC METHODS =====\n\n /** Clear the formula */\n clear(): void {\n this.expressionValue.set('');\n this.applyFormulaValue([], '', this.shouldUseCodeMode());\n this.validatorService.reset();\n this.emitValueChange();\n }\n\n private shouldUseCodeMode(): boolean {\n return this.codeOnly() && !this.builderOnly();\n }\n\n private resolveExpressionValue(\n expression: string,\n builder: FormulaToken[],\n ): string {\n if (expression.trim().length > 0) {\n return expression;\n }\n return builder.length > 0 ? serializeTokens(builder) : '';\n }\n\n private applyFormulaValue(\n builder: FormulaToken[],\n expression: string,\n useCodeMode: boolean,\n ): void {\n this.setBuilderTokens(builder, { writeVisualEditor: true });\n\n const codeEditor = this.codeEditor();\n if (codeEditor) {\n codeEditor.writeValue(expression);\n }\n\n if (useCodeMode) {\n this.editorMode.set('code');\n return;\n }\n\n this.editorMode.set('builder');\n }\n\n private rebuildBuilderFromExpression(expression: string): FormulaToken[] {\n const normalized = expression.trim();\n return this.enrichTokenDisplays(\n normalized ? tokenizeFormulaTemplate(normalized) : [],\n );\n }\n\n /**\n * Resolve friendly display labels on property tokens from the loaded property\n * map (table path -> [{ key, name }]). This lets the visual builder render\n * \"Start Date\" instead of the raw \"@Current::dema_qa_portfolio_startdate\" key\n * after a code->blocks switch or when hydrating an expression-only formula.\n * Pure and loop-safe: returns the SAME array reference when nothing changed,\n * and only touches `display` — never `value` — so the executable expression\n * and validation are unaffected.\n */\n private enrichTokenDisplays(tokens: FormulaToken[]): FormulaToken[] {\n if (tokens.length === 0) {\n return tokens;\n }\n const byPath = this.mergedPropertiesByPath();\n let changed = false;\n const next = tokens.map((token) => {\n if (token.type !== 'property' || !token.value.startsWith('@')) {\n return token;\n }\n const separator = token.value.lastIndexOf('::');\n if (separator < 0) {\n return token;\n }\n const path = token.value.slice(1, separator);\n const key = token.value.slice(separator + 2);\n const match = byPath[path]?.find((prop) => prop.key === key);\n const display =\n match?.name?.trim() || match?.viewTypeName?.display || token.display;\n if (display && display !== token.display) {\n changed = true;\n return { ...token, display };\n }\n return token;\n });\n return changed ? next : tokens;\n }\n\n private syncBuilderFromExpression(\n expression: string,\n options?: {\n emitTokensChange?: boolean;\n writeVisualEditor?: boolean;\n },\n ): void {\n this.setBuilderTokens(this.rebuildBuilderFromExpression(expression), {\n emitTokensChange: options?.emitTokensChange,\n writeVisualEditor: options?.writeVisualEditor,\n });\n }\n\n private setBuilderTokens(\n builder: FormulaToken[],\n options?: {\n emitTokensChange?: boolean;\n writeVisualEditor?: boolean;\n },\n ): void {\n this.builderValue.set(builder);\n this.tokens.set(builder);\n\n if (options?.writeVisualEditor ?? true) {\n const editor = this.editor();\n if (editor) {\n editor.writeValue(builder);\n }\n }\n\n if (options?.emitTokensChange) {\n this.tokensChange.emit(builder);\n }\n }\n\n // ===== PROPERTY COMPOSER =====\n\n readonly propertyScope = signal<string>('');\n\n readonly propertyPathSegments = signal<PathSegment[]>([]);\n\n readonly propertyFieldKey = signal('');\n\n private readonly nextTokenRulesByPath = signal<\n Record<string, Record<string, NextTokenRule>>\n >({});\n\n readonly contextOperators = computed<OperatorDescriptor[]>(() => {\n return this.builderContext()?.schemaDescriptor?.operators ?? [];\n });\n\n readonly baseOperator = computed(() =>\n this.contextOperators().find((op) => op.token === this.propertyScope()),\n );\n\n readonly contextBaseRule = computed(() => {\n const scope = this.propertyScope();\n return this.builderContext()?.schemaDescriptor?.nextTokenRules?.[scope];\n });\n\n readonly baseRule = computed(() => {\n const scope = this.propertyScope();\n return (\n this.nextTokenRulesByPath()[scope]?.[scope] ?? this.contextBaseRule()\n );\n });\n\n readonly availableScopes = computed(() => {\n // When the backend constrains scope tokens (e.g. a standalone module allows\n // only `Current`), never surface a navigation scope outside that set.\n const allowedTokens = this.supportedScopeTokens();\n const isAllowedScope = (token: string) =>\n !allowedTokens || allowedTokens.includes(token);\n\n const operators = this.contextOperators();\n if (operators.length === 0) {\n const propertiesByPath = this.mergedPropertiesByPath();\n return Object.keys(propertiesByPath)\n .filter(\n (path) =>\n (propertiesByPath[path] ?? []).length > 0 && isAllowedScope(path),\n )\n .map((path) => ({\n key: path,\n label: `@${path}`,\n requiresParam: false,\n optional: true,\n }));\n }\n const baseRules =\n this.builderContext()?.schemaDescriptor?.nextTokenRules ?? {};\n const priority = new Map<string, number>(\n PROPERTY_SCOPE_PRIORITY.map((token, index) => [token, index]),\n );\n const scopedOperators = operators.filter(\n (operator) =>\n operator.token.trim().length > 0 && isAllowedScope(operator.token),\n );\n\n return [...scopedOperators]\n .filter((operator) => {\n const parameterKind =\n baseRules[operator.token]?.parameterKind ?? operator.parameterKind;\n const requiresParameter =\n operator.requiresParameter ?? Boolean(parameterKind);\n\n return (\n (!parameterKind && !requiresParameter) ||\n getAllowedValues(baseRules[operator.token]).length > 0\n );\n })\n .sort((a, b) => {\n const aPriority = priority.get(a.token) ?? Number.MAX_SAFE_INTEGER;\n const bPriority = priority.get(b.token) ?? Number.MAX_SAFE_INTEGER;\n if (aPriority !== bPriority) {\n return aPriority - bPriority;\n }\n return a.token.localeCompare(b.token);\n })\n .map((operator) => ({\n key: operator.token,\n label: `@${operator.token}`,\n requiresParam: operator.requiresParameter ?? false,\n optional: !operator.requiresParameter,\n }));\n });\n\n /** Radio card options for scope selection */\n readonly scopeOptions = computed<RadioItem[]>(() =>\n this.availableScopes().map((scope) => ({\n id: scope.key,\n name: this.getOperatorDisplayName(scope.key),\n icon: SCOPE_ICON_MAP[scope.key] ?? DEFAULT_SCOPE_ICON,\n })),\n );\n\n /** Handle scope selection from radio cards */\n onScopeChange(item: RadioItem): void {\n this.setPropertyScope(String(item.id));\n }\n\n readonly pathSegments = computed<SegmentMeta[]>(() => {\n const scope = this.propertyScope();\n return resolveSegmentsMeta({\n scope,\n segments: this.propertyPathSegments(),\n operators: this.contextOperators(),\n baseRule: this.baseRule(),\n rulesByPath: this.nextTokenRulesByPath(),\n });\n });\n\n readonly isDirectAccess = computed(() => {\n const operator = this.baseOperator();\n const needsParameter =\n Boolean(operator?.parameterKind) || Boolean(operator?.requiresParameter);\n return !needsParameter && this.pathSegments().length === 0;\n });\n\n readonly propertyTablePath = computed(() =>\n buildTablePath(\n this.propertyScope(),\n this.pathSegments(),\n this.baseOperator(),\n false,\n ),\n );\n\n readonly resolvedTablePath = computed(() =>\n buildTablePath(\n this.propertyScope(),\n this.pathSegments(),\n this.baseOperator(),\n true,\n ),\n );\n\n readonly currentNextTokenRules = computed(() => {\n const path = this.resolvedTablePath();\n if (!path) return {};\n return this.nextTokenRulesByPath()[path] ?? {};\n });\n\n readonly nextOperatorOptions = computed(() => {\n const rules = this.currentNextTokenRules();\n const operators = this.contextOperators();\n return Object.keys(rules)\n .map((token) => {\n const rule = rules[token];\n const operator = operators.find((item) => item.token === token);\n const parameterKind =\n rule?.parameterKind ?? operator?.parameterKind ?? null;\n const requiresParameter =\n operator?.requiresParameter ?? Boolean(parameterKind);\n const allowedValues = getAllowedValues(rule);\n return {\n token,\n rule,\n requiresParameter,\n allowedValues,\n };\n })\n .filter(\n (option) =>\n option.allowedValues.length > 0 || !option.requiresParameter,\n );\n });\n\n readonly canAddNextSegment = computed(() => {\n if (this.nextOperatorOptions().length === 0) return false;\n const segments = this.pathSegments();\n if (segments.length === 0 || !segments[0].value) {\n return false;\n }\n return segments.every(\n (segment) => !segment.requiresParameter || Boolean(segment.value),\n );\n });\n\n readonly propertiesComponent = computed(() => {\n return this.builderContext()?.contextEntityTypeKey;\n });\n\n readonly mergedPropertiesByPath = computed<\n Record<string, FormulaPropertyDescriptor[]>\n >(() => {\n const merged: Record<string, FormulaPropertyDescriptor[]> = {\n ...this.propertiesByPath(),\n };\n const apiProps = this.propertiesByPathApi();\n Object.entries(apiProps).forEach(([path, props]) => {\n if (props && props.length > 0) {\n merged[path] = props;\n }\n });\n return merged;\n });\n\n readonly isPropertyLoading = computed(() => {\n const path = this.resolvedTablePath();\n return Boolean(path) && this.propertyLoadingPath() === path;\n });\n\n readonly propertyOptions = computed(() => {\n const path = this.resolvedTablePath();\n if (!path) return [];\n const byPath = this.mergedPropertiesByPath()[path];\n const list = byPath && byPath.length > 0 ? byPath : [];\n return list.map((prop) => ({\n key: prop.key,\n name: prop.name?.trim() || prop.viewTypeName?.display || prop.key,\n viewType: prop.viewType,\n }));\n });\n\n readonly selectedProperty = computed(() => {\n const key = this.propertyFieldKey();\n return this.propertyOptions().find((prop) => prop.key === key) ?? null;\n });\n\n /** Selectable values of the chosen lookup/status/lookup-matrix property. */\n readonly lookupItems = signal<FormulaPropertyItem[]>([]);\n\n /** Whether the property-items request is in flight. */\n readonly isLookupItemsLoading = signal(false);\n\n /** Currently selected lookup value key (the form inserted into the formula). */\n readonly lookupValueKey = signal('');\n\n private lookupItemsRequestId = 0;\n\n /** True when the selected field draws its values from a fixed lookup set. */\n readonly isLookupProperty = computed(() => {\n const viewType = this.selectedProperty()?.viewType;\n if (!viewType) return false;\n return LOOKUP_VIEW_TYPES.has(viewType.toLowerCase().replace(/[\\s_-]/g, ''));\n });\n\n /** Insert-value action is enabled once a lookup value has been picked. */\n readonly canInsertLookupValue = computed(\n () => this.isLookupProperty() && Boolean(this.lookupValueKey()),\n );\n\n readonly canInsertProperty = computed(() => {\n if (!this.selectedProperty()) return false;\n return Boolean(this.resolvedTablePath());\n });\n\n setPropertyScope(scope: string): void {\n if (this.propertyScope() === scope) {\n return;\n }\n this.propertyScope.set(scope);\n this.propertyPathSegments.set(\n buildInitialSegments(\n scope,\n this.contextOperators().find((op) => op.token === scope),\n this.baseRule(),\n ),\n );\n this.propertyFieldKey.set('');\n }\n\n setPathSegmentValue(index: number, value: string | null): void {\n this.propertyPathSegments.update((segments) => {\n // Update the segment at the given index and remove all segments after it\n // because subsequent segments depend on previous values\n const updated = segments.slice(0, index + 1);\n updated[index] = { ...updated[index], value: value ?? '' };\n return updated;\n });\n }\n\n addNextSegment(operatorToken: string): void {\n const value = '';\n\n this.propertyPathSegments.update((segments) => [\n ...segments,\n { operatorToken, value },\n ]);\n }\n\n onAddSegmentSelection(\n operatorToken: string,\n popover: { hide: () => void },\n ): void {\n popover.hide();\n this.addNextSegment(operatorToken);\n }\n\n removePathSegment(index: number): void {\n this.propertyPathSegments.update((segments) =>\n segments.filter((_, i) => i !== index),\n );\n }\n\n segmentOptions(index: number): { key: string; name: string }[] {\n const segment = this.pathSegments()[index];\n if (!segment) return [];\n return segment.allowedValueItems;\n }\n\n insertSelectedProperty(insertBlock: (block: SmartBlock) => void): void {\n const prop = this.selectedProperty();\n if (!prop) return;\n\n if (!this.canInsertProperty()) return;\n\n const tablePath = this.resolvedTablePath();\n if (!tablePath) return;\n const display = prop.name ?? prop.key;\n const block = createPropertyBlock(\n `@${tablePath}::${prop.key}`,\n 'current',\n display,\n );\n insertBlock(block);\n }\n\n /**\n * Insert the picked lookup value as a string literal. The executable form\n * carries the stable lookup KEY (locale-independent) while the chip shows\n * the friendly NAME — e.g. `… == \"completed\"` rendered as `… == Completed`.\n */\n insertSelectedLookupValue(insertBlock: (block: SmartBlock) => void): void {\n if (!this.canInsertLookupValue()) return;\n\n const key = this.lookupValueKey();\n const item = this.lookupItems().find((value) => value.key === key);\n if (!item) return;\n\n insertBlock({ ...createLiteralBlock(item.key), display: item.name });\n }\n\n /**\n * Detect that the cursor (in the code editor) is positioned to type the\n * right-hand value of a comparison against a property, e.g.\n * `@Current::task_status == \"in_`. Returns the compared property key, whether\n * an opening quote was already typed, and the partial value typed so far.\n */\n private detectLookupValueContext(\n formula: string,\n cursorPosition: number,\n ): { propertyKey: string; partial: string; hasOpenQuote: boolean } | null {\n const before = formula.slice(0, Math.max(0, cursorPosition));\n const match = before.match(\n /@[A-Za-z][\\w.]*::([A-Za-z_]\\w*)\\s*(?:==|!=|<>|=|\\bin\\b)\\s*\\[?\\s*(\")?([^\"'\\]@]*)$/i,\n );\n if (!match) return null;\n return {\n propertyKey: match[1],\n hasOpenQuote: Boolean(match[2]),\n partial: match[3] ?? '',\n };\n }\n\n /**\n * Avoid a wasted request for properties we already know aren't lookups; for\n * keys whose view type isn't loaded yet, let property-items be the authority.\n */\n private shouldFetchLookupItems(propertyKey: string): boolean {\n const viewType = this.findLoadedPropertyViewType(propertyKey);\n if (!viewType) return true;\n return LOOKUP_VIEW_TYPES.has(viewType.toLowerCase().replace(/[\\s_-]/g, ''));\n }\n\n private findLoadedPropertyViewType(propertyKey: string): string | undefined {\n const byPath = this.mergedPropertiesByPath();\n for (const props of Object.values(byPath)) {\n const found = props.find((prop) => prop.key === propertyKey);\n if (found?.viewType) return found.viewType;\n }\n return undefined;\n }\n\n /**\n * Build an autocomplete response from a lookup property's values. The inserted\n * text carries the stable key wrapped in quotes (the opening quote is dropped\n * when the user already typed one), matching the key-as-value contract used by\n * the toolbar Value row.\n */\n private buildLookupValueResponse(\n items: FormulaPropertyItem[],\n context: { partial: string; hasOpenQuote: boolean },\n ): AutocompleteResponse {\n const needle = context.partial.trim().toLowerCase();\n const valueLabel = this.transloco.translate(\n 'formulaBuilder.properties.value',\n );\n\n const suggestions: AutocompleteSuggestion[] = items\n .filter(\n (item) =>\n !needle ||\n item.name.toLowerCase().includes(needle) ||\n item.key.toLowerCase().includes(needle),\n )\n .map((item) => {\n const insertText = `${context.hasOpenQuote ? '' : '\"'}${item.key}\"`;\n return {\n text: insertText,\n displayText: item.name,\n type: 'Keyword',\n description: valueLabel,\n insertText,\n category: valueLabel,\n };\n });\n\n return {\n suggestions,\n context: { type: 'None', scope: '', prefix: '' },\n };\n }\n\n getOperatorDisplayName(token: string): string {\n if (token === 'Host' && this.isModuleContext()) {\n return this.transloco.translate('formulaBuilder.operatorNames.level');\n }\n\n const key = `formulaBuilder.operatorNames.${token.toLowerCase()}`;\n const translated = this.transloco.translate(key);\n return translated && translated !== key ? translated : token;\n }\n}\n","<mt-card\r\n headless\r\n [class.ring-2]=\"hasFocus()\"\r\n [class.ring-primary]=\"hasFocus()\"\r\n [paddingless]=\"true\"\r\n>\r\n <div\r\n *transloco=\"let t; prefix: 'formulaBuilder'\"\r\n class=\"flex flex-col overflow-hidden\"\r\n >\r\n <!-- Toolbar - Pass data via inputs (pure component) -->\r\n @if (!hideToolbar()) {\r\n <mt-formula-toolbar\r\n [functionCategories]=\"resolvedFunctionCategories()\"\r\n [operators]=\"operators()\"\r\n [visibleTabs]=\"resolvedToolbarTabs()\"\r\n (onBlockInsert)=\"onBlockInsert($event)\"\r\n >\r\n <ng-template #properties let-insertBlock=\"insertBlock\">\r\n @if (isContextLoading()) {\r\n <div class=\"flex flex-col gap-4 p-4\">\r\n <div class=\"flex items-center justify-between gap-4\">\r\n <p-skeleton\r\n width=\"18rem\"\r\n height=\"2.5rem\"\r\n styleClass=\"rounded-md\"\r\n />\r\n <p-skeleton\r\n width=\"7rem\"\r\n height=\"2.5rem\"\r\n styleClass=\"rounded-md\"\r\n />\r\n </div>\r\n <div class=\"flex items-center gap-4\">\r\n <div\r\n class=\"flex min-h-11 min-w-0 flex-1 flex-col gap-2 rounded-lg bg-slate-50 px-3 py-2 dark:bg-slate-800/50\"\r\n >\r\n <div class=\"flex items-center gap-2\">\r\n <p-skeleton\r\n width=\"3rem\"\r\n height=\"1rem\"\r\n styleClass=\"rounded-md\"\r\n />\r\n <div\r\n class=\"h-4 w-px shrink-0 bg-slate-200 dark:bg-slate-700\"\r\n ></div>\r\n <p-skeleton\r\n class=\"flex-1\"\r\n height=\"2rem\"\r\n styleClass=\"rounded-md\"\r\n />\r\n </div>\r\n <div\r\n class=\"flex items-center gap-2 border-t border-slate-200 pt-2 dark:border-slate-700\"\r\n >\r\n <p-skeleton\r\n width=\"3rem\"\r\n height=\"1rem\"\r\n styleClass=\"rounded-md\"\r\n />\r\n <div\r\n class=\"h-4 w-px shrink-0 bg-slate-200 dark:bg-slate-700\"\r\n ></div>\r\n <p-skeleton\r\n class=\"flex-1\"\r\n height=\"2.5rem\"\r\n styleClass=\"rounded-md\"\r\n />\r\n </div>\r\n <p-skeleton height=\"2rem\" styleClass=\"rounded-md\" />\r\n </div>\r\n </div>\r\n </div>\r\n } @else {\r\n <div class=\"flex flex-col gap-4 p-4\">\r\n <!-- Scope Selection - Full width, centered -->\r\n <div class=\"flex items-center justify-between gap-4\">\r\n <mt-radio-cards\r\n [options]=\"scopeOptions()\"\r\n [activeId]=\"propertyScope()\"\r\n (selectionChange)=\"onScopeChange($event)\"\r\n size=\"small\"\r\n />\r\n </div>\r\n\r\n <!-- Path + Field + Preview Row -->\r\n <div class=\"flex items-center gap-4\">\r\n <!-- Path Container - Flexible -->\r\n <div\r\n class=\"flex min-h-11 min-w-0 flex-1 flex-col gap-2 rounded-lg bg-slate-50 px-3 py-2 dark:bg-slate-800/50\"\r\n >\r\n <div class=\"flex items-center gap-2\">\r\n <span\r\n class=\"shrink-0 text-xs font-semibold uppercase tracking-wider text-slate-400\"\r\n >{{ t(\"properties.path\") }}</span\r\n >\r\n <div\r\n class=\"h-4 w-px shrink-0 bg-slate-200 dark:bg-slate-700\"\r\n ></div>\r\n <div class=\"flex min-w-0 flex-1 items-center gap-2\">\r\n @if (isDirectAccess()) {\r\n <span\r\n class=\"rounded-md bg-emerald-100 px-2.5 py-1 text-xs font-medium text-emerald-600 dark:bg-emerald-900/30 dark:text-emerald-400\"\r\n >\r\n ✓ {{ t(\"properties.direct-access\") }}\r\n </span>\r\n } @else if (pathSegments().length === 0) {\r\n <span class=\"text-xs italic text-slate-400\">{{\r\n t(\"properties.no-path-configured\")\r\n }}</span>\r\n } @else {\r\n <div\r\n class=\"flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto\"\r\n >\r\n @for (\r\n segment of pathSegments();\r\n track $index;\r\n let segmentIndex = $index\r\n ) {\r\n @if (segmentIndex > 0) {\r\n <span\r\n class=\"shrink-0 text-slate-300 dark:text-slate-600\"\r\n >›</span\r\n >\r\n }\r\n <mt-button\r\n type=\"button\"\r\n [label]=\"\r\n segment.value ||\r\n t('properties.select') +\r\n ' ' +\r\n getOperatorDisplayName(segment.operatorToken)\r\n \"\r\n icon=\"arrow.chevron-down\"\r\n [outlined]=\"true\"\r\n size=\"small\"\r\n [severity]=\"\r\n segment.value ? 'primary' : 'secondary'\r\n \"\r\n [iconPos]=\"'end'\"\r\n (onClick)=\"pathPopover.toggle($event)\"\r\n ></mt-button>\r\n\r\n <p-popover\r\n #pathPopover\r\n [style]=\"{ width: 'max-content' }\"\r\n appendTo=\"body\"\r\n >\r\n <div class=\"p-2\">\r\n <div\r\n class=\"mb-2 text-xs font-semibold uppercase text-slate-400\"\r\n >\r\n {{ t(\"properties.select\") }}\r\n {{\r\n getOperatorDisplayName(\r\n segment.operatorToken\r\n )\r\n }}\r\n </div>\r\n <div\r\n class=\"flex max-h-[min(24rem,calc(100vh-10rem))] flex-col gap-1 overflow-y-auto pr-1\"\r\n >\r\n @for (\r\n option of segmentOptions(segmentIndex);\r\n track option.key\r\n ) {\r\n <mt-button\r\n type=\"button\"\r\n [label]=\"option.name\"\r\n [icon]=\"\r\n segment.value === option.key\r\n ? 'general.check'\r\n : 'general.minus'\r\n \"\r\n [iconPos]=\"'end'\"\r\n size=\"small\"\r\n severity=\"secondary\"\r\n [styleClass]=\"\r\n 'w-full justify-start rounded-md px-2.5 py-1.5 text-left text-xs font-medium transition-colors ' +\r\n (segment.value === option.key\r\n ? 'bg-primary text-white'\r\n : 'text-slate-600 hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-700')\r\n \"\r\n (onClick)=\"\r\n setPathSegmentValue(\r\n segmentIndex,\r\n option.key\r\n );\r\n pathPopover.hide()\r\n \"\r\n ></mt-button>\r\n }\r\n </div>\r\n @if (segment.optional) {\r\n <mt-button\r\n type=\"button\"\r\n [label]=\"t('actions.clear')\"\r\n [outlined]=\"true\"\r\n icon=\"general.x-close\"\r\n [iconPos]=\"'end'\"\r\n size=\"small\"\r\n severity=\"danger\"\r\n styleClass=\"mt-2 w-full rounded-md border border-slate-200 py-1 text-xs text-slate-400 hover:bg-slate-50 dark:border-slate-700\"\r\n (onClick)=\"\r\n setPathSegmentValue(segmentIndex, null);\r\n pathPopover.hide()\r\n \"\r\n ></mt-button>\r\n }\r\n </div>\r\n </p-popover>\r\n\r\n @if (\r\n segment.canRemove &&\r\n segmentIndex === pathSegments().length - 1\r\n ) {\r\n <mt-button\r\n type=\"button\"\r\n icon=\"general.x-close\"\r\n size=\"small\"\r\n severity=\"danger\"\r\n styleClass=\"flex size-5 shrink-0 items-center justify-center rounded-full bg-red-500 text-white hover:bg-red-600\"\r\n (onClick)=\"removePathSegment(segmentIndex)\"\r\n ></mt-button>\r\n }\r\n }\r\n <mt-button\r\n type=\"button\"\r\n icon=\"general.plus\"\r\n size=\"small\"\r\n severity=\"primary\"\r\n [disabled]=\"!canAddNextSegment()\"\r\n [class.hidden]=\"!canAddNextSegment()\"\r\n styleClass=\"flex size-6 shrink-0 items-center justify-center rounded-md bg-primary text-xs font-bold text-white hover:opacity-90 disabled:opacity-50\"\r\n (onClick)=\"nextOperatorPopover.toggle($event)\"\r\n ></mt-button>\r\n </div>\r\n }\r\n <p-popover\r\n #nextOperatorPopover\r\n [style]=\"{ width: 'max-content' }\"\r\n appendTo=\"body\"\r\n >\r\n <div class=\"p-2\">\r\n <div\r\n class=\"mb-2 text-xs font-semibold uppercase text-slate-400\"\r\n >\r\n {{ t(\"properties.add-segment\") }}\r\n </div>\r\n <div\r\n class=\"flex max-h-[min(24rem,calc(100vh-10rem))] flex-col gap-1 overflow-y-auto pr-1\"\r\n >\r\n @for (\r\n option of nextOperatorOptions();\r\n track option.token\r\n ) {\r\n <mt-button\r\n type=\"button\"\r\n [label]=\"getOperatorDisplayName(option.token)\"\r\n icon=\"general.plus\"\r\n [iconPos]=\"'end'\"\r\n size=\"small\"\r\n severity=\"secondary\"\r\n styleClass=\"w-full justify-start rounded-md px-2.5 py-1.5 text-left text-xs font-medium transition-colors text-slate-600 hover:bg-slate-100 dark:text-slate-300 dark:hover:bg-slate-700\"\r\n (onClick)=\"\r\n onAddSegmentSelection(\r\n option.token,\r\n nextOperatorPopover\r\n )\r\n \"\r\n ></mt-button>\r\n }\r\n </div>\r\n </div>\r\n </p-popover>\r\n </div>\r\n </div>\r\n\r\n <!-- Field Selection - Under Path -->\r\n <div\r\n class=\"flex items-center gap-2 border-t border-slate-200 pt-2 dark:border-slate-700\"\r\n >\r\n <span\r\n class=\"shrink-0 text-xs font-semibold uppercase tracking-wider text-slate-400\"\r\n >{{ t(\"properties.field\") }}</span\r\n >\r\n <div\r\n class=\"h-4 w-px shrink-0 bg-slate-200 dark:bg-slate-700\"\r\n ></div>\r\n @if (isPropertyLoading()) {\r\n <p-skeleton\r\n class=\"flex-1\"\r\n height=\"2.5rem\"\r\n styleClass=\"rounded-md\"\r\n />\r\n } @else {\r\n <mt-select-field\r\n class=\"flex-1\"\r\n [label]=\"''\"\r\n [filter]=\"true\"\r\n [hasPlaceholderPrefix]=\"false\"\r\n [placeholder]=\"t('properties.select')\"\r\n [(ngModel)]=\"propertyFieldKey\"\r\n [options]=\"propertyOptions()\"\r\n optionLabel=\"name\"\r\n optionValue=\"key\"\r\n [size]=\"'small'\"\r\n />\r\n }\r\n </div>\r\n\r\n <!-- Value Selection - Only for lookup / status / lookup-matrix fields -->\r\n @if (isLookupProperty()) {\r\n <div\r\n class=\"flex items-center gap-2 border-t border-slate-200 pt-2 dark:border-slate-700\"\r\n >\r\n <span\r\n class=\"shrink-0 text-xs font-semibold uppercase tracking-wider text-slate-400\"\r\n >{{ t(\"properties.value\") }}</span\r\n >\r\n <div\r\n class=\"h-4 w-px shrink-0 bg-slate-200 dark:bg-slate-700\"\r\n ></div>\r\n @if (isLookupItemsLoading()) {\r\n <p-skeleton\r\n class=\"flex-1\"\r\n height=\"2.5rem\"\r\n styleClass=\"rounded-md\"\r\n />\r\n } @else {\r\n <mt-select-field\r\n class=\"flex-1\"\r\n [label]=\"''\"\r\n [filter]=\"true\"\r\n [hasPlaceholderPrefix]=\"false\"\r\n [placeholder]=\"t('properties.select-value')\"\r\n [(ngModel)]=\"lookupValueKey\"\r\n [options]=\"lookupItems()\"\r\n optionLabel=\"name\"\r\n optionValue=\"key\"\r\n [size]=\"'small'\"\r\n />\r\n }\r\n </div>\r\n }\r\n <div\r\n class=\"w-full truncate rounded-lg bg-amber-100 px-3 py-2 text-sm font-semibold text-amber-700 shadow-sm hover:bg-amber-200 dark:bg-amber-900/30 dark:text-amber-300 dark:hover:bg-amber-900/50\"\r\n [mtTooltip]=\"\r\n '@' +\r\n propertyTablePath() +\r\n '::' +\r\n (selectedProperty()?.key ?? '...')\r\n \"\r\n tooltipPosition=\"top\"\r\n >\r\n @{{ propertyTablePath() }}::{{\r\n selectedProperty()?.key ?? \"...\"\r\n }}\r\n </div>\r\n <div class=\"flex justify-end gap-2\">\r\n @if (isLookupProperty()) {\r\n <mt-button\r\n type=\"button\"\r\n [label]=\"t('actions.insert-value')\"\r\n icon=\"general.plus\"\r\n severity=\"secondary\"\r\n [outlined]=\"true\"\r\n [disabled]=\"!canInsertLookupValue()\"\r\n (onClick)=\"insertSelectedLookupValue(insertBlock)\"\r\n ></mt-button>\r\n }\r\n <mt-button\r\n type=\"button\"\r\n [label]=\"t('actions.insert')\"\r\n icon=\"general.plus\"\r\n severity=\"primary\"\r\n [disabled]=\"!canInsertProperty()\"\r\n (onClick)=\"insertSelectedProperty(insertBlock)\"\r\n ></mt-button>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n }\r\n </ng-template>\r\n </mt-formula-toolbar>\r\n }\r\n\r\n <!-- Editor Area -->\r\n <div class=\"p-3\">\r\n <div\r\n class=\"overflow-hidden rounded-lg border border-surface-200 bg-white dark:border-surface-700 dark:bg-surface-800\"\r\n >\r\n @if (showModeToggle()) {\r\n <div\r\n class=\"flex items-center justify-end border-b border-surface-200 px-3 py-2 dark:border-surface-700\"\r\n >\r\n <mt-toggle-field\r\n [label]=\"t('codeMode')\"\r\n labelPosition=\"end\"\r\n size=\"small\"\r\n [ngModel]=\"isCodeMode()\"\r\n [disabled]=\"isDisabled()\"\r\n (ngModelChange)=\"onModeToggle($event)\"\r\n />\r\n </div>\r\n }\r\n <div class=\"p-0\">\r\n @if (isCodeMode()) {\r\n <mt-formula-editor-code\r\n #formulaEditorCode\r\n [placeholder]=\"placeholder() || t('placeholder')\"\r\n [initialFormula]=\"expression()\"\r\n [disabled]=\"isDisabled()\"\r\n [borderless]=\"true\"\r\n [autocompleteProvider]=\"autocompleteProvider\"\r\n (formulaChange)=\"onCodeFormulaChange($event)\"\r\n (onFocus)=\"onEditorFocus()\"\r\n (onBlur)=\"onEditorBlur()\"\r\n />\r\n } @else {\r\n <mt-formula-editor\r\n #formulaEditor\r\n [placeholder]=\"placeholder() || t('placeholder')\"\r\n [initialTokens]=\"tokens()\"\r\n [disabled]=\"isDisabled()\"\r\n [borderless]=\"true\"\r\n (formulaChange)=\"onFormulaChange($event)\"\r\n (tokensChange)=\"onTokensChange($event)\"\r\n (onFocus)=\"onEditorFocus()\"\r\n (onBlur)=\"onEditorBlur()\"\r\n />\r\n }\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <!-- Status Bar - Pass data via inputs (pure component) -->\r\n @if (!hideStatusBar()) {\r\n <mt-formula-status-bar [validation]=\"validation()\" />\r\n }\r\n </div>\r\n</mt-card>\r\n","/**\r\n * Services barrel export\r\n */\r\n\r\nexport * from './formula-context.service';\r\nexport * from './formula-validator.service';\r\n","/**\r\n * Public API Surface of @masterteam/formula-builder\r\n *\r\n * This package provides the FormulaBuilder component which wraps\r\n * pure UI components from @masterteam/components/formula with\r\n * backend services for validation and context loading.\r\n *\r\n * Architecture:\r\n * - UI Components: imported from @masterteam/components/formula (pure, no services)\r\n * - Services: FormulaContextService, FormulaValidatorService (backend logic)\r\n * - FormulaBuilder: Main wrapper that connects UI with services\r\n */\r\n\r\n// Main component\r\nexport * from './lib/formula-builder';\r\n\r\n// Services (backend logic only)\r\nexport * from './lib/services/index';\r\n\r\n// Re-export models from base package for convenience\r\nexport {\r\n type SmartBlock,\r\n type BlockType,\r\n type ArgumentSlot,\r\n type FormulaToken,\r\n type TokenType,\r\n type DragBehavior,\r\n type ValidationResult,\r\n type ValidationError,\r\n type FunctionDefinition,\r\n type FunctionCategoryGroup,\r\n type OperatorDefinition,\r\n createFunctionBlock,\r\n createPropertyBlock,\r\n createOperatorBlock,\r\n createLiteralBlock,\r\n} from '@masterteam/components/formula';\r\n\r\n// Export validation-specific models\r\nexport type {\r\n ValidationRequest,\r\n FunctionCatalogResponse,\r\n ApiErrorResponse,\r\n} from './lib/models/validation-result.model';\r\n\r\n// Export value model for ControlValueAccessor usage\r\nexport type { FormulaBuilderValue } from './lib/models/formula-builder-value.model';\r\n\r\n// Export builder context models\r\nexport type {\r\n FormulaBuilderContextResponse,\r\n FormulaPropertyDescriptor,\r\n FormulaEngineSchemaDescriptor,\r\n OperatorDescriptor,\r\n NextTokenRule,\r\n NextTokenAllowedValueItem,\r\n} from './lib/models/formula-context.model';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;AAGG;AAyBH;AACA,MAAM,gBAAgB,GAAqB;AACzC,IAAA,OAAO,EAAE,IAAI;AACb,IAAA,MAAM,EAAE,EAAE;AACV,IAAA,QAAQ,EAAE,EAAE;AACZ,IAAA,YAAY,EAAE,EAAE;AAChB,IAAA,UAAU,EAAE,CAAC;CACd;MAGY,uBAAuB,CAAA;AACjB,IAAA,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC;AACzB,IAAA,SAAS,GAAG,MAAM,CAAC,gBAAgB,CAAC;IACpC,MAAM,GAAG,UAAU;AAEpC;;;;AAIG;AACK,IAAA,oBAAoB,CAAC,OAAuB,EAAA;QAClD,OAAO;A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A,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,gBAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,MAAA,EAAA,IAAA,EAAA,CAAA,kBAAA,CAAA,EAAA,CAAA,EAAA,YAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,MAAA,EAAA,IAAA,EAAA,CAAA,cAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AE9KpD;;AAEG;;ACFH;;;;;;;;;;;AAWG;AAEH;;ACbA;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@masterteam/formula-builder",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.35",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"directory": "../../../dist/masterteam/formula-builder",
|
|
6
6
|
"linkDirectory": true,
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"rxjs": "^7.8.2",
|
|
20
20
|
"tailwindcss": "^4.2.2",
|
|
21
21
|
"tailwindcss-primeui": "^0.6.1",
|
|
22
|
-
"@masterteam/components": "^0.0.
|
|
22
|
+
"@masterteam/components": "^0.0.328",
|
|
23
23
|
"@masterteam/icons": "^0.0.17"
|
|
24
24
|
},
|
|
25
25
|
"sideEffects": false,
|
|
@@ -206,6 +206,13 @@ declare class FormulaBuilder implements ControlValueAccessor, OnDestroy {
|
|
|
206
206
|
readonly valueMode: _angular_core.InputSignal<"object" | "expression">;
|
|
207
207
|
/** Use Process Builder current-only Formula Engine endpoints */
|
|
208
208
|
readonly isProcessBuilder: _angular_core.InputSignal<boolean>;
|
|
209
|
+
/**
|
|
210
|
+
* Property keys the formula may reference, sent with every validation. For
|
|
211
|
+
* surfaces that author without a schema-context lookup (notification
|
|
212
|
+
* "send only when" conditions), this is how the backend learns which
|
|
213
|
+
* Current fields exist.
|
|
214
|
+
*/
|
|
215
|
+
readonly knownProperties: _angular_core.InputSignal<string[] | undefined>;
|
|
209
216
|
/** Emits validation result on change */
|
|
210
217
|
readonly validationChange: _angular_core.OutputEmitterRef<_masterteam_formula_builder.ValidationResult>;
|
|
211
218
|
/** Emits when tokens change */
|
|
@@ -418,7 +425,7 @@ declare class FormulaBuilder implements ControlValueAccessor, OnDestroy {
|
|
|
418
425
|
private buildLookupValueResponse;
|
|
419
426
|
getOperatorDisplayName(token: string): string;
|
|
420
427
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormulaBuilder, never>;
|
|
421
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<FormulaBuilder, "mt-formula-builder", never, { "propertiesByPath": { "alias": "propertiesByPath"; "required": false; "isSignal": true; }; "levelSchemaId": { "alias": "levelSchemaId"; "required": false; "isSignal": true; }; "moduleId": { "alias": "moduleId"; "required": false; "isSignal": true; }; "contextKey": { "alias": "contextKey"; "required": false; "isSignal": true; }; "contextEntityTypeKey": { "alias": "contextEntityTypeKey"; "required": false; "isSignal": true; }; "templateId": { "alias": "templateId"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "hideToolbar": { "alias": "hideToolbar"; "required": false; "isSignal": true; }; "hideStatusBar": { "alias": "hideStatusBar"; "required": false; "isSignal": true; }; "invalidWhenEmpty": { "alias": "invalidWhenEmpty"; "required": false; "isSignal": true; }; "toolbarTabs": { "alias": "toolbarTabs"; "required": false; "isSignal": true; }; "functionCategories": { "alias": "functionCategories"; "required": false; "isSignal": true; }; "operators": { "alias": "operators"; "required": false; "isSignal": true; }; "codeOnly": { "alias": "codeOnly"; "required": false; "isSignal": true; }; "builderOnly": { "alias": "builderOnly"; "required": false; "isSignal": true; }; "valueMode": { "alias": "valueMode"; "required": false; "isSignal": true; }; "isProcessBuilder": { "alias": "isProcessBuilder"; "required": false; "isSignal": true; }; }, { "validationChange": "validationChange"; "tokensChange": "tokensChange"; }, never, never, true, never>;
|
|
428
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<FormulaBuilder, "mt-formula-builder", never, { "propertiesByPath": { "alias": "propertiesByPath"; "required": false; "isSignal": true; }; "levelSchemaId": { "alias": "levelSchemaId"; "required": false; "isSignal": true; }; "moduleId": { "alias": "moduleId"; "required": false; "isSignal": true; }; "contextKey": { "alias": "contextKey"; "required": false; "isSignal": true; }; "contextEntityTypeKey": { "alias": "contextEntityTypeKey"; "required": false; "isSignal": true; }; "templateId": { "alias": "templateId"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "hideToolbar": { "alias": "hideToolbar"; "required": false; "isSignal": true; }; "hideStatusBar": { "alias": "hideStatusBar"; "required": false; "isSignal": true; }; "invalidWhenEmpty": { "alias": "invalidWhenEmpty"; "required": false; "isSignal": true; }; "toolbarTabs": { "alias": "toolbarTabs"; "required": false; "isSignal": true; }; "functionCategories": { "alias": "functionCategories"; "required": false; "isSignal": true; }; "operators": { "alias": "operators"; "required": false; "isSignal": true; }; "codeOnly": { "alias": "codeOnly"; "required": false; "isSignal": true; }; "builderOnly": { "alias": "builderOnly"; "required": false; "isSignal": true; }; "valueMode": { "alias": "valueMode"; "required": false; "isSignal": true; }; "isProcessBuilder": { "alias": "isProcessBuilder"; "required": false; "isSignal": true; }; "knownProperties": { "alias": "knownProperties"; "required": false; "isSignal": true; }; }, { "validationChange": "validationChange"; "tokensChange": "tokensChange"; }, never, never, true, never>;
|
|
422
429
|
}
|
|
423
430
|
|
|
424
431
|
type FormulaApiMode$1 = 'default' | 'current-only';
|