@elementumai/edk 0.9.15 → 0.9.17
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/dist-sdk/pull/util.d.ts +0 -15
- package/dist-sdk/pull/util.js +44 -5
- package/dist-sdk/src/engine/build/context.d.ts +2 -2
- package/dist-sdk/src/engine/progress.d.ts +4 -0
- package/dist-sdk/src/engine/progress.js +16 -4
- package/dist-sdk/src/engine/pull/context.d.ts +5 -0
- package/dist-sdk/src/engine/pull/ref-only.d.ts +4 -0
- package/dist-sdk/src/engine/pull/ref-only.js +11 -0
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +1 -1
- package/dist-sdk/src/entities/access-policy/from-tf.js +47 -12
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +5 -3
- package/dist-sdk/src/entities/access-policy/to-tf.js +23 -1
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +27 -2
- package/dist-sdk/src/entities/agent/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/agent/from-tf.js +18 -3
- package/dist-sdk/src/entities/agent/to-tf.js +14 -0
- package/dist-sdk/src/entities/agent/tools.d.ts +79 -2
- package/dist-sdk/src/entities/agent/tools.js +2 -1
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +11 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.js +45 -3
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +7 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.js +72 -20
- package/dist-sdk/src/entities/app/module.js +8 -0
- package/dist-sdk/src/entities/app/to-tf.js +1 -0
- package/dist-sdk/src/entities/automation/build.d.ts +12 -5
- package/dist-sdk/src/entities/automation/build.js +30 -11
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +4 -0
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +108 -23
- package/dist-sdk/src/entities/automation/from-tf.d.ts +73 -5
- package/dist-sdk/src/entities/automation/from-tf.js +270 -30
- package/dist-sdk/src/entities/automation/index.d.ts +2 -1
- package/dist-sdk/src/entities/automation/index.js +2 -1
- package/dist-sdk/src/entities/automation/module.js +6 -7
- package/dist-sdk/src/entities/automation/output-field-types.d.ts +5 -0
- package/dist-sdk/src/entities/automation/output-field-types.js +12 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +20 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +22 -0
- package/dist-sdk/src/entities/automation/script-code.js +13 -4
- package/dist-sdk/src/entities/automation/tasks.d.ts +61 -5
- package/dist-sdk/src/entities/automation/tasks.js +42 -9
- package/dist-sdk/src/entities/automation/to-tf.d.ts +0 -2
- package/dist-sdk/src/entities/automation/to-tf.js +85 -36
- package/dist-sdk/src/entities/automation/triggers.d.ts +5 -2
- package/dist-sdk/src/entities/automation/types.d.ts +2 -0
- package/dist-sdk/src/entities/automation/types.js +5 -0
- package/dist-sdk/src/entities/automation/workflow-output.d.ts +35 -0
- package/dist-sdk/src/entities/automation/workflow-output.js +53 -0
- package/dist-sdk/src/entities/dashboard/from-tf.js +1 -1
- package/dist-sdk/src/entities/dashboard/to-tf.js +1 -0
- package/dist-sdk/src/entities/element/build.d.ts +11 -8
- package/dist-sdk/src/entities/element/build.js +14 -5
- package/dist-sdk/src/entities/element/locals.d.ts +2 -2
- package/dist-sdk/src/entities/element/locals.js +6 -2
- package/dist-sdk/src/entities/element/system-fields.d.ts +4 -0
- package/dist-sdk/src/entities/element/system-fields.js +12 -0
- package/dist-sdk/src/entities/element/to-tf.js +1 -0
- package/dist-sdk/src/entities/field/from-tf.js +47 -1
- package/dist-sdk/src/entities/relationship/from-tf.js +2 -2
- package/dist-sdk/src/entities/relationship/to-tf.js +1 -0
- package/dist-sdk/src/entities/search-table/from-tf.js +6 -6
- package/dist-sdk/src/entities/search-table/module.js +2 -2
- package/dist-sdk/src/entities/search-table/types.d.ts +1 -0
- package/dist-sdk/src/entities/search-table/types.js +1 -0
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +12 -2
- package/dist-sdk/src/entities/shared/filters/index.js +17 -1
- package/dist-sdk/src/entities/shared/filters/print.js +25 -11
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +1 -1
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +39 -7
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +18 -2
- package/dist-sdk/src/entities/skill/module.js +9 -0
- package/dist-sdk/src/entities/skill/to-tf.js +18 -0
- package/dist-sdk/src/entities/skill/tools.d.ts +18 -4
- package/dist-sdk/src/entities/skill/tools.js +1 -1
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +12 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +58 -3
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +6 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.js +78 -43
- package/dist-sdk/src/entities/view/from-tf.js +30 -9
- package/dist-sdk/src/entities/view/to-tf.js +18 -10
- package/dist-sdk/src/entities/widget/from-tf.js +1 -1
- package/dist-sdk/src/entities/widget/to-tf.js +1 -0
- package/dist-sdk/src/graph/index.d.ts +13 -0
- package/dist-sdk/src/graph/index.js +5 -0
- package/dist-sdk/src/graph/types.d.ts +10 -0
- package/package.json +2 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EntityTfError } from "../../engine/entity.js";
|
|
2
|
+
import { type TfBlock, type TfDocument, type TfValue } from "../../engine/tf/index.js";
|
|
2
3
|
import type { AutomationAst } from "./deserializer/ast.js";
|
|
3
4
|
export interface AutomationFromTfResult {
|
|
4
5
|
readonly refName: string;
|
|
@@ -13,6 +14,59 @@ export interface AutomationFromTfResult {
|
|
|
13
14
|
/** Non-fatal issues found while extracting (edk#785: a task anchored to the trigger because its real parent is unsupported). */
|
|
14
15
|
readonly diagnostics?: readonly string[];
|
|
15
16
|
}
|
|
17
|
+
interface DecodeContext {
|
|
18
|
+
readonly appRefName: string;
|
|
19
|
+
readonly appTfLabel: string;
|
|
20
|
+
readonly trigger: TfBlock;
|
|
21
|
+
readonly taskByAddress: ReadonlyMap<string, {
|
|
22
|
+
block: TfBlock;
|
|
23
|
+
refKey: string;
|
|
24
|
+
}>;
|
|
25
|
+
readonly resourceBlocks: ReadonlyMap<string, TfBlock>;
|
|
26
|
+
readonly dataBlocks: ReadonlyMap<string, TfBlock>;
|
|
27
|
+
readonly resourceImportIds: ReadonlyMap<string, string>;
|
|
28
|
+
readonly fieldById: ReadonlyMap<string, {
|
|
29
|
+
readonly key: string;
|
|
30
|
+
readonly name: string;
|
|
31
|
+
readonly resourceType: string;
|
|
32
|
+
}>;
|
|
33
|
+
/** Stage key -> name, from the app block's `stages` list; see `stageFilterName`. */
|
|
34
|
+
readonly stagesByKey: ReadonlyMap<string, string>;
|
|
35
|
+
readonly foreignFieldRefsById?: ReadonlyMap<string, {
|
|
36
|
+
readonly ownerRefName: string;
|
|
37
|
+
readonly fieldKey: string;
|
|
38
|
+
readonly fieldName?: string;
|
|
39
|
+
readonly fieldType?: string;
|
|
40
|
+
}>;
|
|
41
|
+
readonly foreignFieldRefsByDataAddress?: ReadonlyMap<string, {
|
|
42
|
+
readonly ownerRefName: string;
|
|
43
|
+
readonly fieldKey: string;
|
|
44
|
+
readonly ownerKind?: "app" | "element" | "task";
|
|
45
|
+
readonly ownerName?: string;
|
|
46
|
+
readonly ownerNamespace?: string;
|
|
47
|
+
readonly fieldName?: string;
|
|
48
|
+
readonly fieldType?: string;
|
|
49
|
+
}>;
|
|
50
|
+
readonly foreignTableRefsById?: ReadonlyMap<string, {
|
|
51
|
+
readonly tableRefName: string;
|
|
52
|
+
readonly name: string;
|
|
53
|
+
}>;
|
|
54
|
+
readonly picklistOptionLabelById?: ReadonlyMap<string, string>;
|
|
55
|
+
readonly fieldNamesByOwnerRefName?: ReadonlyMap<string, ReadonlyMap<string, string>>;
|
|
56
|
+
/** Task resource address → target aspect refName (from `object_id`). */
|
|
57
|
+
readonly taskTargetOwnerRefNameByAddress?: ReadonlyMap<string, string>;
|
|
58
|
+
/** Task resource address → whether `object_id` names an app or element. */
|
|
59
|
+
readonly taskTargetOwnerKindByAddress?: ReadonlyMap<string, "app" | "element" | "task">;
|
|
60
|
+
readonly foreignAppRefNames?: ReadonlyMap<string, string>;
|
|
61
|
+
readonly foreignElementRefNames?: ReadonlyMap<string, string>;
|
|
62
|
+
readonly foreignTaskRefNames?: ReadonlyMap<string, string>;
|
|
63
|
+
/** Procedure discriminator (`procedureDiscriminator`) → org.ts's disambiguated catalog key, for overloaded same-name procedures. See `procedure-refs.ts`. */
|
|
64
|
+
readonly procedureKeysByDiscriminator?: ReadonlyMap<string, string>;
|
|
65
|
+
}
|
|
66
|
+
export declare function inferredPublishOutputType(value: TfValue, ctx: DecodeContext): {
|
|
67
|
+
readonly fieldType: string;
|
|
68
|
+
readonly multiple: boolean;
|
|
69
|
+
};
|
|
16
70
|
/**
|
|
17
71
|
* Best-effort resource footprint of one automation, used ONLY when whole-
|
|
18
72
|
* automation extraction throws (module.ts's `extractAutomations` catch
|
|
@@ -24,12 +78,25 @@ export interface AutomationFromTfResult {
|
|
|
24
78
|
* shows those addresses as destroy-on-apply (confirmed live: several
|
|
25
79
|
* automations that failed extraction were imported into state anyway,
|
|
26
80
|
* driving spurious destroys). Deliberately lenient - tolerant of the exact
|
|
27
|
-
* conditions that make real extraction fail (zero
|
|
28
|
-
* unrecognized task kind)
|
|
29
|
-
*
|
|
30
|
-
*
|
|
81
|
+
* conditions that make real extraction fail (zero triggers, an
|
|
82
|
+
* unrecognized task kind) so it over-collects rather than under-collects.
|
|
83
|
+
* More than one trigger is not one of those cases: it throws
|
|
84
|
+
* {@link UnsupportedMultiTriggerError} and stops the pull. A false positive
|
|
85
|
+
* here just leaves one more resource unmanaged; a false negative would
|
|
86
|
+
* silently destroy a live automation on apply.
|
|
31
87
|
*/
|
|
32
88
|
export declare function automationOwnedAddresses(doc: TfDocument, automationLabel: string): readonly string[];
|
|
89
|
+
/**
|
|
90
|
+
* Pull stops on this. EDK does not author multi-trigger automations; apps
|
|
91
|
+
* should keep one trigger and call the shared logic with a run-automation
|
|
92
|
+
* action. Callers that otherwise turn extract failures into skips must
|
|
93
|
+
* rethrow it.
|
|
94
|
+
*/
|
|
95
|
+
export declare class UnsupportedMultiTriggerError extends EntityTfError {
|
|
96
|
+
readonly automationName: string;
|
|
97
|
+
readonly triggerCount: number;
|
|
98
|
+
constructor(automationName: string, triggerCount: number);
|
|
99
|
+
}
|
|
33
100
|
export interface AutomationFromTfContext {
|
|
34
101
|
readonly ownerHandle: string;
|
|
35
102
|
readonly diagnostics: string[];
|
|
@@ -82,3 +149,4 @@ export declare function automationFromTf(doc: TfDocument, automationLabel: strin
|
|
|
82
149
|
readonly tableRefName: string;
|
|
83
150
|
readonly name: string;
|
|
84
151
|
}>, picklistOptionLabelById?: ReadonlyMap<string, string>, fieldNamesByOwnerRefName?: ReadonlyMap<string, ReadonlyMap<string, string>>, foreignAppRefNames?: ReadonlyMap<string, string>, foreignElementRefNames?: ReadonlyMap<string, string>, procedureKeysByDiscriminator?: ReadonlyMap<string, string>, foreignTaskRefNames?: ReadonlyMap<string, string>): AutomationFromTfResult;
|
|
152
|
+
export {};
|
|
@@ -11,9 +11,10 @@ import { UNRESOLVED_FIELD_MARKER } from "../shared/ref.js";
|
|
|
11
11
|
import { filterFromTf as deserializeFilterFromTf } from "../shared/filters/tf-codec.js";
|
|
12
12
|
import { TABLE_RESOURCE_TYPE } from "../table/module.js";
|
|
13
13
|
import { SEARCH_TABLE_RESOURCE_TYPES } from "../search-table/types.js";
|
|
14
|
-
import { outputFieldTypesFromScriptSchema } from "./output-field-types.js";
|
|
15
|
-
import { apiTaskRefAuthoringPath, OUTPUT_KEY_WIRE_NAME } from "./output-key-wire-name.js";
|
|
14
|
+
import { outputFieldTypesFromScriptSchema, scriptOutputReferenceIsDeclared } from "./output-field-types.js";
|
|
15
|
+
import { apiTaskRefAuthoringPath, matchesOutputWireKey, OUTPUT_KEY_WIRE_NAME } from "./output-key-wire-name.js";
|
|
16
16
|
import { taskTfLabel } from "./task-label.js";
|
|
17
|
+
import { workflowOutputTypeFromFieldType } from "./workflow-output.js";
|
|
17
18
|
import { ALL_AUTOMATION_TASK_TYPE_SET, AUTOMATION_BRANCH_TYPE_SET, AUTOMATION_RESOURCE_TYPE, AUTOMATION_TRIGGER_TYPE_SET, WORKFLOW_PUBLISH_RESOURCE_TYPE, } from "./types.js";
|
|
18
19
|
const TRIGGER_KINDS = {
|
|
19
20
|
elementum_record_created_trigger: "recordCreate",
|
|
@@ -981,7 +982,7 @@ function decodeTaskReferenceFromString(taskIdOrKey, pathSegments, ctx) {
|
|
|
981
982
|
const keyPath = pathSegments.map((segment) => WIRE_REF_SEGMENT_TO_TS[segment] ?? segment);
|
|
982
983
|
const taskKind = block?.type !== undefined ? TASK_FACTORIES[block.type] : undefined;
|
|
983
984
|
const wireOutputKey = taskKind !== undefined ? OUTPUT_KEY_WIRE_NAME[taskKind] : undefined;
|
|
984
|
-
const outputKeyPath = wireOutputKey !== undefined && keyPath[0]
|
|
985
|
+
const outputKeyPath = wireOutputKey !== undefined && keyPath[0] !== undefined && matchesOutputWireKey(keyPath[0], wireOutputKey)
|
|
985
986
|
? ["output", ...keyPath.slice(1)]
|
|
986
987
|
: keyPath;
|
|
987
988
|
return { kind: "taskRef", task: refKey, path: outputKeyPath };
|
|
@@ -1367,7 +1368,7 @@ function decodeValue(value, ctx) {
|
|
|
1367
1368
|
// the generic `output` accessor its EDK factory actually exposes.
|
|
1368
1369
|
const taskKind = task.block.type !== undefined ? TASK_FACTORIES[task.block.type] : undefined;
|
|
1369
1370
|
const wireOutputKey = taskKind !== undefined ? OUTPUT_KEY_WIRE_NAME[taskKind] : undefined;
|
|
1370
|
-
const outputKeyPath = wireOutputKey !== undefined && keyPath[0]
|
|
1371
|
+
const outputKeyPath = wireOutputKey !== undefined && keyPath[0] !== undefined && matchesOutputWireKey(keyPath[0], wireOutputKey)
|
|
1371
1372
|
? ["output", ...keyPath.slice(1)]
|
|
1372
1373
|
: keyPath;
|
|
1373
1374
|
return { kind: "taskRef", task: task.refKey, path: outputKeyPath };
|
|
@@ -1829,14 +1830,26 @@ function decodeCalculationFormula(value, ctx) {
|
|
|
1829
1830
|
const parts = [];
|
|
1830
1831
|
let cursor = 0;
|
|
1831
1832
|
const pattern = /\{\{(trigger|task)\s+([^}]*)\}\}|variable\.([a-f0-9-]{36})/g;
|
|
1832
|
-
|
|
1833
|
-
|
|
1833
|
+
while (cursor < value.length) {
|
|
1834
|
+
pattern.lastIndex = cursor;
|
|
1835
|
+
const match = pattern.exec(value);
|
|
1836
|
+
const jsonRef = nextCalculationJsonReference(value, cursor, ctx);
|
|
1837
|
+
const matchIndex = match?.index ?? Number.POSITIVE_INFINITY;
|
|
1838
|
+
const jsonIndex = jsonRef?.start ?? Number.POSITIVE_INFINITY;
|
|
1839
|
+
if (match === null && jsonRef === undefined)
|
|
1840
|
+
break;
|
|
1841
|
+
const index = Math.min(matchIndex, jsonIndex);
|
|
1834
1842
|
if (index > cursor)
|
|
1835
1843
|
parts.push(value.slice(cursor, index));
|
|
1844
|
+
if (jsonIndex < matchIndex) {
|
|
1845
|
+
parts.push(jsonRef.reference);
|
|
1846
|
+
cursor = jsonRef.end;
|
|
1847
|
+
continue;
|
|
1848
|
+
}
|
|
1836
1849
|
if (match[3] !== undefined) {
|
|
1837
1850
|
const resolved = resolveVariableReference(match[3], match[3], undefined, ctx);
|
|
1838
|
-
parts.push(resolved ?? { kind: "unresolved", uuid: `variable.${match[3]}`, hint: "
|
|
1839
|
-
cursor =
|
|
1851
|
+
parts.push(resolved ?? { kind: "unresolved", uuid: `variable.${match[3]}`, hint: "calculation-reference" });
|
|
1852
|
+
cursor = pattern.lastIndex;
|
|
1840
1853
|
continue;
|
|
1841
1854
|
}
|
|
1842
1855
|
const kind = match[1];
|
|
@@ -1851,7 +1864,7 @@ function decodeCalculationFormula(value, ctx) {
|
|
|
1851
1864
|
const id = /id="([^"]*)"/.exec(attrs)?.[1];
|
|
1852
1865
|
parts.push(decodeCalculationTaskMustache(id, name, ctx));
|
|
1853
1866
|
}
|
|
1854
|
-
cursor =
|
|
1867
|
+
cursor = pattern.lastIndex;
|
|
1855
1868
|
}
|
|
1856
1869
|
if (parts.length === 0)
|
|
1857
1870
|
return { kind: "literal", value };
|
|
@@ -1861,6 +1874,57 @@ function decodeCalculationFormula(value, ctx) {
|
|
|
1861
1874
|
return parts[0];
|
|
1862
1875
|
return { kind: "template", parts };
|
|
1863
1876
|
}
|
|
1877
|
+
/** Resolve serialized platform ValueReference envelopes embedded in formula text. */
|
|
1878
|
+
function nextCalculationJsonReference(value, fromIndex, ctx) {
|
|
1879
|
+
for (let start = value.indexOf("{", fromIndex); start >= 0; start = value.indexOf("{", start + 1)) {
|
|
1880
|
+
let depth = 0;
|
|
1881
|
+
let inString = false;
|
|
1882
|
+
let escaped = false;
|
|
1883
|
+
let end = start;
|
|
1884
|
+
for (; end < value.length; end += 1) {
|
|
1885
|
+
const char = value[end];
|
|
1886
|
+
if (inString) {
|
|
1887
|
+
if (escaped)
|
|
1888
|
+
escaped = false;
|
|
1889
|
+
else if (char === "\\")
|
|
1890
|
+
escaped = true;
|
|
1891
|
+
else if (char === '"')
|
|
1892
|
+
inString = false;
|
|
1893
|
+
continue;
|
|
1894
|
+
}
|
|
1895
|
+
if (char === '"')
|
|
1896
|
+
inString = true;
|
|
1897
|
+
else if (char === "{")
|
|
1898
|
+
depth += 1;
|
|
1899
|
+
else if (char === "}") {
|
|
1900
|
+
depth -= 1;
|
|
1901
|
+
if (depth === 0) {
|
|
1902
|
+
end += 1;
|
|
1903
|
+
break;
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
if (depth !== 0)
|
|
1908
|
+
continue;
|
|
1909
|
+
let parsed;
|
|
1910
|
+
try {
|
|
1911
|
+
parsed = JSON.parse(value.slice(start, end));
|
|
1912
|
+
}
|
|
1913
|
+
catch {
|
|
1914
|
+
continue;
|
|
1915
|
+
}
|
|
1916
|
+
if (!isObject(parsed))
|
|
1917
|
+
continue;
|
|
1918
|
+
// Calculation formulas also serialize variable/task refs as JSON. Reuse
|
|
1919
|
+
// the same decoder as workflow values so synthetic names such as
|
|
1920
|
+
// `variable|<uuid>` are resolved from the task graph rather than copied
|
|
1921
|
+
// into the generated TypeScript source.
|
|
1922
|
+
const reference = decodeFilterReferenceEnvelope(parsed, ctx);
|
|
1923
|
+
if (reference !== undefined)
|
|
1924
|
+
return { start, end, reference };
|
|
1925
|
+
}
|
|
1926
|
+
return undefined;
|
|
1927
|
+
}
|
|
1864
1928
|
function decodeCalculationTaskMustache(taskId, wireName, ctx) {
|
|
1865
1929
|
if (taskId === undefined || wireName === undefined) {
|
|
1866
1930
|
return { kind: "unresolved", uuid: `task:${taskId ?? "?"}:${wireName ?? "?"}`, hint: "calculation-reference" };
|
|
@@ -1926,6 +1990,15 @@ function decodeCalculationTaskMustache(taskId, wireName, ctx) {
|
|
|
1926
1990
|
const keyPath = wireName.split(".");
|
|
1927
1991
|
const taskKind = taskBlock?.type !== undefined ? TASK_FACTORIES[taskBlock.type] : undefined;
|
|
1928
1992
|
const wireOutputKey = taskKind !== undefined ? OUTPUT_KEY_WIRE_NAME[taskKind] : undefined;
|
|
1993
|
+
// Case-SENSITIVE here, unlike the refs-map/envelope call sites: a
|
|
1994
|
+
// calculation mustache carries the calc-engine's own lowercase name
|
|
1995
|
+
// (WorkflowTaskReference, e.g. "response"), never the refs-map display
|
|
1996
|
+
// key ("Response") - calculationTaskMustache already documents that the
|
|
1997
|
+
// display label does not resolve in this dialect. Case-folding this site
|
|
1998
|
+
// too made "response" fold to "output" (correct) but ALSO folded any
|
|
1999
|
+
// other lowercase wire name that happens to match a wireOutputKey
|
|
2000
|
+
// case-insensitively, rewriting the mustache as {{task name="Response"}}
|
|
2001
|
+
// on the next build - a key the calc engine's real API never has either.
|
|
1929
2002
|
const outputKeyPath = wireOutputKey !== undefined && keyPath[0] === wireOutputKey
|
|
1930
2003
|
? ["output", ...keyPath.slice(1)]
|
|
1931
2004
|
: keyPath.map((segment) => WIRE_REF_SEGMENT_TO_TS[segment] ?? segment);
|
|
@@ -2009,7 +2082,7 @@ function resolveVariableReference(rawId, rawName, outputName, ctx) {
|
|
|
2009
2082
|
}
|
|
2010
2083
|
return undefined;
|
|
2011
2084
|
}
|
|
2012
|
-
function decodeFilterReferenceEnvelope(value, ctx, outputName) {
|
|
2085
|
+
function decodeFilterReferenceEnvelope(value, ctx, outputName, role) {
|
|
2013
2086
|
let raw = isTfExpr(value) && value.$expr === "jsonencode" ? value.value : value;
|
|
2014
2087
|
while (isObject(raw) && "value" in raw && Object.keys(raw).length === 1) {
|
|
2015
2088
|
raw = raw.value;
|
|
@@ -2020,7 +2093,24 @@ function decodeFilterReferenceEnvelope(value, ctx, outputName) {
|
|
|
2020
2093
|
if (isObject(taskRef) && typeof taskRef.name === "string") {
|
|
2021
2094
|
const taskIdOrKey = workflowOutputTaskIdOrKey(taskRef.taskId, ctx);
|
|
2022
2095
|
if (taskIdOrKey !== undefined) {
|
|
2023
|
-
|
|
2096
|
+
const decoded = decodeTaskReferenceFromString(taskIdOrKey, taskRef.name.split("."), ctx);
|
|
2097
|
+
const task = resolveTaskRefKey(taskIdOrKey, ctx).block;
|
|
2098
|
+
if (decoded.kind === "taskRef" && task?.type === "elementum_execute_script_task") {
|
|
2099
|
+
const schemaValue = task.attrs.output_schema;
|
|
2100
|
+
const schema = isTfExpr(schemaValue) && schemaValue.$expr === "jsonencode"
|
|
2101
|
+
? schemaValue.value
|
|
2102
|
+
: schemaValue;
|
|
2103
|
+
const outputTypes = outputFieldTypesFromScriptSchema(schema);
|
|
2104
|
+
const declared = scriptOutputReferenceIsDeclared(outputTypes, taskRef.name);
|
|
2105
|
+
if (role === "left" && !declared && taskRef.name.startsWith("result.")) {
|
|
2106
|
+
if (raw.multiple === true || raw.fieldType === "DECIMAL") {
|
|
2107
|
+
throw new EntityTfError(`execute-script reference "${taskRef.name}" is absent from its output schema and its ` +
|
|
2108
|
+
`${raw.multiple === true ? "multiple" : "DECIMAL"} envelope cannot round-trip losslessly`);
|
|
2109
|
+
}
|
|
2110
|
+
return { ...decoded, undeclaredScriptOutput: true };
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2113
|
+
return decoded;
|
|
2024
2114
|
}
|
|
2025
2115
|
}
|
|
2026
2116
|
const triggerRef = raw.triggerReference;
|
|
@@ -2066,10 +2156,10 @@ function workflowOutputTaskIdOrKey(taskId, ctx) {
|
|
|
2066
2156
|
}
|
|
2067
2157
|
return undefined;
|
|
2068
2158
|
}
|
|
2069
|
-
function filterReference(value, ctx) {
|
|
2159
|
+
function filterReference(value, ctx, role) {
|
|
2070
2160
|
return typeof value === "string"
|
|
2071
2161
|
? decodeReferenceString(value, ctx) ?? { kind: "unresolved", uuid: value, hint: "filter-reference" }
|
|
2072
|
-
: decodeFilterReferenceEnvelope(value, ctx)
|
|
2162
|
+
: decodeFilterReferenceEnvelope(value, ctx, undefined, role)
|
|
2073
2163
|
?? decodeTemplateTriggerRecordFieldRef(value, ctx)
|
|
2074
2164
|
?? decodeTemplateTaskRef(value, ctx)
|
|
2075
2165
|
?? decodeTemplateForEachRef(value, ctx)
|
|
@@ -2095,13 +2185,54 @@ function filterReferenceType(value, fallback, ctx) {
|
|
|
2095
2185
|
}
|
|
2096
2186
|
return typeof raw.fieldType === "string" ? fieldTypeToValueType(raw.fieldType) : fallback;
|
|
2097
2187
|
}
|
|
2188
|
+
export function inferredPublishOutputType(value, ctx) {
|
|
2189
|
+
const raw = isTfExpr(value) && value.$expr === "jsonencode" ? value.value : value;
|
|
2190
|
+
if (!isObject(raw) || !isObject(raw.taskReference) || typeof raw.taskReference.name !== "string") {
|
|
2191
|
+
return { fieldType: "TEXT", multiple: false };
|
|
2192
|
+
}
|
|
2193
|
+
const taskIdOrKey = workflowOutputTaskIdOrKey(raw.taskReference.taskId, ctx);
|
|
2194
|
+
const task = taskIdOrKey === undefined ? undefined : resolveTaskRefKey(taskIdOrKey, ctx).block;
|
|
2195
|
+
if (task?.type === "elementum_execute_script_task") {
|
|
2196
|
+
const schemaValue = task.attrs.output_schema;
|
|
2197
|
+
const schema = isTfExpr(schemaValue) && schemaValue.$expr === "jsonencode"
|
|
2198
|
+
? schemaValue.value
|
|
2199
|
+
: schemaValue;
|
|
2200
|
+
const fromSchema = outputFieldTypesFromScriptSchema(schema)?.get(raw.taskReference.name);
|
|
2201
|
+
if (fromSchema !== undefined)
|
|
2202
|
+
return fromSchema;
|
|
2203
|
+
}
|
|
2204
|
+
if (task?.type === "elementum_ai_agent_task" &&
|
|
2205
|
+
typeof task.attrs.output_type === "string" &&
|
|
2206
|
+
task.attrs.output_type.toLowerCase() === "json" &&
|
|
2207
|
+
Array.isArray(task.attrs.json_fields)) {
|
|
2208
|
+
const name = raw.taskReference.name.replace(/^ai_agent_task_structured_output\./, "");
|
|
2209
|
+
const field = task.attrs.json_fields.find((candidate) => isObject(candidate) && candidate.name === name && typeof candidate.type === "string");
|
|
2210
|
+
if (isObject(field) && typeof field.type === "string") {
|
|
2211
|
+
return { fieldType: field.type.toUpperCase(), multiple: false };
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
if ((task?.type === "elementum_create_record_task" || task?.type === "elementum_find_related_records_task") &&
|
|
2215
|
+
(raw.taskReference.name === "Record" || raw.taskReference.name === "Record ID")) {
|
|
2216
|
+
return { fieldType: "ASPECT_RECORD_ID", multiple: false };
|
|
2217
|
+
}
|
|
2218
|
+
if ((task?.type === "elementum_record_search_task" || task?.type === "elementum_find_related_records_task") &&
|
|
2219
|
+
(raw.taskReference.name === "All found records" || raw.taskReference.name === "records")) {
|
|
2220
|
+
return { fieldType: "ASPECT_RECORD_ID", multiple: true };
|
|
2221
|
+
}
|
|
2222
|
+
if ((task?.type === "elementum_ai_search_table_task" || task?.type === "elementum_table_records_search_task") &&
|
|
2223
|
+
(raw.taskReference.name === "All Records" || raw.taskReference.name === "records" ||
|
|
2224
|
+
raw.taskReference.name === "All matching table rows")) {
|
|
2225
|
+
return { fieldType: "TABLE_RECORD", multiple: true };
|
|
2226
|
+
}
|
|
2227
|
+
return { fieldType: "TEXT", multiple: false };
|
|
2228
|
+
}
|
|
2098
2229
|
function decodeFilter(value, ctx, fieldScope = "app") {
|
|
2099
2230
|
return deserializeFilterFromTf(value, {
|
|
2100
2231
|
field: (fieldValue, scope) => {
|
|
2101
2232
|
const field = scope === "user" ? userFieldRef(fieldValue, ctx) : filterFieldRef(fieldValue, ctx);
|
|
2102
2233
|
return field ?? { kind: "unresolved", uuid: String(fieldValue), hint: "field" };
|
|
2103
2234
|
},
|
|
2104
|
-
reference: (reference) => filterReference(reference, ctx),
|
|
2235
|
+
reference: (reference, role) => filterReference(reference, ctx, role),
|
|
2105
2236
|
referenceType: (reference, fallback) => filterReferenceType(reference, fallback, ctx),
|
|
2106
2237
|
literal: (literal) => picklistOptionLabel(literal) ?? stageFilterName(literal, ctx) ?? literal,
|
|
2107
2238
|
}, fieldScope);
|
|
@@ -2241,7 +2372,7 @@ function triggerFromBlock(block, ctx) {
|
|
|
2241
2372
|
default: throw new EntityTfError(`trigger "${kind}" is outside the Terraform contract`);
|
|
2242
2373
|
}
|
|
2243
2374
|
}
|
|
2244
|
-
function taskArgs(block, factory, ctx) {
|
|
2375
|
+
function taskArgs(block, factory, ctx, fieldMappingDiagnostics) {
|
|
2245
2376
|
const args = {};
|
|
2246
2377
|
for (const [attr, value] of Object.entries(block.attrs)) {
|
|
2247
2378
|
if (attr === "parent" || attr === "name" || attr === "depends_on")
|
|
@@ -2295,7 +2426,40 @@ function taskArgs(block, factory, ctx) {
|
|
|
2295
2426
|
args.inputs = Object.fromEntries(value.map((item) => {
|
|
2296
2427
|
if (!isObject(item) || typeof item.name !== "string")
|
|
2297
2428
|
throw new EntityTfError("invalid script input");
|
|
2298
|
-
|
|
2429
|
+
const decodedValue = decodeValue(item.value, ctx);
|
|
2430
|
+
const rawMappings = item.field_mappings;
|
|
2431
|
+
// A list-valued input's field_mappings - which fields of each list
|
|
2432
|
+
// item the script can read, and under what alias. Kept as a tagged
|
|
2433
|
+
// wrapper the printer turns into withFieldMappings(...); to-tf.ts's
|
|
2434
|
+
// own withFieldMappings() re-derives the exact same wire shape on
|
|
2435
|
+
// rebuild.
|
|
2436
|
+
if (Array.isArray(rawMappings) && rawMappings.length > 0) {
|
|
2437
|
+
const fields = [];
|
|
2438
|
+
for (const mapping of rawMappings) {
|
|
2439
|
+
if (!isObject(mapping) || typeof mapping.alias !== "string") {
|
|
2440
|
+
throw new EntityTfError("invalid script input field_mappings entry");
|
|
2441
|
+
}
|
|
2442
|
+
// ei's exporter (generateScriptInputsIR) keeps the alias but omits
|
|
2443
|
+
// field_id when the mapping's field id is empty on the platform -
|
|
2444
|
+
// drop just this one mapping with a diagnostic instead of
|
|
2445
|
+
// throwing out of taskArgs, which would drop the WHOLE automation
|
|
2446
|
+
// (a live-caught regression in an earlier attempt at this fix).
|
|
2447
|
+
if (mapping.field_id === undefined) {
|
|
2448
|
+
fieldMappingDiagnostics.push(`execute-script input "${item.name}" field_mappings entry ${JSON.stringify(mapping.alias)}: no field_id on the platform; dropped`);
|
|
2449
|
+
continue;
|
|
2450
|
+
}
|
|
2451
|
+
// A PRESENT but unreconstructable field_id (fieldRef throws) is
|
|
2452
|
+
// different: the export genuinely carried a binding EDK failed to
|
|
2453
|
+
// decode. Fail closed (propagate) rather than silently stripping
|
|
2454
|
+
// a real reference - matches fieldRef's own fail-closed contract
|
|
2455
|
+
// used elsewhere in this file.
|
|
2456
|
+
fields.push({ alias: mapping.alias, field: fieldRef(mapping.field_id, ctx) });
|
|
2457
|
+
}
|
|
2458
|
+
if (fields.length > 0) {
|
|
2459
|
+
return [item.name, { __edkExecuteScriptListInput: true, value: decodedValue, fields }];
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2462
|
+
return [item.name, decodedValue];
|
|
2299
2463
|
}));
|
|
2300
2464
|
continue;
|
|
2301
2465
|
}
|
|
@@ -2310,7 +2474,15 @@ function taskArgs(block, factory, ctx) {
|
|
|
2310
2474
|
if (type === undefined || !isObject(definition))
|
|
2311
2475
|
throw new EntityTfError("invalid script output property");
|
|
2312
2476
|
if (type === "array") {
|
|
2313
|
-
|
|
2477
|
+
const itemDefinition = isObject(definition.item) ? Object.values(definition.item)[0] : undefined;
|
|
2478
|
+
const itemName = isObject(itemDefinition) && typeof itemDefinition.name === "string"
|
|
2479
|
+
? itemDefinition.name
|
|
2480
|
+
: undefined;
|
|
2481
|
+
return {
|
|
2482
|
+
type: "array",
|
|
2483
|
+
items: decodeNode(definition.item),
|
|
2484
|
+
...(itemName !== undefined ? { itemName } : {}),
|
|
2485
|
+
};
|
|
2314
2486
|
}
|
|
2315
2487
|
if (type === "object" && Array.isArray(definition.properties)) {
|
|
2316
2488
|
const properties = Object.fromEntries(definition.properties.map((child) => {
|
|
@@ -2414,13 +2586,9 @@ function taskArgs(block, factory, ctx) {
|
|
|
2414
2586
|
: item.include_type === "PICKLIST" && item.picklist_field_id !== undefined
|
|
2415
2587
|
? { picklist: fieldRef(item.picklist_field_id, ctx) ?? decodeValue(item.picklist_field_id, ctx) }
|
|
2416
2588
|
: undefined;
|
|
2417
|
-
|
|
2418
|
-
throw new EntityTfError(`${block.type}.${block.label}: calculation entry id must be a string`);
|
|
2419
|
-
}
|
|
2420
|
-
const advanced = item.id !== undefined || item.record_id !== undefined || include !== undefined;
|
|
2589
|
+
const advanced = item.record_id !== undefined || include !== undefined;
|
|
2421
2590
|
return [item.variable_name, advanced ? {
|
|
2422
2591
|
expression,
|
|
2423
|
-
...(typeof item.id === "string" ? { id: item.id } : {}),
|
|
2424
2592
|
...(item.record_id !== undefined ? { record: decodeValue(item.record_id, ctx) } : {}),
|
|
2425
2593
|
...(include !== undefined ? { include } : {}),
|
|
2426
2594
|
} : expression];
|
|
@@ -2535,6 +2703,21 @@ function taskArgs(block, factory, ctx) {
|
|
|
2535
2703
|
args.outputType = typeof value === "string" ? value.toLowerCase() : decodeValue(value, ctx);
|
|
2536
2704
|
continue;
|
|
2537
2705
|
}
|
|
2706
|
+
if (attr === "attachments" && factory === "aiAgent") {
|
|
2707
|
+
if (!Array.isArray(value))
|
|
2708
|
+
throw new EntityTfError(`${block.type}.${block.label}: attachments must be an array`);
|
|
2709
|
+
args.attachments = value.map((item) => {
|
|
2710
|
+
if (!isObject(item))
|
|
2711
|
+
throw new EntityTfError(`${block.type}.${block.label}: invalid AI agent attachment`);
|
|
2712
|
+
const present = ["file", "attachment", "record"].filter((key) => item[key] !== undefined);
|
|
2713
|
+
if (present.length !== 1) {
|
|
2714
|
+
throw new EntityTfError(`${block.type}.${block.label}: AI agent attachment must set exactly one of file, attachment, or record`);
|
|
2715
|
+
}
|
|
2716
|
+
const key = present[0];
|
|
2717
|
+
return { [key]: decodeValue(item[key], ctx) };
|
|
2718
|
+
});
|
|
2719
|
+
continue;
|
|
2720
|
+
}
|
|
2538
2721
|
if (attr === "json_fields" && factory === "aiAgent") {
|
|
2539
2722
|
const outputType = block.attrs.output_type;
|
|
2540
2723
|
if (typeof outputType !== "string" || outputType.toLowerCase() !== "json")
|
|
@@ -2829,10 +3012,12 @@ function taskRefKey(block, automationLabel, appTfLabel) {
|
|
|
2829
3012
|
* shows those addresses as destroy-on-apply (confirmed live: several
|
|
2830
3013
|
* automations that failed extraction were imported into state anyway,
|
|
2831
3014
|
* driving spurious destroys). Deliberately lenient - tolerant of the exact
|
|
2832
|
-
* conditions that make real extraction fail (zero
|
|
2833
|
-
* unrecognized task kind)
|
|
2834
|
-
*
|
|
2835
|
-
*
|
|
3015
|
+
* conditions that make real extraction fail (zero triggers, an
|
|
3016
|
+
* unrecognized task kind) so it over-collects rather than under-collects.
|
|
3017
|
+
* More than one trigger is not one of those cases: it throws
|
|
3018
|
+
* {@link UnsupportedMultiTriggerError} and stops the pull. A false positive
|
|
3019
|
+
* here just leaves one more resource unmanaged; a false negative would
|
|
3020
|
+
* silently destroy a live automation on apply.
|
|
2836
3021
|
*/
|
|
2837
3022
|
export function automationOwnedAddresses(doc, automationLabel) {
|
|
2838
3023
|
const owned = new Set([`${AUTOMATION_RESOURCE_TYPE}.${automationLabel}`]);
|
|
@@ -2908,16 +3093,40 @@ function unresolvedAuthoringValues(doc) {
|
|
|
2908
3093
|
}
|
|
2909
3094
|
return values;
|
|
2910
3095
|
}
|
|
3096
|
+
/**
|
|
3097
|
+
* Pull stops on this. EDK does not author multi-trigger automations; apps
|
|
3098
|
+
* should keep one trigger and call the shared logic with a run-automation
|
|
3099
|
+
* action. Callers that otherwise turn extract failures into skips must
|
|
3100
|
+
* rethrow it.
|
|
3101
|
+
*/
|
|
3102
|
+
export class UnsupportedMultiTriggerError extends EntityTfError {
|
|
3103
|
+
automationName;
|
|
3104
|
+
triggerCount;
|
|
3105
|
+
constructor(automationName, triggerCount) {
|
|
3106
|
+
super(`EDK does not support multi-trigger automations. Automation "${automationName}" has ${triggerCount} triggers. ` +
|
|
3107
|
+
"Change the automation to a single trigger and use a run-automation action to invoke the shared logic from other entry points.");
|
|
3108
|
+
this.name = "UnsupportedMultiTriggerError";
|
|
3109
|
+
this.automationName = automationName;
|
|
3110
|
+
this.triggerCount = triggerCount;
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
2911
3113
|
/** Extract one app-owned automation graph from an ei app export. */
|
|
2912
3114
|
function automationFromTfDocument(doc, automationLabel, appRefName, foreignFieldRefsById, foreignFieldRefsByDataAddress, foreignTableRefsById, picklistOptionLabelById, fieldNamesByOwnerRefName, foreignAppRefNames, foreignElementRefNames, procedureKeysByDiscriminator, foreignTaskRefNames) {
|
|
2913
3115
|
const automation = doc.blocks.find((block) => block.kind === "resource" && block.type === AUTOMATION_RESOURCE_TYPE && block.label === automationLabel);
|
|
2914
3116
|
if (automation === undefined)
|
|
2915
3117
|
throw new EntityTfError(`automation resource "${automationLabel}" not found`);
|
|
3118
|
+
const triggers = doc.blocks.filter((block) => block.kind === "resource" && AUTOMATION_TRIGGER_TYPE_SET.has(block.type ?? "") && references(block.attrs.automation, AUTOMATION_RESOURCE_TYPE, automationLabel));
|
|
3119
|
+
// N > 1 is a product non-support, not a skippable extract gap. Fail before
|
|
3120
|
+
// later structural checks (owner reference, unknown children, missing
|
|
3121
|
+
// trigger) so a multi-trigger automation cannot be swallowed as a diagnostic.
|
|
3122
|
+
if (triggers.length > 1) {
|
|
3123
|
+
const name = typeof automation.attrs.name === "string" && automation.attrs.name !== "" ? automation.attrs.name : automationLabel;
|
|
3124
|
+
throw new UnsupportedMultiTriggerError(name, triggers.length);
|
|
3125
|
+
}
|
|
2916
3126
|
assertAllowed(automation, new Set(["app_id", "name", "description", "status", "triggers_other_automations", "service_account_id", "depends_on"]));
|
|
2917
3127
|
const app = resourceRef(automation.attrs.app_id);
|
|
2918
3128
|
if (app === undefined || app.type !== "elementum_app" || app.path[0] !== "id")
|
|
2919
3129
|
throw new EntityTfError(`${AUTOMATION_RESOURCE_TYPE}.${automationLabel}: app_id is not an app reference`);
|
|
2920
|
-
const triggers = doc.blocks.filter((block) => block.kind === "resource" && AUTOMATION_TRIGGER_TYPE_SET.has(block.type ?? "") && references(block.attrs.automation, AUTOMATION_RESOURCE_TYPE, automationLabel));
|
|
2921
3130
|
const publish = doc.blocks.find((block) => block.kind === "resource" && block.type === WORKFLOW_PUBLISH_RESOURCE_TYPE && references(block.attrs.automation, AUTOMATION_RESOURCE_TYPE, automationLabel));
|
|
2922
3131
|
const unknownDirectChild = doc.blocks.find((block) => block.kind === "resource" &&
|
|
2923
3132
|
references(block.attrs.automation, AUTOMATION_RESOURCE_TYPE, automationLabel) &&
|
|
@@ -3128,6 +3337,7 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
3128
3337
|
dependencyOrder.set(`${ref.type}.${ref.label}`, index); });
|
|
3129
3338
|
const triggerAddress = `${trigger.type}.${trigger.label}`;
|
|
3130
3339
|
const unrebuildableTasks = [];
|
|
3340
|
+
const fieldMappingDiagnostics = [];
|
|
3131
3341
|
// edk#821: resolve each elementum_unmanaged_task_reference this automation's
|
|
3132
3342
|
// OWN tasks actually parent onto (never the whole doc's data blocks - a
|
|
3133
3343
|
// sibling automation sharing this export can have its own, edk#785) to its
|
|
@@ -3231,7 +3441,7 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
3231
3441
|
id: typeof block.attrs.id === "string" ? block.attrs.id : "",
|
|
3232
3442
|
taskType: typeof block.attrs.task_type === "string" ? block.attrs.task_type : "",
|
|
3233
3443
|
}
|
|
3234
|
-
: taskArgs(block, factory, ctx);
|
|
3444
|
+
: taskArgs(block, factory, ctx, fieldMappingDiagnostics);
|
|
3235
3445
|
const call = { factory, refKey, args, ...(children ? { children } : {}), ...(typeof block.attrs.name === "string" && block.attrs.name !== refKey ? { displayName: block.attrs.name } : {}), ...(hclParent !== undefined ? { hclParent } : {}) };
|
|
3236
3446
|
visiting.delete(address);
|
|
3237
3447
|
return [call, ...buildTasks(address)];
|
|
@@ -3240,6 +3450,7 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
3240
3450
|
if (visited.size !== tasks.length + unmanagedTaskPositions.size)
|
|
3241
3451
|
throw new EntityTfError(`automation "${automationLabel}" contains an orphaned task graph`);
|
|
3242
3452
|
const outputBlocks = publish?.attrs.outputs;
|
|
3453
|
+
const outputDiagnostics = [];
|
|
3243
3454
|
const outputs = Array.isArray(outputBlocks) ? outputBlocks.map((output) => {
|
|
3244
3455
|
if (!isObject(output) || typeof output.name !== "string" || output.value === undefined)
|
|
3245
3456
|
throw new EntityTfError("invalid workflow output");
|
|
@@ -3247,7 +3458,32 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
3247
3458
|
// collapse that envelope to a RefExpr the same way filter references do.
|
|
3248
3459
|
const value = decodeFilterReferenceEnvelope(output.value, ctx, output.name)
|
|
3249
3460
|
?? decodeValue(output.value, ctx);
|
|
3250
|
-
|
|
3461
|
+
const raw = isTfExpr(output.value) && output.value.$expr === "jsonencode"
|
|
3462
|
+
? output.value.value
|
|
3463
|
+
: output.value;
|
|
3464
|
+
const fieldType = isObject(raw) && typeof raw.fieldType === "string" ? raw.fieldType : undefined;
|
|
3465
|
+
const multiple = isObject(raw) && typeof raw.multiple === "boolean" ? raw.multiple : undefined;
|
|
3466
|
+
if (fieldType === undefined || multiple === undefined)
|
|
3467
|
+
return { name: output.name, value };
|
|
3468
|
+
const inferred = inferredPublishOutputType(output.value, ctx);
|
|
3469
|
+
if (inferred.fieldType === fieldType && inferred.multiple === multiple) {
|
|
3470
|
+
return { name: output.name, value };
|
|
3471
|
+
}
|
|
3472
|
+
const explicitType = workflowOutputTypeFromFieldType(fieldType);
|
|
3473
|
+
if (explicitType === undefined) {
|
|
3474
|
+
outputDiagnostics.push(`automation "${automationLabel}" workflow output "${output.name}" has explicit field type ` +
|
|
3475
|
+
`${JSON.stringify(fieldType)}, which the public workflowOutput API cannot represent; ` +
|
|
3476
|
+
`type metadata will be dropped while preserving the bare reference`);
|
|
3477
|
+
return { name: output.name, value };
|
|
3478
|
+
}
|
|
3479
|
+
if (!isObject(value) ||
|
|
3480
|
+
(value.kind !== "taskRef" && value.kind !== "triggerRef")) {
|
|
3481
|
+
outputDiagnostics.push(`automation "${automationLabel}" workflow output "${output.name}" has explicit ${fieldType}/` +
|
|
3482
|
+
`${multiple ? "multiple" : "single"} metadata on a reference kind workflowOutput cannot represent; ` +
|
|
3483
|
+
`type metadata will be dropped while preserving the bare reference`);
|
|
3484
|
+
return { name: output.name, value };
|
|
3485
|
+
}
|
|
3486
|
+
return { name: output.name, value, explicitType, explicitMultiple: multiple };
|
|
3251
3487
|
}) : undefined;
|
|
3252
3488
|
const exportedRevision = publish?.attrs.workflow_revision;
|
|
3253
3489
|
if (exportedRevision !== undefined && typeof exportedRevision !== "string") {
|
|
@@ -3271,10 +3507,12 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
3271
3507
|
ast,
|
|
3272
3508
|
blocks: [automation, trigger, ...tasks, ...ownedBranches, ...(publish ? [publish] : [])],
|
|
3273
3509
|
adoptionAddressAliases,
|
|
3274
|
-
...((unrebuildableTasks.length > 0 || placeholderTasks.length > 0) && {
|
|
3510
|
+
...((unrebuildableTasks.length > 0 || placeholderTasks.length > 0 || outputDiagnostics.length > 0 || fieldMappingDiagnostics.length > 0) && {
|
|
3275
3511
|
diagnostics: [
|
|
3276
3512
|
...unrebuildableTasks.map((address) => `automation "${automationLabel}": ${address}'s real parent is a task type EDK doesn't support yet, so its authored position couldn't be reconstructed (anchored to the trigger instead) - not rebuildable from this source until that task type is supported`),
|
|
3277
3513
|
...placeholderTasks.map(({ name, taskType }) => `automation "${automationLabel}" uses platform task type "${taskType}" ("${name}"), which EDK doesn't implement - kept as an unimplementedTask(...) placeholder; its configuration isn't authorable, but its position and downstream chain are round-trip-safe`),
|
|
3514
|
+
...outputDiagnostics,
|
|
3515
|
+
...fieldMappingDiagnostics.map((message) => `automation "${automationLabel}": ${message}`),
|
|
3278
3516
|
],
|
|
3279
3517
|
}),
|
|
3280
3518
|
};
|
|
@@ -3293,6 +3531,8 @@ export function automationFromTf(first, second, third, fourth, fifth, sixth, sev
|
|
|
3293
3531
|
return { automation: result.ast };
|
|
3294
3532
|
}
|
|
3295
3533
|
catch (err) {
|
|
3534
|
+
if (err instanceof UnsupportedMultiTriggerError)
|
|
3535
|
+
throw err;
|
|
3296
3536
|
const message = err instanceof Error ? err.message : String(err);
|
|
3297
3537
|
ctx.diagnostics.push(message);
|
|
3298
3538
|
return { skippedReason: message };
|
|
@@ -17,5 +17,6 @@ export { AUTOMATION_RESOURCE_TYPES, AUTOMATION_TASK_TYPES, AUTOMATION_TRIGGER_TY
|
|
|
17
17
|
export * as filter from "../shared/filters/index.js";
|
|
18
18
|
export { automationStatus, chainableTrigger, actions, automation, type ActionBuilder, type ActionChain, type ActionDef, type ActionOptions, type ActionSequenceDef, type ActionsStarted, type AutomationConfigured, type AutomationOptions, type AutomationStatus, type ForkJoinBranch, type ForkJoinBranchBuilder, type ForkJoinConfig, type ForEachBuilder, type ForEachConfig, type NestedActionBuilder, type NestedActionChain, type NestedActionContext, type OperatorChild, type SwitchCase, type SwitchCaseBuilder, type SwitchConfig, type TriggerChain, type TriggerDef, type TriggerParamMeta } from "./build.js";
|
|
19
19
|
export { ScriptCodeError, scriptFile, type ScriptCodeFn, type ScriptFile, type ScriptInput } from "./script-code.js";
|
|
20
|
-
export {
|
|
20
|
+
export { workflowOutput, workflowOutputType, type WorkflowOutputDeclaration, type WorkflowOutputType, } from "./workflow-output.js";
|
|
21
|
+
export { addWatcher, aiAgent, aiClassify, aiEmailAnalysis, aiFileAnalysis, aiSearchTable, aiSummarize, aiTransform, apiRequest, approvalChain, approvalChainTemplate, approvalStatusUpdate, assignGroup, assignUser, assignmentEngine, bulkExcel, calculation, createRecord, executeScript, findRelatedRecords, generateReport, initiateCall, initiateEmailConversation, notification, postComment, postTeamsMessage, procedure, readFile, recordFieldLocking, recordSearch, relateRecords, runAutomation, saveAttachment, sendEmail, sendSurvey, setVariable, tableRecordsSearch, unzip, updateField, userGroupSearch, userSearch, withFieldMappings, type AddWatcherOptions, type AiAgentAttachment, type AiAgentOptions, type AiAgentOutput, type AiAgentOutputField, type AiAgentOutputFieldType, type AiClassifyCategorySource, type AiClassifyOptions, type AiClassifyStaticCategory, type AiEmailAnalysisOptions, type AiFileAnalysisOptions, type AiSearchTableOptions, type AiSearchTableOutput, type AiSummarizeOptions, type AiTransformOptions, type ApiRequestHeader, type ApiRequestOptions, type ApprovalChainOptions, type ApprovalChainTemplateOptions, type ApprovalStatusUpdateOptions, type ApprovalStatusUpdateStatus, type AssignGroupOptions, type AssignUserOptions, type AssignmentEngineOptions, type BulkExcelFieldMapping, type BulkExcelFieldSource, type BulkExcelOptions, type CalculationEntry, type CalculationExpression, type CalculationInclude, type CalculationOptions, type CalculationOutputs, type CalculationValueInput, type CalculationValueOptions, type CalculationValueOutputs, type CalculationValues, type CreateRecordOptions, type CreateRecordOutput, type EmailAttachment, type ExecuteScriptFieldMapping, type ExecuteScriptOptions, type FieldAssignment, type FindRelatedRecordsOptions, type FindRelatedRecordsOutput, type GenerateReportOptions, type InitiateCallOptions, type InitiateEmailConversationOptions, type InitiateEmailFirstEmail, type LegacyCalculationOptions, type MultiSelectUpdateMode, type NotificationOptions, type PostCommentOptions, type PostTeamsMessageOptions, type LegacyProcedureOptions, type ProcedureOptions, type TypedProcedureOptions, type ReadFileDataSource, type ReadFileOptions, type RecordFieldLockingOptions, type RecordId, type RecordReference, type RecordSearchOptions, type RecordSearchOutput, type RelateRecordsOptions, type RunAutomationInput, type RunAutomationOptions, type SaveAttachmentOptions, type ScriptOutputProperties, type ScriptOutputScalarType, type ScriptOutputType, type ScriptOutputs, type SendEmailOptions, type SendSurveyOptions, type SetVariableOptions, type TableRecordsSearchOptions, type TableRecordsSearchOutput, type UnzipOptions, type UpdateFieldAssignment, type UpdateFieldOptions, type UserSearchOptions, type VariableAssign, type VariableDecl } from "./tasks.js";
|
|
21
22
|
export { approvalProcessStatusUpdated, attachment, commentAdded, conversationEnd, dataMine, emailReceived, onDemand, recordCreated, recordUpdated, schedule, slackMessage, surveyResponseCreate, temporal, webHook, webhook, type AttachmentTriggerOptions, type AttachmentTriggerOutput, type CommentAddedTriggerOptions, type CommentAddedTriggerOutput, type ConversationEndConversationType, type ConversationEndTriggerOptions, type ConversationEndTriggerOutput, type DataMineTriggerOptions, type DataMineTriggerOutput, type EmailReceivedTriggerOptions, type EmailReceivedTriggerOutput, type RecordTriggerOptions, type RecordTriggerOutput, type ScheduleFrequency, type ScheduleTriggerOptions, type ScheduleTriggerOutput, type SlackMessageTriggerOutput, type SurveyResponseCreateTriggerOptions, type SurveyResponseCreateTriggerOutput, type TemporalTriggerOptions, type TemporalUnit, type WebhookTriggerOptions, type WebhookTriggerOutput, type Weekday, type approvalProcessStatusUpdatedStatus, type approvalProcessStatusUpdatedTriggerOptions } from "./triggers.js";
|
|
@@ -17,7 +17,8 @@ export { AUTOMATION_RESOURCE_TYPES, AUTOMATION_TASK_TYPES, AUTOMATION_TRIGGER_TY
|
|
|
17
17
|
export * as filter from "../shared/filters/index.js";
|
|
18
18
|
export { automationStatus, chainableTrigger, actions, automation } from "./build.js";
|
|
19
19
|
export { ScriptCodeError, scriptFile } from "./script-code.js";
|
|
20
|
-
export {
|
|
20
|
+
export { workflowOutput, workflowOutputType, } from "./workflow-output.js";
|
|
21
|
+
export { addWatcher, aiAgent, aiClassify, aiEmailAnalysis, aiFileAnalysis, aiSearchTable, aiSummarize, aiTransform, apiRequest, approvalChain, approvalChainTemplate, approvalStatusUpdate, assignGroup, assignUser, assignmentEngine, bulkExcel, calculation, createRecord, executeScript, findRelatedRecords, generateReport, initiateCall, initiateEmailConversation, notification, postComment, postTeamsMessage, procedure, readFile, recordFieldLocking, recordSearch, relateRecords, runAutomation, saveAttachment, sendEmail, sendSurvey, setVariable, tableRecordsSearch, unzip, updateField, userGroupSearch, userSearch, withFieldMappings } from "./tasks.js";
|
|
21
22
|
export { approvalProcessStatusUpdated, attachment, commentAdded, conversationEnd, dataMine, emailReceived, onDemand, recordCreated, recordUpdated, schedule, slackMessage, surveyResponseCreate, temporal, webHook, webhook } from "./triggers.js";
|
|
22
23
|
// Pull a deployed automation back as editable v2 source. `automation`
|
|
23
24
|
// is a plain factory returning a builder-chain object (not an Object.assign-able
|