@elementumai/edk 0.9.7 → 0.9.10
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 +3 -2
- package/dist-sdk/src/catalog/factories.d.ts +14 -3
- package/dist-sdk/src/catalog/factories.js +32 -0
- package/dist-sdk/src/catalog/from-authoring.js +27 -33
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +2 -2
- package/dist-sdk/src/catalog/org.js +67 -29
- package/dist-sdk/src/catalog/token.js +10 -0
- package/dist-sdk/src/catalog/types.d.ts +20 -2
- package/dist-sdk/src/catalog/types.js +5 -0
- package/dist-sdk/src/core/index.d.ts +1 -1
- package/dist-sdk/src/core/index.js +1 -1
- package/dist-sdk/src/core/platform-id.d.ts +2 -0
- package/dist-sdk/src/core/platform-id.js +4 -0
- package/dist-sdk/src/core/system-fields.d.ts +14 -0
- package/dist-sdk/src/core/system-fields.js +6 -0
- package/dist-sdk/src/core/triggers/on-demand.d.ts +27 -24
- package/dist-sdk/src/core/triggers/on-demand.js +33 -12
- package/dist-sdk/src/core/types/aspect-category.d.ts +1 -0
- package/dist-sdk/src/core/types/aspect-category.js +1 -0
- package/dist-sdk/src/engine/build/context.d.ts +22 -8
- package/dist-sdk/src/engine/build/source-context.d.ts +14 -17
- package/dist-sdk/src/engine/build/source-context.js +1 -1
- package/dist-sdk/src/engine/pull/context.d.ts +9 -0
- package/dist-sdk/src/engine/pull/org.d.ts +4 -0
- package/dist-sdk/src/engine/pull/org.js +17 -2
- package/dist-sdk/src/engine/pull/procedure-refs.d.ts +16 -0
- package/dist-sdk/src/engine/pull/procedure-refs.js +69 -0
- package/dist-sdk/src/engine/tf/expr.js +1 -1
- package/dist-sdk/src/engine/workspace/authoring-layout.d.ts +15 -0
- package/dist-sdk/src/engine/workspace/authoring-layout.js +33 -1
- package/dist-sdk/src/engine/workspace/loader.d.ts +40 -0
- package/dist-sdk/src/engine/workspace/loader.js +328 -0
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +4 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +10 -2
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +7 -2
- package/dist-sdk/src/entities/agent/build.d.ts +54 -8
- package/dist-sdk/src/entities/agent/build.js +36 -1
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +126 -2
- package/dist-sdk/src/entities/agent/from-tf.d.ts +7 -6
- package/dist-sdk/src/entities/agent/from-tf.js +176 -5
- package/dist-sdk/src/entities/agent/index.d.ts +2 -2
- package/dist-sdk/src/entities/agent/index.js +1 -1
- package/dist-sdk/src/entities/agent/to-tf.d.ts +4 -4
- package/dist-sdk/src/entities/agent/to-tf.js +185 -11
- package/dist-sdk/src/entities/agent/tools.d.ts +16 -5
- package/dist-sdk/src/entities/agent/tools.js +13 -1
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +7 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.js +29 -4
- package/dist-sdk/src/entities/agent-tool/to-tf.js +10 -9
- package/dist-sdk/src/entities/agent-tool/types.js +1 -0
- package/dist-sdk/src/entities/app/build.d.ts +2 -2
- package/dist-sdk/src/entities/app/build.js +6 -3
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +5 -0
- package/dist-sdk/src/entities/app/display-blocks-to-layout.d.ts +45 -0
- package/dist-sdk/src/entities/app/display-blocks-to-layout.js +98 -0
- package/dist-sdk/src/entities/app/display-blocks-to-record-create-form.d.ts +55 -0
- package/dist-sdk/src/entities/app/display-blocks-to-record-create-form.js +99 -0
- package/dist-sdk/src/entities/app/from-tf.js +9 -7
- package/dist-sdk/src/entities/app/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/app/to-tf.js +17 -7
- package/dist-sdk/src/entities/automation/build.d.ts +8 -1
- package/dist-sdk/src/entities/automation/build.js +36 -5
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +3 -7
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +2 -0
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +140 -12
- package/dist-sdk/src/entities/automation/from-tf.d.ts +10 -1
- package/dist-sdk/src/entities/automation/from-tf.js +803 -62
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/module.js +13 -3
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +12 -4
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +17 -6
- package/dist-sdk/src/entities/automation/script-code.d.ts +8 -1
- package/dist-sdk/src/entities/automation/script-code.js +32 -14
- package/dist-sdk/src/entities/automation/task-label.d.ts +2 -0
- package/dist-sdk/src/entities/automation/task-label.js +18 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +60 -9
- package/dist-sdk/src/entities/automation/tasks.js +16 -4
- package/dist-sdk/src/entities/automation/to-tf.d.ts +4 -0
- package/dist-sdk/src/entities/automation/to-tf.js +394 -52
- package/dist-sdk/src/entities/automation/triggers.d.ts +14 -5
- package/dist-sdk/src/entities/automation/triggers.js +1 -1
- package/dist-sdk/src/entities/dashboard/from-tf.js +1 -1
- 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/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +1 -1
- package/dist-sdk/src/entities/element/build.d.ts +30 -7
- package/dist-sdk/src/entities/element/build.js +6 -3
- package/dist-sdk/src/entities/element/from-tf.js +7 -3
- package/dist-sdk/src/entities/element/index.d.ts +1 -1
- package/dist-sdk/src/entities/element/index.js +1 -1
- package/dist-sdk/src/entities/element/to-tf.js +49 -8
- package/dist-sdk/src/entities/field/from-tf.d.ts +6 -0
- package/dist-sdk/src/entities/field/from-tf.js +12 -0
- package/dist-sdk/src/entities/field/module.js +1 -0
- package/dist-sdk/src/entities/field/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/field/to-tf.js +19 -5
- package/dist-sdk/src/entities/org/category-ref.d.ts +5 -0
- package/dist-sdk/src/entities/org/category-ref.js +12 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -3
- package/dist-sdk/src/entities/record-create-form/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/record-create-form/to-tf.js +13 -5
- package/dist-sdk/src/entities/relationship/from-tf.js +15 -4
- package/dist-sdk/src/entities/role/from-tf.js +10 -4
- package/dist-sdk/src/entities/search-table/build.d.ts +1 -1
- package/dist-sdk/src/entities/search-table/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/search-table/from-tf.js +6 -0
- package/dist-sdk/src/entities/search-table/printer.js +3 -1
- package/dist-sdk/src/entities/search-table/to-tf.js +3 -3
- package/dist-sdk/src/entities/search-table/types.js +1 -0
- package/dist-sdk/src/entities/service-account/from-tf.js +10 -4
- package/dist-sdk/src/entities/service-account/to-tf.d.ts +2 -1
- package/dist-sdk/src/entities/service-account/to-tf.js +7 -0
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +7 -1
- package/dist-sdk/src/entities/shared/filters/ast.js +3 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +7 -1
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +8 -4
- package/dist-sdk/src/entities/shared/handle-description.d.ts +12 -0
- package/dist-sdk/src/entities/shared/handle-description.js +20 -0
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +6 -1
- package/dist-sdk/src/entities/shared/types/field-types.js +5 -8
- package/dist-sdk/src/entities/skill/build.d.ts +51 -2
- package/dist-sdk/src/entities/skill/build.js +65 -8
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +35 -3
- package/dist-sdk/src/entities/skill/from-tf.d.ts +11 -0
- package/dist-sdk/src/entities/skill/from-tf.js +39 -7
- package/dist-sdk/src/entities/skill/index.d.ts +1 -1
- package/dist-sdk/src/entities/skill/index.js +1 -1
- package/dist-sdk/src/entities/skill/input-coverage.d.ts +21 -0
- package/dist-sdk/src/entities/skill/input-coverage.js +148 -5
- package/dist-sdk/src/entities/skill/to-tf.d.ts +6 -25
- package/dist-sdk/src/entities/skill/to-tf.js +22 -38
- package/dist-sdk/src/entities/skill/tools.d.ts +2 -1
- package/dist-sdk/src/entities/skill/tools.js +3 -1
- package/dist-sdk/src/entities/skill-tool/from-tf.js +10 -3
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +5 -5
- package/dist-sdk/src/entities/skill-tool/to-tf.js +5 -7
- package/dist-sdk/src/entities/table/to-tf.js +3 -4
- package/dist-sdk/src/entities/task/to-tf.js +3 -2
- package/dist-sdk/src/entities/view/from-tf.js +36 -10
- package/dist-sdk/src/entities/view/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/view/to-tf.js +44 -30
- package/dist-sdk/src/entities/widget/from-tf.js +2 -2
- package/dist-sdk/src/entities/widget/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/widget/to-tf.js +52 -23
- package/dist-sdk/src/graph/index.d.ts +19 -1
- package/dist-sdk/src/graph/index.js +20 -0
- package/dist-sdk/src/graph/types.d.ts +19 -0
- package/package.json +10 -5
|
@@ -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.
|
|
@@ -88,6 +89,7 @@ const TASK_FACTORY_V2 = {
|
|
|
88
89
|
aiClassify: "aiClassify",
|
|
89
90
|
generateReport: "generateReport",
|
|
90
91
|
unzip: "unzip",
|
|
92
|
+
unimplementedTask: "unimplementedTask",
|
|
91
93
|
};
|
|
92
94
|
/**
|
|
93
95
|
* Per-factory arg-key renames: v1 AST arg name → v2 factory option name. The
|
|
@@ -108,8 +110,17 @@ const ARG_RENAMES = {
|
|
|
108
110
|
saveAttachment: { recordRef: "record" },
|
|
109
111
|
documentModel: { recordRef: "record", documentModel: "fileReader" },
|
|
110
112
|
initiateEmailConversation: { recordRef: "record" },
|
|
113
|
+
initiateCall: { recordId: "record", defaultLanguage: "language" },
|
|
111
114
|
generateReport: { recordRef: "record" },
|
|
112
115
|
};
|
|
116
|
+
const REVISION_PROPERTY = /^([ \t]*revision[ \t]*:[ \t]*)(["'`])([^"'`\r\n]+)\2[ \t]*,?[ \t]*$/m;
|
|
117
|
+
/** Keep the authored publish token across pull; live workflow versions are not author intent. */
|
|
118
|
+
export function preserveAuthoredAutomationRevision(freshSource, existingSource) {
|
|
119
|
+
const authored = REVISION_PROPERTY.exec(existingSource)?.[3];
|
|
120
|
+
if (authored === undefined || authored === "")
|
|
121
|
+
return freshSource;
|
|
122
|
+
return freshSource.replace(REVISION_PROPERTY, (_line, prefix) => `${prefix}${JSON.stringify(authored)},`);
|
|
123
|
+
}
|
|
113
124
|
function emptyImports() {
|
|
114
125
|
return {
|
|
115
126
|
filterOps: new Set(),
|
|
@@ -291,18 +302,19 @@ function printTrigger(trigger, state) {
|
|
|
291
302
|
const optionParts = [];
|
|
292
303
|
if (trigger.showTriggeredBy === true)
|
|
293
304
|
optionParts.push("showTriggeredBy: true");
|
|
294
|
-
if (trigger.hasRecord === true)
|
|
295
|
-
optionParts.push("record: true");
|
|
296
305
|
const optionsSuffix = optionParts.length > 0 ? `, { ${optionParts.join(", ")} }` : "";
|
|
297
306
|
if (trigger.inputs.length === 0)
|
|
298
307
|
return `${onDemand}({}${optionsSuffix})`;
|
|
299
308
|
const lines = trigger.inputs.map((i) => {
|
|
300
309
|
const parts = [`type: ${quote(i.type)}`];
|
|
310
|
+
if (i.type === "record" && i.app !== undefined) {
|
|
311
|
+
parts.push(`app: ${printRef(i.app, state, DEFAULT_CTX)}`);
|
|
312
|
+
}
|
|
301
313
|
if (i.required)
|
|
302
314
|
parts.push(`required: ${i.required}`);
|
|
303
315
|
if (i.multiple)
|
|
304
316
|
parts.push(`multiple: ${i.multiple}`);
|
|
305
|
-
if (i.defaultValue !== undefined && i.defaultValue !== null) {
|
|
317
|
+
if (i.type !== "record" && i.defaultValue !== undefined && i.defaultValue !== null) {
|
|
306
318
|
parts.push(`defaultValue: ${literalJson(i.defaultValue)}`);
|
|
307
319
|
}
|
|
308
320
|
if (i.description !== undefined)
|
|
@@ -360,11 +372,21 @@ function printTrigger(trigger, state) {
|
|
|
360
372
|
}
|
|
361
373
|
case "approvalProcessStatusUpdated": {
|
|
362
374
|
const approvalProcessStatusUpdated = trackFactory("approvalProcessStatusUpdated", state);
|
|
375
|
+
let approvalChain;
|
|
376
|
+
if (typeof trigger.approvalChain === "string") {
|
|
377
|
+
// Genuinely unreconstructable (a literal id, not a managed
|
|
378
|
+
// `elementum_approval_process` reference) - same escape hatch as
|
|
379
|
+
// dataMine's raw datamine id, never a bare string on the public
|
|
380
|
+
// typed option (edk#741 review).
|
|
381
|
+
state.imports.usesUnsafePlatformId = true;
|
|
382
|
+
approvalChain = `unsafePlatformId(${quote(trigger.approvalChain)})${unresolvedReferenceComment(trigger.approvalChain, state.unresolvedReferences)}`;
|
|
383
|
+
}
|
|
384
|
+
else if (trigger.approvalChain !== undefined) {
|
|
385
|
+
approvalChain = printRef(trigger.approvalChain, state, DEFAULT_CTX);
|
|
386
|
+
}
|
|
363
387
|
const parts = [
|
|
364
388
|
`app: ${printRef(trigger.app, state, DEFAULT_CTX)}`,
|
|
365
|
-
`approvalChain: ${
|
|
366
|
-
? quote(trigger.approvalChain)
|
|
367
|
-
: printRef(trigger.approvalChain, state, DEFAULT_CTX)}`,
|
|
389
|
+
...(approvalChain !== undefined ? [`approvalChain: ${approvalChain}`] : []),
|
|
368
390
|
`status: ${quote(trigger.status)}`,
|
|
369
391
|
];
|
|
370
392
|
return `${approvalProcessStatusUpdated}({\n ${parts.join(",\n ")}\n })`;
|
|
@@ -489,11 +511,26 @@ function formatExecuteScript(task, state, indent, refCtx = DEFAULT_CTX) {
|
|
|
489
511
|
const configPad = " ".repeat(indent + 1);
|
|
490
512
|
const lines = [];
|
|
491
513
|
if (task.args.inputs !== undefined && task.args.inputs !== null && typeof task.args.inputs === "object") {
|
|
492
|
-
|
|
514
|
+
// The platform can retain an execute-script input name after its value
|
|
515
|
+
// reference has disappeared. Terraform accepts that as an omitted
|
|
516
|
+
// optional `value`, but provider read normalizes it to an empty string.
|
|
517
|
+
// Use that same current-API literal in pulled source: JavaScript
|
|
518
|
+
// `undefined` cannot build, and `null` would create adoption drift against
|
|
519
|
+
// the normalized state. Dropping the property would also drop the
|
|
520
|
+
// platform-owned input name on the next apply.
|
|
521
|
+
const inputs = Object.fromEntries(Object.entries(task.args.inputs)
|
|
522
|
+
.map(([name, value]) => [name,
|
|
523
|
+
value === undefined || (value !== null &&
|
|
524
|
+
typeof value === "object" &&
|
|
525
|
+
value.kind === "literal" &&
|
|
526
|
+
value.value === undefined) ? "" : value,
|
|
527
|
+
]));
|
|
528
|
+
const obj = printObjectLiteral(inputs, state, indent + 1, refCtx);
|
|
493
529
|
lines.push(`${configPad}inputs: (${lambdaParams(obj, "ctx")}) => (${obj}),`);
|
|
494
530
|
}
|
|
495
531
|
const code = task.args.code ?? task.args.script;
|
|
496
532
|
if (typeof code === "string") {
|
|
533
|
+
lines.push(`${configPad}// @ts-ignore`);
|
|
497
534
|
lines.push(`${configPad}code: ${printScriptCodeFn(code, indent + 1, state)},`);
|
|
498
535
|
}
|
|
499
536
|
if (task.args.outputs !== undefined && task.args.outputs !== null && typeof task.args.outputs === "object") {
|
|
@@ -515,7 +552,7 @@ function formatExecuteScript(task, state, indent, refCtx = DEFAULT_CTX) {
|
|
|
515
552
|
* `code:` is always a real function (#125 banned a raw-string alternative).
|
|
516
553
|
* This writes the body's text into the `.ts` source verbatim; byte-fidelity
|
|
517
554
|
* through the SUBSEQUENT `elementum build` (which would otherwise reformat
|
|
518
|
-
* it via
|
|
555
|
+
* it via a `toString()` on the loaded function) is handled separately at
|
|
519
556
|
* build time by `tryExtractFromCurrentSource` (`script-code.ts`), which reads
|
|
520
557
|
* this exact source text back out directly rather than trusting the
|
|
521
558
|
* transpiled runtime function.
|
|
@@ -532,11 +569,79 @@ function formatExecuteScript(task, state, indent, refCtx = DEFAULT_CTX) {
|
|
|
532
569
|
* references. Hand-authored `.executeScript` calls are unaffected — they
|
|
533
570
|
* still get full inference since they never pass this printer.
|
|
534
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
|
+
}
|
|
535
642
|
function printScriptCodeFn(body, indent, state) {
|
|
536
643
|
const pad = " ".repeat(indent);
|
|
537
|
-
const
|
|
538
|
-
const lines = body.replace(/\r\n/g, "\n").split("\n");
|
|
539
|
-
const indented = lines.map((line) => (line.length === 0 ? "" : `${innerPad}${line}`)).join("\n");
|
|
644
|
+
const indented = annotateScriptLines(body, indent + 1);
|
|
540
645
|
state.imports.usesScriptInput = true;
|
|
541
646
|
return `(input: ScriptInput<Record<string, unknown>>) => {\n${indented}\n${pad}}`;
|
|
542
647
|
}
|
|
@@ -660,6 +765,21 @@ function printTaskArgs(task, state, indent, refCtx) {
|
|
|
660
765
|
continue;
|
|
661
766
|
}
|
|
662
767
|
const outKey = renames[k] ?? k;
|
|
768
|
+
if (task.factory === "aiSearchTable" && (k === "table" || outKey === "table")) {
|
|
769
|
+
if (typeof v === "string" || (isRefExpr(v) && v.kind === "unresolved")) {
|
|
770
|
+
const uuid = typeof v === "string" ? v : v.uuid;
|
|
771
|
+
state.imports.usesUnsafePlatformId = true;
|
|
772
|
+
lines.push(`${pad}${safeKey(outKey)}: unsafePlatformId(${quote(uuid)})${unresolvedReferenceComment(uuid, state.unresolvedReferences)},`);
|
|
773
|
+
continue;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
// unimplementedTask's `id` is always a raw platform id — the referenced
|
|
777
|
+
// task has no CRUD, so there's never a portable typed ref to print instead.
|
|
778
|
+
if (task.factory === "unimplementedTask" && k === "id" && typeof v === "string") {
|
|
779
|
+
state.imports.usesUnsafePlatformId = true;
|
|
780
|
+
lines.push(`${pad}${safeKey(outKey)}: unsafePlatformId(${quote(v)}),`);
|
|
781
|
+
continue;
|
|
782
|
+
}
|
|
663
783
|
lines.push(`${pad}${safeKey(outKey)}: ${printArgValue(k, v, state, indent + 1, refCtx)},`);
|
|
664
784
|
}
|
|
665
785
|
if (lines.length === 0)
|
|
@@ -877,6 +997,8 @@ function printRef(ref, state, refCtx) {
|
|
|
877
997
|
return `catalog.tables${safeMember(ref.tableHandle)}`;
|
|
878
998
|
case "tableColumn":
|
|
879
999
|
return `catalog.tables${safeMember(ref.tableHandle)}.columns${safeMember(ref.columnKey)}`;
|
|
1000
|
+
case "searchTable":
|
|
1001
|
+
return `catalog.${ref.appHandle}.searchTables${safeMember(ref.tableKey)}`;
|
|
880
1002
|
case "user":
|
|
881
1003
|
return `${trackFactory("userRef", state)}(${quote(ref.email)})`;
|
|
882
1004
|
case "documentModel":
|
|
@@ -911,6 +1033,8 @@ function printRef(ref, state, refCtx) {
|
|
|
911
1033
|
}
|
|
912
1034
|
case "cloudLink":
|
|
913
1035
|
return `catalog.cloudLinks${safeMember(ref.handle)}`;
|
|
1036
|
+
case "procedure":
|
|
1037
|
+
return `catalog.cloudLinks${safeMember(ref.cloudLinkKey)}.procedures${safeMember(ref.procedureKey)}`;
|
|
914
1038
|
case "unresolved":
|
|
915
1039
|
// v2 value slots accept a literal directly — no `val()` wrapper. But this
|
|
916
1040
|
// RefExpr kind is also the fallback for ref-typed positions (automation,
|
|
@@ -999,7 +1123,11 @@ function printObjectLiteral(obj, state, indent, refCtx) {
|
|
|
999
1123
|
if (entries.length === 0)
|
|
1000
1124
|
return "{}";
|
|
1001
1125
|
const pad = " ".repeat(indent);
|
|
1002
|
-
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
|
+
});
|
|
1003
1131
|
return `{\n${lines.join("\n")}\n${" ".repeat(indent - 1)}}`;
|
|
1004
1132
|
}
|
|
1005
1133
|
function printArrayLiteral(arr, state, indent, refCtx) {
|
|
@@ -5,6 +5,13 @@ export interface AutomationFromTfResult {
|
|
|
5
5
|
readonly tfLabel: string;
|
|
6
6
|
readonly ast: AutomationAst;
|
|
7
7
|
readonly blocks: readonly TfBlock[];
|
|
8
|
+
/** Export address → address rebuilt from the printed current API. */
|
|
9
|
+
readonly adoptionAddressAliases: readonly {
|
|
10
|
+
readonly from: string;
|
|
11
|
+
readonly to: string;
|
|
12
|
+
}[];
|
|
13
|
+
/** Non-fatal issues found while extracting (edk#785: a task anchored to the trigger because its real parent is unsupported). */
|
|
14
|
+
readonly diagnostics?: readonly string[];
|
|
8
15
|
}
|
|
9
16
|
/**
|
|
10
17
|
* Best-effort resource footprint of one automation, used ONLY when whole-
|
|
@@ -30,6 +37,7 @@ export interface AutomationFromTfContext {
|
|
|
30
37
|
readonly ownerRefName: string;
|
|
31
38
|
readonly fieldKey: string;
|
|
32
39
|
readonly fieldName?: string;
|
|
40
|
+
readonly fieldType?: string;
|
|
33
41
|
}>;
|
|
34
42
|
readonly foreignFieldRefsByDataAddress?: ReadonlyMap<string, {
|
|
35
43
|
readonly ownerRefName: string;
|
|
@@ -43,6 +51,7 @@ export interface AutomationFromTfContext {
|
|
|
43
51
|
readonly fieldNamesByOwnerRefName?: ReadonlyMap<string, ReadonlyMap<string, string>>;
|
|
44
52
|
readonly foreignAppRefNames?: ReadonlyMap<string, string>;
|
|
45
53
|
readonly foreignElementRefNames?: ReadonlyMap<string, string>;
|
|
54
|
+
readonly procedureKeysByDiscriminator?: ReadonlyMap<string, string>;
|
|
46
55
|
}
|
|
47
56
|
export interface AutomationGraphFromTfResult {
|
|
48
57
|
readonly automation?: AutomationAst;
|
|
@@ -60,4 +69,4 @@ export declare function automationFromTf(doc: TfDocument, automationLabel: strin
|
|
|
60
69
|
}>, foreignTableRefsById?: ReadonlyMap<string, {
|
|
61
70
|
readonly tableRefName: string;
|
|
62
71
|
readonly name: string;
|
|
63
|
-
}>, picklistOptionLabelById?: ReadonlyMap<string, string>, fieldNamesByOwnerRefName?: ReadonlyMap<string, ReadonlyMap<string, string>>, foreignAppRefNames?: ReadonlyMap<string, string>, foreignElementRefNames?: ReadonlyMap<string, string>): AutomationFromTfResult;
|
|
72
|
+
}>, picklistOptionLabelById?: ReadonlyMap<string, string>, fieldNamesByOwnerRefName?: ReadonlyMap<string, ReadonlyMap<string, string>>, foreignAppRefNames?: ReadonlyMap<string, string>, foreignElementRefNames?: ReadonlyMap<string, string>, procedureKeysByDiscriminator?: ReadonlyMap<string, string>): AutomationFromTfResult;
|