@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
|
@@ -8,13 +8,15 @@ import { workspaceAspectKey } from "../../engine/build/context.js";
|
|
|
8
8
|
import { SEARCH_TABLE_RESOURCE_TYPES } from "../search-table/types.js";
|
|
9
9
|
import { fieldRefToTfValue } from "../field/to-tf.js";
|
|
10
10
|
import { scriptLintFindings } from "./script-lint.js";
|
|
11
|
+
import { setRefsRead } from "./refs-read.js";
|
|
11
12
|
import { MANAGED_FIELD_ORDER_RESOURCE_TYPE } from "../field/types.js";
|
|
12
13
|
import { SERVICE_ACCOUNT_RESOURCE_TYPE } from "../service-account/module.js";
|
|
13
14
|
import { serviceAccountRefToTf } from "../service-account/to-tf.js";
|
|
14
15
|
import { workspaceServiceAccountAppResolver } from "../service-account/workspace-owner.js";
|
|
15
16
|
import { foreignFieldDataLabel, resolveForeignRef } from "../shared/foreign-ref.js";
|
|
16
17
|
import { filterToTf as serializeFilterToTf } from "../shared/filters/tf-codec.js";
|
|
17
|
-
import { referenceValueTypeForField } from "../shared/filters/index.js";
|
|
18
|
+
import { isTextOptionValue, referenceValueTypeForField } from "../shared/filters/index.js";
|
|
19
|
+
import { plainOptionStringWarning, rawOptionIdWarning } from "../shared/raw-option-id.js";
|
|
18
20
|
import { aiCompletionRefsIndex, API_TASK_REF_AUTHORING_NAMES, API_TASK_REF_WIRE_NAMES, executeScriptRefsIndex, OUTPUT_KEY_CANONICAL, OUTPUT_KEY_WIRE_NAME } from "./output-key-wire-name.js";
|
|
19
21
|
import { outputFieldTypesFromScriptSchema, scriptOutputReferenceIsDeclared } from "./output-field-types.js";
|
|
20
22
|
import { RESOURCE_TYPE_TO_EXECUTOR, TASK_OUTPUT_CONTRACTS } from "./generated/task-output-contracts.js";
|
|
@@ -25,11 +27,12 @@ import { UNRESOLVED_FIELD_MARKER } from "../shared/ref.js";
|
|
|
25
27
|
import { ELEMENT_SYSTEM_FIELD_KEYS } from "../element/system-fields.js";
|
|
26
28
|
import { TABLE_RESOURCE_TYPE } from "../table/module.js";
|
|
27
29
|
import { AUTOMATION_RESOURCE_TYPE, WORKFLOW_PUBLISH_RESOURCE_TYPE, automationResourceLabel } from "./types.js";
|
|
28
|
-
import { AI_SEARCH_TABLE_OUTPUT_NAMES, TASK_OUTPUT_REFERENCE_NAMES, TRIGGER_WHOLE_RECORD_MARKER, USER_SEARCH_REF_WIRE_NAMES, triggerAttachmentPayloadRef, triggerWholeRecordRefJson, } from "./task-output-labels.js";
|
|
30
|
+
import { AI_SEARCH_TABLE_OUTPUT_NAMES, RECORD_ID_REFERENCE_FIELD, TASK_OUTPUT_REFERENCE_NAMES, TRIGGER_WHOLE_RECORD_MARKER, USER_SEARCH_REF_WIRE_NAMES, triggerAttachmentPayloadRef, triggerWholeRecordRefJson, } from "./task-output-labels.js";
|
|
29
31
|
import { onDemandTriggerRefKey } from "./value-ref-tf.js";
|
|
30
32
|
import { normalizeOnDemandParamKey } from "../../../pull/util.js";
|
|
31
33
|
import { PROVIDER_FIXED_SYSTEM_FIELD_KEYS, recordFieldWireRefName } from "./system-ref-name.js";
|
|
32
34
|
import { taskTfLabel } from "./task-label.js";
|
|
35
|
+
import { slackMessageTriggerReferenceName, slackMessageTriggerRefName } from "./slack-message-refs.js";
|
|
33
36
|
import { automationRunTargetResourceAttr, automationTargetOwner, bareStaticRunTarget, onDemandRecordParamNames, recordInputMappingProblem } from "./run-target.js";
|
|
34
37
|
import { FIELD_TYPE_MAP, isOnDemandRecordType } from "../shared/types/field-types.js";
|
|
35
38
|
/** The context for reading records of `appRefName` (a `kind`), retargeted from the owner. */
|
|
@@ -49,10 +52,14 @@ const ON_DEMAND_TF_PARAM_TYPES = new Map([
|
|
|
49
52
|
function recordOwnerContext(owner, appRefName, kind, fieldNames) {
|
|
50
53
|
if (appRefName === owner.appRefName && (kind === undefined || kind === owner.parentScope))
|
|
51
54
|
return owner;
|
|
55
|
+
// Retarget fieldAddresses with fieldNames so wireRefName's custom-shadow
|
|
56
|
+
// check (#1871) reads the record app's authored keys, not the automation
|
|
57
|
+
// owner's (taskWireRefName / recordParamFieldWireName / forEach item refs).
|
|
52
58
|
return {
|
|
53
59
|
...owner,
|
|
54
60
|
appRefName,
|
|
55
61
|
fieldNames: fieldNames ?? new Map(),
|
|
62
|
+
fieldAddresses: fieldNamesForAppRefName(owner.fieldAddressesByAppRefName, appRefName) ?? new Map(),
|
|
56
63
|
recordLacksAuditFields: kind === "element" && owner.elementsWithoutAuditFields?.has(appRefName) === true,
|
|
57
64
|
};
|
|
58
65
|
}
|
|
@@ -282,9 +289,187 @@ function onlyEntry(value, subject) {
|
|
|
282
289
|
}
|
|
283
290
|
return entries[0];
|
|
284
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* Record fields whose value is an object the platform writes into a field only
|
|
294
|
+
* by id (edk#2283, edk#2284). Its run-time converter takes a user id or email,
|
|
295
|
+
* a group id or name, or an option id or label. A whole user, group or option
|
|
296
|
+
* object fails the run, and a Multi-Select has no reference to its option ids.
|
|
297
|
+
*/
|
|
298
|
+
const OBJECT_VALUED_FIELD_KINDS = {
|
|
299
|
+
elementum_user_field: "user",
|
|
300
|
+
elementum_group_field: "group",
|
|
301
|
+
elementum_dropdown_field: "Dropdown",
|
|
302
|
+
elementum_multiselect_field: "Multi-Select",
|
|
303
|
+
};
|
|
304
|
+
const OBJECT_VALUED_TARGET_FIELD_TYPES = new Set([
|
|
305
|
+
"USER", "USER_ID", "GROUP", "GROUP_ID", "PICKLIST", "PICKLIST_ID", "MULTI_PICKLIST", "MULTI_PICKLIST_ID",
|
|
306
|
+
]);
|
|
307
|
+
/** The same kinds by catalog field type, for an owner known only from its generated catalog. */
|
|
308
|
+
const OBJECT_VALUED_CATALOG_FIELD_KINDS = {
|
|
309
|
+
USER: "user",
|
|
310
|
+
USER_ID: "user",
|
|
311
|
+
GROUP: "group",
|
|
312
|
+
GROUP_ID: "group",
|
|
313
|
+
PICKLIST: "Dropdown",
|
|
314
|
+
MULTI_PICKLIST: "Multi-Select",
|
|
315
|
+
};
|
|
316
|
+
/** System fields whose value is such an object. They have no field resource to read the type from. */
|
|
317
|
+
const OBJECT_VALUED_SYSTEM_FIELD_KINDS = {
|
|
318
|
+
createdBy: "user",
|
|
319
|
+
updatedBy: "user",
|
|
320
|
+
closedBy: "user",
|
|
321
|
+
status: "Dropdown",
|
|
322
|
+
stage: "Dropdown",
|
|
323
|
+
};
|
|
324
|
+
/**
|
|
325
|
+
* Fails a user, group, Dropdown or Multi-Select field assignment that reads a
|
|
326
|
+
* found or trigger record's whole user, group or option object, or any part
|
|
327
|
+
* of a Multi-Select. Build and plan pass those and the run fails. Pull keeps
|
|
328
|
+
* printing the live shape and only warns, as for a record-id field mapping.
|
|
329
|
+
*/
|
|
330
|
+
function assertRecordFieldValueIsWritable(reference, fieldToken, refs) {
|
|
331
|
+
const problem = recordFieldValueProblem(reference, fieldToken, refs);
|
|
332
|
+
if (problem === undefined)
|
|
333
|
+
return;
|
|
334
|
+
const { message, finding } = problem;
|
|
335
|
+
if (currentValidationMode() === "pull") {
|
|
336
|
+
// Pull prints the live shape and warns. Build writes the finding into the
|
|
337
|
+
// compiled file, so the pull's revision record keeps it as one the
|
|
338
|
+
// platform already runs (#2283).
|
|
339
|
+
refs.owner.advisoriesWhileRecorded?.push({ finding, advisory: message, error: message });
|
|
340
|
+
recordValidations([{
|
|
341
|
+
severity: "warning",
|
|
342
|
+
address: `${AUTOMATION_RESOURCE_TYPE}.${refs.owner.automationTfLabel}`,
|
|
343
|
+
name: refs.owner.automationTfLabel,
|
|
344
|
+
ownerKind: "automation",
|
|
345
|
+
message,
|
|
346
|
+
}]);
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
// An automation the platform already runs this way stays plannable while
|
|
350
|
+
// its revision record lists this exact finding from a pull or apply. Build
|
|
351
|
+
// decides that (it holds the record) and fails any finding the record
|
|
352
|
+
// doesn't list. Without the list there is no record to match, so fail.
|
|
353
|
+
if (!refs.owner.pulledLive || refs.owner.advisoriesWhileRecorded === undefined)
|
|
354
|
+
throw new EntityTfError(message);
|
|
355
|
+
refs.owner.advisoriesWhileRecorded.push({
|
|
356
|
+
finding,
|
|
357
|
+
advisory: `automation ${refs.owner.automationTfLabel}: ${message}`,
|
|
358
|
+
error: `${message} applied-automation-revisions.json doesn't record this assignment from a pull or apply of this automation ` +
|
|
359
|
+
"(it is new, or the record predates EDK recording these), so build stops it. If the platform already runs it, " +
|
|
360
|
+
"pull the app or element again to record it.",
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
function recordFieldValueProblem(reference, fieldToken, refs) {
|
|
364
|
+
if (fieldToken?.fieldType === undefined || !OBJECT_VALUED_TARGET_FIELD_TYPES.has(fieldToken.fieldType))
|
|
365
|
+
return undefined;
|
|
366
|
+
const source = recordFieldSource(reference, refs);
|
|
367
|
+
if (source === undefined)
|
|
368
|
+
return undefined;
|
|
369
|
+
// An authored owner's field resources decide the kind. An owner known only
|
|
370
|
+
// from its generated catalog has none, so its catalog field types decide.
|
|
371
|
+
const address = source.addresses?.get(source.fieldKey);
|
|
372
|
+
const sourceType = address === undefined ? undefined : address.slice(0, address.indexOf("."));
|
|
373
|
+
const catalogTypes = source.addresses === undefined && source.ownerRefName !== undefined
|
|
374
|
+
? fieldNamesForAppRefName(refs.owner.catalogFieldTypesByAppRefName, source.ownerRefName)
|
|
375
|
+
: undefined;
|
|
376
|
+
const catalogType = catalogTypes?.get(source.fieldKey);
|
|
377
|
+
const kind = sourceType !== undefined ? OBJECT_VALUED_FIELD_KINDS[sourceType]
|
|
378
|
+
: catalogType !== undefined ? OBJECT_VALUED_CATALOG_FIELD_KINDS[catalogType]
|
|
379
|
+
: source.addresses !== undefined || catalogTypes !== undefined ? OBJECT_VALUED_SYSTEM_FIELD_KINDS[source.fieldKey]
|
|
380
|
+
: undefined;
|
|
381
|
+
const multiSelect = kind === "Multi-Select";
|
|
382
|
+
if (kind === undefined)
|
|
383
|
+
return undefined;
|
|
384
|
+
const target = fieldToken.name ?? fieldToken.refName;
|
|
385
|
+
// What the revision record keeps: the target field key and the source path as authored.
|
|
386
|
+
const finding = `${fieldToken.refName ?? target} <- ${source.path}`;
|
|
387
|
+
if (multiSelect) {
|
|
388
|
+
return { finding, message: `field "${target}" is set from ${source.path}, a Multi-Select. The platform has no reference to a Multi-Select's option ids, ` +
|
|
389
|
+
`so the run fails with "Unable to validate". Build a JSON list of the option ids (or, for another Multi-Select field, the labels) ` +
|
|
390
|
+
"in an executeScript, store it with setVariable, and set the field from that variable." };
|
|
391
|
+
}
|
|
392
|
+
if (source.rest.length > 0)
|
|
393
|
+
return undefined;
|
|
394
|
+
if (kind === "Dropdown") {
|
|
395
|
+
return { finding, message: `field "${target}" is set from ${source.path}, a whole Dropdown option. The platform writes a Dropdown only from an option id or label, ` +
|
|
396
|
+
`so the run fails. Set it from ${source.path}.id when it is the same field, or ${source.path}.label for another Dropdown, ` +
|
|
397
|
+
"since option ids belong to one field." };
|
|
398
|
+
}
|
|
399
|
+
return { finding, message: `field "${target}" is set from ${source.path}, a whole ${kind} object. The platform writes a ${kind} into a field only by id, ` +
|
|
400
|
+
`so the run fails. Set it from ${source.path}.id instead.` };
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* The record field a task, trigger, on-demand record parameter or record
|
|
404
|
+
* loop item reference reads, with the field addresses of the record's owner.
|
|
405
|
+
*/
|
|
406
|
+
function recordFieldSource(reference, refs) {
|
|
407
|
+
if (!isObject(reference))
|
|
408
|
+
return undefined;
|
|
409
|
+
const taskOwner = (taskRefKey) => {
|
|
410
|
+
const owner = refs.recordFieldContext?.taskAppRefNameByRefKey?.[taskRefKey] ?? refs.tasks.get(taskRefKey)?.recordTarget?.refName;
|
|
411
|
+
if (owner === undefined)
|
|
412
|
+
return { addresses: undefined };
|
|
413
|
+
if (owner === refs.owner.appRefName)
|
|
414
|
+
return { addresses: refs.owner.fieldAddresses };
|
|
415
|
+
return { addresses: fieldNamesForAppRefName(refs.owner.fieldAddressesByAppRefName, owner), ownerRefName: owner };
|
|
416
|
+
};
|
|
417
|
+
if (isObject(reference.taskReference) && typeof reference.taskReference.taskRefKey === "string" && typeof reference.taskReference.name === "string") {
|
|
418
|
+
const [head, fieldKey, ...rest] = normalizeIndexedRecordsFieldPath(reference.taskReference.name).split(".");
|
|
419
|
+
if (head !== "record" || fieldKey === undefined)
|
|
420
|
+
return undefined;
|
|
421
|
+
const taskRefKey = reference.taskReference.taskRefKey;
|
|
422
|
+
return {
|
|
423
|
+
path: `ctx.actions${sourceKeyAccessor(taskRefKey)}.${reference.taskReference.name.replace(/^records\.(\d+)\./, "records[$1].")}`,
|
|
424
|
+
fieldKey,
|
|
425
|
+
rest,
|
|
426
|
+
...taskOwner(taskRefKey),
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
if (isObject(reference.triggerReference) && typeof reference.triggerReference.name === "string") {
|
|
430
|
+
const name = reference.triggerReference.name;
|
|
431
|
+
const [head, fieldKey, ...rest] = name.split(".");
|
|
432
|
+
if (head === "record" && fieldKey !== undefined) {
|
|
433
|
+
return { path: `ctx.trigger.${name}`, fieldKey, rest, addresses: refs.owner.fieldAddresses };
|
|
434
|
+
}
|
|
435
|
+
const param = onDemandRecordFieldPath(name, refs);
|
|
436
|
+
if (param === undefined)
|
|
437
|
+
return undefined;
|
|
438
|
+
return {
|
|
439
|
+
path: `ctx.trigger${sourceKeyAccessor(param.paramName)}.${name.slice(param.paramName.length + 1)}`,
|
|
440
|
+
fieldKey: param.fieldKey,
|
|
441
|
+
rest: param.suffix === "" ? [] : param.suffix.split("."),
|
|
442
|
+
...(param.isOwner
|
|
443
|
+
? { addresses: refs.owner.fieldAddresses }
|
|
444
|
+
: { addresses: fieldNamesForAppRefName(refs.owner.fieldAddressesByAppRefName, param.target.refName), ownerRefName: param.target.refName }),
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
if (isObject(reference.forEachReference) && typeof reference.forEachReference.forEachTaskRefKey === "string" && typeof reference.forEachReference.name === "string") {
|
|
448
|
+
const loop = reference.forEachReference.forEachTaskRefKey;
|
|
449
|
+
const sourceTask = refs.recordItemForEachSourceByRefKey.get(loop);
|
|
450
|
+
if (sourceTask === undefined)
|
|
451
|
+
return undefined;
|
|
452
|
+
const [fieldKey, ...rest] = reference.forEachReference.name.split(".");
|
|
453
|
+
if (fieldKey === undefined || fieldKey === "")
|
|
454
|
+
return undefined;
|
|
455
|
+
return {
|
|
456
|
+
path: `ctx.loops${sourceKeyAccessor(loop)}.item.${reference.forEachReference.name}`,
|
|
457
|
+
fieldKey,
|
|
458
|
+
rest,
|
|
459
|
+
...taskOwner(sourceTask),
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
return undefined;
|
|
463
|
+
}
|
|
464
|
+
/** `.key`, or `["key"]` for a task or loop key that isn't an identifier, as pulled source writes it. */
|
|
465
|
+
function sourceKeyAccessor(key) {
|
|
466
|
+
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? `.${key}` : `[${JSON.stringify(key)}]`;
|
|
467
|
+
}
|
|
285
468
|
/**
|
|
286
469
|
* Tasks whose refs carry every field of the record they search (edk#2280)
|
|
287
|
-
* or create (edk#2406)
|
|
470
|
+
* or create (edk#2406), including system fields via object_fields /
|
|
471
|
+
* object_system_field_ids (edk#2680). update_field refs carry them too and
|
|
472
|
+
* aren't covered yet.
|
|
288
473
|
*/
|
|
289
474
|
const OBJECT_FIELD_REFS_TASK_TYPES = new Set([
|
|
290
475
|
"elementum_record_search_task",
|
|
@@ -330,6 +515,70 @@ function objectFieldIdsAttr(objectId, fieldAddresses) {
|
|
|
330
515
|
object_field_ids: expr.resourceAttr(MANAGED_FIELD_ORDER_RESOURCE_TYPE, scopedResourceLabel(objectId.label, "field_order", scope), ["field_ids"]),
|
|
331
516
|
};
|
|
332
517
|
}
|
|
518
|
+
/**
|
|
519
|
+
* A record trigger's write-only `object_fields` (edk#2438): each of its
|
|
520
|
+
* owner's own fields as `{ id, name }`. refs are keyed by field name, so a
|
|
521
|
+
* field renamed or removed in the same apply plans `refs` unknown. It is set
|
|
522
|
+
* only next to `object_field_ids`, so on the same owners.
|
|
523
|
+
*/
|
|
524
|
+
function objectFieldsAttr(objectFieldIds, fieldAddresses) {
|
|
525
|
+
if (objectFieldIds["object_field_ids"] === undefined || fieldAddresses === undefined)
|
|
526
|
+
return {};
|
|
527
|
+
return {
|
|
528
|
+
object_fields: [...fieldAddresses.values()].map((address) => ({ id: addressExpr(address), name: addressExpr(address, ["name"]) })),
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* The owner attributes a record trigger's `object_system_field_ids` lists, in
|
|
533
|
+
* order (edk#2438). `ei apps export` writes the same lists.
|
|
534
|
+
*/
|
|
535
|
+
const APP_SYSTEM_FIELD_ID_ATTRIBUTES = [
|
|
536
|
+
"title_field_id", "id_field_id", "status_field_id", "stage_field_id",
|
|
537
|
+
"created_at_field_id", "created_by_field_id", "updated_at_field_id", "updated_by_field_id",
|
|
538
|
+
"closed_at_field_id", "closed_by_field_id",
|
|
539
|
+
];
|
|
540
|
+
const ELEMENT_SYSTEM_FIELD_ID_ATTRIBUTES = [
|
|
541
|
+
"title_field_id", "id_field_id",
|
|
542
|
+
"created_at_field_id", "created_by_field_id", "updated_at_field_id", "updated_by_field_id",
|
|
543
|
+
];
|
|
544
|
+
/**
|
|
545
|
+
* A record trigger's `object_field_ids`, `object_fields` and
|
|
546
|
+
* `object_system_field_ids` (edk#2280, edk#2438). The system field ids let the
|
|
547
|
+
* provider tell a removed field from a system field, since refs key both by
|
|
548
|
+
* name.
|
|
549
|
+
*/
|
|
550
|
+
function triggerObjectFieldAttrs(owner) {
|
|
551
|
+
const ownerType = owner.parentScope === "element" ? "elementum_element" : "elementum_app";
|
|
552
|
+
return objectFieldRefsAttrs(expr.resourceAttr(ownerType, owner.appTfLabel, ["id"]), owner.fieldAddresses);
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* A record search / find-related / create-record task's write-only
|
|
556
|
+
* `object_field_ids`, `object_fields` and `object_system_field_ids` (edk#2680).
|
|
557
|
+
* Same shape as a record trigger's, for the task's target app or element so
|
|
558
|
+
* the provider can plan `refs` unknown when a system field the task reads is
|
|
559
|
+
* removed while custom fields change.
|
|
560
|
+
*/
|
|
561
|
+
function taskObjectFieldAttrs(objectId, fieldAddresses) {
|
|
562
|
+
return objectFieldRefsAttrs(objectId, fieldAddresses);
|
|
563
|
+
}
|
|
564
|
+
/** Shared object_field_ids / object_fields / object_system_field_ids for a target app or element. */
|
|
565
|
+
function objectFieldRefsAttrs(objectId, fieldAddresses) {
|
|
566
|
+
const ids = objectFieldIdsAttr(objectId, fieldAddresses);
|
|
567
|
+
const fields = objectFieldsAttr(ids, fieldAddresses);
|
|
568
|
+
if (fields["object_fields"] === undefined)
|
|
569
|
+
return ids;
|
|
570
|
+
if (objectId === undefined || !isTfExpr(objectId) || objectId.$expr !== "resource-attr")
|
|
571
|
+
return ids;
|
|
572
|
+
const ownerType = objectId.type;
|
|
573
|
+
if (ownerType !== "elementum_app" && ownerType !== "elementum_element")
|
|
574
|
+
return ids;
|
|
575
|
+
const systemAttributes = ownerType === "elementum_element" ? ELEMENT_SYSTEM_FIELD_ID_ATTRIBUTES : APP_SYSTEM_FIELD_ID_ATTRIBUTES;
|
|
576
|
+
return {
|
|
577
|
+
...ids,
|
|
578
|
+
...fields,
|
|
579
|
+
object_system_field_ids: systemAttributes.map((attribute) => expr.resourceAttr(ownerType, objectId.label, [attribute])),
|
|
580
|
+
};
|
|
581
|
+
}
|
|
333
582
|
/** The field addresses this build writes for a task's `aspectId` target. */
|
|
334
583
|
function taskTargetFieldAddresses(aspectId, owner) {
|
|
335
584
|
const target = token(aspectId);
|
|
@@ -520,7 +769,7 @@ function crossAppFieldToTf(value, ctx, dataBlocks) {
|
|
|
520
769
|
// table-owned search table has to be distinguishable from an element-owned
|
|
521
770
|
// one.
|
|
522
771
|
if (sibling !== undefined && sibling.kind !== "table" && sibling.kind !== "task") {
|
|
523
|
-
const fieldValue = fieldRefToTfValue(value.fieldType ?? "", value.refName, sibling.tfLabel, sibling.kind,
|
|
772
|
+
const fieldValue = fieldRefToTfValue(value.fieldType ?? "", value.refName, sibling.tfLabel, sibling.kind, fieldNamesForAppRefName(ctx.fieldAddressesByAppRefName, value.parent));
|
|
524
773
|
if (fieldValue === undefined) {
|
|
525
774
|
throw new EntityTfError(`field ref "${value.refName}" on sibling ${sibling.kind} "${value.parent}" has no terraform field resource mapping (fieldType ${JSON.stringify(value.fieldType ?? "")})`);
|
|
526
775
|
}
|
|
@@ -974,16 +1223,19 @@ function tokenToTf(value, ctx, dataBlocks) {
|
|
|
974
1223
|
// label (see ApprovalChainRef); preferring it rewrote live pulls to UUIDs.
|
|
975
1224
|
const refName = typeof value.refName === "string" ? value.refName.trim() : "";
|
|
976
1225
|
if (refName !== "") {
|
|
977
|
-
|
|
1226
|
+
// The approval process belongs to this automation's owner, an app or
|
|
1227
|
+
// an element (edk#373), so its label carries the owner's scope.
|
|
1228
|
+
const approvalLabel = scopedResourceLabel(ctx.appTfLabel, tsLabelToTfLabel(refName), ctx.parentScope);
|
|
1229
|
+
const address = `elementum_approval_process.${approvalLabel}`;
|
|
978
1230
|
// Never emit a reference to an approval process this build doesn't
|
|
979
|
-
// declare (edk#1416). The build records the
|
|
1231
|
+
// declare (edk#1416). The build records the owner's discovered
|
|
980
1232
|
// approval-chain files; direct callers without that information keep
|
|
981
1233
|
// the managed reference.
|
|
982
1234
|
const declared = ctx.workspaceAspects
|
|
983
|
-
?.get(workspaceAspectKey(
|
|
1235
|
+
?.get(workspaceAspectKey(ctx.parentScope, ctx.appRefName))
|
|
984
1236
|
?.managedChildRefNames?.get("approval-chain");
|
|
985
1237
|
if (declared === undefined || declared.has(refName)) {
|
|
986
|
-
return expr.resourceAttr("elementum_approval_process",
|
|
1238
|
+
return expr.resourceAttr("elementum_approval_process", approvalLabel, ["id"]);
|
|
987
1239
|
}
|
|
988
1240
|
if (value.unresolvedId !== undefined) {
|
|
989
1241
|
ctx.diagnostics.push(`automation ${ctx.automationTfLabel}: approval chain "${refName}" is not declared in this build (${address} would be undeclared); ` +
|
|
@@ -991,7 +1243,7 @@ function tokenToTf(value, ctx, dataBlocks) {
|
|
|
991
1243
|
return value.unresolvedId;
|
|
992
1244
|
}
|
|
993
1245
|
throw new EntityTfError(`automation ${ctx.automationTfLabel}: approval chain "${refName}" is not declared in this build (${address} is undeclared) ` +
|
|
994
|
-
`and the reference has no unresolvedId — add approval-chains/${refName}.ts to
|
|
1246
|
+
`and the reference has no unresolvedId — add approval-chains/${refName}.ts to ${ctx.parentScope} "${ctx.appRefName}" or reference an existing approval process`);
|
|
995
1247
|
}
|
|
996
1248
|
if (value.unresolvedId !== undefined)
|
|
997
1249
|
return value.unresolvedId;
|
|
@@ -1446,9 +1698,9 @@ function foreignFoundRecordFieldId(fieldKey, taskRefKey, refs) {
|
|
|
1446
1698
|
return expr.dataAttr("elementum_field", registerForeignFieldLookup(fieldToken, refs.owner, refs.dataBlocks), ["id"]);
|
|
1447
1699
|
}
|
|
1448
1700
|
function calculationTriggerMustache(name, refs) {
|
|
1449
|
-
const
|
|
1450
|
-
if (
|
|
1451
|
-
return [`{{trigger name="${
|
|
1701
|
+
const triggerName = onDemandTriggerRefName(name, refs) ?? slackTriggerReferenceName(name, refs);
|
|
1702
|
+
if (triggerName !== undefined)
|
|
1703
|
+
return [`{{trigger name="${triggerName}"}}`];
|
|
1452
1704
|
const parts = name.split(".");
|
|
1453
1705
|
if (parts[0] !== "record" || parts.length < 2) {
|
|
1454
1706
|
return [`{{trigger name="${name}"}}`];
|
|
@@ -1519,14 +1771,9 @@ const TS_TRIGGER_REF_TO_WIRE = {
|
|
|
1519
1771
|
// pseudo-fields only, keyed by the DIRECT ts accessor name, not a dotted
|
|
1520
1772
|
// record path. Record-path refs are handled below from app fields and
|
|
1521
1773
|
// suffix mappings.
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
messageAuthorId: "Message Author ID",
|
|
1526
|
-
messageAuthorName: "Message Author Name",
|
|
1527
|
-
messageContent: "Message Content",
|
|
1528
|
-
messageId: "Message ID",
|
|
1529
|
-
messageMetadata: "Message Metadata",
|
|
1774
|
+
// Slack message trigger accessors resolve only on that trigger, through
|
|
1775
|
+
// SLACK_MESSAGE_TRIGGER_REF_TO_WIRE (#2581): names like `content` and
|
|
1776
|
+
// `meta` would otherwise rewrite same-named task outputs.
|
|
1530
1777
|
sender_email: "Sender's Email Address",
|
|
1531
1778
|
sender_name: "Sender's Name",
|
|
1532
1779
|
body: "Body (Plain Text)",
|
|
@@ -1588,11 +1835,13 @@ function wireRefName(name, ctx) {
|
|
|
1588
1835
|
// System fields are keyed in ctx.fieldNames under their canonical
|
|
1589
1836
|
// SystemFieldKey (title/id/status/…) with the app's display name —
|
|
1590
1837
|
// including systemFields renames ("App Name"). Provider-fixed audit
|
|
1591
|
-
// keys (stage/createdBy/…) have no rename attribute
|
|
1592
|
-
// DEPLOY_DEFAULT.
|
|
1593
|
-
//
|
|
1594
|
-
//
|
|
1595
|
-
// the
|
|
1838
|
+
// keys (stage/createdBy/…) have no rename attribute, so the real
|
|
1839
|
+
// system field always uses DEPLOY_DEFAULT. Custom fields may not share
|
|
1840
|
+
// those keys (#1871 reject + pull re-key); a leftover fieldAddresses hit
|
|
1841
|
+
// is still treated as custom. Renamable system fields prefer fieldNames;
|
|
1842
|
+
// only when the map lacks the key do we fall back to DEPLOY_DEFAULT (the
|
|
1843
|
+
// silent Title fallback that breaks cross-app findRelatedRecords when the
|
|
1844
|
+
// related app renamed title and the map missed the canonical key).
|
|
1596
1845
|
const systemFieldKey = SYSTEM_FIELD_KEY_SET.has(fieldKey)
|
|
1597
1846
|
? fieldKey
|
|
1598
1847
|
: undefined;
|
|
@@ -1604,6 +1853,10 @@ function wireRefName(name, ctx) {
|
|
|
1604
1853
|
"The platform adds them to apps but only to some elements, and EDK cannot create them. " +
|
|
1605
1854
|
"Remove the reference, or set systemFields: { audit: true } on an element the platform did give them to.");
|
|
1606
1855
|
}
|
|
1856
|
+
// Custom fields may not use reserved system keys (#1871); pull re-keys
|
|
1857
|
+
// them to `<key>Custom`, so a provider-fixed system key always names the
|
|
1858
|
+
// platform field. Leftover source that still keys a custom field as
|
|
1859
|
+
// `closedAt` is rejected at build.
|
|
1607
1860
|
const fieldName = systemFieldKey !== undefined && PROVIDER_FIXED_SYSTEM_FIELD_KEYS.has(systemFieldKey)
|
|
1608
1861
|
? DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES[systemFieldKey]
|
|
1609
1862
|
: ctx.fieldNames.get(fieldKey) ??
|
|
@@ -1657,14 +1910,20 @@ const RECORD_COLLECTION_TASK_WIRE_TYPES = new Set([
|
|
|
1657
1910
|
const TS_FOR_EACH_GENERIC_SEGMENT_TO_WIRE = {
|
|
1658
1911
|
iteration: "Iteration",
|
|
1659
1912
|
};
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1913
|
+
/**
|
|
1914
|
+
* A forEach item's loop metadata (`ctx.item.metadata.<name>`, every
|
|
1915
|
+
* collection kind) is not an item field. Filters spell it
|
|
1916
|
+
* `for_each.<id>.metadata.<name>`; the loop's refs map keys it by display
|
|
1917
|
+
* name (live availableReferences, #2922).
|
|
1918
|
+
*/
|
|
1919
|
+
const FOR_EACH_LOOP_METADATA_TO_WIRE = {
|
|
1920
|
+
"metadata.first": "Is First Item",
|
|
1921
|
+
"metadata.last": "Is Last Item",
|
|
1922
|
+
"metadata.iteration": "Iteration",
|
|
1923
|
+
"metadata.size": "Total Size",
|
|
1924
|
+
};
|
|
1925
|
+
function isForEachLoopMetadata(name) {
|
|
1926
|
+
return Object.hasOwn(FOR_EACH_LOOP_METADATA_TO_WIRE, name);
|
|
1668
1927
|
}
|
|
1669
1928
|
function forEachWireRefName(name, ctx, isRecordCollection) {
|
|
1670
1929
|
// A recordSearch collection's whole item and branded record identity both
|
|
@@ -1672,6 +1931,8 @@ function forEachWireRefName(name, ctx, isRecordCollection) {
|
|
|
1672
1931
|
// exposes that reference under "Record"; "ID" is a distinct TEXT handle.
|
|
1673
1932
|
if (name === "item" || name === "recordId")
|
|
1674
1933
|
return "Record";
|
|
1934
|
+
if (isForEachLoopMetadata(name))
|
|
1935
|
+
return FOR_EACH_LOOP_METADATA_TO_WIRE[name];
|
|
1675
1936
|
// Record fields are keyed by their platform display names, not their typed
|
|
1676
1937
|
// catalog handles. Reuse the same field/suffix mapping as trigger record
|
|
1677
1938
|
// paths.
|
|
@@ -1864,10 +2125,21 @@ function onDemandTriggerRefName(name, refs) {
|
|
|
1864
2125
|
}
|
|
1865
2126
|
return ON_DEMAND_TRIGGERED_BY_REFS[name];
|
|
1866
2127
|
}
|
|
2128
|
+
/** A Slack message trigger's refs-map key; undefined on any other trigger. */
|
|
2129
|
+
function slackTriggerRefName(name, refs) {
|
|
2130
|
+
return refs.trigger.type === TRIGGER_RESOURCES.slackMessage ? slackMessageTriggerRefName(name) : undefined;
|
|
2131
|
+
}
|
|
2132
|
+
/** A Slack message trigger's `triggerReference.name`; undefined on any other trigger. */
|
|
2133
|
+
function slackTriggerReferenceName(name, refs) {
|
|
2134
|
+
return refs.trigger.type === TRIGGER_RESOURCES.slackMessage ? slackMessageTriggerReferenceName(name) : undefined;
|
|
2135
|
+
}
|
|
1867
2136
|
function triggerWireRefName(name, refs) {
|
|
1868
2137
|
const onDemandName = onDemandTriggerRefName(name, refs);
|
|
1869
2138
|
if (onDemandName !== undefined)
|
|
1870
2139
|
return onDemandName;
|
|
2140
|
+
const slackName = slackTriggerRefName(name, refs);
|
|
2141
|
+
if (slackName !== undefined)
|
|
2142
|
+
return slackName;
|
|
1871
2143
|
const scalarParams = refs.triggerParamNames.filter((param) => !refs.recordParamNames.includes(param));
|
|
1872
2144
|
const declared = onDemandTriggerRefKey(name, scalarParams);
|
|
1873
2145
|
if (declared !== name || scalarParams.includes(name))
|
|
@@ -1913,8 +2185,8 @@ function assertLiteralFitsFieldType(value, field) {
|
|
|
1913
2185
|
return;
|
|
1914
2186
|
const fieldType = field.fieldType;
|
|
1915
2187
|
const accepts = {
|
|
1916
|
-
USER: { test: (text) => UUID_PATTERN.test(text), expected: "a user id, or a user reference such as ctx.trigger.record.<userField
|
|
1917
|
-
GROUP: { test: (text) => UUID_PATTERN.test(text), expected: "a group id, or a group reference" },
|
|
2188
|
+
USER: { test: (text) => UUID_PATTERN.test(text), expected: "a user id, or a user id reference such as ctx.trigger.record.<userField>.id" },
|
|
2189
|
+
GROUP: { test: (text) => UUID_PATTERN.test(text), expected: "a group id, or a group id reference such as ctx.trigger.record.<groupField>.id" },
|
|
1918
2190
|
DATE: { test: (text) => ISO_DATE_PATTERN.test(text) && !Number.isNaN(Date.parse(text)), expected: "an ISO date (YYYY-MM-DD) or a date reference" },
|
|
1919
2191
|
DATETIME: {
|
|
1920
2192
|
test: (text) => ISO_DATETIME_PATTERN.test(text) && !Number.isNaN(Date.parse(text)),
|
|
@@ -2015,8 +2287,8 @@ function workflowPublishOutputValueToTf(value, refs) {
|
|
|
2015
2287
|
return valueToTf(value, refs);
|
|
2016
2288
|
}
|
|
2017
2289
|
/**
|
|
2018
|
-
* A `createRecord` task
|
|
2019
|
-
* field
|
|
2290
|
+
* A field of the record a `createRecord` task made, in any app or element,
|
|
2291
|
+
* embedded as a LIVE field `.id` reference instead of a resolved display name.
|
|
2020
2292
|
* Confirmed live (demoapptwo, #1066): the platform stores this specific
|
|
2021
2293
|
* reference shape as `"record.<field-platform-id>.<suffix>"` — the SAME raw
|
|
2022
2294
|
* form the unresolved-field escape hatch above already reproduces for a
|
|
@@ -2031,26 +2303,23 @@ function workflowPublishOutputValueToTf(value, refs) {
|
|
|
2031
2303
|
* pattern as `taskId`/`variableReference.name` just below), so this stays
|
|
2032
2304
|
* correct even across a field id change, unlike a literal string would.
|
|
2033
2305
|
*
|
|
2034
|
-
*
|
|
2035
|
-
*
|
|
2036
|
-
*
|
|
2037
|
-
*
|
|
2038
|
-
*
|
|
2306
|
+
* The suffix is optional and the field may be a system field of the created
|
|
2307
|
+
* record's own app or element: Under Armour's `TOOL_Create_Engagement_Record`
|
|
2308
|
+
* output `.record.id`, on a record of the Engagements element, exports as
|
|
2309
|
+
* `record.<Engagements ID field id>` (edk#2924). The field id resolves like a
|
|
2310
|
+
* filter value's found-record field (`foundRecordFieldReferenceName`): the
|
|
2311
|
+
* target's custom field resource, its `<owner>_<key>_field_id` system-field
|
|
2312
|
+
* local, or a `data.elementum_field` lookup for an app/element outside this
|
|
2313
|
+
* build. A field it can't resolve returns `undefined` and keeps the
|
|
2314
|
+
* display-name path. recordSearch/findRelatedRecords field access on an
|
|
2315
|
+
* EXISTING (not just-created) record isn't confirmed for outputs and stays
|
|
2316
|
+
* on that path too.
|
|
2039
2317
|
*/
|
|
2040
|
-
function
|
|
2318
|
+
function createRecordFieldRefTfValue(target, name, taskRefKey, refs) {
|
|
2041
2319
|
if (target?.type !== "elementum_create_record_task")
|
|
2042
2320
|
return undefined;
|
|
2043
|
-
const
|
|
2044
|
-
|
|
2045
|
-
return undefined;
|
|
2046
|
-
const [, fieldKey, suffix] = match;
|
|
2047
|
-
const fieldType = refs.owner.fieldMetadata.get(fieldKey)?.fieldType;
|
|
2048
|
-
if (fieldType === undefined)
|
|
2049
|
-
return undefined;
|
|
2050
|
-
const fieldId = fieldRefToTfValue(fieldType, fieldKey, refs.owner.appTfLabel, refs.owner.parentScope, refs.owner.fieldAddresses);
|
|
2051
|
-
if (fieldId === undefined)
|
|
2052
|
-
return undefined;
|
|
2053
|
-
return expr.template(["record.", fieldId, `.${suffix}`]);
|
|
2321
|
+
const parts = foundRecordFieldReferenceName(target.type, name, taskRefKey, refs);
|
|
2322
|
+
return parts === undefined ? undefined : expr.template(parts);
|
|
2054
2323
|
}
|
|
2055
2324
|
/**
|
|
2056
2325
|
* The canonical reference envelope for a workflow-OUTPUT task reference —
|
|
@@ -2061,7 +2330,7 @@ function createRecordOwnFieldRefTfValue(target, name, refs) {
|
|
|
2061
2330
|
* against that name (edk#835), so EDK emits it directly instead of the refs-map
|
|
2062
2331
|
* display label. The exceptions keep their existing resolution, since they
|
|
2063
2332
|
* reference FIELDS / declared values by EDK-owned names, not the mobius
|
|
2064
|
-
* display-label drift class: a task's
|
|
2333
|
+
* display-label drift class: a field of the task's record (`record.<field>`),
|
|
2065
2334
|
* aiAgent (platform-nested via {@link aiAgentPlatformRefName}), and file-reader
|
|
2066
2335
|
* (arbitrary schema field names). `fieldType`/`multiple` come from the generated
|
|
2067
2336
|
* service_tasks contract (via {@link publishOutputType}). Returns undefined when
|
|
@@ -2078,16 +2347,16 @@ function taskReferenceEnvelope(value, refs) {
|
|
|
2078
2347
|
const canonicalName = taskRef.name;
|
|
2079
2348
|
const isFileReaderTask = target.type === "elementum_ai_file_read_task" || target.type === "elementum_file_reader_task";
|
|
2080
2349
|
const isAiAgentTask = target.type === "elementum_ai_agent_task";
|
|
2081
|
-
// A task's
|
|
2350
|
+
// A field of the task's created/found record (`record.<field>`) is not a
|
|
2082
2351
|
// task-output name — it resolves by the field's own id/display name. No
|
|
2083
2352
|
// canonical output is ever spelled `record.<field>` (the contract has
|
|
2084
2353
|
// record/records/recordId), so that dotted prefix uniquely marks it.
|
|
2085
|
-
const
|
|
2086
|
-
const
|
|
2087
|
-
const platformRefName =
|
|
2354
|
+
const isRecordFieldRef = canonicalName.startsWith("record.");
|
|
2355
|
+
const createdRecordFieldRef = createRecordFieldRefTfValue(target, canonicalName, taskRef.taskRefKey, refs);
|
|
2356
|
+
const platformRefName = createdRecordFieldRef
|
|
2088
2357
|
?? (isFileReaderTask
|
|
2089
2358
|
? canonicalName
|
|
2090
|
-
:
|
|
2359
|
+
: isRecordFieldRef
|
|
2091
2360
|
? taskWireRefName(canonicalName, taskRef.taskRefKey, refs)
|
|
2092
2361
|
: isAiAgentTask
|
|
2093
2362
|
? aiAgentPlatformRefName(canonicalName)
|
|
@@ -2136,7 +2405,9 @@ function workflowPublishOutputEnvelope(value, refs) {
|
|
|
2136
2405
|
multiple: typed.multiple,
|
|
2137
2406
|
taskReference: null,
|
|
2138
2407
|
triggerReference: {
|
|
2139
|
-
name: onDemandTriggerRefName(value.triggerReference.name, refs) ??
|
|
2408
|
+
name: onDemandTriggerRefName(value.triggerReference.name, refs) ??
|
|
2409
|
+
slackTriggerReferenceName(value.triggerReference.name, refs) ??
|
|
2410
|
+
wireRefName(value.triggerReference.name, refs.owner),
|
|
2140
2411
|
},
|
|
2141
2412
|
variableReference: null,
|
|
2142
2413
|
};
|
|
@@ -2592,9 +2863,9 @@ function valueToTf(value, refs) {
|
|
|
2592
2863
|
function snake(name) {
|
|
2593
2864
|
return name.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/-/g, "_").toLowerCase();
|
|
2594
2865
|
}
|
|
2595
|
-
/** The provider's `default_value` is a string: a Checkbox default is
|
|
2866
|
+
/** The provider's `default_value` is a string: a Number, Decimal or Checkbox default is quoted, as `ei` export writes it. */
|
|
2596
2867
|
function onDemandDefaultToTf(value) {
|
|
2597
|
-
return typeof value === "boolean" ? String(value) : value;
|
|
2868
|
+
return typeof value === "number" || typeof value === "boolean" ? String(value) : value;
|
|
2598
2869
|
}
|
|
2599
2870
|
function unwrapDefault(value) {
|
|
2600
2871
|
if (!isObject(value))
|
|
@@ -2646,7 +2917,7 @@ function onDemandRecordFieldFilterReference(name, refs, operator) {
|
|
|
2646
2917
|
`(ctx.trigger.${paramName}.${fieldKey}.id) or ".label" (ctx.trigger.${paramName}.${fieldKey}.label) explicitly.`);
|
|
2647
2918
|
}
|
|
2648
2919
|
const wireSuffix = suffix === "recordId"
|
|
2649
|
-
?
|
|
2920
|
+
? RECORD_ID_REFERENCE_FIELD
|
|
2650
2921
|
: suffix.length === 0 && isOwner && isOptionBearingPicklist(refs.owner.fieldMetadata.get(fieldKey)) ? "id"
|
|
2651
2922
|
: suffix.length === 0 && isOwner && operator === "is_null" && isIdentityField(refs.owner.fieldMetadata.get(fieldKey)) ? "id" : suffix;
|
|
2652
2923
|
const tail = wireSuffix.length > 0 ? [`.${wireSuffix}`] : [];
|
|
@@ -2731,7 +3002,7 @@ function filterReferenceToTf(value, refs, role = "value", realType, operator) {
|
|
|
2731
3002
|
const fieldKey = parts[1];
|
|
2732
3003
|
const address = refs.owner.fieldAddresses.get(fieldKey);
|
|
2733
3004
|
const suffix = parts.slice(2).join(".");
|
|
2734
|
-
let wireSuffix = suffix === "recordId" ?
|
|
3005
|
+
let wireSuffix = suffix === "recordId" ? RECORD_ID_REFERENCE_FIELD : suffix;
|
|
2735
3006
|
// An option-bearing picklist has no bare wire form. The platform editor
|
|
2736
3007
|
// sends `.id` or `.label`, and a null-check emits `.id`.
|
|
2737
3008
|
if (suffix.length === 0 && isOptionBearingPicklist(refs.owner.fieldMetadata.get(fieldKey))) {
|
|
@@ -2818,11 +3089,21 @@ function filterReferenceToTf(value, refs, role = "value", realType, operator) {
|
|
|
2818
3089
|
}
|
|
2819
3090
|
const triggerRefKey = triggerWireRefName(value.name, refs);
|
|
2820
3091
|
if (refs.trigger.type === TRIGGER_RESOURCES.onDemand) {
|
|
2821
|
-
// filter_refs holds only declared inputs, so the
|
|
3092
|
+
// filter_refs holds only declared inputs, so the user who ran the
|
|
3093
|
+
// automation has no key there. The platform reads it through the
|
|
3094
|
+
// short form instead: the editor saves `trigger.triggeredBy.id`, ei
|
|
3095
|
+
// exports it verbatim, and mobius resolves a TRIGGER reference by
|
|
3096
|
+
// walking the on-demand payload, which carries that user under
|
|
3097
|
+
// `triggeredBy` (OnDemandTriggerProcessor). edk#2788.
|
|
2822
3098
|
if (ON_DEMAND_TRIGGERED_BY_REFS[value.name] !== undefined) {
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
3099
|
+
// The bare user is the id everywhere else ("Triggered By's Id"),
|
|
3100
|
+
// but its short form would make the runtime walk to the whole user
|
|
3101
|
+
// object, so a filter must name the field it compares.
|
|
3102
|
+
if (value.name === "triggeredBy") {
|
|
3103
|
+
throw new EntityTfError("filter on ctx.trigger.triggeredBy: compare a field of the user who ran the automation, " +
|
|
3104
|
+
"ctx.trigger.triggeredBy.id, .email or .name");
|
|
3105
|
+
}
|
|
3106
|
+
return `trigger.${value.name}`;
|
|
2826
3107
|
}
|
|
2827
3108
|
return expr.resourceAttr(refs.trigger.type, refs.trigger.label, ["filter_refs", { index: triggerRefKey }]);
|
|
2828
3109
|
}
|
|
@@ -3074,10 +3355,48 @@ function filterReferenceToTf(value, refs, role = "value", realType, operator) {
|
|
|
3074
3355
|
const task = refs.tasks.get(value.forEachTaskRefKey);
|
|
3075
3356
|
if (task === undefined)
|
|
3076
3357
|
throw new EntityTfError(`unresolved forEach filter ref "${value.forEachTaskRefKey}"`);
|
|
3358
|
+
if (!refs.recordItemForEachRefKeys.has(value.forEachTaskRefKey)) {
|
|
3359
|
+
// Plain-list payload keys are not catalog fields. Preserve their
|
|
3360
|
+
// compact spelling, including the platform's empty whole-item name.
|
|
3361
|
+
const name = value.name === "recordId" ? "item" : value.name === "item" ? "" : value.name;
|
|
3362
|
+
return expr.template(["for_each.", expr.resourceAttr(task.type, task.label, ["id"]), `.${name}`]);
|
|
3363
|
+
}
|
|
3364
|
+
// The loop's own metadata is not a field of the iterated records:
|
|
3365
|
+
// export spells it `for_each.<id>.metadata.<name>` (#2922).
|
|
3366
|
+
if (isForEachLoopMetadata(value.name)) {
|
|
3367
|
+
return expr.template(["for_each.", expr.resourceAttr(task.type, task.label, ["id"]), `.${value.name}`]);
|
|
3368
|
+
}
|
|
3369
|
+
// Filter export uses a compact field-ID path, not inner.refs (the
|
|
3370
|
+
// script-input spelling) or the TypeScript property name. Resolve
|
|
3371
|
+
// the collection's actual owner and preserve that export dialect.
|
|
3372
|
+
const source = refs.recordItemForEachSourceByRefKey.get(value.forEachTaskRefKey);
|
|
3373
|
+
const [fieldKey, ...suffix] = value.name.split(".");
|
|
3374
|
+
if (fieldKey === undefined || fieldKey === "")
|
|
3375
|
+
throw new EntityTfError("record loop filter reference has no field");
|
|
3376
|
+
const isIdentity = value.name === "item" || value.name === "recordId";
|
|
3377
|
+
const foreignFieldId = isIdentity ? undefined : foreignFoundRecordFieldId(fieldKey, source, refs);
|
|
3378
|
+
const scope = isIdentity || foreignFieldId !== undefined ? undefined : calculationFieldScope(source, refs);
|
|
3379
|
+
const fieldId = isIdentity ? RECORD_ID_REFERENCE_FIELD : foreignFieldId ?? calculationRecordFieldId(fieldKey, scope);
|
|
3380
|
+
const joinedSuffix = suffix.join(".");
|
|
3381
|
+
let wireSuffix = joinedSuffix === "recordId" ? RECORD_ID_REFERENCE_FIELD : joinedSuffix;
|
|
3382
|
+
// Same rule as a trigger-record filter: an option-bearing picklist has
|
|
3383
|
+
// no bare wire form (`.id` / `.label`; a null-check emits `.id`), and a
|
|
3384
|
+
// user/group null-check emits `.id`. Field metadata is known only for
|
|
3385
|
+
// the automation's own app/element, as for onDemand record inputs.
|
|
3386
|
+
const metadata = scope === refs.owner ? refs.owner.fieldMetadata.get(fieldKey) : undefined;
|
|
3387
|
+
if (joinedSuffix.length === 0 && isOptionBearingPicklist(metadata)) {
|
|
3388
|
+
if (operator !== "is_null") {
|
|
3389
|
+
throw new EntityTfError(`filter reference to picklist field "${fieldKey}" is ambiguous — write ".id" ` +
|
|
3390
|
+
`(ctx.item.${fieldKey}.id, compare by the option's id) or ".label" ` +
|
|
3391
|
+
`(ctx.item.${fieldKey}.label, compare by display text) explicitly.`);
|
|
3392
|
+
}
|
|
3393
|
+
wireSuffix = "id";
|
|
3394
|
+
}
|
|
3395
|
+
if (joinedSuffix.length === 0 && operator === "is_null" && isIdentityField(metadata))
|
|
3396
|
+
wireSuffix = "id";
|
|
3077
3397
|
return expr.template([
|
|
3078
|
-
"for_each.",
|
|
3079
|
-
|
|
3080
|
-
`.${forEachCompactFilterName(value.name, refs.recordItemForEachRefKeys.has(value.forEachTaskRefKey))}`,
|
|
3398
|
+
"for_each.", expr.resourceAttr(task.type, task.label, ["id"]), ".", fieldId,
|
|
3399
|
+
...(wireSuffix === "" ? [] : [`.${wireSuffix}`]),
|
|
3081
3400
|
]);
|
|
3082
3401
|
}
|
|
3083
3402
|
case "VALUE":
|
|
@@ -3104,6 +3423,10 @@ function filterReferenceToTf(value, refs, role = "value", realType, operator) {
|
|
|
3104
3423
|
throw new EntityTfError(`unsupported filter reference type "${value.type}"`);
|
|
3105
3424
|
}
|
|
3106
3425
|
}
|
|
3426
|
+
/**
|
|
3427
|
+
* A UUID-wrapped filter value on a picklist: a label resolves to its option
|
|
3428
|
+
* id, and a raw id or a pulled stale label passes through as written.
|
|
3429
|
+
*/
|
|
3107
3430
|
function picklistFilterValueToTf(value, field, refs) {
|
|
3108
3431
|
if (typeof value !== "string" ||
|
|
3109
3432
|
field?.__kind !== "field" ||
|
|
@@ -3136,6 +3459,101 @@ function picklistFilterValueToTf(value, field, refs) {
|
|
|
3136
3459
|
refs.owner.diagnostics.push(`automation filter for picklist field ${JSON.stringify(field.name ?? field.refName)} preserves unknown option ${JSON.stringify(value)}`);
|
|
3137
3460
|
return undefined;
|
|
3138
3461
|
}
|
|
3462
|
+
return optionLookupToTf(value, field, refs);
|
|
3463
|
+
}
|
|
3464
|
+
/** A Dropdown or Multi-Select with static options. A record-sourced Dropdown has none and keeps its own rules. */
|
|
3465
|
+
function optionPicklist(field) {
|
|
3466
|
+
return field?.__kind === "field" &&
|
|
3467
|
+
(field.fieldType === "PICKLIST" || field.fieldType === "MULTI_PICKLIST") &&
|
|
3468
|
+
field.options !== undefined
|
|
3469
|
+
? field
|
|
3470
|
+
: undefined;
|
|
3471
|
+
}
|
|
3472
|
+
/**
|
|
3473
|
+
* `filter.textOption(label)`: the option id for `label`, which must name
|
|
3474
|
+
* exactly one option of `field`. Unlike a pulled raw id or stale label, an
|
|
3475
|
+
* option selection never passes through unresolved (#1733).
|
|
3476
|
+
*/
|
|
3477
|
+
function textOptionToTf(label, field, refs, slot) {
|
|
3478
|
+
const picklist = optionPicklist(field);
|
|
3479
|
+
const fieldName = field?.name ?? field?.refName ?? "unknown";
|
|
3480
|
+
if (picklist === undefined) {
|
|
3481
|
+
throw new EntityTfError(`${slot} uses filter.textOption(${JSON.stringify(label)}), but field "${fieldName}" is not a Dropdown or Multi-Select with static options`);
|
|
3482
|
+
}
|
|
3483
|
+
const matches = picklist.options.filter((option) => option === label).length;
|
|
3484
|
+
if (matches === 0 && refs.allowUnknownPicklistOptions === true) {
|
|
3485
|
+
// A pulled workspace keeps a label its live field no longer lists, as
|
|
3486
|
+
// main did for a plain label, so a fresh pull still builds (#1733).
|
|
3487
|
+
warnOption(refs, `${slot} uses filter.textOption(${JSON.stringify(label)}), but field "${fieldName}" has no option with that label; the pulled label is kept as written`);
|
|
3488
|
+
return label;
|
|
3489
|
+
}
|
|
3490
|
+
if (matches !== 1) {
|
|
3491
|
+
throw new EntityTfError(matches === 0
|
|
3492
|
+
? `${slot} uses filter.textOption(${JSON.stringify(label)}), but field "${fieldName}" has no option with that label; expected one of: ${picklist.options.map((option) => JSON.stringify(option)).join(", ")}`
|
|
3493
|
+
: `${slot} uses filter.textOption(${JSON.stringify(label)}), but field "${fieldName}" has ${matches} options with that label, so it names no single option`);
|
|
3494
|
+
}
|
|
3495
|
+
return optionLookupToTf(label, picklist, refs);
|
|
3496
|
+
}
|
|
3497
|
+
/**
|
|
3498
|
+
* A static value assigned to a Dropdown or Multi-Select with static options.
|
|
3499
|
+
* `filter.textOption(label)` is the one spelling and builds to the option id
|
|
3500
|
+
* (#1733). A plain string is refused: it reads as label text, which is not
|
|
3501
|
+
* what the platform stores. Two values pass through as written: the "" clear
|
|
3502
|
+
* (handled by the caller) and a raw option id pull keeps for an option that no
|
|
3503
|
+
* longer exists. Undefined means the caller encodes the value itself.
|
|
3504
|
+
*/
|
|
3505
|
+
function picklistAssignmentValueToTf(value, field, refs) {
|
|
3506
|
+
const fieldName = field?.name ?? field?.refName ?? "unknown";
|
|
3507
|
+
const slot = `automation field "${fieldName}"`;
|
|
3508
|
+
if (isTextOptionValue(value))
|
|
3509
|
+
return textOptionToTf(value.value, field, refs, slot);
|
|
3510
|
+
const picklist = optionPicklist(field);
|
|
3511
|
+
if (picklist === undefined || typeof value !== "string" || value === "")
|
|
3512
|
+
return undefined;
|
|
3513
|
+
if (isUuid(value)) {
|
|
3514
|
+
warnRawOptionId(value, picklist, refs, slot);
|
|
3515
|
+
return undefined;
|
|
3516
|
+
}
|
|
3517
|
+
// 1733 C (Dax, 2026-11-03: "One or the other not both"): a plain label is a
|
|
3518
|
+
// build error. This throw is the one place that decides it.
|
|
3519
|
+
throw new EntityTfError(`automation field "${fieldName}" is a ${field?.fieldType === "MULTI_PICKLIST" ? "Multi-Select" : "Dropdown"} with static options, so a plain string ${JSON.stringify(value)} is not an option. ` +
|
|
3520
|
+
`Select the option by label with filter.textOption(${JSON.stringify(value)})`);
|
|
3521
|
+
}
|
|
3522
|
+
/** A build warning on this automation (#1733). */
|
|
3523
|
+
function warnOption(refs, message) {
|
|
3524
|
+
recordValidations([{
|
|
3525
|
+
severity: "warning",
|
|
3526
|
+
address: `${AUTOMATION_RESOURCE_TYPE}.${refs.owner.automationTfLabel}`,
|
|
3527
|
+
name: refs.owner.automationTfLabel,
|
|
3528
|
+
ownerKind: "automation",
|
|
3529
|
+
message,
|
|
3530
|
+
}]);
|
|
3531
|
+
}
|
|
3532
|
+
/** A raw option id builds as written and warns with the preferred `filter.textOption(label)` (#1733). */
|
|
3533
|
+
function warnRawOptionId(id, field, refs, slot) {
|
|
3534
|
+
warnOption(refs, rawOptionIdWarning({
|
|
3535
|
+
slot,
|
|
3536
|
+
fieldName: field.name ?? field.refName,
|
|
3537
|
+
id,
|
|
3538
|
+
options: field.options,
|
|
3539
|
+
localName: ownedOptionsLocalName(field, refs),
|
|
3540
|
+
index: refs.owner.optionIds,
|
|
3541
|
+
}));
|
|
3542
|
+
}
|
|
3543
|
+
/** The options-by-label lookup that resolves `value` to `field`'s option id at apply. */
|
|
3544
|
+
function optionLookupToTf(value, field, refs) {
|
|
3545
|
+
const owned = ownedOptionsLocalName(field, refs);
|
|
3546
|
+
if (owned !== undefined)
|
|
3547
|
+
return expr.local(owned, [{ index: value }]);
|
|
3548
|
+
// A foreign field's options-by-label local is sourced from
|
|
3549
|
+
// `data.elementum_field.<label>.options` (issue #353) rather than an
|
|
3550
|
+
// owned resource's `options` attribute. Registering here also covers a
|
|
3551
|
+
// payload where nothing else resolves the field's id.
|
|
3552
|
+
const fieldLabel = registerForeignFieldLookup(field, refs.owner, refs.dataBlocks);
|
|
3553
|
+
return expr.local(fieldLabel + "_options_by_label", [{ index: value }]);
|
|
3554
|
+
}
|
|
3555
|
+
/** The options-by-label local of a field this workspace owns; undefined for a foreign field. */
|
|
3556
|
+
function ownedOptionsLocalName(field, refs) {
|
|
3139
3557
|
if (field.parent !== undefined && field.parentKind !== undefined) {
|
|
3140
3558
|
// A field owned by a SIBLING app/element built in this same workspace
|
|
3141
3559
|
// has its options-by-label local sourced from ITS OWN resource's
|
|
@@ -3149,28 +3567,23 @@ function picklistFilterValueToTf(value, field, refs) {
|
|
|
3149
3567
|
// Table siblings excluded for the same reason as in `crossAppFieldToTf`: a
|
|
3150
3568
|
// picklist field's owner is an app or an element, never a table.
|
|
3151
3569
|
if (sibling !== undefined && sibling.kind !== "table" && sibling.kind !== "task") {
|
|
3570
|
+
const childPart = tsLabelToTfLabel(field.resourceKey ?? field.refName);
|
|
3152
3571
|
const localName = sibling.kind === "app" && field.tags?.includes("STATUS")
|
|
3153
3572
|
? `${sibling.tfLabel}_status_options_by_label`
|
|
3154
3573
|
: sibling.kind === "app" && field.tags?.includes("STAGE")
|
|
3155
3574
|
? `${sibling.tfLabel}_stage_options_by_label`
|
|
3156
|
-
: `${scopedResourceLabel(sibling.tfLabel,
|
|
3157
|
-
return
|
|
3575
|
+
: `${scopedResourceLabel(sibling.tfLabel, childPart, sibling.kind)}_options_by_label`;
|
|
3576
|
+
return localName;
|
|
3158
3577
|
}
|
|
3159
3578
|
}
|
|
3160
|
-
if (field.parent !== undefined && (field.parent !== refs.owner.appRefName || field.parentKind === "element"))
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
// payload where nothing else resolves the field's id.
|
|
3165
|
-
const fieldLabel = registerForeignFieldLookup(field, refs.owner, refs.dataBlocks);
|
|
3166
|
-
return expr.local(fieldLabel + "_options_by_label", [{ index: value }]);
|
|
3167
|
-
}
|
|
3168
|
-
const localName = refs.owner.parentScope === "app" && field.tags?.includes("STATUS")
|
|
3579
|
+
if (field.parent !== undefined && (field.parent !== refs.owner.appRefName || field.parentKind === "element"))
|
|
3580
|
+
return undefined;
|
|
3581
|
+
const ownChildPart = tsLabelToTfLabel(field.resourceKey ?? field.refName);
|
|
3582
|
+
return refs.owner.parentScope === "app" && field.tags?.includes("STATUS")
|
|
3169
3583
|
? `${refs.owner.appTfLabel}_status_options_by_label`
|
|
3170
3584
|
: refs.owner.parentScope === "app" && field.tags?.includes("STAGE")
|
|
3171
3585
|
? `${refs.owner.appTfLabel}_stage_options_by_label`
|
|
3172
|
-
: `${scopedResourceLabel(refs.owner.appTfLabel,
|
|
3173
|
-
return expr.local(localName, [{ index: value }]);
|
|
3586
|
+
: `${scopedResourceLabel(refs.owner.appTfLabel, ownChildPart, refs.owner.parentScope)}_options_by_label`;
|
|
3174
3587
|
}
|
|
3175
3588
|
function triggerRecordFieldPath(reference, refs) {
|
|
3176
3589
|
if (!isObject(reference) || typeof reference.name !== "string")
|
|
@@ -3278,7 +3691,10 @@ function booleanTaskOutputRealType(reference, refs, authored) {
|
|
|
3278
3691
|
}
|
|
3279
3692
|
function filterToTf(value, refs) {
|
|
3280
3693
|
return serializeFilterToTf(value, {
|
|
3694
|
+
...(refs.allowUnknownPicklistOptions === true && { keepUnresolvedOptions: true }),
|
|
3281
3695
|
field: (field) => valueToTf(field, refs),
|
|
3696
|
+
// `userRef(email)` compares as the user's id, through the same user lookup a task value uses (#2891).
|
|
3697
|
+
user: (email) => valueToTf({ __kind: "user", email }, refs),
|
|
3282
3698
|
fieldFromLeftValue: (left) => fieldFromFilterLeftValue(left, refs),
|
|
3283
3699
|
reference: (reference, role, realType, operator) => filterReferenceToTf(reference, refs, role ?? "value", realType, operator),
|
|
3284
3700
|
referenceRealType: (reference, role, authored) => {
|
|
@@ -3311,7 +3727,24 @@ function filterToTf(value, refs) {
|
|
|
3311
3727
|
return authored;
|
|
3312
3728
|
return inferred;
|
|
3313
3729
|
},
|
|
3314
|
-
|
|
3730
|
+
// #1733: a plain string is literal text, sent as written. Only an option
|
|
3731
|
+
// selection, `filter.textOption(label)` or a UUID comparison value,
|
|
3732
|
+
// resolves a label to its option id.
|
|
3733
|
+
literal: (literal, field, valueType, isOptionLabel) => {
|
|
3734
|
+
const picklist = optionPicklist(token(field));
|
|
3735
|
+
if (picklist !== undefined && typeof literal === "string" && literal !== "") {
|
|
3736
|
+
// One warning per value (#1733): a raw option id, or a plain string.
|
|
3737
|
+
if (isUuid(literal) && !picklist.options.includes(literal))
|
|
3738
|
+
warnRawOptionId(literal, picklist, refs, "automation filter");
|
|
3739
|
+
else if (!isOptionLabel)
|
|
3740
|
+
warnOption(refs, plainOptionStringWarning("automation filter", picklist.name ?? picklist.refName, literal, picklist.options, false));
|
|
3741
|
+
}
|
|
3742
|
+
if (!isOptionLabel)
|
|
3743
|
+
return valueToTf(literal, refs);
|
|
3744
|
+
if (valueType === "text" && typeof literal === "string")
|
|
3745
|
+
return textOptionToTf(literal, token(field), refs, "automation filter");
|
|
3746
|
+
return picklistFilterValueToTf(literal, token(field), refs) ?? valueToTf(literal, refs);
|
|
3747
|
+
},
|
|
3315
3748
|
});
|
|
3316
3749
|
}
|
|
3317
3750
|
/**
|
|
@@ -3405,6 +3838,13 @@ function configAttrs(kind, config, refs) {
|
|
|
3405
3838
|
attrs.code = raw;
|
|
3406
3839
|
continue;
|
|
3407
3840
|
}
|
|
3841
|
+
if (key === "limit" && kind === "elementum_record_search_task") {
|
|
3842
|
+
if (typeof raw !== "number" || !Number.isInteger(raw) || raw < 1 || raw > 500) {
|
|
3843
|
+
throw new EntityTfError("recordSearch limit must be an integer between 1 and 500; use totalCount and explicit completeness checks when results may reach the limit");
|
|
3844
|
+
}
|
|
3845
|
+
attrs.limit = raw;
|
|
3846
|
+
continue;
|
|
3847
|
+
}
|
|
3408
3848
|
// execute_script input values: provider Read stores Mobius-normalized
|
|
3409
3849
|
// short names for on-demand scalars. Keep that envelope here only —
|
|
3410
3850
|
// templates, notifications, and other attrs still use refs["…"].
|
|
@@ -3415,9 +3855,22 @@ function configAttrs(kind, config, refs) {
|
|
|
3415
3855
|
if (!isObject(item) || typeof item.name !== "string") {
|
|
3416
3856
|
throw new EntityTfError("invalid executeScript input");
|
|
3417
3857
|
}
|
|
3858
|
+
const emptyInput = `executeScript input "${item.name}" has no value; omit unused inputs or pass a supported value reference. Creating a named, unbound input is rejected by the platform`;
|
|
3859
|
+
if (item.value === undefined || (isObject(item.value) && Object.keys(item.value).length === 1 &&
|
|
3860
|
+
"value" in item.value && item.value.value === undefined))
|
|
3861
|
+
throw new EntityTfError(emptyInput);
|
|
3862
|
+
const inputValue = executeScriptInputValueToTf(item.value, refs);
|
|
3863
|
+
if (inputValue === null) {
|
|
3864
|
+
// Update accepts an existing unbound input, unlike create. Keep
|
|
3865
|
+
// pulled configuration faithful; the provider can distinguish a
|
|
3866
|
+
// new task from an existing task during planning.
|
|
3867
|
+
if (!refs.owner.pulledLive && currentValidationMode() !== "pull")
|
|
3868
|
+
throw new EntityTfError(emptyInput);
|
|
3869
|
+
refs.owner.diagnostics.push(`automation ${refs.owner.automationTfLabel}: ${emptyInput}; existing pulled binding preserved`);
|
|
3870
|
+
}
|
|
3418
3871
|
const mapped = {
|
|
3419
3872
|
name: item.name,
|
|
3420
|
-
value:
|
|
3873
|
+
value: inputValue,
|
|
3421
3874
|
};
|
|
3422
3875
|
if (item.field_mappings !== undefined) {
|
|
3423
3876
|
mapped.field_mappings = valueToTf(item.field_mappings, refs);
|
|
@@ -3746,7 +4199,7 @@ function configAttrs(kind, config, refs) {
|
|
|
3746
4199
|
if (fieldToken?.fieldType !== "MULTI_PICKLIST" && !rawIdClear) {
|
|
3747
4200
|
throw new EntityTfError(`automation field "${fieldToken?.name ?? fieldToken?.refName ?? "unknown"}" uses an array value but is not a Multi-Select field`);
|
|
3748
4201
|
}
|
|
3749
|
-
const values = staticValue.map((value) =>
|
|
4202
|
+
const values = staticValue.map((value) => picklistAssignmentValueToTf(value, fieldToken, refs) ?? valueToTf(value, refs));
|
|
3750
4203
|
return {
|
|
3751
4204
|
field_id: valueToTf(field.aspectFieldId, refs),
|
|
3752
4205
|
value: expr.jsonencode(values),
|
|
@@ -3755,9 +4208,10 @@ function configAttrs(kind, config, refs) {
|
|
|
3755
4208
|
}
|
|
3756
4209
|
assertLiteralFitsFieldType(staticValue, fieldToken);
|
|
3757
4210
|
const optionValue = staticValue !== undefined
|
|
3758
|
-
?
|
|
4211
|
+
? picklistAssignmentValueToTf(staticValue, fieldToken, refs)
|
|
3759
4212
|
: undefined;
|
|
3760
4213
|
let reference = field.valueReference;
|
|
4214
|
+
assertRecordFieldValueIsWritable(reference, fieldToken, refs);
|
|
3761
4215
|
if (typeof reference === "string") {
|
|
3762
4216
|
reference = normalizeTriggerRecordIdEnvelopeString(reference, refs);
|
|
3763
4217
|
}
|
|
@@ -3980,6 +4434,7 @@ export function automationToTf(entity, ctx) {
|
|
|
3980
4434
|
ownerHandle: ctx.ownerHandle,
|
|
3981
4435
|
appTfLabel: ctx.appTfLabel,
|
|
3982
4436
|
automationTfLabel,
|
|
4437
|
+
...(ctx.optionIds !== undefined ? { optionIds: ctx.optionIds } : {}),
|
|
3983
4438
|
pulledLive: ctx.workspaceAspects
|
|
3984
4439
|
?.get(workspaceAspectKey(ctx.parentScope ?? "app", ctx.appRefName ?? entity.parent))
|
|
3985
4440
|
?.pulledAutomationRefNames?.has(entity.refName) === true,
|
|
@@ -3994,6 +4449,8 @@ export function automationToTf(entity, ctx) {
|
|
|
3994
4449
|
activeAutomationRefNames: ctx.activeAutomationRefNames,
|
|
3995
4450
|
...(ctx.elementsWithoutAuditFields !== undefined ? { elementsWithoutAuditFields: ctx.elementsWithoutAuditFields } : {}),
|
|
3996
4451
|
...(ctx.fieldAddressesByAppRefName !== undefined ? { fieldAddressesByAppRefName: ctx.fieldAddressesByAppRefName } : {}),
|
|
4452
|
+
...(ctx.catalogFieldTypesByAppRefName !== undefined ? { catalogFieldTypesByAppRefName: ctx.catalogFieldTypesByAppRefName } : {}),
|
|
4453
|
+
...(ctx.advisoriesWhileRecorded !== undefined ? { advisoriesWhileRecorded: ctx.advisoriesWhileRecorded } : {}),
|
|
3997
4454
|
...(ctx.authoredAspectKeys !== undefined ? { authoredAspectKeys: ctx.authoredAspectKeys } : {}),
|
|
3998
4455
|
recordLacksAuditFields: ctx.parentScope === "element" && ctx.ownerAuditFields !== true,
|
|
3999
4456
|
};
|
|
@@ -4232,9 +4689,7 @@ export function automationToTf(entity, ctx) {
|
|
|
4232
4689
|
attrs: {
|
|
4233
4690
|
automation: expr.resourceAttr(AUTOMATION_RESOURCE_TYPE, label),
|
|
4234
4691
|
...triggerAttrs,
|
|
4235
|
-
...(OBJECT_FIELD_REFS_TRIGGER_TYPES.has(triggerType)
|
|
4236
|
-
? objectFieldIdsAttr(expr.resourceAttr(owner.parentScope === "element" ? "elementum_element" : "elementum_app", owner.appTfLabel, ["id"]), owner.fieldAddresses)
|
|
4237
|
-
: {}),
|
|
4692
|
+
...(OBJECT_FIELD_REFS_TRIGGER_TYPES.has(triggerType) ? triggerObjectFieldAttrs(owner) : {}),
|
|
4238
4693
|
},
|
|
4239
4694
|
};
|
|
4240
4695
|
const blocks = [automation, trigger];
|
|
@@ -4242,7 +4697,7 @@ export function automationToTf(entity, ctx) {
|
|
|
4242
4697
|
const runAutomationPublishes = new Set();
|
|
4243
4698
|
// `enclosingOperator` describes the switch/forkJoin/forEach scope THIS
|
|
4244
4699
|
// `emitTasks` call is nested inside (undefined at automation top level) -
|
|
4245
|
-
// needed only by `unimplementedTask` (edk#821) to populate
|
|
4700
|
+
// needed only by `unimplementedTask` (edk#821, edk#2571) to populate
|
|
4246
4701
|
// `operator_task_id`/`operator_child_id` correctly regardless of how many
|
|
4247
4702
|
// real sibling tasks precede the placeholder within the same case/branch
|
|
4248
4703
|
// (the rolling `taskParent` chain below tracks the PRECEDING SIBLING, not
|
|
@@ -4296,8 +4751,15 @@ export function automationToTf(entity, ctx) {
|
|
|
4296
4751
|
if (typeof inner.taskType !== "string" || inner.taskType === "") {
|
|
4297
4752
|
throw new EntityTfError(`unimplementedTask "${refKey}" requires a taskType`);
|
|
4298
4753
|
}
|
|
4299
|
-
|
|
4300
|
-
|
|
4754
|
+
// Both Required: "" at top level, as the export writes; else the operator
|
|
4755
|
+
// and its case/branch (a loop body's is the for_each, as its `inner` says).
|
|
4756
|
+
const operatorId = (address) => {
|
|
4757
|
+
if (address === undefined)
|
|
4758
|
+
return "";
|
|
4759
|
+
if (address.$expr !== "resource-attr")
|
|
4760
|
+
throw new EntityTfError(`unimplementedTask "${refKey}": its enclosing operator has no resource address`);
|
|
4761
|
+
return expr.resourceAttr(address.type, address.label, ["id"]);
|
|
4762
|
+
};
|
|
4301
4763
|
// parent_is_trigger is always false on a task reference. The step this
|
|
4302
4764
|
// placeholder comes after is a local, not this flag: the provider
|
|
4303
4765
|
// copies the flag onto the following task (edk#2320).
|
|
@@ -4308,12 +4770,8 @@ export function automationToTf(entity, ctx) {
|
|
|
4308
4770
|
app_id: expr.resourceAttr(owner.parentScope === "element" ? "elementum_element" : "elementum_app", owner.appTfLabel, ["id"]),
|
|
4309
4771
|
automation_id: expr.resourceAttr(AUTOMATION_RESOURCE_TYPE, label, ["id"]),
|
|
4310
4772
|
parent_is_trigger: false,
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
: {}),
|
|
4314
|
-
...(operatorChildAddress !== undefined && operatorChildAddress.$expr === "resource-attr"
|
|
4315
|
-
? { operator_child_id: expr.resourceAttr(operatorChildAddress.type, operatorChildAddress.label, ["id"]) }
|
|
4316
|
-
: {}),
|
|
4773
|
+
operator_task_id: operatorId(enclosingOperator?.taskAddress),
|
|
4774
|
+
operator_child_id: operatorId(enclosingOperator?.childAddress),
|
|
4317
4775
|
};
|
|
4318
4776
|
if (owner.orgRefs !== undefined) {
|
|
4319
4777
|
owner.orgRefs.rawLookup("elementum_unmanaged_task_reference", tfLabel, displayName, extraAttrs);
|
|
@@ -4376,7 +4834,7 @@ export function automationToTf(entity, ctx) {
|
|
|
4376
4834
|
name: displayName,
|
|
4377
4835
|
...taskAttrs,
|
|
4378
4836
|
...(OBJECT_FIELD_REFS_TASK_TYPES.has(resourceType)
|
|
4379
|
-
?
|
|
4837
|
+
? taskObjectFieldAttrs(taskAttrs["object_id"], taskTargetFieldAddresses(inner.aspectId ?? inner.relatedAspectId, owner))
|
|
4380
4838
|
: {}),
|
|
4381
4839
|
};
|
|
4382
4840
|
if (wireType === "executeScript") {
|
|
@@ -4419,7 +4877,8 @@ export function automationToTf(entity, ctx) {
|
|
|
4419
4877
|
const children = task.children ?? [];
|
|
4420
4878
|
if (children.length !== 1)
|
|
4421
4879
|
throw new EntityTfError(`forEach task "${refKey}" must have exactly one child body`);
|
|
4422
|
-
|
|
4880
|
+
const loopTask = expr.resourceAttr(resourceType, tfLabel);
|
|
4881
|
+
emitTasks(children[0].tasks ?? [], expr.resourceAttr(resourceType, tfLabel, ["inner"]), { taskAddress: loopTask, childAddress: loopTask }, refKey);
|
|
4423
4882
|
// The loop body is a separate operator-owned chain. A fluent sibling
|
|
4424
4883
|
// authored after `forEach` continues from the for_each task itself,
|
|
4425
4884
|
// not from the body's terminal task; the latter silently moves that
|
|
@@ -4562,6 +5021,7 @@ export function automationToTf(entity, ctx) {
|
|
|
4562
5021
|
};
|
|
4563
5022
|
blocks.push(publish);
|
|
4564
5023
|
}
|
|
5024
|
+
setRefsRead(blocks);
|
|
4565
5025
|
const secretBlocks = [...refs.requiredSecrets].sort().map(requiredSecretVariableBlock);
|
|
4566
5026
|
return { blocks: [...secretBlocks, ...[...dataBlocks.values()].sort((a, b) => (a.type + "." + a.label).localeCompare(b.type + "." + b.label)), ...blocks], address: AUTOMATION_RESOURCE_TYPE + "." + label };
|
|
4567
5027
|
}
|