@elementumai/edk 0.12.0 → 0.13.1
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 +8 -2
- package/dist-sdk/src/catalog/factories.d.ts +7 -1
- package/dist-sdk/src/catalog/factories.js +10 -2
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +1 -1
- package/dist-sdk/src/catalog/org.js +79 -34
- package/dist-sdk/src/catalog/token.js +5 -0
- package/dist-sdk/src/catalog/types.d.ts +12 -1
- package/dist-sdk/src/catalog/types.js +3 -0
- package/dist-sdk/src/core/system-fields.d.ts +1 -1
- package/dist-sdk/src/core/system-fields.js +1 -1
- package/dist-sdk/src/core/types/app.d.ts +6 -0
- package/dist-sdk/src/engine/build/context.d.ts +3 -0
- package/dist-sdk/src/engine/coverage-gaps.d.ts +2 -0
- package/dist-sdk/src/engine/coverage-gaps.js +4 -0
- package/dist-sdk/src/engine/ei/run.d.ts +8 -0
- package/dist-sdk/src/engine/ei/run.js +46 -7
- package/dist-sdk/src/engine/pull/authored-address.js +42 -6
- package/dist-sdk/src/engine/pull/authored-root.d.ts +88 -0
- package/dist-sdk/src/engine/pull/authored-root.js +306 -0
- package/dist-sdk/src/engine/pull/context.d.ts +34 -0
- package/dist-sdk/src/engine/pull/field-refs-registry.d.ts +114 -0
- package/dist-sdk/src/engine/pull/field-refs-registry.js +501 -0
- package/dist-sdk/src/engine/pull/org.d.ts +1 -0
- package/dist-sdk/src/engine/pull/org.js +2 -0
- package/dist-sdk/src/engine/pull/partition.d.ts +8 -0
- package/dist-sdk/src/engine/pull/partition.js +43 -0
- package/dist-sdk/src/engine/pull/pulled-roots.d.ts +89 -0
- package/dist-sdk/src/engine/pull/pulled-roots.js +203 -0
- package/dist-sdk/src/engine/pull/ref-only.d.ts +4 -0
- package/dist-sdk/src/engine/pull/ref-only.js +7 -1
- package/dist-sdk/src/engine/pull/source-resources.d.ts +39 -0
- package/dist-sdk/src/engine/pull/source-resources.js +110 -0
- package/dist-sdk/src/engine/pull/stream-root.d.ts +159 -0
- package/dist-sdk/src/engine/pull/stream-root.js +579 -0
- package/dist-sdk/src/engine/workspace/authoring-layout.js +16 -2
- package/dist-sdk/src/engine/workspace/reserved-catalog-keys.d.ts +47 -0
- package/dist-sdk/src/engine/workspace/reserved-catalog-keys.js +115 -0
- package/dist-sdk/src/entities/access-policy/build.d.ts +2 -1
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +7 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +17 -5
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +19 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +65 -8
- package/dist-sdk/src/entities/agent/build.d.ts +52 -1
- package/dist-sdk/src/entities/agent/build.js +34 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +70 -1
- package/dist-sdk/src/entities/agent/from-tf.d.ts +36 -1
- package/dist-sdk/src/entities/agent/from-tf.js +289 -2
- package/dist-sdk/src/entities/agent/index.d.ts +1 -1
- package/dist-sdk/src/entities/agent/module.js +1 -0
- package/dist-sdk/src/entities/agent/to-tf.d.ts +11 -11
- package/dist-sdk/src/entities/agent/to-tf.js +179 -17
- package/dist-sdk/src/entities/agent-tool/from-tf.js +6 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +2 -2
- package/dist-sdk/src/entities/app/build.d.ts +33 -13
- package/dist-sdk/src/entities/app/build.js +14 -12
- package/dist-sdk/src/entities/app/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/app/from-tf.js +7 -9
- package/dist-sdk/src/entities/app/index.d.ts +1 -0
- package/dist-sdk/src/entities/app/index.js +1 -0
- package/dist-sdk/src/entities/app/module.js +3 -0
- package/dist-sdk/src/entities/app/stage-keys.d.ts +2 -2
- package/dist-sdk/src/entities/app/stage-keys.js +3 -3
- package/dist-sdk/src/entities/app/to-tf.js +1 -0
- package/dist-sdk/src/entities/approval-chain/build.d.ts +46 -11
- package/dist-sdk/src/entities/approval-chain/build.js +120 -8
- package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +24 -2
- package/dist-sdk/src/entities/approval-chain/from-tf.js +148 -6
- package/dist-sdk/src/entities/approval-chain/index.d.ts +4 -1
- package/dist-sdk/src/entities/approval-chain/index.js +4 -1
- package/dist-sdk/src/entities/approval-chain/module.js +23 -5
- package/dist-sdk/src/entities/approval-chain/printer.d.ts +1 -1
- package/dist-sdk/src/entities/approval-chain/printer.js +91 -5
- package/dist-sdk/src/entities/approval-chain/steps-tf.d.ts +77 -0
- package/dist-sdk/src/entities/approval-chain/steps-tf.js +255 -0
- package/dist-sdk/src/entities/approval-chain/steps.d.ts +71 -0
- package/dist-sdk/src/entities/approval-chain/steps.js +83 -0
- package/dist-sdk/src/entities/approval-chain/to-tf.d.ts +16 -6
- package/dist-sdk/src/entities/approval-chain/to-tf.js +37 -4
- package/dist-sdk/src/entities/automation/build.d.ts +10 -1
- package/dist-sdk/src/entities/automation/build.js +70 -27
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +21 -5
- package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -5
- package/dist-sdk/src/entities/automation/from-tf.js +665 -112
- package/dist-sdk/src/entities/automation/index.d.ts +2 -1
- package/dist-sdk/src/entities/automation/index.js +1 -0
- package/dist-sdk/src/entities/automation/module.d.ts +4 -3
- package/dist-sdk/src/entities/automation/module.js +45 -12
- package/dist-sdk/src/entities/automation/refs-read.d.ts +19 -0
- package/dist-sdk/src/entities/automation/refs-read.js +48 -0
- package/dist-sdk/src/entities/automation/slack-message-refs.d.ts +9 -0
- package/dist-sdk/src/entities/automation/slack-message-refs.js +75 -0
- package/dist-sdk/src/entities/automation/system-ref-name.d.ts +23 -3
- package/dist-sdk/src/entities/automation/system-ref-name.js +86 -4
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +11 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +23 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +29 -4
- package/dist-sdk/src/entities/automation/tasks.js +34 -11
- package/dist-sdk/src/entities/automation/to-tf.d.ts +8 -1
- package/dist-sdk/src/entities/automation/to-tf.js +563 -103
- package/dist-sdk/src/entities/automation/triggers.d.ts +0 -8
- package/dist-sdk/src/entities/automation/triggers.js +26 -11
- package/dist-sdk/src/entities/automation/unsafe-script-output.d.ts +50 -0
- package/dist-sdk/src/entities/automation/unsafe-script-output.js +92 -0
- package/dist-sdk/src/entities/chart/build.d.ts +9 -1
- package/dist-sdk/src/entities/chart/from-tf.js +3 -0
- package/dist-sdk/src/entities/chart/to-tf.js +19 -2
- package/dist-sdk/src/entities/dashboard/from-tf.d.ts +3 -1
- package/dist-sdk/src/entities/dashboard/from-tf.js +42 -2
- package/dist-sdk/src/entities/dashboard/to-tf.js +9 -1
- package/dist-sdk/src/entities/dashboard-widget-order/module.d.ts +10 -0
- package/dist-sdk/src/entities/dashboard-widget-order/module.js +25 -0
- package/dist-sdk/src/entities/dashboard-widget-order/order.d.ts +31 -0
- package/dist-sdk/src/entities/dashboard-widget-order/order.js +102 -0
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +2 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +44 -5
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +46 -12
- package/dist-sdk/src/entities/element/audit-field-guard.d.ts +9 -0
- package/dist-sdk/src/entities/element/audit-field-guard.js +88 -0
- package/dist-sdk/src/entities/element/build.js +2 -1
- package/dist-sdk/src/entities/element/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/element/from-tf.js +4 -7
- package/dist-sdk/src/entities/element/module.js +5 -0
- package/dist-sdk/src/entities/element/system-fields.d.ts +13 -0
- package/dist-sdk/src/entities/element/system-fields.js +23 -0
- package/dist-sdk/src/entities/element/to-tf.js +1 -0
- package/dist-sdk/src/entities/field/build.d.ts +9 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +52 -1
- package/dist-sdk/src/entities/field/from-tf.js +212 -14
- package/dist-sdk/src/entities/field/module.js +4 -0
- package/dist-sdk/src/entities/field/to-tf.d.ts +5 -1
- package/dist-sdk/src/entities/field/to-tf.js +33 -12
- package/dist-sdk/src/entities/org/category.js +1 -0
- package/dist-sdk/src/entities/org/index.d.ts +1 -0
- package/dist-sdk/src/entities/org/index.js +1 -0
- package/dist-sdk/src/entities/org/voice-auth.d.ts +5 -0
- package/dist-sdk/src/entities/org/voice-auth.js +33 -0
- package/dist-sdk/src/entities/organization/build.d.ts +3 -0
- package/dist-sdk/src/entities/organization/build.js +2 -0
- package/dist-sdk/src/entities/organization/index.d.ts +1 -0
- package/dist-sdk/src/entities/organization/index.js +1 -0
- package/dist-sdk/src/entities/organization/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/organization/to-tf.js +59 -1
- package/dist-sdk/src/entities/organization/voice-auth.d.ts +60 -0
- package/dist-sdk/src/entities/organization/voice-auth.js +60 -0
- package/dist-sdk/src/entities/phone-service/build.d.ts +9 -1
- package/dist-sdk/src/entities/phone-service/build.js +1 -0
- package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.js +3 -0
- package/dist-sdk/src/entities/phone-service/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/phone-service/from-tf.js +8 -1
- package/dist-sdk/src/entities/phone-service/to-tf.js +16 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.js +2 -2
- package/dist-sdk/src/entities/relationship/from-tf.js +9 -4
- package/dist-sdk/src/entities/relationship/module.js +2 -2
- package/dist-sdk/src/entities/relationship/pair-check.d.ts +6 -2
- package/dist-sdk/src/entities/relationship/pair-check.js +105 -18
- package/dist-sdk/src/entities/relationship/to-tf.js +5 -2
- package/dist-sdk/src/entities/role/build.d.ts +3 -4
- package/dist-sdk/src/entities/role/permission-levels.d.ts +7 -0
- package/dist-sdk/src/entities/role/permission-levels.js +78 -0
- package/dist-sdk/src/entities/role/to-tf.js +32 -2
- package/dist-sdk/src/entities/search-table/build.d.ts +9 -3
- package/dist-sdk/src/entities/search-table/build.js +4 -4
- package/dist-sdk/src/entities/search-table/printer.js +3 -1
- package/dist-sdk/src/entities/search-table/to-tf.js +20 -2
- package/dist-sdk/src/entities/service-account/module.d.ts +2 -1
- package/dist-sdk/src/entities/service-account/module.js +4 -1
- package/dist-sdk/src/entities/service-account/resource-type.d.ts +2 -0
- package/dist-sdk/src/entities/service-account/resource-type.js +2 -0
- package/dist-sdk/src/entities/service-account/role-membership-check.d.ts +20 -0
- package/dist-sdk/src/entities/service-account/role-membership-check.js +80 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +15 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +36 -0
- package/dist-sdk/src/entities/shared/context.d.ts +14 -1
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +97 -15
- package/dist-sdk/src/entities/shared/filters/index.js +30 -7
- package/dist-sdk/src/entities/shared/filters/option-lookups.d.ts +57 -0
- package/dist-sdk/src/entities/shared/filters/option-lookups.js +108 -0
- package/dist-sdk/src/entities/shared/filters/print.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/print.js +19 -6
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +16 -7
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +25 -5
- package/dist-sdk/src/entities/shared/filters/types.d.ts +4 -0
- package/dist-sdk/src/entities/shared/raw-option-id.d.ts +30 -0
- package/dist-sdk/src/entities/shared/raw-option-id.js +41 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +1 -1
- package/dist-sdk/src/entities/shared/tool-field-ref.js +3 -2
- package/dist-sdk/src/entities/skill/input-coverage.js +5 -2
- package/dist-sdk/src/entities/sla/build.d.ts +96 -0
- package/dist-sdk/src/entities/sla/build.js +124 -0
- package/dist-sdk/src/entities/sla/from-tf.d.ts +40 -0
- package/dist-sdk/src/entities/sla/from-tf.js +164 -0
- package/dist-sdk/src/entities/sla/index.d.ts +1 -0
- package/dist-sdk/src/entities/sla/index.js +1 -0
- package/dist-sdk/src/entities/sla/module.d.ts +4 -0
- package/dist-sdk/src/entities/sla/module.js +73 -0
- package/dist-sdk/src/entities/sla/printer.d.ts +2 -0
- package/dist-sdk/src/entities/sla/printer.js +84 -0
- package/dist-sdk/src/entities/sla/to-tf.d.ts +12 -0
- package/dist-sdk/src/entities/sla/to-tf.js +81 -0
- package/dist-sdk/src/entities/table/build.d.ts +7 -2
- package/dist-sdk/src/entities/table/build.js +22 -1
- package/dist-sdk/src/entities/table/deserializer/normalize.d.ts +4 -1
- package/dist-sdk/src/entities/table/from-tf.js +89 -14
- package/dist-sdk/src/entities/table/index.d.ts +1 -1
- package/dist-sdk/src/entities/table/to-tf.js +41 -2
- package/dist-sdk/src/entities/task/from-tf.js +3 -2
- package/dist-sdk/src/entities/view/custom-view-validate.d.ts +6 -4
- package/dist-sdk/src/entities/view/custom-view-validate.js +36 -18
- package/dist-sdk/src/entities/view/from-tf.js +16 -4
- package/dist-sdk/src/entities/view/to-tf.js +66 -47
- package/dist-sdk/src/entities/visual-flow/module.js +52 -1
- package/dist-sdk/src/entities/widget/from-tf.js +19 -8
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +49 -4
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +9 -0
- package/dist-sdk/src/graph/index.js +8 -0
- package/dist-sdk/src/graph/modules.js +13 -1
- package/dist-sdk/src/graph/resource-types.d.ts +47 -0
- package/dist-sdk/src/graph/resource-types.js +62 -0
- package/dist-sdk/src/graph/types.d.ts +113 -6
- package/package.json +7 -4
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { USER_FIELD_KEYS, USER_GROUP_FIELD_KEYS } from "../../catalog/types.js";
|
|
2
|
+
import { RECORD_ID_REFERENCE_FIELD } from "./task-output-labels.js";
|
|
2
3
|
import { DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES, SYSTEM_FIELD_KEY_SET, SYSTEM_FIELD_KEYS } from "../../core/system-fields.js";
|
|
3
4
|
import { normalizeOnDemandParamKey } from "../../../pull/util.js";
|
|
4
5
|
import { EntityTfError } from "../../engine/entity.js";
|
|
@@ -8,7 +9,7 @@ import { appResourceLabelPrefix, childPartFromScopedLabel, elementResourceLabelP
|
|
|
8
9
|
import { SUB_TYPE_BY_RESOURCE } from "../field/types.js";
|
|
9
10
|
import { IMPLEMENTED_FILE_READER_RESOURCE_TYPES } from "../file-reader/types.js";
|
|
10
11
|
import { connectorIdentityFromTf } from "../shared/connector-from-tf.js";
|
|
11
|
-
import { fieldTypeToValueType } from "../shared/filters/index.js";
|
|
12
|
+
import { fieldTypeToValueType, textOption } from "../shared/filters/index.js";
|
|
12
13
|
import { UNRESOLVED_FIELD_MARKER } from "../shared/ref.js";
|
|
13
14
|
import { filterFromTf as deserializeFilterFromTf } from "../shared/filters/tf-codec.js";
|
|
14
15
|
import { TABLE_RESOURCE_TYPE } from "../table/module.js";
|
|
@@ -16,10 +17,11 @@ import { SEARCH_TABLE_RESOURCE_TYPES } from "../search-table/types.js";
|
|
|
16
17
|
import { outputFieldTypesFromScriptSchema, repeatedScriptOutputNames, scriptOutputReferenceIsDeclared } from "./output-field-types.js";
|
|
17
18
|
import { apiTaskRefAuthoringPath, executeScriptAuthoringPath, matchesOutputWireKey, OUTPUT_KEY_WIRE_NAME } from "./output-key-wire-name.js";
|
|
18
19
|
import { RESOURCE_TYPE_TO_EXECUTOR, TASK_OUTPUT_CONTRACTS } from "./generated/task-output-contracts.js";
|
|
19
|
-
import { systemRefNameRoundTrips } from "./system-ref-name.js";
|
|
20
|
+
import { auditRefNeedsProviderAlias, systemRefNameRoundTrips } from "./system-ref-name.js";
|
|
20
21
|
import { taskTfLabel } from "./task-label.js";
|
|
21
22
|
import { parseTriggerAttachmentPayloadRefJson, parseTriggerWholeRecordRefJson, TASK_OUTPUT_REFERENCE_NAMES, TRIGGER_WHOLE_RECORD_REF_NAME } from "./task-output-labels.js";
|
|
22
23
|
import { workflowOutputTypeFromFieldType } from "./workflow-output.js";
|
|
24
|
+
import { slackMessageTriggerPathFromWire } from "./slack-message-refs.js";
|
|
23
25
|
import { ALL_AUTOMATION_TASK_TYPE_SET, AUTOMATION_BRANCH_TYPE_SET, AUTOMATION_RESOURCE_TYPE, AUTOMATION_TRIGGER_TYPE_SET, WEBHOOK_REQUEST_REF_PATTERN, WORKFLOW_PUBLISH_RESOURCE_TYPE, } from "./types.js";
|
|
24
26
|
const TRIGGER_KINDS = {
|
|
25
27
|
elementum_record_created_trigger: "recordCreate",
|
|
@@ -336,9 +338,14 @@ const TRIGGER_ATTRIBUTES = new Set([
|
|
|
336
338
|
"aspect_field_id", "temporal_unit", "value",
|
|
337
339
|
// Build-derived from the owner's field order and never printed (edk#2280).
|
|
338
340
|
"object_field_ids",
|
|
341
|
+
// Build-derived from the owner's fields and never printed (edk#2438).
|
|
342
|
+
"object_fields",
|
|
343
|
+
"object_system_field_ids",
|
|
344
|
+
// Build-derived from the refs keys the automation reads (edk#2648).
|
|
345
|
+
"refs_read",
|
|
339
346
|
]);
|
|
340
347
|
const TASK_ATTRIBUTES = new Set([
|
|
341
|
-
"parent", "name", "depends_on", "object_field_ids", "filter", "fields", "inputs", "output_schema",
|
|
348
|
+
"parent", "name", "depends_on", "object_field_ids", "object_fields", "object_system_field_ids", "refs_read", "filter", "fields", "inputs", "output_schema",
|
|
342
349
|
"list", "code", "variables", "updates", "variable", "value",
|
|
343
350
|
"object_id", "table_id", "record_reference", "record_id", "source_record_ids",
|
|
344
351
|
"approval_process_id", "requester_reference", "approver_references", "reason", "summary",
|
|
@@ -353,7 +360,7 @@ const TASK_ATTRIBUTES = new Set([
|
|
|
353
360
|
"fields_to_lock", "fields_to_unlock", "file", "file_id", "attachment", "attachment_id", "view_state", "target_automation_id",
|
|
354
361
|
"target_automation_ref", "input_mappings", "dynamic_input_mappings",
|
|
355
362
|
"output_mappings", "file_reader_id", "raw_text", "procedure_id",
|
|
356
|
-
"calculations", "categories", "limit", "sort", "tag", "tags", "context", "length",
|
|
363
|
+
"calculations", "categories", "limit", "sort", "tag", "tags", "context", "length", "dimensions",
|
|
357
364
|
"subject", "phone_service_id", "phone_number", "default_language", "first_message",
|
|
358
365
|
"synchronous", "cloudlink_id", "stored_function_id",
|
|
359
366
|
"relate_to_record_reference", "method", "parameters", "headers",
|
|
@@ -384,14 +391,6 @@ function appRef(appRefName) {
|
|
|
384
391
|
const WIRE_REF_SEGMENT_TO_TS = {
|
|
385
392
|
"Changed Fields": "changedFieldIds",
|
|
386
393
|
"Iteration": "iteration",
|
|
387
|
-
"Slack Thread ID": "slackThreadId",
|
|
388
|
-
"Slack Channel ID": "slackChannelId",
|
|
389
|
-
"Message Author Email": "messageAuthorEmail",
|
|
390
|
-
"Message Author ID": "messageAuthorId",
|
|
391
|
-
"Message Author Name": "messageAuthorName",
|
|
392
|
-
"Message Content": "messageContent",
|
|
393
|
-
"Message ID": "messageId",
|
|
394
|
-
"Message Metadata": "messageMetadata",
|
|
395
394
|
};
|
|
396
395
|
const ON_DEMAND_TRIGGERED_BY_FROM_WIRE = {
|
|
397
396
|
"Triggered By's Id": ["triggeredBy", "id"],
|
|
@@ -446,12 +445,72 @@ function recordFieldRefPath(wireName, ctx, ownerRefName = ctx.appRefName, rootNa
|
|
|
446
445
|
return [rootName, fieldKey, ...suffixPath];
|
|
447
446
|
}
|
|
448
447
|
}
|
|
449
|
-
const systemPath = systemFieldRefPath(wireName);
|
|
450
|
-
|
|
448
|
+
const systemPath = systemFieldRefPath(wireName, customFieldNamed(ownerRefName, ctx));
|
|
449
|
+
if (systemPath === undefined)
|
|
450
|
+
return undefined;
|
|
451
|
+
// A leftover default wire name after a Title/Handle/Status rename must not
|
|
452
|
+
// decode as the typed key: build would emit the new name (#2671 N1).
|
|
453
|
+
const systemKey = systemPath[0];
|
|
454
|
+
if (ownerRefName === ctx.appRefName &&
|
|
455
|
+
systemKey !== undefined &&
|
|
456
|
+
renamedSystemFieldKey(systemKey, ctx)) {
|
|
457
|
+
return undefined;
|
|
458
|
+
}
|
|
459
|
+
return [rootName, ...systemPath];
|
|
460
|
+
}
|
|
461
|
+
/** Whether the owner renamed this system field away from its deploy default. */
|
|
462
|
+
function renamedSystemFieldKey(key, ctx) {
|
|
463
|
+
if (key === "title")
|
|
464
|
+
return ctx.titleFieldName !== undefined;
|
|
465
|
+
if (key === "id")
|
|
466
|
+
return ctx.idFieldName !== undefined;
|
|
467
|
+
if (key === "status")
|
|
468
|
+
return ctx.statusFieldName !== undefined;
|
|
469
|
+
return false;
|
|
470
|
+
}
|
|
471
|
+
/** Current display name of a renamable system field on the automation owner. */
|
|
472
|
+
function currentRenamableSystemName(key, ctx) {
|
|
473
|
+
if (key === "title")
|
|
474
|
+
return ctx.titleFieldName ?? DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES.title;
|
|
475
|
+
if (key === "id")
|
|
476
|
+
return ctx.idFieldName ?? DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES.id;
|
|
477
|
+
return ctx.statusFieldName ?? DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES.status;
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Map a renamed Title/Handle/Status display name to its fixed key. Only the
|
|
481
|
+
* rename attributes match positively; Title wins when its rename equals
|
|
482
|
+
* Handle/Status's current name (e.g. Title renamed to "ID"). An id/status
|
|
483
|
+
* rename that collides with another renamable's current name is refused (#2671 S1).
|
|
484
|
+
*/
|
|
485
|
+
function renamableSystemFieldKeyByDisplayName(displayNameLower, ctx) {
|
|
486
|
+
const fromAttrs = [];
|
|
487
|
+
if (ctx.titleFieldName?.toLowerCase() === displayNameLower)
|
|
488
|
+
fromAttrs.push("title");
|
|
489
|
+
if (ctx.idFieldName?.toLowerCase() === displayNameLower)
|
|
490
|
+
fromAttrs.push("id");
|
|
491
|
+
if (ctx.statusFieldName?.toLowerCase() === displayNameLower)
|
|
492
|
+
fromAttrs.push("status");
|
|
493
|
+
if (fromAttrs.length === 0)
|
|
494
|
+
return undefined;
|
|
495
|
+
if (fromAttrs.includes("title"))
|
|
496
|
+
return "title";
|
|
497
|
+
for (const key of fromAttrs) {
|
|
498
|
+
const collides = ["title", "id", "status"].some((other) => other !== key && currentRenamableSystemName(other, ctx).toLowerCase() === displayNameLower);
|
|
499
|
+
if (!collides)
|
|
500
|
+
return key;
|
|
501
|
+
}
|
|
502
|
+
return undefined;
|
|
451
503
|
}
|
|
504
|
+
/**
|
|
505
|
+
* A display-name match to a system key decodes here only when the build
|
|
506
|
+
* emits the same key; a platform audit spelling that needs the provider's
|
|
507
|
+
* alias goes through systemFieldRefPath, which checks the owner first.
|
|
508
|
+
*/
|
|
452
509
|
function systemFieldPathRoundTrips(fieldKey, wireSuffix, wireName) {
|
|
453
|
-
|
|
454
|
-
|
|
510
|
+
if (!SYSTEM_FIELD_KEY_SET.has(fieldKey))
|
|
511
|
+
return true;
|
|
512
|
+
const key = fieldKey;
|
|
513
|
+
return systemRefNameRoundTrips(key, wireSuffix, wireName) && !auditRefNeedsProviderAlias(key, wireSuffix, wireName);
|
|
455
514
|
}
|
|
456
515
|
/**
|
|
457
516
|
* System fields have no `*_field` resource block, so they never appear in
|
|
@@ -459,18 +518,44 @@ function systemFieldPathRoundTrips(fieldKey, wireSuffix, wireName) {
|
|
|
459
518
|
* when a rebuild of the typed path emits the same refs key; otherwise the
|
|
460
519
|
* caller keeps the org's exact label.
|
|
461
520
|
*/
|
|
462
|
-
function systemFieldRefPath(wireName) {
|
|
521
|
+
function systemFieldRefPath(wireName, deployDefaultTaken) {
|
|
463
522
|
const wireNameLower = wireName.toLowerCase();
|
|
464
523
|
for (const key of SYSTEM_FIELD_KEYS) {
|
|
465
524
|
const defaultName = DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES[key];
|
|
466
525
|
for (const [suffix, suffixPath] of FIELD_REF_SUFFIX_FROM_WIRE) {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
526
|
+
// A platform-named audit field ("Created on", edk#2936) rebuilds under
|
|
527
|
+
// the deploy default, which the provider publishes as its alias. Not
|
|
528
|
+
// when a custom field may hold that name: the alias would not be added
|
|
529
|
+
// and the rebuilt key would read the custom field.
|
|
530
|
+
const viaAlias = auditRefNeedsProviderAlias(key, suffix, wireName);
|
|
531
|
+
if (!viaAlias && wireNameLower !== `${defaultName}${suffix}`.toLowerCase())
|
|
532
|
+
continue;
|
|
533
|
+
if (!systemRefNameRoundTrips(key, suffix, wireName))
|
|
534
|
+
continue;
|
|
535
|
+
if (viaAlias && deployDefaultTaken(defaultName))
|
|
536
|
+
continue;
|
|
537
|
+
return [key, ...suffixPath];
|
|
470
538
|
}
|
|
471
539
|
}
|
|
472
540
|
return undefined;
|
|
473
541
|
}
|
|
542
|
+
/**
|
|
543
|
+
* Whether the owner may have a custom (non-system) field with this display
|
|
544
|
+
* name. An owner whose fields this pull doesn't know (an unknown loop item
|
|
545
|
+
* owner, an aspect never pulled) counts as having one, so a platform-named
|
|
546
|
+
* audit ref stays a raw key there: the build-vs-export check reads both
|
|
547
|
+
* spellings as one key (mapKeyAliases) and would not catch a wrong decode.
|
|
548
|
+
*/
|
|
549
|
+
function customFieldNamed(ownerRefName, ctx) {
|
|
550
|
+
const known = ownerRefName !== undefined &&
|
|
551
|
+
(ownerRefName === ctx.appRefName || ctx.fieldNamesByOwnerRefName?.has(ownerRefName) === true);
|
|
552
|
+
if (!known)
|
|
553
|
+
return () => true;
|
|
554
|
+
return (displayName) => {
|
|
555
|
+
const key = lookupFieldKeyByDisplayName(ownerRefName, displayName, ctx);
|
|
556
|
+
return key !== undefined && !SYSTEM_FIELD_KEY_SET.has(key);
|
|
557
|
+
};
|
|
558
|
+
}
|
|
474
559
|
const RECORD_BEARING_TRIGGER_TYPES = new Set([
|
|
475
560
|
"elementum_record_created_trigger",
|
|
476
561
|
"elementum_record_updated_trigger",
|
|
@@ -752,6 +837,8 @@ function findRelatedRecordsFieldPath(wireName, taskAddress, ctx) {
|
|
|
752
837
|
const kind = taskAddress !== undefined
|
|
753
838
|
? ctx.taskTargetOwnerKindByAddress?.get(taskAddress)
|
|
754
839
|
: undefined;
|
|
840
|
+
if (wireName === "All found records")
|
|
841
|
+
return ["records"];
|
|
755
842
|
const lower = wireName.toLowerCase();
|
|
756
843
|
if (kind === "app" && (lower === "title" || lower === "id")) {
|
|
757
844
|
return ["record", "id"];
|
|
@@ -768,8 +855,19 @@ function lookupFieldKeyByDisplayName(ownerRefName, displayName, ctx) {
|
|
|
768
855
|
if (field.name.toLowerCase() === lower)
|
|
769
856
|
return field.key;
|
|
770
857
|
}
|
|
858
|
+
// Renamed Title/Handle/Status have no field blocks; build keys them by
|
|
859
|
+
// their fixed keys (#2650, #2671 S1). Title wins when its rename collides
|
|
860
|
+
// with Handle/Status's current name (e.g. Title renamed to "ID").
|
|
861
|
+
const renamedKey = renamableSystemFieldKeyByDisplayName(lower, ctx);
|
|
862
|
+
if (renamedKey !== undefined)
|
|
863
|
+
return renamedKey;
|
|
771
864
|
}
|
|
865
|
+
const ownerRenames = ownerRefName === ctx.appRefName;
|
|
772
866
|
for (const key of SYSTEM_FIELD_KEYS) {
|
|
867
|
+
// Skip defaults for fields this owner renamed; systemFieldRefPath is gated
|
|
868
|
+
// the same way so trigger refs honor it too (#2671 N1).
|
|
869
|
+
if (ownerRenames && renamedSystemFieldKey(key, ctx))
|
|
870
|
+
continue;
|
|
773
871
|
if (DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES[key].toLowerCase() === lower)
|
|
774
872
|
return key;
|
|
775
873
|
}
|
|
@@ -799,12 +897,16 @@ function taskRecordSearchFieldPath(taskAddress, wireName, ctx) {
|
|
|
799
897
|
for (const [suffix, suffixPath] of FIELD_REF_SUFFIX_FROM_WIRE) {
|
|
800
898
|
for (const base of suffix === "" ? [wireName] : wireName.endsWith(suffix) ? [wireName.slice(0, -suffix.length)] : []) {
|
|
801
899
|
const fieldKey = lookupFieldKeyByDisplayName(ownerRefName, base, ctx);
|
|
802
|
-
if (fieldKey !== undefined &&
|
|
900
|
+
if (fieldKey !== undefined &&
|
|
901
|
+
(suffix === "" || wireNameLower === `${base}${suffix}`.toLowerCase()) &&
|
|
902
|
+
systemFieldPathRoundTrips(fieldKey, suffix, wireName)) {
|
|
803
903
|
return ["record", fieldKey, ...suffixPath];
|
|
804
904
|
}
|
|
805
905
|
}
|
|
806
906
|
}
|
|
807
|
-
|
|
907
|
+
// A platform-named audit field ("Created on") decodes like any found
|
|
908
|
+
// record's (#2936): only when its rebuild resolves to the same refs value.
|
|
909
|
+
return recordFieldRefPath(wireName, ctx, ownerRefName);
|
|
808
910
|
}
|
|
809
911
|
/**
|
|
810
912
|
* Sentinel returned by {@link approverReferenceFieldAuthoringType} for a
|
|
@@ -916,13 +1018,52 @@ function decodeFieldAssignmentValue(value, ctx, diagnostics, where = "field assi
|
|
|
916
1018
|
if (Array.isArray(value)) {
|
|
917
1019
|
return value.map((item) => decodeFieldAssignmentValue(item, ctx, diagnostics, where));
|
|
918
1020
|
}
|
|
919
|
-
if (typeof value === "string" && /^[a-f0-9-]{36}$/i.test(value)) {
|
|
920
|
-
const label = ctx.picklistOptionLabelById?.get(value);
|
|
921
|
-
if (label !== undefined)
|
|
922
|
-
return { kind: "literal", value: label };
|
|
923
|
-
}
|
|
924
1021
|
return decodeValueOrStringifiedRef(value, ctx, diagnostics, where);
|
|
925
1022
|
}
|
|
1023
|
+
/**
|
|
1024
|
+
* A Dropdown or Multi-Select assignment's option, printed as
|
|
1025
|
+
* `filter.textOption(label)`, the one spelling build accepts there (#1733).
|
|
1026
|
+
* Export holds an option id as its options-by-label lookup and Read keeps the
|
|
1027
|
+
* label, so either decodes to a label here. A label the field no longer lists
|
|
1028
|
+
* keeps the selection too, and build names it. A raw id becomes its label only
|
|
1029
|
+
* when it is one of this field's current options (#2568); any other id stays
|
|
1030
|
+
* as written and warns, so the building agent can pick a current option. That
|
|
1031
|
+
* holds for another app's or element's field too: its id must be one of the
|
|
1032
|
+
* options state lists for that field, and its label one of the field's
|
|
1033
|
+
* reference options when the reference carries them (#2592, #2596). `raw` is
|
|
1034
|
+
* the exported field id and value, which name a foreign field's options. The
|
|
1035
|
+
* "" clear stays as written. Any field without static options, record-sourced
|
|
1036
|
+
* Dropdowns included, keeps its value.
|
|
1037
|
+
*/
|
|
1038
|
+
function assignmentOptionValue(value, field, raw, ctx, diagnostics, where) {
|
|
1039
|
+
const ownLabels = optionLabelsForDecodedField(field, ctx);
|
|
1040
|
+
const foreignLabels = ownLabels === undefined ? foreignOptionIdLabels(raw.fieldId, raw.value, field, ctx) : undefined;
|
|
1041
|
+
if (ownLabels === undefined && foreignLabels === undefined)
|
|
1042
|
+
return value;
|
|
1043
|
+
const optionLabel = (id) => {
|
|
1044
|
+
if (foreignLabels === undefined)
|
|
1045
|
+
return decodedFieldOptionLabel(id, field, ctx);
|
|
1046
|
+
const label = foreignFieldOptionLabel(id, field, ctx);
|
|
1047
|
+
return label !== undefined && foreignLabels.has(label) ? label : undefined;
|
|
1048
|
+
};
|
|
1049
|
+
const decode = (item) => {
|
|
1050
|
+
if (Array.isArray(item))
|
|
1051
|
+
return item.map(decode);
|
|
1052
|
+
const text = isObject(item) && item.kind === "literal" ? item.value : item;
|
|
1053
|
+
if (typeof text !== "string" || text === "")
|
|
1054
|
+
return item;
|
|
1055
|
+
if (!isUuid(text))
|
|
1056
|
+
return textOption(text);
|
|
1057
|
+
const label = optionLabel(text);
|
|
1058
|
+
if (label !== undefined)
|
|
1059
|
+
return textOption(label);
|
|
1060
|
+
const warning = unknownOptionIdWarning(where, text, field, ctx, foreignLabels !== undefined);
|
|
1061
|
+
if (warning !== undefined)
|
|
1062
|
+
diagnostics.push(warning);
|
|
1063
|
+
return item;
|
|
1064
|
+
};
|
|
1065
|
+
return decode(value);
|
|
1066
|
+
}
|
|
926
1067
|
const VALUE_REFERENCE_KEYS = ["taskReference", "triggerReference", "variableReference"];
|
|
927
1068
|
/**
|
|
928
1069
|
* edk#1646: ei's exporter falls back to a stringified wire ValueReference
|
|
@@ -1116,12 +1257,18 @@ function canonicalTriggerRecordIdSlot(value, ctx) {
|
|
|
1116
1257
|
value.kind === "triggerRef" &&
|
|
1117
1258
|
Array.isArray(value.path) &&
|
|
1118
1259
|
((value.path.length === 1 && value.path[0] === "recordId") ||
|
|
1119
|
-
(value.path.length === 2 && value.path[0] === "record" && value.path[1] ===
|
|
1260
|
+
(value.path.length === 2 && value.path[0] === "record" && value.path[1] === RECORD_ID_REFERENCE_FIELD))) {
|
|
1120
1261
|
return { ...value, path: ["record"] };
|
|
1121
1262
|
}
|
|
1122
1263
|
return value;
|
|
1123
1264
|
}
|
|
1124
1265
|
function triggerRefPath(path, ctx) {
|
|
1266
|
+
// Slack message keys ("Message Content" -> content) are mapped only on that
|
|
1267
|
+
// trigger, so a field or task output with the same display name elsewhere
|
|
1268
|
+
// keeps its own path (#2581).
|
|
1269
|
+
const slackPath = slackTriggerPath(path.map((segment) => typeof segment === "string" ? segment : segment.index), ctx);
|
|
1270
|
+
if (slackPath !== undefined)
|
|
1271
|
+
return slackPath;
|
|
1125
1272
|
const names = pathNames(path);
|
|
1126
1273
|
if (names.length !== 1)
|
|
1127
1274
|
return names;
|
|
@@ -1217,12 +1364,100 @@ function triggerRefPath(path, ctx) {
|
|
|
1217
1364
|
return names;
|
|
1218
1365
|
return recordFieldRefPath(wireName, ctx) ?? names;
|
|
1219
1366
|
}
|
|
1367
|
+
// Top-level properties the record trigger outputs declare (RecordTriggerOutput,
|
|
1368
|
+
// AttachmentTriggerOutput, CommentAddedTriggerOutput in triggers.ts).
|
|
1369
|
+
const RECORD_TRIGGER_OUTPUT_HEADS = new Set(["record", "changedFieldIds", "attachment", "comment"]);
|
|
1370
|
+
const UNDECLARED_HEAD_TRIGGER_TYPES = new Set([
|
|
1371
|
+
"elementum_record_created_trigger",
|
|
1372
|
+
"elementum_record_updated_trigger",
|
|
1373
|
+
"elementum_attachment_added_trigger",
|
|
1374
|
+
"elementum_comment_added_trigger",
|
|
1375
|
+
"elementum_approval_chain_trigger",
|
|
1376
|
+
]);
|
|
1377
|
+
/**
|
|
1378
|
+
* A record trigger ref whose single name matches no field or declared output
|
|
1379
|
+
* (an unknown name, or a group-qualified key such as
|
|
1380
|
+
* "Record Update Trigger - Record Type"). The output type has no index
|
|
1381
|
+
* signature, so pull prints it through an `as any` escape (#2643).
|
|
1382
|
+
*/
|
|
1383
|
+
function undeclaredRecordTriggerHead(path, ctx) {
|
|
1384
|
+
return UNDECLARED_HEAD_TRIGGER_TYPES.has(ctx.trigger.type ?? "") && path.length === 1 && !RECORD_TRIGGER_OUTPUT_HEADS.has(path[0]);
|
|
1385
|
+
}
|
|
1220
1386
|
function forEachItemOwnerRefName(loop, ctx) {
|
|
1221
1387
|
const collection = loop === undefined ? undefined : resourceRef(loop.attrs.list);
|
|
1222
1388
|
return collection === undefined ? undefined : ctx.taskTargetOwnerRefNameByAddress?.get(`${collection.type}.${collection.label}`);
|
|
1223
1389
|
}
|
|
1390
|
+
/**
|
|
1391
|
+
* The tf label of a record loop's collection owner, from the source task's
|
|
1392
|
+
* `object_id` (`elementum_app.<label>.id` / `elementum_element.<label>.id`).
|
|
1393
|
+
* Build names that owner's system-field ids `local.<label>_<field>_field_id`
|
|
1394
|
+
* (calculationFieldScope), which may be another in-workspace aspect.
|
|
1395
|
+
*/
|
|
1396
|
+
function forEachItemOwnerTfLabel(loop, ctx) {
|
|
1397
|
+
const collection = resourceRef(loop.attrs.list);
|
|
1398
|
+
const source = collection === undefined ? undefined : ctx.taskByAddress.get(`${collection.type}.${collection.label}`);
|
|
1399
|
+
const objectId = (source?.block.attrs.object_id ?? null);
|
|
1400
|
+
if (!isTfExpr(objectId) || objectId.$expr !== "resource-attr" ||
|
|
1401
|
+
(objectId.type !== "elementum_app" && objectId.type !== "elementum_element") || objectId.path[0] !== "id") {
|
|
1402
|
+
return undefined;
|
|
1403
|
+
}
|
|
1404
|
+
return objectId.label;
|
|
1405
|
+
}
|
|
1406
|
+
/** Build's sentinel for a record's own id decodes to the typed `recordId`, at any depth. */
|
|
1407
|
+
function recordIdSegments(segments) {
|
|
1408
|
+
return segments.map((segment) => segment === RECORD_ID_REFERENCE_FIELD ? "recordId" : segment);
|
|
1409
|
+
}
|
|
1410
|
+
/**
|
|
1411
|
+
* The item field key behind a `for_each.<id>.${<field id>}` filter path. A
|
|
1412
|
+
* system field's id is a local named by the collection owner's tf label, which
|
|
1413
|
+
* is not this automation's app when the loop reads another aspect's records;
|
|
1414
|
+
* decodeValue only knows this app's prefix and would throw for the whole
|
|
1415
|
+
* automation, so locals resolve here against the owner first.
|
|
1416
|
+
*/
|
|
1417
|
+
function forEachItemFieldKey(fieldPart, loop, ctx) {
|
|
1418
|
+
if (fieldPart.$expr === "local") {
|
|
1419
|
+
if (!fieldPart.name.endsWith("_field_id"))
|
|
1420
|
+
return undefined;
|
|
1421
|
+
const ownerLabel = forEachItemOwnerTfLabel(loop, ctx) ?? ctx.appTfLabel;
|
|
1422
|
+
const prefix = `${ownerLabel}_`;
|
|
1423
|
+
return fieldPart.name.startsWith(prefix)
|
|
1424
|
+
? tfLabelToTsLabel(fieldPart.name.slice(prefix.length, -"_field_id".length))
|
|
1425
|
+
: undefined;
|
|
1426
|
+
}
|
|
1427
|
+
try {
|
|
1428
|
+
const field = fieldRef(fieldPart, ctx);
|
|
1429
|
+
if (field.kind === "field")
|
|
1430
|
+
return field.fieldKey;
|
|
1431
|
+
}
|
|
1432
|
+
catch (error) {
|
|
1433
|
+
if (!(error instanceof EntityTfError))
|
|
1434
|
+
throw error;
|
|
1435
|
+
}
|
|
1436
|
+
return fieldKeyFromTriggerFieldIdExpr(fieldPart, ctx);
|
|
1437
|
+
}
|
|
1438
|
+
/**
|
|
1439
|
+
* A loop's refs-map keys for its own metadata (every collection kind) print
|
|
1440
|
+
* as the typed `ctx.item.metadata.<name>`; filters already carry
|
|
1441
|
+
* `for_each.<id>.metadata.<name>` (#2922).
|
|
1442
|
+
*/
|
|
1443
|
+
const FOR_EACH_LOOP_METADATA_FROM_WIRE = {
|
|
1444
|
+
"Is First Item": "first",
|
|
1445
|
+
"Is Last Item": "last",
|
|
1446
|
+
"Iteration": "iteration",
|
|
1447
|
+
"Total Size": "size",
|
|
1448
|
+
};
|
|
1224
1449
|
function forEachItemRefPath(path, ctx, loop) {
|
|
1225
1450
|
const names = pathNames(path);
|
|
1451
|
+
const itemOwner = forEachItemOwnerRefName(loop, ctx);
|
|
1452
|
+
if (itemOwner !== undefined && names[0] !== undefined && isUuid(names[0])) {
|
|
1453
|
+
// Provider/filter export uses the actual field ID; script inputs use a
|
|
1454
|
+
// refs-map display name. Both spellings must print the same typed path.
|
|
1455
|
+
if (names.length === 1 && names[0] === RECORD_ID_REFERENCE_FIELD)
|
|
1456
|
+
return ["recordId"];
|
|
1457
|
+
const fieldKey = resolveFieldKeyFromId(names[0], itemOwner, ctx);
|
|
1458
|
+
if (fieldKey !== undefined)
|
|
1459
|
+
return [fieldKey, ...recordIdSegments(names.slice(1))];
|
|
1460
|
+
}
|
|
1226
1461
|
if (names.length !== 1)
|
|
1227
1462
|
return names.flatMap((segment) => segment.split("."));
|
|
1228
1463
|
const wireName = names[0];
|
|
@@ -1232,7 +1467,6 @@ function forEachItemRefPath(path, ctx, loop) {
|
|
|
1232
1467
|
if (wireName === "Record")
|
|
1233
1468
|
return ["recordId"];
|
|
1234
1469
|
const wireNameLower = wireName.toLowerCase();
|
|
1235
|
-
const itemOwner = forEachItemOwnerRefName(loop, ctx);
|
|
1236
1470
|
const ownFields = itemOwner === undefined || itemOwner === ctx.appRefName ? ctx.fieldById.values() : [];
|
|
1237
1471
|
for (const field of ownFields) {
|
|
1238
1472
|
// Some provider paths already contain the stable EDK field key (for
|
|
@@ -1246,7 +1480,21 @@ function forEachItemRefPath(path, ctx, loop) {
|
|
|
1246
1480
|
}
|
|
1247
1481
|
}
|
|
1248
1482
|
}
|
|
1249
|
-
|
|
1483
|
+
if (itemOwner !== undefined) {
|
|
1484
|
+
// A record collection can belong to a different app/element. Resolve
|
|
1485
|
+
// its refs-map display names through that owner's catalog, just as
|
|
1486
|
+
// build does, rather than printing a foreign label as an item key.
|
|
1487
|
+
const recordPath = recordFieldRefPath(wireName, ctx, itemOwner);
|
|
1488
|
+
if (recordPath !== undefined)
|
|
1489
|
+
return recordPath.slice(1);
|
|
1490
|
+
}
|
|
1491
|
+
// pathNames already turned "Iteration" into "iteration"; match the raw key.
|
|
1492
|
+
const rawName = typeof path[0] === "string" ? path[0] : path[0]?.index;
|
|
1493
|
+
if (rawName !== undefined && Object.hasOwn(FOR_EACH_LOOP_METADATA_FROM_WIRE, rawName)) {
|
|
1494
|
+
return ["metadata", FOR_EACH_LOOP_METADATA_FROM_WIRE[rawName]];
|
|
1495
|
+
}
|
|
1496
|
+
return systemFieldRefPath(wireName, customFieldNamed(itemOwner, ctx)) ??
|
|
1497
|
+
names.flatMap((segment) => segment.split("."));
|
|
1250
1498
|
}
|
|
1251
1499
|
function resolveTaskRefKey(taskIdOrKey, ctx) {
|
|
1252
1500
|
if (/^[a-f0-9-]{36}$/.test(taskIdOrKey)) {
|
|
@@ -1416,10 +1664,17 @@ function decodeTaskReferenceFromString(taskIdOrKey, pathSegments, ctx) {
|
|
|
1416
1664
|
: keyPath;
|
|
1417
1665
|
return { kind: "taskRef", task: refKey, path: outputKeyPath };
|
|
1418
1666
|
}
|
|
1667
|
+
/** A Slack message trigger reference's accessor path; undefined on any other trigger. */
|
|
1668
|
+
function slackTriggerPath(path, ctx) {
|
|
1669
|
+
return ctx.trigger.type === "elementum_slack_message_trigger" ? slackMessageTriggerPathFromWire(path) : undefined;
|
|
1670
|
+
}
|
|
1419
1671
|
function decodeReferenceString(value, ctx) {
|
|
1420
1672
|
const pieces = value.split(".");
|
|
1421
1673
|
if (pieces[0] === "trigger" && pieces.length > 1) {
|
|
1422
1674
|
const path = pieces.slice(1);
|
|
1675
|
+
const slackPath = slackTriggerPath(path, ctx);
|
|
1676
|
+
if (slackPath !== undefined)
|
|
1677
|
+
return { kind: "triggerRef", path: slackPath };
|
|
1423
1678
|
const declaredInput = path.length === 1 ? declaredOnDemandInputForWireName(ctx.trigger, path[0]) : undefined;
|
|
1424
1679
|
if (declaredInput !== undefined)
|
|
1425
1680
|
return { kind: "triggerRef", path: [declaredInput] };
|
|
@@ -1510,7 +1765,7 @@ function decodeTemplateTriggerRecordFieldRef(value, ctx) {
|
|
|
1510
1765
|
if (fieldKey === undefined)
|
|
1511
1766
|
return undefined;
|
|
1512
1767
|
const suffix = suffixPart === undefined ? [] : suffixPart.replace(/^\./, "").split(".").filter((s) => s.length > 0);
|
|
1513
|
-
if (suffix.length === 1 && suffix[0] ===
|
|
1768
|
+
if (suffix.length === 1 && suffix[0] === RECORD_ID_REFERENCE_FIELD) {
|
|
1514
1769
|
return { kind: "triggerRef", path: [root, fieldKey, "recordId"] };
|
|
1515
1770
|
}
|
|
1516
1771
|
return { kind: "triggerRef", path: [root, fieldKey, ...suffix] };
|
|
@@ -1578,7 +1833,7 @@ function templateRecordFieldPath(parts, taskBlock, ctx) {
|
|
|
1578
1833
|
function decodeTemplateForEachRef(value, ctx) {
|
|
1579
1834
|
if (!isTfExpr(value) || value.$expr !== "template")
|
|
1580
1835
|
return undefined;
|
|
1581
|
-
const [prefix, idPart, suffixPart] = value.parts;
|
|
1836
|
+
const [prefix, idPart, suffixPart, fieldPart, fieldSuffix, ...rest] = mergeAdjacentTemplateStrings(value.parts);
|
|
1582
1837
|
if (prefix !== "for_each." || idPart === undefined || typeof idPart === "string")
|
|
1583
1838
|
return undefined;
|
|
1584
1839
|
if (typeof suffixPart !== "string" || !suffixPart.startsWith("."))
|
|
@@ -1588,6 +1843,17 @@ function decodeTemplateForEachRef(value, ctx) {
|
|
|
1588
1843
|
const task = ctx.taskByAddress.get(`${idPart.type}.${idPart.label}`);
|
|
1589
1844
|
if (task === undefined)
|
|
1590
1845
|
return undefined;
|
|
1846
|
+
if (suffixPart === "." && fieldPart !== undefined && typeof fieldPart !== "string") {
|
|
1847
|
+
if (rest.length > 0 || (fieldSuffix !== undefined && (typeof fieldSuffix !== "string" || !fieldSuffix.startsWith("."))))
|
|
1848
|
+
return undefined;
|
|
1849
|
+
const fieldKey = forEachItemFieldKey(fieldPart, task.block, ctx);
|
|
1850
|
+
if (fieldKey === undefined)
|
|
1851
|
+
return undefined;
|
|
1852
|
+
const suffix = (fieldSuffix ?? "").split(".").filter((part) => part.length > 0);
|
|
1853
|
+
return { kind: "forEachItemRef", forEachTask: task.refKey, path: [fieldKey, ...recordIdSegments(suffix)] };
|
|
1854
|
+
}
|
|
1855
|
+
if (fieldPart !== undefined)
|
|
1856
|
+
return undefined;
|
|
1591
1857
|
const nameParts = suffixPart.slice(1).split(".").filter((segment) => segment.length > 0);
|
|
1592
1858
|
if (nameParts.length === 0 && suffixPart !== ".")
|
|
1593
1859
|
return undefined;
|
|
@@ -1826,7 +2092,10 @@ function decodeValue(value, ctx) {
|
|
|
1826
2092
|
if (optionLabel !== undefined)
|
|
1827
2093
|
return { kind: "literal", value: optionLabel };
|
|
1828
2094
|
if (value.type === ctx.trigger.type && value.label === ctx.trigger.label && value.path[0] === "refs") {
|
|
1829
|
-
|
|
2095
|
+
const path = triggerRefPath(value.path.slice(1), ctx);
|
|
2096
|
+
return (undeclaredRecordTriggerHead(path, ctx)
|
|
2097
|
+
? { kind: "triggerRef", path, undeclaredHead: true }
|
|
2098
|
+
: { kind: "triggerRef", path });
|
|
1830
2099
|
}
|
|
1831
2100
|
const task = ctx.taskByAddress.get(`${value.type}.${value.label}`);
|
|
1832
2101
|
if (task !== undefined && value.path[0] === "inner" && value.path[1] === "refs") {
|
|
@@ -2430,37 +2699,20 @@ function labelsFromOptions(value) {
|
|
|
2430
2699
|
return labels.size > 0 ? labels : undefined;
|
|
2431
2700
|
}
|
|
2432
2701
|
/**
|
|
2433
|
-
*
|
|
2434
|
-
*
|
|
2435
|
-
*
|
|
2702
|
+
* The static Dropdown or Multi-Select block a filter's field id expression
|
|
2703
|
+
* names. A reference to another task's record is not a field id, and app
|
|
2704
|
+
* status options are not read here (#2099, #2568).
|
|
2436
2705
|
*/
|
|
2437
|
-
function
|
|
2706
|
+
function picklistBlockForFieldIdExpr(value, blocks) {
|
|
2438
2707
|
if (!isTfExpr(value))
|
|
2439
2708
|
return undefined;
|
|
2440
2709
|
if (value.$expr === "resource-attr" && value.type.endsWith("_field") && value.path[0] === "id") {
|
|
2441
2710
|
const block = blocks.get(`${value.type}.${value.label}`);
|
|
2442
|
-
|
|
2443
|
-
return undefined;
|
|
2444
|
-
return labelsFromOptions(block.attrs.options);
|
|
2445
|
-
}
|
|
2446
|
-
if ((value.$expr === "resource-attr" || value.$expr === "data-attr") &&
|
|
2447
|
-
(value.type === "elementum_app" || value.type === "elementum_element") &&
|
|
2448
|
-
value.path[0] === "status_field_id") {
|
|
2449
|
-
return labelsFromOptions(blocks.get(`${value.type}.${value.label}`)?.attrs.status_options);
|
|
2711
|
+
return isPicklistFieldBlock(block) ? block : undefined;
|
|
2450
2712
|
}
|
|
2451
2713
|
if (value.$expr === "local" && value.name.endsWith("_field_id")) {
|
|
2452
|
-
const
|
|
2453
|
-
|
|
2454
|
-
const owner = ownerAndField.slice(0, -"_status".length);
|
|
2455
|
-
const block = blocks.get(`elementum_app.${owner}`) ?? blocks.get(`elementum_element.${owner}`);
|
|
2456
|
-
return labelsFromOptions(block?.attrs.status_options);
|
|
2457
|
-
}
|
|
2458
|
-
for (const block of blocks.values()) {
|
|
2459
|
-
if (block.type !== "elementum_dropdown_field" && block.type !== "elementum_multiselect_field")
|
|
2460
|
-
continue;
|
|
2461
|
-
if (block.label === ownerAndField)
|
|
2462
|
-
return labelsFromOptions(block.attrs.options);
|
|
2463
|
-
}
|
|
2714
|
+
const fieldLabel = value.name.slice(0, -"_field_id".length);
|
|
2715
|
+
return [...blocks.values()].find((block) => isPicklistFieldBlock(block) && block.label === fieldLabel);
|
|
2464
2716
|
}
|
|
2465
2717
|
return undefined;
|
|
2466
2718
|
}
|
|
@@ -2468,46 +2720,247 @@ function optionLabelsForDecodedField(field, ctx) {
|
|
|
2468
2720
|
if (!isObject(field) || field.kind !== "field" || typeof field.fieldKey !== "string")
|
|
2469
2721
|
return undefined;
|
|
2470
2722
|
const ownerHandle = typeof field.appHandle === "string" ? field.appHandle : ctx.appRefName;
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2723
|
+
const statusLabels = systemStatusLabels(field, ctx);
|
|
2724
|
+
if (statusLabels !== undefined)
|
|
2725
|
+
return statusLabels;
|
|
2726
|
+
const labels = new Set();
|
|
2727
|
+
for (const block of picklistBlocksForDecodedField(field, ctx))
|
|
2728
|
+
collectOptionLabels(labels, block.attrs.options);
|
|
2729
|
+
// The app's system stage: its value decodes from stage_ids_by_key to the
|
|
2730
|
+
// stage name, and build reads that name as a static option (#1733).
|
|
2731
|
+
if (labels.size === 0 && field.fieldKey === "stage" && ownerHandle === ctx.appRefName && ctx.ownerScope === "app") {
|
|
2732
|
+
for (const name of ctx.stagesByKey.values())
|
|
2733
|
+
labels.add(name);
|
|
2478
2734
|
}
|
|
2735
|
+
return labels.size > 0 ? labels : undefined;
|
|
2736
|
+
}
|
|
2737
|
+
/** True when `handle` is a ref name this pull already bound to an element or task. */
|
|
2738
|
+
function refMapNames(map, handle) {
|
|
2739
|
+
if (map === undefined)
|
|
2740
|
+
return false;
|
|
2741
|
+
if (map.has(handle))
|
|
2742
|
+
return true;
|
|
2743
|
+
for (const refName of map.values()) {
|
|
2744
|
+
if (refName === handle)
|
|
2745
|
+
return true;
|
|
2746
|
+
}
|
|
2747
|
+
return false;
|
|
2748
|
+
}
|
|
2749
|
+
/**
|
|
2750
|
+
* A plain string on a foreign field is that app's system stage name.
|
|
2751
|
+
* Elements and tasks have no system stage. A picklist type is not enough:
|
|
2752
|
+
* a record-sourced Dropdown is `PICKLIST` and has no static options.
|
|
2753
|
+
*/
|
|
2754
|
+
function foreignStageName(field, ctx, systemStage) {
|
|
2755
|
+
if (field.fieldKey !== "stage")
|
|
2756
|
+
return false;
|
|
2757
|
+
const meta = isObject(field.foreign) ? field.foreign : undefined;
|
|
2758
|
+
const entityType = typeof meta?.entityType === "string" ? meta.entityType : undefined;
|
|
2759
|
+
if (entityType === "element" || entityType === "task")
|
|
2760
|
+
return false;
|
|
2761
|
+
if (entityType !== "app" || meta?.ownerKindUnknown === true) {
|
|
2762
|
+
const handle = typeof field.appHandle === "string" ? field.appHandle : undefined;
|
|
2763
|
+
if (handle === undefined || refMapNames(ctx.foreignElementRefNames, handle) || refMapNames(ctx.foreignTaskRefNames, handle))
|
|
2764
|
+
return false;
|
|
2765
|
+
}
|
|
2766
|
+
if (systemStage)
|
|
2767
|
+
return true;
|
|
2768
|
+
// A foreign field whose metadata has neither a type nor a name.
|
|
2769
|
+
const fieldType = typeof meta?.fieldType === "string" ? meta.fieldType : undefined;
|
|
2770
|
+
const fieldName = typeof meta?.fieldName === "string" ? meta.fieldName : undefined;
|
|
2771
|
+
return fieldType === undefined && fieldName === undefined;
|
|
2772
|
+
}
|
|
2773
|
+
/**
|
|
2774
|
+
* A raw field id whose registry entry is the system Stage. Those entries come
|
|
2775
|
+
* from system-field state: the key is `stage` and there is no field type.
|
|
2776
|
+
* The display name is recorded too, so its presence is not a custom field.
|
|
2777
|
+
*/
|
|
2778
|
+
function rawIdSystemStage(fieldId, ctx) {
|
|
2779
|
+
if (typeof fieldId !== "string")
|
|
2780
|
+
return false;
|
|
2781
|
+
const identity = ctx.foreignFieldRefsById?.get(fieldId);
|
|
2782
|
+
return identity !== undefined && identity.fieldKey === "stage" && identity.fieldType === undefined;
|
|
2783
|
+
}
|
|
2784
|
+
/** The strings inside a field assignment, including a Multi-Select `jsonencode([...])`. */
|
|
2785
|
+
function foreignAssignmentItems(value) {
|
|
2786
|
+
if (isTfExpr(value) && value.$expr === "jsonencode")
|
|
2787
|
+
return foreignAssignmentItems(value.value);
|
|
2788
|
+
if (Array.isArray(value))
|
|
2789
|
+
return value.flatMap((item) => foreignAssignmentItems(item));
|
|
2790
|
+
return [value];
|
|
2791
|
+
}
|
|
2792
|
+
/**
|
|
2793
|
+
* The option labels of another app's or element's field. A non-recursive
|
|
2794
|
+
* export carries no field resource for it: the static options on its
|
|
2795
|
+
* reference, else the current options state lists for that same field
|
|
2796
|
+
* (#2568). A plain string is a stage name only for the system Stage.
|
|
2797
|
+
* Undefined for an own field, a record-sourced Dropdown, or a field with no
|
|
2798
|
+
* known options.
|
|
2799
|
+
*/
|
|
2800
|
+
function foreignOptionIdLabels(fieldId, value, field, ctx) {
|
|
2801
|
+
if (!isObject(field) || field.kind !== "field")
|
|
2802
|
+
return undefined;
|
|
2803
|
+
const foreign = field.foreign !== undefined || (typeof field.appHandle === "string" && field.appHandle !== ctx.appRefName);
|
|
2804
|
+
if (!foreign)
|
|
2805
|
+
return undefined;
|
|
2806
|
+
const dataField = isTfExpr(fieldId) && fieldId.$expr === "data-attr"
|
|
2807
|
+
? ctx.foreignFieldRefsByDataAddress?.get(`${fieldId.type}.${fieldId.label}`)
|
|
2808
|
+
: undefined;
|
|
2809
|
+
if (dataField?.options !== undefined && dataField.options.length > 0)
|
|
2810
|
+
return new Set(dataField.options);
|
|
2811
|
+
const stateOptions = foreignFieldStateOptions(field, ctx);
|
|
2812
|
+
if (stateOptions.length > 0)
|
|
2813
|
+
return new Set(stateOptions.flatMap((options) => [...options.values()]));
|
|
2814
|
+
const systemStage = dataField?.systemStage === true || rawIdSystemStage(fieldId, ctx);
|
|
2479
2815
|
const labels = new Set();
|
|
2480
|
-
for (const
|
|
2481
|
-
if (
|
|
2816
|
+
for (const item of foreignAssignmentItems(value)) {
|
|
2817
|
+
if (typeof item === "string" && item !== "" && !isUuid(item) && foreignStageName(field, ctx, systemStage))
|
|
2818
|
+
labels.add(item);
|
|
2819
|
+
}
|
|
2820
|
+
return labels.size > 0 ? labels : undefined;
|
|
2821
|
+
}
|
|
2822
|
+
/**
|
|
2823
|
+
* The current options state lists for another app's or element's field: the
|
|
2824
|
+
* picklist resources whose scoped label names that owner and field key
|
|
2825
|
+
* (#2568). Empty when this org's state does not manage that field.
|
|
2826
|
+
*/
|
|
2827
|
+
function foreignFieldStateOptions(field, ctx) {
|
|
2828
|
+
if (!isObject(field) || field.kind !== "field" || typeof field.fieldKey !== "string" || typeof field.appHandle !== "string")
|
|
2829
|
+
return [];
|
|
2830
|
+
const out = [];
|
|
2831
|
+
for (const [label, options] of ctx.picklistOptionsByField ?? []) {
|
|
2832
|
+
const owner = ownerFromScopedChildLabel(label);
|
|
2833
|
+
if (owner === undefined || tfLabelToTsLabel(owner.ownerTfLabel) !== field.appHandle)
|
|
2482
2834
|
continue;
|
|
2835
|
+
if (fieldBagKey(label, ctx) === field.fieldKey)
|
|
2836
|
+
out.push(options);
|
|
2837
|
+
}
|
|
2838
|
+
return out;
|
|
2839
|
+
}
|
|
2840
|
+
/** The label of option `id` when state lists it as an option of this foreign field (#2568). */
|
|
2841
|
+
function foreignFieldOptionLabel(id, field, ctx) {
|
|
2842
|
+
for (const options of foreignFieldStateOptions(field, ctx)) {
|
|
2843
|
+
const label = options.get(id);
|
|
2844
|
+
if (label !== undefined)
|
|
2845
|
+
return label;
|
|
2846
|
+
}
|
|
2847
|
+
return undefined;
|
|
2848
|
+
}
|
|
2849
|
+
/**
|
|
2850
|
+
* The owner's system status options, for a field keyed `status`. An element
|
|
2851
|
+
* has no system status, so its field keyed status is its own Dropdown and
|
|
2852
|
+
* this is undefined (#2683).
|
|
2853
|
+
*/
|
|
2854
|
+
function systemStatusLabels(field, ctx) {
|
|
2855
|
+
if (!isObject(field) || field.kind !== "field" || field.fieldKey !== "status")
|
|
2856
|
+
return undefined;
|
|
2857
|
+
const ownerHandle = typeof field.appHandle === "string" ? field.appHandle : ctx.appRefName;
|
|
2858
|
+
const ownerBlock = ownerHandle === ctx.appRefName
|
|
2859
|
+
? ctx.resourceBlocks.get(`${ctx.ownerScope === "element" ? "elementum_element" : "elementum_app"}.${ctx.appTfLabel}`)
|
|
2860
|
+
: [...ctx.resourceBlocks.values()].find((block) => (block.type === "elementum_app" || block.type === "elementum_element") &&
|
|
2861
|
+
block.label !== undefined &&
|
|
2862
|
+
tfLabelToTsLabel(block.label) === ownerHandle);
|
|
2863
|
+
return labelsFromOptions(ownerBlock?.attrs.status_options);
|
|
2864
|
+
}
|
|
2865
|
+
/**
|
|
2866
|
+
* The static Dropdown and Multi-Select blocks in this export that a decoded
|
|
2867
|
+
* field names. An owner's system status (non-empty `status_options`) is not
|
|
2868
|
+
* one of those blocks. An element Dropdown keyed `status` is.
|
|
2869
|
+
*/
|
|
2870
|
+
function picklistBlocksForDecodedField(field, ctx) {
|
|
2871
|
+
if (!isObject(field) || field.kind !== "field" || typeof field.fieldKey !== "string")
|
|
2872
|
+
return [];
|
|
2873
|
+
if (systemStatusLabels(field, ctx) !== undefined)
|
|
2874
|
+
return [];
|
|
2875
|
+
const ownerHandle = typeof field.appHandle === "string" ? field.appHandle : ctx.appRefName;
|
|
2876
|
+
return [...ctx.resourceBlocks.values()].filter((block) => {
|
|
2877
|
+
if (!isPicklistFieldBlock(block) || block.label === undefined)
|
|
2878
|
+
return false;
|
|
2483
2879
|
if (fieldBagKey(block.label, ctx) !== field.fieldKey)
|
|
2484
|
-
|
|
2485
|
-
const
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2880
|
+
return false;
|
|
2881
|
+
const ownerTf = ownerFromScopedChildLabel(block.label)?.ownerTfLabel ?? ctx.appTfLabel;
|
|
2882
|
+
return tfLabelToTsLabel(ownerTf) === ownerHandle;
|
|
2883
|
+
});
|
|
2884
|
+
}
|
|
2885
|
+
function isPicklistFieldBlock(block) {
|
|
2886
|
+
return block?.type === "elementum_dropdown_field" || block?.type === "elementum_multiselect_field";
|
|
2887
|
+
}
|
|
2888
|
+
/**
|
|
2889
|
+
* The label of option `id` of this picklist block: state must list `id` as
|
|
2890
|
+
* one of the field's options, and the export must still list its label
|
|
2891
|
+
* (#2568). An id of another field, or a deleted option, has none.
|
|
2892
|
+
*/
|
|
2893
|
+
function picklistBlockOptionLabel(id, block, optionsByField) {
|
|
2894
|
+
if (block.label === undefined)
|
|
2895
|
+
return undefined;
|
|
2896
|
+
const label = optionsByField?.get(block.label)?.get(id);
|
|
2897
|
+
return label !== undefined && labelsFromOptions(block.attrs.options)?.has(label) === true ? label : undefined;
|
|
2898
|
+
}
|
|
2899
|
+
/** The compared field's label for option `id`, when `id` is one of its current options (#2568). */
|
|
2900
|
+
function decodedFieldOptionLabel(id, field, ctx) {
|
|
2901
|
+
if (!isUuid(id))
|
|
2902
|
+
return undefined;
|
|
2903
|
+
for (const block of picklistBlocksForDecodedField(field, ctx)) {
|
|
2904
|
+
const label = picklistBlockOptionLabel(id, block, ctx.picklistOptionsByField);
|
|
2905
|
+
if (label !== undefined)
|
|
2906
|
+
return label;
|
|
2490
2907
|
}
|
|
2491
|
-
return
|
|
2908
|
+
return undefined;
|
|
2492
2909
|
}
|
|
2493
2910
|
/**
|
|
2494
|
-
*
|
|
2495
|
-
*
|
|
2496
|
-
*
|
|
2911
|
+
* The pull warning for an assigned option id that is not one of the field's
|
|
2912
|
+
* current options (#2568). Dax, 2026-11-03: "Any bad configuration shouldn't
|
|
2913
|
+
* abort a pull. It should warn so the building agent can suggest a
|
|
2914
|
+
* correction". Undefined for an own field this export does not hold as a
|
|
2915
|
+
* picklist. `foreign` is a field of another app or element that the caller
|
|
2916
|
+
* already knows has static options; its ids are checked against state alone.
|
|
2917
|
+
*/
|
|
2918
|
+
function unknownOptionIdWarning(where, id, field, ctx, foreign = false) {
|
|
2919
|
+
const blocks = foreign ? [] : picklistBlocksForDecodedField(field, ctx);
|
|
2920
|
+
if (!foreign && blocks.length === 0)
|
|
2921
|
+
return undefined;
|
|
2922
|
+
const known = foreign
|
|
2923
|
+
? foreignFieldStateOptions(field, ctx).length > 0
|
|
2924
|
+
: blocks.some((block) => block.label !== undefined && ctx.picklistOptionsByField?.has(block.label) === true);
|
|
2925
|
+
const reason = known
|
|
2926
|
+
? "is not one of the field's current options (deleted, or an option of another field)"
|
|
2927
|
+
: "cannot be checked because the field's option ids are not in state";
|
|
2928
|
+
return `${where}: option id ${JSON.stringify(id)} ${reason}, so it is kept as the raw id. Select a current option with filter.textOption("<label>")`;
|
|
2929
|
+
}
|
|
2930
|
+
/**
|
|
2931
|
+
* A filter literal's option id, printed as the label only when it is one of
|
|
2932
|
+
* the compared field's current options. Build then writes the
|
|
2933
|
+
* options-by-label local. An id compared with a static picklist field that
|
|
2934
|
+
* is not one of its current options stays the raw id, and pull names it with
|
|
2935
|
+
* the same warning an assignment gets (#2099, #2568).
|
|
2497
2936
|
*/
|
|
2498
2937
|
function filterOptionLabel(value, field, ctx) {
|
|
2499
2938
|
if (typeof value !== "string" || !isUuid(value))
|
|
2500
2939
|
return undefined;
|
|
2501
|
-
const label =
|
|
2502
|
-
if (label
|
|
2940
|
+
const label = decodedFieldOptionLabel(value, field, ctx);
|
|
2941
|
+
if (label !== undefined)
|
|
2942
|
+
return label;
|
|
2943
|
+
// A record-sourced Dropdown has no static options, and its values are record
|
|
2944
|
+
// ids, so they get no option warning (the assignment path skips them too).
|
|
2945
|
+
if (optionLabelsForDecodedField(field, ctx) === undefined)
|
|
2503
2946
|
return undefined;
|
|
2504
|
-
|
|
2947
|
+
const fieldKey = isObject(field) && typeof field.fieldKey === "string" ? field.fieldKey : "?";
|
|
2948
|
+
const warning = unknownOptionIdWarning(`filter on field ${fieldKey}`, value, field, ctx);
|
|
2949
|
+
if (warning !== undefined)
|
|
2950
|
+
ctx.optionIdWarnings?.add(warning);
|
|
2951
|
+
return undefined;
|
|
2505
2952
|
}
|
|
2506
|
-
/**
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2953
|
+
/**
|
|
2954
|
+
* Option ids `filterOptionLabel` prints as labels at every filter comparison
|
|
2955
|
+
* that holds them. The export still holds the id. An id that any comparison
|
|
2956
|
+
* keeps raw, on another field or a deleted option, is left out, so its
|
|
2957
|
+
* unresolved-UUID warning is not muted (#2568).
|
|
2958
|
+
*/
|
|
2959
|
+
export function filterOptionIdsPrintedAsLabels(doc, optionsByField) {
|
|
2960
|
+
const printed = new Set();
|
|
2961
|
+
const keptRaw = new Set();
|
|
2962
|
+
if (optionsByField === undefined || optionsByField.size === 0)
|
|
2963
|
+
return printed;
|
|
2511
2964
|
const blocks = new Map();
|
|
2512
2965
|
for (const block of doc.blocks) {
|
|
2513
2966
|
if (block.kind !== "resource" || block.type === undefined || block.label === undefined)
|
|
@@ -2531,15 +2984,14 @@ export function filterOptionIdsPrintedAsLabels(doc, optionLabelById) {
|
|
|
2531
2984
|
value.children.forEach((child) => visit(child));
|
|
2532
2985
|
return;
|
|
2533
2986
|
}
|
|
2534
|
-
const
|
|
2535
|
-
if (labels === undefined)
|
|
2536
|
-
return;
|
|
2987
|
+
const block = picklistBlockForFieldIdExpr(fieldId, blocks);
|
|
2537
2988
|
const consider = (literal) => {
|
|
2538
|
-
if (typeof literal !== "string" || !
|
|
2989
|
+
if (typeof literal !== "string" || !isUuid(literal))
|
|
2539
2990
|
return;
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2991
|
+
if (block !== undefined && picklistBlockOptionLabel(literal, block, optionsByField) !== undefined)
|
|
2992
|
+
printed.add(literal);
|
|
2993
|
+
else
|
|
2994
|
+
keptRaw.add(literal);
|
|
2543
2995
|
};
|
|
2544
2996
|
if (isObject(value.value))
|
|
2545
2997
|
consider(value.value.value);
|
|
@@ -2560,7 +3012,7 @@ export function filterOptionIdsPrintedAsLabels(doc, optionLabelById) {
|
|
|
2560
3012
|
visit(attrValue);
|
|
2561
3013
|
}
|
|
2562
3014
|
}
|
|
2563
|
-
return
|
|
3015
|
+
return new Set([...printed].filter((id) => !keptRaw.has(id)));
|
|
2564
3016
|
}
|
|
2565
3017
|
function picklistOptionLabel(value) {
|
|
2566
3018
|
if (value === undefined || !isTfExpr(value))
|
|
@@ -2949,13 +3401,34 @@ function workflowOutputTaskIdOrKey(taskId, ctx) {
|
|
|
2949
3401
|
}
|
|
2950
3402
|
function filterReference(value, ctx, role) {
|
|
2951
3403
|
assertFilterTaskRefResolves(filterReferenceTaskId(value), ctx);
|
|
2952
|
-
return typeof value === "string"
|
|
3404
|
+
return markUndeclaredScriptOutput(typeof value === "string"
|
|
2953
3405
|
? decodeReferenceString(value, ctx) ?? { kind: "unresolved", uuid: value, hint: "filter-reference" }
|
|
2954
3406
|
: decodeFilterReferenceEnvelope(value, ctx, undefined, role)
|
|
2955
3407
|
?? decodeTemplateTriggerRecordFieldRef(value, ctx)
|
|
2956
3408
|
?? decodeTemplateTaskRef(value, ctx)
|
|
2957
3409
|
?? decodeTemplateForEachRef(value, ctx)
|
|
2958
|
-
?? decodeValue(value, ctx);
|
|
3410
|
+
?? decodeValue(value, ctx), ctx);
|
|
3411
|
+
}
|
|
3412
|
+
/**
|
|
3413
|
+
* A filter reference to an execute-script output its schema doesn't declare
|
|
3414
|
+
* (a switch left-value envelope, or a RHS `task.<id>.result.<name>`) prints as
|
|
3415
|
+
* `unsafeScriptOutput(...)`, the only form build accepts in a filter (#1725).
|
|
3416
|
+
*/
|
|
3417
|
+
function markUndeclaredScriptOutput(reference, ctx) {
|
|
3418
|
+
if (reference.kind !== "taskRef" || reference.undeclaredScriptOutput === true)
|
|
3419
|
+
return reference;
|
|
3420
|
+
if (reference.path[0] !== "result" || reference.path.length < 2)
|
|
3421
|
+
return reference;
|
|
3422
|
+
const task = resolveTaskRefKey(reference.task, ctx).block;
|
|
3423
|
+
if (task?.type !== "elementum_execute_script_task")
|
|
3424
|
+
return reference;
|
|
3425
|
+
const schemaValue = task.attrs.output_schema;
|
|
3426
|
+
const schema = isTfExpr(schemaValue) && schemaValue.$expr === "jsonencode"
|
|
3427
|
+
? schemaValue.value
|
|
3428
|
+
: schemaValue;
|
|
3429
|
+
return scriptOutputReferenceIsDeclared(outputFieldTypesFromScriptSchema(schema), reference.path.join("."))
|
|
3430
|
+
? reference
|
|
3431
|
+
: { ...reference, undeclaredScriptOutput: true };
|
|
2959
3432
|
}
|
|
2960
3433
|
/** The platform task id a filter reference names: `task.<id>.<name>`, or an envelope's `taskReference.taskId`. */
|
|
2961
3434
|
function filterReferenceTaskId(value) {
|
|
@@ -3087,7 +3560,17 @@ function decodeFilter(value, ctx, fieldScope = "app") {
|
|
|
3087
3560
|
},
|
|
3088
3561
|
reference: (reference, role) => filterReference(reference, ctx, role),
|
|
3089
3562
|
referenceType: (reference, fallback) => filterReferenceType(reference, fallback, ctx),
|
|
3563
|
+
// The exporter turns a user id it knows into a user lookup; that prints as `userRef(email)` (#2891).
|
|
3564
|
+
user: (value) => {
|
|
3565
|
+
if (!isTfExpr(value) || value.$expr !== "data-attr" || value.type !== "elementum_user" || value.path[0] !== "id")
|
|
3566
|
+
return undefined;
|
|
3567
|
+
const decoded = decodeValue(value, ctx);
|
|
3568
|
+
return decoded.kind === "user" && typeof decoded.email === "string" ? decoded.email : undefined;
|
|
3569
|
+
},
|
|
3090
3570
|
literal: (literal, _valueType, field) => picklistOptionLabel(literal) ?? stageFilterName(literal, ctx) ?? filterOptionLabel(literal, field, ctx) ?? literal,
|
|
3571
|
+
// A plain string builds as literal text, so a stored option id must print
|
|
3572
|
+
// as `filter.textOption(label)` to build back to that id (#1733).
|
|
3573
|
+
optionLookupsAreIdentities: true,
|
|
3091
3574
|
}, fieldScope);
|
|
3092
3575
|
}
|
|
3093
3576
|
/**
|
|
@@ -3142,7 +3625,28 @@ function dataMineCondition(raw, datamineTable, ctx) {
|
|
|
3142
3625
|
visit(condition);
|
|
3143
3626
|
return condition;
|
|
3144
3627
|
}
|
|
3145
|
-
|
|
3628
|
+
// default_value is a string attribute, so number and decimal defaults come back quoted ("2").
|
|
3629
|
+
function numericDefault(name, type, value, diagnostics) {
|
|
3630
|
+
if (typeof value !== "string")
|
|
3631
|
+
return value;
|
|
3632
|
+
const decoded = numericLiteral(type, value);
|
|
3633
|
+
if (decoded !== undefined)
|
|
3634
|
+
return decoded;
|
|
3635
|
+
diagnostics.push(`on-demand ${type} parameter "${name}" default ${JSON.stringify(value)} has no exact ${type} literal form, ` +
|
|
3636
|
+
`so it was printed as a string${type === "number" ? ", which build rejects until it is rewritten as an integer" : ""}`);
|
|
3637
|
+
return value;
|
|
3638
|
+
}
|
|
3639
|
+
// Only forms that rebuild to the exact same string, so to-tf's stringified default matches the export.
|
|
3640
|
+
function numericLiteral(type, value) {
|
|
3641
|
+
const pattern = type === "number" ? /^-?\d+$/ : /^-?\d+(\.\d+)?$/;
|
|
3642
|
+
if (!pattern.test(value))
|
|
3643
|
+
return undefined;
|
|
3644
|
+
const decoded = Number(value);
|
|
3645
|
+
if (type === "number" && !Number.isSafeInteger(decoded))
|
|
3646
|
+
return undefined;
|
|
3647
|
+
return String(decoded) === value ? decoded : undefined;
|
|
3648
|
+
}
|
|
3649
|
+
function triggerFromBlock(block, ctx, diagnostics) {
|
|
3146
3650
|
const kind = TRIGGER_KINDS[block.type];
|
|
3147
3651
|
if (kind === undefined)
|
|
3148
3652
|
throw new EntityTfError(`unknown trigger resource type "${block.type}"`);
|
|
@@ -3186,7 +3690,10 @@ function triggerFromBlock(block, ctx) {
|
|
|
3186
3690
|
...(parameter.required === true ? { required: true } : {}),
|
|
3187
3691
|
...(parameter.multiple === true ? { multiple: true } : {}),
|
|
3188
3692
|
...(!record && parameter.default_value !== undefined
|
|
3189
|
-
? { defaultValue: type === "userId" ? userIdDefault(parameter.default_value, ctx)
|
|
3693
|
+
? { defaultValue: type === "userId" ? userIdDefault(parameter.default_value, ctx)
|
|
3694
|
+
: type === "boolean" ? booleanDefault(parameter.default_value)
|
|
3695
|
+
: type === "number" || type === "decimal" ? numericDefault(parameter.name, type, parameter.default_value, diagnostics)
|
|
3696
|
+
: parameter.default_value }
|
|
3190
3697
|
: {}),
|
|
3191
3698
|
...(typeof parameter.description === "string" ? { description: parameter.description } : {}),
|
|
3192
3699
|
};
|
|
@@ -3312,8 +3819,10 @@ function triggerFromBlock(block, ctx) {
|
|
|
3312
3819
|
function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
3313
3820
|
const args = {};
|
|
3314
3821
|
for (const [attr, value] of Object.entries(block.attrs)) {
|
|
3315
|
-
// object_field_ids is build-derived from the target's field order (edk#2280)
|
|
3316
|
-
|
|
3822
|
+
// object_field_ids is build-derived from the target's field order (edk#2280),
|
|
3823
|
+
// object_fields / object_system_field_ids from the owner's fields (edk#2680 / #2692),
|
|
3824
|
+
// refs_read from the refs keys the automation reads (edk#2648).
|
|
3825
|
+
if (attr === "parent" || attr === "name" || attr === "depends_on" || attr === "object_field_ids" || attr === "object_fields" || attr === "object_system_field_ids" || attr === "refs_read")
|
|
3317
3826
|
continue;
|
|
3318
3827
|
if (attr === "filter") {
|
|
3319
3828
|
const where = `task ${JSON.stringify(typeof block.attrs.name === "string" ? block.attrs.name : block.label)} (${factory})`;
|
|
@@ -3339,9 +3848,10 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
3339
3848
|
? field.fieldKey
|
|
3340
3849
|
: `${UNRESOLVED_FIELD_MARKER}${field.uuid}`;
|
|
3341
3850
|
const decodedValue = decodeFieldAssignmentValue(item.value, ctx, taskDiagnostics, `${block.type}.${block.label} field ${field.kind === "field" ? field.fieldKey : field.uuid}`);
|
|
3851
|
+
const optionValue = assignmentOptionValue(decodedValue, field, { fieldId: item.field_id, value: item.value }, ctx, taskDiagnostics, `${block.type}.${block.label} field ${field.kind === "field" ? field.fieldKey : field.uuid}`);
|
|
3342
3852
|
const canonicalValue = factory === "createRecord" || factory === "updateField"
|
|
3343
|
-
? canonicalTriggerRecordIdSlot(
|
|
3344
|
-
:
|
|
3853
|
+
? canonicalTriggerRecordIdSlot(optionValue, ctx)
|
|
3854
|
+
: optionValue;
|
|
3345
3855
|
const foreignInfo = field.kind === "field" && field.foreign !== undefined
|
|
3346
3856
|
? {
|
|
3347
3857
|
foreignFieldName: field.foreign.fieldName,
|
|
@@ -3660,10 +4170,24 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
3660
4170
|
args.table = decodeSearchTableReference(value, ctx);
|
|
3661
4171
|
continue;
|
|
3662
4172
|
}
|
|
4173
|
+
if (factory === "approvalStatusUpdate" && attr === "approval_reference") {
|
|
4174
|
+
args.approvalReference = decodeValue(value, ctx);
|
|
4175
|
+
continue;
|
|
4176
|
+
}
|
|
4177
|
+
if (factory === "approvalStatusUpdate" && attr === "record_reference") {
|
|
4178
|
+
args.record = decodeValue(value, ctx);
|
|
4179
|
+
continue;
|
|
4180
|
+
}
|
|
3663
4181
|
if (factory === "approvalChain" && attr === "approval_process_id") {
|
|
3664
4182
|
args.approvalProcess = decodeValue(value, ctx);
|
|
3665
4183
|
continue;
|
|
3666
4184
|
}
|
|
4185
|
+
// The wire attribute is `tags`; approvalChain()'s option is the product's
|
|
4186
|
+
// singular Approval Process Tag (the message task's `tags` is its channel).
|
|
4187
|
+
if (factory === "approvalChain" && attr === "tags") {
|
|
4188
|
+
args.tag = decodeValue(value, ctx);
|
|
4189
|
+
continue;
|
|
4190
|
+
}
|
|
3667
4191
|
if (factory === "approvalChain" && attr === "record_reference") {
|
|
3668
4192
|
args.record = decodeValue(value, ctx);
|
|
3669
4193
|
continue;
|
|
@@ -3909,10 +4433,10 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
3909
4433
|
args.message = decodeValue(value, ctx);
|
|
3910
4434
|
continue;
|
|
3911
4435
|
}
|
|
3912
|
-
// Notification's dynamic
|
|
4436
|
+
// Notification's and addWatcher's dynamic HCL attributes share the names
|
|
3913
4437
|
// `users`/`groups` with sendEmail, but their public options are
|
|
3914
4438
|
// userRefs/groupRefs (not sendEmail's toUsers/toGroups).
|
|
3915
|
-
if (factory === "notification" && (attr === "users" || attr === "groups")) {
|
|
4439
|
+
if ((factory === "notification" || factory === "addWatcher") && (attr === "users" || attr === "groups")) {
|
|
3916
4440
|
args[attr === "users" ? "userRefs" : "groupRefs"] = decodeValue(value, ctx);
|
|
3917
4441
|
continue;
|
|
3918
4442
|
}
|
|
@@ -4128,10 +4652,21 @@ function parentAddress(block, triggerAddress, unmanagedTaskPositions, onUnmanage
|
|
|
4128
4652
|
const suffix = parent.path.length > 0 ? `.${pathNames(parent.path).join(".")}` : "";
|
|
4129
4653
|
return `${parent.type}.${parent.label}${suffix}`;
|
|
4130
4654
|
}
|
|
4131
|
-
function taskRefKey(block, automationLabel, appTfLabel) {
|
|
4655
|
+
function taskRefKey(block, automationLabel, appTfLabel, exportAutoChild) {
|
|
4132
4656
|
const autoChild = childPartFromScopedLabel(appTfLabel, automationLabel, "app");
|
|
4133
4657
|
const taskChild = childPartFromScopedLabel(appTfLabel, block.label ?? "", "app");
|
|
4134
|
-
|
|
4658
|
+
// edk#2484: a renamed automation keeps its authored label, but ei still prefixes its tasks with the new name.
|
|
4659
|
+
// When both prefixes fit, take the one that leaves the task's own name, so a task named after the added or
|
|
4660
|
+
// removed word keeps that word; otherwise fall back to the longer prefix.
|
|
4661
|
+
const owners = [autoChild, exportAutoChild]
|
|
4662
|
+
.filter((child) => child !== undefined && taskChild.startsWith(`${child}_`))
|
|
4663
|
+
.sort((a, b) => b.length - a.length);
|
|
4664
|
+
const ownNameKey = typeof block.attrs.name === "string" ? sanitizeName(block.attrs.name) : undefined;
|
|
4665
|
+
const owner = owners.find((child) => {
|
|
4666
|
+
const rest = taskChild.slice(child.length + 1);
|
|
4667
|
+
return rest === ownNameKey || `_${rest}` === ownNameKey;
|
|
4668
|
+
}) ?? owners[0];
|
|
4669
|
+
const tail = owner !== undefined ? taskChild.slice(owner.length + 1) : taskChild;
|
|
4135
4670
|
const taskName = typeof block.attrs.name === "string" ? block.attrs.name : undefined;
|
|
4136
4671
|
if (taskName !== undefined) {
|
|
4137
4672
|
const sanitized = sanitizeName(taskName);
|
|
@@ -4576,7 +5111,7 @@ function describeUnresolvedTask(taskId, doc, automationLabel, taskByAddress, res
|
|
|
4576
5111
|
`(the platform checks references only when an automation is published), or it is a task type EDK cannot export. ${FIX_FILTER_IN_BUILDER}`;
|
|
4577
5112
|
}
|
|
4578
5113
|
/** Extract one app- or element-owned automation graph from an ei export. */
|
|
4579
|
-
function automationFromTfDocument(doc, automationLabel, appRefName, foreignFieldRefsById, foreignFieldRefsByDataAddress, foreignTableRefsById,
|
|
5114
|
+
function automationFromTfDocument(doc, automationLabel, appRefName, foreignFieldRefsById, foreignFieldRefsByDataAddress, foreignTableRefsById, picklistOptionsByField, fieldNamesByOwnerRefName, foreignAppRefNames, foreignElementRefNames, procedureKeysByDiscriminator, foreignTaskRefNames, groupKeysByName, serviceAccountsById, foreignFileReaderRefsById, foreignAppRefNamespaces) {
|
|
4580
5115
|
const automation = doc.blocks.find((block) => block.kind === "resource" && block.type === AUTOMATION_RESOURCE_TYPE && block.label === automationLabel);
|
|
4581
5116
|
if (automation === undefined)
|
|
4582
5117
|
throw new EntityTfError(`automation resource "${automationLabel}" not found`);
|
|
@@ -4715,9 +5250,14 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
4715
5250
|
}
|
|
4716
5251
|
const appTfLabel = app.label;
|
|
4717
5252
|
const dataBlocks = new Map(doc.blocks.filter((block) => block.kind === "data" && block.type && block.label).map((block) => [`${block.type}.${block.label}`, block]));
|
|
4718
|
-
|
|
5253
|
+
// edk#2484: the trigger keeps ei's label for the automation's current name; the authored label can be an older one.
|
|
5254
|
+
const exportAutoChild = trigger.label !== automationLabel ? childPartFromScopedLabel(appTfLabel, trigger.label ?? "", "app") : undefined;
|
|
5255
|
+
const renamed = (block) => exportAutoChild !== undefined && childPartFromScopedLabel(appTfLabel, block.label ?? "", "app").startsWith(`${exportAutoChild}_`);
|
|
5256
|
+
const taskByAddress = new Map(tasks.map((block) => [`${block.type}.${block.label}`, { block, refKey: taskRefKey(block, automationLabel, appTfLabel, exportAutoChild) }]));
|
|
5257
|
+
const ownerAliases = [trigger, publish].flatMap((block) => block !== undefined && exportAutoChild !== undefined && block.label !== automationLabel
|
|
5258
|
+
? [{ from: `${block.type}.${block.label}`, to: `${block.type}.${automationLabel}` }] : []);
|
|
4719
5259
|
const taskAddressAliases = [...taskByAddress.entries()].flatMap(([from, { block, refKey }]) => {
|
|
4720
|
-
if (soleVariableName(block) === undefined)
|
|
5260
|
+
if (soleVariableName(block) === undefined && !renamed(block))
|
|
4721
5261
|
return [];
|
|
4722
5262
|
const to = `${block.type}.${taskTfLabel(automationLabel, refKey)}`;
|
|
4723
5263
|
return to === from ? [] : [{ from, to }];
|
|
@@ -4759,7 +5299,7 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
4759
5299
|
// (adopt.ts) already refuses two aliases that claim the same target
|
|
4760
5300
|
// address, naming both "from" addresses, so that case fails loudly here
|
|
4761
5301
|
// instead of silently importing the wrong state.
|
|
4762
|
-
const adoptionAddressAliases = [...taskAddressAliases, ...branchAddressAliases];
|
|
5302
|
+
const adoptionAddressAliases = [...ownerAliases, ...taskAddressAliases, ...branchAddressAliases];
|
|
4763
5303
|
const taskTargetOwnerRefNameByAddress = new Map();
|
|
4764
5304
|
const taskTargetOwnerKindByAddress = new Map();
|
|
4765
5305
|
for (const [address, { block }] of taskByAddress) {
|
|
@@ -4795,6 +5335,13 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
4795
5335
|
resourceType: block.type,
|
|
4796
5336
|
});
|
|
4797
5337
|
}
|
|
5338
|
+
const ownerAttrs = resourceBlocks.get(`${app.type}.${app.label}`)?.attrs;
|
|
5339
|
+
const titleFieldNameAttr = ownerAttrs?.["title_field_name"];
|
|
5340
|
+
const titleFieldName = typeof titleFieldNameAttr === "string" && titleFieldNameAttr !== "" ? titleFieldNameAttr : undefined;
|
|
5341
|
+
const idFieldNameAttr = ownerAttrs?.["id_field_name"];
|
|
5342
|
+
const idFieldName = typeof idFieldNameAttr === "string" && idFieldNameAttr !== "" ? idFieldNameAttr : undefined;
|
|
5343
|
+
const statusFieldNameAttr = ownerAttrs?.["status_field_name"];
|
|
5344
|
+
const statusFieldName = typeof statusFieldNameAttr === "string" && statusFieldNameAttr !== "" ? statusFieldNameAttr : undefined;
|
|
4798
5345
|
const stagesByKey = new Map();
|
|
4799
5346
|
const stagesAttr = resourceBlocks.get(`elementum_app.${app.label}`)?.attrs["stages"];
|
|
4800
5347
|
if (Array.isArray(stagesAttr)) {
|
|
@@ -4805,6 +5352,7 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
4805
5352
|
}
|
|
4806
5353
|
const stringifiedValueReferences = { unresolved: false };
|
|
4807
5354
|
const groupsMissingFromOrg = new Set();
|
|
5355
|
+
const optionIdWarnings = new Set();
|
|
4808
5356
|
const ctx = {
|
|
4809
5357
|
appRefName,
|
|
4810
5358
|
appTfLabel: app.label,
|
|
@@ -4816,11 +5364,14 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
4816
5364
|
resourceImportIds,
|
|
4817
5365
|
fieldById,
|
|
4818
5366
|
stagesByKey,
|
|
5367
|
+
...(titleFieldName !== undefined && { titleFieldName }),
|
|
5368
|
+
...(idFieldName !== undefined && { idFieldName }),
|
|
5369
|
+
...(statusFieldName !== undefined && { statusFieldName }),
|
|
4819
5370
|
...(foreignFieldRefsById !== undefined && { foreignFieldRefsById }),
|
|
4820
5371
|
...(foreignFieldRefsByDataAddress !== undefined && { foreignFieldRefsByDataAddress }),
|
|
4821
5372
|
...(foreignTableRefsById !== undefined && { foreignTableRefsById }),
|
|
4822
5373
|
...(foreignFileReaderRefsById !== undefined && { foreignFileReaderRefsById }),
|
|
4823
|
-
...(
|
|
5374
|
+
...(picklistOptionsByField !== undefined && { picklistOptionsByField }),
|
|
4824
5375
|
...(fieldNamesByOwnerRefName !== undefined && { fieldNamesByOwnerRefName }),
|
|
4825
5376
|
...(taskTargetOwnerRefNameByAddress.size > 0 && { taskTargetOwnerRefNameByAddress }),
|
|
4826
5377
|
...(taskTargetOwnerKindByAddress.size > 0 && { taskTargetOwnerKindByAddress }),
|
|
@@ -4831,6 +5382,7 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
4831
5382
|
...(groupKeysByName !== undefined && { groupKeysByName }),
|
|
4832
5383
|
stringifiedValueReferences,
|
|
4833
5384
|
groupsMissingFromOrg,
|
|
5385
|
+
optionIdWarnings,
|
|
4834
5386
|
...(resourceImportIds.has(`${AUTOMATION_RESOURCE_TYPE}.${automationLabel}`) && {
|
|
4835
5387
|
automationId: resourceImportIds.get(`${AUTOMATION_RESOURCE_TYPE}.${automationLabel}`),
|
|
4836
5388
|
}),
|
|
@@ -5057,7 +5609,7 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
5057
5609
|
...(serviceAccountName !== undefined ? { serviceAccountName } : {}),
|
|
5058
5610
|
...(serviceAccountAppRefName !== undefined ? { serviceAccountAppRefName } : {}),
|
|
5059
5611
|
status: automation.attrs.status === "INACTIVE" ? "INACTIVE" : publish ? "ACTIVE" : "DRAFT",
|
|
5060
|
-
trigger: triggerFromBlock(trigger, ctx),
|
|
5612
|
+
trigger: triggerFromBlock(trigger, ctx, taskDiagnostics),
|
|
5061
5613
|
tasks: topTasks,
|
|
5062
5614
|
...(outputs && outputs.length > 0 ? { outputs } : {}),
|
|
5063
5615
|
};
|
|
@@ -5067,12 +5619,13 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
5067
5619
|
ast,
|
|
5068
5620
|
blocks: [automation, trigger, ...tasks, ...ownedBranches, ...(publish ? [publish] : [])],
|
|
5069
5621
|
adoptionAddressAliases,
|
|
5070
|
-
...((unrebuildableTasks.length > 0 || placeholderTasks.length > 0 || outputDiagnostics.length > 0 || taskDiagnostics.length > 0 || groupsMissingFromOrg.size > 0) && {
|
|
5622
|
+
...((unrebuildableTasks.length > 0 || placeholderTasks.length > 0 || outputDiagnostics.length > 0 || taskDiagnostics.length > 0 || groupsMissingFromOrg.size > 0 || optionIdWarnings.size > 0) && {
|
|
5071
5623
|
diagnostics: [
|
|
5072
5624
|
...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`),
|
|
5073
5625
|
...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`),
|
|
5074
5626
|
...outputDiagnostics,
|
|
5075
5627
|
...taskDiagnostics.map((message) => `automation "${automationLabel}": ${message}`),
|
|
5628
|
+
...[...optionIdWarnings].map((message) => `automation "${automationLabel}": ${message}`),
|
|
5076
5629
|
...[...groupsMissingFromOrg].map((name) => `automation "${automationLabel}": group "${name}" is not in the org catalog this pull loaded (org.ts doesn't carry it, or org.ts is missing or couldn't be imported), so it was pulled as groupRef({ name: ${JSON.stringify(name)} }); run \`elementum pull org --data-only\`, then pull this app again to refer to it as org.groups.<key>`),
|
|
5077
5630
|
],
|
|
5078
5631
|
}),
|
|
@@ -5088,7 +5641,7 @@ export function automationFromTf(first, second, third, fourth, fifth, sixth, sev
|
|
|
5088
5641
|
throw new EntityTfError(`automation graph has no ${AUTOMATION_RESOURCE_TYPE} resource, so its resources (${addresses.join(", ") || "none"}) cannot be pulled`);
|
|
5089
5642
|
}
|
|
5090
5643
|
try {
|
|
5091
|
-
const result = automationFromTfDocument({ blocks: [...first] }, automationBlock.label, ctx.ownerHandle, ctx.foreignFieldRefsById, ctx.foreignFieldRefsByDataAddress, ctx.foreignTableRefsById, ctx.
|
|
5644
|
+
const result = automationFromTfDocument({ blocks: [...first] }, automationBlock.label, ctx.ownerHandle, ctx.foreignFieldRefsById, ctx.foreignFieldRefsByDataAddress, ctx.foreignTableRefsById, ctx.picklistOptionsByField, ctx.fieldNamesByOwnerRefName, ctx.foreignAppRefNames, ctx.foreignElementRefNames, ctx.procedureKeysByDiscriminator, ctx.foreignTaskRefNames, ctx.groupKeysByName, ctx.serviceAccountsById, ctx.foreignFileReaderRefsById, ctx.foreignAppRefNamespaces);
|
|
5092
5645
|
if (result.diagnostics)
|
|
5093
5646
|
ctx.diagnostics.push(...result.diagnostics);
|
|
5094
5647
|
return { automation: result.ast };
|