@elementumai/edk 0.10.4 → 0.12.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 +49 -13
- package/dist-sdk/src/catalog/token.js +2 -1
- package/dist-sdk/src/core/triggers/on-demand.d.ts +2 -0
- package/dist-sdk/src/core/triggers/on-demand.js +3 -0
- package/dist-sdk/src/core/wire/ref-serializer.js +26 -1
- package/dist-sdk/src/engine/build/context.d.ts +4 -0
- package/dist-sdk/src/engine/coverage-gaps.d.ts +7 -0
- package/dist-sdk/src/engine/coverage-gaps.js +12 -0
- package/dist-sdk/src/engine/ei/json-stream-reader.d.ts +43 -0
- package/dist-sdk/src/engine/ei/json-stream-reader.js +234 -0
- package/dist-sdk/src/engine/ei/run.d.ts +42 -1
- package/dist-sdk/src/engine/ei/run.js +201 -32
- package/dist-sdk/src/engine/ei/saved-plan.d.ts +16 -0
- package/dist-sdk/src/engine/ei/saved-plan.js +19 -0
- package/dist-sdk/src/engine/ei/state.d.ts +1 -1
- package/dist-sdk/src/engine/ei/state.js +17 -4
- package/dist-sdk/src/engine/progress.d.ts +3 -1
- package/dist-sdk/src/engine/progress.js +7 -3
- package/dist-sdk/src/engine/pull/authored-address.d.ts +15 -1
- package/dist-sdk/src/engine/pull/authored-address.js +180 -29
- package/dist-sdk/src/engine/pull/context.d.ts +37 -2
- package/dist-sdk/src/engine/pull/context.js +7 -4
- package/dist-sdk/src/engine/pull/ref-only.d.ts +18 -0
- package/dist-sdk/src/engine/pull/ref-only.js +52 -0
- package/dist-sdk/src/engine/tf/index.d.ts +2 -2
- package/dist-sdk/src/engine/tf/index.js +2 -2
- package/dist-sdk/src/engine/tf/labels.d.ts +22 -0
- package/dist-sdk/src/engine/tf/labels.js +50 -0
- package/dist-sdk/src/engine/tf/model.d.ts +2 -0
- package/dist-sdk/src/engine/tf/model.js +26 -0
- package/dist-sdk/src/engine/validation.d.ts +2 -0
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +18 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +58 -24
- package/dist-sdk/src/entities/access-policy/member-list.d.ts +32 -0
- package/dist-sdk/src/entities/access-policy/member-list.js +57 -0
- package/dist-sdk/src/entities/access-policy/module.js +10 -0
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +4 -3
- package/dist-sdk/src/entities/access-policy/to-tf.js +21 -12
- package/dist-sdk/src/entities/agent/build.js +7 -5
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +2 -0
- package/dist-sdk/src/entities/agent/from-tf.js +13 -3
- package/dist-sdk/src/entities/agent/to-tf.js +11 -5
- package/dist-sdk/src/entities/agent/tools.d.ts +8 -0
- package/dist-sdk/src/entities/agent/tools.js +6 -2
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +29 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.js +56 -3
- package/dist-sdk/src/entities/agent-tool/types.d.ts +12 -8
- package/dist-sdk/src/entities/agent-tool/types.js +13 -9
- package/dist-sdk/src/entities/app/build.d.ts +12 -1
- package/dist-sdk/src/entities/app/build.js +80 -4
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +5 -7
- package/dist-sdk/src/entities/app/from-tf.js +17 -12
- package/dist-sdk/src/entities/app/stage-keys.d.ts +18 -3
- package/dist-sdk/src/entities/app/stage-keys.js +40 -6
- package/dist-sdk/src/entities/app/to-tf.js +7 -4
- package/dist-sdk/src/entities/automation/build.d.ts +52 -31
- package/dist-sdk/src/entities/automation/build.js +59 -20
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +7 -4
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +39 -14
- package/dist-sdk/src/entities/automation/from-tf.d.ts +35 -2
- package/dist-sdk/src/entities/automation/from-tf.js +721 -93
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/module.d.ts +22 -2
- package/dist-sdk/src/entities/automation/module.js +244 -57
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +22 -2
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +54 -3
- package/dist-sdk/src/entities/automation/run-target.d.ts +61 -0
- package/dist-sdk/src/entities/automation/run-target.js +104 -0
- package/dist-sdk/src/entities/automation/script-code.d.ts +11 -1
- package/dist-sdk/src/entities/automation/script-code.js +106 -4
- package/dist-sdk/src/entities/automation/script-lint.d.ts +13 -0
- package/dist-sdk/src/entities/automation/script-lint.js +418 -0
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +17 -1
- package/dist-sdk/src/entities/automation/task-output-labels.js +58 -1
- package/dist-sdk/src/entities/automation/tasks.d.ts +67 -22
- package/dist-sdk/src/entities/automation/tasks.js +18 -4
- package/dist-sdk/src/entities/automation/to-tf.d.ts +1 -3
- package/dist-sdk/src/entities/automation/to-tf.js +354 -64
- package/dist-sdk/src/entities/automation/triggers.d.ts +63 -11
- package/dist-sdk/src/entities/automation/triggers.js +45 -5
- package/dist-sdk/src/entities/automation/types.d.ts +21 -0
- package/dist-sdk/src/entities/automation/types.js +26 -0
- package/dist-sdk/src/entities/chart/build.d.ts +9 -1
- package/dist-sdk/src/entities/chart/from-tf.d.ts +2 -2
- package/dist-sdk/src/entities/chart/from-tf.js +25 -1
- package/dist-sdk/src/entities/chart/index.d.ts +1 -1
- package/dist-sdk/src/entities/chart/printer.js +5 -2
- package/dist-sdk/src/entities/chart/to-tf.js +19 -1
- package/dist-sdk/src/entities/dashboard/from-tf.d.ts +11 -1
- package/dist-sdk/src/entities/dashboard/from-tf.js +57 -7
- package/dist-sdk/src/entities/dashboard/to-tf.js +13 -0
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +8 -2
- package/dist-sdk/src/entities/dynamic-layout/condition-keys.d.ts +48 -0
- package/dist-sdk/src/entities/dynamic-layout/condition-keys.js +261 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +3 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +66 -20
- package/dist-sdk/src/entities/dynamic-layout/module.js +2 -1
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +4 -2
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +341 -32
- package/dist-sdk/src/entities/element/build.d.ts +10 -0
- package/dist-sdk/src/entities/element/build.js +1 -0
- package/dist-sdk/src/entities/element/from-tf.js +14 -9
- package/dist-sdk/src/entities/element/to-tf.js +7 -4
- package/dist-sdk/src/entities/field/from-tf.d.ts +24 -0
- package/dist-sdk/src/entities/field/from-tf.js +79 -1
- package/dist-sdk/src/entities/field/module.js +14 -1
- package/dist-sdk/src/entities/field/to-tf.d.ts +38 -3
- package/dist-sdk/src/entities/field/to-tf.js +108 -34
- package/dist-sdk/src/entities/file-reader/module.js +3 -3
- package/dist-sdk/src/entities/file-reader/to-tf.js +3 -3
- package/dist-sdk/src/entities/file-reader/types.d.ts +4 -16
- package/dist-sdk/src/entities/file-reader/types.js +7 -0
- package/dist-sdk/src/entities/org/group.d.ts +1 -0
- package/dist-sdk/src/entities/org/group.js +2 -1
- package/dist-sdk/src/entities/org/role.js +5 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.d.ts +8 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.js +10 -2
- package/dist-sdk/src/entities/record-create-form/to-tf.d.ts +2 -1
- package/dist-sdk/src/entities/record-create-form/to-tf.js +14 -2
- package/dist-sdk/src/entities/relationship/from-tf.d.ts +8 -0
- package/dist-sdk/src/entities/relationship/from-tf.js +88 -10
- package/dist-sdk/src/entities/relationship/to-tf.d.ts +3 -2
- package/dist-sdk/src/entities/relationship/to-tf.js +79 -8
- package/dist-sdk/src/entities/role/from-tf.js +24 -7
- package/dist-sdk/src/entities/role/to-tf.js +25 -7
- package/dist-sdk/src/entities/service-account/from-tf.js +2 -1
- package/dist-sdk/src/entities/service-account/module.js +20 -0
- package/dist-sdk/src/entities/service-account/role-fidelity.d.ts +5 -5
- package/dist-sdk/src/entities/service-account/role-fidelity.js +21 -13
- package/dist-sdk/src/entities/service-account/to-tf.js +12 -4
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +1 -1
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +12 -7
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +6 -3
- package/dist-sdk/src/entities/shared/types/field-types.js +3 -1
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +5 -2
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +8 -1
- package/dist-sdk/src/entities/skill/from-tf.js +10 -3
- package/dist-sdk/src/entities/skill/module.js +18 -0
- package/dist-sdk/src/entities/skill/to-tf.d.ts +8 -1
- package/dist-sdk/src/entities/skill/to-tf.js +23 -14
- package/dist-sdk/src/entities/skill/tools.d.ts +8 -0
- package/dist-sdk/src/entities/skill/tools.js +6 -2
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +8 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.js +6 -2
- package/dist-sdk/src/entities/task/to-tf.js +1 -0
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +8 -2
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +20 -10
- package/dist-sdk/src/entities/view/from-tf.d.ts +68 -4
- package/dist-sdk/src/entities/view/from-tf.js +394 -22
- package/dist-sdk/src/entities/view/module.js +20 -0
- package/dist-sdk/src/entities/view/portable.d.ts +11 -0
- package/dist-sdk/src/entities/view/portable.js +47 -0
- package/dist-sdk/src/entities/view/to-tf.d.ts +4 -1
- package/dist-sdk/src/entities/view/to-tf.js +25 -7
- package/dist-sdk/src/entities/view/types.js +1 -1
- package/dist-sdk/src/entities/widget/build.d.ts +4 -3
- package/dist-sdk/src/entities/widget/from-tf.d.ts +3 -0
- package/dist-sdk/src/entities/widget/from-tf.js +100 -3
- package/dist-sdk/src/entities/widget/to-tf.d.ts +16 -1
- package/dist-sdk/src/entities/widget/to-tf.js +77 -14
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +30 -9
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/field-resource-types.d.ts +2 -0
- package/dist-sdk/src/graph/field-resource-types.js +11 -0
- package/dist-sdk/src/graph/index.d.ts +41 -3
- package/dist-sdk/src/graph/index.js +24 -2
- package/dist-sdk/src/graph/types.d.ts +195 -5
- package/package.json +1 -1
|
@@ -7,6 +7,8 @@ import { appResourceLabelPrefix, appScopedResourceLabel, expr, isTfExpr, isUuid,
|
|
|
7
7
|
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
|
+
import { scriptLintFindings } from "./script-lint.js";
|
|
11
|
+
import { MANAGED_FIELD_ORDER_RESOURCE_TYPE } from "../field/types.js";
|
|
10
12
|
import { SERVICE_ACCOUNT_RESOURCE_TYPE } from "../service-account/module.js";
|
|
11
13
|
import { serviceAccountRefToTf } from "../service-account/to-tf.js";
|
|
12
14
|
import { workspaceServiceAccountAppResolver } from "../service-account/workspace-owner.js";
|
|
@@ -18,7 +20,7 @@ import { outputFieldTypesFromScriptSchema, scriptOutputReferenceIsDeclared } fro
|
|
|
18
20
|
import { RESOURCE_TYPE_TO_EXECUTOR, TASK_OUTPUT_CONTRACTS } from "./generated/task-output-contracts.js";
|
|
19
21
|
import { CONNECTOR_ORG_BAG } from "../org/connector.js";
|
|
20
22
|
import { GROUP_ORG_BAG } from "../org/group.js";
|
|
21
|
-
import { FILE_READER_SUB_TYPE_BY_RESOURCE, FILE_READER_SUB_TYPE_BY_TYPE_KEY } from "../file-reader/types.js";
|
|
23
|
+
import { FILE_READER_SUB_TYPE_BY_RESOURCE, FILE_READER_SUB_TYPE_BY_TYPE_KEY, fileReaderResourceLabel } from "../file-reader/types.js";
|
|
22
24
|
import { UNRESOLVED_FIELD_MARKER } from "../shared/ref.js";
|
|
23
25
|
import { ELEMENT_SYSTEM_FIELD_KEYS } from "../element/system-fields.js";
|
|
24
26
|
import { TABLE_RESOURCE_TYPE } from "../table/module.js";
|
|
@@ -28,6 +30,7 @@ import { onDemandTriggerRefKey } from "./value-ref-tf.js";
|
|
|
28
30
|
import { normalizeOnDemandParamKey } from "../../../pull/util.js";
|
|
29
31
|
import { PROVIDER_FIXED_SYSTEM_FIELD_KEYS, recordFieldWireRefName } from "./system-ref-name.js";
|
|
30
32
|
import { taskTfLabel } from "./task-label.js";
|
|
33
|
+
import { automationRunTargetResourceAttr, automationTargetOwner, bareStaticRunTarget, onDemandRecordParamNames, recordInputMappingProblem } from "./run-target.js";
|
|
31
34
|
import { FIELD_TYPE_MAP, isOnDemandRecordType } from "../shared/types/field-types.js";
|
|
32
35
|
/** The context for reading records of `appRefName` (a `kind`), retargeted from the owner. */
|
|
33
36
|
/**
|
|
@@ -129,6 +132,7 @@ const TRIGGER_RESOURCES = {
|
|
|
129
132
|
datamine: "elementum_datamine_trigger",
|
|
130
133
|
survey: "elementum_survey_trigger",
|
|
131
134
|
schedule: "elementum_schedule_trigger",
|
|
135
|
+
temporal: "elementum_temporal_trigger",
|
|
132
136
|
};
|
|
133
137
|
/**
|
|
134
138
|
* The live platform id of a created variable: `variables[<index>].id` on its
|
|
@@ -226,7 +230,7 @@ const CONFIG_ATTRS = {
|
|
|
226
230
|
fromUsername: "from_username",
|
|
227
231
|
fromPersonal: "from_personal",
|
|
228
232
|
externalEmails: "external_emails",
|
|
229
|
-
emailAttachments: "
|
|
233
|
+
emailAttachments: "email_attachments",
|
|
230
234
|
contentsReference: "message",
|
|
231
235
|
agentId: "agent_id",
|
|
232
236
|
agentPrompt: "prompt",
|
|
@@ -278,6 +282,66 @@ function onlyEntry(value, subject) {
|
|
|
278
282
|
}
|
|
279
283
|
return entries[0];
|
|
280
284
|
}
|
|
285
|
+
/**
|
|
286
|
+
* Tasks whose refs carry every field of the record they search (edk#2280)
|
|
287
|
+
* or create (edk#2406). update_field refs carry them too and aren't covered yet.
|
|
288
|
+
*/
|
|
289
|
+
const OBJECT_FIELD_REFS_TASK_TYPES = new Set([
|
|
290
|
+
"elementum_record_search_task",
|
|
291
|
+
"elementum_find_related_records_task",
|
|
292
|
+
"elementum_create_record_task",
|
|
293
|
+
]);
|
|
294
|
+
/**
|
|
295
|
+
* Triggers whose refs were confirmed to carry every custom field of the
|
|
296
|
+
* owner's record (a Preston High state with 18 field types). Build sets
|
|
297
|
+
* `object_field_ids` on these triggers only.
|
|
298
|
+
*/
|
|
299
|
+
const OBJECT_FIELD_REFS_TRIGGER_TYPES = new Set([
|
|
300
|
+
"elementum_record_created_trigger",
|
|
301
|
+
"elementum_record_updated_trigger",
|
|
302
|
+
"elementum_comment_added_trigger",
|
|
303
|
+
"elementum_attachment_added_trigger",
|
|
304
|
+
"elementum_agent_conversation_ended_trigger",
|
|
305
|
+
"elementum_on_demand_trigger",
|
|
306
|
+
]);
|
|
307
|
+
/**
|
|
308
|
+
* A record-bearing task's or trigger's write-only `object_field_ids`
|
|
309
|
+
* (edk#2280). It is the field order of its app or element, so a field created
|
|
310
|
+
* in the same apply plans `refs` unknown instead of keeping refs read before
|
|
311
|
+
* the field existed. Only an owner whose own fields this build writes (and so
|
|
312
|
+
* whose `elementum_managed_field_order` it writes) gets one. ei's export sets it
|
|
313
|
+
* only for the exported app or element. A pull builds only that root, so the
|
|
314
|
+
* two agree there.
|
|
315
|
+
*/
|
|
316
|
+
function objectFieldIdsAttr(objectId, fieldAddresses) {
|
|
317
|
+
if (fieldAddresses === undefined || fieldAddresses.size === 0)
|
|
318
|
+
return {};
|
|
319
|
+
if (objectId === undefined || !isTfExpr(objectId) || objectId.$expr !== "resource-attr" || objectId.path.length !== 1 || objectId.path[0] !== "id")
|
|
320
|
+
return {};
|
|
321
|
+
const scope = objectId.type === "elementum_app" ? "app" : objectId.type === "elementum_element" ? "element" : undefined;
|
|
322
|
+
if (scope === undefined)
|
|
323
|
+
return {};
|
|
324
|
+
// The addresses must be this owner's own fields, since an app and an element can share a refName.
|
|
325
|
+
const fieldLabelPrefix = scopedResourceLabel(objectId.label, "", scope);
|
|
326
|
+
const ownFields = [...fieldAddresses.values()].some((address) => address.slice(address.indexOf(".") + 1).startsWith(fieldLabelPrefix));
|
|
327
|
+
if (!ownFields)
|
|
328
|
+
return {};
|
|
329
|
+
return {
|
|
330
|
+
object_field_ids: expr.resourceAttr(MANAGED_FIELD_ORDER_RESOURCE_TYPE, scopedResourceLabel(objectId.label, "field_order", scope), ["field_ids"]),
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
/** The field addresses this build writes for a task's `aspectId` target. */
|
|
334
|
+
function taskTargetFieldAddresses(aspectId, owner) {
|
|
335
|
+
const target = token(aspectId);
|
|
336
|
+
if (target === undefined || typeof target.refName !== "string")
|
|
337
|
+
return undefined;
|
|
338
|
+
const kind = target.__kind === "element" ? "element" : target.__kind === "app" ? "app" : undefined;
|
|
339
|
+
if (kind === undefined)
|
|
340
|
+
return undefined;
|
|
341
|
+
if (target.refName === owner.appRefName && kind === owner.parentScope)
|
|
342
|
+
return owner.fieldAddresses;
|
|
343
|
+
return fieldNamesForAppRefName(owner.fieldAddressesByAppRefName, target.refName);
|
|
344
|
+
}
|
|
281
345
|
function token(value) {
|
|
282
346
|
if (!isObject(value) || typeof value.__kind !== "string")
|
|
283
347
|
return undefined;
|
|
@@ -503,19 +567,6 @@ function registerForeignFieldLookup(value, ctx, dataBlocks) {
|
|
|
503
567
|
registerForeignOptionsByLabelLocal(fieldLabel, ctx);
|
|
504
568
|
return fieldLabel;
|
|
505
569
|
}
|
|
506
|
-
/**
|
|
507
|
-
* A bare platform-id target whose every input names a raw parameter id is a
|
|
508
|
-
* static run: pull prints a static export with an undiscovered target
|
|
509
|
-
* (`target_automation_id` + `input_mappings[].parameter_id`) as
|
|
510
|
-
* `automation: "<uuid>"` + `inputs[].name: "<uuid>"`. Dynamic mappings name
|
|
511
|
-
* the target's inputs, never a parameter id.
|
|
512
|
-
*/
|
|
513
|
-
function bareStaticRunTarget(config) {
|
|
514
|
-
return typeof config.targetAutomationId === "string" &&
|
|
515
|
-
Array.isArray(config.inputMappings) &&
|
|
516
|
-
config.inputMappings.length > 0 &&
|
|
517
|
-
config.inputMappings.every((mapping) => isObject(mapping) && typeof mapping.name === "string" && isUuid(mapping.name));
|
|
518
|
-
}
|
|
519
570
|
/**
|
|
520
571
|
* Resolve an automation token as a managed definition (same stream root or a
|
|
521
572
|
* sibling root in this build) or as a ref-only `data.elementum_automation`
|
|
@@ -524,9 +575,7 @@ function bareStaticRunTarget(config) {
|
|
|
524
575
|
* degrade to `target_automation_ref` / `dynamic_input_mappings`.
|
|
525
576
|
*/
|
|
526
577
|
function automationTargetToTf(value, ctx, dataBlocks) {
|
|
527
|
-
const ownerKind = value
|
|
528
|
-
const isOwn = value.parent === undefined ||
|
|
529
|
-
(value.parent === ctx.appRefName && ownerKind === ctx.parentScope);
|
|
578
|
+
const { ownerKind, isOwn } = automationTargetOwner(value, ctx);
|
|
530
579
|
const sibling = !isOwn && value.parent !== undefined
|
|
531
580
|
? ctx.workspaceAspects?.get(workspaceAspectKey(ownerKind, value.parent))
|
|
532
581
|
: undefined;
|
|
@@ -542,6 +591,7 @@ function automationTargetToTf(value, ctx, dataBlocks) {
|
|
|
542
591
|
: undefined;
|
|
543
592
|
const managedLabel = automationResourceLabel(managedOwnerLabel, value.refName, ownerKind === "element" ? "element" : "app", managedHandle);
|
|
544
593
|
const targetActiveRefs = targetOwner?.activeAutomationRefNames;
|
|
594
|
+
const recordInputNames = targetOwner?.onDemandRecordInputsByAutomationRefName?.get(value.refName);
|
|
545
595
|
const isActive = targetActiveRefs !== undefined
|
|
546
596
|
? targetActiveRefs.has(value.refName)
|
|
547
597
|
: isOwn && ctx.activeAutomationRefNames?.has(value.refName) === true;
|
|
@@ -574,12 +624,14 @@ function automationTargetToTf(value, ctx, dataBlocks) {
|
|
|
574
624
|
id: expr.dataAttr(AUTOMATION_RESOURCE_TYPE, currentBindingLabel, ["id"]),
|
|
575
625
|
parameterId: (name) => expr.dataAttr(AUTOMATION_RESOURCE_TYPE, currentBindingLabel, ["parameter_ids", { index: name }]),
|
|
576
626
|
managedLabel,
|
|
627
|
+
recordInputNames,
|
|
577
628
|
};
|
|
578
629
|
}
|
|
579
630
|
return {
|
|
580
631
|
id: expr.resourceAttr(AUTOMATION_RESOURCE_TYPE, managedLabel, ["id"]),
|
|
581
632
|
parameterId: (name) => expr.resourceAttr("elementum_on_demand_trigger", managedLabel, ["parameter_ids", { index: name }]),
|
|
582
633
|
managedLabel,
|
|
634
|
+
recordInputNames,
|
|
583
635
|
};
|
|
584
636
|
}
|
|
585
637
|
if (value.parent === undefined || value.parent === "") {
|
|
@@ -955,7 +1007,7 @@ function tokenToTf(value, ctx, dataBlocks) {
|
|
|
955
1007
|
if (subType === undefined || subType.implemented !== true) {
|
|
956
1008
|
throw new EntityTfError(`file reader token "${value.refName}" has no recognized readerType ("${value.readerType}") — was it built with a file-reader factory?`);
|
|
957
1009
|
}
|
|
958
|
-
return expr.resourceAttr(subType.resourceType,
|
|
1010
|
+
return expr.resourceAttr(subType.resourceType, fileReaderResourceLabel(fileReaderOwnerTfLabel(value, ctx), value.refName), ["id"]);
|
|
959
1011
|
}
|
|
960
1012
|
case "group": {
|
|
961
1013
|
// Static notification/add-watcher recipients (edk#1389). An org.ts
|
|
@@ -988,6 +1040,28 @@ function tokenToTf(value, ctx, dataBlocks) {
|
|
|
988
1040
|
throw new EntityTfError(`catalog ref kind "${value.__kind}" has no automation HCL representation`);
|
|
989
1041
|
}
|
|
990
1042
|
}
|
|
1043
|
+
/**
|
|
1044
|
+
* The Terraform label of the app that owns a file-reader token. Another
|
|
1045
|
+
* app's reader is scoped under that app, built here or authored but left out
|
|
1046
|
+
* of this build. An element-owned reader is reachable only from its own
|
|
1047
|
+
* element: the provider and export do not carry one across owners yet.
|
|
1048
|
+
*/
|
|
1049
|
+
function fileReaderOwnerTfLabel(value, ctx) {
|
|
1050
|
+
const owner = value.parent;
|
|
1051
|
+
if (owner === undefined || owner === ctx.appRefName)
|
|
1052
|
+
return ctx.appTfLabel;
|
|
1053
|
+
const app = ctx.workspaceAspects?.get(workspaceAspectKey("app", owner));
|
|
1054
|
+
if (app !== undefined)
|
|
1055
|
+
return app.tfLabel;
|
|
1056
|
+
const outOfScope = ctx.outOfScopeApps?.get(owner)?.namespace;
|
|
1057
|
+
if (outOfScope !== undefined)
|
|
1058
|
+
return outOfScope;
|
|
1059
|
+
if (ctx.workspaceAspects?.get(workspaceAspectKey("element", owner)) !== undefined) {
|
|
1060
|
+
throw new EntityTfError(`automation ${ctx.automationTfLabel}: file reader "${owner}.${value.refName}" is owned by element "${owner}" — ` +
|
|
1061
|
+
"a file reader is referenced across owners only from an app");
|
|
1062
|
+
}
|
|
1063
|
+
throw new EntityTfError(`automation ${ctx.automationTfLabel}: file reader "${owner}.${value.refName}" is owned by "${owner}", which is not an app in this workspace`);
|
|
1064
|
+
}
|
|
991
1065
|
function procedureToTf(value, ctx, dataBlocks) {
|
|
992
1066
|
if (value.__kind !== "procedure")
|
|
993
1067
|
throw new EntityTfError("procedure requires a procedure catalog reference");
|
|
@@ -1213,12 +1287,43 @@ function calculationTaskRefName(targetType, name, taskRefKey, refs) {
|
|
|
1213
1287
|
suffix.length > 0 ? `.${suffix}` : "",
|
|
1214
1288
|
];
|
|
1215
1289
|
}
|
|
1216
|
-
|
|
1290
|
+
// A single-output AI task's `.output` reaches here as its refs label
|
|
1291
|
+
// (`Response`); the calc engine resolves only the canonical name (`response`, #2405).
|
|
1292
|
+
const refName = taskOutputReferenceName(targetType, name, refs.tasks.get(taskRefKey)) ??
|
|
1293
|
+
canonicalSingleOutputName(targetType, name) ?? name;
|
|
1217
1294
|
if (refName.includes('"')) {
|
|
1218
1295
|
throw new EntityTfError(`calculation task output name "${refName}" contains a double quote`);
|
|
1219
1296
|
}
|
|
1220
1297
|
return [refName];
|
|
1221
1298
|
}
|
|
1299
|
+
/**
|
|
1300
|
+
* Output → refs-map key, the inverse of TASK_OUTPUT_REFERENCE_NAMES, for the
|
|
1301
|
+
* tasks whose refs are keyed by display label: bulkUpdateFields (edk#2281) and
|
|
1302
|
+
* tableRecordsSearch (edk#2407, whose count is authored as `totalCount`).
|
|
1303
|
+
* Envelopes and calculations keep the output's own name.
|
|
1304
|
+
*/
|
|
1305
|
+
function inverseReferenceNames(resourceType) {
|
|
1306
|
+
return Object.fromEntries(Object.entries(TASK_OUTPUT_REFERENCE_NAMES[resourceType] ?? {}).map(([key, name]) => [name, key]));
|
|
1307
|
+
}
|
|
1308
|
+
const BULK_UPDATE_FIELDS_REFS_INDEX = inverseReferenceNames(TASK_RESOURCES.bulkUpdateFields);
|
|
1309
|
+
const TABLE_RECORDS_SEARCH_REFS_INDEX = (() => {
|
|
1310
|
+
const index = inverseReferenceNames(TASK_RESOURCES.tableRecordsSearch);
|
|
1311
|
+
return { ...index, totalCount: index["count"] };
|
|
1312
|
+
})();
|
|
1313
|
+
/** refs-map key for a task output keyed by a display label (AI completion tasks, bulkUpdateFields, tableRecordsSearch), or undefined. */
|
|
1314
|
+
function taskOutputRefsIndex(resourceType, name) {
|
|
1315
|
+
if (resourceType === TASK_RESOURCES.bulkUpdateFields)
|
|
1316
|
+
return BULK_UPDATE_FIELDS_REFS_INDEX[name];
|
|
1317
|
+
if (resourceType === TASK_RESOURCES.tableRecordsSearch)
|
|
1318
|
+
return TABLE_RECORDS_SEARCH_REFS_INDEX[name];
|
|
1319
|
+
return aiCompletionRefsIndex(resourceType, name);
|
|
1320
|
+
}
|
|
1321
|
+
/** A refs key's WorkflowTaskReference name. An apiRequest maps only when it's JSON; FILE and CUSTOM are unconfirmed live (edk#2058). */
|
|
1322
|
+
function taskOutputReferenceName(type, wireName, task) {
|
|
1323
|
+
if (type === TASK_RESOURCES.api && task?.jsonApiResponse !== true)
|
|
1324
|
+
return undefined;
|
|
1325
|
+
return TASK_OUTPUT_REFERENCE_NAMES[type]?.[wireName];
|
|
1326
|
+
}
|
|
1222
1327
|
/**
|
|
1223
1328
|
* The calc-engine field id of a found record's field. A field of an aspect in
|
|
1224
1329
|
* this build is its resource id. A sibling the workspace authors but this
|
|
@@ -1731,9 +1836,10 @@ function taskOutputWireRefKey(targetType, name, taskRefKey, refs) {
|
|
|
1731
1836
|
if (scriptIndex !== undefined)
|
|
1732
1837
|
return scriptIndex;
|
|
1733
1838
|
}
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1839
|
+
// AI completion, bulkUpdateFields (edk#2281) and tableRecordsSearch (edk#2407) outputs are keyed by display label.
|
|
1840
|
+
const labelIndex = taskOutputRefsIndex(targetType, name);
|
|
1841
|
+
if (labelIndex !== undefined)
|
|
1842
|
+
return labelIndex;
|
|
1737
1843
|
return taskWireRefName(name, taskRefKey, refs);
|
|
1738
1844
|
}
|
|
1739
1845
|
/** The platform's own on-demand "Triggered By" refs (live refs-map keys). */
|
|
@@ -1792,14 +1898,6 @@ function recordParamFieldWireName(paramName, suffix, refs) {
|
|
|
1792
1898
|
: fieldNamesForAppRefName(refs.fieldNamesByAppRefName, targetRefName);
|
|
1793
1899
|
return wireRefName(`record.${suffix}`, recordOwnerContext(refs.owner, targetRefName, target.__kind === "element" || target.__kind === "app" ? target.__kind : undefined, targetFieldNames));
|
|
1794
1900
|
}
|
|
1795
|
-
/** Run-automation targets reference publish for ACTIVE automations, automation for draft/inactive. */
|
|
1796
|
-
export function automationRunTargetResourceAttr(appTfLabel, automationRefName, activeAutomationRefNames, scope = "app", handle) {
|
|
1797
|
-
const label = automationResourceLabel(appTfLabel, automationRefName, scope, handle);
|
|
1798
|
-
if (activeAutomationRefNames?.has(automationRefName) === true) {
|
|
1799
|
-
return expr.resourceAttr(WORKFLOW_PUBLISH_RESOURCE_TYPE, label, ["id"]);
|
|
1800
|
-
}
|
|
1801
|
-
return expr.resourceAttr(AUTOMATION_RESOURCE_TYPE, label, ["id"]);
|
|
1802
|
-
}
|
|
1803
1901
|
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
1804
1902
|
const ISO_DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
|
|
1805
1903
|
/** The provider's `ValidateFieldValue` datetime shape: seconds and a timezone are required. */
|
|
@@ -2098,6 +2196,21 @@ function aiAgentPlatformRefName(refsKey) {
|
|
|
2098
2196
|
}
|
|
2099
2197
|
return `ai_agent_task_structured_output.${refsKey.toLowerCase()}`;
|
|
2100
2198
|
}
|
|
2199
|
+
/**
|
|
2200
|
+
* Switch left-value name for one AI agent structured field, or undefined
|
|
2201
|
+
* when `wireName` is the whole text response (`refs["Action Response"]`).
|
|
2202
|
+
* Filter refs arrive already rewritten (`candidateCount`); a leftover
|
|
2203
|
+
* `result.<field>` is accepted too.
|
|
2204
|
+
*/
|
|
2205
|
+
function aiAgentStructuredLeftValueName(wireName) {
|
|
2206
|
+
if (wireName === "Action Response" || wireName === "result" || wireName === "ai_agent_task_response") {
|
|
2207
|
+
return undefined;
|
|
2208
|
+
}
|
|
2209
|
+
const field = wireName.startsWith("result.") ? wireName.slice("result.".length) : wireName;
|
|
2210
|
+
if (field === "" || field === "Action Response")
|
|
2211
|
+
return undefined;
|
|
2212
|
+
return aiAgentPlatformRefName(field);
|
|
2213
|
+
}
|
|
2101
2214
|
function publishOutputType(value, target, wireName) {
|
|
2102
2215
|
if (typeof value.fieldType === "string") {
|
|
2103
2216
|
return { fieldType: value.fieldType, multiple: value.multiple === true };
|
|
@@ -2148,16 +2261,6 @@ function collectUnresolvedForEachItems(value, found) {
|
|
|
2148
2261
|
for (const nested of Object.values(value))
|
|
2149
2262
|
collectUnresolvedForEachItems(nested, found);
|
|
2150
2263
|
}
|
|
2151
|
-
/** The onDemand trigger's record parameters: they expose only a record ID. */
|
|
2152
|
-
function onDemandRecordParamNames(trigger) {
|
|
2153
|
-
const inputs = trigger?.onDemand?.inputs;
|
|
2154
|
-
if (!Array.isArray(inputs))
|
|
2155
|
-
return new Set();
|
|
2156
|
-
return new Set(inputs.flatMap((input) => {
|
|
2157
|
-
const param = input;
|
|
2158
|
-
return typeof param?.name === "string" && isOnDemandRecordType(typeof param.type === "string" ? param.type : undefined) ? [param.name] : [];
|
|
2159
|
-
}));
|
|
2160
|
-
}
|
|
2161
2264
|
/** refKey → task kind (`findRelatedRecords`, …) for every task, nested ones included. */
|
|
2162
2265
|
function collectPayloadTaskKinds(value, kinds) {
|
|
2163
2266
|
if (Array.isArray(value)) {
|
|
@@ -2489,6 +2592,10 @@ function valueToTf(value, refs) {
|
|
|
2489
2592
|
function snake(name) {
|
|
2490
2593
|
return name.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/-/g, "_").toLowerCase();
|
|
2491
2594
|
}
|
|
2595
|
+
/** The provider's `default_value` is a string: a Checkbox default is `"true"` or `"false"`, as `ei` export writes it. */
|
|
2596
|
+
function onDemandDefaultToTf(value) {
|
|
2597
|
+
return typeof value === "boolean" ? String(value) : value;
|
|
2598
|
+
}
|
|
2492
2599
|
function unwrapDefault(value) {
|
|
2493
2600
|
if (!isObject(value))
|
|
2494
2601
|
return value;
|
|
@@ -2564,7 +2671,8 @@ function onDemandRecordFieldFilterReference(name, refs, operator) {
|
|
|
2564
2671
|
/**
|
|
2565
2672
|
* The canonical (`service_tasks`) name of a single-output AI task's output,
|
|
2566
2673
|
* when `wireName` is that output's refs display label. The filter short form
|
|
2567
|
-
* `task.<id>.<name>`
|
|
2674
|
+
* `task.<id>.<name>` and a calculation's `{{task name="..."}}` use it
|
|
2675
|
+
* (`response`), not the label (`Response`, #2405).
|
|
2568
2676
|
*/
|
|
2569
2677
|
function canonicalSingleOutputName(resourceType, wireName) {
|
|
2570
2678
|
const taskKey = Object.keys(TASK_RESOURCES).find((key) => TASK_RESOURCES[key] === resourceType);
|
|
@@ -2572,6 +2680,27 @@ function canonicalSingleOutputName(resourceType, wireName) {
|
|
|
2572
2680
|
return undefined;
|
|
2573
2681
|
return OUTPUT_KEY_CANONICAL[taskKey];
|
|
2574
2682
|
}
|
|
2683
|
+
/**
|
|
2684
|
+
* A Table Records Search's or AI Data Search's `.records` read as a filter
|
|
2685
|
+
* value, by authored name or refs key, keyed by resource type (edk#2402). The
|
|
2686
|
+
* filter value spells it by its output contract name, not the refs key
|
|
2687
|
+
* ("All matching table rows", "All Records") or Record Search's
|
|
2688
|
+
* `All found records`.
|
|
2689
|
+
*/
|
|
2690
|
+
const SEARCH_RECORDS_FILTER_NAMES = {
|
|
2691
|
+
[TASK_RESOURCES.tableRecordsSearch]: { names: ["records", "All matching table rows"], contractName: "records" },
|
|
2692
|
+
[TASK_RESOURCES.aiSearchTable]: { names: ["records", AI_SEARCH_TABLE_OUTPUT_NAMES.records[0]], contractName: AI_SEARCH_TABLE_OUTPUT_NAMES.records[1] },
|
|
2693
|
+
};
|
|
2694
|
+
function searchRecordsContractName(resourceType, name, wireName) {
|
|
2695
|
+
const entry = SEARCH_RECORDS_FILTER_NAMES[resourceType];
|
|
2696
|
+
if (entry === undefined || !(entry.names.includes(name) || entry.names.includes(wireName)))
|
|
2697
|
+
return undefined;
|
|
2698
|
+
const executor = RESOURCE_TYPE_TO_EXECUTOR[resourceType];
|
|
2699
|
+
if (executor === undefined || TASK_OUTPUT_CONTRACTS[executor]?.[entry.contractName] === undefined) {
|
|
2700
|
+
throw new EntityTfError(`${resourceType} has no "${entry.contractName}" output contract`);
|
|
2701
|
+
}
|
|
2702
|
+
return entry.contractName;
|
|
2703
|
+
}
|
|
2575
2704
|
const TRIGGER_REFERENCE_NAME_PATTERN = /^[a-z][A-Za-z0-9]*(?:\.[a-z][A-Za-z0-9]*)*$/;
|
|
2576
2705
|
function filterReferenceToTf(value, refs, role = "value", realType, operator) {
|
|
2577
2706
|
// Raw pass-through for a filter left side the pull-time deserializer
|
|
@@ -2714,9 +2843,25 @@ function filterReferenceToTf(value, refs, role = "value", realType, operator) {
|
|
|
2714
2843
|
throw new EntityTfError(`unresolved task filter ref "${value.taskRefKey}"`);
|
|
2715
2844
|
const isFileReaderTask = task.type === "elementum_ai_file_read_task" || task.type === "elementum_file_reader_task";
|
|
2716
2845
|
const isAiAgentTask = task.type === "elementum_ai_agent_task";
|
|
2846
|
+
// A found record's field on the value side is spelled by field id, so
|
|
2847
|
+
// its refs label is never needed. That label has no form for a field
|
|
2848
|
+
// of the related record (`record.<field>.<related field id>`).
|
|
2849
|
+
const recordFieldName = role === "left"
|
|
2850
|
+
? undefined
|
|
2851
|
+
: foundRecordFieldReferenceName(task.type, value.name, value.taskRefKey, refs);
|
|
2852
|
+
if (recordFieldName !== undefined) {
|
|
2853
|
+
return expr.template(["task.", expr.resourceAttr(task.type, task.label, ["id"]), ".", ...recordFieldName]);
|
|
2854
|
+
}
|
|
2855
|
+
// A Table Records Search switch reads its refs by display label
|
|
2856
|
+
// (edk#2407). Look the authored name up before taskWireRefName, whose
|
|
2857
|
+
// generic rewrite turns `record` into `Record`, as taskOutputWireRefKey
|
|
2858
|
+
// does. `records` keeps its current spelling.
|
|
2859
|
+
const tableSearchLabel = role === "left" && task.type === TASK_RESOURCES.tableRecordsSearch && value.name !== "records"
|
|
2860
|
+
? taskOutputRefsIndex(task.type, value.name)
|
|
2861
|
+
: undefined;
|
|
2717
2862
|
const wireName = isFileReaderTask || isAiAgentTask
|
|
2718
2863
|
? value.name
|
|
2719
|
-
: taskWireRefName(value.name, value.taskRefKey, refs);
|
|
2864
|
+
: tableSearchLabel ?? taskWireRefName(value.name, value.taskRefKey, refs);
|
|
2720
2865
|
// left_value (switch cases): provider Read stores the JSON envelope that
|
|
2721
2866
|
// `.refs["…"]` evaluates to (#490). Emitting the short `task.<id>.…`
|
|
2722
2867
|
// string matches record_search RHS state but perpetual-diffs left_value.
|
|
@@ -2770,6 +2915,23 @@ function filterReferenceToTf(value, refs, role = "value", realType, operator) {
|
|
|
2770
2915
|
},
|
|
2771
2916
|
});
|
|
2772
2917
|
}
|
|
2918
|
+
// An AI agent's structured field is `refs["<field>"]` on a task input
|
|
2919
|
+
// (#759). A switch left-value is the other spelling: a NUMBER (or
|
|
2920
|
+
// other) envelope whose taskReference.name is
|
|
2921
|
+
// `ai_agent_task_structured_output.<field>` (#2096). Emitting the
|
|
2922
|
+
// refs index here plans that envelope away after every pull.
|
|
2923
|
+
const aiAgentStructuredName = isAiAgentTask ? aiAgentStructuredLeftValueName(wireName) : undefined;
|
|
2924
|
+
if (aiAgentStructuredName !== undefined) {
|
|
2925
|
+
const declared = task.outputFieldTypes?.get(wireName);
|
|
2926
|
+
return expr.jsonencode({
|
|
2927
|
+
fieldType: (realType ?? declared?.fieldType ?? "TEXT").toUpperCase(),
|
|
2928
|
+
multiple: declared?.multiple === true,
|
|
2929
|
+
taskReference: {
|
|
2930
|
+
name: aiAgentStructuredName,
|
|
2931
|
+
taskId: expr.resourceAttr(task.type, task.label, ["id"]),
|
|
2932
|
+
},
|
|
2933
|
+
});
|
|
2934
|
+
}
|
|
2773
2935
|
// An explicit filter.text() on a runAutomation output is a TEXT
|
|
2774
2936
|
// envelope. A missing realType stays on .refs; the provider's refs
|
|
2775
2937
|
// map is already TEXT for outputs ei stores that way.
|
|
@@ -2790,11 +2952,15 @@ function filterReferenceToTf(value, refs, role = "value", realType, operator) {
|
|
|
2790
2952
|
// `multiple` follows the declaration so an array output is not
|
|
2791
2953
|
// flattened. A NUMBER comparison of a DECIMAL script output is the
|
|
2792
2954
|
// next branch (#1618).
|
|
2793
|
-
const envelopeName =
|
|
2794
|
-
const
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2955
|
+
const envelopeName = taskOutputReferenceName(task.type, wireName, task) ?? wireName;
|
|
2956
|
+
const declared = declaredTaskOutputType(task, wireName, envelopeName);
|
|
2957
|
+
// This includes a Table Records Search row (TABLE_RECORD): the
|
|
2958
|
+
// platform stores only the condition's real_type, so a check of
|
|
2959
|
+
// `.record`, bare (built with real_type text) or `filter.text(…)`, is
|
|
2960
|
+
// read back and exported as the TEXT envelope named `record`
|
|
2961
|
+
// (edk#2407).
|
|
2962
|
+
const isTableSearchRow = task.type === TASK_RESOURCES.tableRecordsSearch && declared?.fieldType === "TABLE_RECORD" && declared.multiple !== true;
|
|
2963
|
+
const compared = realType?.toUpperCase() ?? (isTableSearchRow ? "TEXT" : undefined);
|
|
2798
2964
|
if (compared !== undefined &&
|
|
2799
2965
|
declared !== undefined &&
|
|
2800
2966
|
declared.fieldType !== compared &&
|
|
@@ -2869,27 +3035,37 @@ function filterReferenceToTf(value, refs, role = "value", realType, operator) {
|
|
|
2869
3035
|
}
|
|
2870
3036
|
const refsIndex = task.type === TASK_RESOURCES.executeScript
|
|
2871
3037
|
? executeScriptRefsIndex(wireName) ?? wireName
|
|
2872
|
-
:
|
|
3038
|
+
: taskOutputRefsIndex(task.type, wireName) ?? wireName;
|
|
2873
3039
|
return expr.resourceAttr(task.type, task.label, ["refs", { index: refsIndex }]);
|
|
2874
3040
|
}
|
|
2875
|
-
const recordFieldName = foundRecordFieldReferenceName(task.type, value.name, value.taskRefKey, refs);
|
|
2876
3041
|
// The short form addresses user-search outputs by path, and an AI task's
|
|
2877
3042
|
// single output by its canonical name (`response`, edk#1509); only
|
|
2878
3043
|
// `.refs` is keyed by their display labels. recordSearch's ASPECT_RECORD_ID
|
|
2879
3044
|
// is keyed `First found record id` in refs, but filter RHS / ei export use
|
|
2880
3045
|
// the canonical short name `recordId` (service_tasks) — emitting the
|
|
2881
|
-
// display label here plans drift after every pull (edk#1524).
|
|
3046
|
+
// display label here plans drift after every pull (edk#1524). Its
|
|
3047
|
+
// `All found records` short name is `records`, and a Find Related
|
|
3048
|
+
// Records filter value uses that same short name. A Table Records
|
|
3049
|
+
// Search's or AI Data Search's `.records` uses its contract name.
|
|
3050
|
+
const searchRecords = searchRecordsContractName(task.type, value.name, wireName);
|
|
2882
3051
|
const shortName = task.type === TASK_RESOURCES.userSearch
|
|
2883
3052
|
? USER_SEARCH_PATH_BY_WIRE_NAME.get(wireName) ?? wireName
|
|
2884
3053
|
: task.type === TASK_RESOURCES.recordSearch &&
|
|
2885
3054
|
(wireName === "First found record id" || value.name === "record.recordId" || value.name === "recordId")
|
|
2886
3055
|
? "recordId"
|
|
2887
|
-
:
|
|
3056
|
+
: (task.type === TASK_RESOURCES.recordSearch || task.type === TASK_RESOURCES.findRelatedRecords) &&
|
|
3057
|
+
(wireName === "All found records" || value.name === "records")
|
|
3058
|
+
? "records"
|
|
3059
|
+
: searchRecords !== undefined
|
|
3060
|
+
? searchRecords
|
|
3061
|
+
: task.type === TASK_RESOURCES.api
|
|
3062
|
+
? taskOutputReferenceName(task.type, wireName, task) ?? wireName
|
|
3063
|
+
: canonicalSingleOutputName(task.type, wireName) ?? wireName;
|
|
2888
3064
|
return expr.template([
|
|
2889
3065
|
"task.",
|
|
2890
3066
|
expr.resourceAttr(task.type, task.label, ["id"]),
|
|
2891
3067
|
".",
|
|
2892
|
-
|
|
3068
|
+
shortName,
|
|
2893
3069
|
]);
|
|
2894
3070
|
}
|
|
2895
3071
|
case "FOR_EACH": {
|
|
@@ -3064,12 +3240,53 @@ function recordRefKeyIsAmbiguous(name, wireName, taskRefKey, refs) {
|
|
|
3064
3240
|
}
|
|
3065
3241
|
return false;
|
|
3066
3242
|
}
|
|
3243
|
+
/** A task output's declared type: from the task's own output schema, else the executor's output contract. */
|
|
3244
|
+
function declaredTaskOutputType(task, wireName, envelopeName) {
|
|
3245
|
+
const executor = RESOURCE_TYPE_TO_EXECUTOR[task.type];
|
|
3246
|
+
return task.outputFieldTypes?.get(wireName) ??
|
|
3247
|
+
(executor === undefined ? undefined : TASK_OUTPUT_CONTRACTS[executor]?.[envelopeName]);
|
|
3248
|
+
}
|
|
3249
|
+
/**
|
|
3250
|
+
* A switch case comparing a single BOOLEAN task output with no typed wrapper
|
|
3251
|
+
* (`filter.eq(ctx.actions.B.allMatchingRecordsUpdated, true)`) compares as
|
|
3252
|
+
* BOOLEAN, the same as `filter.boolean(...)`. Built with the operator's TEXT
|
|
3253
|
+
* fallback, the platform stores a text comparison, pull prints it back as
|
|
3254
|
+
* `filter.text(...)`, and the plan after that pull changes the envelope's
|
|
3255
|
+
* fieldType BOOLEAN -> TEXT (#2404). Only that fallback yields: a typed
|
|
3256
|
+
* wrapper (`filter.text(...)`) is explicit and never reaches this hook.
|
|
3257
|
+
*/
|
|
3258
|
+
function booleanTaskOutputRealType(reference, refs, authored) {
|
|
3259
|
+
if (authored !== undefined && authored.toUpperCase() !== "TEXT")
|
|
3260
|
+
return undefined;
|
|
3261
|
+
if (!isObject(reference) || reference.type?.toString().toUpperCase() !== "TASK")
|
|
3262
|
+
return undefined;
|
|
3263
|
+
if (typeof reference.taskRefKey !== "string" || typeof reference.name !== "string")
|
|
3264
|
+
return undefined;
|
|
3265
|
+
const task = refs.tasks.get(reference.taskRefKey);
|
|
3266
|
+
// These spell their left values by their own rules in filterReferenceToTf.
|
|
3267
|
+
if (task === undefined ||
|
|
3268
|
+
task.type === "elementum_ai_file_read_task" ||
|
|
3269
|
+
task.type === "elementum_file_reader_task" ||
|
|
3270
|
+
task.type === "elementum_ai_agent_task" ||
|
|
3271
|
+
task.type === TASK_RESOURCES.tableRecordsSearch) {
|
|
3272
|
+
return undefined;
|
|
3273
|
+
}
|
|
3274
|
+
const wireName = taskWireRefName(reference.name, reference.taskRefKey, refs);
|
|
3275
|
+
const envelopeName = taskOutputReferenceName(task.type, wireName, task) ?? wireName;
|
|
3276
|
+
const declared = declaredTaskOutputType(task, wireName, envelopeName);
|
|
3277
|
+
return declared?.fieldType === "BOOLEAN" && declared.multiple !== true ? "BOOLEAN" : undefined;
|
|
3278
|
+
}
|
|
3067
3279
|
function filterToTf(value, refs) {
|
|
3068
3280
|
return serializeFilterToTf(value, {
|
|
3069
3281
|
field: (field) => valueToTf(field, refs),
|
|
3070
3282
|
fieldFromLeftValue: (left) => fieldFromFilterLeftValue(left, refs),
|
|
3071
3283
|
reference: (reference, role, realType, operator) => filterReferenceToTf(reference, refs, role ?? "value", realType, operator),
|
|
3072
|
-
referenceRealType: (reference,
|
|
3284
|
+
referenceRealType: (reference, role, authored) => {
|
|
3285
|
+
if (role === "left") {
|
|
3286
|
+
const booleanOutput = booleanTaskOutputRealType(reference, refs, authored);
|
|
3287
|
+
if (booleanOutput !== undefined)
|
|
3288
|
+
return booleanOutput;
|
|
3289
|
+
}
|
|
3073
3290
|
if (!isObject(reference) || reference.type?.toString().toUpperCase() !== "TRIGGER")
|
|
3074
3291
|
return authored;
|
|
3075
3292
|
const parsed = triggerRecordFieldPath(reference, refs);
|
|
@@ -3113,6 +3330,22 @@ function isRunAutomationValueReference(raw) {
|
|
|
3113
3330
|
isObject(raw.secretReference) ||
|
|
3114
3331
|
isObject(raw.variableReference));
|
|
3115
3332
|
}
|
|
3333
|
+
/**
|
|
3334
|
+
* #1870: the platform compiles a synchronous Dynamic Reference call to a WAIT
|
|
3335
|
+
* task and resumes the caller by matching that task's exact name. Inside a
|
|
3336
|
+
* forEach the loop suffixes the name per iteration, so the completion never
|
|
3337
|
+
* matches: the called automation runs, but the caller never resumes. The task
|
|
3338
|
+
* is still built and applied as authored (an advisory, coverage-gaps.ts).
|
|
3339
|
+
*/
|
|
3340
|
+
function dynamicSyncRunInForEachWarning(refKey, config, enclosingForEach) {
|
|
3341
|
+
if (enclosingForEach === undefined || config.synchronous !== true || !isRunAutomationValueReference(config.targetAutomationRef)) {
|
|
3342
|
+
return undefined;
|
|
3343
|
+
}
|
|
3344
|
+
return `task "${refKey}" is a synchronous Dynamic Reference runAutomation inside forEach "${enclosingForEach}"; ` +
|
|
3345
|
+
"the platform never resumes the caller after the called automation finishes, so the steps after it never run " +
|
|
3346
|
+
"and the run stays parked. Move the call out of the forEach, or call a known automation by its catalog ref " +
|
|
3347
|
+
"(Select Automation)";
|
|
3348
|
+
}
|
|
3116
3349
|
function configAttrs(kind, config, refs) {
|
|
3117
3350
|
const attrs = {};
|
|
3118
3351
|
for (const [key, raw] of Object.entries(config)) {
|
|
@@ -3127,6 +3360,10 @@ function configAttrs(kind, config, refs) {
|
|
|
3127
3360
|
// default so build matches export's omit-when-1 convention.
|
|
3128
3361
|
if (kind === "elementum_schedule_trigger" && key === "interval" && raw === 1)
|
|
3129
3362
|
continue;
|
|
3363
|
+
if (kind === "elementum_temporal_trigger" && key === "aspectFieldId") {
|
|
3364
|
+
attrs.aspect_field_id = valueToTf(raw, refs);
|
|
3365
|
+
continue;
|
|
3366
|
+
}
|
|
3130
3367
|
// A config value of exactly `undefined` almost always means the
|
|
3131
3368
|
// authoring builder was called with a required option omitted (e.g. a
|
|
3132
3369
|
// TS-only-enforced field that no runtime actually type-checks at
|
|
@@ -3212,6 +3449,20 @@ function configAttrs(kind, config, refs) {
|
|
|
3212
3449
|
continue;
|
|
3213
3450
|
}
|
|
3214
3451
|
const resolvedTarget = automationTargetToTf(target, refs.owner, refs.dataBlocks);
|
|
3452
|
+
const recordInputProblem = recordInputMappingProblem(target, raw, resolvedTarget.recordInputNames);
|
|
3453
|
+
if (recordInputProblem !== undefined) {
|
|
3454
|
+
// The recorded unit is the whole automation (#2250): a key in
|
|
3455
|
+
// applied-automation-revisions.json means the platform already runs
|
|
3456
|
+
// this file, so a later edit of the mapping is reported too. Pull
|
|
3457
|
+
// reports and keeps emitting, the same as a record-id field mapping
|
|
3458
|
+
// (#1499), so the first pull can write that key. Build, plan, and
|
|
3459
|
+
// apply still refuse an automation the record does not have. The
|
|
3460
|
+
// report is an advisory (coverage-gaps.ts): the mapping is emitted
|
|
3461
|
+
// as authored, and the failure is at workflow runtime.
|
|
3462
|
+
if (!refs.owner.pulledLive && currentValidationMode() !== "pull")
|
|
3463
|
+
throw new EntityTfError(recordInputProblem);
|
|
3464
|
+
refs.owner.diagnostics.push(`automation ${refs.owner.automationTfLabel}: ${recordInputProblem}`);
|
|
3465
|
+
}
|
|
3215
3466
|
attrs.input_mappings = raw.map((mapping) => {
|
|
3216
3467
|
if (!isObject(mapping) || typeof mapping.name !== "string" || mapping.value === undefined) {
|
|
3217
3468
|
throw new EntityTfError("runAutomation input mapping requires name and value");
|
|
@@ -3247,6 +3498,11 @@ function configAttrs(kind, config, refs) {
|
|
|
3247
3498
|
}
|
|
3248
3499
|
const target = token(raw.value);
|
|
3249
3500
|
if (target?.__kind === "automation") {
|
|
3501
|
+
// The label below is the caller's own; another owner would bind a same-named automation (edk#2118).
|
|
3502
|
+
if (!automationTargetOwner(target, refs.owner).isOwn) {
|
|
3503
|
+
throw new EntityTfError(`runAutomation STATIC targetAutomationRef "${target.parent ?? ""}.${target.refName}" is owned by another ` +
|
|
3504
|
+
"app or element; pass the automation as `automation` (targetAutomationId) so it resolves by its owner");
|
|
3505
|
+
}
|
|
3250
3506
|
attrs["target_automation_ref"] = automationRunTargetResourceAttr(refs.owner.appTfLabel, target.refName, refs.owner.activeAutomationRefNames, refs.owner.parentScope, refs.owner.ownerHandle);
|
|
3251
3507
|
continue;
|
|
3252
3508
|
}
|
|
@@ -3433,13 +3689,13 @@ function configAttrs(kind, config, refs) {
|
|
|
3433
3689
|
if (typeof input.type !== "string" || !ON_DEMAND_TF_PARAM_TYPES.has(input.type)) {
|
|
3434
3690
|
throw new EntityTfError(`onDemand parameter ${JSON.stringify(input.name)} has type ${JSON.stringify(input.type)}, which ` +
|
|
3435
3691
|
`elementum_on_demand_trigger does not support (allowed: text, number, decimal, boolean, date, ` +
|
|
3436
|
-
`datetime, userId, attachmentId, record). Use "text" for a JSON string.`);
|
|
3692
|
+
`datetime, userId, groupId, attachmentId, record). Use "text" for a JSON string.`);
|
|
3437
3693
|
}
|
|
3438
3694
|
const mapped = Object.fromEntries(Object.entries(input)
|
|
3439
3695
|
.filter(([k]) => k !== "app")
|
|
3440
3696
|
.map(([k, v]) => [
|
|
3441
3697
|
CONFIG_ATTRS[k] ?? snake(k),
|
|
3442
|
-
valueToTf(k === "defaultValue" ? unwrapDefault(v) :
|
|
3698
|
+
valueToTf(k === "defaultValue" ? onDemandDefaultToTf(unwrapDefault(v)) :
|
|
3443
3699
|
k === "type" && typeof v === "string" ? ON_DEMAND_TF_PARAM_TYPES.get(v) : v, refs),
|
|
3444
3700
|
]));
|
|
3445
3701
|
if (isOnDemandRecordType(typeof input.type === "string" ? input.type : undefined)) {
|
|
@@ -3724,6 +3980,9 @@ export function automationToTf(entity, ctx) {
|
|
|
3724
3980
|
ownerHandle: ctx.ownerHandle,
|
|
3725
3981
|
appTfLabel: ctx.appTfLabel,
|
|
3726
3982
|
automationTfLabel,
|
|
3983
|
+
pulledLive: ctx.workspaceAspects
|
|
3984
|
+
?.get(workspaceAspectKey(ctx.parentScope ?? "app", ctx.appRefName ?? entity.parent))
|
|
3985
|
+
?.pulledAutomationRefNames?.has(entity.refName) === true,
|
|
3727
3986
|
fieldAddresses: ctx.fieldAddresses ?? new Map(),
|
|
3728
3987
|
fieldNames: ctx.fieldNames ?? new Map(),
|
|
3729
3988
|
fieldMetadata: ctx.fieldMetadata ?? new Map(),
|
|
@@ -3861,6 +4120,7 @@ export function automationToTf(entity, ctx) {
|
|
|
3861
4120
|
...(wireType === "unimplementedTask" ? { isData: true } : {}),
|
|
3862
4121
|
...(outputFieldTypes !== undefined && outputFieldTypes.size > 0 ? { outputFieldTypes } : {}),
|
|
3863
4122
|
...(recordTarget !== undefined ? { recordTarget } : {}),
|
|
4123
|
+
...(wireType === "api" && (taskBody.responseType ?? "JSON") === "JSON" ? { jsonApiResponse: true } : {}),
|
|
3864
4124
|
});
|
|
3865
4125
|
if (wireType === "variable" && Array.isArray(taskBody.create)) {
|
|
3866
4126
|
taskBody.create.forEach((candidate, index) => {
|
|
@@ -3969,7 +4229,13 @@ export function automationToTf(entity, ctx) {
|
|
|
3969
4229
|
kind: "resource",
|
|
3970
4230
|
type: triggerType,
|
|
3971
4231
|
label,
|
|
3972
|
-
attrs: {
|
|
4232
|
+
attrs: {
|
|
4233
|
+
automation: expr.resourceAttr(AUTOMATION_RESOURCE_TYPE, label),
|
|
4234
|
+
...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
|
+
: {}),
|
|
4238
|
+
},
|
|
3973
4239
|
};
|
|
3974
4240
|
const blocks = [automation, trigger];
|
|
3975
4241
|
const dependencies = [expr.resourceAttr(triggerType, label)];
|
|
@@ -3981,7 +4247,9 @@ export function automationToTf(entity, ctx) {
|
|
|
3981
4247
|
// real sibling tasks precede the placeholder within the same case/branch
|
|
3982
4248
|
// (the rolling `taskParent` chain below tracks the PRECEDING SIBLING, not
|
|
3983
4249
|
// the enclosing operator, once more than one task shares a scope).
|
|
3984
|
-
|
|
4250
|
+
// `enclosingForEach` is the refKey of the nearest forEach around this scope
|
|
4251
|
+
// at any depth (a switch or fork inside a loop body keeps it), for #1870.
|
|
4252
|
+
const emitTasks = (tasks, initialParent, enclosingOperator, enclosingForEach) => {
|
|
3985
4253
|
let parent = initialParent;
|
|
3986
4254
|
let first;
|
|
3987
4255
|
for (const task of tasks) {
|
|
@@ -4030,14 +4298,16 @@ export function automationToTf(entity, ctx) {
|
|
|
4030
4298
|
}
|
|
4031
4299
|
const operatorTaskAddress = enclosingOperator?.taskAddress;
|
|
4032
4300
|
const operatorChildAddress = enclosingOperator?.childAddress;
|
|
4033
|
-
|
|
4301
|
+
// parent_is_trigger is always false on a task reference. The step this
|
|
4302
|
+
// placeholder comes after is a local, not this flag: the provider
|
|
4303
|
+
// copies the flag onto the following task (edk#2320).
|
|
4034
4304
|
const extraAttrs = {
|
|
4035
4305
|
id: idValue,
|
|
4036
4306
|
task_type: inner.taskType,
|
|
4037
4307
|
workflow_id: expr.resourceAttr(AUTOMATION_RESOURCE_TYPE, label, ["workflow_id"]),
|
|
4038
4308
|
app_id: expr.resourceAttr(owner.parentScope === "element" ? "elementum_element" : "elementum_app", owner.appTfLabel, ["id"]),
|
|
4039
4309
|
automation_id: expr.resourceAttr(AUTOMATION_RESOURCE_TYPE, label, ["id"]),
|
|
4040
|
-
parent_is_trigger:
|
|
4310
|
+
parent_is_trigger: false,
|
|
4041
4311
|
...(operatorTaskAddress !== undefined && operatorTaskAddress.$expr === "resource-attr"
|
|
4042
4312
|
? { operator_task_id: expr.resourceAttr(operatorTaskAddress.type, operatorTaskAddress.label, ["id"]) }
|
|
4043
4313
|
: {}),
|
|
@@ -4057,6 +4327,10 @@ export function automationToTf(entity, ctx) {
|
|
|
4057
4327
|
});
|
|
4058
4328
|
}
|
|
4059
4329
|
const address = expr.dataAttr("elementum_unmanaged_task_reference", tfLabel);
|
|
4330
|
+
const predecessorLocal = `edk_unmanaged_predecessor_${tfLabel}`;
|
|
4331
|
+
if (ctx.localsAttrs !== undefined && !(predecessorLocal in ctx.localsAttrs)) {
|
|
4332
|
+
ctx.localsAttrs[predecessorLocal] = taskParent;
|
|
4333
|
+
}
|
|
4060
4334
|
first ??= address;
|
|
4061
4335
|
parent = address;
|
|
4062
4336
|
continue;
|
|
@@ -4097,11 +4371,24 @@ export function automationToTf(entity, ctx) {
|
|
|
4097
4371
|
const message = err instanceof Error ? err.message : String(err);
|
|
4098
4372
|
throw new EntityTfError(`automation "${entity.refName}"'s task "${refKey}" (${wireType}): ${message}`);
|
|
4099
4373
|
}
|
|
4100
|
-
const attrs = {
|
|
4374
|
+
const attrs = {
|
|
4375
|
+
parent: taskParent,
|
|
4376
|
+
name: displayName,
|
|
4377
|
+
...taskAttrs,
|
|
4378
|
+
...(OBJECT_FIELD_REFS_TASK_TYPES.has(resourceType)
|
|
4379
|
+
? objectFieldIdsAttr(taskAttrs["object_id"], taskTargetFieldAddresses(inner.aspectId ?? inner.relatedAspectId, owner))
|
|
4380
|
+
: {}),
|
|
4381
|
+
};
|
|
4382
|
+
if (wireType === "executeScript") {
|
|
4383
|
+
for (const finding of scriptLintFindings(displayName, inner.code, inner.inputs, inner.outputSchema)) {
|
|
4384
|
+
owner.diagnostics.push(`automation ${owner.automationTfLabel}: ${finding}`);
|
|
4385
|
+
}
|
|
4386
|
+
}
|
|
4101
4387
|
const block = { kind: "resource", type: resourceType, label: tfLabel, attrs };
|
|
4102
4388
|
if (wireType === "runAutomation") {
|
|
4103
4389
|
const target = token(inner.targetAutomationId) ?? (isObject(inner.targetAutomationRef) ? token(inner.targetAutomationRef.value) : undefined);
|
|
4104
|
-
|
|
4390
|
+
// Own targets only: another owner's publish edge rides its `_for_<caller>` lookup (edk#2118).
|
|
4391
|
+
if (target?.__kind === "automation" && automationTargetOwner(target, owner).isOwn) {
|
|
4105
4392
|
const targetLabel = scopedLabel(owner.appTfLabel, tsLabelToTfLabel(target.refName));
|
|
4106
4393
|
// Only a running (ACTIVE) target is a run dependency. A paused
|
|
4107
4394
|
// target keeps its publish resource, but ei export does not wait
|
|
@@ -4113,6 +4400,9 @@ export function automationToTf(entity, ctx) {
|
|
|
4113
4400
|
}
|
|
4114
4401
|
// Bare-UUID / unresolved targets skip depends_on — configAttrs already
|
|
4115
4402
|
// emitted target_automation_id as a literal and pushed a diagnostic.
|
|
4403
|
+
const warning = dynamicSyncRunInForEachWarning(refKey, inner, enclosingForEach);
|
|
4404
|
+
if (warning !== undefined)
|
|
4405
|
+
owner.diagnostics.push(`automation ${owner.automationTfLabel}: ${warning}`);
|
|
4116
4406
|
}
|
|
4117
4407
|
blocks.push(block);
|
|
4118
4408
|
const address = expr.resourceAttr(resourceType, tfLabel);
|
|
@@ -4129,7 +4419,7 @@ export function automationToTf(entity, ctx) {
|
|
|
4129
4419
|
const children = task.children ?? [];
|
|
4130
4420
|
if (children.length !== 1)
|
|
4131
4421
|
throw new EntityTfError(`forEach task "${refKey}" must have exactly one child body`);
|
|
4132
|
-
emitTasks(children[0].tasks ?? [], expr.resourceAttr(resourceType, tfLabel, ["inner"]), { taskAddress: expr.resourceAttr(resourceType, tfLabel) });
|
|
4422
|
+
emitTasks(children[0].tasks ?? [], expr.resourceAttr(resourceType, tfLabel, ["inner"]), { taskAddress: expr.resourceAttr(resourceType, tfLabel) }, refKey);
|
|
4133
4423
|
// The loop body is a separate operator-owned chain. A fluent sibling
|
|
4134
4424
|
// authored after `forEach` continues from the for_each task itself,
|
|
4135
4425
|
// not from the body's terminal task; the latter silently moves that
|
|
@@ -4230,7 +4520,7 @@ export function automationToTf(entity, ctx) {
|
|
|
4230
4520
|
blocks.push({ kind: "resource", type: branchType, label: branchLabel, attrs: branchAttrs });
|
|
4231
4521
|
const branchAddress = expr.resourceAttr(branchType, branchLabel);
|
|
4232
4522
|
dependencies.push(branchAddress);
|
|
4233
|
-
emitTasks(child.tasks ?? [], branchAddress, { taskAddress: address, childAddress: branchAddress });
|
|
4523
|
+
emitTasks(child.tasks ?? [], branchAddress, { taskAddress: address, childAddress: branchAddress }, enclosingForEach);
|
|
4234
4524
|
previous = branchAddress;
|
|
4235
4525
|
}
|
|
4236
4526
|
}
|