@elementumai/edk 0.9.6 → 0.9.7
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/README.md +31 -1
- package/dist-sdk/src/catalog/factories.d.ts +12 -3
- package/dist-sdk/src/catalog/factories.js +9 -6
- package/dist-sdk/src/catalog/org.js +26 -13
- package/dist-sdk/src/catalog/types.d.ts +22 -1
- package/dist-sdk/src/core/index.d.ts +1 -1
- package/dist-sdk/src/core/system-fields.d.ts +4 -0
- package/dist-sdk/src/core/system-fields.js +15 -0
- package/dist-sdk/src/core/types/app.d.ts +14 -9
- package/dist-sdk/src/core/types/platform.d.ts +1 -1
- package/dist-sdk/src/engine/build/context.d.ts +4 -0
- package/dist-sdk/src/engine/pull/context.d.ts +9 -0
- package/dist-sdk/src/engine/pull/ref-only.d.ts +14 -0
- package/dist-sdk/src/engine/pull/ref-only.js +35 -2
- package/dist-sdk/src/entities/access-policy/from-tf.js +14 -2
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +6 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +4 -1
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +18 -1
- package/dist-sdk/src/entities/agent/module.js +1 -0
- package/dist-sdk/src/entities/agent/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/agent/to-tf.js +1 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +9 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.js +10 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.js +2 -3
- package/dist-sdk/src/entities/app/build.d.ts +42 -22
- package/dist-sdk/src/entities/app/build.js +12 -5
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +10 -0
- package/dist-sdk/src/entities/app/from-tf.js +71 -8
- package/dist-sdk/src/entities/app/index.d.ts +3 -2
- package/dist-sdk/src/entities/app/index.js +2 -1
- package/dist-sdk/src/entities/app/to-tf.js +16 -0
- package/dist-sdk/src/entities/automation/build.d.ts +31 -19
- package/dist-sdk/src/entities/automation/build.js +85 -7
- package/dist-sdk/src/entities/automation/catalog-render.js +5 -2
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +5 -3
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +26 -12
- package/dist-sdk/src/entities/automation/from-tf.js +364 -31
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/module.js +2 -2
- package/dist-sdk/src/entities/automation/operators.d.ts +2 -2
- package/dist-sdk/src/entities/automation/operators.js +1 -0
- package/dist-sdk/src/entities/automation/output-field-types.d.ts +17 -0
- package/dist-sdk/src/entities/automation/output-field-types.js +45 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +8 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +16 -0
- package/dist-sdk/src/entities/automation/script-code.js +153 -25
- package/dist-sdk/src/entities/automation/tasks.d.ts +100 -37
- package/dist-sdk/src/entities/automation/tasks.js +44 -43
- package/dist-sdk/src/entities/automation/to-tf.d.ts +3 -1
- package/dist-sdk/src/entities/automation/to-tf.js +454 -58
- package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +78 -0
- package/dist-sdk/src/entities/automation/value-ref-tf.js +193 -0
- package/dist-sdk/src/entities/element/build.js +1 -0
- package/dist-sdk/src/entities/element/index.d.ts +2 -1
- package/dist-sdk/src/entities/element/index.js +2 -1
- package/dist-sdk/src/entities/field/build.d.ts +94 -3
- package/dist-sdk/src/entities/field/build.js +82 -3
- package/dist-sdk/src/entities/field/from-tf.js +92 -1
- package/dist-sdk/src/entities/field/locals.js +6 -7
- package/dist-sdk/src/entities/field/options.d.ts +2 -0
- package/dist-sdk/src/entities/field/options.js +12 -2
- package/dist-sdk/src/entities/field/record-shape.d.ts +12 -15
- package/dist-sdk/src/entities/field/to-tf.d.ts +12 -2
- package/dist-sdk/src/entities/field/to-tf.js +172 -51
- package/dist-sdk/src/entities/field/types.js +2 -0
- package/dist-sdk/src/entities/record-create-form/to-tf.js +5 -8
- package/dist-sdk/src/entities/relationship/from-tf.js +91 -9
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +9 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +39 -0
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +18 -1
- package/dist-sdk/src/entities/shared/filters/ast.js +1 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +6 -1
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +6 -4
- package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +5 -3
- package/dist-sdk/src/entities/shared/tool-field-ref.js +11 -16
- package/dist-sdk/src/entities/shared/types/common.d.ts +7 -5
- package/dist-sdk/src/entities/shared/types/platform.d.ts +15 -2
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +1 -1
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +44 -15
- package/dist-sdk/src/entities/skill/from-tf.js +11 -1
- package/dist-sdk/src/entities/skill/input-coverage.d.ts +68 -0
- package/dist-sdk/src/entities/skill/input-coverage.js +184 -0
- package/dist-sdk/src/entities/skill/module.js +2 -0
- package/dist-sdk/src/entities/skill/to-tf.d.ts +3 -0
- package/dist-sdk/src/entities/skill/to-tf.js +7 -2
- package/dist-sdk/src/entities/skill/tools.d.ts +10 -1
- package/dist-sdk/src/entities/skill/tools.js +0 -5
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +19 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +40 -11
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +4 -2
- package/dist-sdk/src/entities/skill-tool/to-tf.js +24 -16
- package/dist-sdk/src/entities/table/to-tf.js +18 -1
- package/dist-sdk/src/entities/view/to-tf.js +8 -3
- package/dist-sdk/src/entities/visual-flow/from-tf.js +6 -2
- package/dist-sdk/src/graph/types.d.ts +3 -0
- package/package.json +2 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Value-reference codec for the automation tf dialect.
|
|
3
|
+
*
|
|
4
|
+
* The compose wire carries refs as JSON envelopes ({triggerReference},
|
|
5
|
+
* {taskReference}, {variableReference}, {templateReference}, {value}); ei's
|
|
6
|
+
* HCL dialect carries them as `refs["…"]` RESOURCE EXPRESSIONS resolved at
|
|
7
|
+
* apply — `elementum_on_demand_trigger.x.refs["STUDENT_NAME"]` — with plain
|
|
8
|
+
* literals for static values and `${…}` interpolated strings for multi-part
|
|
9
|
+
* templates (cmd/elementum/export/hcl_task.go convertToRefsSyntax). ei's
|
|
10
|
+
* exporter falls back to embedding the raw JSON (with platform ids) when it
|
|
11
|
+
* can't resolve a ref; that fallback is NOT reproduced here — build emits only
|
|
12
|
+
* the id-free refs syntax, and pull reports the JSON fallback loudly instead
|
|
13
|
+
* of guessing.
|
|
14
|
+
*
|
|
15
|
+
* refs-map KEY naming (provider sources):
|
|
16
|
+
* - on_demand trigger: the DECLARED parameter name (the authored schema key;
|
|
17
|
+
* the wire's triggerReference name is the Mobius-canonicalized form —
|
|
18
|
+
* reverse-mapped here via the declared names).
|
|
19
|
+
* - variable task: the variable_name (buildVariableTaskRefs).
|
|
20
|
+
* - execute_script: "Result" for the whole result, "result.<prop>" per
|
|
21
|
+
* output-schema property.
|
|
22
|
+
*/
|
|
23
|
+
import { type TfValue } from "../../engine/tf/index.js";
|
|
24
|
+
import type { RefExpr } from "./deserializer/ast.js";
|
|
25
|
+
/** Map an authored/canonical onDemand param key to the declared parameter name. */
|
|
26
|
+
export declare function onDemandTriggerRefKey(name: string, paramNames: readonly string[]): string;
|
|
27
|
+
export interface WireRefContext {
|
|
28
|
+
/** The automation's tf label (trigger blocks share it). */
|
|
29
|
+
readonly autoLabel: string;
|
|
30
|
+
/** The trigger block's resource type. */
|
|
31
|
+
readonly triggerType: string;
|
|
32
|
+
/** Declared onDemand parameter names (authored schema keys), for reverse canonicalization. */
|
|
33
|
+
readonly paramNames: readonly string[];
|
|
34
|
+
/** Task refKey → its tf resource type (implemented tasks only). */
|
|
35
|
+
readonly taskType: (refKey: string) => string | undefined;
|
|
36
|
+
/** Task refKey → the result property names its output schema declares. */
|
|
37
|
+
readonly taskResultProps: (refKey: string) => readonly string[];
|
|
38
|
+
/** Stamped variable id → its owning task refKey + variable name. */
|
|
39
|
+
readonly variableById: ReadonlyMap<string, {
|
|
40
|
+
taskRefKey: string;
|
|
41
|
+
varName: string;
|
|
42
|
+
}>;
|
|
43
|
+
}
|
|
44
|
+
export type WireRefResult = {
|
|
45
|
+
value: TfValue;
|
|
46
|
+
} | {
|
|
47
|
+
unsupported: string;
|
|
48
|
+
};
|
|
49
|
+
/** Wire ref envelope → tf attribute value (literal, refs expression, or template). */
|
|
50
|
+
export declare function wireRefToTf(ref: unknown, ctx: WireRefContext): WireRefResult;
|
|
51
|
+
/** Index the stamped variable ids in a finalized payload: id → {taskRefKey, varName}. */
|
|
52
|
+
export declare function indexVariableIds(tasks: ReadonlyArray<{
|
|
53
|
+
refKey?: string;
|
|
54
|
+
task?: Record<string, unknown>;
|
|
55
|
+
}>): Map<string, {
|
|
56
|
+
taskRefKey: string;
|
|
57
|
+
varName: string;
|
|
58
|
+
}>;
|
|
59
|
+
export interface TfRefContext {
|
|
60
|
+
/** The automation's tf label — the label-strip FALLBACK for refKey recovery. */
|
|
61
|
+
readonly autoLabel: string;
|
|
62
|
+
/** Trigger resource types (any `*_trigger`). */
|
|
63
|
+
readonly isTriggerType: (type: string) => boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Task tf label → the authored refKey (recovered from the block's `name`
|
|
66
|
+
* attribute when the label derives from it — see from-tf). Labels are
|
|
67
|
+
* snake_case by ei's labeling rule, so this is what preserves caps/spaces
|
|
68
|
+
* in task names across a pull.
|
|
69
|
+
*/
|
|
70
|
+
readonly refKeyByLabel: ReadonlyMap<string, string>;
|
|
71
|
+
}
|
|
72
|
+
export type TfRefResult = {
|
|
73
|
+
ast: RefExpr | string | number | boolean;
|
|
74
|
+
} | {
|
|
75
|
+
unsupported: string;
|
|
76
|
+
};
|
|
77
|
+
/** tf attribute value → printer AST node (inverse of wireRefToTf). */
|
|
78
|
+
export declare function tfRefToAst(value: TfValue, ctx: TfRefContext): TfRefResult;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Value-reference codec for the automation tf dialect.
|
|
3
|
+
*
|
|
4
|
+
* The compose wire carries refs as JSON envelopes ({triggerReference},
|
|
5
|
+
* {taskReference}, {variableReference}, {templateReference}, {value}); ei's
|
|
6
|
+
* HCL dialect carries them as `refs["…"]` RESOURCE EXPRESSIONS resolved at
|
|
7
|
+
* apply — `elementum_on_demand_trigger.x.refs["STUDENT_NAME"]` — with plain
|
|
8
|
+
* literals for static values and `${…}` interpolated strings for multi-part
|
|
9
|
+
* templates (cmd/elementum/export/hcl_task.go convertToRefsSyntax). ei's
|
|
10
|
+
* exporter falls back to embedding the raw JSON (with platform ids) when it
|
|
11
|
+
* can't resolve a ref; that fallback is NOT reproduced here — build emits only
|
|
12
|
+
* the id-free refs syntax, and pull reports the JSON fallback loudly instead
|
|
13
|
+
* of guessing.
|
|
14
|
+
*
|
|
15
|
+
* refs-map KEY naming (provider sources):
|
|
16
|
+
* - on_demand trigger: the DECLARED parameter name (the authored schema key;
|
|
17
|
+
* the wire's triggerReference name is the Mobius-canonicalized form —
|
|
18
|
+
* reverse-mapped here via the declared names).
|
|
19
|
+
* - variable task: the variable_name (buildVariableTaskRefs).
|
|
20
|
+
* - execute_script: "Result" for the whole result, "result.<prop>" per
|
|
21
|
+
* output-schema property.
|
|
22
|
+
*/
|
|
23
|
+
import { normalizeOnDemandParamKey } from "../../../pull/util.js";
|
|
24
|
+
import { expr, isTfExpr, sanitizeName } from "../../engine/tf/index.js";
|
|
25
|
+
import { AUTOMATION_SUB_TYPE_BY_RESOURCE, AUTOMATION_SUB_TYPE_BY_TYPE_KEY } from "./types.js";
|
|
26
|
+
const VARIABLE_TASK_TYPE = AUTOMATION_SUB_TYPE_BY_TYPE_KEY.get("variable").resourceType;
|
|
27
|
+
/** Map an authored/canonical onDemand param key to the declared parameter name. */
|
|
28
|
+
export function onDemandTriggerRefKey(name, paramNames) {
|
|
29
|
+
if (paramNames.includes(name))
|
|
30
|
+
return name;
|
|
31
|
+
return paramNames.find((p) => normalizeOnDemandParamKey(p) === name) ?? name;
|
|
32
|
+
}
|
|
33
|
+
function refsExpr(type, label, key) {
|
|
34
|
+
return expr.resourceAttr(type, label, ["refs", { index: key }]);
|
|
35
|
+
}
|
|
36
|
+
/** Wire ref envelope → tf attribute value (literal, refs expression, or template). */
|
|
37
|
+
export function wireRefToTf(ref, ctx) {
|
|
38
|
+
if (ref === null || typeof ref !== "object") {
|
|
39
|
+
return typeof ref === "string" || typeof ref === "number" || typeof ref === "boolean"
|
|
40
|
+
? { value: ref }
|
|
41
|
+
: { unsupported: `unrecognized value shape ${JSON.stringify(ref)}` };
|
|
42
|
+
}
|
|
43
|
+
const r = ref;
|
|
44
|
+
if ("value" in r && Object.keys(r).length === 1) {
|
|
45
|
+
const v = r["value"];
|
|
46
|
+
if (typeof v === "string" || typeof v === "number" || typeof v === "boolean")
|
|
47
|
+
return { value: v };
|
|
48
|
+
return { unsupported: `static value of unsupported type ${JSON.stringify(v)}` };
|
|
49
|
+
}
|
|
50
|
+
const trig = r["triggerReference"];
|
|
51
|
+
if (trig !== undefined && typeof trig?.name === "string") {
|
|
52
|
+
// The wire carries the AUTHORED name verbatim (canonicalization dropped);
|
|
53
|
+
// exact declared match wins. The canonical-form lookup remains only for
|
|
54
|
+
// sources printed by the old printer, whose access paths were camelCased.
|
|
55
|
+
return { value: refsExpr(ctx.triggerType, ctx.autoLabel, onDemandTriggerRefKey(trig.name, ctx.paramNames)) };
|
|
56
|
+
}
|
|
57
|
+
const task = r["taskReference"];
|
|
58
|
+
if (task !== undefined && typeof task?.name === "string") {
|
|
59
|
+
const refKey = task.taskRefKey ?? "";
|
|
60
|
+
const type = ctx.taskType(refKey);
|
|
61
|
+
if (type === undefined)
|
|
62
|
+
return { unsupported: `taskReference to unknown/uncarried task "${refKey}"` };
|
|
63
|
+
const key = task.name === "result" ? "Result" : task.name;
|
|
64
|
+
if (key !== "Result" && !key.startsWith("result.")) {
|
|
65
|
+
return { unsupported: `taskReference output "${task.name}" has no known refs-map key` };
|
|
66
|
+
}
|
|
67
|
+
if (key.startsWith("result.")) {
|
|
68
|
+
// Per-property result refs exist ONLY when the script declares that
|
|
69
|
+
// property in its output schema — otherwise the apply fails with
|
|
70
|
+
// "Invalid index" on the refs map. Fail at build instead, with the fix.
|
|
71
|
+
const prop = key.slice("result.".length);
|
|
72
|
+
if (!ctx.taskResultProps(refKey).includes(prop)) {
|
|
73
|
+
return {
|
|
74
|
+
unsupported: `references result.${prop} of task "${refKey}", but that task declares no output schema for it — ` +
|
|
75
|
+
`add outputs: { ${prop}: "text" } (or the right type) to its executeScript`,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return { value: refsExpr(type, `${ctx.autoLabel}_${sanitizeName(refKey)}`, key) };
|
|
80
|
+
}
|
|
81
|
+
const variable = r["variableReference"];
|
|
82
|
+
if (variable !== undefined && typeof variable?.id === "string") {
|
|
83
|
+
const target = ctx.variableById.get(variable.id);
|
|
84
|
+
if (target === undefined)
|
|
85
|
+
return { unsupported: `variableReference to an id not created in this workflow` };
|
|
86
|
+
return {
|
|
87
|
+
value: refsExpr(VARIABLE_TASK_TYPE, `${ctx.autoLabel}_${sanitizeName(target.taskRefKey)}`, target.varName),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const template = r["templateReference"];
|
|
91
|
+
if (template !== undefined && typeof template?.template === "string") {
|
|
92
|
+
const params = template.parameters ?? [];
|
|
93
|
+
// Single bare placeholder collapses to the ref itself (matches ei).
|
|
94
|
+
if (template.template === "{{{p1}}}" && params.length === 1) {
|
|
95
|
+
return wireRefToTf(params[0]?.value?.value, ctx);
|
|
96
|
+
}
|
|
97
|
+
const byName = new Map();
|
|
98
|
+
for (const p of params) {
|
|
99
|
+
if (typeof p?.value?.name === "string")
|
|
100
|
+
byName.set(p.value.name, p.value.value);
|
|
101
|
+
}
|
|
102
|
+
const parts = [];
|
|
103
|
+
let rest = template.template;
|
|
104
|
+
const placeholder = /\{\{\{(\w+)\}\}\}/;
|
|
105
|
+
for (;;) {
|
|
106
|
+
const m = placeholder.exec(rest);
|
|
107
|
+
if (m === null)
|
|
108
|
+
break;
|
|
109
|
+
if (m.index > 0)
|
|
110
|
+
parts.push(rest.slice(0, m.index));
|
|
111
|
+
const inner = wireRefToTf(byName.get(m[1]), ctx);
|
|
112
|
+
if ("unsupported" in inner)
|
|
113
|
+
return inner;
|
|
114
|
+
if (isTfExpr(inner.value))
|
|
115
|
+
parts.push(inner.value);
|
|
116
|
+
else
|
|
117
|
+
parts.push(String(inner.value));
|
|
118
|
+
rest = rest.slice(m.index + m[0].length);
|
|
119
|
+
}
|
|
120
|
+
if (rest !== "")
|
|
121
|
+
parts.push(rest);
|
|
122
|
+
return { value: { $expr: "template", parts } };
|
|
123
|
+
}
|
|
124
|
+
return { unsupported: `unsupported reference kind: ${Object.keys(r).join(", ")}` };
|
|
125
|
+
}
|
|
126
|
+
/** Index the stamped variable ids in a finalized payload: id → {taskRefKey, varName}. */
|
|
127
|
+
export function indexVariableIds(tasks) {
|
|
128
|
+
const index = new Map();
|
|
129
|
+
for (const t of tasks) {
|
|
130
|
+
const variable = t.task?.["variable"];
|
|
131
|
+
for (const c of variable?.create ?? []) {
|
|
132
|
+
if (typeof c?.id === "string" && typeof c?.name === "string" && typeof t.refKey === "string") {
|
|
133
|
+
index.set(c.id, { taskRefKey: t.refKey, varName: c.name });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return index;
|
|
138
|
+
}
|
|
139
|
+
function refKeyFromLabel(label, autoLabel) {
|
|
140
|
+
return label.startsWith(`${autoLabel}_`) ? label.slice(autoLabel.length + 1) : label;
|
|
141
|
+
}
|
|
142
|
+
/** tf attribute value → printer AST node (inverse of wireRefToTf). */
|
|
143
|
+
export function tfRefToAst(value, ctx) {
|
|
144
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
145
|
+
// A raw JSON envelope means ei fell back past refs syntax (unresolvable
|
|
146
|
+
// ref at export time) — report rather than round-trip platform ids.
|
|
147
|
+
if (typeof value === "string" && value.startsWith('{"')) {
|
|
148
|
+
return { unsupported: "ei exported a raw JSON value reference (refs-syntax fallback); not round-tripped" };
|
|
149
|
+
}
|
|
150
|
+
return { ast: value };
|
|
151
|
+
}
|
|
152
|
+
if (!isTfExpr(value))
|
|
153
|
+
return { unsupported: `unrecognized tf value ${JSON.stringify(value)}` };
|
|
154
|
+
if (value.$expr === "template") {
|
|
155
|
+
const parts = [];
|
|
156
|
+
for (const part of value.parts) {
|
|
157
|
+
if (typeof part === "string") {
|
|
158
|
+
parts.push(part);
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
const inner = tfRefToAst(part, ctx);
|
|
162
|
+
if ("unsupported" in inner)
|
|
163
|
+
return inner;
|
|
164
|
+
if (typeof inner.ast === "object")
|
|
165
|
+
parts.push(inner.ast);
|
|
166
|
+
else
|
|
167
|
+
parts.push(String(inner.ast));
|
|
168
|
+
}
|
|
169
|
+
return { ast: { kind: "template", parts } };
|
|
170
|
+
}
|
|
171
|
+
if (value.$expr === "resource-attr" && value.path.length === 2 && value.path[0] === "refs") {
|
|
172
|
+
const seg = value.path[1];
|
|
173
|
+
const key = typeof seg === "object" ? seg.index : String(seg);
|
|
174
|
+
const type = value.type;
|
|
175
|
+
if (ctx.isTriggerType(type)) {
|
|
176
|
+
// The refs key IS the declared parameter name — print it verbatim; the
|
|
177
|
+
// printer emits bracket access when it isn't identifier-safe.
|
|
178
|
+
return { ast: { kind: "triggerRef", path: [key] } };
|
|
179
|
+
}
|
|
180
|
+
const refKeyOf = (label) => ctx.refKeyByLabel.get(label) ?? refKeyFromLabel(label, ctx.autoLabel);
|
|
181
|
+
if (type === VARIABLE_TASK_TYPE) {
|
|
182
|
+
return {
|
|
183
|
+
ast: { kind: "variableParamRef", varTask: refKeyOf(value.label), name: key },
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
if (AUTOMATION_SUB_TYPE_BY_RESOURCE.has(type)) {
|
|
187
|
+
const path = key === "Result" ? ["result"] : key.split(".");
|
|
188
|
+
return { ast: { kind: "taskRef", task: refKeyOf(value.label), path } };
|
|
189
|
+
}
|
|
190
|
+
return { unsupported: `refs expression on unrecognized resource type ${type}` };
|
|
191
|
+
}
|
|
192
|
+
return { unsupported: `unsupported tf expression ${JSON.stringify(value).slice(0, 120)}` };
|
|
193
|
+
}
|
|
@@ -61,6 +61,7 @@ export function element(opts) {
|
|
|
61
61
|
parentKind: "element",
|
|
62
62
|
parentName: opts.name,
|
|
63
63
|
fieldType: field.type,
|
|
64
|
+
...("dynamicSource" in field && field.dynamicSource === true ? { dynamicSource: true } : {}),
|
|
64
65
|
...(field.options !== undefined ? { options: picklistOptionLabels(field.options) } : {}),
|
|
65
66
|
...(field.tags !== undefined ? { tags: field.tags } : {}),
|
|
66
67
|
};
|
|
@@ -10,8 +10,9 @@ export { type AppRecordCreateForm, type AppRecordCreateFormSection } from "../ap
|
|
|
10
10
|
export { listViewDensity, managedViewSortAggregation, managedViewSortDirection, type ListViewDensity, type ManagedViewSort, type ManagedViewSortAggregation, type ManagedViewSortDirection, type ManagedViewSortField, type ManagedViewSortOrder, } from "../view/build.js";
|
|
11
11
|
export { type AppRelationship, type AppRelationshipColumn } from "../relationship/build.js";
|
|
12
12
|
export { dashboardRecordsWidget, dashboardWidgetSize, type DashboardRecordsWidget, type DashboardWidget, type DashboardWidgetSize, } from "../dashboard/build.js";
|
|
13
|
-
export { attachmentField, booleanField, calculatedField, dateField, dateTimeField, decimalField, groupField, jsonField,
|
|
13
|
+
export { attachmentField, booleanField, calculatedField, dateField, dateTimeField, decimalField, dropdownDisplay, dropdownField, dropdownOption, dropdownValue, groupField, jsonField, multiSelectField, numberField, relationField, richTextField, textField, userField, type BaseFieldOptions, type CalculatedFieldOptions, type InferredCalculatedField, type NumericFieldFormat, type DropdownConfig, type DropdownDisplay, type DropdownFieldOptions, type DropdownOption, type DropdownParentValueRef, type DynamicDropdownConfig, type DynamicDropdownParent, type DynamicDropdownParentMapping, type MultiSelectFieldOptions, type NumericFieldOptions, type RelationFieldOptions, type QrFieldFormat, type TextFieldOptions, } from "../field/build.js";
|
|
14
14
|
export { calc, dateDifUnit, dateTimeTruncPrecision, field, orderByDirection, predicateOp, weekdayMode, type ConcatExprType, type DateDifUnit, type DateTimeTruncPrecision, type Expr, type ExprType, type FieldRefExprType, type OrderByDirection, type Predicate, type PredicateOp, type StringAggOptions, type StringAggOrderBy, type WeekdayMode, } from "../field/calc.js";
|
|
15
|
+
export { asc, desc, sortBy, type SortDirection, type SortOrder } from "../shared/types/common.js";
|
|
15
16
|
export { groupId, userId, type AccessPolicyGroupRef, type AccessPolicyOptions, type AccessPolicyPrincipalRef, type AccessPolicyUserRef, type GroupId, type UserId } from "../access-policy/build.js";
|
|
16
17
|
export { roleAutoShare, rolePermissionGroup, rolePermissionLevel, userRef, type AppRole, type RoleAutoShare, type RoleGroupRef, type RolePermission, type RolePermissionGroup, type RolePermissionLevel, type RoleUserRef } from "../role/build.js";
|
|
17
18
|
export { serviceAccountRef, type ServiceAccountRef } from "../service-account/ref.js";
|
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
export { element, } from "./build.js";
|
|
9
9
|
export { listViewDensity, managedViewSortAggregation, managedViewSortDirection, } from "../view/build.js";
|
|
10
10
|
export { dashboardRecordsWidget, dashboardWidgetSize, } from "../dashboard/build.js";
|
|
11
|
-
export { attachmentField, booleanField, calculatedField, dateField, dateTimeField, decimalField, groupField, jsonField,
|
|
11
|
+
export { attachmentField, booleanField, calculatedField, dateField, dateTimeField, decimalField, dropdownDisplay, dropdownField, dropdownOption, dropdownValue, groupField, jsonField, multiSelectField, numberField, relationField, richTextField, textField, userField, } from "../field/build.js";
|
|
12
12
|
export { calc, dateDifUnit, dateTimeTruncPrecision, field, orderByDirection, predicateOp, weekdayMode, } from "../field/calc.js";
|
|
13
|
+
export { asc, desc, sortBy } from "../shared/types/common.js";
|
|
13
14
|
export { groupId, userId } from "../access-policy/build.js";
|
|
14
15
|
export { roleAutoShare, rolePermissionGroup, rolePermissionLevel, userRef } from "../role/build.js";
|
|
15
16
|
export { serviceAccountRef } from "../service-account/ref.js";
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
* fields: {
|
|
7
7
|
* glamourShot: attachmentField({ name: "Glamour Shot" }),
|
|
8
8
|
* hasPetLlama: booleanField({ name: "Has Pet Llama", required: true }),
|
|
9
|
-
* club:
|
|
9
|
+
* club: dropdownField({
|
|
10
|
+
* name: "Club",
|
|
11
|
+
* config: { static: { values: ["FFA", "Rex Kwon Do"] } },
|
|
12
|
+
* }),
|
|
10
13
|
* }
|
|
11
14
|
*
|
|
12
15
|
* Each factory returns a plain {@link AppField} with the `type` discriminator
|
|
@@ -19,6 +22,8 @@ import type { AppOrElementRef, FieldRef } from "../../catalog/index.js";
|
|
|
19
22
|
import type { AppFieldOfExprType, CalculationInclude, Expr, ExprContext, ExprType, ExprTypeOf, FieldRefOfExprType } from "./calc/types.js";
|
|
20
23
|
import type { UnsafePlatformId } from "../../core/platform-id.js";
|
|
21
24
|
import type { AspectFieldQrFormat, AspectNumericFieldFormat } from "../../../elementum-entity-client/clients/aspects/models/format.js";
|
|
25
|
+
import type { Filter } from "../shared/filters/types.js";
|
|
26
|
+
import type { SortOrder } from "../shared/types/common.js";
|
|
22
27
|
/** Statically typed display options for NUMBER and DECIMAL fields. */
|
|
23
28
|
export type NumericFieldFormat = AspectNumericFieldFormat;
|
|
24
29
|
/** Statically typed QR display options for text fields. */
|
|
@@ -41,7 +46,7 @@ type WithExpression<T extends ExprType> = {
|
|
|
41
46
|
/** @deprecated Prefer `calculatedField({ name, expression })` for calculated values. */
|
|
42
47
|
readonly expression?: ScalarExpression<T>;
|
|
43
48
|
};
|
|
44
|
-
/**
|
|
49
|
+
/** @deprecated Use {@link DropdownFieldOptions} or {@link MultiSelectFieldOptions}. */
|
|
45
50
|
export interface PicklistFieldOptions extends BaseFieldOptions {
|
|
46
51
|
/** Static options; omit for dynamic picklists (`config.dynamic`). */
|
|
47
52
|
readonly options?: readonly (string | PicklistOption)[];
|
|
@@ -51,6 +56,71 @@ export interface PicklistFieldOptions extends BaseFieldOptions {
|
|
|
51
56
|
/** @deprecated Prefer `calculatedField({ name, expression })`. */
|
|
52
57
|
readonly expression?: ScalarExpression<"picklist" | "multiPicklist">;
|
|
53
58
|
}
|
|
59
|
+
/** Product-visible rendering modes for dynamically sourced values. */
|
|
60
|
+
export declare const dropdownDisplay: {
|
|
61
|
+
readonly dropdown: "DROPDOWN";
|
|
62
|
+
readonly table: "TABLE";
|
|
63
|
+
};
|
|
64
|
+
export type DropdownDisplay = (typeof dropdownDisplay)[keyof typeof dropdownDisplay];
|
|
65
|
+
/** A typed reference to a value on a parent Dropdown or Multi-Select field. */
|
|
66
|
+
export interface DropdownParentValueRef {
|
|
67
|
+
readonly __kind: "dropdownValue";
|
|
68
|
+
readonly field: FieldRef<string, string, "PICKLIST" | "MULTI_PICKLIST">;
|
|
69
|
+
readonly label: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Reference a static value on a parent selection field without exposing its
|
|
73
|
+
* platform UUID. The provider resolves the label through the parent's
|
|
74
|
+
* options-by-label local.
|
|
75
|
+
*/
|
|
76
|
+
export declare function dropdownValue(field: FieldRef<string, string, "PICKLIST" | "MULTI_PICKLIST">, label: string): DropdownParentValueRef;
|
|
77
|
+
/** Product-facing static value declaration shared by Dropdown and Multi-Select. */
|
|
78
|
+
export interface DropdownOption {
|
|
79
|
+
readonly label: string;
|
|
80
|
+
readonly active?: boolean;
|
|
81
|
+
readonly icon?: string;
|
|
82
|
+
readonly color?: string;
|
|
83
|
+
readonly tags?: readonly ("CLOSED" | "CRITICAL" | "HIGH" | "MEDIUM" | "LOW")[];
|
|
84
|
+
readonly availableWhen?: readonly DropdownParentValueRef[];
|
|
85
|
+
}
|
|
86
|
+
export declare function dropdownOption(option: DropdownOption): DropdownOption;
|
|
87
|
+
/** One parent/source-field equality used by a cascading dynamic selection field. */
|
|
88
|
+
export interface DynamicDropdownParentMapping {
|
|
89
|
+
readonly parentSourceField: FieldRef;
|
|
90
|
+
readonly sourceField: FieldRef;
|
|
91
|
+
}
|
|
92
|
+
export interface DynamicDropdownParent {
|
|
93
|
+
/** Dynamic parents are single-select Dropdown fields in the product UI. */
|
|
94
|
+
readonly field: FieldRef<string, string, "PICKLIST">;
|
|
95
|
+
readonly mappings: readonly DynamicDropdownParentMapping[];
|
|
96
|
+
}
|
|
97
|
+
export interface StaticDropdownConfig {
|
|
98
|
+
readonly values: readonly (string | DropdownOption)[];
|
|
99
|
+
readonly parent?: FieldRef<string, string, "PICKLIST" | "MULTI_PICKLIST">;
|
|
100
|
+
}
|
|
101
|
+
export interface DynamicDropdownConfig {
|
|
102
|
+
readonly source: AppOrElementRef | UnsafePlatformId;
|
|
103
|
+
readonly label: FieldRef | UnsafePlatformId;
|
|
104
|
+
readonly parent?: DynamicDropdownParent;
|
|
105
|
+
readonly autoRelate?: boolean;
|
|
106
|
+
readonly displayAs?: DropdownDisplay;
|
|
107
|
+
readonly filter?: Filter;
|
|
108
|
+
readonly sort?: readonly SortOrder<FieldRef | UnsafePlatformId>[];
|
|
109
|
+
}
|
|
110
|
+
/** Exactly one value source is required. */
|
|
111
|
+
export type DropdownConfig = {
|
|
112
|
+
readonly static: StaticDropdownConfig;
|
|
113
|
+
readonly dynamic?: never;
|
|
114
|
+
} | {
|
|
115
|
+
readonly static?: never;
|
|
116
|
+
readonly dynamic: DynamicDropdownConfig;
|
|
117
|
+
};
|
|
118
|
+
export interface DropdownFieldOptions extends BaseFieldOptions {
|
|
119
|
+
readonly config: DropdownConfig;
|
|
120
|
+
}
|
|
121
|
+
export interface MultiSelectFieldOptions extends BaseFieldOptions {
|
|
122
|
+
readonly config: DropdownConfig;
|
|
123
|
+
}
|
|
54
124
|
/** Extra options for the numeric kinds (`numberField` / `decimalField`). */
|
|
55
125
|
export interface NumericFieldOptions extends BaseFieldOptions {
|
|
56
126
|
readonly numericFormat?: NumericFieldFormat;
|
|
@@ -68,7 +138,7 @@ export interface TextFieldOptions extends BaseFieldOptions {
|
|
|
68
138
|
/**
|
|
69
139
|
* Options for `relationField` — a dynamic dropdown sourced from another
|
|
70
140
|
* App/Element/Task's records (`elementum_relation_field`), distinct from a
|
|
71
|
-
* static `
|
|
141
|
+
* static `dropdownField`. `relatedObject`/`relatedLabelField` (see
|
|
72
142
|
* {@link RelationAppField}) accept a catalog token or a raw platform id. A
|
|
73
143
|
* token naming a SIBLING app/element authored in the same build resolves
|
|
74
144
|
* to a direct resource reference and does not need to already exist on the
|
|
@@ -114,9 +184,30 @@ export declare function attachmentField(opts: BaseFieldOptions & WithExpression<
|
|
|
114
184
|
export declare function jsonField(opts: BaseFieldOptions & WithExpression<"json">): AppField & {
|
|
115
185
|
readonly type: "JSON";
|
|
116
186
|
};
|
|
187
|
+
/** A single-value Dropdown field, using the product's Static/Dynamic configuration model. */
|
|
188
|
+
type DynamicSelectionMarker<Config extends DropdownConfig> = Config extends {
|
|
189
|
+
readonly dynamic: DynamicDropdownConfig;
|
|
190
|
+
} ? {
|
|
191
|
+
readonly dynamicSource: true;
|
|
192
|
+
} : {
|
|
193
|
+
readonly dynamicSource?: never;
|
|
194
|
+
};
|
|
195
|
+
export declare function dropdownField<const Config extends DropdownConfig>(opts: Omit<DropdownFieldOptions, "config"> & {
|
|
196
|
+
readonly config: Config;
|
|
197
|
+
}): AppField & {
|
|
198
|
+
readonly type: "PICKLIST";
|
|
199
|
+
} & DynamicSelectionMarker<Config>;
|
|
200
|
+
/** A multiple-value Multi-Select field, using the product's Static/Dynamic configuration model. */
|
|
201
|
+
export declare function multiSelectField<const Config extends DropdownConfig>(opts: Omit<MultiSelectFieldOptions, "config"> & {
|
|
202
|
+
readonly config: Config;
|
|
203
|
+
}): AppField & {
|
|
204
|
+
readonly type: "MULTI_PICKLIST";
|
|
205
|
+
} & DynamicSelectionMarker<Config>;
|
|
206
|
+
/** @deprecated Use {@link dropdownField}. */
|
|
117
207
|
export declare function picklistField(opts: Omit<PicklistFieldOptions, "expression"> & WithExpression<"picklist">): AppField & {
|
|
118
208
|
readonly type: "PICKLIST";
|
|
119
209
|
};
|
|
210
|
+
/** @deprecated Use {@link multiSelectField}. */
|
|
120
211
|
export declare function multiPicklistField(opts: Omit<PicklistFieldOptions, "expression"> & WithExpression<"multiPicklist">): AppField & {
|
|
121
212
|
readonly type: "MULTI_PICKLIST";
|
|
122
213
|
};
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
* fields: {
|
|
7
7
|
* glamourShot: attachmentField({ name: "Glamour Shot" }),
|
|
8
8
|
* hasPetLlama: booleanField({ name: "Has Pet Llama", required: true }),
|
|
9
|
-
* club:
|
|
9
|
+
* club: dropdownField({
|
|
10
|
+
* name: "Club",
|
|
11
|
+
* config: { static: { values: ["FFA", "Rex Kwon Do"] } },
|
|
12
|
+
* }),
|
|
10
13
|
* }
|
|
11
14
|
*
|
|
12
15
|
* Each factory returns a plain {@link AppField} with the `type` discriminator
|
|
@@ -15,6 +18,22 @@
|
|
|
15
18
|
* AppField is accepted.
|
|
16
19
|
*/
|
|
17
20
|
import { coerce } from "./calc/runtime.js";
|
|
21
|
+
/** Product-visible rendering modes for dynamically sourced values. */
|
|
22
|
+
export const dropdownDisplay = {
|
|
23
|
+
dropdown: "DROPDOWN",
|
|
24
|
+
table: "TABLE",
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Reference a static value on a parent selection field without exposing its
|
|
28
|
+
* platform UUID. The provider resolves the label through the parent's
|
|
29
|
+
* options-by-label local.
|
|
30
|
+
*/
|
|
31
|
+
export function dropdownValue(field, label) {
|
|
32
|
+
return { __kind: "dropdownValue", field, label };
|
|
33
|
+
}
|
|
34
|
+
export function dropdownOption(option) {
|
|
35
|
+
return option;
|
|
36
|
+
}
|
|
18
37
|
// Generic over the literal type discriminator so a field factory's return
|
|
19
38
|
// type carries e.g. `type: "PICKLIST"`, not the widened `WorkflowFieldType`
|
|
20
39
|
// union — required for the live catalog path (`app`'s `.ref()`) to
|
|
@@ -57,9 +76,69 @@ export function attachmentField(opts) {
|
|
|
57
76
|
export function jsonField(opts) {
|
|
58
77
|
return field("JSON", opts);
|
|
59
78
|
}
|
|
79
|
+
function selectionFieldOptions(opts) {
|
|
80
|
+
const { config, ...base } = opts;
|
|
81
|
+
if (config.static !== undefined) {
|
|
82
|
+
const options = config.static.values.map((value) => {
|
|
83
|
+
if (typeof value === "string")
|
|
84
|
+
return value;
|
|
85
|
+
return {
|
|
86
|
+
label: value.label,
|
|
87
|
+
...(value.active !== undefined && { active: value.active }),
|
|
88
|
+
...(value.icon !== undefined && { icon: value.icon }),
|
|
89
|
+
...(value.color !== undefined && { color: value.color }),
|
|
90
|
+
...(value.tags !== undefined && { tags: value.tags }),
|
|
91
|
+
...(value.availableWhen !== undefined && { parentValues: value.availableWhen }),
|
|
92
|
+
};
|
|
93
|
+
});
|
|
94
|
+
return {
|
|
95
|
+
...base,
|
|
96
|
+
options,
|
|
97
|
+
...(config.static.parent !== undefined && { parentField: config.static.parent }),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const dynamic = config.dynamic;
|
|
101
|
+
return {
|
|
102
|
+
...base,
|
|
103
|
+
config: {
|
|
104
|
+
dynamic: {
|
|
105
|
+
relatedAspectId: dynamic.source,
|
|
106
|
+
relatedLabelFieldId: dynamic.label,
|
|
107
|
+
...(dynamic.parent !== undefined && {
|
|
108
|
+
parentFieldId: dynamic.parent.field,
|
|
109
|
+
parentMappings: dynamic.parent.mappings.map((mapping) => ({
|
|
110
|
+
parentAspectFieldId: mapping.parentSourceField,
|
|
111
|
+
relatedAspectFieldId: mapping.sourceField,
|
|
112
|
+
})),
|
|
113
|
+
}),
|
|
114
|
+
...(dynamic.autoRelate !== undefined && { autoRelate: dynamic.autoRelate }),
|
|
115
|
+
...(dynamic.displayAs !== undefined && { valuesRenderType: dynamic.displayAs }),
|
|
116
|
+
...(dynamic.filter !== undefined && { filter: dynamic.filter }),
|
|
117
|
+
...(dynamic.sort !== undefined && { sort: { orders: dynamic.sort } }),
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
export function dropdownField(opts) {
|
|
123
|
+
const built = field("PICKLIST", selectionFieldOptions(opts));
|
|
124
|
+
return {
|
|
125
|
+
...built,
|
|
126
|
+
...("dynamic" in opts.config ? { dynamicSource: true } : {}),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/** A multiple-value Multi-Select field, using the product's Static/Dynamic configuration model. */
|
|
130
|
+
export function multiSelectField(opts) {
|
|
131
|
+
const built = field("MULTI_PICKLIST", selectionFieldOptions(opts));
|
|
132
|
+
return {
|
|
133
|
+
...built,
|
|
134
|
+
...("dynamic" in opts.config ? { dynamicSource: true } : {}),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/** @deprecated Use {@link dropdownField}. */
|
|
60
138
|
export function picklistField(opts) {
|
|
61
139
|
return field("PICKLIST", opts);
|
|
62
140
|
}
|
|
141
|
+
/** @deprecated Use {@link multiSelectField}. */
|
|
63
142
|
export function multiPicklistField(opts) {
|
|
64
143
|
return field("MULTI_PICKLIST", opts);
|
|
65
144
|
}
|
|
@@ -103,7 +182,7 @@ export const FIELD_FACTORY_BY_TYPE = new Map([
|
|
|
103
182
|
["GROUP", "groupField"],
|
|
104
183
|
["ATTACHMENT", "attachmentField"],
|
|
105
184
|
["JSON", "jsonField"],
|
|
106
|
-
["PICKLIST", "
|
|
107
|
-
["MULTI_PICKLIST", "
|
|
185
|
+
["PICKLIST", "dropdownField"],
|
|
186
|
+
["MULTI_PICKLIST", "multiSelectField"],
|
|
108
187
|
["RELATION", "relationField"],
|
|
109
188
|
]);
|