@masterteam/formula-builder 0.0.26 → 0.0.28
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/package.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@masterteam/formula-builder",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.28",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"directory": "../../../dist/masterteam/formula-builder",
|
|
6
6
|
"linkDirectory": true,
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
9
9
|
"peerDependencies": {
|
|
10
|
-
"@angular/common": "
|
|
11
|
-
"@angular/core": "
|
|
12
|
-
"@angular/forms": "
|
|
13
|
-
"@angular/cdk": "
|
|
14
|
-
"@primeuix/themes": "
|
|
15
|
-
"@tailwindcss/postcss": "
|
|
16
|
-
"@jsverse/transloco": "
|
|
17
|
-
"postcss": "
|
|
18
|
-
"primeng": "
|
|
19
|
-
"rxjs": "
|
|
20
|
-
"tailwindcss": "
|
|
21
|
-
"tailwindcss-primeui": "
|
|
22
|
-
"@masterteam/components": "
|
|
23
|
-
"@masterteam/icons": "
|
|
10
|
+
"@angular/common": "catalog:angular21",
|
|
11
|
+
"@angular/core": "catalog:angular21",
|
|
12
|
+
"@angular/forms": "catalog:angular21",
|
|
13
|
+
"@angular/cdk": "catalog:angular21",
|
|
14
|
+
"@primeuix/themes": "catalog:",
|
|
15
|
+
"@tailwindcss/postcss": "catalog:",
|
|
16
|
+
"@jsverse/transloco": "catalog:i18n",
|
|
17
|
+
"postcss": "catalog:",
|
|
18
|
+
"primeng": "catalog:",
|
|
19
|
+
"rxjs": "catalog:angular21",
|
|
20
|
+
"tailwindcss": "catalog:",
|
|
21
|
+
"tailwindcss-primeui": "catalog:",
|
|
22
|
+
"@masterteam/components": "workspace:^",
|
|
23
|
+
"@masterteam/icons": "workspace:^"
|
|
24
24
|
},
|
|
25
25
|
"sideEffects": false,
|
|
26
26
|
"exports": {
|
|
@@ -36,6 +36,6 @@
|
|
|
36
36
|
"typings": "types/masterteam-formula-builder.d.ts",
|
|
37
37
|
"type": "module",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"tslib": "
|
|
39
|
+
"tslib": "catalog:angular21"
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -4,13 +4,15 @@ import { OnDestroy } from '@angular/core';
|
|
|
4
4
|
import { ControlValueAccessor } from '@angular/forms';
|
|
5
5
|
import { RadioItem } from '@masterteam/components/radio-cards';
|
|
6
6
|
import { Observable } from 'rxjs';
|
|
7
|
-
import { FunctionCategoryGroup, AutocompleteRequest as AutocompleteRequest$1, AutocompleteResponse as AutocompleteResponse$1, ValidationResult as ValidationResult$1, FormulaToken, ToolbarTab, SmartBlock } from '@masterteam/components/formula';
|
|
7
|
+
import { FunctionCategoryGroup, AutocompleteRequest as AutocompleteRequest$1, AutocompleteResponse as AutocompleteResponse$1, ValidationResult as ValidationResult$1, FormulaToken, ToolbarTab, OperatorDefinition, SmartBlock } from '@masterteam/components/formula';
|
|
8
8
|
export { ArgumentSlot, BlockType, DragBehavior, FormulaToken, FunctionCategoryGroup, FunctionDefinition, OperatorDefinition, SmartBlock, TokenType, ValidationError, ValidationResult, createFunctionBlock, createLiteralBlock, createOperatorBlock, createPropertyBlock } from '@masterteam/components/formula';
|
|
9
9
|
|
|
10
10
|
type ValidationResult = ValidationResult$1;
|
|
11
11
|
type AutocompleteResponse = AutocompleteResponse$1;
|
|
12
12
|
interface AutocompleteRequest extends AutocompleteRequest$1 {
|
|
13
13
|
moduleId?: number;
|
|
14
|
+
/** Canonical context id, e.g. `Module:123` / `Level:5/Module:10`. */
|
|
15
|
+
contextKey?: string;
|
|
14
16
|
}
|
|
15
17
|
/** Validation request payload (for API calls) */
|
|
16
18
|
interface ValidationRequest {
|
|
@@ -19,6 +21,8 @@ interface ValidationRequest {
|
|
|
19
21
|
levelSchemaId?: number;
|
|
20
22
|
moduleId?: number;
|
|
21
23
|
templateId?: number;
|
|
24
|
+
/** Canonical context id, e.g. `Module:123` / `Level:5/Module:10`. */
|
|
25
|
+
contextKey?: string;
|
|
22
26
|
}
|
|
23
27
|
/** Function catalog response from API */
|
|
24
28
|
interface FunctionCatalogResponse {
|
|
@@ -64,8 +68,37 @@ interface FormulaEngineSchemaDescriptor {
|
|
|
64
68
|
generatedAt?: string;
|
|
65
69
|
}
|
|
66
70
|
|
|
71
|
+
/**
|
|
72
|
+
* How the backend resolves a formula's execution surface for a context.
|
|
73
|
+
* `InlineCurrentOnly` — standalone module / current-only authoring (only
|
|
74
|
+
* `@Current::Property` is valid); `EntityBacked` — full workspace/level
|
|
75
|
+
* authoring with navigation scopes. Serialized as strings by the API.
|
|
76
|
+
*/
|
|
77
|
+
type FormulaExecutionProfile = 'InlineCurrentOnly' | 'EntityBacked' | (string & {});
|
|
78
|
+
/**
|
|
79
|
+
* The kind of context a `contextKey` resolves to. `StandaloneModule` is a
|
|
80
|
+
* module opened without a workspace/level (e.g. `General Task`) addressed as
|
|
81
|
+
* `Module:{moduleId}`. Serialized as strings by the API.
|
|
82
|
+
*/
|
|
83
|
+
type FormulaContextKind = 'StandaloneModule' | (string & {});
|
|
67
84
|
interface FormulaBuilderContextResponse {
|
|
68
85
|
schemaId: number;
|
|
86
|
+
/**
|
|
87
|
+
* Canonical schema id to use for subsequent properties/next-tokens calls.
|
|
88
|
+
* For standalone modules this equals the module id. Falls back to `schemaId`
|
|
89
|
+
* when the backend omits it.
|
|
90
|
+
*/
|
|
91
|
+
formulaSchemaId?: number;
|
|
92
|
+
/** Canonical context identifier the response was resolved from. */
|
|
93
|
+
contextKey?: string;
|
|
94
|
+
contextKind?: FormulaContextKind;
|
|
95
|
+
executionProfile?: FormulaExecutionProfile;
|
|
96
|
+
/**
|
|
97
|
+
* Scope tokens the FE may surface for this context. Standalone modules
|
|
98
|
+
* return only `['Current']`. When present, the builder gates visible
|
|
99
|
+
* navigation scopes to this list.
|
|
100
|
+
*/
|
|
101
|
+
supportedScopeTokens?: string[];
|
|
69
102
|
contextEntityTypeKey?: string;
|
|
70
103
|
schemaDescriptor: FormulaEngineSchemaDescriptor;
|
|
71
104
|
currentProperties: FormulaPropertyDescriptor[];
|
|
@@ -131,6 +164,15 @@ declare class FormulaBuilder implements ControlValueAccessor, OnDestroy {
|
|
|
131
164
|
readonly levelSchemaId: _angular_core.InputSignal<number | undefined>;
|
|
132
165
|
/** Optional module ID when the formula is scoped inside a level-linked module */
|
|
133
166
|
readonly moduleId: _angular_core.InputSignal<number | undefined>;
|
|
167
|
+
/**
|
|
168
|
+
* Canonical context identifier — `Module:{id}` / `Level:{id}` /
|
|
169
|
+
* `Level:{id}/Module:{id}`. When set it is the source of truth for the
|
|
170
|
+
* context kind and execution profile: it is the only way to address a
|
|
171
|
+
* standalone module (no workspace/level schema), and the builder loads its
|
|
172
|
+
* context, scopes, functions and validation through it. When omitted the
|
|
173
|
+
* legacy `levelSchemaId` + `moduleId` flow is used unchanged.
|
|
174
|
+
*/
|
|
175
|
+
readonly contextKey: _angular_core.InputSignal<string | undefined>;
|
|
134
176
|
/** Optional current context entity key, e.g. LevelData or Risk */
|
|
135
177
|
readonly contextEntityTypeKey: _angular_core.InputSignal<string | undefined>;
|
|
136
178
|
/** Template ID for validation context */
|
|
@@ -143,6 +185,10 @@ declare class FormulaBuilder implements ControlValueAccessor, OnDestroy {
|
|
|
143
185
|
readonly hideStatusBar: _angular_core.InputSignal<boolean>;
|
|
144
186
|
/** Visible toolbar tabs */
|
|
145
187
|
readonly toolbarTabs: _angular_core.InputSignal<readonly ToolbarTab[]>;
|
|
188
|
+
/** Optional host-owned function catalog. Takes precedence over API context. */
|
|
189
|
+
readonly functionCategories: _angular_core.InputSignal<FunctionCategoryGroup[]>;
|
|
190
|
+
/** Operators shown in the formula toolbar. */
|
|
191
|
+
readonly operators: _angular_core.InputSignal<OperatorDefinition[]>;
|
|
146
192
|
/** Force code editor mode and hide the mode toggle */
|
|
147
193
|
readonly codeOnly: _angular_core.InputSignal<boolean>;
|
|
148
194
|
/** Keep the block builder active and hide the code-mode toggle. */
|
|
@@ -165,6 +211,27 @@ declare class FormulaBuilder implements ControlValueAccessor, OnDestroy {
|
|
|
165
211
|
readonly expression: _angular_core.Signal<string>;
|
|
166
212
|
readonly resolvedContextEntityTypeKey: _angular_core.Signal<string | undefined>;
|
|
167
213
|
readonly isModuleContext: _angular_core.Signal<boolean>;
|
|
214
|
+
/** Trimmed canonical context key, or undefined when not supplied. */
|
|
215
|
+
readonly resolvedContextKey: _angular_core.Signal<string | undefined>;
|
|
216
|
+
/**
|
|
217
|
+
* True when authoring is current-only (a standalone module / `Module:{id}`).
|
|
218
|
+
* Prefers the resolved context (execution profile / kind) once loaded, and
|
|
219
|
+
* falls back to the shape of the context key before the context arrives so
|
|
220
|
+
* navigation scopes never flash for a standalone module.
|
|
221
|
+
*/
|
|
222
|
+
readonly isCurrentOnlyContext: _angular_core.Signal<boolean>;
|
|
223
|
+
/**
|
|
224
|
+
* Scope tokens the backend allows for this context, or null when it doesn't
|
|
225
|
+
* constrain them (legacy contexts). Used to gate the visible navigation.
|
|
226
|
+
*/
|
|
227
|
+
readonly supportedScopeTokens: _angular_core.Signal<string[] | null>;
|
|
228
|
+
/**
|
|
229
|
+
* Schema id for downstream properties / next-token / validation calls. The
|
|
230
|
+
* context response is authoritative (a standalone module resolves its own
|
|
231
|
+
* `formulaSchemaId`); falls back to the `levelSchemaId` input for legacy
|
|
232
|
+
* flows and before the context loads.
|
|
233
|
+
*/
|
|
234
|
+
readonly effectiveSchemaId: _angular_core.Signal<number | undefined>;
|
|
168
235
|
readonly autocompleteProvider: (request: AutocompleteRequest) => Observable<AutocompleteResponse | null>;
|
|
169
236
|
private fetchAutocomplete$;
|
|
170
237
|
/** Editor mode */
|
|
@@ -184,8 +251,8 @@ declare class FormulaBuilder implements ControlValueAccessor, OnDestroy {
|
|
|
184
251
|
readonly isValidating: _angular_core.Signal<boolean>;
|
|
185
252
|
/** Builder context from API */
|
|
186
253
|
readonly builderContext: _angular_core.WritableSignal<FormulaBuilderContextResponse | null>;
|
|
187
|
-
/** Function categories from context */
|
|
188
|
-
readonly
|
|
254
|
+
/** Function categories from the host, context API, or validation fallback. */
|
|
255
|
+
readonly resolvedFunctionCategories: _angular_core.Signal<FunctionCategoryGroup[]>;
|
|
189
256
|
/** Is builder context loading */
|
|
190
257
|
readonly isContextLoading: _angular_core.WritableSignal<boolean>;
|
|
191
258
|
private contextRequestId;
|
|
@@ -327,7 +394,7 @@ declare class FormulaBuilder implements ControlValueAccessor, OnDestroy {
|
|
|
327
394
|
private buildLookupValueResponse;
|
|
328
395
|
getOperatorDisplayName(token: string): string;
|
|
329
396
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<FormulaBuilder, never>;
|
|
330
|
-
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; }; "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; }; "toolbarTabs": { "alias": "toolbarTabs"; "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>;
|
|
397
|
+
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; }; "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>;
|
|
331
398
|
}
|
|
332
399
|
|
|
333
400
|
type FormulaApiMode$1 = 'default' | 'current-only';
|
|
@@ -335,14 +402,22 @@ declare class FormulaContextService {
|
|
|
335
402
|
private readonly http;
|
|
336
403
|
private readonly apiUrl;
|
|
337
404
|
private getBaseUrl;
|
|
405
|
+
private buildLegacyContextUrl;
|
|
338
406
|
private unwrapResponse;
|
|
339
407
|
private readonly contextCache;
|
|
340
408
|
private readonly propertiesCache;
|
|
341
409
|
private readonly nextTokensCache;
|
|
342
410
|
private readonly propertyItemsCache;
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
411
|
+
/**
|
|
412
|
+
* Load the builder context. When `contextKey` is provided it is the canonical
|
|
413
|
+
* context identifier (`Module:123` / `Level:5` / `Level:5/Module:10`) and the
|
|
414
|
+
* context-key endpoint is used — this is the only way to address a standalone
|
|
415
|
+
* module, which has no workspace/level schema id. Otherwise the legacy
|
|
416
|
+
* schema-id path endpoint is used unchanged.
|
|
417
|
+
*/
|
|
418
|
+
loadContext(schemaId: number | undefined, moduleId?: number, contextEntityTypeKey?: string, mode?: FormulaApiMode$1, contextKey?: string): Observable<FormulaBuilderContextResponse | null>;
|
|
419
|
+
getScopeProperties(schemaId: number, component: string | undefined, tablePath: string, moduleId?: number, mode?: FormulaApiMode$1, contextKey?: string): Observable<FormulaPropertyDescriptor[]>;
|
|
420
|
+
getNextTokens(schemaId: number, component: string, tablePath: string, moduleId?: number, mode?: FormulaApiMode$1, contextKey?: string): Observable<FormulaBuilderNextTokensResponse | null>;
|
|
346
421
|
/**
|
|
347
422
|
* Selectable values for a lookup / status / lookup-matrix property.
|
|
348
423
|
* The backend responds 400 (VAL_001) for any non-lookup property, which we
|
|
@@ -382,9 +457,9 @@ declare class FormulaValidatorService {
|
|
|
382
457
|
/** Setup debounced validation stream */
|
|
383
458
|
private setupValidationStream;
|
|
384
459
|
/** Validate formula (debounced) */
|
|
385
|
-
validate(formula: string, knownProperties?: string[], levelSchemaId?: number, moduleId?: number, templateId?: number, apiMode?: FormulaApiMode): void;
|
|
460
|
+
validate(formula: string, knownProperties?: string[], levelSchemaId?: number, moduleId?: number, templateId?: number, apiMode?: FormulaApiMode, contextKey?: string): void;
|
|
386
461
|
/** Validate formula immediately (no debounce) */
|
|
387
|
-
validateImmediate(formula: string, knownProperties?: string[], levelSchemaId?: number, moduleId?: number, templateId?: number, apiMode?: FormulaApiMode): Observable<ValidationResult>;
|
|
462
|
+
validateImmediate(formula: string, knownProperties?: string[], levelSchemaId?: number, moduleId?: number, templateId?: number, apiMode?: FormulaApiMode, contextKey?: string): Observable<ValidationResult>;
|
|
388
463
|
/** Call validation API */
|
|
389
464
|
private callValidateApi;
|
|
390
465
|
/** Reset validation state */
|