@aglyn/plugins-logic 1.0.0-beta.246 → 1.0.0-beta.249
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 +8 -8
- package/src/lib/components/formula-builder-dialog.component.d.ts +33 -0
- package/src/lib/components/formula-builder-dialog.component.js +331 -0
- package/src/lib/components/formula-builder-dialog.component.js.map +1 -0
- package/src/lib/components/formula-builder.component.d.ts +30 -0
- package/src/lib/components/formula-builder.component.js +62 -0
- package/src/lib/components/formula-builder.component.js.map +1 -0
- package/src/lib/components/host-functions-card.component.js +167 -62
- package/src/lib/components/host-functions-card.component.js.map +1 -1
- package/src/lib/components/host-variables-card.component.js +14 -9
- package/src/lib/components/host-variables-card.component.js.map +1 -1
- package/src/lib/components/parameter-choices-editor.component.d.ts +31 -0
- package/src/lib/components/parameter-choices-editor.component.js +124 -0
- package/src/lib/components/parameter-choices-editor.component.js.map +1 -0
- package/src/lib/components/structured-value-editor.component.d.ts +30 -0
- package/src/lib/components/structured-value-editor.component.js +189 -0
- package/src/lib/components/structured-value-editor.component.js.map +1 -0
- package/src/lib/model/formula-names.d.ts +41 -0
- package/src/lib/model/formula-names.js +82 -0
- package/src/lib/model/formula-names.js.map +1 -0
- package/src/lib/model/formula.d.ts +72 -0
- package/src/lib/model/formula.js +264 -0
- package/src/lib/model/formula.js.map +1 -0
- package/src/lib/model/parameter-options.d.ts +16 -0
- package/src/lib/model/parameter-options.js +31 -0
- package/src/lib/model/parameter-options.js.map +1 -1
- package/src/lib/model/structured-value.d.ts +51 -0
- package/src/lib/model/structured-value.js +135 -0
- package/src/lib/model/structured-value.js.map +1 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* A dictionary or collection variable, as rows an author fills in rather than
|
|
19
|
+
* JSON they type (AGL-3757). The stored value is unchanged — the same JSON
|
|
20
|
+
* string `formatVariableValue` and a function's `name.member` read — so this
|
|
21
|
+
* module only translates between that string and the rows the editor shows.
|
|
22
|
+
*/
|
|
23
|
+
/** What one entry holds; `kept` is a nested value the rows cannot edit. */
|
|
24
|
+
export type StructuredValueKind = 'text' | 'number' | 'boolean' | 'kept';
|
|
25
|
+
export interface StructuredValueRow {
|
|
26
|
+
/** The dictionary key; ignored for a collection. */
|
|
27
|
+
key: string;
|
|
28
|
+
kind: StructuredValueKind;
|
|
29
|
+
/** Text as shown in the box; `'true'`/`'false'` for a true/false entry. */
|
|
30
|
+
value: string;
|
|
31
|
+
/** The original nested value, carried through untouched for a `kept` row. */
|
|
32
|
+
kept?: unknown;
|
|
33
|
+
}
|
|
34
|
+
export interface ParsedStructuredValue {
|
|
35
|
+
rows: StructuredValueRow[];
|
|
36
|
+
/**
|
|
37
|
+
* True when a stored value could not be read as the expected shape — an
|
|
38
|
+
* old hand-typed value with a stray comma, or a list stored on a
|
|
39
|
+
* dictionary. The editor starts from what it could read and says so.
|
|
40
|
+
*/
|
|
41
|
+
unreadable: boolean;
|
|
42
|
+
}
|
|
43
|
+
/** The rows a stored dictionary or collection value reads as. */
|
|
44
|
+
export declare function parseStructuredValue(raw: string | undefined, shape: 'dictionary' | 'collection'): ParsedStructuredValue;
|
|
45
|
+
/**
|
|
46
|
+
* The JSON string rows store as. A dictionary drops rows without a key and
|
|
47
|
+
* keeps the LAST row of a repeated key, as reading the JSON back would.
|
|
48
|
+
*/
|
|
49
|
+
export declare function serializeStructuredValue(rows: readonly StructuredValueRow[], shape: 'dictionary' | 'collection'): string;
|
|
50
|
+
/** The dictionary keys used more than once, which the editor flags. */
|
|
51
|
+
export declare function duplicateStructuredKeys(rows: readonly StructuredValueRow[]): Set<string>;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ /**
|
|
17
|
+
* A dictionary or collection variable, as rows an author fills in rather than
|
|
18
|
+
* JSON they type (AGL-3757). The stored value is unchanged — the same JSON
|
|
19
|
+
* string `formatVariableValue` and a function's `name.member` read — so this
|
|
20
|
+
* module only translates between that string and the rows the editor shows.
|
|
21
|
+
*/ /** What one entry holds; `kept` is a nested value the rows cannot edit. */ function rowFor(key, value) {
|
|
22
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
23
|
+
return {
|
|
24
|
+
key,
|
|
25
|
+
kind: 'number',
|
|
26
|
+
value: String(value)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
if (typeof value === 'boolean') {
|
|
30
|
+
return {
|
|
31
|
+
key,
|
|
32
|
+
kind: 'boolean',
|
|
33
|
+
value: value ? 'true' : 'false'
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if (typeof value === 'string') return {
|
|
37
|
+
key,
|
|
38
|
+
kind: 'text',
|
|
39
|
+
value
|
|
40
|
+
};
|
|
41
|
+
if (value === null || value === undefined) {
|
|
42
|
+
return {
|
|
43
|
+
key,
|
|
44
|
+
kind: 'text',
|
|
45
|
+
value: ''
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
key,
|
|
50
|
+
kind: 'kept',
|
|
51
|
+
value: JSON.stringify(value),
|
|
52
|
+
kept: value
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** The rows a stored dictionary or collection value reads as. */ export function parseStructuredValue(raw, shape) {
|
|
56
|
+
const text = String(raw != null ? raw : '').trim();
|
|
57
|
+
if (!text) return {
|
|
58
|
+
rows: [],
|
|
59
|
+
unreadable: false
|
|
60
|
+
};
|
|
61
|
+
let parsed;
|
|
62
|
+
try {
|
|
63
|
+
parsed = JSON.parse(text);
|
|
64
|
+
} catch (unused) {
|
|
65
|
+
return {
|
|
66
|
+
rows: [],
|
|
67
|
+
unreadable: true
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (shape === 'collection') {
|
|
71
|
+
if (!Array.isArray(parsed)) return {
|
|
72
|
+
rows: [],
|
|
73
|
+
unreadable: true
|
|
74
|
+
};
|
|
75
|
+
return {
|
|
76
|
+
rows: parsed.map((item)=>rowFor('', item)),
|
|
77
|
+
unreadable: false
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
81
|
+
return {
|
|
82
|
+
rows: [],
|
|
83
|
+
unreadable: true
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
rows: Object.entries(parsed).map(([key, value])=>rowFor(key, value)),
|
|
88
|
+
unreadable: false
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* One row's stored value. A number box that does not hold a number stores
|
|
93
|
+
* nothing rather than a string a calculation would then trip over.
|
|
94
|
+
*/ function rowValue(row) {
|
|
95
|
+
switch(row.kind){
|
|
96
|
+
case 'number':
|
|
97
|
+
{
|
|
98
|
+
const text = row.value.trim();
|
|
99
|
+
const parsed = Number(text);
|
|
100
|
+
return text !== '' && Number.isFinite(parsed) ? parsed : null;
|
|
101
|
+
}
|
|
102
|
+
case 'boolean':
|
|
103
|
+
return row.value === 'true';
|
|
104
|
+
case 'kept':
|
|
105
|
+
return row.kept;
|
|
106
|
+
case 'text':
|
|
107
|
+
default:
|
|
108
|
+
return row.value;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The JSON string rows store as. A dictionary drops rows without a key and
|
|
113
|
+
* keeps the LAST row of a repeated key, as reading the JSON back would.
|
|
114
|
+
*/ export function serializeStructuredValue(rows, shape) {
|
|
115
|
+
if (shape === 'collection') return JSON.stringify(rows.map(rowValue));
|
|
116
|
+
const entries = {};
|
|
117
|
+
for (const row of rows){
|
|
118
|
+
const key = row.key.trim();
|
|
119
|
+
if (key) entries[key] = rowValue(row);
|
|
120
|
+
}
|
|
121
|
+
return JSON.stringify(entries);
|
|
122
|
+
}
|
|
123
|
+
/** The dictionary keys used more than once, which the editor flags. */ export function duplicateStructuredKeys(rows) {
|
|
124
|
+
const seen = new Set();
|
|
125
|
+
const duplicates = new Set();
|
|
126
|
+
for (const row of rows){
|
|
127
|
+
const key = row.key.trim();
|
|
128
|
+
if (!key) continue;
|
|
129
|
+
if (seen.has(key)) duplicates.add(key);
|
|
130
|
+
seen.add(key);
|
|
131
|
+
}
|
|
132
|
+
return duplicates;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
//# sourceMappingURL=structured-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/logic/src/lib/model/structured-value.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A dictionary or collection variable, as rows an author fills in rather than\n * JSON they type (AGL-3757). The stored value is unchanged — the same JSON\n * string `formatVariableValue` and a function's `name.member` read — so this\n * module only translates between that string and the rows the editor shows.\n */\n\n/** What one entry holds; `kept` is a nested value the rows cannot edit. */\nexport type StructuredValueKind = 'text' | 'number' | 'boolean' | 'kept'\n\nexport interface StructuredValueRow {\n /** The dictionary key; ignored for a collection. */\n key: string\n kind: StructuredValueKind\n /** Text as shown in the box; `'true'`/`'false'` for a true/false entry. */\n value: string\n /** The original nested value, carried through untouched for a `kept` row. */\n kept?: unknown\n}\n\nexport interface ParsedStructuredValue {\n rows: StructuredValueRow[]\n /**\n * True when a stored value could not be read as the expected shape — an\n * old hand-typed value with a stray comma, or a list stored on a\n * dictionary. The editor starts from what it could read and says so.\n */\n unreadable: boolean\n}\n\nfunction rowFor(key: string, value: unknown): StructuredValueRow {\n if (typeof value === 'number' && Number.isFinite(value)) {\n return { key, kind: 'number', value: String(value) }\n }\n if (typeof value === 'boolean') {\n return { key, kind: 'boolean', value: value ? 'true' : 'false' }\n }\n if (typeof value === 'string') return { key, kind: 'text', value }\n if (value === null || value === undefined) {\n return { key, kind: 'text', value: '' }\n }\n return { key, kind: 'kept', value: JSON.stringify(value), kept: value }\n}\n\n/** The rows a stored dictionary or collection value reads as. */\nexport function parseStructuredValue(\n raw: string | undefined,\n shape: 'dictionary' | 'collection',\n): ParsedStructuredValue {\n const text = String(raw ?? '').trim()\n if (!text) return { rows: [], unreadable: false }\n let parsed: unknown\n try {\n parsed = JSON.parse(text)\n } catch {\n return { rows: [], unreadable: true }\n }\n if (shape === 'collection') {\n if (!Array.isArray(parsed)) return { rows: [], unreadable: true }\n return { rows: parsed.map((item) => rowFor('', item)), unreadable: false }\n }\n if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {\n return { rows: [], unreadable: true }\n }\n return {\n rows: Object.entries(parsed as Record<string, unknown>).map(\n ([key, value]) => rowFor(key, value),\n ),\n unreadable: false,\n }\n}\n\n/**\n * One row's stored value. A number box that does not hold a number stores\n * nothing rather than a string a calculation would then trip over.\n */\nfunction rowValue(row: StructuredValueRow): unknown {\n switch (row.kind) {\n case 'number': {\n const text = row.value.trim()\n const parsed = Number(text)\n return text !== '' && Number.isFinite(parsed) ? parsed : null\n }\n case 'boolean':\n return row.value === 'true'\n case 'kept':\n return row.kept\n case 'text':\n default:\n return row.value\n }\n}\n\n/**\n * The JSON string rows store as. A dictionary drops rows without a key and\n * keeps the LAST row of a repeated key, as reading the JSON back would.\n */\nexport function serializeStructuredValue(\n rows: readonly StructuredValueRow[],\n shape: 'dictionary' | 'collection',\n): string {\n if (shape === 'collection') return JSON.stringify(rows.map(rowValue))\n const entries: Record<string, unknown> = {}\n for (const row of rows) {\n const key = row.key.trim()\n if (key) entries[key] = rowValue(row)\n }\n return JSON.stringify(entries)\n}\n\n/** The dictionary keys used more than once, which the editor flags. */\nexport function duplicateStructuredKeys(\n rows: readonly StructuredValueRow[],\n): Set<string> {\n const seen = new Set<string>()\n const duplicates = new Set<string>()\n for (const row of rows) {\n const key = row.key.trim()\n if (!key) continue\n if (seen.has(key)) duplicates.add(key)\n seen.add(key)\n }\n return duplicates\n}\n"],"names":["rowFor","key","value","Number","isFinite","kind","String","undefined","JSON","stringify","kept","parseStructuredValue","raw","shape","text","trim","rows","unreadable","parsed","parse","Array","isArray","map","item","Object","entries","rowValue","row","serializeStructuredValue","duplicateStructuredKeys","seen","Set","duplicates","has","add"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;CAKC,G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