@elementumai/edk 0.13.3 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-sdk/src/catalog/factories.d.ts +4 -2
- package/dist-sdk/src/catalog/factories.js +3 -1
- package/dist-sdk/src/catalog/from-authoring.d.ts +8 -3
- package/dist-sdk/src/catalog/from-authoring.js +21 -8
- package/dist-sdk/src/engine/build/context.d.ts +17 -0
- package/dist-sdk/src/engine/coverage-gaps.d.ts +13 -0
- package/dist-sdk/src/engine/coverage-gaps.js +21 -0
- package/dist-sdk/src/engine/pull/context.d.ts +57 -1
- package/dist-sdk/src/engine/pull/context.js +9 -1
- package/dist-sdk/src/engine/pull/pulled-roots.d.ts +14 -1
- package/dist-sdk/src/engine/pull/pulled-roots.js +23 -3
- package/dist-sdk/src/engine/pull/ref-only.d.ts +6 -1
- package/dist-sdk/src/engine/pull/ref-only.js +4 -1
- package/dist-sdk/src/engine/pull/stream-root.d.ts +17 -1
- package/dist-sdk/src/engine/pull/stream-root.js +57 -4
- package/dist-sdk/src/engine/tf/index.d.ts +1 -0
- package/dist-sdk/src/engine/tf/index.js +1 -0
- package/dist-sdk/src/engine/tf/jsonencode.d.ts +19 -0
- package/dist-sdk/src/engine/tf/jsonencode.js +49 -0
- package/dist-sdk/src/engine/validation.d.ts +36 -1
- package/dist-sdk/src/engine/validation.js +56 -2
- package/dist-sdk/src/engine/workspace/loader.d.ts +6 -0
- package/dist-sdk/src/engine/workspace/loader.js +87 -2
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +7 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +58 -17
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +3 -1
- package/dist-sdk/src/entities/access-policy/to-tf.js +1 -1
- package/dist-sdk/src/entities/agent/build.d.ts +15 -0
- package/dist-sdk/src/entities/agent/build.js +139 -16
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +3 -3
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +39 -25
- package/dist-sdk/src/entities/agent/module.js +95 -3
- package/dist-sdk/src/entities/agent/to-tf.js +6 -4
- package/dist-sdk/src/entities/agent-evaluation/from-tf.d.ts +7 -0
- package/dist-sdk/src/entities/agent-evaluation/from-tf.js +14 -5
- package/dist-sdk/src/entities/agent-evaluation/module.js +4 -2
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +11 -2
- package/dist-sdk/src/entities/agent-tool/from-tf.js +38 -40
- package/dist-sdk/src/entities/agent-tool/to-tf.js +12 -5
- package/dist-sdk/src/entities/app/build.d.ts +1 -1
- package/dist-sdk/src/entities/app/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/approval-trigger-refs.d.ts +20 -0
- package/dist-sdk/src/entities/automation/approval-trigger-refs.js +83 -0
- package/dist-sdk/src/entities/automation/build.d.ts +75 -42
- package/dist-sdk/src/entities/automation/build.js +18 -8
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +14 -2
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +9 -0
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +64 -12
- package/dist-sdk/src/entities/automation/from-tf.d.ts +53 -0
- package/dist-sdk/src/entities/automation/from-tf.js +579 -106
- package/dist-sdk/src/entities/automation/index.d.ts +2 -2
- package/dist-sdk/src/entities/automation/index.js +1 -1
- package/dist-sdk/src/entities/automation/lookup-owner.d.ts +23 -0
- package/dist-sdk/src/entities/automation/lookup-owner.js +27 -0
- package/dist-sdk/src/entities/automation/module.js +265 -26
- package/dist-sdk/src/entities/automation/operators.d.ts +6 -2
- package/dist-sdk/src/entities/automation/operators.js +0 -2
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +8 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +11 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +37 -2
- package/dist-sdk/src/entities/automation/tasks.js +38 -1
- package/dist-sdk/src/entities/automation/to-tf.d.ts +8 -0
- package/dist-sdk/src/entities/automation/to-tf.js +576 -52
- package/dist-sdk/src/entities/automation/triggers.d.ts +47 -1
- package/dist-sdk/src/entities/automation/unsafe-script-output.d.ts +10 -5
- package/dist-sdk/src/entities/automation/unsafe-script-output.js +10 -5
- package/dist-sdk/src/entities/chart/to-tf.js +18 -5
- package/dist-sdk/src/entities/dashboard/from-tf.js +45 -11
- package/dist-sdk/src/entities/dashboard-widget-order/order.d.ts +5 -3
- package/dist-sdk/src/entities/dashboard-widget-order/order.js +6 -4
- package/dist-sdk/src/entities/datamine/from-tf.js +10 -3
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +38 -11
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +35 -7
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +101 -9
- package/dist-sdk/src/entities/element/build.d.ts +4 -1
- package/dist-sdk/src/entities/element/build.js +3 -4
- package/dist-sdk/src/entities/element/index.d.ts +1 -1
- package/dist-sdk/src/entities/field/from-tf.js +8 -1
- package/dist-sdk/src/entities/field/to-tf.d.ts +29 -2
- package/dist-sdk/src/entities/field/to-tf.js +106 -7
- package/dist-sdk/src/entities/phone-service/from-tf.d.ts +7 -0
- package/dist-sdk/src/entities/phone-service/from-tf.js +15 -7
- package/dist-sdk/src/entities/phone-service/module.js +4 -2
- package/dist-sdk/src/entities/portal/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/portal/to-tf.js +61 -2
- package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -1
- package/dist-sdk/src/entities/relationship/from-tf.js +34 -4
- package/dist-sdk/src/entities/relationship/to-tf.js +24 -6
- package/dist-sdk/src/entities/role/from-tf.js +3 -1
- package/dist-sdk/src/entities/search-table/from-tf.d.ts +3 -1
- package/dist-sdk/src/entities/search-table/from-tf.js +6 -3
- package/dist-sdk/src/entities/search-table/module.js +18 -2
- package/dist-sdk/src/entities/search-table/to-tf.js +10 -16
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +6 -1
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +6 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +21 -4
- package/dist-sdk/src/entities/shared/filters/index.js +27 -3
- package/dist-sdk/src/entities/shared/filters/print.js +23 -7
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +24 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +98 -3
- package/dist-sdk/src/entities/shared/filters/types.d.ts +8 -1
- package/dist-sdk/src/entities/shared/run-automation-requirement.d.ts +15 -0
- package/dist-sdk/src/entities/shared/run-automation-requirement.js +28 -0
- package/dist-sdk/src/entities/shared/search-table-address.d.ts +17 -0
- package/dist-sdk/src/entities/shared/search-table-address.js +24 -0
- package/dist-sdk/src/entities/shared/skip-release.d.ts +49 -0
- package/dist-sdk/src/entities/shared/skip-release.js +74 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +3 -3
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +11 -5
- package/dist-sdk/src/entities/skill/module.js +3 -25
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +4 -2
- package/dist-sdk/src/entities/skill-tool/from-tf.js +28 -27
- package/dist-sdk/src/entities/skill-tool/to-tf.js +12 -5
- package/dist-sdk/src/entities/skill-tool/types.d.ts +1 -0
- package/dist-sdk/src/entities/skill-tool/types.js +2 -1
- package/dist-sdk/src/entities/table/catalog.d.ts +16 -0
- package/dist-sdk/src/entities/table/catalog.js +44 -2
- package/dist-sdk/src/entities/table/from-tf.js +30 -4
- package/dist-sdk/src/entities/table/keys.d.ts +27 -0
- package/dist-sdk/src/entities/table/keys.js +46 -0
- package/dist-sdk/src/entities/table/to-tf.js +2 -2
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +12 -1
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +9 -4
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +215 -10
- package/dist-sdk/src/entities/view/agent-view-layout.d.ts +10 -4
- package/dist-sdk/src/entities/view/custom-view-runtime-rules.d.ts +43 -0
- package/dist-sdk/src/entities/view/custom-view-runtime-rules.js +285 -0
- package/dist-sdk/src/entities/view/custom-view-validate.d.ts +3 -1
- package/dist-sdk/src/entities/view/custom-view-validate.js +24 -5
- package/dist-sdk/src/entities/view/from-tf.js +14 -1
- package/dist-sdk/src/entities/widget/from-tf.js +14 -7
- package/dist-sdk/src/entities/widget/to-tf.js +9 -6
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +4 -2
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +14 -1
- package/dist-sdk/src/graph/index.js +2 -0
- package/dist-sdk/src/graph/resource-types.d.ts +2 -0
- package/dist-sdk/src/graph/resource-types.js +3 -0
- package/dist-sdk/src/graph/types.d.ts +105 -0
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ import { EntityTfError } from "../../engine/entity.js";
|
|
|
8
8
|
import { dataRefLabel, optionalString, resourceRefLabel } from "../../engine/pull/context.js";
|
|
9
9
|
import { isTfExpr, isUuid, sanitizeName, scopedLabelToBagKey, tfLabelToTsLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
10
10
|
import { dataAspectDisplayName, dataAspectRefName, resolveDataAspectTarget } from "../shared/aspect-target-from-tf.js";
|
|
11
|
+
import { skipAndRelease, unresolvedReferenceName } from "../shared/skip-release.js";
|
|
11
12
|
import { droppedToolFieldDiagnostic, resolveToolFieldKey } from "../shared/tool-field-ref.js";
|
|
12
13
|
import { KNOWN_SKILL_TOOL_ATTRS, SKILL_TOOL_SUB_TYPE_BY_RESOURCE, UNAUTHORABLE_SKILL_TOOL_ATTRS, } from "./types.js";
|
|
13
14
|
/** Namespace-map key for a catalog ref, skipping UUID index entries. */
|
|
@@ -23,13 +24,16 @@ function stateScopeLabel(catalogRef, namespaces) {
|
|
|
23
24
|
return tsLabelToTfLabel(catalogRef);
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
|
-
* One tool block → its normalized shape; undefined = skipped
|
|
27
|
-
*
|
|
27
|
+
* One tool block → its normalized shape; undefined = skipped (unimplemented
|
|
28
|
+
* sub-type, wrong owner, unresolvable target). A tool written to no source
|
|
29
|
+
* is also left out of adoption, or released if state has it, so the next
|
|
30
|
+
* plan doesn't destroy it (edk#3172); skipAndRelease does both.
|
|
28
31
|
*/
|
|
29
32
|
export function skillToolFromTf(block, owner, ctx) {
|
|
30
33
|
const subType = SKILL_TOOL_SUB_TYPE_BY_RESOURCE.get(block.type ?? "");
|
|
31
34
|
if (subType === undefined) {
|
|
32
|
-
|
|
35
|
+
const fallback = `resource "${block.type}" is not a known skill tool resource; skipped`;
|
|
36
|
+
skipAndRelease(ctx, `${block.type}.${block.label ?? ""}`, { problem: "its resource type is not a skill tool pull knows" }, fallback);
|
|
33
37
|
return undefined;
|
|
34
38
|
}
|
|
35
39
|
const label = block.label;
|
|
@@ -39,9 +43,17 @@ export function skillToolFromTf(block, owner, ctx) {
|
|
|
39
43
|
const attrs = block.attrs;
|
|
40
44
|
const name = optionalString(attrs, "name", `tool "${label}"`, ctx) ?? "";
|
|
41
45
|
const where = `skill tool "${name}" (${block.type}.${label})`;
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
const address = `${block.type}.${label}`;
|
|
47
|
+
const skipReference = (attribute, value, fallback) => {
|
|
48
|
+
skipAndRelease(ctx, address, { reference: unresolvedReferenceName(value, attribute) }, fallback);
|
|
49
|
+
return undefined;
|
|
50
|
+
};
|
|
51
|
+
const skipProblem = (problem, fallback) => {
|
|
52
|
+
skipAndRelease(ctx, address, { problem }, fallback);
|
|
44
53
|
return undefined;
|
|
54
|
+
};
|
|
55
|
+
if (subType.implemented !== true) {
|
|
56
|
+
return skipProblem("its tool kind is not supported yet", `${where}: tool kind is not supported on the terraform path yet; skipped`);
|
|
45
57
|
}
|
|
46
58
|
const known = KNOWN_SKILL_TOOL_ATTRS[subType.typeKey];
|
|
47
59
|
for (const key of Object.keys(attrs)) {
|
|
@@ -122,8 +134,7 @@ export function skillToolFromTf(block, owner, ctx) {
|
|
|
122
134
|
if (subType.typeKey === "runAgent") {
|
|
123
135
|
const targetLabel = resourceRefLabel(attrs["target_agent_id"], "elementum_agent");
|
|
124
136
|
if (targetLabel === undefined) {
|
|
125
|
-
|
|
126
|
-
return undefined;
|
|
137
|
+
return skipReference("target_agent_id", attrs["target_agent_id"], `${where}: target_agent_id is not an elementum_agent resource reference; skipped`);
|
|
127
138
|
}
|
|
128
139
|
return {
|
|
129
140
|
typeKey: "runAgent",
|
|
@@ -158,8 +169,7 @@ export function skillToolFromTf(block, owner, ctx) {
|
|
|
158
169
|
automation.type === "elementum_automation") {
|
|
159
170
|
const automationName = ctx.dataName(automation.type, automation.label);
|
|
160
171
|
if (automationName === undefined) {
|
|
161
|
-
|
|
162
|
-
return undefined;
|
|
172
|
+
return skipReference("automation_id", automation, `${where}: automation_id references data.${automation.type}.${automation.label} but the stream has no matching name lookup; skipped`);
|
|
163
173
|
}
|
|
164
174
|
const ownerAttrs = ctx.dataAttrs?.(automation.type, automation.label);
|
|
165
175
|
const appOwnerLabel = dataRefLabel(ownerAttrs?.["app_id"], "elementum_app");
|
|
@@ -167,8 +177,7 @@ export function skillToolFromTf(block, owner, ctx) {
|
|
|
167
177
|
const ownerKind = appOwnerLabel !== undefined ? "app" : elementOwnerLabel !== undefined ? "element" : undefined;
|
|
168
178
|
const ownerLabel = appOwnerLabel ?? elementOwnerLabel;
|
|
169
179
|
if (ownerKind === undefined || ownerLabel === undefined) {
|
|
170
|
-
|
|
171
|
-
return undefined;
|
|
180
|
+
return skipProblem(`its automation data.${automation.type}.${automation.label} is owned by no app or element pull can name`, `${where}: automation_id references data.${automation.type}.${automation.label}, whose owner app_id isn't a recognized app/element reference; skipped`);
|
|
172
181
|
}
|
|
173
182
|
const resolvedOwner = resolveDataAspectTarget(ctx, ownerKind, ownerLabel);
|
|
174
183
|
automationForeignName = automationName;
|
|
@@ -178,8 +187,7 @@ export function skillToolFromTf(block, owner, ctx) {
|
|
|
178
187
|
automationForeignParentKind = ownerKind;
|
|
179
188
|
}
|
|
180
189
|
if (automationLabel === undefined && automationRawId === undefined && automationForeignName === undefined) {
|
|
181
|
-
|
|
182
|
-
return undefined;
|
|
190
|
+
return skipReference("automation_id", automation, `${where}: automation_id is not an automation/workflow_publish resource reference; skipped`);
|
|
183
191
|
}
|
|
184
192
|
const inputs = [];
|
|
185
193
|
for (const item of Array.isArray(attrs["inputs"]) ? attrs["inputs"] : []) {
|
|
@@ -272,8 +280,7 @@ export function skillToolFromTf(block, owner, ctx) {
|
|
|
272
280
|
}
|
|
273
281
|
}
|
|
274
282
|
if (searchTableName === undefined) {
|
|
275
|
-
|
|
276
|
-
return undefined;
|
|
283
|
+
return skipReference("search_table_id", value, `${where}: search_table_id references data.${value.type}.${value.label} without a matching name lookup; skipped`);
|
|
277
284
|
}
|
|
278
285
|
}
|
|
279
286
|
else if (typeof value === "string" && value !== "") {
|
|
@@ -288,8 +295,7 @@ export function skillToolFromTf(block, owner, ctx) {
|
|
|
288
295
|
searchTableRawId = value;
|
|
289
296
|
}
|
|
290
297
|
else {
|
|
291
|
-
|
|
292
|
-
return undefined;
|
|
298
|
+
return skipReference("search_table_id", value, `${where}: search_table_id is not a supported search-table resource reference; skipped`);
|
|
293
299
|
}
|
|
294
300
|
}
|
|
295
301
|
// Target: the owning app's resource ref = self; a data.elementum_app ref =
|
|
@@ -308,8 +314,7 @@ export function skillToolFromTf(block, owner, ctx) {
|
|
|
308
314
|
target = { kind: "tableOwned" };
|
|
309
315
|
}
|
|
310
316
|
else {
|
|
311
|
-
|
|
312
|
-
return undefined;
|
|
317
|
+
return skipProblem("its target_id is empty, which only a table-owned search table has", `${where}: empty target_id is only valid for a table-owned search table; skipped`);
|
|
313
318
|
}
|
|
314
319
|
}
|
|
315
320
|
else if (owner.appLabel !== undefined && selfLabel === owner.appLabel) {
|
|
@@ -318,8 +323,7 @@ export function skillToolFromTf(block, owner, ctx) {
|
|
|
318
323
|
else if (isTfExpr(targetAttr) && targetAttr.$expr === "data-attr" && targetAttr.type === "elementum_app") {
|
|
319
324
|
const appName = dataAspectDisplayName(ctx, "app", targetAttr.label);
|
|
320
325
|
if (appName === undefined) {
|
|
321
|
-
|
|
322
|
-
return undefined;
|
|
326
|
+
return skipReference("target_id", targetAttr, `${where}: target_id references data.elementum_app.${targetAttr.label} but the stream has no such data block; skipped`);
|
|
323
327
|
}
|
|
324
328
|
const attrs = ctx.dataAttrs?.("elementum_app", targetAttr.label);
|
|
325
329
|
const namespace = typeof attrs?.namespace === "string" ? attrs.namespace : undefined;
|
|
@@ -336,8 +340,7 @@ export function skillToolFromTf(block, owner, ctx) {
|
|
|
336
340
|
// Board issue #42: an aspect target can be an element, not just an app.
|
|
337
341
|
const elementName = dataAspectDisplayName(ctx, "element", targetAttr.label);
|
|
338
342
|
if (elementName === undefined) {
|
|
339
|
-
|
|
340
|
-
return undefined;
|
|
343
|
+
return skipReference("target_id", targetAttr, `${where}: target_id references data.elementum_element.${targetAttr.label} but the stream has no such data block; skipped`);
|
|
341
344
|
}
|
|
342
345
|
const attrs = ctx.dataAttrs?.("elementum_element", targetAttr.label);
|
|
343
346
|
const namespace = typeof attrs?.namespace === "string" ? attrs.namespace : undefined;
|
|
@@ -354,8 +357,7 @@ export function skillToolFromTf(block, owner, ctx) {
|
|
|
354
357
|
else if (isTfExpr(targetAttr) && targetAttr.$expr === "data-attr" && targetAttr.type === "elementum_task") {
|
|
355
358
|
const taskName = dataAspectDisplayName(ctx, "task", targetAttr.label);
|
|
356
359
|
if (taskName === undefined) {
|
|
357
|
-
|
|
358
|
-
return undefined;
|
|
360
|
+
return skipReference("target_id", targetAttr, `${where}: target_id references data.elementum_task.${targetAttr.label} but the stream has no such data block; skipped`);
|
|
359
361
|
}
|
|
360
362
|
const attrs = ctx.dataAttrs?.("elementum_task", targetAttr.label);
|
|
361
363
|
const namespace = typeof attrs?.namespace === "string" ? attrs.namespace : undefined;
|
|
@@ -398,8 +400,7 @@ export function skillToolFromTf(block, owner, ctx) {
|
|
|
398
400
|
}
|
|
399
401
|
}
|
|
400
402
|
else {
|
|
401
|
-
|
|
402
|
-
return undefined;
|
|
403
|
+
return skipReference("target_id", targetAttr, `${where}: target_id has an unrecognized shape (${JSON.stringify(targetAttr)}); skipped`);
|
|
403
404
|
}
|
|
404
405
|
let fields;
|
|
405
406
|
const rawFields = attrs["fields"];
|
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
import { typedCoverageGap } from "../../engine/coverage-gaps.js";
|
|
10
10
|
import { workspaceAspectKey } from "../../engine/build/context.js";
|
|
11
11
|
import { automationRunTargetResourceAttr } from "../automation/run-target.js";
|
|
12
|
-
import { appScopedResourceLabel, childPartFromScopedLabel, expr, sanitizeName,
|
|
13
|
-
import {
|
|
12
|
+
import { appScopedResourceLabel, childPartFromScopedLabel, expr, sanitizeName, stableIdSuffix, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
13
|
+
import { fieldRefToTfValue, siblingFieldOwnership, } from "../field/to-tf.js";
|
|
14
14
|
import { foreignFieldDataLabel } from "../shared/foreign-ref.js";
|
|
15
|
+
import { localSearchTableLabel } from "../shared/search-table-address.js";
|
|
15
16
|
import { encodeOptionalHandleDescription } from "../shared/handle-description.js";
|
|
16
17
|
import { SKILL_TOOL_SUB_TYPE_BY_TYPE_KEY } from "./types.js";
|
|
17
18
|
function serviceAccountIdValue(token, where, ctx) {
|
|
@@ -64,7 +65,9 @@ function targetIdValue(token, ctx) {
|
|
|
64
65
|
refName,
|
|
65
66
|
kind,
|
|
66
67
|
localTfLabel: sibling.tfLabel,
|
|
67
|
-
|
|
68
|
+
// Each field resolves to the address the sibling's own build gives it,
|
|
69
|
+
// whatever type the reference carries (#3088).
|
|
70
|
+
fieldOwnership: siblingFieldOwnership(sibling.streamRootEntity?.payload, sibling.tfLabel, kind),
|
|
68
71
|
};
|
|
69
72
|
}
|
|
70
73
|
const name = token.name ?? refName;
|
|
@@ -133,7 +136,7 @@ function fieldRefValue(token, where, ctx, target) {
|
|
|
133
136
|
const authoringType = token.fieldType ?? "";
|
|
134
137
|
const ref = refName === ""
|
|
135
138
|
? undefined
|
|
136
|
-
: fieldRefToTfValue(authoringType, refName, target.localTfLabel, target.kind, target.fieldOwnership);
|
|
139
|
+
: fieldRefToTfValue(authoringType, refName, target.localTfLabel, target.kind, target.fieldOwnership, undefined, token.name);
|
|
137
140
|
if (ref === undefined) {
|
|
138
141
|
ctx.diagnostics.push(`${where}: field token "${refName}" has no terraform field resource mapping (fieldType ${JSON.stringify(authoringType)}); dropped`);
|
|
139
142
|
return undefined;
|
|
@@ -386,7 +389,11 @@ export function skillToolToTf(entry, ctx) {
|
|
|
386
389
|
: table.__variant === "table"
|
|
387
390
|
? "elementum_table_search_table"
|
|
388
391
|
: "elementum_ai_search_table";
|
|
389
|
-
attrs["search_table_id"] = expr.resourceAttr(resourceType,
|
|
392
|
+
attrs["search_table_id"] = expr.resourceAttr(resourceType, localSearchTableLabel(where, { refName: table.refName ?? "", ...(table.name !== undefined && { name: table.name }) }, {
|
|
393
|
+
refName: target.refName,
|
|
394
|
+
tfLabel: target.localTfLabel,
|
|
395
|
+
scope: target.kind === "element" ? "element" : "app",
|
|
396
|
+
}), ["id"]);
|
|
390
397
|
}
|
|
391
398
|
}
|
|
392
399
|
}
|
|
@@ -20,6 +20,7 @@ export interface SkillToolSubType {
|
|
|
20
20
|
/** Implemented on the terraform path (to-tf + from-tf + printer). */
|
|
21
21
|
readonly implemented?: true;
|
|
22
22
|
}
|
|
23
|
+
export declare const SKILL_RUN_AUTOMATION_TOOL_RESOURCE_TYPE = "elementum_agentic_skill_run_automation_tool";
|
|
23
24
|
export declare const SKILL_TOOL_SUB_TYPES: readonly SkillToolSubType[];
|
|
24
25
|
export declare const SKILL_TOOL_SUB_TYPE_BY_TYPE_KEY: ReadonlyMap<string, SkillToolSubType>;
|
|
25
26
|
export declare const SKILL_TOOL_SUB_TYPE_BY_RESOURCE: ReadonlyMap<string, SkillToolSubType>;
|
|
@@ -11,13 +11,14 @@
|
|
|
11
11
|
* `executeWorkflow` — confirmed against the live provider schema
|
|
12
12
|
* (`entities/skill/tools.ts`'s `skillAutomation` factory).
|
|
13
13
|
*/
|
|
14
|
+
export const SKILL_RUN_AUTOMATION_TOOL_RESOURCE_TYPE = "elementum_agentic_skill_run_automation_tool";
|
|
14
15
|
export const SKILL_TOOL_SUB_TYPES = [
|
|
15
16
|
{ typeKey: "createRecord", resourceType: "elementum_agentic_skill_create_record_tool", implemented: true },
|
|
16
17
|
{ typeKey: "searchAspect", resourceType: "elementum_agentic_skill_search_records_tool", implemented: true },
|
|
17
18
|
{ typeKey: "updateRecord", resourceType: "elementum_agentic_skill_update_record_tool", implemented: true },
|
|
18
19
|
{ typeKey: "searchTable", resourceType: "elementum_agentic_skill_ai_search_tool", implemented: true },
|
|
19
20
|
{ typeKey: "runAgent", resourceType: "elementum_agentic_skill_run_agent_tool", implemented: true },
|
|
20
|
-
{ typeKey: "automation", resourceType:
|
|
21
|
+
{ typeKey: "automation", resourceType: SKILL_RUN_AUTOMATION_TOOL_RESOURCE_TYPE, implemented: true },
|
|
21
22
|
];
|
|
22
23
|
export const SKILL_TOOL_SUB_TYPE_BY_TYPE_KEY = new Map(SKILL_TOOL_SUB_TYPES.map((t) => [t.typeKey, t]));
|
|
23
24
|
export const SKILL_TOOL_SUB_TYPE_BY_RESOURCE = new Map(SKILL_TOOL_SUB_TYPES.map((t) => [t.resourceType, t]));
|
|
@@ -9,6 +9,22 @@ export interface TableCatalogInput {
|
|
|
9
9
|
}>;
|
|
10
10
|
}
|
|
11
11
|
export declare function renderTableCatalog(table: TableCatalogInput): string;
|
|
12
|
+
/** A column key that a catalog rewrite gives to a different column than before. */
|
|
13
|
+
export interface MovedTableColumnKey {
|
|
14
|
+
readonly key: string;
|
|
15
|
+
readonly from: string;
|
|
16
|
+
readonly to: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Write a table's catalog. `movedKeys` lists each key the catalog already on
|
|
20
|
+
* disk gave to a different column: two columns of a table that share a key
|
|
21
|
+
* are numbered in name order (#3167), so a column added later, or this
|
|
22
|
+
* version's keying of an older catalog, can give a key to another column.
|
|
23
|
+
* Source that reads the key and isn't pulled again then builds that column.
|
|
24
|
+
*/
|
|
12
25
|
export declare function writeTableCatalog(orgRoot: string, table: TableCatalogInput): Promise<{
|
|
13
26
|
catalogPath: string;
|
|
27
|
+
movedKeys: readonly MovedTableColumnKey[];
|
|
14
28
|
}>;
|
|
29
|
+
/** The pull warning for keys a table catalog rewrite gave to other columns. */
|
|
30
|
+
export declare function movedTableColumnKeysMessage(tableName: string, handle: string, moved: readonly MovedTableColumnKey[]): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mkdir, writeFile } from "node:fs/promises";
|
|
1
|
+
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { sdkPackageSpecifier } from "../../internal/sdk-package.js";
|
|
4
4
|
const RESERVED_IDENT = new Set([
|
|
@@ -57,10 +57,52 @@ export function renderTableCatalog(table) {
|
|
|
57
57
|
lines.push("");
|
|
58
58
|
return lines.join("\n");
|
|
59
59
|
}
|
|
60
|
+
const CATALOG_COLUMN_LINE = /^ {4}("(?:[^"\\]|\\.)*"|[A-Za-z_$][A-Za-z0-9_$]*): tableColumnRef\(\{ name: ("(?:[^"\\]|\\.)*")/;
|
|
61
|
+
/** Column key → display name in a catalog `renderTableCatalog` wrote. */
|
|
62
|
+
function catalogColumnNames(source) {
|
|
63
|
+
const names = new Map();
|
|
64
|
+
for (const line of source.split("\n")) {
|
|
65
|
+
const match = CATALOG_COLUMN_LINE.exec(line);
|
|
66
|
+
if (match === null)
|
|
67
|
+
continue;
|
|
68
|
+
try {
|
|
69
|
+
const key = match[1].startsWith("\"") ? JSON.parse(match[1]) : match[1];
|
|
70
|
+
names.set(key, JSON.parse(match[2]));
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
// Not a line this renderer wrote; ignore it.
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return names;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Write a table's catalog. `movedKeys` lists each key the catalog already on
|
|
80
|
+
* disk gave to a different column: two columns of a table that share a key
|
|
81
|
+
* are numbered in name order (#3167), so a column added later, or this
|
|
82
|
+
* version's keying of an older catalog, can give a key to another column.
|
|
83
|
+
* Source that reads the key and isn't pulled again then builds that column.
|
|
84
|
+
*/
|
|
60
85
|
export async function writeTableCatalog(orgRoot, table) {
|
|
61
86
|
const generatedDir = join(orgRoot, "tables", table.handle, "generated");
|
|
62
87
|
const catalogPath = join(generatedDir, "catalog.ts");
|
|
88
|
+
const previous = await readFile(catalogPath, "utf8").then(catalogColumnNames, () => new Map());
|
|
89
|
+
// Only a key whose old column is still in the table, under another key,
|
|
90
|
+
// has moved. When the old name is gone the column was renamed (`Status` to
|
|
91
|
+
// `STATUS`) or removed, and source that reads the key gets what it named.
|
|
92
|
+
const columns = Object.entries(table.tableColumns ?? {});
|
|
93
|
+
const names = new Set(columns.map(([, column]) => column.name));
|
|
94
|
+
const movedKeys = columns.flatMap(([key, column]) => {
|
|
95
|
+
const from = previous.get(key);
|
|
96
|
+
return from !== undefined && from !== column.name && names.has(from) ? [{ key, from, to: column.name }] : [];
|
|
97
|
+
}).sort((a, b) => a.key.localeCompare(b.key));
|
|
63
98
|
await mkdir(generatedDir, { recursive: true });
|
|
64
99
|
await writeFile(catalogPath, renderTableCatalog(table), "utf8");
|
|
65
|
-
return { catalogPath };
|
|
100
|
+
return { catalogPath, movedKeys };
|
|
101
|
+
}
|
|
102
|
+
/** The pull warning for keys a table catalog rewrite gave to other columns. */
|
|
103
|
+
export function movedTableColumnKeysMessage(tableName, handle, moved) {
|
|
104
|
+
const list = moved.map((m) => `\`${m.key}\` was ${JSON.stringify(m.from)}, now ${JSON.stringify(m.to)}`).join("; ");
|
|
105
|
+
return `table "${tableName}": tables/${handle}/generated/catalog.ts gives ${moved.length === 1 ? "a column key" : "column keys"} to another column (${list}), ` +
|
|
106
|
+
"because two of its columns share a key and are numbered in name order. Source that reads such a key now builds the other column: " +
|
|
107
|
+
"pull again every app, element or dashboard that reads this table, and check source you wrote by hand.";
|
|
66
108
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { dataRefLabel, optionalBoolean, optionalString, plainObject, resourceRefLabel, } from "../../engine/pull/context.js";
|
|
2
|
-
import { isTfExpr, sanitizeName,
|
|
2
|
+
import { isTfExpr, sanitizeName, tfLabelToTsLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
3
3
|
import { tableDataminesFromTf } from "../datamine/from-tf.js";
|
|
4
4
|
import { TABLE_RESOURCE_TYPE } from "./module.js";
|
|
5
|
+
import { tableColumnKey, tableColumnKeysByName } from "./keys.js";
|
|
5
6
|
import { EntityTfError } from "../../engine/entity.js";
|
|
6
7
|
import { catalogRefForAspectOwner } from "../shared/aspect-target-from-tf.js";
|
|
7
8
|
import { filterFromTf } from "../shared/filters/tf-codec.js";
|
|
@@ -197,7 +198,7 @@ function tableFilterFieldFromTf(value, tableTfLabel, columnKeyByName, ctx, where
|
|
|
197
198
|
return {
|
|
198
199
|
kind: "tableColumn",
|
|
199
200
|
tableRefName: tfLabelToTsLabel(value.label),
|
|
200
|
-
columnRefName: ownKey ??
|
|
201
|
+
columnRefName: ownKey ?? tableColumnKey(name),
|
|
201
202
|
};
|
|
202
203
|
}
|
|
203
204
|
const fieldLabel = dataRefLabel(value, "elementum_field");
|
|
@@ -245,12 +246,25 @@ export function tableFromTf(block, ctx, datamineBlocks = []) {
|
|
|
245
246
|
const handle = optionalString(attrs, "handle", `table ${block.label}`, ctx) ?? block.label;
|
|
246
247
|
const mapping = cloudMapping(attrs);
|
|
247
248
|
const rawFields = Array.isArray(attrs["fields"]) ? attrs["fields"] : [];
|
|
249
|
+
const fieldNameAt = (field, index) => str(field, "name") ?? `Column ${index + 1}`;
|
|
250
|
+
// The key every other side derives for this column: the ref-only table
|
|
251
|
+
// catalog, an automation's or another table's `field_ids["<name>"]` read,
|
|
252
|
+
// and the table stream's column handles. A second derivation here printed
|
|
253
|
+
// "Street 1" as `street1`, "firstName" as `firstname` and "2nd Line" as
|
|
254
|
+
// `"2ndLine"` while the app's source read `street_1`, `firstName` and
|
|
255
|
+
// `_2ndLine`, so a --with-dependencies pull left those reads undefined
|
|
256
|
+
// (#3063). Two names with one key ("DOMAIN" and "Domain") get distinct
|
|
257
|
+
// ones, the same on every side (#3167).
|
|
258
|
+
const columnKeys = tableColumnKeysByName(rawFields.flatMap((item, index) => {
|
|
259
|
+
const field = plainObject(item);
|
|
260
|
+
return field === undefined ? [] : [fieldNameAt(field, index)];
|
|
261
|
+
}));
|
|
248
262
|
const columns = rawFields.flatMap((item, index) => {
|
|
249
263
|
const field = plainObject(item);
|
|
250
264
|
if (field === undefined)
|
|
251
265
|
return [];
|
|
252
|
-
const fieldName =
|
|
253
|
-
const key =
|
|
266
|
+
const fieldName = fieldNameAt(field, index);
|
|
267
|
+
const key = columnKeys.get(fieldName);
|
|
254
268
|
const tags = stringList(field["tags"]);
|
|
255
269
|
const ref = fieldSourceRef(field["reference_field_id"], ctx);
|
|
256
270
|
let def;
|
|
@@ -282,15 +296,27 @@ export function tableFromTf(block, ctx, datamineBlocks = []) {
|
|
|
282
296
|
...(ref !== undefined && { sourceRef: ref }),
|
|
283
297
|
}];
|
|
284
298
|
});
|
|
299
|
+
// Build addresses a column by its display name (`field_ids["<name>"]`), so
|
|
300
|
+
// two columns with one name can't both be held in source. Refuse rather
|
|
301
|
+
// than print one and let apply remove the other.
|
|
302
|
+
const repeated = [...new Set(columns.map((column) => column.state.name).filter((n, i, all) => all.indexOf(n) !== i))];
|
|
303
|
+
if (repeated.length > 0) {
|
|
304
|
+
throw new EntityTfError(`table "${name}": ${repeated.map((n) => `more than one column is named ${JSON.stringify(n)}`).join("; ")}, ` +
|
|
305
|
+
"so source can hold only one of them and applying it would remove the other. Rename one of the columns in the platform, then pull again.");
|
|
306
|
+
}
|
|
285
307
|
const columnKeyByName = new Map(columns.map((column) => [column.state.name, column.key]));
|
|
286
308
|
const joins = (Array.isArray(attrs["joins"]) ? attrs["joins"] : []).flatMap((item) => {
|
|
287
309
|
const join = plainObject(item);
|
|
288
310
|
if (join === undefined)
|
|
289
311
|
return [];
|
|
290
312
|
const joinedSource = sourceRef(join["source_id"], ctx);
|
|
313
|
+
// The export writes a joined source it has no reference for as its id,
|
|
314
|
+
// as it does the table's own source (edk#3100).
|
|
315
|
+
const joinedSourceId = typeof join["source_id"] === "string" ? join["source_id"] : undefined;
|
|
291
316
|
return [{
|
|
292
317
|
type: (str(join, "type") ?? "LEFT"),
|
|
293
318
|
...(joinedSource !== undefined && { sourceRef: joinedSource }),
|
|
319
|
+
...(joinedSourceId !== undefined && { source: { id: joinedSourceId } }),
|
|
294
320
|
on: (Array.isArray(join["join_on"]) ? join["join_on"] : []).flatMap((pair) => {
|
|
295
321
|
const value = plainObject(pair);
|
|
296
322
|
const leftId = value ? rawRef(value["left_field_id"]) : undefined;
|
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The catalog key of a table column with this display name, on every side:
|
|
3
|
+
* the pulled table's own `columns` bag, the ref-only table catalog (ei's
|
|
4
|
+
* `SanitizeName` of the name), and any automation, table or datamine source
|
|
5
|
+
* that reads the column through `field_ids["<name>"]`. One derivation, so a
|
|
6
|
+
* column like "Street 1", "firstName" or "2nd Line" has the same key whether
|
|
7
|
+
* its table is a stub or pulled in full (#3063). It never needs quoting:
|
|
8
|
+
* `_2ndLine`, not `"2ndLine"`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function tableColumnKey(name: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* The catalog key of every column of one table, by display name. Each column
|
|
13
|
+
* keys as `tableColumnKey(name)` unless another column of the same table keys
|
|
14
|
+
* the same way: "DOMAIN" and "Domain" are both `domain` (#3167). Then the
|
|
15
|
+
* names are taken in sort order (`Array.prototype.sort`, by UTF-16 code
|
|
16
|
+
* unit); the first keeps the key and each later one takes the next free
|
|
17
|
+
* `<key>2`, `<key>3`, … (the `withUniqueKeys` suffix), skipping a key another
|
|
18
|
+
* column has as its own (`Domain2`). The result depends only on the set of
|
|
19
|
+
* names, never on the order a source lists them in, so the pulled table, its
|
|
20
|
+
* ref-only catalog and every automation, table or datamine that reads a
|
|
21
|
+
* column through `field_ids["<name>"]` give the column the same key, as long
|
|
22
|
+
* as each sees the same columns. A table without such a collision keys
|
|
23
|
+
* exactly as `tableColumnKey` does. A column added later whose name sorts
|
|
24
|
+
* first takes the key from the column that had it; `writeTableCatalog`
|
|
25
|
+
* reports that move so pull can warn.
|
|
26
|
+
*/
|
|
27
|
+
export declare function tableColumnKeysByName(names: Iterable<string>): ReadonlyMap<string, string>;
|
|
1
28
|
/**
|
|
2
29
|
* Convert a table/column label to the identifier convention used by table
|
|
3
30
|
* authoring and state. Table keys intentionally normalize the whole first
|
|
@@ -1,4 +1,50 @@
|
|
|
1
1
|
import { camelCase } from "../../../pull/util.js";
|
|
2
|
+
import { sanitizeName, tfLabelToTsLabel } from "../../engine/tf/labels.js";
|
|
3
|
+
/**
|
|
4
|
+
* The catalog key of a table column with this display name, on every side:
|
|
5
|
+
* the pulled table's own `columns` bag, the ref-only table catalog (ei's
|
|
6
|
+
* `SanitizeName` of the name), and any automation, table or datamine source
|
|
7
|
+
* that reads the column through `field_ids["<name>"]`. One derivation, so a
|
|
8
|
+
* column like "Street 1", "firstName" or "2nd Line" has the same key whether
|
|
9
|
+
* its table is a stub or pulled in full (#3063). It never needs quoting:
|
|
10
|
+
* `_2ndLine`, not `"2ndLine"`.
|
|
11
|
+
*/
|
|
12
|
+
export function tableColumnKey(name) {
|
|
13
|
+
return tfLabelToTsLabel(sanitizeName(name));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The catalog key of every column of one table, by display name. Each column
|
|
17
|
+
* keys as `tableColumnKey(name)` unless another column of the same table keys
|
|
18
|
+
* the same way: "DOMAIN" and "Domain" are both `domain` (#3167). Then the
|
|
19
|
+
* names are taken in sort order (`Array.prototype.sort`, by UTF-16 code
|
|
20
|
+
* unit); the first keeps the key and each later one takes the next free
|
|
21
|
+
* `<key>2`, `<key>3`, … (the `withUniqueKeys` suffix), skipping a key another
|
|
22
|
+
* column has as its own (`Domain2`). The result depends only on the set of
|
|
23
|
+
* names, never on the order a source lists them in, so the pulled table, its
|
|
24
|
+
* ref-only catalog and every automation, table or datamine that reads a
|
|
25
|
+
* column through `field_ids["<name>"]` give the column the same key, as long
|
|
26
|
+
* as each sees the same columns. A table without such a collision keys
|
|
27
|
+
* exactly as `tableColumnKey` does. A column added later whose name sorts
|
|
28
|
+
* first takes the key from the column that had it; `writeTableCatalog`
|
|
29
|
+
* reports that move so pull can warn.
|
|
30
|
+
*/
|
|
31
|
+
export function tableColumnKeysByName(names) {
|
|
32
|
+
const sorted = [...new Set(names)].sort();
|
|
33
|
+
const plain = new Map(sorted.map((name) => [name, tableColumnKey(name)]));
|
|
34
|
+
const reserved = new Set(plain.values());
|
|
35
|
+
const used = new Set();
|
|
36
|
+
const keys = new Map();
|
|
37
|
+
for (const name of sorted) {
|
|
38
|
+
const base = plain.get(name);
|
|
39
|
+
let key = base;
|
|
40
|
+
let suffix = 2;
|
|
41
|
+
while (used.has(key) || (key !== base && reserved.has(key)))
|
|
42
|
+
key = `${base}${suffix++}`;
|
|
43
|
+
used.add(key);
|
|
44
|
+
keys.set(name, key);
|
|
45
|
+
}
|
|
46
|
+
return keys;
|
|
47
|
+
}
|
|
2
48
|
/**
|
|
3
49
|
* Convert a table/column label to the identifier convention used by table
|
|
4
50
|
* authoring and state. Table keys intentionally normalize the whole first
|
|
@@ -5,7 +5,7 @@ import { CATEGORY_ORG_BAG } from "../org/category.js";
|
|
|
5
5
|
import { categoryIdExpr, missingCategoryDiagnostic } from "../org/category-ref.js";
|
|
6
6
|
import { CLOUD_LINK_ORG_BAG } from "../org/cloud-link.js";
|
|
7
7
|
import { tableDataminesToTf, } from "../datamine/to-tf.js";
|
|
8
|
-
import {
|
|
8
|
+
import { fieldRefToTfValue, siblingFieldOwnership } from "../field/to-tf.js";
|
|
9
9
|
import { foreignFieldDataLabel, resolveForeignRef } from "../shared/foreign-ref.js";
|
|
10
10
|
import { filterToTf as serializeFilterToTf } from "../shared/filters/tf-codec.js";
|
|
11
11
|
import { optionSelectionLiteral, optionsLocalName } from "../shared/filters/option-lookups.js";
|
|
@@ -113,7 +113,7 @@ function fieldId(value, orgRefs, ownRef, ownLabel, ownColumnNames, workspaceAspe
|
|
|
113
113
|
if (local !== undefined &&
|
|
114
114
|
ref.fieldType !== undefined &&
|
|
115
115
|
ref.refName !== undefined) {
|
|
116
|
-
const resolved = fieldRefToTfValue(ref.fieldType, ref.refName, local.tfLabel, kind,
|
|
116
|
+
const resolved = fieldRefToTfValue(ref.fieldType, ref.refName, local.tfLabel, kind, siblingFieldOwnership(local.streamRootEntity?.payload, local.tfLabel, kind), undefined, ref.name);
|
|
117
117
|
if (resolved !== undefined)
|
|
118
118
|
return resolved;
|
|
119
119
|
}
|
|
@@ -29,6 +29,12 @@ export interface ViewBlocksForeignFieldMarker {
|
|
|
29
29
|
readonly parentName: string;
|
|
30
30
|
readonly parentNamespace?: string;
|
|
31
31
|
}
|
|
32
|
+
/** One of the view owner's automations, named in an action (triggerAutomation's automationId, #3207). */
|
|
33
|
+
export interface ViewBlocksAutomationMarker {
|
|
34
|
+
readonly __specRef: "automation";
|
|
35
|
+
readonly key: string;
|
|
36
|
+
readonly name: string;
|
|
37
|
+
}
|
|
32
38
|
/**
|
|
33
39
|
* A typed reference inside a pulled blocks layout. `app` is the view's owner
|
|
34
40
|
* (an app or an element) and `field` one of its fields; `source` and
|
|
@@ -39,7 +45,10 @@ export type AgentViewSpecMarker = {
|
|
|
39
45
|
} | {
|
|
40
46
|
readonly __specRef: "field";
|
|
41
47
|
readonly key: string;
|
|
42
|
-
} | ViewBlocksSourceMarker | ViewBlocksForeignFieldMarker | {
|
|
48
|
+
} | ViewBlocksSourceMarker | ViewBlocksForeignFieldMarker | ViewBlocksAutomationMarker | {
|
|
49
|
+
readonly __specRef: "option";
|
|
50
|
+
readonly label: string;
|
|
51
|
+
} | {
|
|
43
52
|
readonly __specRef: "unsafe";
|
|
44
53
|
readonly id: string;
|
|
45
54
|
};
|
|
@@ -73,6 +82,8 @@ export interface AgentViewLayoutFromTfOptions {
|
|
|
73
82
|
readonly foreignSource?: (value: TfValue) => ViewBlocksSourceMarker | undefined;
|
|
74
83
|
/** Resolves the data lookup of another app's or element's field. */
|
|
75
84
|
readonly foreignField?: (value: TfValue) => ViewBlocksForeignFieldMarker | undefined;
|
|
85
|
+
/** Resolves a reference to one of the owner's automations (inside actions only). */
|
|
86
|
+
readonly automation?: (value: TfValue) => ViewBlocksAutomationMarker | undefined;
|
|
76
87
|
}
|
|
77
88
|
export type AgentViewLayoutFromTfResult = {
|
|
78
89
|
readonly ok: true;
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { isTfExpr } from "../../engine/tf/index.js";
|
|
13
13
|
import { AGENT_VIEW_SPEC_FILTER_PROPS, AGENT_VIEW_SPEC_ID_PROPS } from "./agent-view-layout.js";
|
|
14
|
+
import { optionLookupLabel } from "../shared/filters/option-lookups.js";
|
|
14
15
|
const PLATFORM_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
15
16
|
const ATTACHMENT_URL = /^\/api\/v1\/attachments\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i;
|
|
16
17
|
const FILTER_PROPS = new Set(AGENT_VIEW_SPEC_FILTER_PROPS);
|
|
@@ -152,6 +153,10 @@ function decodeProps(type, value, where, opts) {
|
|
|
152
153
|
return out;
|
|
153
154
|
}
|
|
154
155
|
function deepRefs(value, where, opts) {
|
|
156
|
+
// A Dropdown option the export wrote as its field's options-by-label lookup (#3206).
|
|
157
|
+
const optionLabel = optionLookupLabel(value);
|
|
158
|
+
if (optionLabel !== undefined)
|
|
159
|
+
return { __specRef: "option", label: optionLabel };
|
|
155
160
|
if (isTfExpr(value)) {
|
|
156
161
|
return sourceRef(value, opts) ?? fieldMarker(value, where, opts);
|
|
157
162
|
}
|
|
@@ -166,13 +171,13 @@ function deepRefs(value, where, opts) {
|
|
|
166
171
|
return value;
|
|
167
172
|
}
|
|
168
173
|
/**
|
|
169
|
-
* Actions (`on` events, button `onPress`):
|
|
170
|
-
* appear. A platform id export could not
|
|
171
|
-
* other strings stay plain.
|
|
174
|
+
* Actions (`on` events, button `onPress`): app or element references, and the
|
|
175
|
+
* owner's automations (#3207), may appear. A platform id export could not
|
|
176
|
+
* resolve becomes unsafePlatformId(...); other strings stay plain.
|
|
172
177
|
*/
|
|
173
178
|
function deepSourceMarkers(value, where, opts) {
|
|
174
179
|
if (isTfExpr(value)) {
|
|
175
|
-
const ref = sourceRef(value, opts);
|
|
180
|
+
const ref = sourceRef(value, opts) ?? opts.automation?.(value);
|
|
176
181
|
if (ref === undefined)
|
|
177
182
|
throw new Unrepresentable(`${where} holds a reference the EDK cannot represent inside an action`);
|
|
178
183
|
return ref;
|