@elementumai/edk 0.9.9 → 0.9.11
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/src/catalog/factories.d.ts +8 -1
- package/dist-sdk/src/catalog/factories.js +13 -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/types.d.ts +19 -2
- package/dist-sdk/src/catalog/types.js +1 -0
- package/dist-sdk/src/engine/build/context.d.ts +5 -0
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +3 -3
- package/dist-sdk/src/entities/access-policy/from-tf.js +27 -8
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +13 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +34 -3
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +13 -7
- package/dist-sdk/src/entities/agent-tool/to-tf.js +13 -0
- package/dist-sdk/src/entities/app/build.d.ts +15 -2
- package/dist-sdk/src/entities/app/build.js +6 -0
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +13 -3
- package/dist-sdk/src/entities/app/from-tf.js +6 -3
- package/dist-sdk/src/entities/app/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/app/to-tf.js +7 -1
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +78 -19
- package/dist-sdk/src/entities/automation/from-tf.js +113 -1
- package/dist-sdk/src/entities/automation/module.js +1 -0
- package/dist-sdk/src/entities/automation/script-code.d.ts +7 -0
- package/dist-sdk/src/entities/automation/script-code.js +17 -3
- package/dist-sdk/src/entities/automation/tasks.js +17 -0
- package/dist-sdk/src/entities/automation/to-tf.d.ts +8 -0
- package/dist-sdk/src/entities/automation/to-tf.js +162 -46
- package/dist-sdk/src/entities/automation/types.js +1 -0
- package/dist-sdk/src/entities/dashboard/from-tf.js +11 -2
- package/dist-sdk/src/entities/dashboard/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/dashboard/to-tf.js +4 -0
- package/dist-sdk/src/entities/datamine/from-tf.js +23 -3
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +2 -1
- package/dist-sdk/src/entities/dynamic-layout/dialect.d.ts +8 -0
- package/dist-sdk/src/entities/dynamic-layout/dialect.js +12 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +7 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +64 -10
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +54 -6
- package/dist-sdk/src/entities/element/build.d.ts +7 -0
- package/dist-sdk/src/entities/element/from-tf.js +1 -1
- package/dist-sdk/src/entities/element/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/element/to-tf.js +19 -1
- package/dist-sdk/src/entities/field/build.d.ts +10 -1
- package/dist-sdk/src/entities/field/build.js +2 -1
- package/dist-sdk/src/entities/field/calc/index.js +7 -7
- package/dist-sdk/src/entities/field/calc/runtime.d.ts +19 -0
- package/dist-sdk/src/entities/field/calc/runtime.js +32 -0
- package/dist-sdk/src/entities/field/calc/types.d.ts +6 -0
- package/dist-sdk/src/entities/file-reader/to-tf.js +10 -2
- package/dist-sdk/src/entities/relationship/build.d.ts +14 -7
- package/dist-sdk/src/entities/relationship/from-tf.js +14 -14
- package/dist-sdk/src/entities/relationship/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/relationship/to-tf.js +18 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +15 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +21 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +16 -4
- package/dist-sdk/src/entities/skill/tools.d.ts +10 -0
- package/dist-sdk/src/entities/skill/tools.js +10 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +7 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +22 -2
- package/dist-sdk/src/entities/skill-tool/to-tf.js +21 -0
- package/dist-sdk/src/entities/table/catalog-render.js +2 -1
- package/dist-sdk/src/entities/view/from-tf.js +9 -0
- package/dist-sdk/src/entities/view/to-tf.d.ts +7 -0
- package/dist-sdk/src/entities/view/to-tf.js +34 -5
- package/dist-sdk/src/entities/widget/build.d.ts +17 -7
- package/dist-sdk/src/entities/widget/from-tf.d.ts +1 -1
- package/dist-sdk/src/entities/widget/from-tf.js +132 -18
- package/dist-sdk/src/entities/widget/to-tf.d.ts +17 -0
- package/dist-sdk/src/entities/widget/to-tf.js +40 -0
- package/dist-sdk/src/graph/types.d.ts +8 -0
- package/package.json +1 -1
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* Unsupported authoring shapes degrade through `diagnostics` — reported,
|
|
15
15
|
* never silent, never thrown (plan §4.3).
|
|
16
16
|
*/
|
|
17
|
+
import { workspaceAspectKey } from "../../engine/build/context.js";
|
|
17
18
|
import { DEPLOY_DEFAULT_STATUS_OPTION_VALUES, SYSTEM_FIELD_HCL_KEY_BY_KEY, SYSTEM_FIELD_KEY_BY_TAG } from "../../core/system-fields.js";
|
|
18
19
|
import { EntityTfError } from "../../engine/entity.js";
|
|
19
20
|
import { expr, snakeSlug } from "../../engine/tf/index.js";
|
|
@@ -30,7 +31,7 @@ import { recordCreateFormToTf } from "../record-create-form/to-tf.js";
|
|
|
30
31
|
import { relationshipsToTf } from "../relationship/to-tf.js";
|
|
31
32
|
import { rolesToTf } from "../role/to-tf.js";
|
|
32
33
|
import { serviceAccountsToTf } from "../service-account/to-tf.js";
|
|
33
|
-
import { widgetsToTf } from "../widget/to-tf.js";
|
|
34
|
+
import { relationshipTargetsFromBag, widgetsToTf } from "../widget/to-tf.js";
|
|
34
35
|
import { viewToTf } from "../view/to-tf.js";
|
|
35
36
|
import { APP_RESOURCE_TYPE } from "./module.js";
|
|
36
37
|
/** System-field tags that fold into the app resource instead of emitting a field resource. */
|
|
@@ -79,6 +80,8 @@ export function appToTf(entity, ctx) {
|
|
|
79
80
|
appAttrs["color"] = payload.color;
|
|
80
81
|
if (payload.commentsEnabled !== undefined)
|
|
81
82
|
appAttrs["comments_enabled"] = payload.commentsEnabled;
|
|
83
|
+
if (payload.lockStages !== undefined)
|
|
84
|
+
appAttrs["lock_stages"] = payload.lockStages;
|
|
82
85
|
const categoryName = payload.category?.name;
|
|
83
86
|
if (categoryName !== undefined && categoryName !== "") {
|
|
84
87
|
const category = ctx.orgRefs.byName(CATEGORY_ORG_BAG, categoryName);
|
|
@@ -246,6 +249,7 @@ export function appToTf(entity, ctx) {
|
|
|
246
249
|
ownerResourceType: APP_RESOURCE_TYPE,
|
|
247
250
|
orgRefs: ctx.orgRefs,
|
|
248
251
|
workspaceAspects: ctx.workspaceAspects,
|
|
252
|
+
availableChartRefNames: ctx.workspaceAspects?.get(workspaceAspectKey("app", ctx.appRefName))?.managedChildRefNames?.get("chart"),
|
|
249
253
|
diagnostics: ctx.diagnostics,
|
|
250
254
|
}));
|
|
251
255
|
blocks.push(...widgetsToTf(payload.widgets, {
|
|
@@ -258,6 +262,7 @@ export function appToTf(entity, ctx) {
|
|
|
258
262
|
workspaceAspects: ctx.workspaceAspects,
|
|
259
263
|
diagnostics: ctx.diagnostics,
|
|
260
264
|
fieldAddresses,
|
|
265
|
+
relationshipTargets: relationshipTargetsFromBag(payload.relationships),
|
|
261
266
|
}));
|
|
262
267
|
const { blocks: viewBlocks } = viewToTf(payload.layouts, payload.listViews, payload.calendarViews, payload.kanbanViews, payload.dashboardViews, payload.agentViews, payload.viewOrder, {
|
|
263
268
|
ownerRefName: ctx.appRefName,
|
|
@@ -269,6 +274,7 @@ export function appToTf(entity, ctx) {
|
|
|
269
274
|
orgRefs: ctx.orgRefs,
|
|
270
275
|
diagnostics: ctx.diagnostics,
|
|
271
276
|
fieldAddresses,
|
|
277
|
+
widgetKeys: new Set(Object.keys(payload.widgets ?? {})),
|
|
272
278
|
});
|
|
273
279
|
blocks.push(...viewBlocks);
|
|
274
280
|
const recordCreateForm = recordCreateFormToTf(payload.recordCreateForm, {
|
|
@@ -37,6 +37,7 @@ import { isRefExpr } from "../../shared/filters/ast.js";
|
|
|
37
37
|
import { printFilter as printCanonicalFilter } from "../../shared/filters/print.js";
|
|
38
38
|
import { UNRESOLVED_FIELD_MARKER } from "../../shared/ref.js";
|
|
39
39
|
import { UNRESOLVED_REFERENCE_MARKER } from "../filter.js";
|
|
40
|
+
import { INJECTED_TS_IGNORE } from "../script-code.js";
|
|
40
41
|
import { unresolvedReferenceComment } from "../../../engine/pull/ref-only.js";
|
|
41
42
|
// ---------------------------------------------------------------------------
|
|
42
43
|
// Factory name mapping — v1 AST `factory` → v2 factory function name.
|
|
@@ -248,21 +249,6 @@ export function printAutomationV2(ast, opts = {}) {
|
|
|
248
249
|
// ---------------------------------------------------------------------------
|
|
249
250
|
function renderHeader(ast, imports, _opts) {
|
|
250
251
|
const lines = [];
|
|
251
|
-
if (imports.usesScriptInput) {
|
|
252
|
-
// executeScript task bodies are printed VERBATIM from the platform's
|
|
253
|
-
// plain-JavaScript source (script-code.ts) — they carry no type
|
|
254
|
-
// annotations of their own, so under this workspace's `noImplicitAny`
|
|
255
|
-
// every untyped nested function/variable in a pulled script body fails
|
|
256
|
-
// `tsc` (#749). The script text is later re-extracted byte-exact from
|
|
257
|
-
// this file's own source (`tryExtractFromCurrentSource`) and shipped to
|
|
258
|
-
// the platform as literal JavaScript, so annotating it in place isn't
|
|
259
|
-
// safe — `: any` would be invalid JS if the file is ever hand-edited
|
|
260
|
-
// into something the extractor can't match and falls back to
|
|
261
|
-
// `Function#toString()`. `@ts-nocheck` must lead the file to take
|
|
262
|
-
// effect, so it costs this one file's typechecking (still fully
|
|
263
|
-
// buildable) rather than the workspace's.
|
|
264
|
-
lines.push(`// @ts-nocheck — executeScript task bodies below are untyped platform JavaScript (see #749)`);
|
|
265
|
-
}
|
|
266
252
|
lines.push(`/**`);
|
|
267
253
|
lines.push(` * ${ast.name}`);
|
|
268
254
|
lines.push(` *`);
|
|
@@ -544,6 +530,7 @@ function formatExecuteScript(task, state, indent, refCtx = DEFAULT_CTX) {
|
|
|
544
530
|
}
|
|
545
531
|
const code = task.args.code ?? task.args.script;
|
|
546
532
|
if (typeof code === "string") {
|
|
533
|
+
lines.push(`${configPad}// @ts-ignore`);
|
|
547
534
|
lines.push(`${configPad}code: ${printScriptCodeFn(code, indent + 1, state)},`);
|
|
548
535
|
}
|
|
549
536
|
if (task.args.outputs !== undefined && task.args.outputs !== null && typeof task.args.outputs === "object") {
|
|
@@ -582,11 +569,79 @@ function formatExecuteScript(task, state, indent, refCtx = DEFAULT_CTX) {
|
|
|
582
569
|
* references. Hand-authored `.executeScript` calls are unaffected — they
|
|
583
570
|
* still get full inference since they never pass this printer.
|
|
584
571
|
*/
|
|
572
|
+
/**
|
|
573
|
+
* Annotates lines of a script body with `// @ts-ignore` so untyped nested
|
|
574
|
+
* declarations (such as `function helper(value) { ... }`) pass under
|
|
575
|
+
* `noImplicitAny` when pulled scripts are type-checked.
|
|
576
|
+
* Lines inside multi-line template literals or block comments are left
|
|
577
|
+
* unannotated to avoid altering string literals or breaking comments.
|
|
578
|
+
*/
|
|
579
|
+
function annotateScriptLines(body, indent) {
|
|
580
|
+
const innerPad = " ".repeat(indent);
|
|
581
|
+
const lines = body.replace(/\r\n/g, "\n").split("\n");
|
|
582
|
+
let inBacktick = false;
|
|
583
|
+
let inBlockComment = false;
|
|
584
|
+
const result = [];
|
|
585
|
+
for (const line of lines) {
|
|
586
|
+
if (line.trim().length === 0) {
|
|
587
|
+
result.push("");
|
|
588
|
+
continue;
|
|
589
|
+
}
|
|
590
|
+
const wasInBacktick = inBacktick;
|
|
591
|
+
const wasInBlockComment = inBlockComment;
|
|
592
|
+
for (let i = 0; i < line.length; i++) {
|
|
593
|
+
const c = line[i];
|
|
594
|
+
const next = line[i + 1];
|
|
595
|
+
if (inBlockComment) {
|
|
596
|
+
if (c === "*" && next === "/") {
|
|
597
|
+
inBlockComment = false;
|
|
598
|
+
i++;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
else if (inBacktick) {
|
|
602
|
+
if (c === "\\") {
|
|
603
|
+
i++;
|
|
604
|
+
}
|
|
605
|
+
else if (c === "`") {
|
|
606
|
+
inBacktick = false;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
else {
|
|
610
|
+
if (c === "/" && next === "*") {
|
|
611
|
+
inBlockComment = true;
|
|
612
|
+
i++;
|
|
613
|
+
}
|
|
614
|
+
else if (c === "/" && next === "/") {
|
|
615
|
+
break;
|
|
616
|
+
}
|
|
617
|
+
else if (c === "`") {
|
|
618
|
+
inBacktick = true;
|
|
619
|
+
}
|
|
620
|
+
else if (c === '"' || c === "'") {
|
|
621
|
+
const quote = c;
|
|
622
|
+
i++;
|
|
623
|
+
while (i < line.length && line[i] !== quote) {
|
|
624
|
+
if (line[i] === "\\")
|
|
625
|
+
i++;
|
|
626
|
+
i++;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
const trimmed = line.trim();
|
|
632
|
+
const isCommentLine = trimmed.startsWith("//") || (trimmed.startsWith("/*") && trimmed.endsWith("*/"));
|
|
633
|
+
if (wasInBacktick || wasInBlockComment || isCommentLine) {
|
|
634
|
+
result.push(`${innerPad}${line}`);
|
|
635
|
+
}
|
|
636
|
+
else {
|
|
637
|
+
result.push(`${innerPad}${INJECTED_TS_IGNORE}\n${innerPad}${line}`);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
return result.join("\n");
|
|
641
|
+
}
|
|
585
642
|
function printScriptCodeFn(body, indent, state) {
|
|
586
643
|
const pad = " ".repeat(indent);
|
|
587
|
-
const
|
|
588
|
-
const lines = body.replace(/\r\n/g, "\n").split("\n");
|
|
589
|
-
const indented = lines.map((line) => (line.length === 0 ? "" : `${innerPad}${line}`)).join("\n");
|
|
644
|
+
const indented = annotateScriptLines(body, indent + 1);
|
|
590
645
|
state.imports.usesScriptInput = true;
|
|
591
646
|
return `(input: ScriptInput<Record<string, unknown>>) => {\n${indented}\n${pad}}`;
|
|
592
647
|
}
|
|
@@ -1068,7 +1123,11 @@ function printObjectLiteral(obj, state, indent, refCtx) {
|
|
|
1068
1123
|
if (entries.length === 0)
|
|
1069
1124
|
return "{}";
|
|
1070
1125
|
const pad = " ".repeat(indent);
|
|
1071
|
-
const lines = entries.map(([k, v]) =>
|
|
1126
|
+
const lines = entries.map(([k, v]) => {
|
|
1127
|
+
const isScript = (k === "code" || k === "script") && typeof v === "string";
|
|
1128
|
+
const prefix = isScript ? `${pad}// @ts-ignore\n` : "";
|
|
1129
|
+
return `${prefix}${pad}${safeKey(k)}: ${printArgValue(k, v, state, indent + 1, refCtx)},`;
|
|
1130
|
+
});
|
|
1072
1131
|
return `{\n${lines.join("\n")}\n${" ".repeat(indent - 1)}}`;
|
|
1073
1132
|
}
|
|
1074
1133
|
function printArrayLiteral(arr, state, indent, refCtx) {
|
|
@@ -28,6 +28,7 @@ const TRIGGER_KINDS = {
|
|
|
28
28
|
elementum_approval_chain_trigger: "approvalProcessStatusUpdated",
|
|
29
29
|
elementum_datamine_trigger: "dataMine",
|
|
30
30
|
elementum_survey_trigger: "surveyResponseCreate",
|
|
31
|
+
elementum_schedule_trigger: "schedule",
|
|
31
32
|
};
|
|
32
33
|
const TASK_FACTORIES = {
|
|
33
34
|
elementum_message_task: "postComment",
|
|
@@ -232,6 +233,8 @@ const TRIGGER_ATTRIBUTES = new Set([
|
|
|
232
233
|
"authenticated", "custom_response", "show_triggered_by", "parameters",
|
|
233
234
|
"approval_chain_template_id", "status", "datamine_id", "fire_on_alert",
|
|
234
235
|
"fire_on_recovery", "email_alias_id", "survey_template_id",
|
|
236
|
+
"frequency", "interval", "timezone", "start_at", "weekdays", "day_of_month",
|
|
237
|
+
"end_at", "ends_after_count", "interval_unit",
|
|
235
238
|
]);
|
|
236
239
|
const TASK_ATTRIBUTES = new Set([
|
|
237
240
|
"parent", "name", "depends_on", "filter", "fields", "inputs", "output_schema",
|
|
@@ -402,6 +405,17 @@ const RECORD_SEARCH_TASK_REF_SEGMENT_TO_TS = {
|
|
|
402
405
|
"All found records": "records",
|
|
403
406
|
Record: "record",
|
|
404
407
|
};
|
|
408
|
+
/**
|
|
409
|
+
* The same outputs as seen from a CALCULATION formula, which addresses a
|
|
410
|
+
* reference by its WorkflowTaskReference name rather than the refs-map
|
|
411
|
+
* display key above (`to-tf.ts`'s `CALCULATION_TASK_OUTPUT_REF_NAME` is the
|
|
412
|
+
* write side). Only the names that differ from their authoring path are
|
|
413
|
+
* listed; the rest already read back correctly.
|
|
414
|
+
*/
|
|
415
|
+
const RECORD_SEARCH_CALCULATION_REF_NAME_TO_TS = {
|
|
416
|
+
count: ["totalCount"],
|
|
417
|
+
recordId: ["record", "recordId"],
|
|
418
|
+
};
|
|
405
419
|
// aiSearchTable's own output ref name — same scoping reason as
|
|
406
420
|
// RECORD_SEARCH_TASK_REF_SEGMENT_TO_TS: "All Records" is a platform-fixed
|
|
407
421
|
// wire key on elementum_ai_search_table_task only. A trigger field could
|
|
@@ -526,6 +540,22 @@ function lookupFieldKeyByDisplayName(ownerRefName, displayName, ctx) {
|
|
|
526
540
|
}
|
|
527
541
|
return undefined;
|
|
528
542
|
}
|
|
543
|
+
/**
|
|
544
|
+
* `record.<field-uuid>[.suffix]` — how a calculation formula names a found
|
|
545
|
+
* record's field (the calc engine resolves it by field id, not display
|
|
546
|
+
* name). Mirrors the same shape already handled for live filters in
|
|
547
|
+
* `decodeReferenceString`, resolving the id back to its authoring bag key.
|
|
548
|
+
*/
|
|
549
|
+
function calculationRecordFieldPath(taskAddress, wireName, ctx) {
|
|
550
|
+
if (taskAddress === undefined)
|
|
551
|
+
return undefined;
|
|
552
|
+
const [head, ...tail] = wireName.split(".");
|
|
553
|
+
if (head !== "record" || tail.length === 0 || !/^[a-f0-9-]{36}$/i.test(tail[0]))
|
|
554
|
+
return undefined;
|
|
555
|
+
const ownerRefName = ctx.taskTargetOwnerRefNameByAddress?.get(taskAddress) ?? ctx.appRefName;
|
|
556
|
+
const fieldKey = resolveFieldKeyFromId(tail[0], ownerRefName, ctx);
|
|
557
|
+
return ["record", fieldKey ?? tail[0], ...tail.slice(1)];
|
|
558
|
+
}
|
|
529
559
|
function taskRecordSearchFieldPath(taskAddress, wireName, ctx) {
|
|
530
560
|
if (ctx.taskTargetOwnerRefNameByAddress?.get(taskAddress) === undefined)
|
|
531
561
|
return undefined;
|
|
@@ -796,6 +826,25 @@ function decodeTaskReferenceFromString(taskIdOrKey, pathSegments, ctx) {
|
|
|
796
826
|
if (aiAgentPath !== undefined)
|
|
797
827
|
return { kind: "taskRef", task: refKey, path: aiAgentPath };
|
|
798
828
|
}
|
|
829
|
+
// A task's own record output can be addressed by an unresolved field UUID
|
|
830
|
+
// (`record.<field-uuid>[.suffix]`) the same way a recordSearch task's
|
|
831
|
+
// found-record fields already are below - an updateField task's "record"
|
|
832
|
+
// refers to the record it just updated (same-app field, live-confirmed on
|
|
833
|
+
// purchaseorder/eu-sanofi), so it needs the identical UUID resolution or
|
|
834
|
+
// it falls through to the raw-uuid escape even for a resolvable field.
|
|
835
|
+
if (block?.type === "elementum_update_field_task" &&
|
|
836
|
+
pathSegments.length >= 2 &&
|
|
837
|
+
pathSegments[0] === "record" &&
|
|
838
|
+
/^[a-f0-9-]{36}$/i.test(pathSegments[1])) {
|
|
839
|
+
const taskAddress = block.label !== undefined ? `${block.type}.${block.label}` : undefined;
|
|
840
|
+
const ownerRefName = (taskAddress !== undefined ? ctx.taskTargetOwnerRefNameByAddress?.get(taskAddress) : undefined) ?? ctx.appRefName;
|
|
841
|
+
const fieldKey = resolveFieldKeyFromId(pathSegments[1], ownerRefName, ctx);
|
|
842
|
+
return {
|
|
843
|
+
kind: "taskRef",
|
|
844
|
+
task: refKey,
|
|
845
|
+
path: ["record", fieldKey ?? pathSegments[1], ...pathSegments.slice(2)],
|
|
846
|
+
};
|
|
847
|
+
}
|
|
799
848
|
if (block?.type === "elementum_record_search_task" && pathSegments.length >= 1) {
|
|
800
849
|
const [head, ...tail] = pathSegments;
|
|
801
850
|
if (head === "count") {
|
|
@@ -1694,12 +1743,22 @@ function decodeCalculationTaskMustache(taskId, wireName, ctx) {
|
|
|
1694
1743
|
if (aiAgentPath !== undefined)
|
|
1695
1744
|
return { kind: "taskRef", task: refKey, path: aiAgentPath };
|
|
1696
1745
|
}
|
|
1746
|
+
// A calculation mustache carries the WorkflowTaskReference name, not the
|
|
1747
|
+
// refs-map display key: a found record's field is `record.<field-uuid>`
|
|
1748
|
+
// and the task's own outputs are their internal names. Both are addressed
|
|
1749
|
+
// here before the display-key tables below, which never match them.
|
|
1750
|
+
const taskAddress = taskBlock?.label !== undefined ? `${taskBlock.type}.${taskBlock.label}` : undefined;
|
|
1751
|
+
const calcRecordFieldPath = calculationRecordFieldPath(taskAddress, wireName, ctx);
|
|
1752
|
+
if (calcRecordFieldPath !== undefined)
|
|
1753
|
+
return { kind: "taskRef", task: refKey, path: calcRecordFieldPath };
|
|
1697
1754
|
if (taskBlock?.type === "elementum_record_search_task") {
|
|
1755
|
+
const calcOwnOutput = RECORD_SEARCH_CALCULATION_REF_NAME_TO_TS[wireName];
|
|
1756
|
+
if (calcOwnOutput !== undefined)
|
|
1757
|
+
return { kind: "taskRef", task: refKey, path: [...calcOwnOutput] };
|
|
1698
1758
|
const recordSearchName = RECORD_SEARCH_TASK_REF_SEGMENT_TO_TS[wireName];
|
|
1699
1759
|
if (recordSearchName !== undefined) {
|
|
1700
1760
|
return { kind: "taskRef", task: refKey, path: [recordSearchName] };
|
|
1701
1761
|
}
|
|
1702
|
-
const taskAddress = taskBlock.label !== undefined ? `${taskBlock.type}.${taskBlock.label}` : undefined;
|
|
1703
1762
|
if (taskAddress !== undefined) {
|
|
1704
1763
|
const recordFieldPath = taskRecordSearchFieldPath(taskAddress, wireName, ctx);
|
|
1705
1764
|
if (recordFieldPath !== undefined) {
|
|
@@ -1791,6 +1850,23 @@ function resolveVariableReference(rawId, rawName, outputName, ctx) {
|
|
|
1791
1850
|
return { kind: "variableParamRef", varTask: byOutput.refKey, name: byOutput.varName };
|
|
1792
1851
|
}
|
|
1793
1852
|
}
|
|
1853
|
+
// 4. The variable's real platform id only exists in deployed state, never
|
|
1854
|
+
// in the static export text a `variable_task`/`update_variable_task` block
|
|
1855
|
+
// carries (no `variable_id`/`id` attribute on the wire) - so a workflow
|
|
1856
|
+
// OUTPUT's `variableReference.name` is always the synthetic
|
|
1857
|
+
// "variable|<uuid>" placeholder, and #2/#3's name-based matches routinely
|
|
1858
|
+
// miss on casing/spacing (output "Output Message" vs. variable "Output
|
|
1859
|
+
// message" - live-confirmed on purchaseorder/eu-sanofi's Authorization
|
|
1860
|
+
// Check automation). With exactly one variable task in the whole
|
|
1861
|
+
// automation there is no other candidate it could mean. Scoped to
|
|
1862
|
+
// outputName (workflow_publish outputs only) - a bare filter reference's
|
|
1863
|
+
// "variable.<uuid>" is a DIFFERENT wire dialect with no such guarantee
|
|
1864
|
+
// (board issue #171 contract: a filter referencing variable.<uuid> must
|
|
1865
|
+
// NOT bind to a same-automation variable task).
|
|
1866
|
+
if (rawId !== undefined && outputName !== undefined && variableTasks.length === 1) {
|
|
1867
|
+
const only = variableTasks[0];
|
|
1868
|
+
return { kind: "variableParamRef", varTask: only.refKey, name: only.varName };
|
|
1869
|
+
}
|
|
1794
1870
|
return undefined;
|
|
1795
1871
|
}
|
|
1796
1872
|
function decodeFilterReferenceEnvelope(value, ctx, outputName) {
|
|
@@ -1985,6 +2061,42 @@ function triggerFromBlock(block, ctx) {
|
|
|
1985
2061
|
if (typeof block.attrs.survey_template_id !== "string")
|
|
1986
2062
|
throw new EntityTfError("survey trigger requires survey_template_id");
|
|
1987
2063
|
return { kind, app, survey: block.attrs.survey_template_id };
|
|
2064
|
+
case "schedule": {
|
|
2065
|
+
if (typeof block.attrs.frequency !== "string")
|
|
2066
|
+
throw new EntityTfError("schedule trigger requires frequency");
|
|
2067
|
+
if (typeof block.attrs.timezone !== "string")
|
|
2068
|
+
throw new EntityTfError("schedule trigger requires timezone");
|
|
2069
|
+
if (typeof block.attrs.start_at !== "string")
|
|
2070
|
+
throw new EntityTfError("schedule trigger requires start_at");
|
|
2071
|
+
const frequency = block.attrs.frequency;
|
|
2072
|
+
if (frequency !== "HOURLY" && frequency !== "DAILY" && frequency !== "WEEKLY" && frequency !== "MONTHLY") {
|
|
2073
|
+
throw new EntityTfError(`schedule trigger frequency "${frequency}" is not a public EDK schedule frequency`);
|
|
2074
|
+
}
|
|
2075
|
+
if (block.attrs.end_at !== undefined) {
|
|
2076
|
+
throw new EntityTfError("schedule trigger end_at is not a public EDK schedule option");
|
|
2077
|
+
}
|
|
2078
|
+
if (block.attrs.ends_after_count !== undefined) {
|
|
2079
|
+
throw new EntityTfError("schedule trigger ends_after_count is not a public EDK schedule option");
|
|
2080
|
+
}
|
|
2081
|
+
if (block.attrs.interval_unit !== undefined) {
|
|
2082
|
+
throw new EntityTfError("schedule trigger interval_unit is not a public EDK schedule option");
|
|
2083
|
+
}
|
|
2084
|
+
if (block.attrs.filter !== undefined) {
|
|
2085
|
+
throw new EntityTfError("schedule trigger filter is not a public EDK schedule option");
|
|
2086
|
+
}
|
|
2087
|
+
const weekdays = Array.isArray(block.attrs.weekdays)
|
|
2088
|
+
? block.attrs.weekdays.filter((day) => typeof day === "string")
|
|
2089
|
+
: undefined;
|
|
2090
|
+
return {
|
|
2091
|
+
kind,
|
|
2092
|
+
frequency,
|
|
2093
|
+
timezone: block.attrs.timezone,
|
|
2094
|
+
startAt: block.attrs.start_at,
|
|
2095
|
+
...(typeof block.attrs.interval === "number" ? { interval: block.attrs.interval } : {}),
|
|
2096
|
+
...(weekdays !== undefined && weekdays.length > 0 ? { weekdays } : {}),
|
|
2097
|
+
...(typeof block.attrs.day_of_month === "number" ? { dayOfMonth: block.attrs.day_of_month } : {}),
|
|
2098
|
+
};
|
|
2099
|
+
}
|
|
1988
2100
|
default: throw new EntityTfError(`trigger "${kind}" is outside the Terraform contract`);
|
|
1989
2101
|
}
|
|
1990
2102
|
}
|
|
@@ -204,6 +204,7 @@ export const automationModule = {
|
|
|
204
204
|
fieldNames: ctx.fieldNames ?? new Map(),
|
|
205
205
|
fieldMetadata: ctx.fieldMetadata ?? new Map(),
|
|
206
206
|
...(ctx.fieldNamesByAppRefName !== undefined ? { fieldNamesByAppRefName: ctx.fieldNamesByAppRefName } : {}),
|
|
207
|
+
...(ctx.fieldAddressesByAppRefName !== undefined ? { fieldAddressesByAppRefName: ctx.fieldAddressesByAppRefName } : {}),
|
|
207
208
|
...(ctx.allowUnknownPicklistOptions === true ? { allowUnknownPicklistOptions: true } : {}),
|
|
208
209
|
orgRefs: ctx.orgRefs,
|
|
209
210
|
workspaceAspects: ctx.workspaceAspects,
|
|
@@ -12,6 +12,13 @@ export declare class ScriptCodeError extends Error {
|
|
|
12
12
|
* with expression body (wrapped into a `return`), and `function` declarations.
|
|
13
13
|
*/
|
|
14
14
|
export declare function extractScriptBody(fn: (...args: never[]) => unknown): string;
|
|
15
|
+
export declare const INJECTED_TS_IGNORE = "// @ts-ignore edk:injected";
|
|
16
|
+
/**
|
|
17
|
+
* Strips `// @ts-ignore edk:injected` directive lines that were injected
|
|
18
|
+
* by the pull printer to suppress `noImplicitAny` errors in untyped script bodies.
|
|
19
|
+
* Legitimate user-authored `// @ts-ignore` comments are preserved.
|
|
20
|
+
*/
|
|
21
|
+
export declare function stripTsIgnoreLines(code: string): string;
|
|
15
22
|
/**
|
|
16
23
|
* Infer the executeScript output schema (property name → authoring type
|
|
17
24
|
* alias) from the script body's `return {...}` object literals — the runtime
|
|
@@ -109,8 +109,21 @@ export function extractScriptBody(fn) {
|
|
|
109
109
|
throw new ScriptCodeError("executeScript code: could not extract a script body from the function source — " +
|
|
110
110
|
"author it as `(input) => { ... return {...}; }`.");
|
|
111
111
|
}
|
|
112
|
+
export const INJECTED_TS_IGNORE = "// @ts-ignore edk:injected";
|
|
113
|
+
/**
|
|
114
|
+
* Strips `// @ts-ignore edk:injected` directive lines that were injected
|
|
115
|
+
* by the pull printer to suppress `noImplicitAny` errors in untyped script bodies.
|
|
116
|
+
* Legitimate user-authored `// @ts-ignore` comments are preserved.
|
|
117
|
+
*/
|
|
118
|
+
export function stripTsIgnoreLines(code) {
|
|
119
|
+
return code
|
|
120
|
+
.replace(/\r\n/g, "\n")
|
|
121
|
+
.split("\n")
|
|
122
|
+
.filter((line) => !/^\s*\/\/\s*@ts-ignore\s+edk:injected\s*$/.test(line))
|
|
123
|
+
.join("\n");
|
|
124
|
+
}
|
|
112
125
|
function finishBody(rawBody, rawParams, fullSrc) {
|
|
113
|
-
const body = dedent(rawBody.replace(/^\n+/, "").replace(/\s+$/, ""));
|
|
126
|
+
const body = dedent(stripTsIgnoreLines(rawBody).replace(/^\n+/, "").replace(/\s+$/, ""));
|
|
114
127
|
const params = collectParamNames(rawParams);
|
|
115
128
|
const unknown = freeIdentifiers(body, params);
|
|
116
129
|
if (unknown.length > 0) {
|
|
@@ -644,8 +657,9 @@ function scanExecuteScriptBodies(src) {
|
|
|
644
657
|
const name = unquoteIfStringLiteral(call.args[0]);
|
|
645
658
|
if (name !== undefined) {
|
|
646
659
|
const body = extractCodeBody(call.args[1]);
|
|
647
|
-
if (body !== undefined)
|
|
648
|
-
result.set(name, dedent(body.replace(/^\n+/, "").replace(/\s+$/, "")));
|
|
660
|
+
if (body !== undefined) {
|
|
661
|
+
result.set(name, dedent(stripTsIgnoreLines(body).replace(/^\n+/, "").replace(/\s+$/, "")));
|
|
662
|
+
}
|
|
649
663
|
}
|
|
650
664
|
}
|
|
651
665
|
}
|
|
@@ -360,7 +360,22 @@ export function aiEmailAnalysis(opts) {
|
|
|
360
360
|
},
|
|
361
361
|
};
|
|
362
362
|
}
|
|
363
|
+
function isFileReaderCatalogRef(value) {
|
|
364
|
+
return (typeof value === "object" &&
|
|
365
|
+
value !== null &&
|
|
366
|
+
value.__kind === "documentModel" &&
|
|
367
|
+
typeof value.refName === "string");
|
|
368
|
+
}
|
|
369
|
+
function isUnresolvedFileReaderPlaceholder(value) {
|
|
370
|
+
return typeof value === "string";
|
|
371
|
+
}
|
|
372
|
+
function assertFileReaderReference(value, taskName) {
|
|
373
|
+
if (isFileReaderCatalogRef(value) || isUnresolvedFileReaderPlaceholder(value))
|
|
374
|
+
return;
|
|
375
|
+
throw new Error(`${taskName} requires a FileReaderCatalogRef or an unresolved pulled placeholder.`);
|
|
376
|
+
}
|
|
363
377
|
export function aiFileAnalysis(opts) {
|
|
378
|
+
assertFileReaderReference(opts.documentModel, "aiFileAnalysis");
|
|
364
379
|
return {
|
|
365
380
|
key: "aiFileAnalysis",
|
|
366
381
|
config: {
|
|
@@ -715,6 +730,7 @@ export function runAutomation(opts) {
|
|
|
715
730
|
};
|
|
716
731
|
}
|
|
717
732
|
export function readFile(opts) {
|
|
733
|
+
assertFileReaderReference(opts.fileReader, "readFile");
|
|
718
734
|
return {
|
|
719
735
|
key: "documentModel",
|
|
720
736
|
config: {
|
|
@@ -727,6 +743,7 @@ export function readFile(opts) {
|
|
|
727
743
|
export function bulkExcel(opts) {
|
|
728
744
|
if (opts.fieldMappings.length === 0)
|
|
729
745
|
throw new Error("bulkExcel requires at least one fieldMapping.");
|
|
746
|
+
assertFileReaderReference(opts.documentModel, "bulkExcel");
|
|
730
747
|
return {
|
|
731
748
|
key: "bulkExcel",
|
|
732
749
|
config: {
|
|
@@ -18,6 +18,14 @@ export interface AutomationToTfContext {
|
|
|
18
18
|
* typed against a DIFFERENT aspect resolve cross-app refs (#490).
|
|
19
19
|
*/
|
|
20
20
|
readonly fieldNamesByAppRefName?: ReadonlyMap<string, ReadonlyMap<string, string>>;
|
|
21
|
+
/**
|
|
22
|
+
* Field resource ADDRESSES for every app/element in this build, keyed the
|
|
23
|
+
* same way as {@link fieldNamesByAppRefName}. The calc engine addresses a
|
|
24
|
+
* found record's field by field id rather than display name, so a
|
|
25
|
+
* cross-aspect `recordSearch` output used inside a calculation needs the
|
|
26
|
+
* searched aspect's own `<resource>.<label>.id` to interpolate.
|
|
27
|
+
*/
|
|
28
|
+
readonly fieldAddressesByAppRefName?: ReadonlyMap<string, ReadonlyMap<string, string>>;
|
|
21
29
|
/** Build-time tolerance for stale labels retained by pulled automations. */
|
|
22
30
|
readonly allowUnknownPicklistOptions?: boolean;
|
|
23
31
|
readonly orgRefs?: OrgRefLookup;
|