@elementumai/edk 0.9.20 → 0.10.2
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 +19 -7
- package/dist-sdk/src/catalog/factories.d.ts +10 -2
- package/dist-sdk/src/catalog/factories.js +10 -1
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +1 -1
- package/dist-sdk/src/catalog/token.js +4 -0
- package/dist-sdk/src/catalog/types.d.ts +7 -1
- package/dist-sdk/src/catalog/types.js +1 -0
- package/dist-sdk/src/core/triggers/on-demand.d.ts +2 -2
- package/dist-sdk/src/core/triggers/on-demand.js +7 -0
- package/dist-sdk/src/core/types/app.d.ts +2 -2
- package/dist-sdk/src/engine/coverage-gaps.d.ts +86 -0
- package/dist-sdk/src/engine/coverage-gaps.js +156 -0
- package/dist-sdk/src/engine/ei/run.d.ts +21 -1
- package/dist-sdk/src/engine/ei/run.js +89 -2
- package/dist-sdk/src/engine/pull/catalog-ref.d.ts +16 -0
- package/dist-sdk/src/engine/pull/catalog-ref.js +24 -0
- package/dist-sdk/src/engine/pull/context.d.ts +68 -6
- package/dist-sdk/src/engine/pull/context.js +40 -1
- package/dist-sdk/src/engine/pull/procedure-refs.d.ts +8 -0
- package/dist-sdk/src/engine/pull/procedure-refs.js +28 -0
- package/dist-sdk/src/engine/pull/result-output.js +27 -1
- package/dist-sdk/src/engine/tf/index.d.ts +1 -1
- package/dist-sdk/src/engine/tf/index.js +1 -1
- package/dist-sdk/src/engine/tf/labels.d.ts +22 -5
- package/dist-sdk/src/engine/tf/labels.js +45 -3
- package/dist-sdk/src/engine/tf/parse.js +3 -2
- package/dist-sdk/src/engine/validation.d.ts +5 -0
- package/dist-sdk/src/engine/validation.js +12 -2
- package/dist-sdk/src/entities/access-policy/from-tf.js +38 -1
- package/dist-sdk/src/entities/access-policy/principal.d.ts +2 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +3 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +42 -19
- package/dist-sdk/src/entities/agent/from-tf.js +11 -3
- package/dist-sdk/src/entities/agent/module.js +2 -0
- package/dist-sdk/src/entities/agent/to-tf.js +14 -3
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +8 -1
- package/dist-sdk/src/entities/agent-tool/from-tf.js +11 -5
- package/dist-sdk/src/entities/agent-tool/module.js +3 -0
- package/dist-sdk/src/entities/app/auto-share.d.ts +38 -0
- package/dist-sdk/src/entities/app/auto-share.js +49 -0
- package/dist-sdk/src/entities/app/build.d.ts +17 -3
- package/dist-sdk/src/entities/app/build.js +56 -4
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +6 -1
- package/dist-sdk/src/entities/app/from-tf.js +4 -0
- package/dist-sdk/src/entities/app/index.d.ts +2 -1
- package/dist-sdk/src/entities/app/index.js +1 -8
- package/dist-sdk/src/entities/app/module.js +2 -1
- package/dist-sdk/src/entities/app/to-tf.d.ts +6 -0
- package/dist-sdk/src/entities/app/to-tf.js +25 -2
- package/dist-sdk/src/entities/automation/build.d.ts +12 -2
- package/dist-sdk/src/entities/automation/build.js +105 -17
- package/dist-sdk/src/entities/automation/calculation-expression.d.ts +7 -7
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +17 -4
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +187 -27
- package/dist-sdk/src/entities/automation/from-tf.d.ts +9 -2
- package/dist-sdk/src/entities/automation/from-tf.js +397 -89
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/index.js +1 -1
- package/dist-sdk/src/entities/automation/module.d.ts +3 -0
- package/dist-sdk/src/entities/automation/module.js +70 -7
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +21 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +38 -0
- package/dist-sdk/src/entities/automation/script-code.d.ts +5 -2
- package/dist-sdk/src/entities/automation/script-code.js +23 -5
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +37 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +76 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +92 -20
- package/dist-sdk/src/entities/automation/tasks.js +48 -15
- package/dist-sdk/src/entities/automation/to-tf.d.ts +20 -3
- package/dist-sdk/src/entities/automation/to-tf.js +656 -65
- package/dist-sdk/src/entities/automation/triggers.d.ts +8 -4
- package/dist-sdk/src/entities/automation/types.d.ts +9 -0
- package/dist-sdk/src/entities/automation/types.js +19 -0
- package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +1 -1
- package/dist-sdk/src/entities/automation/value-ref-tf.js +1 -1
- package/dist-sdk/src/entities/chart/from-tf.js +9 -1
- package/dist-sdk/src/entities/data-lookup/module.js +2 -0
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +7 -5
- package/dist-sdk/src/entities/element/build.d.ts +3 -0
- package/dist-sdk/src/entities/element/build.js +1 -0
- package/dist-sdk/src/entities/element/from-tf.js +4 -0
- package/dist-sdk/src/entities/element/module.js +2 -1
- package/dist-sdk/src/entities/element/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/element/to-tf.js +12 -14
- package/dist-sdk/src/entities/field/build.d.ts +3 -2
- package/dist-sdk/src/entities/field/calc.d.ts +7 -7
- package/dist-sdk/src/entities/field/from-tf.d.ts +4 -4
- package/dist-sdk/src/entities/field/from-tf.js +255 -80
- package/dist-sdk/src/entities/field/module.d.ts +6 -0
- package/dist-sdk/src/entities/field/module.js +23 -2
- package/dist-sdk/src/entities/field/options.js +6 -1
- package/dist-sdk/src/entities/field/order.d.ts +16 -0
- package/dist-sdk/src/entities/field/order.js +41 -0
- package/dist-sdk/src/entities/field/to-tf.d.ts +4 -4
- package/dist-sdk/src/entities/field/to-tf.js +7 -1
- package/dist-sdk/src/entities/field/types.d.ts +7 -0
- package/dist-sdk/src/entities/field/types.js +32 -0
- package/dist-sdk/src/entities/role/from-tf.js +3 -3
- package/dist-sdk/src/entities/role/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/role/to-tf.js +12 -4
- package/dist-sdk/src/entities/service-account/from-tf.js +3 -3
- package/dist-sdk/src/entities/service-account/workspace-owner.d.ts +16 -0
- package/dist-sdk/src/entities/service-account/workspace-owner.js +22 -0
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +15 -1
- package/dist-sdk/src/entities/shared/filters/ast.js +2 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +5 -0
- package/dist-sdk/src/entities/shared/filters/index.js +5 -0
- package/dist-sdk/src/entities/shared/filters/print.js +7 -2
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +5 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +42 -7
- package/dist-sdk/src/entities/shared/filters/types.d.ts +8 -3
- package/dist-sdk/src/entities/shared/ref.d.ts +5 -7
- package/dist-sdk/src/entities/shared/ref.js +5 -7
- package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +9 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.js +35 -2
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +10 -0
- package/dist-sdk/src/entities/shared/types/field-types.js +4 -0
- package/dist-sdk/src/entities/skill/access-policy.js +3 -3
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +3 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +12 -5
- package/dist-sdk/src/entities/skill/from-tf.js +4 -2
- package/dist-sdk/src/entities/skill/module.js +2 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +41 -8
- package/dist-sdk/src/entities/skill-tool/module.js +3 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +0 -6
- package/dist-sdk/src/entities/skill-tool/to-tf.js +22 -9
- package/dist-sdk/src/entities/task/build.d.ts +8 -0
- package/dist-sdk/src/entities/task/build.js +10 -1
- package/dist-sdk/src/entities/task/from-tf.d.ts +4 -2
- package/dist-sdk/src/entities/task/from-tf.js +7 -2
- package/dist-sdk/src/entities/task/module.js +3 -2
- package/dist-sdk/src/entities/task/to-tf.d.ts +8 -4
- package/dist-sdk/src/entities/task/to-tf.js +32 -1
- package/dist-sdk/src/entities/view/from-tf.js +9 -1
- package/dist-sdk/src/entities/view/module.js +4 -1
- package/dist-sdk/src/entities/view/to-tf.d.ts +6 -7
- package/dist-sdk/src/entities/view/to-tf.js +30 -11
- package/dist-sdk/src/entities/view/types.d.ts +6 -0
- package/dist-sdk/src/entities/view/types.js +6 -0
- package/dist-sdk/src/entities/visual-flow/build.d.ts +16 -1
- package/dist-sdk/src/entities/visual-flow/build.js +9 -0
- package/dist-sdk/src/entities/visual-flow/from-tf.d.ts +14 -0
- package/dist-sdk/src/entities/visual-flow/from-tf.js +51 -3
- package/dist-sdk/src/entities/visual-flow/index.d.ts +1 -1
- package/dist-sdk/src/entities/visual-flow/index.js +1 -1
- package/dist-sdk/src/entities/visual-flow/printer.js +19 -0
- package/dist-sdk/src/entities/visual-flow/to-tf.js +87 -3
- package/dist-sdk/src/entities/widget/from-tf.js +3 -3
- package/dist-sdk/src/entities/widget/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/widget/to-tf.js +7 -6
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +133 -9
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +4 -2
- package/dist-sdk/src/graph/index.js +3 -0
- package/dist-sdk/src/graph/modules.js +2 -1
- package/dist-sdk/src/graph/types.d.ts +41 -3
- package/package.json +7 -3
|
@@ -4,7 +4,7 @@ import { normalizeOnDemandParamKey } from "../../../pull/util.js";
|
|
|
4
4
|
import { EntityTfError } from "../../engine/entity.js";
|
|
5
5
|
import { dataRefLabel } from "../../engine/pull/context.js";
|
|
6
6
|
import { procedureDiscriminator } from "../../engine/pull/procedure-refs.js";
|
|
7
|
-
import { appResourceLabelPrefix, childPartFromScopedLabel, elementResourceLabelPrefix, isTfExpr, sanitizeName, scopedLabelToBagKey, tfLabelToTsLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
|
|
7
|
+
import { appResourceLabelPrefix, childPartFromScopedLabel, elementResourceLabelPrefix, isTfExpr, isTfLabel, isUuid, ownerFromScopedChildLabel, sanitizeName, scopedLabelToBagKey, tfLabelToTsLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
|
|
8
8
|
import { SUB_TYPE_BY_RESOURCE } from "../field/types.js";
|
|
9
9
|
import { IMPLEMENTED_FILE_READER_RESOURCE_TYPES } from "../file-reader/types.js";
|
|
10
10
|
import { connectorIdentityFromTf } from "../shared/connector-from-tf.js";
|
|
@@ -14,10 +14,11 @@ import { filterFromTf as deserializeFilterFromTf } from "../shared/filters/tf-co
|
|
|
14
14
|
import { TABLE_RESOURCE_TYPE } from "../table/module.js";
|
|
15
15
|
import { SEARCH_TABLE_RESOURCE_TYPES } from "../search-table/types.js";
|
|
16
16
|
import { outputFieldTypesFromScriptSchema, repeatedScriptOutputNames, scriptOutputReferenceIsDeclared } from "./output-field-types.js";
|
|
17
|
-
import { apiTaskRefAuthoringPath, matchesOutputWireKey, OUTPUT_KEY_WIRE_NAME } from "./output-key-wire-name.js";
|
|
17
|
+
import { apiTaskRefAuthoringPath, executeScriptAuthoringPath, matchesOutputWireKey, OUTPUT_KEY_WIRE_NAME } from "./output-key-wire-name.js";
|
|
18
18
|
import { RESOURCE_TYPE_TO_EXECUTOR, TASK_OUTPUT_CONTRACTS } from "./generated/task-output-contracts.js";
|
|
19
19
|
import { systemRefNameRoundTrips } from "./system-ref-name.js";
|
|
20
20
|
import { taskTfLabel } from "./task-label.js";
|
|
21
|
+
import { parseTriggerAttachmentPayloadRefJson, parseTriggerWholeRecordRefJson, TRIGGER_WHOLE_RECORD_REF_NAME } from "./task-output-labels.js";
|
|
21
22
|
import { workflowOutputTypeFromFieldType } from "./workflow-output.js";
|
|
22
23
|
import { ALL_AUTOMATION_TASK_TYPE_SET, AUTOMATION_BRANCH_TYPE_SET, AUTOMATION_RESOURCE_TYPE, AUTOMATION_TRIGGER_TYPE_SET, WORKFLOW_PUBLISH_RESOURCE_TYPE, } from "./types.js";
|
|
23
24
|
const TRIGGER_KINDS = {
|
|
@@ -38,6 +39,7 @@ const TRIGGER_KINDS = {
|
|
|
38
39
|
const TASK_FACTORIES = {
|
|
39
40
|
elementum_message_task: "postComment",
|
|
40
41
|
elementum_update_field_task: "updateField",
|
|
42
|
+
elementum_bulk_update_fields_task: "bulkUpdateFields",
|
|
41
43
|
elementum_variable_task: "setVariable",
|
|
42
44
|
elementum_update_variable_task: "setVariable",
|
|
43
45
|
elementum_create_record_task: "createRecord",
|
|
@@ -61,6 +63,7 @@ const TASK_FACTORIES = {
|
|
|
61
63
|
elementum_ai_search_table_task: "aiSearchTable",
|
|
62
64
|
elementum_ai_transform_task: "aiTransform",
|
|
63
65
|
elementum_save_attachment_task: "saveAttachment",
|
|
66
|
+
elementum_unzip_file_task: "unzip",
|
|
64
67
|
elementum_user_search_task: "userSearch",
|
|
65
68
|
elementum_user_group_search_task: "userGroupSearch",
|
|
66
69
|
elementum_calculation_task: "calculation",
|
|
@@ -327,7 +330,7 @@ const TRIGGER_ATTRIBUTES = new Set([
|
|
|
327
330
|
]);
|
|
328
331
|
const TASK_ATTRIBUTES = new Set([
|
|
329
332
|
"parent", "name", "depends_on", "filter", "fields", "inputs", "output_schema",
|
|
330
|
-
"list", "code", "
|
|
333
|
+
"list", "code", "variables", "updates", "variable", "value",
|
|
331
334
|
"object_id", "table_id", "record_reference", "record_id", "source_record_ids",
|
|
332
335
|
"approval_process_id", "requester_reference", "approver_references", "reason", "summary",
|
|
333
336
|
"approval_reference", "status",
|
|
@@ -342,7 +345,7 @@ const TASK_ATTRIBUTES = new Set([
|
|
|
342
345
|
"output_mappings", "file_reader_id", "raw_text", "procedure_id",
|
|
343
346
|
"calculations", "categories", "limit", "sort", "tag", "tags", "context", "length",
|
|
344
347
|
"subject", "phone_service_id", "phone_number", "default_language", "first_message",
|
|
345
|
-
"synchronous", "cloudlink_id", "stored_function_id",
|
|
348
|
+
"synchronous", "cloudlink_id", "stored_function_id",
|
|
346
349
|
"relate_to_record_reference", "method", "parameters", "headers",
|
|
347
350
|
"basic_auth", "bearer_auth", "oauth", "json_body", "form_body", "custom_body", "multipart_body",
|
|
348
351
|
"query",
|
|
@@ -594,7 +597,13 @@ const TASK_OUTPUT_LABEL_TO_TS = {
|
|
|
594
597
|
elementum_record_search_task: { "First found record": ["record"] },
|
|
595
598
|
elementum_create_record_task: { "Created record": ["record"] },
|
|
596
599
|
elementum_update_field_task: { "Updated record": ["record"] },
|
|
597
|
-
elementum_execute_script_task: {
|
|
600
|
+
elementum_execute_script_task: {
|
|
601
|
+
// Display keys. Canonical `result` / `stringArrayResult` are not refs keys;
|
|
602
|
+
// `Result` is the whole JSON envelope, not a property named Result (#1656).
|
|
603
|
+
Result: ["result"],
|
|
604
|
+
"Text Result": ["textResult"],
|
|
605
|
+
"Text List Result": ["stringArrayResult"],
|
|
606
|
+
},
|
|
598
607
|
elementum_user_search_task: {
|
|
599
608
|
"Users Size": ["count"],
|
|
600
609
|
"User's Id": ["user", "id"],
|
|
@@ -705,11 +714,13 @@ function aspectRefFromObjectId(objectId, ctx) {
|
|
|
705
714
|
}
|
|
706
715
|
if (typeof identity !== "string" || identity === "")
|
|
707
716
|
return undefined;
|
|
717
|
+
const namespace = lookup?.attrs.namespace;
|
|
708
718
|
return {
|
|
709
719
|
kind: "app",
|
|
710
720
|
appHandle: tfLabelToTsLabel(objectId.label),
|
|
711
721
|
entityType: objectId.type === "elementum_task" ? "task" : objectId.type === "elementum_element" ? "element" : "app",
|
|
712
722
|
name: identity,
|
|
723
|
+
...(typeof namespace === "string" && namespace !== "" ? { namespace } : {}),
|
|
713
724
|
};
|
|
714
725
|
}
|
|
715
726
|
function aspectKindFromObjectId(objectId) {
|
|
@@ -891,22 +902,144 @@ function approverReferenceFieldAuthoringType(value, ctx) {
|
|
|
891
902
|
}
|
|
892
903
|
return undefined;
|
|
893
904
|
}
|
|
894
|
-
function decodeFieldAssignmentValue(value, ctx) {
|
|
905
|
+
function decodeFieldAssignmentValue(value, ctx, diagnostics, where = "field assignment") {
|
|
895
906
|
// Multi-Select assignments are exported as jsonencode([<option UUID>, ...])
|
|
896
907
|
// rather than the options-by-label locals used for a scalar Dropdown. Walk
|
|
897
908
|
// that payload with the state-derived option registry so pulled source stays
|
|
898
909
|
// portable across organizations and fresh creates.
|
|
899
910
|
if (isTfExpr(value) && value.$expr === "jsonencode") {
|
|
900
|
-
return decodeFieldAssignmentValue(value.value, ctx);
|
|
911
|
+
return decodeFieldAssignmentValue(value.value, ctx, diagnostics, where);
|
|
901
912
|
}
|
|
902
913
|
if (Array.isArray(value)) {
|
|
903
|
-
return value.map((item) => decodeFieldAssignmentValue(item, ctx));
|
|
914
|
+
return value.map((item) => decodeFieldAssignmentValue(item, ctx, diagnostics, where));
|
|
904
915
|
}
|
|
905
916
|
if (typeof value === "string" && /^[a-f0-9-]{36}$/i.test(value)) {
|
|
906
917
|
const label = ctx.picklistOptionLabelById?.get(value);
|
|
907
918
|
if (label !== undefined)
|
|
908
919
|
return { kind: "literal", value: label };
|
|
909
920
|
}
|
|
921
|
+
return decodeValueOrStringifiedRef(value, ctx, diagnostics, where);
|
|
922
|
+
}
|
|
923
|
+
const VALUE_REFERENCE_KEYS = ["taskReference", "triggerReference", "variableReference"];
|
|
924
|
+
/**
|
|
925
|
+
* edk#1646: ei's exporter falls back to a stringified wire ValueReference
|
|
926
|
+
* envelope (`"{\"fieldType\":…,\"taskReference\":{…}}"`) when it cannot emit a
|
|
927
|
+
* `refs["…"]` expression. Left as a literal, build ships the JSON text into
|
|
928
|
+
* the field (or fails a typed field). Decode the envelope - whole-string or
|
|
929
|
+
* embedded in surrounding text - through the same path calculation formulas
|
|
930
|
+
* use. An envelope whose task / trigger / variable does not resolve in this
|
|
931
|
+
* automation stays visible as an `unresolved` value-reference with a pull
|
|
932
|
+
* diagnostic instead of a silent literal. Returns undefined for any string
|
|
933
|
+
* that carries no envelope.
|
|
934
|
+
*/
|
|
935
|
+
function decodeStringifiedValueReference(value, ctx, diagnostics, where) {
|
|
936
|
+
if (!value.includes("{") || !VALUE_REFERENCE_KEYS.some((key) => value.includes(`"${key}"`)))
|
|
937
|
+
return undefined;
|
|
938
|
+
const parts = [];
|
|
939
|
+
let cursor = 0;
|
|
940
|
+
let unresolved = false;
|
|
941
|
+
let found = false;
|
|
942
|
+
for (let start = value.indexOf("{", cursor); start >= 0; start = value.indexOf("{", cursor)) {
|
|
943
|
+
let depth = 0;
|
|
944
|
+
let inString = false;
|
|
945
|
+
let escaped = false;
|
|
946
|
+
let end = start;
|
|
947
|
+
for (; end < value.length; end += 1) {
|
|
948
|
+
const char = value[end];
|
|
949
|
+
if (inString) {
|
|
950
|
+
if (escaped)
|
|
951
|
+
escaped = false;
|
|
952
|
+
else if (char === "\\")
|
|
953
|
+
escaped = true;
|
|
954
|
+
else if (char === '"')
|
|
955
|
+
inString = false;
|
|
956
|
+
continue;
|
|
957
|
+
}
|
|
958
|
+
if (char === '"')
|
|
959
|
+
inString = true;
|
|
960
|
+
else if (char === "{")
|
|
961
|
+
depth += 1;
|
|
962
|
+
else if (char === "}") {
|
|
963
|
+
depth -= 1;
|
|
964
|
+
if (depth === 0) {
|
|
965
|
+
end += 1;
|
|
966
|
+
break;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
if (depth !== 0)
|
|
971
|
+
break;
|
|
972
|
+
let parsed;
|
|
973
|
+
try {
|
|
974
|
+
parsed = JSON.parse(value.slice(start, end));
|
|
975
|
+
}
|
|
976
|
+
catch {
|
|
977
|
+
cursor = start + 1;
|
|
978
|
+
continue;
|
|
979
|
+
}
|
|
980
|
+
if (!isObject(parsed) || !VALUE_REFERENCE_KEYS.some((key) => isObject(parsed[key]))) {
|
|
981
|
+
cursor = start + 1;
|
|
982
|
+
continue;
|
|
983
|
+
}
|
|
984
|
+
found = true;
|
|
985
|
+
if (start > cursor)
|
|
986
|
+
parts.push(value.slice(cursor, start));
|
|
987
|
+
const reference = decodeFilterReferenceEnvelope(parsed, ctx);
|
|
988
|
+
if (reference === undefined || !stringifiedReferenceResolves(parsed, reference, ctx)) {
|
|
989
|
+
unresolved = true;
|
|
990
|
+
parts.push({ kind: "unresolved", uuid: value.slice(start, end), hint: "value-reference (edk#1646)" });
|
|
991
|
+
}
|
|
992
|
+
else {
|
|
993
|
+
parts.push(reference);
|
|
994
|
+
}
|
|
995
|
+
cursor = end;
|
|
996
|
+
}
|
|
997
|
+
if (!found)
|
|
998
|
+
return undefined;
|
|
999
|
+
if (unresolved) {
|
|
1000
|
+
diagnostics?.push(`${where}: value is a stringified platform ValueReference whose task/trigger/variable is not in this automation; ` +
|
|
1001
|
+
"kept as an unresolved value-reference - rewrite it as a ctx reference before building (edk#1646)");
|
|
1002
|
+
}
|
|
1003
|
+
if (cursor < value.length)
|
|
1004
|
+
parts.push(value.slice(cursor));
|
|
1005
|
+
const merged = [];
|
|
1006
|
+
for (const part of parts) {
|
|
1007
|
+
const last = merged[merged.length - 1];
|
|
1008
|
+
if (typeof part === "string" && typeof last === "string")
|
|
1009
|
+
merged[merged.length - 1] = last + part;
|
|
1010
|
+
else
|
|
1011
|
+
merged.push(part);
|
|
1012
|
+
}
|
|
1013
|
+
// A sole unresolved envelope (or one that failed to resolve) becomes a
|
|
1014
|
+
// single unresolved value so the printer surfaces the TODO instead of a
|
|
1015
|
+
// template that still embeds the JSON text.
|
|
1016
|
+
if (unresolved && merged.length === 1 && typeof merged[0] !== "string") {
|
|
1017
|
+
return merged[0];
|
|
1018
|
+
}
|
|
1019
|
+
if (unresolved) {
|
|
1020
|
+
return { kind: "unresolved", uuid: value, hint: "value-reference (edk#1646)" };
|
|
1021
|
+
}
|
|
1022
|
+
if (merged.length === 1 && typeof merged[0] !== "string")
|
|
1023
|
+
return merged[0];
|
|
1024
|
+
return { kind: "template", parts: merged };
|
|
1025
|
+
}
|
|
1026
|
+
function stringifiedReferenceResolves(envelope, reference, ctx) {
|
|
1027
|
+
if (reference.kind === "unresolved")
|
|
1028
|
+
return false;
|
|
1029
|
+
const taskRef = envelope.taskReference;
|
|
1030
|
+
if (isObject(taskRef)) {
|
|
1031
|
+
const taskIdOrKey = workflowOutputTaskIdOrKey(taskRef.taskId, ctx);
|
|
1032
|
+
return taskIdOrKey !== undefined && resolveTaskRefKey(taskIdOrKey, ctx).block !== undefined;
|
|
1033
|
+
}
|
|
1034
|
+
return true;
|
|
1035
|
+
}
|
|
1036
|
+
/** decodeValue, upgrading a stringified ValueReference envelope (edk#1646). */
|
|
1037
|
+
function decodeValueOrStringifiedRef(value, ctx, diagnostics, where) {
|
|
1038
|
+
if (typeof value === "string") {
|
|
1039
|
+
const decoded = decodeStringifiedValueReference(value, ctx, diagnostics, where);
|
|
1040
|
+
if (decoded !== undefined)
|
|
1041
|
+
return decoded;
|
|
1042
|
+
}
|
|
910
1043
|
return decodeValue(value, ctx);
|
|
911
1044
|
}
|
|
912
1045
|
function triggerRefPath(path, ctx) {
|
|
@@ -966,15 +1099,16 @@ function triggerRefPath(path, ctx) {
|
|
|
966
1099
|
// field display name "Facility".
|
|
967
1100
|
if (isDeclaredOnDemandParameter(ctx.trigger, wireName))
|
|
968
1101
|
return names;
|
|
969
|
-
// A trigger's own bare record reference
|
|
970
|
-
//
|
|
971
|
-
//
|
|
972
|
-
//
|
|
973
|
-
//
|
|
974
|
-
//
|
|
975
|
-
//
|
|
976
|
-
//
|
|
977
|
-
//
|
|
1102
|
+
// A trigger's own bare record reference. refs["Record"] is the record ID
|
|
1103
|
+
// (ASPECT_RECORD_ID, confirmed live via `ei refs`, see
|
|
1104
|
+
// trigger-record-id.test.ts); the whole record shares that display name and
|
|
1105
|
+
// has no refs key, so it exports as its reference JSON instead (edk#1284).
|
|
1106
|
+
// Deliberately scoped to triggerRefPath, not the shared
|
|
1107
|
+
// WIRE_REF_SEGMENT_TO_TS table: createRecord/findRelatedRecords TASKS also
|
|
1108
|
+
// expose a wire key literally named "Record" (their record-ID output), and
|
|
1109
|
+
// translating it globally intercepted that task-level case before it could
|
|
1110
|
+
// ever be checked (decodeValue's own dedicated "Record" handling for those
|
|
1111
|
+
// task types).
|
|
978
1112
|
if (wireName === "Record") {
|
|
979
1113
|
const recordParams = onDemandRecordParameters(ctx.trigger);
|
|
980
1114
|
return recordParams.length === 1
|
|
@@ -993,7 +1127,11 @@ function triggerRefPath(path, ctx) {
|
|
|
993
1127
|
return names;
|
|
994
1128
|
return recordFieldRefPath(wireName, ctx) ?? names;
|
|
995
1129
|
}
|
|
996
|
-
function
|
|
1130
|
+
function forEachItemOwnerRefName(loop, ctx) {
|
|
1131
|
+
const collection = loop === undefined ? undefined : resourceRef(loop.attrs.list);
|
|
1132
|
+
return collection === undefined ? undefined : ctx.taskTargetOwnerRefNameByAddress?.get(`${collection.type}.${collection.label}`);
|
|
1133
|
+
}
|
|
1134
|
+
function forEachItemRefPath(path, ctx, loop) {
|
|
997
1135
|
const names = pathNames(path);
|
|
998
1136
|
if (names.length !== 1)
|
|
999
1137
|
return names.flatMap((segment) => segment.split("."));
|
|
@@ -1004,7 +1142,9 @@ function forEachItemRefPath(path, ctx) {
|
|
|
1004
1142
|
if (wireName === "Record")
|
|
1005
1143
|
return ["recordId"];
|
|
1006
1144
|
const wireNameLower = wireName.toLowerCase();
|
|
1007
|
-
|
|
1145
|
+
const itemOwner = forEachItemOwnerRefName(loop, ctx);
|
|
1146
|
+
const ownFields = itemOwner === undefined || itemOwner === ctx.appRefName ? ctx.fieldById.values() : [];
|
|
1147
|
+
for (const field of ownFields) {
|
|
1008
1148
|
// Some provider paths already contain the stable EDK field key (for
|
|
1009
1149
|
// example `for_each.<task-id>.productId`), while inner.refs uses the
|
|
1010
1150
|
// display name in other workflow shapes. Accept both forms.
|
|
@@ -1170,6 +1310,14 @@ function decodeTaskReferenceFromString(taskIdOrKey, pathSegments, ctx) {
|
|
|
1170
1310
|
return { kind: "taskRef", task: refKey, path: apiPath };
|
|
1171
1311
|
}
|
|
1172
1312
|
}
|
|
1313
|
+
// Exact contract names only. `result.passed` is two segments and stays a
|
|
1314
|
+
// property; `Result` is the whole JSON envelope (#1656).
|
|
1315
|
+
if (block?.type === "elementum_execute_script_task" && pathSegments.length === 1) {
|
|
1316
|
+
const scriptPath = executeScriptAuthoringPath(pathSegments[0]);
|
|
1317
|
+
if (scriptPath !== undefined) {
|
|
1318
|
+
return { kind: "taskRef", task: refKey, path: [...scriptPath] };
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1173
1321
|
const keyPath = pathSegments.map((segment) => WIRE_REF_SEGMENT_TO_TS[segment] ?? segment);
|
|
1174
1322
|
const taskKind = block?.type !== undefined ? TASK_FACTORIES[block.type] : undefined;
|
|
1175
1323
|
const wireOutputKey = taskKind !== undefined ? OUTPUT_KEY_WIRE_NAME[taskKind] : undefined;
|
|
@@ -1212,11 +1360,11 @@ function decodeReferenceString(value, ctx) {
|
|
|
1212
1360
|
return decodeTaskReferenceFromString(pieces[1], pieces.slice(2), ctx);
|
|
1213
1361
|
}
|
|
1214
1362
|
if (pieces[0] === "for_each" && pieces.length > 2) {
|
|
1215
|
-
const { refKey } = resolveTaskRefKey(pieces[1], ctx);
|
|
1363
|
+
const { refKey, block } = resolveTaskRefKey(pieces[1], ctx);
|
|
1216
1364
|
return {
|
|
1217
1365
|
kind: "forEachItemRef",
|
|
1218
1366
|
forEachTask: refKey,
|
|
1219
|
-
path: forEachItemRefPath(pieces.slice(2), ctx),
|
|
1367
|
+
path: forEachItemRefPath(pieces.slice(2), ctx, block),
|
|
1220
1368
|
};
|
|
1221
1369
|
}
|
|
1222
1370
|
if (pieces[0] === "variable" && pieces.length > 1) {
|
|
@@ -1356,7 +1504,7 @@ function decodeTemplateForEachRef(value, ctx) {
|
|
|
1356
1504
|
return {
|
|
1357
1505
|
kind: "forEachItemRef",
|
|
1358
1506
|
forEachTask: task.refKey,
|
|
1359
|
-
path: forEachItemRefPath(nameParts, ctx),
|
|
1507
|
+
path: forEachItemRefPath(nameParts, ctx, task.block),
|
|
1360
1508
|
};
|
|
1361
1509
|
}
|
|
1362
1510
|
/**
|
|
@@ -1368,6 +1516,12 @@ function decodeTemplateForEachRef(value, ctx) {
|
|
|
1368
1516
|
* decodeValue's generic local handling, but resolves to a triggerRef bag key
|
|
1369
1517
|
* instead of a "field" RefExpr so it stays a valid filter LHS.
|
|
1370
1518
|
*/
|
|
1519
|
+
function fieldBagKey(label, ctx) {
|
|
1520
|
+
const owned = ownerFromScopedChildLabel(label);
|
|
1521
|
+
if (owned !== undefined)
|
|
1522
|
+
return scopedLabelToBagKey(owned.ownerTfLabel, label, owned.scope);
|
|
1523
|
+
return scopedLabelToBagKey(ctx.appTfLabel, label, ctx.ownerScope);
|
|
1524
|
+
}
|
|
1371
1525
|
/**
|
|
1372
1526
|
* A field id under an on-demand record input belongs to that input's target
|
|
1373
1527
|
* (its `default_value`). Another app's or element's field decodes only when its
|
|
@@ -1399,7 +1553,7 @@ function fieldKeyOnRecordParameterTarget(fieldPart, target, ctx) {
|
|
|
1399
1553
|
}
|
|
1400
1554
|
function fieldKeyFromTriggerFieldIdExpr(fieldPart, ctx) {
|
|
1401
1555
|
if (fieldPart.$expr === "resource-attr" && fieldPart.type.endsWith("_field") && fieldPart.path[0] === "id") {
|
|
1402
|
-
return
|
|
1556
|
+
return fieldBagKey(fieldPart.label, ctx);
|
|
1403
1557
|
}
|
|
1404
1558
|
if (fieldPart.$expr === "local") {
|
|
1405
1559
|
const prefix = `${ctx.appTfLabel}_`;
|
|
@@ -1563,6 +1717,11 @@ function userIdDefault(value, ctx) {
|
|
|
1563
1717
|
return decoded?.kind === "user" ? decoded : value;
|
|
1564
1718
|
}
|
|
1565
1719
|
function decodeValue(value, ctx) {
|
|
1720
|
+
if (ctx.trigger.type === "elementum_attachment_added_trigger") {
|
|
1721
|
+
const payloadKey = parseTriggerAttachmentPayloadRefJson(isTfExpr(value) && value.$expr === "jsonencode" ? JSON.stringify(value.value) : value);
|
|
1722
|
+
if (payloadKey !== undefined)
|
|
1723
|
+
return { kind: "triggerRef", path: ["attachment", payloadKey] };
|
|
1724
|
+
}
|
|
1566
1725
|
if (isTfExpr(value)) {
|
|
1567
1726
|
if (value.$expr === "template") {
|
|
1568
1727
|
return { kind: "template", parts: value.parts.map((part) => typeof part === "string" ? part : decodeValue(part, ctx)) };
|
|
@@ -1581,7 +1740,7 @@ function decodeValue(value, ctx) {
|
|
|
1581
1740
|
return {
|
|
1582
1741
|
kind: "forEachItemRef",
|
|
1583
1742
|
forEachTask: task.refKey,
|
|
1584
|
-
path: forEachItemRefPath(value.path.slice(2), ctx),
|
|
1743
|
+
path: forEachItemRefPath(value.path.slice(2), ctx, task.block),
|
|
1585
1744
|
};
|
|
1586
1745
|
}
|
|
1587
1746
|
if (task !== undefined && value.path[0] === "refs") {
|
|
@@ -1691,7 +1850,7 @@ function decodeValue(value, ctx) {
|
|
|
1691
1850
|
return {
|
|
1692
1851
|
kind: "field",
|
|
1693
1852
|
appHandle: ctx.appRefName,
|
|
1694
|
-
fieldKey:
|
|
1853
|
+
fieldKey: fieldBagKey(value.label, ctx),
|
|
1695
1854
|
};
|
|
1696
1855
|
}
|
|
1697
1856
|
if (value.type === AUTOMATION_RESOURCE_TYPE && value.path[0] === "id") {
|
|
@@ -1702,13 +1861,13 @@ function decodeValue(value, ctx) {
|
|
|
1702
1861
|
};
|
|
1703
1862
|
}
|
|
1704
1863
|
if (value.type === "elementum_agent" && value.path[0] === "id") {
|
|
1705
|
-
return { kind: "agent", appHandle: ctx.appRefName, agentKey: scopedLabelToBagKey(ctx.appTfLabel, value.label), name: value.label };
|
|
1864
|
+
return { kind: "agent", appHandle: ctx.appRefName, agentKey: scopedLabelToBagKey(ctx.appTfLabel, value.label, ctx.ownerScope), name: value.label };
|
|
1706
1865
|
}
|
|
1707
1866
|
if (value.type === "elementum_phone_service" && value.path[0] === "id") {
|
|
1708
1867
|
return {
|
|
1709
1868
|
kind: "phoneService",
|
|
1710
1869
|
appHandle: ctx.appRefName,
|
|
1711
|
-
phoneServiceKey: scopedLabelToBagKey(ctx.appTfLabel, value.label),
|
|
1870
|
+
phoneServiceKey: scopedLabelToBagKey(ctx.appTfLabel, value.label, ctx.ownerScope),
|
|
1712
1871
|
};
|
|
1713
1872
|
}
|
|
1714
1873
|
if (value.type === TABLE_RESOURCE_TYPE && value.path[0] === "id") {
|
|
@@ -1746,7 +1905,7 @@ function decodeValue(value, ctx) {
|
|
|
1746
1905
|
return {
|
|
1747
1906
|
kind: "documentModel",
|
|
1748
1907
|
appHandle: ctx.appRefName,
|
|
1749
|
-
documentModelKey: scopedLabelToBagKey(ctx.appTfLabel, value.label),
|
|
1908
|
+
documentModelKey: scopedLabelToBagKey(ctx.appTfLabel, value.label, ctx.ownerScope),
|
|
1750
1909
|
};
|
|
1751
1910
|
}
|
|
1752
1911
|
if (value.type === "elementum_approval_process" && value.path[0] === "id") {
|
|
@@ -1757,7 +1916,7 @@ function decodeValue(value, ctx) {
|
|
|
1757
1916
|
return {
|
|
1758
1917
|
kind: "approvalChain",
|
|
1759
1918
|
appHandle: ctx.appRefName,
|
|
1760
|
-
approvalChainKey: scopedLabelToBagKey(ctx.appTfLabel, value.label),
|
|
1919
|
+
approvalChainKey: scopedLabelToBagKey(ctx.appTfLabel, value.label, ctx.ownerScope),
|
|
1761
1920
|
};
|
|
1762
1921
|
}
|
|
1763
1922
|
if ((value.type === SEARCH_TABLE_RESOURCE_TYPES.snowflake ||
|
|
@@ -1808,11 +1967,13 @@ function decodeValue(value, ctx) {
|
|
|
1808
1967
|
const mappedHandle = typeof name === "string"
|
|
1809
1968
|
? (value.type === "elementum_task" ? ctx.foreignTaskRefNames : value.type === "elementum_element" ? ctx.foreignElementRefNames : ctx.foreignAppRefNames)?.get(name)
|
|
1810
1969
|
: undefined;
|
|
1970
|
+
const namespace = lookup?.attrs.namespace;
|
|
1811
1971
|
return {
|
|
1812
1972
|
kind: "app",
|
|
1813
1973
|
appHandle: mappedHandle ?? tfLabelToTsLabel(value.label),
|
|
1814
1974
|
entityType: value.type === "elementum_task" ? "task" : value.type === "elementum_element" ? "element" : "app",
|
|
1815
1975
|
...(typeof name === "string" ? { name } : {}),
|
|
1976
|
+
...(typeof namespace === "string" && namespace !== "" ? { namespace } : {}),
|
|
1816
1977
|
};
|
|
1817
1978
|
}
|
|
1818
1979
|
if (value.$expr === "data-attr" && value.type === AUTOMATION_RESOURCE_TYPE && value.path[0] === "id") {
|
|
@@ -1951,6 +2112,25 @@ function decodeValue(value, ctx) {
|
|
|
1951
2112
|
}
|
|
1952
2113
|
return { kind: "user", email };
|
|
1953
2114
|
}
|
|
2115
|
+
if (value.$expr === "data-attr" && value.type === "elementum_vault_entry" && value.path[0] === "value_reference") {
|
|
2116
|
+
const key = ctx.dataBlocks.get(`${value.type}.${value.label}`)?.attrs.key;
|
|
2117
|
+
if (typeof key !== "string" || key === "") {
|
|
2118
|
+
throw new EntityTfError(`data.elementum_vault_entry.${value.label}: key lookup is missing`);
|
|
2119
|
+
}
|
|
2120
|
+
return { kind: "secret", key };
|
|
2121
|
+
}
|
|
2122
|
+
if (value.$expr === "data-attr" && value.type === "elementum_group" && value.path[0] === "id") {
|
|
2123
|
+
// Static notification/add-watcher recipients (edk#1389). The export
|
|
2124
|
+
// labels recipient lookups by id, so the org.groups key is the one
|
|
2125
|
+
// org.ts assigned this name (edk#1412), else the name's sanitized key,
|
|
2126
|
+
// the way `pull org` derives it.
|
|
2127
|
+
const name = ctx.dataBlocks.get(`${value.type}.${value.label}`)?.attrs.name;
|
|
2128
|
+
if (typeof name !== "string" || name === "") {
|
|
2129
|
+
throw new EntityTfError(`data.elementum_group.${value.label}: name lookup is missing`);
|
|
2130
|
+
}
|
|
2131
|
+
const groupKey = ctx.groupKeysByName?.get(name) ?? tfLabelToTsLabel(sanitizeName(name));
|
|
2132
|
+
return { kind: "orgGroup", groupKey, name };
|
|
2133
|
+
}
|
|
1954
2134
|
if (value.$expr === "variable") {
|
|
1955
2135
|
if (value.path.length !== 0) {
|
|
1956
2136
|
throw new EntityTfError(`unsupported variable reference var.${value.name}`);
|
|
@@ -2024,14 +2204,35 @@ function decodeCustomResponse(value, ctx) {
|
|
|
2024
2204
|
return undefined;
|
|
2025
2205
|
return { ...(success !== undefined ? { success } : {}), ...(failure !== undefined ? { failure } : {}) };
|
|
2026
2206
|
}
|
|
2207
|
+
/**
|
|
2208
|
+
* The managed bag key for a ref-only field lookup, matched on display name
|
|
2209
|
+
* and owner. Managed entries name the owner by its catalog ref or, when
|
|
2210
|
+
* bootstrapped from state, by the camelCase of its tf label (#1431).
|
|
2211
|
+
*/
|
|
2212
|
+
function managedFieldKeyForDisplayName(foreign, ctx) {
|
|
2213
|
+
if (foreign.fieldName === undefined)
|
|
2214
|
+
return undefined;
|
|
2215
|
+
const lower = foreign.fieldName.toLowerCase();
|
|
2216
|
+
const owners = new Set([foreign.ownerRefName]);
|
|
2217
|
+
if (foreign.ownerNamespace !== undefined && isTfLabel(foreign.ownerNamespace))
|
|
2218
|
+
owners.add(tfLabelToTsLabel(foreign.ownerNamespace));
|
|
2219
|
+
const keys = new Set();
|
|
2220
|
+
for (const [id, identity] of ctx.foreignFieldRefsById ?? []) {
|
|
2221
|
+
if (id.startsWith("refOnly:") || !owners.has(identity.ownerRefName) || identity.fieldName?.toLowerCase() !== lower)
|
|
2222
|
+
continue;
|
|
2223
|
+
keys.add(identity.fieldKey);
|
|
2224
|
+
}
|
|
2225
|
+
return keys.size === 1 ? keys.values().next().value : undefined;
|
|
2226
|
+
}
|
|
2027
2227
|
function fieldRef(value, ctx) {
|
|
2028
2228
|
if (isTfExpr(value) && value.$expr === "data-attr" && value.path.join(".") === "id") {
|
|
2029
2229
|
const foreign = ctx.foreignFieldRefsByDataAddress?.get(`${value.type}.${value.label}`);
|
|
2030
2230
|
if (foreign !== undefined) {
|
|
2231
|
+
const fieldKey = managedFieldKeyForDisplayName(foreign, ctx) ?? foreign.fieldKey;
|
|
2031
2232
|
return {
|
|
2032
2233
|
kind: "field",
|
|
2033
2234
|
appHandle: foreign.ownerRefName,
|
|
2034
|
-
fieldKey
|
|
2235
|
+
fieldKey,
|
|
2035
2236
|
...(foreign.ownerKind !== undefined || foreign.fieldName !== undefined || foreign.fieldType !== undefined
|
|
2036
2237
|
? {
|
|
2037
2238
|
foreign: {
|
|
@@ -2056,11 +2257,12 @@ function fieldRef(value, ctx) {
|
|
|
2056
2257
|
kind: "field",
|
|
2057
2258
|
appHandle: foreign.ownerRefName,
|
|
2058
2259
|
fieldKey: foreign.fieldKey,
|
|
2059
|
-
...(foreign.fieldName !== undefined || foreign.fieldType !== undefined
|
|
2260
|
+
...(foreign.ownerKind !== undefined || foreign.fieldName !== undefined || foreign.fieldType !== undefined
|
|
2060
2261
|
? {
|
|
2061
2262
|
foreign: {
|
|
2062
|
-
entityType: "app",
|
|
2063
|
-
name: foreign.ownerRefName,
|
|
2263
|
+
entityType: foreign.ownerKind ?? "app",
|
|
2264
|
+
name: foreign.ownerName ?? foreign.ownerRefName,
|
|
2265
|
+
...(foreign.ownerNamespace !== undefined ? { namespace: foreign.ownerNamespace } : {}),
|
|
2064
2266
|
...(foreign.fieldName !== undefined ? { fieldName: foreign.fieldName } : {}),
|
|
2065
2267
|
...(foreign.fieldType !== undefined ? { fieldType: foreign.fieldType } : {}),
|
|
2066
2268
|
},
|
|
@@ -2315,6 +2517,11 @@ function decodeCalculationTaskMustache(taskId, wireName, ctx) {
|
|
|
2315
2517
|
return { kind: "taskRef", task: refKey, path: apiPath };
|
|
2316
2518
|
}
|
|
2317
2519
|
}
|
|
2520
|
+
if (taskBlock?.type === "elementum_execute_script_task") {
|
|
2521
|
+
const scriptPath = executeScriptAuthoringPath(wireName);
|
|
2522
|
+
if (scriptPath !== undefined)
|
|
2523
|
+
return { kind: "taskRef", task: refKey, path: [...scriptPath] };
|
|
2524
|
+
}
|
|
2318
2525
|
const keyPath = wireName.split(".");
|
|
2319
2526
|
const taskKind = taskBlock?.type !== undefined ? TASK_FACTORIES[taskBlock.type] : undefined;
|
|
2320
2527
|
const wireOutputKey = taskKind !== undefined ? OUTPUT_KEY_WIRE_NAME[taskKind] : undefined;
|
|
@@ -2355,16 +2562,13 @@ function pulledRawCalculation(formula, outputType, multiple) {
|
|
|
2355
2562
|
return resultType === undefined ? undefined : { kind: "calculationRaw", text: formula, resultType };
|
|
2356
2563
|
}
|
|
2357
2564
|
function resolveVariableReference(rawId, rawName, outputName, ctx) {
|
|
2565
|
+
// One candidate per created variable (edk#1456: a task can create several).
|
|
2358
2566
|
const variableTasks = [];
|
|
2359
2567
|
for (const [, task] of ctx.taskByAddress) {
|
|
2360
2568
|
if (task.block.type === "elementum_variable_task") {
|
|
2361
|
-
const
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
const varId = typeof task.block.attrs.variable_id === "string"
|
|
2365
|
-
? task.block.attrs.variable_id
|
|
2366
|
-
: undefined;
|
|
2367
|
-
variableTasks.push({ refKey: task.refKey, varName, varId });
|
|
2569
|
+
for (const entry of variableTaskEntries(task.block)) {
|
|
2570
|
+
variableTasks.push({ refKey: task.refKey, varName: entry.name, ...(entry.id !== undefined ? { varId: entry.id } : {}) });
|
|
2571
|
+
}
|
|
2368
2572
|
}
|
|
2369
2573
|
}
|
|
2370
2574
|
if (variableTasks.length === 0)
|
|
@@ -2391,8 +2595,8 @@ function resolveVariableReference(rawId, rawName, outputName, ctx) {
|
|
|
2391
2595
|
}
|
|
2392
2596
|
}
|
|
2393
2597
|
// 4. The variable's real platform id is Computed on the provider, so the
|
|
2394
|
-
// static `variable_task` block does not carry `
|
|
2395
|
-
// in an EDK-only `
|
|
2598
|
+
// static `variable_task` block does not carry `variables[*].id`. Export puts them
|
|
2599
|
+
// in an EDK-only `edk_variable_ids_<label>` local (hydrated onto the block
|
|
2396
2600
|
// before this resolver runs). Without that, a workflow OUTPUT's
|
|
2397
2601
|
// `variableReference.name` is the synthetic "variable|<uuid>" placeholder,
|
|
2398
2602
|
// and #2/#3's name-based matches routinely
|
|
@@ -2404,6 +2608,7 @@ function resolveVariableReference(rawId, rawName, outputName, ctx) {
|
|
|
2404
2608
|
// "variable.<uuid>" is a DIFFERENT wire dialect with no such guarantee
|
|
2405
2609
|
// (board issue #171 contract: a filter referencing variable.<uuid> must
|
|
2406
2610
|
// NOT bind to a same-automation variable task).
|
|
2611
|
+
// One candidate means one variable in the whole automation.
|
|
2407
2612
|
if (rawId !== undefined && outputName !== undefined && variableTasks.length === 1) {
|
|
2408
2613
|
const only = variableTasks[0];
|
|
2409
2614
|
return { kind: "variableParamRef", varTask: only.refKey, name: only.varName };
|
|
@@ -2758,7 +2963,7 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
2758
2963
|
args.filter = decodeFilter(value, ctx, FILTER_FIELD_SCOPE_BY_FACTORY[factory] ?? "app");
|
|
2759
2964
|
continue;
|
|
2760
2965
|
}
|
|
2761
|
-
if (attr === "fields" && (factory === "createRecord" || factory === "updateField")) {
|
|
2966
|
+
if (attr === "fields" && (factory === "createRecord" || factory === "updateField" || factory === "bulkUpdateFields")) {
|
|
2762
2967
|
if (!Array.isArray(value))
|
|
2763
2968
|
throw new EntityTfError(`${block.type}.${block.label}: fields must be an array`);
|
|
2764
2969
|
const values = {};
|
|
@@ -2776,21 +2981,31 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
2776
2981
|
const fieldKey = field.kind === "field"
|
|
2777
2982
|
? field.fieldKey
|
|
2778
2983
|
: `${UNRESOLVED_FIELD_MARKER}${field.uuid}`;
|
|
2779
|
-
const decodedValue = decodeFieldAssignmentValue(item.value, ctx);
|
|
2984
|
+
const decodedValue = decodeFieldAssignmentValue(item.value, ctx, taskDiagnostics, `${block.type}.${block.label} field ${field.kind === "field" ? field.fieldKey : field.uuid}`);
|
|
2780
2985
|
const foreignInfo = field.kind === "field" && field.foreign !== undefined
|
|
2781
2986
|
? {
|
|
2782
2987
|
foreignFieldName: field.foreign.fieldName,
|
|
2783
2988
|
foreignEntityType: field.foreign.entityType,
|
|
2784
2989
|
foreignOwnerName: field.foreign.name,
|
|
2990
|
+
...(field.foreign.namespace !== undefined ? { foreignOwnerNamespace: field.foreign.namespace } : {}),
|
|
2785
2991
|
...(field.foreign.fieldType !== undefined ? { foreignFieldType: field.foreign.fieldType } : {}),
|
|
2786
2992
|
}
|
|
2787
2993
|
: undefined;
|
|
2788
|
-
|
|
2994
|
+
// State can rename a foreign system-field id (Title) to its key
|
|
2995
|
+
// without a field type. The target aspect may still be outside this
|
|
2996
|
+
// workspace, and a bare key then prints as null and the file will
|
|
2997
|
+
// not load. Keep the platform id so the printer can emit
|
|
2998
|
+
// unsafePlatformId, which is what an element-only pull already does.
|
|
2999
|
+
const platformFieldId = typeof item.field_id === "string" && isUuid(item.field_id) && field.kind === "field" && field.fieldKey !== item.field_id
|
|
3000
|
+
? item.field_id
|
|
3001
|
+
: undefined;
|
|
3002
|
+
values[fieldKey] = item.update_mode === "add" || foreignInfo !== undefined || platformFieldId !== undefined
|
|
2789
3003
|
? {
|
|
2790
3004
|
__fieldAssignment: true,
|
|
2791
3005
|
value: decodedValue,
|
|
2792
3006
|
...(item.update_mode === "add" ? { updateMode: "add" } : {}),
|
|
2793
3007
|
...(foreignInfo !== undefined ? foreignInfo : {}),
|
|
3008
|
+
...(platformFieldId !== undefined ? { platformFieldId } : {}),
|
|
2794
3009
|
}
|
|
2795
3010
|
: decodedValue;
|
|
2796
3011
|
}
|
|
@@ -2833,7 +3048,15 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
2833
3048
|
fields.push({ alias: mapping.alias, field: fieldRef(mapping.field_id, ctx) });
|
|
2834
3049
|
}
|
|
2835
3050
|
if (fields.length > 0) {
|
|
2836
|
-
|
|
3051
|
+
// A record trigger's whole record exports as its reference JSON,
|
|
3052
|
+
// because refs["Record"] is the record ID (edk#1284). Field
|
|
3053
|
+
// mappings make it `ctx.trigger.record` again; build restores
|
|
3054
|
+
// the JSON (TRIGGER_WHOLE_RECORD_MARKER).
|
|
3055
|
+
const wholeRecord = parseTriggerWholeRecordRefJson(item.value);
|
|
3056
|
+
const value = wholeRecord === TRIGGER_WHOLE_RECORD_REF_NAME && ctx.trigger.type !== "elementum_on_demand_trigger"
|
|
3057
|
+
? { kind: "triggerRef", path: [TRIGGER_WHOLE_RECORD_REF_NAME] }
|
|
3058
|
+
: decodedValue;
|
|
3059
|
+
return [item.name, { __edkExecuteScriptListInput: true, value, fields }];
|
|
2837
3060
|
}
|
|
2838
3061
|
}
|
|
2839
3062
|
return [item.name, decodedValue];
|
|
@@ -2844,8 +3067,8 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
2844
3067
|
const raw = isTfExpr(value) && value.$expr === "jsonencode" ? value.value : value;
|
|
2845
3068
|
const root = isObject(raw) && isObject(raw.object) ? raw.object : undefined;
|
|
2846
3069
|
const props = Array.isArray(root?.properties) ? root.properties : [];
|
|
2847
|
-
//
|
|
2848
|
-
//
|
|
3070
|
+
// Export and import collapse an identical repeat of a property, but keep
|
|
3071
|
+
// a name listed twice with different shapes. The public `outputs`
|
|
2849
3072
|
// option is keyed by name and cannot carry the repeat, so keep the
|
|
2850
3073
|
// FIRST occurrence (position and type) and report the collapse: the
|
|
2851
3074
|
// rebuilt schema no longer matches live. The provider refreshes
|
|
@@ -2967,6 +3190,17 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
2967
3190
|
});
|
|
2968
3191
|
continue;
|
|
2969
3192
|
}
|
|
3193
|
+
if (attr === "output_mappings" && factory === "runAutomation") {
|
|
3194
|
+
if (!Array.isArray(value))
|
|
3195
|
+
throw new EntityTfError(`${block.type}.${block.label}: output_mappings must be an array`);
|
|
3196
|
+
args.outputs = value.map((item) => {
|
|
3197
|
+
if (!isObject(item) || typeof item.name !== "string") {
|
|
3198
|
+
throw new EntityTfError(`${block.type}.${block.label}: invalid output mapping`);
|
|
3199
|
+
}
|
|
3200
|
+
return item.name;
|
|
3201
|
+
});
|
|
3202
|
+
continue;
|
|
3203
|
+
}
|
|
2970
3204
|
// `file_reader_id` resolves to a real `documentModel` RefExpr only
|
|
2971
3205
|
// through decodeValue's resource-attr branch (an implemented reader
|
|
2972
3206
|
// type's own resource block in this export). When ei instead emits a
|
|
@@ -3100,7 +3334,7 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
3100
3334
|
continue;
|
|
3101
3335
|
}
|
|
3102
3336
|
if (attr === "list" && factory === "forEach") {
|
|
3103
|
-
args.collection =
|
|
3337
|
+
args.collection = decodeValueOrStringifiedRef(value, ctx, taskDiagnostics, `${block.type}.${block.label} list`);
|
|
3104
3338
|
continue;
|
|
3105
3339
|
}
|
|
3106
3340
|
if (attr === "code" && factory === "executeScript") {
|
|
@@ -3181,7 +3415,7 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
3181
3415
|
// the wire (relate_to_record_reference) - its presence alone implies
|
|
3182
3416
|
// relateToRecord: true (the provider has no separate boolean attribute).
|
|
3183
3417
|
if (attr === "relate_to_record_reference" && factory === "createRecord") {
|
|
3184
|
-
args.record =
|
|
3418
|
+
args.record = decodeValueOrStringifiedRef(value, ctx, taskDiagnostics, `${block.type}.${block.label} relate_to_record_reference`);
|
|
3185
3419
|
args.relateToRecord = true;
|
|
3186
3420
|
continue;
|
|
3187
3421
|
}
|
|
@@ -3207,11 +3441,25 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
3207
3441
|
if (!isObject(value))
|
|
3208
3442
|
throw new EntityTfError(`${block.type}.${block.label}: basic_auth must be an object`);
|
|
3209
3443
|
args.basicAuth = {
|
|
3210
|
-
|
|
3444
|
+
// reference_username is a vault-bound username; it authors back as
|
|
3445
|
+
// username: secret("KEY") (edk#1283).
|
|
3446
|
+
username: decodeValue((value.reference_username ?? value.username_wo ?? value.username), ctx),
|
|
3211
3447
|
...(value.reference_password !== undefined ? { referencePassword: decodeValue(value.reference_password, ctx) } : {}),
|
|
3212
3448
|
};
|
|
3213
3449
|
continue;
|
|
3214
3450
|
}
|
|
3451
|
+
if (attr === "headers" && factory === "apiRequest" && Array.isArray(value)) {
|
|
3452
|
+
// value_wo (write-only, edk#1400) authors back as the header's value.
|
|
3453
|
+
args.headers = value.map((h) => {
|
|
3454
|
+
if (!isObject(h))
|
|
3455
|
+
throw new EntityTfError(`${block.type}.${block.label}: invalid header`);
|
|
3456
|
+
return {
|
|
3457
|
+
name: decodeValue(h.name, ctx),
|
|
3458
|
+
value: decodeValue((h.value_wo ?? h.value), ctx),
|
|
3459
|
+
};
|
|
3460
|
+
});
|
|
3461
|
+
continue;
|
|
3462
|
+
}
|
|
3215
3463
|
if (attr === "bearer_auth" && factory === "apiRequest") {
|
|
3216
3464
|
if (!isObject(value))
|
|
3217
3465
|
throw new EntityTfError(`${block.type}.${block.label}: bearer_auth must be an object`);
|
|
@@ -3234,8 +3482,14 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
3234
3482
|
args.oauth = {
|
|
3235
3483
|
requestType: value.request_type,
|
|
3236
3484
|
...(value.url !== undefined ? { url: decodeValue(value.url, ctx) } : {}),
|
|
3237
|
-
|
|
3238
|
-
|
|
3485
|
+
// reference_client_id/reference_client_secret are vault-bound and
|
|
3486
|
+
// author back as secret("KEY") (edk#1283).
|
|
3487
|
+
...(value.reference_client_id !== undefined
|
|
3488
|
+
? { clientId: decodeValue(value.reference_client_id, ctx) }
|
|
3489
|
+
: value.client_id !== undefined ? { clientId: value.client_id } : {}),
|
|
3490
|
+
...(value.reference_client_secret !== undefined
|
|
3491
|
+
? { clientSecret: decodeValue(value.reference_client_secret, ctx) }
|
|
3492
|
+
: value.client_secret !== undefined ? { clientSecret: value.client_secret } : {}),
|
|
3239
3493
|
...(headers !== undefined ? { headers } : {}),
|
|
3240
3494
|
};
|
|
3241
3495
|
continue;
|
|
@@ -3294,9 +3548,11 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
3294
3548
|
continue;
|
|
3295
3549
|
}
|
|
3296
3550
|
const arg = ATTR_TO_ARG[attr] ?? attr.replace(/_([a-z])/g, (_, char) => char.toUpperCase());
|
|
3297
|
-
args[arg] =
|
|
3551
|
+
args[arg] = (attr === "record_reference" || attr === "record_id") && (factory === "createRecord" || factory === "updateField")
|
|
3552
|
+
? decodeValueOrStringifiedRef(value, ctx, taskDiagnostics, `${block.type}.${block.label} ${attr}`)
|
|
3553
|
+
: decodeValue(value, ctx);
|
|
3298
3554
|
}
|
|
3299
|
-
if (["recordSearch", "createRecord", "updateField"].includes(factory))
|
|
3555
|
+
if (["recordSearch", "createRecord", "updateField", "bulkUpdateFields"].includes(factory))
|
|
3300
3556
|
args.app ??= appRef(ctx.appRefName);
|
|
3301
3557
|
if (factory === "findRelatedRecords") {
|
|
3302
3558
|
args.relatedApp = args.app ?? appRef(ctx.appRefName);
|
|
@@ -3315,15 +3571,28 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
3315
3571
|
}
|
|
3316
3572
|
}
|
|
3317
3573
|
if (factory === "setVariable") {
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3574
|
+
// edk#1456: elementum_variable_task carries `variables` (creates) and
|
|
3575
|
+
// optionally `updates`; elementum_update_variable_task carries `updates`.
|
|
3576
|
+
// The provider's update attribute is variable_reference; the AST/authoring
|
|
3577
|
+
// key stays "variable" (SetVariableOptions.update[].variable).
|
|
3578
|
+
const create = block.type === "elementum_variable_task"
|
|
3579
|
+
? variableTaskEntries(block).map((entry) => ({
|
|
3580
|
+
name: entry.name,
|
|
3581
|
+
type: entry.type,
|
|
3582
|
+
...(entry.value !== undefined ? { value: decodeValue(entry.value, ctx) } : {}),
|
|
3583
|
+
}))
|
|
3584
|
+
: [];
|
|
3585
|
+
if (block.type === "elementum_variable_task" && create.length === 0)
|
|
3586
|
+
throw new EntityTfError("variable task is incomplete");
|
|
3587
|
+
const rawUpdates = Array.isArray(block.attrs.updates) ? block.attrs.updates : [];
|
|
3588
|
+
const update = rawUpdates.map((item) => {
|
|
3589
|
+
if (!isObject(item))
|
|
3590
|
+
throw new EntityTfError("variable task update is incomplete");
|
|
3591
|
+
return { variable: decodeValue(item.variable_reference, ctx), value: decodeValue(item.value, ctx) };
|
|
3592
|
+
});
|
|
3593
|
+
if (create.length === 0 && update.length === 0)
|
|
3594
|
+
throw new EntityTfError("update variable task is incomplete");
|
|
3595
|
+
return { ...(create.length > 0 ? { create } : {}), ...(update.length > 0 ? { update } : {}) };
|
|
3327
3596
|
}
|
|
3328
3597
|
return args;
|
|
3329
3598
|
}
|
|
@@ -3398,12 +3667,11 @@ function taskRefKey(block, automationLabel, appTfLabel) {
|
|
|
3398
3667
|
// keys them by the variable they create. Restrict this reconciliation to
|
|
3399
3668
|
// that positional export shape: named tasks such as "set_variable_task"
|
|
3400
3669
|
// remain valid action identities used by workflow outputs.
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
block.attrs.variable_name !== "" &&
|
|
3670
|
+
const soleVariable = soleVariableName(block);
|
|
3671
|
+
if (soleVariable !== undefined &&
|
|
3404
3672
|
/(?:\s|-)\d+$/.test(taskName.trim()) &&
|
|
3405
3673
|
(sanitized === tail || sanitized === `_${tail}`)) {
|
|
3406
|
-
return
|
|
3674
|
+
return soleVariable;
|
|
3407
3675
|
}
|
|
3408
3676
|
// ei sanitizes `<automation>_<task>` as ONE combined string
|
|
3409
3677
|
// (imports.go), so the digit-leading guard only ever sees the
|
|
@@ -3442,7 +3710,8 @@ export function automationOwnedAddresses(doc, automationLabel) {
|
|
|
3442
3710
|
const owned = new Set([`${AUTOMATION_RESOURCE_TYPE}.${automationLabel}`]);
|
|
3443
3711
|
for (const block of doc.blocks) {
|
|
3444
3712
|
if (block.kind === "resource" && block.type !== undefined && block.label !== undefined &&
|
|
3445
|
-
references(block.attrs.automation, AUTOMATION_RESOURCE_TYPE, automationLabel)
|
|
3713
|
+
(references(block.attrs.automation, AUTOMATION_RESOURCE_TYPE, automationLabel) ||
|
|
3714
|
+
references(block.attrs.automation_id, AUTOMATION_RESOURCE_TYPE, automationLabel))) {
|
|
3446
3715
|
owned.add(`${block.type}.${block.label}`);
|
|
3447
3716
|
}
|
|
3448
3717
|
}
|
|
@@ -3464,30 +3733,61 @@ export function automationOwnedAddresses(doc, automationLabel) {
|
|
|
3464
3733
|
}
|
|
3465
3734
|
return [...owned];
|
|
3466
3735
|
}
|
|
3467
|
-
const
|
|
3468
|
-
/** Pull-only: computed
|
|
3736
|
+
const EDK_VARIABLE_IDS_LOCAL_PREFIX = "edk_variable_ids_";
|
|
3737
|
+
/** Pull-only: the computed variables[*].id cannot live on the resource config. */
|
|
3469
3738
|
function exportedVariableIdsByTaskLabel(doc) {
|
|
3470
3739
|
const ids = new Map();
|
|
3471
3740
|
for (const block of doc.blocks) {
|
|
3472
3741
|
if (block.kind !== "locals")
|
|
3473
3742
|
continue;
|
|
3474
3743
|
for (const [key, value] of Object.entries(block.attrs)) {
|
|
3475
|
-
if (key.startsWith(
|
|
3476
|
-
ids.set(key.slice(
|
|
3744
|
+
if (key.startsWith(EDK_VARIABLE_IDS_LOCAL_PREFIX) && Array.isArray(value)) {
|
|
3745
|
+
ids.set(key.slice(EDK_VARIABLE_IDS_LOCAL_PREFIX.length), value.map((id) => (typeof id === "string" ? id : "")));
|
|
3477
3746
|
}
|
|
3478
3747
|
}
|
|
3479
3748
|
}
|
|
3480
3749
|
return ids;
|
|
3481
3750
|
}
|
|
3751
|
+
/** Hydrates each exported variable id onto its `variables` entry, by position. */
|
|
3482
3752
|
function withExportedVariableId(block, ids) {
|
|
3483
|
-
if (block.type !== "elementum_variable_task" || block.label === undefined)
|
|
3484
|
-
return block;
|
|
3485
|
-
if (typeof block.attrs.variable_id === "string" && block.attrs.variable_id !== "")
|
|
3753
|
+
if (block.type !== "elementum_variable_task" || block.label === undefined || !Array.isArray(block.attrs.variables))
|
|
3486
3754
|
return block;
|
|
3487
3755
|
const exported = ids.get(block.label);
|
|
3488
3756
|
if (exported === undefined)
|
|
3489
3757
|
return block;
|
|
3490
|
-
|
|
3758
|
+
const variables = block.attrs.variables.map((entry, index) => {
|
|
3759
|
+
const id = exported[index];
|
|
3760
|
+
if (!isObject(entry))
|
|
3761
|
+
return entry;
|
|
3762
|
+
const object = entry;
|
|
3763
|
+
if (id === undefined || id === "" || (typeof object.id === "string" && object.id !== ""))
|
|
3764
|
+
return entry;
|
|
3765
|
+
return { ...object, id };
|
|
3766
|
+
});
|
|
3767
|
+
return { ...block, attrs: { ...block.attrs, variables } };
|
|
3768
|
+
}
|
|
3769
|
+
/** The created variables of an elementum_variable_task block, in order (edk#1456). */
|
|
3770
|
+
function variableTaskEntries(block) {
|
|
3771
|
+
if (block.type !== "elementum_variable_task" || !Array.isArray(block.attrs.variables))
|
|
3772
|
+
return [];
|
|
3773
|
+
return block.attrs.variables.flatMap((entry) => {
|
|
3774
|
+
if (!isObject(entry) || typeof entry.name !== "string" || typeof entry.type !== "string") {
|
|
3775
|
+
throw new EntityTfError(`${block.type}.${block.label}: variable entry is incomplete`);
|
|
3776
|
+
}
|
|
3777
|
+
return [{
|
|
3778
|
+
name: entry.name,
|
|
3779
|
+
type: entry.type,
|
|
3780
|
+
...(entry.value !== undefined && entry.value !== null ? { value: entry.value } : {}),
|
|
3781
|
+
...(typeof entry.id === "string" && entry.id !== "" ? { id: entry.id } : {}),
|
|
3782
|
+
}];
|
|
3783
|
+
});
|
|
3784
|
+
}
|
|
3785
|
+
/** The variable name of a variable task that creates exactly one variable. */
|
|
3786
|
+
function soleVariableName(block) {
|
|
3787
|
+
if (block.type !== "elementum_variable_task" || !Array.isArray(block.attrs.variables) || block.attrs.variables.length !== 1)
|
|
3788
|
+
return undefined;
|
|
3789
|
+
const entry = block.attrs.variables[0];
|
|
3790
|
+
return isObject(entry) && typeof entry.name === "string" && entry.name !== "" ? entry.name : undefined;
|
|
3491
3791
|
}
|
|
3492
3792
|
/**
|
|
3493
3793
|
* #1320: a task may read the current item of a loop that ENCLOSES it - the
|
|
@@ -3611,8 +3911,8 @@ export class ForEachItemOutsideLoopError extends EntityTfError {
|
|
|
3611
3911
|
this.name = "ForEachItemOutsideLoopError";
|
|
3612
3912
|
}
|
|
3613
3913
|
}
|
|
3614
|
-
/** Extract one app-owned automation graph from an ei
|
|
3615
|
-
function automationFromTfDocument(doc, automationLabel, appRefName, foreignFieldRefsById, foreignFieldRefsByDataAddress, foreignTableRefsById, picklistOptionLabelById, fieldNamesByOwnerRefName, foreignAppRefNames, foreignElementRefNames, procedureKeysByDiscriminator, foreignTaskRefNames) {
|
|
3914
|
+
/** Extract one app- or element-owned automation graph from an ei export. */
|
|
3915
|
+
function automationFromTfDocument(doc, automationLabel, appRefName, foreignFieldRefsById, foreignFieldRefsByDataAddress, foreignTableRefsById, picklistOptionLabelById, fieldNamesByOwnerRefName, foreignAppRefNames, foreignElementRefNames, procedureKeysByDiscriminator, foreignTaskRefNames, groupKeysByName) {
|
|
3616
3916
|
const automation = doc.blocks.find((block) => block.kind === "resource" && block.type === AUTOMATION_RESOURCE_TYPE && block.label === automationLabel);
|
|
3617
3917
|
if (automation === undefined)
|
|
3618
3918
|
throw new EntityTfError(`automation resource "${automationLabel}" not found`);
|
|
@@ -3626,8 +3926,12 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
3626
3926
|
}
|
|
3627
3927
|
assertAllowed(automation, new Set(["app_id", "name", "description", "status", "triggers_other_automations", "service_account_id", "depends_on"]));
|
|
3628
3928
|
const app = resourceRef(automation.attrs.app_id);
|
|
3629
|
-
if (app === undefined ||
|
|
3630
|
-
|
|
3929
|
+
if (app === undefined ||
|
|
3930
|
+
app.path[0] !== "id" ||
|
|
3931
|
+
(app.type !== "elementum_app" && app.type !== "elementum_element")) {
|
|
3932
|
+
throw new EntityTfError(`${AUTOMATION_RESOURCE_TYPE}.${automationLabel}: app_id is not an app or element reference`);
|
|
3933
|
+
}
|
|
3934
|
+
const ownerScope = app.type === "elementum_element" ? "element" : "app";
|
|
3631
3935
|
const publish = doc.blocks.find((block) => block.kind === "resource" && block.type === WORKFLOW_PUBLISH_RESOURCE_TYPE && references(block.attrs.automation, AUTOMATION_RESOURCE_TYPE, automationLabel));
|
|
3632
3936
|
const unknownDirectChild = doc.blocks.find((block) => block.kind === "resource" &&
|
|
3633
3937
|
references(block.attrs.automation, AUTOMATION_RESOURCE_TYPE, automationLabel) &&
|
|
@@ -3744,9 +4048,7 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
3744
4048
|
const dataBlocks = new Map(doc.blocks.filter((block) => block.kind === "data" && block.type && block.label).map((block) => [`${block.type}.${block.label}`, block]));
|
|
3745
4049
|
const taskByAddress = new Map(tasks.map((block) => [`${block.type}.${block.label}`, { block, refKey: taskRefKey(block, automationLabel, appTfLabel) }]));
|
|
3746
4050
|
const adoptionAddressAliases = [...taskByAddress.entries()].flatMap(([from, { block, refKey }]) => {
|
|
3747
|
-
if (block
|
|
3748
|
-
typeof block.attrs.variable_name !== "string" ||
|
|
3749
|
-
block.attrs.variable_name === "")
|
|
4051
|
+
if (soleVariableName(block) === undefined)
|
|
3750
4052
|
return [];
|
|
3751
4053
|
const to = `${block.type}.${taskTfLabel(automationLabel, refKey)}`;
|
|
3752
4054
|
return to === from ? [] : [{ from, to }];
|
|
@@ -3777,8 +4079,11 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
3777
4079
|
const block = resourceBlocks.get(address);
|
|
3778
4080
|
if (block?.type?.endsWith("_field") !== true || block.label === undefined)
|
|
3779
4081
|
continue;
|
|
4082
|
+
const ownedField = ownerFromScopedChildLabel(block.label);
|
|
3780
4083
|
fieldById.set(id, {
|
|
3781
|
-
key:
|
|
4084
|
+
key: ownedField !== undefined
|
|
4085
|
+
? scopedLabelToBagKey(ownedField.ownerTfLabel, block.label, ownedField.scope)
|
|
4086
|
+
: scopedLabelToBagKey(appTfLabel, block.label, ownerScope),
|
|
3782
4087
|
name: typeof block.attrs.name === "string" ? block.attrs.name : block.label,
|
|
3783
4088
|
resourceType: block.type,
|
|
3784
4089
|
});
|
|
@@ -3794,6 +4099,7 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
3794
4099
|
const ctx = {
|
|
3795
4100
|
appRefName,
|
|
3796
4101
|
appTfLabel: app.label,
|
|
4102
|
+
ownerScope,
|
|
3797
4103
|
trigger,
|
|
3798
4104
|
taskByAddress,
|
|
3799
4105
|
resourceBlocks,
|
|
@@ -3812,6 +4118,7 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
3812
4118
|
...(foreignElementRefNames !== undefined && { foreignElementRefNames }),
|
|
3813
4119
|
...(foreignTaskRefNames !== undefined && { foreignTaskRefNames }),
|
|
3814
4120
|
...(procedureKeysByDiscriminator !== undefined && { procedureKeysByDiscriminator }),
|
|
4121
|
+
...(groupKeysByName !== undefined && { groupKeysByName }),
|
|
3815
4122
|
};
|
|
3816
4123
|
let serviceAccountName;
|
|
3817
4124
|
const serviceAccountValue = automation.attrs.service_account_id;
|
|
@@ -4027,15 +4334,16 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
4027
4334
|
}),
|
|
4028
4335
|
};
|
|
4029
4336
|
}
|
|
4030
|
-
export function automationFromTf(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth) {
|
|
4337
|
+
export function automationFromTf(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth) {
|
|
4031
4338
|
if (Array.isArray(first)) {
|
|
4032
4339
|
const ctx = second;
|
|
4033
4340
|
const automationBlock = first.find((block) => block.kind === "resource" && block.type === AUTOMATION_RESOURCE_TYPE);
|
|
4034
4341
|
if (automationBlock?.label === undefined) {
|
|
4035
|
-
|
|
4342
|
+
const addresses = first.filter((block) => block.kind === "resource").map((block) => `${block.type}.${block.label}`);
|
|
4343
|
+
throw new EntityTfError(`automation graph has no ${AUTOMATION_RESOURCE_TYPE} resource, so its resources (${addresses.join(", ") || "none"}) cannot be pulled`);
|
|
4036
4344
|
}
|
|
4037
4345
|
try {
|
|
4038
|
-
const result = automationFromTfDocument({ blocks: [...first] }, automationBlock.label, ctx.ownerHandle, ctx.foreignFieldRefsById, ctx.foreignFieldRefsByDataAddress, ctx.foreignTableRefsById, ctx.picklistOptionLabelById, ctx.fieldNamesByOwnerRefName, ctx.foreignAppRefNames, ctx.foreignElementRefNames, ctx.procedureKeysByDiscriminator, ctx.foreignTaskRefNames);
|
|
4346
|
+
const result = automationFromTfDocument({ blocks: [...first] }, automationBlock.label, ctx.ownerHandle, ctx.foreignFieldRefsById, ctx.foreignFieldRefsByDataAddress, ctx.foreignTableRefsById, ctx.picklistOptionLabelById, ctx.fieldNamesByOwnerRefName, ctx.foreignAppRefNames, ctx.foreignElementRefNames, ctx.procedureKeysByDiscriminator, ctx.foreignTaskRefNames, ctx.groupKeysByName);
|
|
4039
4347
|
if (result.diagnostics)
|
|
4040
4348
|
ctx.diagnostics.push(...result.diagnostics);
|
|
4041
4349
|
return { automation: result.ast };
|
|
@@ -4048,5 +4356,5 @@ export function automationFromTf(first, second, third, fourth, fifth, sixth, sev
|
|
|
4048
4356
|
return { skippedReason: message };
|
|
4049
4357
|
}
|
|
4050
4358
|
}
|
|
4051
|
-
return automationFromTfDocument(first, second, third ?? "", fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth);
|
|
4359
|
+
return automationFromTfDocument(first, second, third ?? "", fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth);
|
|
4052
4360
|
}
|