@elementumai/edk 0.12.0 → 0.13.0
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 +2 -0
- package/dist-sdk/src/catalog/factories.d.ts +7 -1
- package/dist-sdk/src/catalog/factories.js +2 -0
- 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 +7 -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/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 +10 -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 +148 -0
- package/dist-sdk/src/engine/pull/stream-root.js +563 -0
- 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 +18 -3
- 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 +68 -0
- package/dist-sdk/src/entities/agent/from-tf.d.ts +34 -1
- package/dist-sdk/src/entities/agent/from-tf.js +262 -2
- package/dist-sdk/src/entities/agent/index.d.ts +1 -1
- package/dist-sdk/src/entities/agent/to-tf.d.ts +8 -10
- package/dist-sdk/src/entities/agent/to-tf.js +158 -14
- 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.js +24 -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 +1 -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.js +70 -27
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +20 -5
- package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -5
- package/dist-sdk/src/entities/automation/from-tf.js +593 -101
- package/dist-sdk/src/entities/automation/index.d.ts +1 -0
- 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 +33 -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/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 +3 -0
- package/dist-sdk/src/entities/automation/to-tf.js +337 -77
- 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/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.js +15 -2
- package/dist-sdk/src/entities/element/module.js +3 -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 +29 -1
- package/dist-sdk/src/entities/field/from-tf.js +99 -6
- 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 +7 -2
- 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/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/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/filters/ast.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +85 -14
- package/dist-sdk/src/entities/shared/filters/index.js +18 -6
- 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.js +9 -5
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +12 -7
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +9 -5
- 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.js +6 -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 +2 -1
- package/dist-sdk/src/entities/view/from-tf.js +7 -4
- package/dist-sdk/src/entities/widget/from-tf.js +13 -2
- 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 +5 -0
- package/dist-sdk/src/graph/index.js +7 -0
- package/dist-sdk/src/graph/modules.js +11 -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 +78 -6
- package/package.json +6 -3
|
@@ -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";
|
|
@@ -20,6 +21,7 @@ import { 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"],
|
|
@@ -447,7 +446,60 @@ function recordFieldRefPath(wireName, ctx, ownerRefName = ctx.appRefName, rootNa
|
|
|
447
446
|
}
|
|
448
447
|
}
|
|
449
448
|
const systemPath = systemFieldRefPath(wireName);
|
|
450
|
-
|
|
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
|
}
|
|
452
504
|
function systemFieldPathRoundTrips(fieldKey, wireSuffix, wireName) {
|
|
453
505
|
return !SYSTEM_FIELD_KEY_SET.has(fieldKey) ||
|
|
@@ -752,6 +804,8 @@ function findRelatedRecordsFieldPath(wireName, taskAddress, ctx) {
|
|
|
752
804
|
const kind = taskAddress !== undefined
|
|
753
805
|
? ctx.taskTargetOwnerKindByAddress?.get(taskAddress)
|
|
754
806
|
: undefined;
|
|
807
|
+
if (wireName === "All found records")
|
|
808
|
+
return ["records"];
|
|
755
809
|
const lower = wireName.toLowerCase();
|
|
756
810
|
if (kind === "app" && (lower === "title" || lower === "id")) {
|
|
757
811
|
return ["record", "id"];
|
|
@@ -768,8 +822,19 @@ function lookupFieldKeyByDisplayName(ownerRefName, displayName, ctx) {
|
|
|
768
822
|
if (field.name.toLowerCase() === lower)
|
|
769
823
|
return field.key;
|
|
770
824
|
}
|
|
825
|
+
// Renamed Title/Handle/Status have no field blocks; build keys them by
|
|
826
|
+
// their fixed keys (#2650, #2671 S1). Title wins when its rename collides
|
|
827
|
+
// with Handle/Status's current name (e.g. Title renamed to "ID").
|
|
828
|
+
const renamedKey = renamableSystemFieldKeyByDisplayName(lower, ctx);
|
|
829
|
+
if (renamedKey !== undefined)
|
|
830
|
+
return renamedKey;
|
|
771
831
|
}
|
|
832
|
+
const ownerRenames = ownerRefName === ctx.appRefName;
|
|
772
833
|
for (const key of SYSTEM_FIELD_KEYS) {
|
|
834
|
+
// Skip defaults for fields this owner renamed; systemFieldRefPath is gated
|
|
835
|
+
// the same way so trigger refs honor it too (#2671 N1).
|
|
836
|
+
if (ownerRenames && renamedSystemFieldKey(key, ctx))
|
|
837
|
+
continue;
|
|
773
838
|
if (DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES[key].toLowerCase() === lower)
|
|
774
839
|
return key;
|
|
775
840
|
}
|
|
@@ -916,13 +981,52 @@ function decodeFieldAssignmentValue(value, ctx, diagnostics, where = "field assi
|
|
|
916
981
|
if (Array.isArray(value)) {
|
|
917
982
|
return value.map((item) => decodeFieldAssignmentValue(item, ctx, diagnostics, where));
|
|
918
983
|
}
|
|
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
984
|
return decodeValueOrStringifiedRef(value, ctx, diagnostics, where);
|
|
925
985
|
}
|
|
986
|
+
/**
|
|
987
|
+
* A Dropdown or Multi-Select assignment's option, printed as
|
|
988
|
+
* `filter.textOption(label)`, the one spelling build accepts there (#1733).
|
|
989
|
+
* Export holds an option id as its options-by-label lookup and Read keeps the
|
|
990
|
+
* label, so either decodes to a label here. A label the field no longer lists
|
|
991
|
+
* keeps the selection too, and build names it. A raw id becomes its label only
|
|
992
|
+
* when it is one of this field's current options (#2568); any other id stays
|
|
993
|
+
* as written and warns, so the building agent can pick a current option. That
|
|
994
|
+
* holds for another app's or element's field too: its id must be one of the
|
|
995
|
+
* options state lists for that field, and its label one of the field's
|
|
996
|
+
* reference options when the reference carries them (#2592, #2596). `raw` is
|
|
997
|
+
* the exported field id and value, which name a foreign field's options. The
|
|
998
|
+
* "" clear stays as written. Any field without static options, record-sourced
|
|
999
|
+
* Dropdowns included, keeps its value.
|
|
1000
|
+
*/
|
|
1001
|
+
function assignmentOptionValue(value, field, raw, ctx, diagnostics, where) {
|
|
1002
|
+
const ownLabels = optionLabelsForDecodedField(field, ctx);
|
|
1003
|
+
const foreignLabels = ownLabels === undefined ? foreignOptionIdLabels(raw.fieldId, raw.value, field, ctx) : undefined;
|
|
1004
|
+
if (ownLabels === undefined && foreignLabels === undefined)
|
|
1005
|
+
return value;
|
|
1006
|
+
const optionLabel = (id) => {
|
|
1007
|
+
if (foreignLabels === undefined)
|
|
1008
|
+
return decodedFieldOptionLabel(id, field, ctx);
|
|
1009
|
+
const label = foreignFieldOptionLabel(id, field, ctx);
|
|
1010
|
+
return label !== undefined && foreignLabels.has(label) ? label : undefined;
|
|
1011
|
+
};
|
|
1012
|
+
const decode = (item) => {
|
|
1013
|
+
if (Array.isArray(item))
|
|
1014
|
+
return item.map(decode);
|
|
1015
|
+
const text = isObject(item) && item.kind === "literal" ? item.value : item;
|
|
1016
|
+
if (typeof text !== "string" || text === "")
|
|
1017
|
+
return item;
|
|
1018
|
+
if (!isUuid(text))
|
|
1019
|
+
return textOption(text);
|
|
1020
|
+
const label = optionLabel(text);
|
|
1021
|
+
if (label !== undefined)
|
|
1022
|
+
return textOption(label);
|
|
1023
|
+
const warning = unknownOptionIdWarning(where, text, field, ctx, foreignLabels !== undefined);
|
|
1024
|
+
if (warning !== undefined)
|
|
1025
|
+
diagnostics.push(warning);
|
|
1026
|
+
return item;
|
|
1027
|
+
};
|
|
1028
|
+
return decode(value);
|
|
1029
|
+
}
|
|
926
1030
|
const VALUE_REFERENCE_KEYS = ["taskReference", "triggerReference", "variableReference"];
|
|
927
1031
|
/**
|
|
928
1032
|
* edk#1646: ei's exporter falls back to a stringified wire ValueReference
|
|
@@ -1116,12 +1220,18 @@ function canonicalTriggerRecordIdSlot(value, ctx) {
|
|
|
1116
1220
|
value.kind === "triggerRef" &&
|
|
1117
1221
|
Array.isArray(value.path) &&
|
|
1118
1222
|
((value.path.length === 1 && value.path[0] === "recordId") ||
|
|
1119
|
-
(value.path.length === 2 && value.path[0] === "record" && value.path[1] ===
|
|
1223
|
+
(value.path.length === 2 && value.path[0] === "record" && value.path[1] === RECORD_ID_REFERENCE_FIELD))) {
|
|
1120
1224
|
return { ...value, path: ["record"] };
|
|
1121
1225
|
}
|
|
1122
1226
|
return value;
|
|
1123
1227
|
}
|
|
1124
1228
|
function triggerRefPath(path, ctx) {
|
|
1229
|
+
// Slack message keys ("Message Content" -> content) are mapped only on that
|
|
1230
|
+
// trigger, so a field or task output with the same display name elsewhere
|
|
1231
|
+
// keeps its own path (#2581).
|
|
1232
|
+
const slackPath = slackTriggerPath(path.map((segment) => typeof segment === "string" ? segment : segment.index), ctx);
|
|
1233
|
+
if (slackPath !== undefined)
|
|
1234
|
+
return slackPath;
|
|
1125
1235
|
const names = pathNames(path);
|
|
1126
1236
|
if (names.length !== 1)
|
|
1127
1237
|
return names;
|
|
@@ -1217,12 +1327,89 @@ function triggerRefPath(path, ctx) {
|
|
|
1217
1327
|
return names;
|
|
1218
1328
|
return recordFieldRefPath(wireName, ctx) ?? names;
|
|
1219
1329
|
}
|
|
1330
|
+
// Top-level properties the record trigger outputs declare (RecordTriggerOutput,
|
|
1331
|
+
// AttachmentTriggerOutput, CommentAddedTriggerOutput in triggers.ts).
|
|
1332
|
+
const RECORD_TRIGGER_OUTPUT_HEADS = new Set(["record", "changedFieldIds", "attachment", "comment"]);
|
|
1333
|
+
const UNDECLARED_HEAD_TRIGGER_TYPES = new Set([
|
|
1334
|
+
"elementum_record_created_trigger",
|
|
1335
|
+
"elementum_record_updated_trigger",
|
|
1336
|
+
"elementum_attachment_added_trigger",
|
|
1337
|
+
"elementum_comment_added_trigger",
|
|
1338
|
+
"elementum_approval_chain_trigger",
|
|
1339
|
+
]);
|
|
1340
|
+
/**
|
|
1341
|
+
* A record trigger ref whose single name matches no field or declared output
|
|
1342
|
+
* (an unknown name, or a group-qualified key such as
|
|
1343
|
+
* "Record Update Trigger - Record Type"). The output type has no index
|
|
1344
|
+
* signature, so pull prints it through an `as any` escape (#2643).
|
|
1345
|
+
*/
|
|
1346
|
+
function undeclaredRecordTriggerHead(path, ctx) {
|
|
1347
|
+
return UNDECLARED_HEAD_TRIGGER_TYPES.has(ctx.trigger.type ?? "") && path.length === 1 && !RECORD_TRIGGER_OUTPUT_HEADS.has(path[0]);
|
|
1348
|
+
}
|
|
1220
1349
|
function forEachItemOwnerRefName(loop, ctx) {
|
|
1221
1350
|
const collection = loop === undefined ? undefined : resourceRef(loop.attrs.list);
|
|
1222
1351
|
return collection === undefined ? undefined : ctx.taskTargetOwnerRefNameByAddress?.get(`${collection.type}.${collection.label}`);
|
|
1223
1352
|
}
|
|
1353
|
+
/**
|
|
1354
|
+
* The tf label of a record loop's collection owner, from the source task's
|
|
1355
|
+
* `object_id` (`elementum_app.<label>.id` / `elementum_element.<label>.id`).
|
|
1356
|
+
* Build names that owner's system-field ids `local.<label>_<field>_field_id`
|
|
1357
|
+
* (calculationFieldScope), which may be another in-workspace aspect.
|
|
1358
|
+
*/
|
|
1359
|
+
function forEachItemOwnerTfLabel(loop, ctx) {
|
|
1360
|
+
const collection = resourceRef(loop.attrs.list);
|
|
1361
|
+
const source = collection === undefined ? undefined : ctx.taskByAddress.get(`${collection.type}.${collection.label}`);
|
|
1362
|
+
const objectId = (source?.block.attrs.object_id ?? null);
|
|
1363
|
+
if (!isTfExpr(objectId) || objectId.$expr !== "resource-attr" ||
|
|
1364
|
+
(objectId.type !== "elementum_app" && objectId.type !== "elementum_element") || objectId.path[0] !== "id") {
|
|
1365
|
+
return undefined;
|
|
1366
|
+
}
|
|
1367
|
+
return objectId.label;
|
|
1368
|
+
}
|
|
1369
|
+
/** Build's sentinel for a record's own id decodes to the typed `recordId`, at any depth. */
|
|
1370
|
+
function recordIdSegments(segments) {
|
|
1371
|
+
return segments.map((segment) => segment === RECORD_ID_REFERENCE_FIELD ? "recordId" : segment);
|
|
1372
|
+
}
|
|
1373
|
+
/**
|
|
1374
|
+
* The item field key behind a `for_each.<id>.${<field id>}` filter path. A
|
|
1375
|
+
* system field's id is a local named by the collection owner's tf label, which
|
|
1376
|
+
* is not this automation's app when the loop reads another aspect's records;
|
|
1377
|
+
* decodeValue only knows this app's prefix and would throw for the whole
|
|
1378
|
+
* automation, so locals resolve here against the owner first.
|
|
1379
|
+
*/
|
|
1380
|
+
function forEachItemFieldKey(fieldPart, loop, ctx) {
|
|
1381
|
+
if (fieldPart.$expr === "local") {
|
|
1382
|
+
if (!fieldPart.name.endsWith("_field_id"))
|
|
1383
|
+
return undefined;
|
|
1384
|
+
const ownerLabel = forEachItemOwnerTfLabel(loop, ctx) ?? ctx.appTfLabel;
|
|
1385
|
+
const prefix = `${ownerLabel}_`;
|
|
1386
|
+
return fieldPart.name.startsWith(prefix)
|
|
1387
|
+
? tfLabelToTsLabel(fieldPart.name.slice(prefix.length, -"_field_id".length))
|
|
1388
|
+
: undefined;
|
|
1389
|
+
}
|
|
1390
|
+
try {
|
|
1391
|
+
const field = fieldRef(fieldPart, ctx);
|
|
1392
|
+
if (field.kind === "field")
|
|
1393
|
+
return field.fieldKey;
|
|
1394
|
+
}
|
|
1395
|
+
catch (error) {
|
|
1396
|
+
if (!(error instanceof EntityTfError))
|
|
1397
|
+
throw error;
|
|
1398
|
+
}
|
|
1399
|
+
return fieldKeyFromTriggerFieldIdExpr(fieldPart, ctx);
|
|
1400
|
+
}
|
|
1224
1401
|
function forEachItemRefPath(path, ctx, loop) {
|
|
1225
1402
|
const names = pathNames(path);
|
|
1403
|
+
const itemOwner = forEachItemOwnerRefName(loop, ctx);
|
|
1404
|
+
if (itemOwner !== undefined && names[0] !== undefined && isUuid(names[0])) {
|
|
1405
|
+
// Provider/filter export uses the actual field ID; script inputs use a
|
|
1406
|
+
// refs-map display name. Both spellings must print the same typed path.
|
|
1407
|
+
if (names.length === 1 && names[0] === RECORD_ID_REFERENCE_FIELD)
|
|
1408
|
+
return ["recordId"];
|
|
1409
|
+
const fieldKey = resolveFieldKeyFromId(names[0], itemOwner, ctx);
|
|
1410
|
+
if (fieldKey !== undefined)
|
|
1411
|
+
return [fieldKey, ...recordIdSegments(names.slice(1))];
|
|
1412
|
+
}
|
|
1226
1413
|
if (names.length !== 1)
|
|
1227
1414
|
return names.flatMap((segment) => segment.split("."));
|
|
1228
1415
|
const wireName = names[0];
|
|
@@ -1232,7 +1419,6 @@ function forEachItemRefPath(path, ctx, loop) {
|
|
|
1232
1419
|
if (wireName === "Record")
|
|
1233
1420
|
return ["recordId"];
|
|
1234
1421
|
const wireNameLower = wireName.toLowerCase();
|
|
1235
|
-
const itemOwner = forEachItemOwnerRefName(loop, ctx);
|
|
1236
1422
|
const ownFields = itemOwner === undefined || itemOwner === ctx.appRefName ? ctx.fieldById.values() : [];
|
|
1237
1423
|
for (const field of ownFields) {
|
|
1238
1424
|
// Some provider paths already contain the stable EDK field key (for
|
|
@@ -1246,6 +1432,14 @@ function forEachItemRefPath(path, ctx, loop) {
|
|
|
1246
1432
|
}
|
|
1247
1433
|
}
|
|
1248
1434
|
}
|
|
1435
|
+
if (itemOwner !== undefined) {
|
|
1436
|
+
// A record collection can belong to a different app/element. Resolve
|
|
1437
|
+
// its refs-map display names through that owner's catalog, just as
|
|
1438
|
+
// build does, rather than printing a foreign label as an item key.
|
|
1439
|
+
const recordPath = recordFieldRefPath(wireName, ctx, itemOwner);
|
|
1440
|
+
if (recordPath !== undefined)
|
|
1441
|
+
return recordPath.slice(1);
|
|
1442
|
+
}
|
|
1249
1443
|
return systemFieldRefPath(wireName) ?? names.flatMap((segment) => segment.split("."));
|
|
1250
1444
|
}
|
|
1251
1445
|
function resolveTaskRefKey(taskIdOrKey, ctx) {
|
|
@@ -1416,10 +1610,17 @@ function decodeTaskReferenceFromString(taskIdOrKey, pathSegments, ctx) {
|
|
|
1416
1610
|
: keyPath;
|
|
1417
1611
|
return { kind: "taskRef", task: refKey, path: outputKeyPath };
|
|
1418
1612
|
}
|
|
1613
|
+
/** A Slack message trigger reference's accessor path; undefined on any other trigger. */
|
|
1614
|
+
function slackTriggerPath(path, ctx) {
|
|
1615
|
+
return ctx.trigger.type === "elementum_slack_message_trigger" ? slackMessageTriggerPathFromWire(path) : undefined;
|
|
1616
|
+
}
|
|
1419
1617
|
function decodeReferenceString(value, ctx) {
|
|
1420
1618
|
const pieces = value.split(".");
|
|
1421
1619
|
if (pieces[0] === "trigger" && pieces.length > 1) {
|
|
1422
1620
|
const path = pieces.slice(1);
|
|
1621
|
+
const slackPath = slackTriggerPath(path, ctx);
|
|
1622
|
+
if (slackPath !== undefined)
|
|
1623
|
+
return { kind: "triggerRef", path: slackPath };
|
|
1423
1624
|
const declaredInput = path.length === 1 ? declaredOnDemandInputForWireName(ctx.trigger, path[0]) : undefined;
|
|
1424
1625
|
if (declaredInput !== undefined)
|
|
1425
1626
|
return { kind: "triggerRef", path: [declaredInput] };
|
|
@@ -1510,7 +1711,7 @@ function decodeTemplateTriggerRecordFieldRef(value, ctx) {
|
|
|
1510
1711
|
if (fieldKey === undefined)
|
|
1511
1712
|
return undefined;
|
|
1512
1713
|
const suffix = suffixPart === undefined ? [] : suffixPart.replace(/^\./, "").split(".").filter((s) => s.length > 0);
|
|
1513
|
-
if (suffix.length === 1 && suffix[0] ===
|
|
1714
|
+
if (suffix.length === 1 && suffix[0] === RECORD_ID_REFERENCE_FIELD) {
|
|
1514
1715
|
return { kind: "triggerRef", path: [root, fieldKey, "recordId"] };
|
|
1515
1716
|
}
|
|
1516
1717
|
return { kind: "triggerRef", path: [root, fieldKey, ...suffix] };
|
|
@@ -1578,7 +1779,7 @@ function templateRecordFieldPath(parts, taskBlock, ctx) {
|
|
|
1578
1779
|
function decodeTemplateForEachRef(value, ctx) {
|
|
1579
1780
|
if (!isTfExpr(value) || value.$expr !== "template")
|
|
1580
1781
|
return undefined;
|
|
1581
|
-
const [prefix, idPart, suffixPart] = value.parts;
|
|
1782
|
+
const [prefix, idPart, suffixPart, fieldPart, fieldSuffix, ...rest] = mergeAdjacentTemplateStrings(value.parts);
|
|
1582
1783
|
if (prefix !== "for_each." || idPart === undefined || typeof idPart === "string")
|
|
1583
1784
|
return undefined;
|
|
1584
1785
|
if (typeof suffixPart !== "string" || !suffixPart.startsWith("."))
|
|
@@ -1588,6 +1789,17 @@ function decodeTemplateForEachRef(value, ctx) {
|
|
|
1588
1789
|
const task = ctx.taskByAddress.get(`${idPart.type}.${idPart.label}`);
|
|
1589
1790
|
if (task === undefined)
|
|
1590
1791
|
return undefined;
|
|
1792
|
+
if (suffixPart === "." && fieldPart !== undefined && typeof fieldPart !== "string") {
|
|
1793
|
+
if (rest.length > 0 || (fieldSuffix !== undefined && (typeof fieldSuffix !== "string" || !fieldSuffix.startsWith("."))))
|
|
1794
|
+
return undefined;
|
|
1795
|
+
const fieldKey = forEachItemFieldKey(fieldPart, task.block, ctx);
|
|
1796
|
+
if (fieldKey === undefined)
|
|
1797
|
+
return undefined;
|
|
1798
|
+
const suffix = (fieldSuffix ?? "").split(".").filter((part) => part.length > 0);
|
|
1799
|
+
return { kind: "forEachItemRef", forEachTask: task.refKey, path: [fieldKey, ...recordIdSegments(suffix)] };
|
|
1800
|
+
}
|
|
1801
|
+
if (fieldPart !== undefined)
|
|
1802
|
+
return undefined;
|
|
1591
1803
|
const nameParts = suffixPart.slice(1).split(".").filter((segment) => segment.length > 0);
|
|
1592
1804
|
if (nameParts.length === 0 && suffixPart !== ".")
|
|
1593
1805
|
return undefined;
|
|
@@ -1826,7 +2038,10 @@ function decodeValue(value, ctx) {
|
|
|
1826
2038
|
if (optionLabel !== undefined)
|
|
1827
2039
|
return { kind: "literal", value: optionLabel };
|
|
1828
2040
|
if (value.type === ctx.trigger.type && value.label === ctx.trigger.label && value.path[0] === "refs") {
|
|
1829
|
-
|
|
2041
|
+
const path = triggerRefPath(value.path.slice(1), ctx);
|
|
2042
|
+
return (undeclaredRecordTriggerHead(path, ctx)
|
|
2043
|
+
? { kind: "triggerRef", path, undeclaredHead: true }
|
|
2044
|
+
: { kind: "triggerRef", path });
|
|
1830
2045
|
}
|
|
1831
2046
|
const task = ctx.taskByAddress.get(`${value.type}.${value.label}`);
|
|
1832
2047
|
if (task !== undefined && value.path[0] === "inner" && value.path[1] === "refs") {
|
|
@@ -2430,37 +2645,20 @@ function labelsFromOptions(value) {
|
|
|
2430
2645
|
return labels.size > 0 ? labels : undefined;
|
|
2431
2646
|
}
|
|
2432
2647
|
/**
|
|
2433
|
-
*
|
|
2434
|
-
*
|
|
2435
|
-
*
|
|
2648
|
+
* The static Dropdown or Multi-Select block a filter's field id expression
|
|
2649
|
+
* names. A reference to another task's record is not a field id, and app
|
|
2650
|
+
* status options are not read here (#2099, #2568).
|
|
2436
2651
|
*/
|
|
2437
|
-
function
|
|
2652
|
+
function picklistBlockForFieldIdExpr(value, blocks) {
|
|
2438
2653
|
if (!isTfExpr(value))
|
|
2439
2654
|
return undefined;
|
|
2440
2655
|
if (value.$expr === "resource-attr" && value.type.endsWith("_field") && value.path[0] === "id") {
|
|
2441
2656
|
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);
|
|
2657
|
+
return isPicklistFieldBlock(block) ? block : undefined;
|
|
2450
2658
|
}
|
|
2451
2659
|
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
|
-
}
|
|
2660
|
+
const fieldLabel = value.name.slice(0, -"_field_id".length);
|
|
2661
|
+
return [...blocks.values()].find((block) => isPicklistFieldBlock(block) && block.label === fieldLabel);
|
|
2464
2662
|
}
|
|
2465
2663
|
return undefined;
|
|
2466
2664
|
}
|
|
@@ -2468,46 +2666,247 @@ function optionLabelsForDecodedField(field, ctx) {
|
|
|
2468
2666
|
if (!isObject(field) || field.kind !== "field" || typeof field.fieldKey !== "string")
|
|
2469
2667
|
return undefined;
|
|
2470
2668
|
const ownerHandle = typeof field.appHandle === "string" ? field.appHandle : ctx.appRefName;
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2669
|
+
const statusLabels = systemStatusLabels(field, ctx);
|
|
2670
|
+
if (statusLabels !== undefined)
|
|
2671
|
+
return statusLabels;
|
|
2672
|
+
const labels = new Set();
|
|
2673
|
+
for (const block of picklistBlocksForDecodedField(field, ctx))
|
|
2674
|
+
collectOptionLabels(labels, block.attrs.options);
|
|
2675
|
+
// The app's system stage: its value decodes from stage_ids_by_key to the
|
|
2676
|
+
// stage name, and build reads that name as a static option (#1733).
|
|
2677
|
+
if (labels.size === 0 && field.fieldKey === "stage" && ownerHandle === ctx.appRefName && ctx.ownerScope === "app") {
|
|
2678
|
+
for (const name of ctx.stagesByKey.values())
|
|
2679
|
+
labels.add(name);
|
|
2680
|
+
}
|
|
2681
|
+
return labels.size > 0 ? labels : undefined;
|
|
2682
|
+
}
|
|
2683
|
+
/** True when `handle` is a ref name this pull already bound to an element or task. */
|
|
2684
|
+
function refMapNames(map, handle) {
|
|
2685
|
+
if (map === undefined)
|
|
2686
|
+
return false;
|
|
2687
|
+
if (map.has(handle))
|
|
2688
|
+
return true;
|
|
2689
|
+
for (const refName of map.values()) {
|
|
2690
|
+
if (refName === handle)
|
|
2691
|
+
return true;
|
|
2478
2692
|
}
|
|
2693
|
+
return false;
|
|
2694
|
+
}
|
|
2695
|
+
/**
|
|
2696
|
+
* A plain string on a foreign field is that app's system stage name.
|
|
2697
|
+
* Elements and tasks have no system stage. A picklist type is not enough:
|
|
2698
|
+
* a record-sourced Dropdown is `PICKLIST` and has no static options.
|
|
2699
|
+
*/
|
|
2700
|
+
function foreignStageName(field, ctx, systemStage) {
|
|
2701
|
+
if (field.fieldKey !== "stage")
|
|
2702
|
+
return false;
|
|
2703
|
+
const meta = isObject(field.foreign) ? field.foreign : undefined;
|
|
2704
|
+
const entityType = typeof meta?.entityType === "string" ? meta.entityType : undefined;
|
|
2705
|
+
if (entityType === "element" || entityType === "task")
|
|
2706
|
+
return false;
|
|
2707
|
+
if (entityType !== "app" || meta?.ownerKindUnknown === true) {
|
|
2708
|
+
const handle = typeof field.appHandle === "string" ? field.appHandle : undefined;
|
|
2709
|
+
if (handle === undefined || refMapNames(ctx.foreignElementRefNames, handle) || refMapNames(ctx.foreignTaskRefNames, handle))
|
|
2710
|
+
return false;
|
|
2711
|
+
}
|
|
2712
|
+
if (systemStage)
|
|
2713
|
+
return true;
|
|
2714
|
+
// A foreign field whose metadata has neither a type nor a name.
|
|
2715
|
+
const fieldType = typeof meta?.fieldType === "string" ? meta.fieldType : undefined;
|
|
2716
|
+
const fieldName = typeof meta?.fieldName === "string" ? meta.fieldName : undefined;
|
|
2717
|
+
return fieldType === undefined && fieldName === undefined;
|
|
2718
|
+
}
|
|
2719
|
+
/**
|
|
2720
|
+
* A raw field id whose registry entry is the system Stage. Those entries come
|
|
2721
|
+
* from system-field state: the key is `stage` and there is no field type.
|
|
2722
|
+
* The display name is recorded too, so its presence is not a custom field.
|
|
2723
|
+
*/
|
|
2724
|
+
function rawIdSystemStage(fieldId, ctx) {
|
|
2725
|
+
if (typeof fieldId !== "string")
|
|
2726
|
+
return false;
|
|
2727
|
+
const identity = ctx.foreignFieldRefsById?.get(fieldId);
|
|
2728
|
+
return identity !== undefined && identity.fieldKey === "stage" && identity.fieldType === undefined;
|
|
2729
|
+
}
|
|
2730
|
+
/** The strings inside a field assignment, including a Multi-Select `jsonencode([...])`. */
|
|
2731
|
+
function foreignAssignmentItems(value) {
|
|
2732
|
+
if (isTfExpr(value) && value.$expr === "jsonencode")
|
|
2733
|
+
return foreignAssignmentItems(value.value);
|
|
2734
|
+
if (Array.isArray(value))
|
|
2735
|
+
return value.flatMap((item) => foreignAssignmentItems(item));
|
|
2736
|
+
return [value];
|
|
2737
|
+
}
|
|
2738
|
+
/**
|
|
2739
|
+
* The option labels of another app's or element's field. A non-recursive
|
|
2740
|
+
* export carries no field resource for it: the static options on its
|
|
2741
|
+
* reference, else the current options state lists for that same field
|
|
2742
|
+
* (#2568). A plain string is a stage name only for the system Stage.
|
|
2743
|
+
* Undefined for an own field, a record-sourced Dropdown, or a field with no
|
|
2744
|
+
* known options.
|
|
2745
|
+
*/
|
|
2746
|
+
function foreignOptionIdLabels(fieldId, value, field, ctx) {
|
|
2747
|
+
if (!isObject(field) || field.kind !== "field")
|
|
2748
|
+
return undefined;
|
|
2749
|
+
const foreign = field.foreign !== undefined || (typeof field.appHandle === "string" && field.appHandle !== ctx.appRefName);
|
|
2750
|
+
if (!foreign)
|
|
2751
|
+
return undefined;
|
|
2752
|
+
const dataField = isTfExpr(fieldId) && fieldId.$expr === "data-attr"
|
|
2753
|
+
? ctx.foreignFieldRefsByDataAddress?.get(`${fieldId.type}.${fieldId.label}`)
|
|
2754
|
+
: undefined;
|
|
2755
|
+
if (dataField?.options !== undefined && dataField.options.length > 0)
|
|
2756
|
+
return new Set(dataField.options);
|
|
2757
|
+
const stateOptions = foreignFieldStateOptions(field, ctx);
|
|
2758
|
+
if (stateOptions.length > 0)
|
|
2759
|
+
return new Set(stateOptions.flatMap((options) => [...options.values()]));
|
|
2760
|
+
const systemStage = dataField?.systemStage === true || rawIdSystemStage(fieldId, ctx);
|
|
2479
2761
|
const labels = new Set();
|
|
2480
|
-
for (const
|
|
2481
|
-
if (
|
|
2762
|
+
for (const item of foreignAssignmentItems(value)) {
|
|
2763
|
+
if (typeof item === "string" && item !== "" && !isUuid(item) && foreignStageName(field, ctx, systemStage))
|
|
2764
|
+
labels.add(item);
|
|
2765
|
+
}
|
|
2766
|
+
return labels.size > 0 ? labels : undefined;
|
|
2767
|
+
}
|
|
2768
|
+
/**
|
|
2769
|
+
* The current options state lists for another app's or element's field: the
|
|
2770
|
+
* picklist resources whose scoped label names that owner and field key
|
|
2771
|
+
* (#2568). Empty when this org's state does not manage that field.
|
|
2772
|
+
*/
|
|
2773
|
+
function foreignFieldStateOptions(field, ctx) {
|
|
2774
|
+
if (!isObject(field) || field.kind !== "field" || typeof field.fieldKey !== "string" || typeof field.appHandle !== "string")
|
|
2775
|
+
return [];
|
|
2776
|
+
const out = [];
|
|
2777
|
+
for (const [label, options] of ctx.picklistOptionsByField ?? []) {
|
|
2778
|
+
const owner = ownerFromScopedChildLabel(label);
|
|
2779
|
+
if (owner === undefined || tfLabelToTsLabel(owner.ownerTfLabel) !== field.appHandle)
|
|
2482
2780
|
continue;
|
|
2781
|
+
if (fieldBagKey(label, ctx) === field.fieldKey)
|
|
2782
|
+
out.push(options);
|
|
2783
|
+
}
|
|
2784
|
+
return out;
|
|
2785
|
+
}
|
|
2786
|
+
/** The label of option `id` when state lists it as an option of this foreign field (#2568). */
|
|
2787
|
+
function foreignFieldOptionLabel(id, field, ctx) {
|
|
2788
|
+
for (const options of foreignFieldStateOptions(field, ctx)) {
|
|
2789
|
+
const label = options.get(id);
|
|
2790
|
+
if (label !== undefined)
|
|
2791
|
+
return label;
|
|
2792
|
+
}
|
|
2793
|
+
return undefined;
|
|
2794
|
+
}
|
|
2795
|
+
/**
|
|
2796
|
+
* The owner's system status options, for a field keyed `status`. An element
|
|
2797
|
+
* has no system status, so its field keyed status is its own Dropdown and
|
|
2798
|
+
* this is undefined (#2683).
|
|
2799
|
+
*/
|
|
2800
|
+
function systemStatusLabels(field, ctx) {
|
|
2801
|
+
if (!isObject(field) || field.kind !== "field" || field.fieldKey !== "status")
|
|
2802
|
+
return undefined;
|
|
2803
|
+
const ownerHandle = typeof field.appHandle === "string" ? field.appHandle : ctx.appRefName;
|
|
2804
|
+
const ownerBlock = ownerHandle === ctx.appRefName
|
|
2805
|
+
? ctx.resourceBlocks.get(`${ctx.ownerScope === "element" ? "elementum_element" : "elementum_app"}.${ctx.appTfLabel}`)
|
|
2806
|
+
: [...ctx.resourceBlocks.values()].find((block) => (block.type === "elementum_app" || block.type === "elementum_element") &&
|
|
2807
|
+
block.label !== undefined &&
|
|
2808
|
+
tfLabelToTsLabel(block.label) === ownerHandle);
|
|
2809
|
+
return labelsFromOptions(ownerBlock?.attrs.status_options);
|
|
2810
|
+
}
|
|
2811
|
+
/**
|
|
2812
|
+
* The static Dropdown and Multi-Select blocks in this export that a decoded
|
|
2813
|
+
* field names. An owner's system status (non-empty `status_options`) is not
|
|
2814
|
+
* one of those blocks. An element Dropdown keyed `status` is.
|
|
2815
|
+
*/
|
|
2816
|
+
function picklistBlocksForDecodedField(field, ctx) {
|
|
2817
|
+
if (!isObject(field) || field.kind !== "field" || typeof field.fieldKey !== "string")
|
|
2818
|
+
return [];
|
|
2819
|
+
if (systemStatusLabels(field, ctx) !== undefined)
|
|
2820
|
+
return [];
|
|
2821
|
+
const ownerHandle = typeof field.appHandle === "string" ? field.appHandle : ctx.appRefName;
|
|
2822
|
+
return [...ctx.resourceBlocks.values()].filter((block) => {
|
|
2823
|
+
if (!isPicklistFieldBlock(block) || block.label === undefined)
|
|
2824
|
+
return false;
|
|
2483
2825
|
if (fieldBagKey(block.label, ctx) !== field.fieldKey)
|
|
2484
|
-
|
|
2485
|
-
const
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2826
|
+
return false;
|
|
2827
|
+
const ownerTf = ownerFromScopedChildLabel(block.label)?.ownerTfLabel ?? ctx.appTfLabel;
|
|
2828
|
+
return tfLabelToTsLabel(ownerTf) === ownerHandle;
|
|
2829
|
+
});
|
|
2830
|
+
}
|
|
2831
|
+
function isPicklistFieldBlock(block) {
|
|
2832
|
+
return block?.type === "elementum_dropdown_field" || block?.type === "elementum_multiselect_field";
|
|
2833
|
+
}
|
|
2834
|
+
/**
|
|
2835
|
+
* The label of option `id` of this picklist block: state must list `id` as
|
|
2836
|
+
* one of the field's options, and the export must still list its label
|
|
2837
|
+
* (#2568). An id of another field, or a deleted option, has none.
|
|
2838
|
+
*/
|
|
2839
|
+
function picklistBlockOptionLabel(id, block, optionsByField) {
|
|
2840
|
+
if (block.label === undefined)
|
|
2841
|
+
return undefined;
|
|
2842
|
+
const label = optionsByField?.get(block.label)?.get(id);
|
|
2843
|
+
return label !== undefined && labelsFromOptions(block.attrs.options)?.has(label) === true ? label : undefined;
|
|
2844
|
+
}
|
|
2845
|
+
/** The compared field's label for option `id`, when `id` is one of its current options (#2568). */
|
|
2846
|
+
function decodedFieldOptionLabel(id, field, ctx) {
|
|
2847
|
+
if (!isUuid(id))
|
|
2848
|
+
return undefined;
|
|
2849
|
+
for (const block of picklistBlocksForDecodedField(field, ctx)) {
|
|
2850
|
+
const label = picklistBlockOptionLabel(id, block, ctx.picklistOptionsByField);
|
|
2851
|
+
if (label !== undefined)
|
|
2852
|
+
return label;
|
|
2490
2853
|
}
|
|
2491
|
-
return
|
|
2854
|
+
return undefined;
|
|
2855
|
+
}
|
|
2856
|
+
/**
|
|
2857
|
+
* The pull warning for an assigned option id that is not one of the field's
|
|
2858
|
+
* current options (#2568). Dax, 2026-11-03: "Any bad configuration shouldn't
|
|
2859
|
+
* abort a pull. It should warn so the building agent can suggest a
|
|
2860
|
+
* correction". Undefined for an own field this export does not hold as a
|
|
2861
|
+
* picklist. `foreign` is a field of another app or element that the caller
|
|
2862
|
+
* already knows has static options; its ids are checked against state alone.
|
|
2863
|
+
*/
|
|
2864
|
+
function unknownOptionIdWarning(where, id, field, ctx, foreign = false) {
|
|
2865
|
+
const blocks = foreign ? [] : picklistBlocksForDecodedField(field, ctx);
|
|
2866
|
+
if (!foreign && blocks.length === 0)
|
|
2867
|
+
return undefined;
|
|
2868
|
+
const known = foreign
|
|
2869
|
+
? foreignFieldStateOptions(field, ctx).length > 0
|
|
2870
|
+
: blocks.some((block) => block.label !== undefined && ctx.picklistOptionsByField?.has(block.label) === true);
|
|
2871
|
+
const reason = known
|
|
2872
|
+
? "is not one of the field's current options (deleted, or an option of another field)"
|
|
2873
|
+
: "cannot be checked because the field's option ids are not in state";
|
|
2874
|
+
return `${where}: option id ${JSON.stringify(id)} ${reason}, so it is kept as the raw id. Select a current option with filter.textOption("<label>")`;
|
|
2492
2875
|
}
|
|
2493
2876
|
/**
|
|
2494
|
-
* A filter literal's option id, printed as the label only when
|
|
2495
|
-
* field
|
|
2496
|
-
*
|
|
2877
|
+
* A filter literal's option id, printed as the label only when it is one of
|
|
2878
|
+
* the compared field's current options. Build then writes the
|
|
2879
|
+
* options-by-label local. An id compared with a static picklist field that
|
|
2880
|
+
* is not one of its current options stays the raw id, and pull names it with
|
|
2881
|
+
* the same warning an assignment gets (#2099, #2568).
|
|
2497
2882
|
*/
|
|
2498
2883
|
function filterOptionLabel(value, field, ctx) {
|
|
2499
2884
|
if (typeof value !== "string" || !isUuid(value))
|
|
2500
2885
|
return undefined;
|
|
2501
|
-
const label =
|
|
2502
|
-
if (label
|
|
2886
|
+
const label = decodedFieldOptionLabel(value, field, ctx);
|
|
2887
|
+
if (label !== undefined)
|
|
2888
|
+
return label;
|
|
2889
|
+
// A record-sourced Dropdown has no static options, and its values are record
|
|
2890
|
+
// ids, so they get no option warning (the assignment path skips them too).
|
|
2891
|
+
if (optionLabelsForDecodedField(field, ctx) === undefined)
|
|
2503
2892
|
return undefined;
|
|
2504
|
-
|
|
2893
|
+
const fieldKey = isObject(field) && typeof field.fieldKey === "string" ? field.fieldKey : "?";
|
|
2894
|
+
const warning = unknownOptionIdWarning(`filter on field ${fieldKey}`, value, field, ctx);
|
|
2895
|
+
if (warning !== undefined)
|
|
2896
|
+
ctx.optionIdWarnings?.add(warning);
|
|
2897
|
+
return undefined;
|
|
2505
2898
|
}
|
|
2506
|
-
/**
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2899
|
+
/**
|
|
2900
|
+
* Option ids `filterOptionLabel` prints as labels at every filter comparison
|
|
2901
|
+
* that holds them. The export still holds the id. An id that any comparison
|
|
2902
|
+
* keeps raw, on another field or a deleted option, is left out, so its
|
|
2903
|
+
* unresolved-UUID warning is not muted (#2568).
|
|
2904
|
+
*/
|
|
2905
|
+
export function filterOptionIdsPrintedAsLabels(doc, optionsByField) {
|
|
2906
|
+
const printed = new Set();
|
|
2907
|
+
const keptRaw = new Set();
|
|
2908
|
+
if (optionsByField === undefined || optionsByField.size === 0)
|
|
2909
|
+
return printed;
|
|
2511
2910
|
const blocks = new Map();
|
|
2512
2911
|
for (const block of doc.blocks) {
|
|
2513
2912
|
if (block.kind !== "resource" || block.type === undefined || block.label === undefined)
|
|
@@ -2531,15 +2930,14 @@ export function filterOptionIdsPrintedAsLabels(doc, optionLabelById) {
|
|
|
2531
2930
|
value.children.forEach((child) => visit(child));
|
|
2532
2931
|
return;
|
|
2533
2932
|
}
|
|
2534
|
-
const
|
|
2535
|
-
if (labels === undefined)
|
|
2536
|
-
return;
|
|
2933
|
+
const block = picklistBlockForFieldIdExpr(fieldId, blocks);
|
|
2537
2934
|
const consider = (literal) => {
|
|
2538
|
-
if (typeof literal !== "string" || !
|
|
2935
|
+
if (typeof literal !== "string" || !isUuid(literal))
|
|
2539
2936
|
return;
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2937
|
+
if (block !== undefined && picklistBlockOptionLabel(literal, block, optionsByField) !== undefined)
|
|
2938
|
+
printed.add(literal);
|
|
2939
|
+
else
|
|
2940
|
+
keptRaw.add(literal);
|
|
2543
2941
|
};
|
|
2544
2942
|
if (isObject(value.value))
|
|
2545
2943
|
consider(value.value.value);
|
|
@@ -2560,7 +2958,7 @@ export function filterOptionIdsPrintedAsLabels(doc, optionLabelById) {
|
|
|
2560
2958
|
visit(attrValue);
|
|
2561
2959
|
}
|
|
2562
2960
|
}
|
|
2563
|
-
return
|
|
2961
|
+
return new Set([...printed].filter((id) => !keptRaw.has(id)));
|
|
2564
2962
|
}
|
|
2565
2963
|
function picklistOptionLabel(value) {
|
|
2566
2964
|
if (value === undefined || !isTfExpr(value))
|
|
@@ -2949,13 +3347,34 @@ function workflowOutputTaskIdOrKey(taskId, ctx) {
|
|
|
2949
3347
|
}
|
|
2950
3348
|
function filterReference(value, ctx, role) {
|
|
2951
3349
|
assertFilterTaskRefResolves(filterReferenceTaskId(value), ctx);
|
|
2952
|
-
return typeof value === "string"
|
|
3350
|
+
return markUndeclaredScriptOutput(typeof value === "string"
|
|
2953
3351
|
? decodeReferenceString(value, ctx) ?? { kind: "unresolved", uuid: value, hint: "filter-reference" }
|
|
2954
3352
|
: decodeFilterReferenceEnvelope(value, ctx, undefined, role)
|
|
2955
3353
|
?? decodeTemplateTriggerRecordFieldRef(value, ctx)
|
|
2956
3354
|
?? decodeTemplateTaskRef(value, ctx)
|
|
2957
3355
|
?? decodeTemplateForEachRef(value, ctx)
|
|
2958
|
-
?? decodeValue(value, ctx);
|
|
3356
|
+
?? decodeValue(value, ctx), ctx);
|
|
3357
|
+
}
|
|
3358
|
+
/**
|
|
3359
|
+
* A filter reference to an execute-script output its schema doesn't declare
|
|
3360
|
+
* (a switch left-value envelope, or a RHS `task.<id>.result.<name>`) prints as
|
|
3361
|
+
* `unsafeScriptOutput(...)`, the only form build accepts in a filter (#1725).
|
|
3362
|
+
*/
|
|
3363
|
+
function markUndeclaredScriptOutput(reference, ctx) {
|
|
3364
|
+
if (reference.kind !== "taskRef" || reference.undeclaredScriptOutput === true)
|
|
3365
|
+
return reference;
|
|
3366
|
+
if (reference.path[0] !== "result" || reference.path.length < 2)
|
|
3367
|
+
return reference;
|
|
3368
|
+
const task = resolveTaskRefKey(reference.task, ctx).block;
|
|
3369
|
+
if (task?.type !== "elementum_execute_script_task")
|
|
3370
|
+
return reference;
|
|
3371
|
+
const schemaValue = task.attrs.output_schema;
|
|
3372
|
+
const schema = isTfExpr(schemaValue) && schemaValue.$expr === "jsonencode"
|
|
3373
|
+
? schemaValue.value
|
|
3374
|
+
: schemaValue;
|
|
3375
|
+
return scriptOutputReferenceIsDeclared(outputFieldTypesFromScriptSchema(schema), reference.path.join("."))
|
|
3376
|
+
? reference
|
|
3377
|
+
: { ...reference, undeclaredScriptOutput: true };
|
|
2959
3378
|
}
|
|
2960
3379
|
/** The platform task id a filter reference names: `task.<id>.<name>`, or an envelope's `taskReference.taskId`. */
|
|
2961
3380
|
function filterReferenceTaskId(value) {
|
|
@@ -3088,6 +3507,9 @@ function decodeFilter(value, ctx, fieldScope = "app") {
|
|
|
3088
3507
|
reference: (reference, role) => filterReference(reference, ctx, role),
|
|
3089
3508
|
referenceType: (reference, fallback) => filterReferenceType(reference, fallback, ctx),
|
|
3090
3509
|
literal: (literal, _valueType, field) => picklistOptionLabel(literal) ?? stageFilterName(literal, ctx) ?? filterOptionLabel(literal, field, ctx) ?? literal,
|
|
3510
|
+
// A plain string builds as literal text, so a stored option id must print
|
|
3511
|
+
// as `filter.textOption(label)` to build back to that id (#1733).
|
|
3512
|
+
optionLookupsAreIdentities: true,
|
|
3091
3513
|
}, fieldScope);
|
|
3092
3514
|
}
|
|
3093
3515
|
/**
|
|
@@ -3142,7 +3564,28 @@ function dataMineCondition(raw, datamineTable, ctx) {
|
|
|
3142
3564
|
visit(condition);
|
|
3143
3565
|
return condition;
|
|
3144
3566
|
}
|
|
3145
|
-
|
|
3567
|
+
// default_value is a string attribute, so number and decimal defaults come back quoted ("2").
|
|
3568
|
+
function numericDefault(name, type, value, diagnostics) {
|
|
3569
|
+
if (typeof value !== "string")
|
|
3570
|
+
return value;
|
|
3571
|
+
const decoded = numericLiteral(type, value);
|
|
3572
|
+
if (decoded !== undefined)
|
|
3573
|
+
return decoded;
|
|
3574
|
+
diagnostics.push(`on-demand ${type} parameter "${name}" default ${JSON.stringify(value)} has no exact ${type} literal form, ` +
|
|
3575
|
+
`so it was printed as a string${type === "number" ? ", which build rejects until it is rewritten as an integer" : ""}`);
|
|
3576
|
+
return value;
|
|
3577
|
+
}
|
|
3578
|
+
// Only forms that rebuild to the exact same string, so to-tf's stringified default matches the export.
|
|
3579
|
+
function numericLiteral(type, value) {
|
|
3580
|
+
const pattern = type === "number" ? /^-?\d+$/ : /^-?\d+(\.\d+)?$/;
|
|
3581
|
+
if (!pattern.test(value))
|
|
3582
|
+
return undefined;
|
|
3583
|
+
const decoded = Number(value);
|
|
3584
|
+
if (type === "number" && !Number.isSafeInteger(decoded))
|
|
3585
|
+
return undefined;
|
|
3586
|
+
return String(decoded) === value ? decoded : undefined;
|
|
3587
|
+
}
|
|
3588
|
+
function triggerFromBlock(block, ctx, diagnostics) {
|
|
3146
3589
|
const kind = TRIGGER_KINDS[block.type];
|
|
3147
3590
|
if (kind === undefined)
|
|
3148
3591
|
throw new EntityTfError(`unknown trigger resource type "${block.type}"`);
|
|
@@ -3186,7 +3629,10 @@ function triggerFromBlock(block, ctx) {
|
|
|
3186
3629
|
...(parameter.required === true ? { required: true } : {}),
|
|
3187
3630
|
...(parameter.multiple === true ? { multiple: true } : {}),
|
|
3188
3631
|
...(!record && parameter.default_value !== undefined
|
|
3189
|
-
? { defaultValue: type === "userId" ? userIdDefault(parameter.default_value, ctx)
|
|
3632
|
+
? { defaultValue: type === "userId" ? userIdDefault(parameter.default_value, ctx)
|
|
3633
|
+
: type === "boolean" ? booleanDefault(parameter.default_value)
|
|
3634
|
+
: type === "number" || type === "decimal" ? numericDefault(parameter.name, type, parameter.default_value, diagnostics)
|
|
3635
|
+
: parameter.default_value }
|
|
3190
3636
|
: {}),
|
|
3191
3637
|
...(typeof parameter.description === "string" ? { description: parameter.description } : {}),
|
|
3192
3638
|
};
|
|
@@ -3312,8 +3758,10 @@ function triggerFromBlock(block, ctx) {
|
|
|
3312
3758
|
function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
3313
3759
|
const args = {};
|
|
3314
3760
|
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
|
-
|
|
3761
|
+
// object_field_ids is build-derived from the target's field order (edk#2280),
|
|
3762
|
+
// object_fields / object_system_field_ids from the owner's fields (edk#2680 / #2692),
|
|
3763
|
+
// refs_read from the refs keys the automation reads (edk#2648).
|
|
3764
|
+
if (attr === "parent" || attr === "name" || attr === "depends_on" || attr === "object_field_ids" || attr === "object_fields" || attr === "object_system_field_ids" || attr === "refs_read")
|
|
3317
3765
|
continue;
|
|
3318
3766
|
if (attr === "filter") {
|
|
3319
3767
|
const where = `task ${JSON.stringify(typeof block.attrs.name === "string" ? block.attrs.name : block.label)} (${factory})`;
|
|
@@ -3339,9 +3787,10 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
3339
3787
|
? field.fieldKey
|
|
3340
3788
|
: `${UNRESOLVED_FIELD_MARKER}${field.uuid}`;
|
|
3341
3789
|
const decodedValue = decodeFieldAssignmentValue(item.value, ctx, taskDiagnostics, `${block.type}.${block.label} field ${field.kind === "field" ? field.fieldKey : field.uuid}`);
|
|
3790
|
+
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
3791
|
const canonicalValue = factory === "createRecord" || factory === "updateField"
|
|
3343
|
-
? canonicalTriggerRecordIdSlot(
|
|
3344
|
-
:
|
|
3792
|
+
? canonicalTriggerRecordIdSlot(optionValue, ctx)
|
|
3793
|
+
: optionValue;
|
|
3345
3794
|
const foreignInfo = field.kind === "field" && field.foreign !== undefined
|
|
3346
3795
|
? {
|
|
3347
3796
|
foreignFieldName: field.foreign.fieldName,
|
|
@@ -3660,10 +4109,24 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
3660
4109
|
args.table = decodeSearchTableReference(value, ctx);
|
|
3661
4110
|
continue;
|
|
3662
4111
|
}
|
|
4112
|
+
if (factory === "approvalStatusUpdate" && attr === "approval_reference") {
|
|
4113
|
+
args.approvalReference = decodeValue(value, ctx);
|
|
4114
|
+
continue;
|
|
4115
|
+
}
|
|
4116
|
+
if (factory === "approvalStatusUpdate" && attr === "record_reference") {
|
|
4117
|
+
args.record = decodeValue(value, ctx);
|
|
4118
|
+
continue;
|
|
4119
|
+
}
|
|
3663
4120
|
if (factory === "approvalChain" && attr === "approval_process_id") {
|
|
3664
4121
|
args.approvalProcess = decodeValue(value, ctx);
|
|
3665
4122
|
continue;
|
|
3666
4123
|
}
|
|
4124
|
+
// The wire attribute is `tags`; approvalChain()'s option is the product's
|
|
4125
|
+
// singular Approval Process Tag (the message task's `tags` is its channel).
|
|
4126
|
+
if (factory === "approvalChain" && attr === "tags") {
|
|
4127
|
+
args.tag = decodeValue(value, ctx);
|
|
4128
|
+
continue;
|
|
4129
|
+
}
|
|
3667
4130
|
if (factory === "approvalChain" && attr === "record_reference") {
|
|
3668
4131
|
args.record = decodeValue(value, ctx);
|
|
3669
4132
|
continue;
|
|
@@ -3909,10 +4372,10 @@ function taskArgs(block, factory, ctx, taskDiagnostics) {
|
|
|
3909
4372
|
args.message = decodeValue(value, ctx);
|
|
3910
4373
|
continue;
|
|
3911
4374
|
}
|
|
3912
|
-
// Notification's dynamic
|
|
4375
|
+
// Notification's and addWatcher's dynamic HCL attributes share the names
|
|
3913
4376
|
// `users`/`groups` with sendEmail, but their public options are
|
|
3914
4377
|
// userRefs/groupRefs (not sendEmail's toUsers/toGroups).
|
|
3915
|
-
if (factory === "notification" && (attr === "users" || attr === "groups")) {
|
|
4378
|
+
if ((factory === "notification" || factory === "addWatcher") && (attr === "users" || attr === "groups")) {
|
|
3916
4379
|
args[attr === "users" ? "userRefs" : "groupRefs"] = decodeValue(value, ctx);
|
|
3917
4380
|
continue;
|
|
3918
4381
|
}
|
|
@@ -4128,10 +4591,21 @@ function parentAddress(block, triggerAddress, unmanagedTaskPositions, onUnmanage
|
|
|
4128
4591
|
const suffix = parent.path.length > 0 ? `.${pathNames(parent.path).join(".")}` : "";
|
|
4129
4592
|
return `${parent.type}.${parent.label}${suffix}`;
|
|
4130
4593
|
}
|
|
4131
|
-
function taskRefKey(block, automationLabel, appTfLabel) {
|
|
4594
|
+
function taskRefKey(block, automationLabel, appTfLabel, exportAutoChild) {
|
|
4132
4595
|
const autoChild = childPartFromScopedLabel(appTfLabel, automationLabel, "app");
|
|
4133
4596
|
const taskChild = childPartFromScopedLabel(appTfLabel, block.label ?? "", "app");
|
|
4134
|
-
|
|
4597
|
+
// edk#2484: a renamed automation keeps its authored label, but ei still prefixes its tasks with the new name.
|
|
4598
|
+
// When both prefixes fit, take the one that leaves the task's own name, so a task named after the added or
|
|
4599
|
+
// removed word keeps that word; otherwise fall back to the longer prefix.
|
|
4600
|
+
const owners = [autoChild, exportAutoChild]
|
|
4601
|
+
.filter((child) => child !== undefined && taskChild.startsWith(`${child}_`))
|
|
4602
|
+
.sort((a, b) => b.length - a.length);
|
|
4603
|
+
const ownNameKey = typeof block.attrs.name === "string" ? sanitizeName(block.attrs.name) : undefined;
|
|
4604
|
+
const owner = owners.find((child) => {
|
|
4605
|
+
const rest = taskChild.slice(child.length + 1);
|
|
4606
|
+
return rest === ownNameKey || `_${rest}` === ownNameKey;
|
|
4607
|
+
}) ?? owners[0];
|
|
4608
|
+
const tail = owner !== undefined ? taskChild.slice(owner.length + 1) : taskChild;
|
|
4135
4609
|
const taskName = typeof block.attrs.name === "string" ? block.attrs.name : undefined;
|
|
4136
4610
|
if (taskName !== undefined) {
|
|
4137
4611
|
const sanitized = sanitizeName(taskName);
|
|
@@ -4576,7 +5050,7 @@ function describeUnresolvedTask(taskId, doc, automationLabel, taskByAddress, res
|
|
|
4576
5050
|
`(the platform checks references only when an automation is published), or it is a task type EDK cannot export. ${FIX_FILTER_IN_BUILDER}`;
|
|
4577
5051
|
}
|
|
4578
5052
|
/** Extract one app- or element-owned automation graph from an ei export. */
|
|
4579
|
-
function automationFromTfDocument(doc, automationLabel, appRefName, foreignFieldRefsById, foreignFieldRefsByDataAddress, foreignTableRefsById,
|
|
5053
|
+
function automationFromTfDocument(doc, automationLabel, appRefName, foreignFieldRefsById, foreignFieldRefsByDataAddress, foreignTableRefsById, picklistOptionsByField, fieldNamesByOwnerRefName, foreignAppRefNames, foreignElementRefNames, procedureKeysByDiscriminator, foreignTaskRefNames, groupKeysByName, serviceAccountsById, foreignFileReaderRefsById, foreignAppRefNamespaces) {
|
|
4580
5054
|
const automation = doc.blocks.find((block) => block.kind === "resource" && block.type === AUTOMATION_RESOURCE_TYPE && block.label === automationLabel);
|
|
4581
5055
|
if (automation === undefined)
|
|
4582
5056
|
throw new EntityTfError(`automation resource "${automationLabel}" not found`);
|
|
@@ -4715,9 +5189,14 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
4715
5189
|
}
|
|
4716
5190
|
const appTfLabel = app.label;
|
|
4717
5191
|
const dataBlocks = new Map(doc.blocks.filter((block) => block.kind === "data" && block.type && block.label).map((block) => [`${block.type}.${block.label}`, block]));
|
|
4718
|
-
|
|
5192
|
+
// edk#2484: the trigger keeps ei's label for the automation's current name; the authored label can be an older one.
|
|
5193
|
+
const exportAutoChild = trigger.label !== automationLabel ? childPartFromScopedLabel(appTfLabel, trigger.label ?? "", "app") : undefined;
|
|
5194
|
+
const renamed = (block) => exportAutoChild !== undefined && childPartFromScopedLabel(appTfLabel, block.label ?? "", "app").startsWith(`${exportAutoChild}_`);
|
|
5195
|
+
const taskByAddress = new Map(tasks.map((block) => [`${block.type}.${block.label}`, { block, refKey: taskRefKey(block, automationLabel, appTfLabel, exportAutoChild) }]));
|
|
5196
|
+
const ownerAliases = [trigger, publish].flatMap((block) => block !== undefined && exportAutoChild !== undefined && block.label !== automationLabel
|
|
5197
|
+
? [{ from: `${block.type}.${block.label}`, to: `${block.type}.${automationLabel}` }] : []);
|
|
4719
5198
|
const taskAddressAliases = [...taskByAddress.entries()].flatMap(([from, { block, refKey }]) => {
|
|
4720
|
-
if (soleVariableName(block) === undefined)
|
|
5199
|
+
if (soleVariableName(block) === undefined && !renamed(block))
|
|
4721
5200
|
return [];
|
|
4722
5201
|
const to = `${block.type}.${taskTfLabel(automationLabel, refKey)}`;
|
|
4723
5202
|
return to === from ? [] : [{ from, to }];
|
|
@@ -4759,7 +5238,7 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
4759
5238
|
// (adopt.ts) already refuses two aliases that claim the same target
|
|
4760
5239
|
// address, naming both "from" addresses, so that case fails loudly here
|
|
4761
5240
|
// instead of silently importing the wrong state.
|
|
4762
|
-
const adoptionAddressAliases = [...taskAddressAliases, ...branchAddressAliases];
|
|
5241
|
+
const adoptionAddressAliases = [...ownerAliases, ...taskAddressAliases, ...branchAddressAliases];
|
|
4763
5242
|
const taskTargetOwnerRefNameByAddress = new Map();
|
|
4764
5243
|
const taskTargetOwnerKindByAddress = new Map();
|
|
4765
5244
|
for (const [address, { block }] of taskByAddress) {
|
|
@@ -4795,6 +5274,13 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
4795
5274
|
resourceType: block.type,
|
|
4796
5275
|
});
|
|
4797
5276
|
}
|
|
5277
|
+
const ownerAttrs = resourceBlocks.get(`${app.type}.${app.label}`)?.attrs;
|
|
5278
|
+
const titleFieldNameAttr = ownerAttrs?.["title_field_name"];
|
|
5279
|
+
const titleFieldName = typeof titleFieldNameAttr === "string" && titleFieldNameAttr !== "" ? titleFieldNameAttr : undefined;
|
|
5280
|
+
const idFieldNameAttr = ownerAttrs?.["id_field_name"];
|
|
5281
|
+
const idFieldName = typeof idFieldNameAttr === "string" && idFieldNameAttr !== "" ? idFieldNameAttr : undefined;
|
|
5282
|
+
const statusFieldNameAttr = ownerAttrs?.["status_field_name"];
|
|
5283
|
+
const statusFieldName = typeof statusFieldNameAttr === "string" && statusFieldNameAttr !== "" ? statusFieldNameAttr : undefined;
|
|
4798
5284
|
const stagesByKey = new Map();
|
|
4799
5285
|
const stagesAttr = resourceBlocks.get(`elementum_app.${app.label}`)?.attrs["stages"];
|
|
4800
5286
|
if (Array.isArray(stagesAttr)) {
|
|
@@ -4805,6 +5291,7 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
4805
5291
|
}
|
|
4806
5292
|
const stringifiedValueReferences = { unresolved: false };
|
|
4807
5293
|
const groupsMissingFromOrg = new Set();
|
|
5294
|
+
const optionIdWarnings = new Set();
|
|
4808
5295
|
const ctx = {
|
|
4809
5296
|
appRefName,
|
|
4810
5297
|
appTfLabel: app.label,
|
|
@@ -4816,11 +5303,14 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
4816
5303
|
resourceImportIds,
|
|
4817
5304
|
fieldById,
|
|
4818
5305
|
stagesByKey,
|
|
5306
|
+
...(titleFieldName !== undefined && { titleFieldName }),
|
|
5307
|
+
...(idFieldName !== undefined && { idFieldName }),
|
|
5308
|
+
...(statusFieldName !== undefined && { statusFieldName }),
|
|
4819
5309
|
...(foreignFieldRefsById !== undefined && { foreignFieldRefsById }),
|
|
4820
5310
|
...(foreignFieldRefsByDataAddress !== undefined && { foreignFieldRefsByDataAddress }),
|
|
4821
5311
|
...(foreignTableRefsById !== undefined && { foreignTableRefsById }),
|
|
4822
5312
|
...(foreignFileReaderRefsById !== undefined && { foreignFileReaderRefsById }),
|
|
4823
|
-
...(
|
|
5313
|
+
...(picklistOptionsByField !== undefined && { picklistOptionsByField }),
|
|
4824
5314
|
...(fieldNamesByOwnerRefName !== undefined && { fieldNamesByOwnerRefName }),
|
|
4825
5315
|
...(taskTargetOwnerRefNameByAddress.size > 0 && { taskTargetOwnerRefNameByAddress }),
|
|
4826
5316
|
...(taskTargetOwnerKindByAddress.size > 0 && { taskTargetOwnerKindByAddress }),
|
|
@@ -4831,6 +5321,7 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
4831
5321
|
...(groupKeysByName !== undefined && { groupKeysByName }),
|
|
4832
5322
|
stringifiedValueReferences,
|
|
4833
5323
|
groupsMissingFromOrg,
|
|
5324
|
+
optionIdWarnings,
|
|
4834
5325
|
...(resourceImportIds.has(`${AUTOMATION_RESOURCE_TYPE}.${automationLabel}`) && {
|
|
4835
5326
|
automationId: resourceImportIds.get(`${AUTOMATION_RESOURCE_TYPE}.${automationLabel}`),
|
|
4836
5327
|
}),
|
|
@@ -5057,7 +5548,7 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
5057
5548
|
...(serviceAccountName !== undefined ? { serviceAccountName } : {}),
|
|
5058
5549
|
...(serviceAccountAppRefName !== undefined ? { serviceAccountAppRefName } : {}),
|
|
5059
5550
|
status: automation.attrs.status === "INACTIVE" ? "INACTIVE" : publish ? "ACTIVE" : "DRAFT",
|
|
5060
|
-
trigger: triggerFromBlock(trigger, ctx),
|
|
5551
|
+
trigger: triggerFromBlock(trigger, ctx, taskDiagnostics),
|
|
5061
5552
|
tasks: topTasks,
|
|
5062
5553
|
...(outputs && outputs.length > 0 ? { outputs } : {}),
|
|
5063
5554
|
};
|
|
@@ -5067,12 +5558,13 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
5067
5558
|
ast,
|
|
5068
5559
|
blocks: [automation, trigger, ...tasks, ...ownedBranches, ...(publish ? [publish] : [])],
|
|
5069
5560
|
adoptionAddressAliases,
|
|
5070
|
-
...((unrebuildableTasks.length > 0 || placeholderTasks.length > 0 || outputDiagnostics.length > 0 || taskDiagnostics.length > 0 || groupsMissingFromOrg.size > 0) && {
|
|
5561
|
+
...((unrebuildableTasks.length > 0 || placeholderTasks.length > 0 || outputDiagnostics.length > 0 || taskDiagnostics.length > 0 || groupsMissingFromOrg.size > 0 || optionIdWarnings.size > 0) && {
|
|
5071
5562
|
diagnostics: [
|
|
5072
5563
|
...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
5564
|
...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
5565
|
...outputDiagnostics,
|
|
5075
5566
|
...taskDiagnostics.map((message) => `automation "${automationLabel}": ${message}`),
|
|
5567
|
+
...[...optionIdWarnings].map((message) => `automation "${automationLabel}": ${message}`),
|
|
5076
5568
|
...[...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
5569
|
],
|
|
5078
5570
|
}),
|
|
@@ -5088,7 +5580,7 @@ export function automationFromTf(first, second, third, fourth, fifth, sixth, sev
|
|
|
5088
5580
|
throw new EntityTfError(`automation graph has no ${AUTOMATION_RESOURCE_TYPE} resource, so its resources (${addresses.join(", ") || "none"}) cannot be pulled`);
|
|
5089
5581
|
}
|
|
5090
5582
|
try {
|
|
5091
|
-
const result = automationFromTfDocument({ blocks: [...first] }, automationBlock.label, ctx.ownerHandle, ctx.foreignFieldRefsById, ctx.foreignFieldRefsByDataAddress, ctx.foreignTableRefsById, ctx.
|
|
5583
|
+
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
5584
|
if (result.diagnostics)
|
|
5093
5585
|
ctx.diagnostics.push(...result.diagnostics);
|
|
5094
5586
|
return { automation: result.ast };
|