@elementumai/edk 0.9.14 → 0.9.16
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/dist-sdk/pull/util.d.ts +0 -15
- package/dist-sdk/pull/util.js +44 -5
- package/dist-sdk/src/catalog/factories.d.ts +4 -2
- package/dist-sdk/src/catalog/factories.js +4 -0
- package/dist-sdk/src/catalog/from-authoring.js +5 -1
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +1 -1
- package/dist-sdk/src/catalog/token.js +2 -2
- package/dist-sdk/src/catalog/types.d.ts +7 -2
- package/dist-sdk/src/core/types/app.d.ts +4 -4
- package/dist-sdk/src/engine/build/context.d.ts +5 -4
- package/dist-sdk/src/engine/build/source-context.d.ts +2 -0
- package/dist-sdk/src/engine/build/source-context.js +16 -0
- package/dist-sdk/src/engine/progress.d.ts +19 -1
- package/dist-sdk/src/engine/progress.js +33 -5
- package/dist-sdk/src/engine/pull/context.d.ts +9 -1
- package/dist-sdk/src/engine/pull/ref-only.d.ts +6 -2
- package/dist-sdk/src/engine/pull/ref-only.js +14 -3
- package/dist-sdk/src/engine/workspace/loader.js +23 -2
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +1 -1
- package/dist-sdk/src/entities/access-policy/from-tf.js +47 -12
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +5 -3
- package/dist-sdk/src/entities/access-policy/to-tf.js +23 -1
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +6 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +50 -4
- package/dist-sdk/src/entities/agent/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/agent/from-tf.js +18 -3
- package/dist-sdk/src/entities/agent/module.js +1 -0
- package/dist-sdk/src/entities/agent/to-tf.js +15 -0
- package/dist-sdk/src/entities/agent/tools.d.ts +98 -5
- package/dist-sdk/src/entities/agent/tools.js +12 -3
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +15 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.js +47 -4
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +9 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.js +82 -25
- package/dist-sdk/src/entities/app/build.d.ts +2 -2
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +4 -4
- package/dist-sdk/src/entities/app/module.js +8 -0
- package/dist-sdk/src/entities/app/to-tf.js +1 -0
- package/dist-sdk/src/entities/approval-chain/build.d.ts +8 -1
- package/dist-sdk/src/entities/approval-chain/build.js +3 -0
- package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +2 -1
- package/dist-sdk/src/entities/approval-chain/from-tf.js +20 -7
- package/dist-sdk/src/entities/approval-chain/printer.js +13 -2
- package/dist-sdk/src/entities/approval-chain/to-tf.js +3 -0
- package/dist-sdk/src/entities/automation/build.d.ts +19 -12
- package/dist-sdk/src/entities/automation/build.js +36 -13
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +4 -0
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +19 -0
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +222 -65
- package/dist-sdk/src/entities/automation/from-tf.d.ts +86 -6
- package/dist-sdk/src/entities/automation/from-tf.js +360 -63
- package/dist-sdk/src/entities/automation/index.d.ts +3 -2
- package/dist-sdk/src/entities/automation/index.js +3 -2
- package/dist-sdk/src/entities/automation/module.js +21 -16
- package/dist-sdk/src/entities/automation/output-field-types.d.ts +5 -0
- package/dist-sdk/src/entities/automation/output-field-types.js +12 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +20 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +22 -0
- package/dist-sdk/src/entities/automation/script-code.d.ts +32 -0
- package/dist-sdk/src/entities/automation/script-code.js +72 -5
- package/dist-sdk/src/entities/automation/tasks.d.ts +60 -24
- package/dist-sdk/src/entities/automation/tasks.js +33 -14
- package/dist-sdk/src/entities/automation/to-tf.d.ts +0 -2
- package/dist-sdk/src/entities/automation/to-tf.js +123 -46
- package/dist-sdk/src/entities/automation/triggers.d.ts +5 -2
- package/dist-sdk/src/entities/automation/types.d.ts +2 -0
- package/dist-sdk/src/entities/automation/types.js +5 -0
- package/dist-sdk/src/entities/automation/workflow-output.d.ts +35 -0
- package/dist-sdk/src/entities/automation/workflow-output.js +53 -0
- package/dist-sdk/src/entities/chart/build.d.ts +3 -3
- package/dist-sdk/src/entities/chart/from-tf.d.ts +2 -2
- package/dist-sdk/src/entities/chart/from-tf.js +20 -13
- package/dist-sdk/src/entities/chart/to-tf.js +7 -5
- package/dist-sdk/src/entities/dashboard/from-tf.js +1 -1
- package/dist-sdk/src/entities/dashboard/to-tf.js +1 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +3 -2
- package/dist-sdk/src/entities/element/build.d.ts +11 -8
- package/dist-sdk/src/entities/element/build.js +14 -5
- package/dist-sdk/src/entities/element/locals.d.ts +2 -2
- package/dist-sdk/src/entities/element/locals.js +6 -2
- package/dist-sdk/src/entities/element/system-fields.d.ts +4 -0
- package/dist-sdk/src/entities/element/system-fields.js +12 -0
- package/dist-sdk/src/entities/element/to-tf.js +1 -0
- package/dist-sdk/src/entities/field/build.d.ts +2 -2
- package/dist-sdk/src/entities/field/from-tf.js +82 -4
- package/dist-sdk/src/entities/field/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/field/to-tf.js +11 -4
- package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -2
- package/dist-sdk/src/entities/relationship/from-tf.js +8 -5
- package/dist-sdk/src/entities/relationship/to-tf.js +13 -3
- package/dist-sdk/src/entities/search-table/from-tf.js +6 -6
- package/dist-sdk/src/entities/search-table/module.js +2 -2
- package/dist-sdk/src/entities/search-table/types.d.ts +1 -0
- package/dist-sdk/src/entities/search-table/types.js +1 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +3 -3
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +10 -6
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +4 -2
- package/dist-sdk/src/entities/shared/filters/index.d.ts +12 -2
- package/dist-sdk/src/entities/shared/filters/index.js +17 -1
- package/dist-sdk/src/entities/shared/filters/print.js +25 -11
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +1 -1
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +39 -7
- package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +1 -1
- package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -2
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +6 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +47 -18
- package/dist-sdk/src/entities/skill/module.js +10 -0
- package/dist-sdk/src/entities/skill/to-tf.js +19 -0
- package/dist-sdk/src/entities/skill/tools.d.ts +29 -7
- package/dist-sdk/src/entities/skill/tools.js +6 -2
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +18 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +77 -4
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +8 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.js +90 -46
- package/dist-sdk/src/entities/task/module.js +1 -1
- package/dist-sdk/src/entities/view/from-tf.js +30 -9
- package/dist-sdk/src/entities/view/to-tf.js +18 -10
- package/dist-sdk/src/entities/widget/from-tf.js +3 -3
- package/dist-sdk/src/entities/widget/to-tf.js +1 -0
- package/dist-sdk/src/graph/index.d.ts +15 -0
- package/dist-sdk/src/graph/index.js +19 -0
- package/dist-sdk/src/graph/types.d.ts +37 -1
- package/package.json +2 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { serializeValueOrRef } from "../../core/wire/ref-serializer.js";
|
|
2
2
|
import { isExpr } from "../field/calc/runtime.js";
|
|
3
3
|
import { renderCalculationExpression, } from "./calculation-expression.js";
|
|
4
|
-
import { extractScriptBody } from "./script-code.js";
|
|
4
|
+
import { extractScriptBody, isScriptFile, readScriptFile } from "./script-code.js";
|
|
5
5
|
function workflowFields(fields) {
|
|
6
6
|
return fields.map((f) => {
|
|
7
7
|
const updateMode = "updateMode" in f ? f.updateMode : undefined;
|
|
@@ -209,7 +209,12 @@ function outputSchemaNode(name, type) {
|
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
if (type.type === "array") {
|
|
212
|
-
return {
|
|
212
|
+
return {
|
|
213
|
+
array: {
|
|
214
|
+
...(name === undefined ? {} : { name }),
|
|
215
|
+
item: outputSchemaNode(type.itemName, type.items),
|
|
216
|
+
},
|
|
217
|
+
};
|
|
213
218
|
}
|
|
214
219
|
const properties = type.properties === undefined
|
|
215
220
|
? undefined
|
|
@@ -227,6 +232,19 @@ function outputSchema(outputs) {
|
|
|
227
232
|
const properties = Object.entries(declared).map(([name, type]) => outputSchemaNode(name, type));
|
|
228
233
|
return { object: { ...(rootName !== undefined ? { name: rootName } : {}), properties } };
|
|
229
234
|
}
|
|
235
|
+
const EXECUTE_SCRIPT_LIST_INPUT_MARKER = "__edkExecuteScriptListInput";
|
|
236
|
+
/**
|
|
237
|
+
* Wrap a list-valued executeScript input (e.g. a prior task's `.records`)
|
|
238
|
+
* with the field mappings the script can read off each item - which fields,
|
|
239
|
+
* and under what alias. Only meaningful for a list-shaped input; a scalar
|
|
240
|
+
* input has no per-item fields to map.
|
|
241
|
+
*/
|
|
242
|
+
export function withFieldMappings(value, fields) {
|
|
243
|
+
return { [EXECUTE_SCRIPT_LIST_INPUT_MARKER]: true, value, fields };
|
|
244
|
+
}
|
|
245
|
+
function isExecuteScriptListInputToken(value) {
|
|
246
|
+
return typeof value === "object" && value !== null && value[EXECUTE_SCRIPT_LIST_INPUT_MARKER] === true;
|
|
247
|
+
}
|
|
230
248
|
/**
|
|
231
249
|
* Build the executeScript `ActionDef` from an ALREADY-RESOLVED body string.
|
|
232
250
|
* Shared by the public `executeScript()` factory below (which resolves the
|
|
@@ -237,10 +255,16 @@ function outputSchema(outputs) {
|
|
|
237
255
|
* so the body is computed exactly once, not re-derived by each layer.
|
|
238
256
|
*/
|
|
239
257
|
export function executeScriptActionDefWithBody(body, opts) {
|
|
240
|
-
const inputs = Object.entries(opts.inputs ?? {}).map(([name,
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
258
|
+
const inputs = Object.entries(opts.inputs ?? {}).map(([name, entry]) => {
|
|
259
|
+
if (isExecuteScriptListInputToken(entry)) {
|
|
260
|
+
return {
|
|
261
|
+
name,
|
|
262
|
+
value: serializeValueOrRef(entry.value),
|
|
263
|
+
field_mappings: entry.fields.map((f) => ({ alias: f.alias, field_id: f.field })),
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
return { name, value: serializeValueOrRef(entry) };
|
|
267
|
+
});
|
|
244
268
|
return {
|
|
245
269
|
key: "executeScript",
|
|
246
270
|
config: {
|
|
@@ -251,7 +275,7 @@ export function executeScriptActionDefWithBody(body, opts) {
|
|
|
251
275
|
};
|
|
252
276
|
}
|
|
253
277
|
export function executeScript(opts) {
|
|
254
|
-
return executeScriptActionDefWithBody(extractScriptBody(opts.code), opts);
|
|
278
|
+
return executeScriptActionDefWithBody(isScriptFile(opts.code) ? readScriptFile(opts.code) : extractScriptBody(opts.code), opts);
|
|
255
279
|
}
|
|
256
280
|
function apiRequestHeaders(headers) {
|
|
257
281
|
return (headers ?? []).map((h) => ({ name: h.name, value: serializeValueOrRef(h.value) }));
|
|
@@ -458,9 +482,6 @@ export function notification(opts) {
|
|
|
458
482
|
},
|
|
459
483
|
};
|
|
460
484
|
}
|
|
461
|
-
export function filterAction(opts) {
|
|
462
|
-
return { key: "filter", config: { filter: opts.condition } };
|
|
463
|
-
}
|
|
464
485
|
export function assignUser(opts) {
|
|
465
486
|
return { key: "assignUser", config: { fieldId: opts.field, userId: opts.userId } };
|
|
466
487
|
}
|
|
@@ -620,7 +641,6 @@ function normalizeCalculationOptions(opts) {
|
|
|
620
641
|
return Object.entries(opts.values).map(([name, value]) => {
|
|
621
642
|
const advanced = typeof value === "object" && value !== null && "expression" in value;
|
|
622
643
|
return {
|
|
623
|
-
...(advanced && value.id !== undefined ? { id: value.id } : {}),
|
|
624
644
|
name,
|
|
625
645
|
expression: advanced ? value.expression : value,
|
|
626
646
|
...(advanced && value.record !== undefined
|
|
@@ -656,8 +676,8 @@ export function calculation(opts) {
|
|
|
656
676
|
// `outputType`/`multiple`/`referencedFields`) this used to mirror. Sending
|
|
657
677
|
// the GET shape back on create/update 500s server-side with no
|
|
658
678
|
// field-level error, because it isn't what the write mutation's input type
|
|
659
|
-
// actually accepts.
|
|
660
|
-
//
|
|
679
|
+
// actually accepts. Calculation entry IDs are server-assigned state and
|
|
680
|
+
// are intentionally absent from the public authoring API.
|
|
661
681
|
const calculations = [];
|
|
662
682
|
for (const c of entries) {
|
|
663
683
|
const rawCalculationReference = isExpr(c.expression)
|
|
@@ -708,7 +728,6 @@ export function calculation(opts) {
|
|
|
708
728
|
},
|
|
709
729
|
};
|
|
710
730
|
calculations.push({
|
|
711
|
-
...(c.id !== undefined ? { id: c.id } : {}),
|
|
712
731
|
name: c.name,
|
|
713
732
|
recordId: c.record !== undefined ? serializeValueOrRef(c.record) : null,
|
|
714
733
|
calculationReference: wireCalculationReference,
|
|
@@ -33,8 +33,6 @@ export interface AutomationToTfContext {
|
|
|
33
33
|
readonly serviceAccounts?: Readonly<Record<string, AppServiceAccount>>;
|
|
34
34
|
/** App-local automations whose publish resource will be emitted in this build. */
|
|
35
35
|
readonly activeAutomationRefNames?: ReadonlySet<string>;
|
|
36
|
-
/** Display names for app-local authored automations, keyed by source refName. */
|
|
37
|
-
readonly automationNamesByRefName?: ReadonlyMap<string, string>;
|
|
38
36
|
/**
|
|
39
37
|
* Every app/element stream root discovered in this same build, keyed by
|
|
40
38
|
* `workspaceAspectKey` — lets a cross-aspect token (an app/element ref, or
|
|
@@ -10,7 +10,7 @@ import { resolveForeignRef } from "../shared/foreign-ref.js";
|
|
|
10
10
|
import { filterToTf as serializeFilterToTf } from "../shared/filters/tf-codec.js";
|
|
11
11
|
import { referenceValueTypeForField } from "../shared/filters/index.js";
|
|
12
12
|
import { API_TASK_REF_AUTHORING_NAMES, API_TASK_REF_WIRE_NAMES } from "./output-key-wire-name.js";
|
|
13
|
-
import { outputFieldTypesFromScriptSchema } from "./output-field-types.js";
|
|
13
|
+
import { outputFieldTypesFromScriptSchema, scriptOutputReferenceIsDeclared } from "./output-field-types.js";
|
|
14
14
|
import { CONNECTOR_ORG_BAG } from "../org/connector.js";
|
|
15
15
|
import { FILE_READER_SUB_TYPE_BY_RESOURCE, FILE_READER_SUB_TYPE_BY_TYPE_KEY } from "../file-reader/types.js";
|
|
16
16
|
import { UNRESOLVED_FIELD_MARKER } from "../shared/ref.js";
|
|
@@ -299,9 +299,9 @@ function resolveTableColumnFieldExpr(opts) {
|
|
|
299
299
|
* its own foreign-field label: an app and an element can share a refName,
|
|
300
300
|
* and `elementum_field` is one shared data-source type for both.
|
|
301
301
|
*/
|
|
302
|
-
/** App/element root lookup attrs when orgRefs is unavailable (mirrors graph rootNamespace strategy). */
|
|
302
|
+
/** App/element/task root lookup attrs when orgRefs is unavailable (mirrors graph rootNamespace strategy). */
|
|
303
303
|
function foreignRootLookup(kind, identity) {
|
|
304
|
-
const resourceType = kind === "element" ? "elementum_element" : "elementum_app";
|
|
304
|
+
const resourceType = kind === "task" ? "elementum_task" : kind === "element" ? "elementum_element" : "elementum_app";
|
|
305
305
|
if (identity.namespace !== undefined && identity.namespace !== "") {
|
|
306
306
|
return {
|
|
307
307
|
resourceType,
|
|
@@ -318,7 +318,7 @@ function foreignRootLookup(kind, identity) {
|
|
|
318
318
|
};
|
|
319
319
|
}
|
|
320
320
|
/**
|
|
321
|
-
* Validates and derives the shared naming for a cross-app/element field
|
|
321
|
+
* Validates and derives the shared naming for a cross-app/element/task field
|
|
322
322
|
* token — the `data.elementum_field` label {@link crossAppFieldToTf} emits,
|
|
323
323
|
* and the matching `<fieldLabel>_options_by_label` local a foreign PICKLIST
|
|
324
324
|
* field's option-label lookup (in {@link picklistFilterValueToTf}) resolves
|
|
@@ -343,7 +343,7 @@ function foreignFieldNaming(value) {
|
|
|
343
343
|
throw new EntityTfError(`field ref "${value.refName}" has a parent ("${parent}") but no parentName — incomplete foreign-field provenance; the owner lookup would key on the refName instead of its real display name and silently miss at apply`);
|
|
344
344
|
}
|
|
345
345
|
const fieldName = value.name ?? value.refName;
|
|
346
|
-
const ownerKind = value.parentKind === "element" ? "element" : "app";
|
|
346
|
+
const ownerKind = value.parentKind === "task" ? "task" : value.parentKind === "element" ? "element" : "app";
|
|
347
347
|
const resolved = foreignRootLookup(ownerKind, {
|
|
348
348
|
name: value.parentName,
|
|
349
349
|
namespace: value.parentNamespace,
|
|
@@ -385,7 +385,7 @@ function crossAppFieldToTf(value, ctx, dataBlocks) {
|
|
|
385
385
|
// filtered out rather than cast away — the map holds tables too, because a
|
|
386
386
|
// table-owned search table has to be distinguishable from an element-owned
|
|
387
387
|
// one.
|
|
388
|
-
if (sibling !== undefined && sibling.kind !== "table") {
|
|
388
|
+
if (sibling !== undefined && sibling.kind !== "table" && sibling.kind !== "task") {
|
|
389
389
|
const fieldValue = fieldRefToTfValue(value.fieldType ?? "", value.refName, sibling.tfLabel, sibling.kind);
|
|
390
390
|
if (fieldValue === undefined) {
|
|
391
391
|
throw new EntityTfError(`field ref "${value.refName}" on sibling ${sibling.kind} "${value.parent}" has no terraform field resource mapping (fieldType ${JSON.stringify(value.fieldType ?? "")})`);
|
|
@@ -394,7 +394,7 @@ function crossAppFieldToTf(value, ctx, dataBlocks) {
|
|
|
394
394
|
}
|
|
395
395
|
}
|
|
396
396
|
const { fieldName, fieldLabel } = foreignFieldNaming(value);
|
|
397
|
-
const ownerKind = value.parentKind === "element" ? "element" : "app";
|
|
397
|
+
const ownerKind = value.parentKind === "task" ? "task" : value.parentKind === "element" ? "element" : "app";
|
|
398
398
|
if (ctx.orgRefs !== undefined) {
|
|
399
399
|
const owner = resolveForeignRef(ownerKind, { name: value.parentName, namespace: value.parentNamespace }, ctx.orgRefs, ctx.diagnostics, `automation field "${value.refName}" owner`);
|
|
400
400
|
ctx.orgRefs.foreignField("elementum_field", fieldLabel, owner.value, fieldName);
|
|
@@ -443,9 +443,9 @@ function automationTargetToTf(value, ctx, dataBlocks) {
|
|
|
443
443
|
if (managedOwnerLabel !== undefined) {
|
|
444
444
|
const managedLabel = scopedLabel(managedOwnerLabel, tsLabelToTfLabel(value.refName));
|
|
445
445
|
const targetOwner = ctx.workspaceAspects?.get(workspaceAspectKey(ownerKind, isOwn ? ctx.appRefName : value.parent ?? ""));
|
|
446
|
-
const
|
|
447
|
-
const isActive =
|
|
448
|
-
?
|
|
446
|
+
const targetActiveRefs = targetOwner?.activeAutomationRefNames;
|
|
447
|
+
const isActive = targetActiveRefs !== undefined
|
|
448
|
+
? targetActiveRefs.has(value.refName)
|
|
449
449
|
: isOwn && ctx.activeAutomationRefNames?.has(value.refName) === true;
|
|
450
450
|
// The on-demand trigger resource exposes the parameter ids from the
|
|
451
451
|
// mutable draft workflow. Once an ACTIVE target is published, however,
|
|
@@ -454,12 +454,6 @@ function automationTargetToTf(value, ctx, dataBlocks) {
|
|
|
454
454
|
// ids describe that same current revision. Draft/inactive targets retain
|
|
455
455
|
// the direct resource references below because they have no publish edge.
|
|
456
456
|
if (isActive) {
|
|
457
|
-
const lookupName = targetActiveNames?.get(value.refName) ??
|
|
458
|
-
(isOwn ? ctx.automationNamesByRefName?.get(value.refName) : undefined) ??
|
|
459
|
-
value.name;
|
|
460
|
-
if (lookupName === undefined || lookupName === "") {
|
|
461
|
-
throw new EntityTfError(`managed ACTIVE automation ref "${value.refName}" has no lookup name`);
|
|
462
|
-
}
|
|
463
457
|
// Data block addresses are module-global even though EDK emits one
|
|
464
458
|
// file per automation. Scope the lookup to this caller so two callers
|
|
465
459
|
// of the same target cannot declare a duplicate data address.
|
|
@@ -470,7 +464,7 @@ function automationTargetToTf(value, ctx, dataBlocks) {
|
|
|
470
464
|
label: currentBindingLabel,
|
|
471
465
|
attrs: {
|
|
472
466
|
app_id: expr.resourceAttr(ownerKind === "element" ? "elementum_element" : "elementum_app", managedOwnerLabel, ["id"]),
|
|
473
|
-
|
|
467
|
+
id: expr.resourceAttr(AUTOMATION_RESOURCE_TYPE, managedLabel, ["id"]),
|
|
474
468
|
depends_on: [expr.resourceAttr(WORKFLOW_PUBLISH_RESOURCE_TYPE, managedLabel)],
|
|
475
469
|
},
|
|
476
470
|
});
|
|
@@ -556,6 +550,28 @@ function tokenToTf(value, ctx, dataBlocks) {
|
|
|
556
550
|
}
|
|
557
551
|
case "userField":
|
|
558
552
|
return value.refName;
|
|
553
|
+
case "task": {
|
|
554
|
+
const sibling = ctx.workspaceAspects?.get(workspaceAspectKey("task", value.refName));
|
|
555
|
+
if (sibling !== undefined) {
|
|
556
|
+
return expr.resourceAttr("elementum_task", sibling.tfLabel, ["id"]);
|
|
557
|
+
}
|
|
558
|
+
const name = value.name ?? value.refName;
|
|
559
|
+
if (!name)
|
|
560
|
+
throw new EntityTfError(`task ref "${value.refName}" has no lookup name`);
|
|
561
|
+
if (ctx.orgRefs !== undefined) {
|
|
562
|
+
const tfLabel = sanitizeName(value.namespace ?? name);
|
|
563
|
+
ctx.orgRefs.rawLookup("elementum_task", tfLabel, name);
|
|
564
|
+
return expr.dataAttr("elementum_task", tfLabel, ["id"]);
|
|
565
|
+
}
|
|
566
|
+
const resolved = foreignRootLookup("task", { name, namespace: value.namespace });
|
|
567
|
+
dataBlocks.set(`${resolved.resourceType}.${resolved.tfLabel}`, {
|
|
568
|
+
kind: "data",
|
|
569
|
+
type: resolved.resourceType,
|
|
570
|
+
label: resolved.tfLabel,
|
|
571
|
+
attrs: { [resolved.lookupAttr]: resolved.lookupValue },
|
|
572
|
+
});
|
|
573
|
+
return expr.dataAttr(resolved.resourceType, resolved.tfLabel, ["id"]);
|
|
574
|
+
}
|
|
559
575
|
case "app":
|
|
560
576
|
case "element":
|
|
561
577
|
if (value.refName !== ctx.appRefName || value.__kind !== ctx.parentScope) {
|
|
@@ -586,7 +602,7 @@ function tokenToTf(value, ctx, dataBlocks) {
|
|
|
586
602
|
// kind+refName, not refName alone), so a same-named element field
|
|
587
603
|
// must still resolve as foreign — the automation's own app is
|
|
588
604
|
// always an app (automations are app-owned only, for now).
|
|
589
|
-
if (value.parent !== undefined && (value.parent !== ctx.appRefName || value.parentKind === "element")) {
|
|
605
|
+
if (value.parent !== undefined && (value.parent !== ctx.appRefName || value.parentKind === "element" || value.parentKind === "task")) {
|
|
590
606
|
return crossAppFieldToTf(value, ctx, dataBlocks);
|
|
591
607
|
}
|
|
592
608
|
const address = ctx.fieldAddresses.get(value.refName);
|
|
@@ -949,7 +965,18 @@ function calculationFormulaRefToParts(value, refs) {
|
|
|
949
965
|
return calculationTaskMustache(value.taskReference.taskRefKey, value.taskReference.name, refs);
|
|
950
966
|
}
|
|
951
967
|
if (isObject(value.variableReference) && typeof value.variableReference.id === "string") {
|
|
952
|
-
|
|
968
|
+
// `value.variableReference.id` is the client-side id `stampAndCollectVariableIds`
|
|
969
|
+
// just minted for this build's own `elementum_variable_task` create entry, not the
|
|
970
|
+
// variable's real (deploy-time-assigned) platform id - baking it in as a literal
|
|
971
|
+
// here always mismatches live state on the very next plan. Interpolate the live
|
|
972
|
+
// resource's `variable_id` instead, the same fix already applied to workflow_publish
|
|
973
|
+
// outputs and task input values referencing the same variable.
|
|
974
|
+
const target = refs.variableById.get(value.variableReference.id);
|
|
975
|
+
if (target === undefined) {
|
|
976
|
+
refs.owner.diagnostics.push(`automation unresolved variable ref ${JSON.stringify(value.variableReference.id)} preserved as a literal calculation reference`);
|
|
977
|
+
return [`variable.${value.variableReference.id}`];
|
|
978
|
+
}
|
|
979
|
+
return ["variable.", expr.resourceAttr(target.type, target.label, ["variable_id"])];
|
|
953
980
|
}
|
|
954
981
|
if (isObject(value.templateReference))
|
|
955
982
|
return calculationTemplateToParts(value.templateReference, refs);
|
|
@@ -1102,8 +1129,8 @@ const TS_TRIGGER_REF_TO_WIRE = {
|
|
|
1102
1129
|
// ("record.createdBy.email") never reaches this flat lookup table (see
|
|
1103
1130
|
// from-tf.ts's matching comment) — this table is for genuine trigger-level
|
|
1104
1131
|
// pseudo-fields only, keyed by the DIRECT ts accessor name, not a dotted
|
|
1105
|
-
// record path.
|
|
1106
|
-
//
|
|
1132
|
+
// record path. Record-path refs are handled below from app fields and
|
|
1133
|
+
// suffix mappings.
|
|
1107
1134
|
slackThreadId: "Slack Thread ID",
|
|
1108
1135
|
slackChannelId: "Slack Channel ID",
|
|
1109
1136
|
messageAuthorEmail: "Message Author Email",
|
|
@@ -1140,13 +1167,6 @@ const FIELD_REF_SUFFIX_TO_WIRE = {
|
|
|
1140
1167
|
"employee.manager.email": " Manager Email",
|
|
1141
1168
|
"employee.manager.name": " Manager Name",
|
|
1142
1169
|
};
|
|
1143
|
-
// Confirmed live on demoapptwo: the "...Email"/"...Manager Email" audit refs
|
|
1144
|
-
// lowercase "by", unlike every other audit-field ref suffix. Only these two
|
|
1145
|
-
// keys/suffixes are overridden; closedBy is not confirmed and is left alone.
|
|
1146
|
-
const AUDIT_FIELD_EMAIL_WIRE_NAME = {
|
|
1147
|
-
createdBy: "Created by",
|
|
1148
|
-
updatedBy: "Updated by",
|
|
1149
|
-
};
|
|
1150
1170
|
const PROVIDER_FIXED_SYSTEM_FIELD_KEYS = new Set([
|
|
1151
1171
|
"stage",
|
|
1152
1172
|
"createdAt",
|
|
@@ -1202,18 +1222,13 @@ function wireRefName(name, ctx) {
|
|
|
1202
1222
|
if (wireSuffix === undefined) {
|
|
1203
1223
|
throw new EntityTfError(`automation reference "${name}" has unsupported record-field path "${suffix}"`);
|
|
1204
1224
|
}
|
|
1205
|
-
//
|
|
1206
|
-
//
|
|
1207
|
-
//
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
// other system field) keeps the field's own display casing.
|
|
1213
|
-
const auditEmailName = systemFieldKey !== undefined && (wireSuffix === " Email" || wireSuffix === " Manager Email")
|
|
1214
|
-
? AUDIT_FIELD_EMAIL_WIRE_NAME[systemFieldKey]
|
|
1215
|
-
: undefined;
|
|
1216
|
-
return `${auditEmailName ?? fieldName}${wireSuffix}`;
|
|
1225
|
+
// Email audit refs have historically varied in the capitalization of
|
|
1226
|
+
// "by" between organizations. The provider exposes both spellings as
|
|
1227
|
+
// aliases, so author the established lowercase wire name consistently.
|
|
1228
|
+
const refName = `${fieldName}${wireSuffix}`;
|
|
1229
|
+
return /^(Created|Updated) By (?:Manager )?Email$/.test(refName)
|
|
1230
|
+
? refName.replace(/ By(?= (?:Manager )?Email$)/, " by")
|
|
1231
|
+
: refName;
|
|
1217
1232
|
}
|
|
1218
1233
|
// A webhook trigger's body/headers refs (ctx.trigger.body["X"]) can only
|
|
1219
1234
|
// type-check against DeepRefs<WebhookTriggerOutput>, so parts[0] being
|
|
@@ -1254,6 +1269,9 @@ const RECORD_COLLECTION_TASK_WIRE_TYPES = new Set([
|
|
|
1254
1269
|
const TS_FOR_EACH_GENERIC_SEGMENT_TO_WIRE = {
|
|
1255
1270
|
iteration: "Iteration",
|
|
1256
1271
|
};
|
|
1272
|
+
function forEachCompactFilterName(name) {
|
|
1273
|
+
return name === "recordId" ? "item" : name;
|
|
1274
|
+
}
|
|
1257
1275
|
function forEachWireRefName(name, ctx, isRecordCollection) {
|
|
1258
1276
|
// A recordSearch collection's whole item and branded record identity both
|
|
1259
1277
|
// point at the loop's ASPECT_RECORD_ID reference. Live provider state
|
|
@@ -1665,6 +1683,18 @@ function valueToTf(value, refs) {
|
|
|
1665
1683
|
return value.map((item) => valueToTf(item, refs));
|
|
1666
1684
|
if (!isObject(value))
|
|
1667
1685
|
throw new EntityTfError(`unsupported automation value ${String(value)}`);
|
|
1686
|
+
if (typeof value.__edkUnresolvedForEachItem === "string") {
|
|
1687
|
+
// Printed by print-automation.ts for a forEachItemRef pointing at a
|
|
1688
|
+
// sibling or non-nearest-ancestor loop - EDK has no authoring primitive
|
|
1689
|
+
// for "another loop's current item". Fail the build loudly instead of
|
|
1690
|
+
// silently reinterpreting this as a task-output reference: `ctx.actions`
|
|
1691
|
+
// would have turned ANY property-access shape into a real, but WRONG,
|
|
1692
|
+
// task ref (review feedback on PR #1097, cursor[bot]).
|
|
1693
|
+
const path = Array.isArray(value.path) ? value.path.join(".") : "";
|
|
1694
|
+
throw new EntityTfError(`unresolved forEach item reference to "${value.__edkUnresolvedForEachItem}"${path ? `.${path}` : ""}: ` +
|
|
1695
|
+
`EDK cannot express a reference to another loop's current item - re-express this by hand ` +
|
|
1696
|
+
`(e.g. restructure the loops, or pass the value through a variable) before this automation can build`);
|
|
1697
|
+
}
|
|
1668
1698
|
if (value.__unsafe === "platformId" && typeof value.value === "string") {
|
|
1669
1699
|
refs.owner.diagnostics.push(`automation raw UUID fallback ${JSON.stringify(value.value)} is source-org-only and non-portable`);
|
|
1670
1700
|
return value.value;
|
|
@@ -1871,6 +1901,24 @@ function filterReferenceToTf(value, refs, role = "value", realType, operator) {
|
|
|
1871
1901
|
},
|
|
1872
1902
|
});
|
|
1873
1903
|
}
|
|
1904
|
+
const isUndeclaredScriptOutput = task.type === TASK_RESOURCES.executeScript &&
|
|
1905
|
+
wireName.startsWith("result.") &&
|
|
1906
|
+
!scriptOutputReferenceIsDeclared(task.outputFieldTypes, wireName);
|
|
1907
|
+
if (isUndeclaredScriptOutput) {
|
|
1908
|
+
// A pulled live workflow can retain this dangling envelope even
|
|
1909
|
+
// though the provider cannot expose it through `refs`. Pull rejects
|
|
1910
|
+
// multiple/DECIMAL variants, so the scalar envelope is lossless.
|
|
1911
|
+
refs.owner.diagnostics.push(`automation switch preserves reference to ${JSON.stringify(wireName)} on execute-script task ` +
|
|
1912
|
+
`${JSON.stringify(value.taskRefKey)} even though that task does not declare the output`);
|
|
1913
|
+
return expr.jsonencode({
|
|
1914
|
+
fieldType: (realType ?? "TEXT").toUpperCase(),
|
|
1915
|
+
multiple: false,
|
|
1916
|
+
taskReference: {
|
|
1917
|
+
name: wireName,
|
|
1918
|
+
taskId: expr.resourceAttr(task.type, task.label, ["id"]),
|
|
1919
|
+
},
|
|
1920
|
+
});
|
|
1921
|
+
}
|
|
1874
1922
|
return expr.resourceAttr(task.type, task.label, ["refs", { index: wireName }]);
|
|
1875
1923
|
}
|
|
1876
1924
|
return expr.template([
|
|
@@ -1885,8 +1933,11 @@ function filterReferenceToTf(value, refs, role = "value", realType, operator) {
|
|
|
1885
1933
|
const task = refs.tasks.get(value.forEachTaskRefKey);
|
|
1886
1934
|
if (task === undefined)
|
|
1887
1935
|
throw new EntityTfError(`unresolved forEach filter ref "${value.forEachTaskRefKey}"`);
|
|
1888
|
-
|
|
1889
|
-
|
|
1936
|
+
return expr.template([
|
|
1937
|
+
"for_each.",
|
|
1938
|
+
expr.resourceAttr(task.type, task.label, ["id"]),
|
|
1939
|
+
`.${forEachCompactFilterName(value.name)}`,
|
|
1940
|
+
]);
|
|
1890
1941
|
}
|
|
1891
1942
|
case "VALUE":
|
|
1892
1943
|
return valueToTf(value.value, refs);
|
|
@@ -1956,7 +2007,7 @@ function picklistFilterValueToTf(value, field, refs) {
|
|
|
1956
2007
|
const sibling = refs.owner.workspaceAspects?.get(workspaceAspectKey(field.parentKind, field.parent));
|
|
1957
2008
|
// Table siblings excluded for the same reason as in `crossAppFieldToTf`: a
|
|
1958
2009
|
// picklist field's owner is an app or an element, never a table.
|
|
1959
|
-
if (sibling !== undefined && sibling.kind !== "table") {
|
|
2010
|
+
if (sibling !== undefined && sibling.kind !== "table" && sibling.kind !== "task") {
|
|
1960
2011
|
const localName = field.tags?.includes("STATUS")
|
|
1961
2012
|
? `${sibling.tfLabel}_status_options_by_label`
|
|
1962
2013
|
: field.tags?.includes("STAGE")
|
|
@@ -1994,6 +2045,8 @@ function triggerRecordFieldPath(reference) {
|
|
|
1994
2045
|
return { fieldKey: path[1], suffix: path.slice(2).join(".") };
|
|
1995
2046
|
}
|
|
1996
2047
|
function fieldFromFilterLeftValue(value, refs) {
|
|
2048
|
+
if (isObject(value) && value.type === "FIELD")
|
|
2049
|
+
return token(value.value ?? value.field);
|
|
1997
2050
|
if (!isObject(value) || !isObject(value.value) || value.value.type?.toString().toUpperCase() !== "TRIGGER") {
|
|
1998
2051
|
return undefined;
|
|
1999
2052
|
}
|
|
@@ -2274,7 +2327,6 @@ function configAttrs(kind, config, refs) {
|
|
|
2274
2327
|
}
|
|
2275
2328
|
}
|
|
2276
2329
|
return {
|
|
2277
|
-
...(typeof item.id === "string" ? { id: item.id } : {}),
|
|
2278
2330
|
variable_name: item.name,
|
|
2279
2331
|
formula: calculationFormulaToTf(reference.templateReference, refs),
|
|
2280
2332
|
...(includeType !== "AUTO" ? { include_type: includeType } : {}),
|
|
@@ -2530,7 +2582,6 @@ export function automationToTf(entity, ctx) {
|
|
|
2530
2582
|
workspaceAspects: ctx.workspaceAspects,
|
|
2531
2583
|
diagnostics: ctx.diagnostics ?? [],
|
|
2532
2584
|
activeAutomationRefNames: ctx.activeAutomationRefNames,
|
|
2533
|
-
automationNamesByRefName: ctx.automationNamesByRefName,
|
|
2534
2585
|
};
|
|
2535
2586
|
if (entity.kind !== "automation")
|
|
2536
2587
|
throw new EntityTfError(`automationToTf expects kind "automation"; got "${entity.kind}"`);
|
|
@@ -2889,6 +2940,15 @@ export function automationToTf(entity, ctx) {
|
|
|
2889
2940
|
if (children.length === 0)
|
|
2890
2941
|
throw new EntityTfError(`${wireType} task "${refKey}" must have branches`);
|
|
2891
2942
|
const usedLabels = new Map();
|
|
2943
|
+
// Separate from usedLabels above: that map rejects two branches
|
|
2944
|
+
// sharing the same RAW display label/no-label, but a genuinely
|
|
2945
|
+
// unlabeled branch's fixed "case" fallback and an EXPLICIT label
|
|
2946
|
+
// like "Case" have different raw labels ("" vs "Case") yet
|
|
2947
|
+
// sanitize to the identical tf suffix ("case") - a real address
|
|
2948
|
+
// collision usedLabels never catches. Live-confirmed shape
|
|
2949
|
+
// (review feedback, PR #1100, cursor[bot]): unlabeled sibling next
|
|
2950
|
+
// to a branch explicitly labeled "Case".
|
|
2951
|
+
const usedSuffixes = new Map();
|
|
2892
2952
|
for (const [index, child] of children.entries()) {
|
|
2893
2953
|
const isDefault = wireType === "switch" && (child.isDefault === true || child.label === null);
|
|
2894
2954
|
const displayLabel = isDefault
|
|
@@ -2901,6 +2961,13 @@ export function automationToTf(entity, ctx) {
|
|
|
2901
2961
|
: `${wireType} task "${refKey}" reuses label ${JSON.stringify(displayLabel)} on cases ${prior} and ${index + 1}`);
|
|
2902
2962
|
}
|
|
2903
2963
|
usedLabels.set(displayLabel, index + 1);
|
|
2964
|
+
const fallbackLabel = isDefault ? "default" : "case";
|
|
2965
|
+
const suffix = sanitizeName(child.label ?? child.defaultLabel ?? fallbackLabel);
|
|
2966
|
+
const priorSuffix = usedSuffixes.get(suffix);
|
|
2967
|
+
if (priorSuffix !== undefined) {
|
|
2968
|
+
throw new EntityTfError(`${wireType} task "${refKey}" cases ${priorSuffix} and ${index + 1} both sanitize to the terraform label suffix ${JSON.stringify(suffix)}; give each branch/case a distinct label`);
|
|
2969
|
+
}
|
|
2970
|
+
usedSuffixes.set(suffix, index + 1);
|
|
2904
2971
|
}
|
|
2905
2972
|
let previous;
|
|
2906
2973
|
for (const [index, child] of children.entries()) {
|
|
@@ -2909,7 +2976,17 @@ export function automationToTf(entity, ctx) {
|
|
|
2909
2976
|
// ei's own resource label follows the branch's real display text
|
|
2910
2977
|
// (a default branch renamed "Default Path" exports as
|
|
2911
2978
|
// "..._default_path", not a hardcoded "..._default") - confirmed live.
|
|
2912
|
-
|
|
2979
|
+
// A genuinely unlabeled non-default branch/case exports with the
|
|
2980
|
+
// fixed literal suffix "case" (no index) regardless of wireType or
|
|
2981
|
+
// position - live-confirmed on conciergeforfield (sanofi/us): both
|
|
2982
|
+
// an unlabeled elementum_fork_join_branch and an unlabeled
|
|
2983
|
+
// elementum_switch_case exported as "..._case". The prior
|
|
2984
|
+
// "branch_${index+1}" fallback never matched this, so every
|
|
2985
|
+
// rebuild relabeled the resource and planned a destroy+create for
|
|
2986
|
+
// an otherwise-unchanged branch. usedSuffixes above already
|
|
2987
|
+
// rejects the fixed "case" suffix colliding with an explicitly
|
|
2988
|
+
// labeled sibling that sanitizes to the same thing.
|
|
2989
|
+
const fallbackLabel = isDefault ? "default" : "case";
|
|
2913
2990
|
const branchLabel = `${tfLabel}_${sanitizeName(child.label ?? child.defaultLabel ?? fallbackLabel)}`;
|
|
2914
2991
|
const branchAttrs = {
|
|
2915
2992
|
[wireType === "switch" ? "switch_task" : "fork_join_task"]: address,
|
|
@@ -219,8 +219,11 @@ export interface SlackMessageTriggerOutput {
|
|
|
219
219
|
export declare function slackMessage(): TriggerChain<SlackMessageTriggerOutput>;
|
|
220
220
|
export interface SurveyResponseCreateTriggerOptions {
|
|
221
221
|
readonly app: AppOrElementRef;
|
|
222
|
-
/**
|
|
223
|
-
|
|
222
|
+
/**
|
|
223
|
+
* Survey template id until survey templates are catalog-modeled. The
|
|
224
|
+
* explicit wrapper marks this platform-owned value as non-portable.
|
|
225
|
+
*/
|
|
226
|
+
readonly survey: UnsafePlatformId;
|
|
224
227
|
}
|
|
225
228
|
export type SurveyResponseCreateTriggerOutput = Record<string, unknown>;
|
|
226
229
|
/** Fires when a response is created for the selected survey template. */
|
|
@@ -77,3 +77,5 @@ export declare const AUTOMATION_TASK_TYPE_SET: ReadonlySet<string>;
|
|
|
77
77
|
*/
|
|
78
78
|
export declare const ALL_AUTOMATION_TASK_TYPE_SET: ReadonlySet<string>;
|
|
79
79
|
export declare const AUTOMATION_BRANCH_TYPE_SET: ReadonlySet<string>;
|
|
80
|
+
/** Whether an exported address belongs to an automation composite. */
|
|
81
|
+
export declare function isAutomationResourceAddress(address: string): boolean;
|
|
@@ -131,3 +131,8 @@ export const AUTOMATION_TASK_TYPE_SET = new Set(AUTOMATION_TASK_TYPES);
|
|
|
131
131
|
*/
|
|
132
132
|
export const ALL_AUTOMATION_TASK_TYPE_SET = new Set(TASK_SUB_TYPES.map((t) => t.resourceType));
|
|
133
133
|
export const AUTOMATION_BRANCH_TYPE_SET = new Set(AUTOMATION_BRANCH_TYPES);
|
|
134
|
+
/** Whether an exported address belongs to an automation composite. */
|
|
135
|
+
export function isAutomationResourceAddress(address) {
|
|
136
|
+
const separator = address.indexOf(".");
|
|
137
|
+
return separator > 0 && ALL_AUTOMATION_RESOURCE_TYPES.includes(address.slice(0, separator));
|
|
138
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Ref } from "../shared/ref.js";
|
|
2
|
+
/** Product-shaped output types an automation may publish for downstream use. */
|
|
3
|
+
export declare const workflowOutputType: {
|
|
4
|
+
readonly text: "text";
|
|
5
|
+
readonly number: "number";
|
|
6
|
+
readonly decimal: "decimal";
|
|
7
|
+
readonly boolean: "boolean";
|
|
8
|
+
readonly date: "date";
|
|
9
|
+
readonly datetime: "datetime";
|
|
10
|
+
readonly json: "json";
|
|
11
|
+
readonly object: "object";
|
|
12
|
+
readonly record: "record";
|
|
13
|
+
readonly tableRecord: "tableRecord";
|
|
14
|
+
};
|
|
15
|
+
export type WorkflowOutputType = (typeof workflowOutputType)[keyof typeof workflowOutputType];
|
|
16
|
+
export interface WorkflowOutputDeclaration<Value extends Ref<unknown> = Ref<unknown>, Type extends WorkflowOutputType = WorkflowOutputType, Multiple extends boolean = boolean> {
|
|
17
|
+
/** @internal */
|
|
18
|
+
readonly __kind: "workflowOutput";
|
|
19
|
+
readonly value: Value;
|
|
20
|
+
readonly type: Type;
|
|
21
|
+
readonly multiple: Multiple;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Explicitly type one published automation output when its reference alone
|
|
25
|
+
* cannot reproduce the metadata stored by the platform. The value must be a
|
|
26
|
+
* task or trigger reference; variable and template references do not carry
|
|
27
|
+
* this metadata in the workflow HCL contract.
|
|
28
|
+
*/
|
|
29
|
+
export declare function workflowOutput<const Value extends Ref<unknown>, const Type extends WorkflowOutputType, const Multiple extends boolean>(value: Value, options: {
|
|
30
|
+
readonly type: Type;
|
|
31
|
+
readonly multiple: Multiple;
|
|
32
|
+
}): WorkflowOutputDeclaration<Value, Type, Multiple>;
|
|
33
|
+
export declare function isWorkflowOutputDeclaration(value: unknown): value is WorkflowOutputDeclaration;
|
|
34
|
+
export declare function workflowOutputFieldType(type: WorkflowOutputType): string;
|
|
35
|
+
export declare function workflowOutputTypeFromFieldType(fieldType: string): WorkflowOutputType | undefined;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** Product-shaped output types an automation may publish for downstream use. */
|
|
2
|
+
export const workflowOutputType = {
|
|
3
|
+
text: "text",
|
|
4
|
+
number: "number",
|
|
5
|
+
decimal: "decimal",
|
|
6
|
+
boolean: "boolean",
|
|
7
|
+
date: "date",
|
|
8
|
+
datetime: "datetime",
|
|
9
|
+
json: "json",
|
|
10
|
+
object: "object",
|
|
11
|
+
record: "record",
|
|
12
|
+
tableRecord: "tableRecord",
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Explicitly type one published automation output when its reference alone
|
|
16
|
+
* cannot reproduce the metadata stored by the platform. The value must be a
|
|
17
|
+
* task or trigger reference; variable and template references do not carry
|
|
18
|
+
* this metadata in the workflow HCL contract.
|
|
19
|
+
*/
|
|
20
|
+
export function workflowOutput(value, options) {
|
|
21
|
+
return {
|
|
22
|
+
__kind: "workflowOutput",
|
|
23
|
+
value,
|
|
24
|
+
type: options.type,
|
|
25
|
+
multiple: options.multiple,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function isWorkflowOutputDeclaration(value) {
|
|
29
|
+
return typeof value === "object" && value !== null &&
|
|
30
|
+
value.__kind === "workflowOutput";
|
|
31
|
+
}
|
|
32
|
+
const WORKFLOW_OUTPUT_FIELD_TYPE = {
|
|
33
|
+
text: "TEXT",
|
|
34
|
+
number: "NUMBER",
|
|
35
|
+
decimal: "DECIMAL",
|
|
36
|
+
boolean: "BOOLEAN",
|
|
37
|
+
date: "DATE",
|
|
38
|
+
datetime: "DATETIME",
|
|
39
|
+
json: "JSON",
|
|
40
|
+
object: "OBJECT",
|
|
41
|
+
record: "ASPECT_RECORD_ID",
|
|
42
|
+
tableRecord: "TABLE_RECORD",
|
|
43
|
+
};
|
|
44
|
+
export function workflowOutputFieldType(type) {
|
|
45
|
+
return WORKFLOW_OUTPUT_FIELD_TYPE[type];
|
|
46
|
+
}
|
|
47
|
+
const FIELD_TYPE_TO_WORKFLOW_OUTPUT = new Map(Object.entries(WORKFLOW_OUTPUT_FIELD_TYPE).map(([type, fieldType]) => [
|
|
48
|
+
fieldType,
|
|
49
|
+
type,
|
|
50
|
+
]));
|
|
51
|
+
export function workflowOutputTypeFromFieldType(fieldType) {
|
|
52
|
+
return FIELD_TYPE_TO_WORKFLOW_OUTPUT.get(fieldType);
|
|
53
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { type AppCatalogRef, type
|
|
1
|
+
import { type AppCatalogRef, type AppOrElementOrTaskRef, type ChartRef, type FieldRef, type TableColumnRef, type TableRef } from "../../catalog/index.js";
|
|
2
2
|
import type { DeployableEntity, EntityDeployOptions } from "../../engine/entity.js";
|
|
3
3
|
import type { Filter } from "../shared/filters/types.js";
|
|
4
4
|
import type { UnsafePlatformId } from "../../core/platform-id.js";
|
|
5
5
|
import type { ChartAggregation, ChartColumnValueType, ChartJoinType, ChartType } from "./types.js";
|
|
6
6
|
export { chartAggregation, chartColumnValueType, chartJoinType, chartType, type ChartAggregation, type ChartColumnValueType, type ChartJoinType, type ChartType, } from "./types.js";
|
|
7
|
-
export type ChartDatasourceRef =
|
|
7
|
+
export type ChartDatasourceRef = AppOrElementOrTaskRef | TableRef;
|
|
8
8
|
type RefBagValue<T> = T extends Readonly<Record<string, infer Value>> ? Value : never;
|
|
9
9
|
export type ChartFieldFor<Datasource> = Datasource extends {
|
|
10
10
|
readonly __kind: "table";
|
|
11
11
|
readonly columns?: infer Columns;
|
|
12
12
|
} ? Extract<RefBagValue<NonNullable<Columns>>, TableColumnRef> : Datasource extends {
|
|
13
13
|
readonly fields: infer Fields;
|
|
14
|
-
} ? Extract<RefBagValue<Fields>, FieldRef> : Datasource extends
|
|
14
|
+
} ? Extract<RefBagValue<Fields>, FieldRef> : Datasource extends AppOrElementOrTaskRef<infer Parent> ? FieldRef<Parent> : Datasource extends TableRef<infer Parent> ? TableColumnRef<Parent> : never;
|
|
15
15
|
interface ChartColumnBase {
|
|
16
16
|
readonly name?: string;
|
|
17
17
|
}
|
|
@@ -3,7 +3,7 @@ import { type TfBlock, type TfValue } from "../../engine/tf/index.js";
|
|
|
3
3
|
import type { Filter } from "../shared/filters/types.js";
|
|
4
4
|
import type { ChartProperties } from "./build.js";
|
|
5
5
|
export interface NormalizedChartDatasource {
|
|
6
|
-
readonly kind: "app" | "element" | "table";
|
|
6
|
+
readonly kind: "app" | "element" | "table" | "task";
|
|
7
7
|
readonly refName: string;
|
|
8
8
|
readonly name?: string;
|
|
9
9
|
readonly local: boolean;
|
|
@@ -11,7 +11,7 @@ export interface NormalizedChartDatasource {
|
|
|
11
11
|
}
|
|
12
12
|
export interface NormalizedChartField {
|
|
13
13
|
readonly kind: "field" | "tableColumn";
|
|
14
|
-
readonly parentKind: "app" | "element" | "table";
|
|
14
|
+
readonly parentKind: "app" | "element" | "table" | "task";
|
|
15
15
|
readonly parentRefName: string;
|
|
16
16
|
readonly refName: string;
|
|
17
17
|
readonly name?: string;
|