@elementumai/edk 0.9.20 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -7
- package/dist-sdk/src/catalog/factories.d.ts +10 -2
- package/dist-sdk/src/catalog/factories.js +10 -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 +4 -0
- package/dist-sdk/src/catalog/types.d.ts +7 -1
- package/dist-sdk/src/catalog/types.js +1 -0
- package/dist-sdk/src/core/triggers/on-demand.d.ts +2 -2
- package/dist-sdk/src/core/triggers/on-demand.js +7 -0
- package/dist-sdk/src/core/types/app.d.ts +2 -2
- package/dist-sdk/src/engine/coverage-gaps.d.ts +86 -0
- package/dist-sdk/src/engine/coverage-gaps.js +156 -0
- package/dist-sdk/src/engine/ei/run.d.ts +21 -1
- package/dist-sdk/src/engine/ei/run.js +89 -2
- package/dist-sdk/src/engine/pull/catalog-ref.d.ts +16 -0
- package/dist-sdk/src/engine/pull/catalog-ref.js +24 -0
- package/dist-sdk/src/engine/pull/context.d.ts +68 -6
- package/dist-sdk/src/engine/pull/context.js +40 -1
- package/dist-sdk/src/engine/pull/procedure-refs.d.ts +8 -0
- package/dist-sdk/src/engine/pull/procedure-refs.js +28 -0
- package/dist-sdk/src/engine/pull/result-output.js +27 -1
- package/dist-sdk/src/engine/tf/index.d.ts +1 -1
- package/dist-sdk/src/engine/tf/index.js +1 -1
- package/dist-sdk/src/engine/tf/labels.d.ts +22 -5
- package/dist-sdk/src/engine/tf/labels.js +45 -3
- package/dist-sdk/src/engine/tf/parse.js +3 -2
- package/dist-sdk/src/engine/validation.d.ts +5 -0
- package/dist-sdk/src/engine/validation.js +12 -2
- package/dist-sdk/src/entities/access-policy/from-tf.js +38 -1
- package/dist-sdk/src/entities/access-policy/principal.d.ts +2 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +3 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +42 -19
- package/dist-sdk/src/entities/agent/from-tf.js +11 -3
- package/dist-sdk/src/entities/agent/module.js +2 -0
- package/dist-sdk/src/entities/agent/to-tf.js +14 -3
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +8 -1
- package/dist-sdk/src/entities/agent-tool/from-tf.js +11 -5
- package/dist-sdk/src/entities/agent-tool/module.js +3 -0
- package/dist-sdk/src/entities/app/auto-share.d.ts +38 -0
- package/dist-sdk/src/entities/app/auto-share.js +49 -0
- package/dist-sdk/src/entities/app/build.d.ts +17 -3
- package/dist-sdk/src/entities/app/build.js +56 -4
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +6 -1
- package/dist-sdk/src/entities/app/from-tf.js +4 -0
- package/dist-sdk/src/entities/app/index.d.ts +2 -1
- package/dist-sdk/src/entities/app/index.js +1 -8
- package/dist-sdk/src/entities/app/to-tf.d.ts +6 -0
- package/dist-sdk/src/entities/app/to-tf.js +21 -2
- package/dist-sdk/src/entities/automation/build.d.ts +10 -2
- package/dist-sdk/src/entities/automation/build.js +104 -17
- package/dist-sdk/src/entities/automation/calculation-expression.d.ts +7 -7
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +17 -4
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +156 -19
- package/dist-sdk/src/entities/automation/from-tf.d.ts +9 -2
- package/dist-sdk/src/entities/automation/from-tf.js +366 -86
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/index.js +1 -1
- package/dist-sdk/src/entities/automation/module.d.ts +3 -0
- package/dist-sdk/src/entities/automation/module.js +70 -7
- package/dist-sdk/src/entities/automation/script-code.d.ts +5 -2
- package/dist-sdk/src/entities/automation/script-code.js +23 -5
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +37 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +76 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +92 -20
- package/dist-sdk/src/entities/automation/tasks.js +48 -15
- package/dist-sdk/src/entities/automation/to-tf.d.ts +20 -3
- package/dist-sdk/src/entities/automation/to-tf.js +606 -62
- package/dist-sdk/src/entities/automation/triggers.d.ts +8 -4
- package/dist-sdk/src/entities/automation/types.d.ts +9 -0
- package/dist-sdk/src/entities/automation/types.js +19 -0
- package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +1 -1
- package/dist-sdk/src/entities/automation/value-ref-tf.js +1 -1
- package/dist-sdk/src/entities/chart/from-tf.js +9 -1
- package/dist-sdk/src/entities/data-lookup/module.js +2 -0
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +7 -5
- package/dist-sdk/src/entities/element/build.d.ts +3 -0
- package/dist-sdk/src/entities/element/build.js +1 -0
- package/dist-sdk/src/entities/element/from-tf.js +4 -0
- package/dist-sdk/src/entities/element/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/element/to-tf.js +8 -14
- package/dist-sdk/src/entities/field/build.d.ts +3 -2
- package/dist-sdk/src/entities/field/calc.d.ts +7 -7
- package/dist-sdk/src/entities/field/from-tf.d.ts +4 -4
- package/dist-sdk/src/entities/field/from-tf.js +205 -48
- package/dist-sdk/src/entities/field/module.js +1 -0
- package/dist-sdk/src/entities/field/options.js +6 -1
- package/dist-sdk/src/entities/field/to-tf.d.ts +4 -4
- package/dist-sdk/src/entities/field/to-tf.js +7 -1
- package/dist-sdk/src/entities/field/types.d.ts +2 -0
- package/dist-sdk/src/entities/field/types.js +27 -0
- package/dist-sdk/src/entities/role/from-tf.js +3 -3
- package/dist-sdk/src/entities/role/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/role/to-tf.js +12 -4
- package/dist-sdk/src/entities/service-account/from-tf.js +3 -3
- package/dist-sdk/src/entities/service-account/workspace-owner.d.ts +16 -0
- package/dist-sdk/src/entities/service-account/workspace-owner.js +22 -0
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +15 -1
- package/dist-sdk/src/entities/shared/filters/ast.js +2 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +5 -0
- package/dist-sdk/src/entities/shared/filters/index.js +5 -0
- package/dist-sdk/src/entities/shared/filters/print.js +7 -2
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +5 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +42 -7
- package/dist-sdk/src/entities/shared/filters/types.d.ts +8 -3
- package/dist-sdk/src/entities/shared/ref.d.ts +5 -7
- package/dist-sdk/src/entities/shared/ref.js +5 -7
- package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +9 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.js +35 -2
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +10 -0
- package/dist-sdk/src/entities/shared/types/field-types.js +4 -0
- package/dist-sdk/src/entities/skill/access-policy.js +3 -3
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +3 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +12 -5
- package/dist-sdk/src/entities/skill/from-tf.js +4 -2
- package/dist-sdk/src/entities/skill/module.js +2 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +41 -8
- package/dist-sdk/src/entities/skill-tool/module.js +3 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +0 -6
- package/dist-sdk/src/entities/skill-tool/to-tf.js +22 -9
- package/dist-sdk/src/entities/task/build.d.ts +8 -0
- package/dist-sdk/src/entities/task/build.js +10 -1
- package/dist-sdk/src/entities/task/from-tf.d.ts +4 -2
- package/dist-sdk/src/entities/task/from-tf.js +7 -2
- package/dist-sdk/src/entities/task/module.js +2 -2
- package/dist-sdk/src/entities/task/to-tf.d.ts +8 -4
- package/dist-sdk/src/entities/task/to-tf.js +28 -1
- package/dist-sdk/src/entities/view/from-tf.js +9 -1
- package/dist-sdk/src/entities/view/to-tf.d.ts +6 -7
- package/dist-sdk/src/entities/view/to-tf.js +19 -8
- package/dist-sdk/src/entities/visual-flow/build.d.ts +16 -1
- package/dist-sdk/src/entities/visual-flow/build.js +9 -0
- package/dist-sdk/src/entities/visual-flow/from-tf.d.ts +14 -0
- package/dist-sdk/src/entities/visual-flow/from-tf.js +51 -3
- package/dist-sdk/src/entities/visual-flow/index.d.ts +1 -1
- package/dist-sdk/src/entities/visual-flow/index.js +1 -1
- package/dist-sdk/src/entities/visual-flow/printer.js +19 -0
- package/dist-sdk/src/entities/visual-flow/to-tf.js +87 -3
- package/dist-sdk/src/entities/widget/from-tf.js +3 -3
- package/dist-sdk/src/entities/widget/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/widget/to-tf.js +7 -6
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +133 -9
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +1 -0
- package/dist-sdk/src/graph/types.d.ts +29 -3
- package/package.json +7 -3
|
@@ -35,6 +35,7 @@ import { sdkPackageSpecifier } from "../../../internal/sdk-package.js";
|
|
|
35
35
|
import { safeIdentifier } from "../../../internal/safe-identifier.js";
|
|
36
36
|
import { isRefExpr } from "../../shared/filters/ast.js";
|
|
37
37
|
import { printFilter as printCanonicalFilter } from "../../shared/filters/print.js";
|
|
38
|
+
import { isUuid } from "../../../engine/tf/labels.js";
|
|
38
39
|
import { UNRESOLVED_FIELD_MARKER } from "../../shared/ref.js";
|
|
39
40
|
import { UNRESOLVED_REFERENCE_MARKER } from "../filter.js";
|
|
40
41
|
import { INJECTED_TS_IGNORE, scriptFileText } from "../script-code.js";
|
|
@@ -54,6 +55,7 @@ const TASK_FACTORY_V2 = {
|
|
|
54
55
|
executeScript: "executeScript",
|
|
55
56
|
createRecord: "createRecord",
|
|
56
57
|
updateField: "updateField",
|
|
58
|
+
bulkUpdateFields: "bulkUpdateFields",
|
|
57
59
|
apiRequest: "apiRequest",
|
|
58
60
|
aiAgent: "aiAgent",
|
|
59
61
|
aiSearchTable: "aiSearchTable",
|
|
@@ -114,12 +116,64 @@ const ARG_RENAMES = {
|
|
|
114
116
|
generateReport: { recordRef: "record" },
|
|
115
117
|
};
|
|
116
118
|
const REVISION_PROPERTY = /^([ \t]*revision[ \t]*:[ \t]*)(["'`])([^"'`\r\n]+)\2[ \t]*,?[ \t]*$/m;
|
|
117
|
-
/**
|
|
118
|
-
|
|
119
|
+
/** Numeric dotted revision parts, or undefined when the token is not dotted numeric. */
|
|
120
|
+
function revisionParts(revision) {
|
|
121
|
+
if (!/^\d+(\.\d+)*$/.test(revision))
|
|
122
|
+
return undefined;
|
|
123
|
+
return revision.split(".").map(Number);
|
|
124
|
+
}
|
|
125
|
+
/** True when `a` is at least `b`; non-numeric tokens only compare equal. */
|
|
126
|
+
function revisionAtLeast(a, b) {
|
|
127
|
+
if (a === b)
|
|
128
|
+
return true;
|
|
129
|
+
const pa = revisionParts(a);
|
|
130
|
+
const pb = revisionParts(b);
|
|
131
|
+
if (pa === undefined || pb === undefined)
|
|
132
|
+
return false;
|
|
133
|
+
for (let i = 0; i < Math.max(pa.length, pb.length); i++) {
|
|
134
|
+
const d = (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
135
|
+
if (d !== 0)
|
|
136
|
+
return d > 0;
|
|
137
|
+
}
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
/** workflow_revision of the state workflow_publish whose id is `platformId`. */
|
|
141
|
+
function stateWorkflowRevision(context) {
|
|
142
|
+
if (context?.platformId === undefined || context.stateResources === undefined)
|
|
143
|
+
return undefined;
|
|
144
|
+
for (const resource of context.stateResources) {
|
|
145
|
+
if (resource.type !== "elementum_workflow_publish")
|
|
146
|
+
continue;
|
|
147
|
+
for (const instance of resource.instances ?? []) {
|
|
148
|
+
const attrs = instance.attributes;
|
|
149
|
+
if (attrs?.id === context.platformId && typeof attrs.workflow_revision === "string")
|
|
150
|
+
return attrs.workflow_revision;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Keep the authored publish token across pull; live workflow versions are not
|
|
157
|
+
* author intent (#693). The token must still agree with what state tracks, or a
|
|
158
|
+
* fresh-state pull + adopt plans a republish that downgrades the live revision
|
|
159
|
+
* (#1590): adoption imports the live revision, and the provider's Read keeps
|
|
160
|
+
* whatever revision state holds. So the authored token wins only when it is at
|
|
161
|
+
* least the baseline — the state revision, or the freshly printed live revision
|
|
162
|
+
* when state has no entry yet (adoption is about to import it). An older
|
|
163
|
+
* authored token is replaced by that baseline. Without readable state the
|
|
164
|
+
* pre-#1590 behaviour (always keep authored) is unchanged.
|
|
165
|
+
*/
|
|
166
|
+
export function preserveAuthoredAutomationRevision(freshSource, existingSource, context) {
|
|
119
167
|
const authored = REVISION_PROPERTY.exec(existingSource)?.[3];
|
|
120
168
|
if (authored === undefined || authored === "")
|
|
121
169
|
return freshSource;
|
|
122
|
-
|
|
170
|
+
let keep = authored;
|
|
171
|
+
if (context?.stateResources !== undefined) {
|
|
172
|
+
const baseline = stateWorkflowRevision(context) ?? REVISION_PROPERTY.exec(freshSource)?.[3];
|
|
173
|
+
if (baseline !== undefined && !revisionAtLeast(authored, baseline))
|
|
174
|
+
keep = baseline;
|
|
175
|
+
}
|
|
176
|
+
return freshSource.replace(REVISION_PROPERTY, (_line, prefix) => `${prefix}${JSON.stringify(keep)},`);
|
|
123
177
|
}
|
|
124
178
|
/** Index just past the string literal opening at `i` (`'` or `"`), or -1 when unterminated. */
|
|
125
179
|
function skipQuoted(source, i) {
|
|
@@ -448,8 +502,8 @@ export function preserveAuthoredAutomationDescription(freshSource, existingSourc
|
|
|
448
502
|
return freshSource;
|
|
449
503
|
}
|
|
450
504
|
/** Pull merge: preserve authored revision + description across live reprint. */
|
|
451
|
-
export function preserveAuthoredAutomationPullMeta(freshSource, existingSource) {
|
|
452
|
-
return preserveAuthoredAutomationDescription(preserveAuthoredAutomationRevision(freshSource, existingSource), existingSource);
|
|
505
|
+
export function preserveAuthoredAutomationPullMeta(freshSource, existingSource, context) {
|
|
506
|
+
return preserveAuthoredAutomationDescription(preserveAuthoredAutomationRevision(freshSource, existingSource, context), existingSource);
|
|
453
507
|
}
|
|
454
508
|
function emptyImports() {
|
|
455
509
|
return {
|
|
@@ -457,6 +511,7 @@ function emptyImports() {
|
|
|
457
511
|
factories: new Set(),
|
|
458
512
|
aliases: new Map(),
|
|
459
513
|
usesTemplate: false,
|
|
514
|
+
usesSecret: false,
|
|
460
515
|
usesUnresolvedField: false,
|
|
461
516
|
usesUnsafePlatformId: false,
|
|
462
517
|
usesOrg: false,
|
|
@@ -573,6 +628,8 @@ function printAutomation(ast, opts, externalScripts) {
|
|
|
573
628
|
taskFactoriesByRefKey,
|
|
574
629
|
...(opts.foreignAppRefNames !== undefined && { foreignAppRefNames: opts.foreignAppRefNames }),
|
|
575
630
|
...(opts.foreignElementRefNames !== undefined && { foreignElementRefNames: opts.foreignElementRefNames }),
|
|
631
|
+
...(opts.foreignAppRefNamespaces !== undefined && { foreignAppRefNamespaces: opts.foreignAppRefNamespaces }),
|
|
632
|
+
...(opts.foreignElementRefNamespaces !== undefined && { foreignElementRefNamespaces: opts.foreignElementRefNamespaces }),
|
|
576
633
|
...(opts.foreignTaskRefNames !== undefined && { foreignTaskRefNames: opts.foreignTaskRefNames }),
|
|
577
634
|
};
|
|
578
635
|
const triggerCode = printTrigger(ast.trigger, state);
|
|
@@ -706,8 +763,10 @@ function renderHeader(ast, imports, _opts) {
|
|
|
706
763
|
if (imports.usesTableSearchTableRef) {
|
|
707
764
|
lines.push(`import { tableSearchTableRef } from "${sdkPackageSpecifier("catalog")}";`);
|
|
708
765
|
}
|
|
709
|
-
if (imports.usesTemplate || imports.usesUnresolvedField || imports.usesUnsafePlatformId || imports.usesRefType) {
|
|
766
|
+
if (imports.usesSecret || imports.usesTemplate || imports.usesUnresolvedField || imports.usesUnsafePlatformId || imports.usesRefType) {
|
|
710
767
|
const coreNamed = [];
|
|
768
|
+
if (imports.usesSecret)
|
|
769
|
+
coreNamed.push("secret");
|
|
711
770
|
if (imports.usesTemplate)
|
|
712
771
|
coreNamed.push("template");
|
|
713
772
|
if (imports.usesUnresolvedField)
|
|
@@ -1247,7 +1306,7 @@ function printTaskArgs(task, state, indent, refCtx) {
|
|
|
1247
1306
|
const lines = [];
|
|
1248
1307
|
for (const [k, v] of Object.entries(task.args)) {
|
|
1249
1308
|
// createRecord / updateField field-value maps → v2 `fields` array.
|
|
1250
|
-
if (k === "values" && (task.factory === "createRecord" || task.factory === "updateField")) {
|
|
1309
|
+
if (k === "values" && (task.factory === "createRecord" || task.factory === "updateField" || task.factory === "bulkUpdateFields")) {
|
|
1251
1310
|
lines.push(`${pad}fields: ${printFieldAssignments(v, target, state, indent + 1, refCtx)},`);
|
|
1252
1311
|
continue;
|
|
1253
1312
|
}
|
|
@@ -1258,6 +1317,27 @@ function printTaskArgs(task, state, indent, refCtx) {
|
|
|
1258
1317
|
continue;
|
|
1259
1318
|
}
|
|
1260
1319
|
const outKey = renames[k] ?? k;
|
|
1320
|
+
const aspectId = typeof v === "string"
|
|
1321
|
+
? v
|
|
1322
|
+
: isRefExpr(v) && v.kind === "literal" && typeof v.value === "string"
|
|
1323
|
+
? v.value
|
|
1324
|
+
: undefined;
|
|
1325
|
+
if ((k === "app" || k === "relatedApp") && aspectId !== undefined && isUuid(aspectId)) {
|
|
1326
|
+
const catalogRef = state.foreignAppRefNamespaces?.get(aspectId)
|
|
1327
|
+
?? state.foreignElementRefNamespaces?.get(aspectId)
|
|
1328
|
+
?? state.foreignAppRefNames?.get(aspectId)
|
|
1329
|
+
?? state.foreignElementRefNames?.get(aspectId);
|
|
1330
|
+
if (catalogRef !== undefined) {
|
|
1331
|
+
lines.push(`${pad}${safeKey(outKey)}: catalog.${catalogRef},`);
|
|
1332
|
+
continue;
|
|
1333
|
+
}
|
|
1334
|
+
// A raw aspect id is not a workspace app. A uuid refName makes build
|
|
1335
|
+
// look up an app that does not exist, and null fails the task's load.
|
|
1336
|
+
// The platform id has no refName, so build emits it as the literal.
|
|
1337
|
+
state.imports.usesUnsafePlatformId = true;
|
|
1338
|
+
lines.push(`${pad}${safeKey(outKey)}: unsafePlatformId(${quote(aspectId)}) as any /* unresolved aspect */${unresolvedReferenceComment(aspectId, state.unresolvedReferences)},`);
|
|
1339
|
+
continue;
|
|
1340
|
+
}
|
|
1261
1341
|
if (task.factory === "aiSearchTable" && (k === "table" || outKey === "table")) {
|
|
1262
1342
|
if (typeof v === "string" || (isRefExpr(v) && v.kind === "unresolved")) {
|
|
1263
1343
|
const uuid = typeof v === "string" ? v : v.uuid;
|
|
@@ -1311,6 +1391,17 @@ function printFieldAssignments(values, target, state, indent, refCtx) {
|
|
|
1311
1391
|
fieldExpr = (`{ __kind: "field", refName: ${quote(fieldKey)}, name: ${quote(fieldName)}, fieldType: ${quote(fieldType)}, ` +
|
|
1312
1392
|
`parent: ${quote(parentRef)}, parentKind: "task", parentName: ${quote(parentName)} }`);
|
|
1313
1393
|
}
|
|
1394
|
+
else if (target !== undefined &&
|
|
1395
|
+
!target.inCatalog &&
|
|
1396
|
+
assignment?.foreignOwnerNamespace !== undefined &&
|
|
1397
|
+
!fieldKey.startsWith(UNRESOLVED_FIELD_MARKER)) {
|
|
1398
|
+
const fieldType = assignment.foreignFieldType ?? "TEXT";
|
|
1399
|
+
const parentName = assignment.foreignOwnerName ?? target.name ?? target.refName;
|
|
1400
|
+
fieldExpr = (`{ __kind: "field", refName: ${quote(fieldKey)}, name: ${quote(assignment.foreignFieldName ?? fieldKey)}, fieldType: ${quote(fieldType)}, ` +
|
|
1401
|
+
`parent: ${quote(target.refName)}, parentKind: ${quote(target.kind)}, parentName: ${quote(parentName)}, ` +
|
|
1402
|
+
`parentNamespace: ${quote(assignment.foreignOwnerNamespace)} } ` +
|
|
1403
|
+
`/* TODO: foreign field — type unconfirmed (ei's elementum_field data source doesn't expose it) and refName is a best-effort guess; verify against "${parentName}" */`);
|
|
1404
|
+
}
|
|
1314
1405
|
else if (target && !fieldKey.startsWith(UNRESOLVED_FIELD_MARKER)) {
|
|
1315
1406
|
// `taskPrimaryTarget` already remapped the owner and resolved a
|
|
1316
1407
|
// pulled foreign element. Remapping again via `catalogOwnerHandle`
|
|
@@ -1319,11 +1410,23 @@ function printFieldAssignments(values, target, state, indent, refCtx) {
|
|
|
1319
1410
|
fieldExpr = `catalog.${target.refName}.fields${safeMember(fieldKey)}`;
|
|
1320
1411
|
}
|
|
1321
1412
|
else {
|
|
1322
|
-
const
|
|
1413
|
+
const rawKey = fieldKey.startsWith(UNRESOLVED_FIELD_MARKER)
|
|
1323
1414
|
? fieldKey.slice(UNRESOLVED_FIELD_MARKER.length)
|
|
1324
1415
|
: fieldKey;
|
|
1325
|
-
|
|
1326
|
-
|
|
1416
|
+
const foreignOwner = assignment?.foreignOwnerName;
|
|
1417
|
+
const foreignKind = assignment?.foreignEntityType;
|
|
1418
|
+
if ((foreignKind === "app" || foreignKind === "element") && foreignOwner !== undefined && foreignOwner !== "" && !isUuid(rawKey) && assignment?.foreignFieldType !== undefined) {
|
|
1419
|
+
fieldExpr = `catalog.${foreignOwner}.fields${safeMember(rawKey)}`;
|
|
1420
|
+
}
|
|
1421
|
+
else if (!isUuid(rawKey)) {
|
|
1422
|
+
// A bag key with no known owner and type is not a TEXT field. Inventing
|
|
1423
|
+
// one makes the next build address elementum_text_field.
|
|
1424
|
+
fieldExpr = `/* unresolved field ${quote(rawKey)} */ null`;
|
|
1425
|
+
}
|
|
1426
|
+
else {
|
|
1427
|
+
state.imports.usesUnsafePlatformId = true;
|
|
1428
|
+
fieldExpr = `unsafePlatformId(${quote(rawKey)})`;
|
|
1429
|
+
}
|
|
1327
1430
|
}
|
|
1328
1431
|
const valueExpr = printArgValue("", assignment?.value ?? rawValue, state, indent + 2, refCtx);
|
|
1329
1432
|
const updateMode = assignment?.updateMode === "add" ? `, updateMode: "add"` : "";
|
|
@@ -1335,21 +1438,47 @@ function printFieldAssignments(values, target, state, indent, refCtx) {
|
|
|
1335
1438
|
* The task's primary target, used to resolve `values:` field keys to
|
|
1336
1439
|
* `<target>.fields.<key>` tokens (or inline field stubs for tasks).
|
|
1337
1440
|
* Reads the `app` / `relatedApp` arg.
|
|
1441
|
+
*
|
|
1442
|
+
* Non-recursive element/app exports often leave `object_id` as a raw platform
|
|
1443
|
+
* UUID. The `app:` printer already joins those via
|
|
1444
|
+
* `foreign*RefNamespaces` (#1427); this must use the same join so system-field
|
|
1445
|
+
* bag keys (Title/ID — no `foreignFieldType` on the assignment) still print as
|
|
1446
|
+
* `catalog.<target>.fields.<key>` instead of an unresolved-field null stub.
|
|
1338
1447
|
*/
|
|
1339
1448
|
function taskPrimaryTarget(args, state) {
|
|
1340
1449
|
for (const k of ["app", "relatedApp"]) {
|
|
1341
1450
|
const v = args[k];
|
|
1342
1451
|
if (isRefExpr(v) && v.kind === "app") {
|
|
1343
1452
|
if (v.entityType === "task") {
|
|
1344
|
-
const
|
|
1345
|
-
|
|
1453
|
+
const foreignRefName = v.name !== undefined ? state.foreignTaskRefNames?.get(v.name) : undefined;
|
|
1454
|
+
const refName = foreignRefName ?? v.appHandle;
|
|
1455
|
+
return { kind: "task", refName, name: v.name ?? refName, inCatalog: foreignRefName !== undefined };
|
|
1346
1456
|
}
|
|
1347
1457
|
if (v.entityType === "element") {
|
|
1348
|
-
const
|
|
1349
|
-
return { kind: "element", refName, name: v.name };
|
|
1458
|
+
const foreignRefName = v.name !== undefined ? state.foreignElementRefNames?.get(v.name) : undefined;
|
|
1459
|
+
return { kind: "element", refName: foreignRefName ?? v.appHandle, name: v.name, inCatalog: v.name === undefined || foreignRefName !== undefined };
|
|
1350
1460
|
}
|
|
1351
|
-
const
|
|
1352
|
-
|
|
1461
|
+
const foreignRefName = v.name !== undefined ? state.foreignAppRefNames?.get(v.name) : undefined;
|
|
1462
|
+
const refName = foreignRefName ?? catalogOwnerHandle(state, v.appHandle);
|
|
1463
|
+
return { kind: "app", refName, name: v.name, inCatalog: v.entityType === undefined || v.name === undefined || foreignRefName !== undefined };
|
|
1464
|
+
}
|
|
1465
|
+
const aspectId = typeof v === "string"
|
|
1466
|
+
? v
|
|
1467
|
+
: isRefExpr(v) && v.kind === "literal" && typeof v.value === "string"
|
|
1468
|
+
? v.value
|
|
1469
|
+
: undefined;
|
|
1470
|
+
if (aspectId !== undefined && isUuid(aspectId)) {
|
|
1471
|
+
// Same order as the `app:` printer: app namespace, element namespace,
|
|
1472
|
+
// then the name maps. Checking elements first would print fields against
|
|
1473
|
+
// a different catalog ref than the app argument.
|
|
1474
|
+
const appRef = state.foreignAppRefNamespaces?.get(aspectId)
|
|
1475
|
+
?? state.foreignAppRefNames?.get(aspectId);
|
|
1476
|
+
if (appRef !== undefined)
|
|
1477
|
+
return { kind: "app", refName: appRef, inCatalog: true };
|
|
1478
|
+
const elementRef = state.foreignElementRefNamespaces?.get(aspectId)
|
|
1479
|
+
?? state.foreignElementRefNames?.get(aspectId);
|
|
1480
|
+
if (elementRef !== undefined)
|
|
1481
|
+
return { kind: "element", refName: elementRef, inCatalog: true };
|
|
1353
1482
|
}
|
|
1354
1483
|
}
|
|
1355
1484
|
return undefined;
|
|
@@ -1548,12 +1677,13 @@ function printRef(ref, state, refCtx) {
|
|
|
1548
1677
|
// pulled into this workspace (board issue #40, app-only) resolves to a
|
|
1549
1678
|
// typed token; otherwise a literal stub (field type is unconfirmed —
|
|
1550
1679
|
// ei's `elementum_field` data source doesn't expose it).
|
|
1680
|
+
const namespace = ref.foreign.namespace;
|
|
1551
1681
|
const foreignRefName = ref.foreign.entityType === "element"
|
|
1552
|
-
? state.foreignElementRefNames?.get(ref.foreign.name)
|
|
1682
|
+
? (namespace !== undefined ? state.foreignElementRefNamespaces?.get(namespace) : undefined) ?? state.foreignElementRefNames?.get(ref.foreign.name)
|
|
1553
1683
|
: ref.foreign.entityType === "task"
|
|
1554
1684
|
? state.foreignTaskRefNames?.get(ref.foreign.name)
|
|
1555
1685
|
: ref.foreign.entityType === "app"
|
|
1556
|
-
? state.foreignAppRefNames?.get(ref.foreign.name)
|
|
1686
|
+
? (namespace !== undefined ? state.foreignAppRefNamespaces?.get(namespace) : undefined) ?? state.foreignAppRefNames?.get(ref.foreign.name)
|
|
1557
1687
|
: undefined;
|
|
1558
1688
|
if (ref.foreign.entityType === "task") {
|
|
1559
1689
|
const parentRef = foreignRefName ?? ref.appHandle;
|
|
@@ -1595,7 +1725,8 @@ function printRef(ref, state, refCtx) {
|
|
|
1595
1725
|
: undefined;
|
|
1596
1726
|
if (foreignRefName !== undefined)
|
|
1597
1727
|
return `catalog.${foreignRefName}`;
|
|
1598
|
-
|
|
1728
|
+
const namespace = ref.namespace !== undefined ? `, namespace: ${quote(ref.namespace)}` : "";
|
|
1729
|
+
return `{ __kind: ${quote(ref.entityType)}, refName: ${quote(ref.appHandle)}, name: ${quote(ref.name)}${namespace} }`;
|
|
1599
1730
|
}
|
|
1600
1731
|
case "agent":
|
|
1601
1732
|
return `catalog.${catalogOwnerHandle(state, ref.appHandle)}.agents${safeMember(ref.agentKey)}`;
|
|
@@ -1631,6 +1762,12 @@ function printRef(ref, state, refCtx) {
|
|
|
1631
1762
|
return `catalog.${ref.appHandle}.searchTables${safeMember(ref.tableKey)}`;
|
|
1632
1763
|
case "user":
|
|
1633
1764
|
return `${trackFactory("userRef", state)}(${quote(ref.email)})`;
|
|
1765
|
+
case "secret":
|
|
1766
|
+
state.imports.usesSecret = true;
|
|
1767
|
+
return `secret(${quote(ref.key)})`;
|
|
1768
|
+
case "orgGroup":
|
|
1769
|
+
state.imports.usesOrg = true;
|
|
1770
|
+
return `org.groups${safeMember(ref.groupKey)}`;
|
|
1634
1771
|
case "documentModel":
|
|
1635
1772
|
return `catalog.${catalogOwnerHandle(state, ref.appHandle)}.fileReaders${safeMember(ref.documentModelKey)}`;
|
|
1636
1773
|
case "documentModelField":
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EntityTfError } from "../../engine/entity.js";
|
|
2
|
-
import { type TfBlock, type TfDocument, type TfValue } from "../../engine/tf/index.js";
|
|
2
|
+
import { type ChildResourceScope, type TfBlock, type TfDocument, type TfValue } from "../../engine/tf/index.js";
|
|
3
3
|
import type { AutomationAst } from "./deserializer/ast.js";
|
|
4
4
|
export interface AutomationFromTfResult {
|
|
5
5
|
readonly refName: string;
|
|
@@ -17,6 +17,7 @@ export interface AutomationFromTfResult {
|
|
|
17
17
|
interface DecodeContext {
|
|
18
18
|
readonly appRefName: string;
|
|
19
19
|
readonly appTfLabel: string;
|
|
20
|
+
readonly ownerScope: ChildResourceScope;
|
|
20
21
|
readonly trigger: TfBlock;
|
|
21
22
|
readonly taskByAddress: ReadonlyMap<string, {
|
|
22
23
|
block: TfBlock;
|
|
@@ -35,6 +36,9 @@ interface DecodeContext {
|
|
|
35
36
|
readonly foreignFieldRefsById?: ReadonlyMap<string, {
|
|
36
37
|
readonly ownerRefName: string;
|
|
37
38
|
readonly fieldKey: string;
|
|
39
|
+
readonly ownerKind?: "app" | "element";
|
|
40
|
+
readonly ownerName?: string;
|
|
41
|
+
readonly ownerNamespace?: string;
|
|
38
42
|
readonly fieldName?: string;
|
|
39
43
|
readonly fieldType?: string;
|
|
40
44
|
}>;
|
|
@@ -62,6 +66,8 @@ interface DecodeContext {
|
|
|
62
66
|
readonly foreignTaskRefNames?: ReadonlyMap<string, string>;
|
|
63
67
|
/** Procedure discriminator (`procedureDiscriminator`) → org.ts's disambiguated catalog key, for overloaded same-name procedures. See `procedure-refs.ts`. */
|
|
64
68
|
readonly procedureKeysByDiscriminator?: ReadonlyMap<string, string>;
|
|
69
|
+
/** Group name → org.ts's `org.groups` key, for static recipients (edk#1412). See `FromTfContext.groupKeysByName`. */
|
|
70
|
+
readonly groupKeysByName?: ReadonlyMap<string, string>;
|
|
65
71
|
}
|
|
66
72
|
/**
|
|
67
73
|
* The same outputs as seen from a CALCULATION formula, which addresses a
|
|
@@ -147,6 +153,7 @@ export interface AutomationFromTfContext {
|
|
|
147
153
|
readonly foreignElementRefNames?: ReadonlyMap<string, string>;
|
|
148
154
|
readonly foreignTaskRefNames?: ReadonlyMap<string, string>;
|
|
149
155
|
readonly procedureKeysByDiscriminator?: ReadonlyMap<string, string>;
|
|
156
|
+
readonly groupKeysByName?: ReadonlyMap<string, string>;
|
|
150
157
|
}
|
|
151
158
|
export interface AutomationGraphFromTfResult {
|
|
152
159
|
readonly automation?: AutomationAst;
|
|
@@ -170,5 +177,5 @@ export declare function automationFromTf(doc: TfDocument, automationLabel: strin
|
|
|
170
177
|
}>, foreignTableRefsById?: ReadonlyMap<string, {
|
|
171
178
|
readonly tableRefName: string;
|
|
172
179
|
readonly name: string;
|
|
173
|
-
}>, picklistOptionLabelById?: ReadonlyMap<string, string>, fieldNamesByOwnerRefName?: ReadonlyMap<string, ReadonlyMap<string, string>>, foreignAppRefNames?: ReadonlyMap<string, string>, foreignElementRefNames?: ReadonlyMap<string, string>, procedureKeysByDiscriminator?: ReadonlyMap<string, string>, foreignTaskRefNames?: ReadonlyMap<string, string>): AutomationFromTfResult;
|
|
180
|
+
}>, picklistOptionLabelById?: ReadonlyMap<string, string>, fieldNamesByOwnerRefName?: ReadonlyMap<string, ReadonlyMap<string, string>>, foreignAppRefNames?: ReadonlyMap<string, string>, foreignElementRefNames?: ReadonlyMap<string, string>, procedureKeysByDiscriminator?: ReadonlyMap<string, string>, foreignTaskRefNames?: ReadonlyMap<string, string>, groupKeysByName?: ReadonlyMap<string, string>): AutomationFromTfResult;
|
|
174
181
|
export {};
|