@elementumai/edk 0.9.10 → 0.9.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-sdk/src/catalog/factories.d.ts +8 -1
- package/dist-sdk/src/catalog/factories.js +13 -1
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +1 -1
- package/dist-sdk/src/catalog/types.d.ts +19 -2
- package/dist-sdk/src/catalog/types.js +1 -0
- package/dist-sdk/src/engine/build/context.d.ts +3 -0
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +3 -3
- package/dist-sdk/src/entities/access-policy/from-tf.js +27 -8
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +13 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +34 -3
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +13 -7
- package/dist-sdk/src/entities/agent-tool/to-tf.js +13 -0
- package/dist-sdk/src/entities/app/build.d.ts +15 -2
- package/dist-sdk/src/entities/app/build.js +6 -0
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +13 -3
- package/dist-sdk/src/entities/app/from-tf.js +6 -3
- package/dist-sdk/src/entities/app/to-tf.js +5 -1
- package/dist-sdk/src/entities/automation/from-tf.js +113 -1
- package/dist-sdk/src/entities/automation/module.js +1 -0
- package/dist-sdk/src/entities/automation/tasks.js +17 -0
- package/dist-sdk/src/entities/automation/to-tf.d.ts +8 -0
- package/dist-sdk/src/entities/automation/to-tf.js +153 -46
- package/dist-sdk/src/entities/automation/types.js +1 -0
- package/dist-sdk/src/entities/dashboard/from-tf.js +11 -2
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +2 -1
- package/dist-sdk/src/entities/dynamic-layout/dialect.d.ts +8 -0
- package/dist-sdk/src/entities/dynamic-layout/dialect.js +12 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +7 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +64 -10
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +54 -6
- package/dist-sdk/src/entities/element/build.d.ts +7 -0
- package/dist-sdk/src/entities/element/from-tf.js +1 -1
- package/dist-sdk/src/entities/element/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/element/to-tf.js +19 -1
- package/dist-sdk/src/entities/field/build.d.ts +10 -1
- package/dist-sdk/src/entities/field/build.js +2 -1
- package/dist-sdk/src/entities/field/calc/index.js +7 -7
- package/dist-sdk/src/entities/field/calc/runtime.d.ts +19 -0
- package/dist-sdk/src/entities/field/calc/runtime.js +32 -0
- package/dist-sdk/src/entities/field/calc/types.d.ts +6 -0
- package/dist-sdk/src/entities/file-reader/to-tf.js +10 -2
- package/dist-sdk/src/entities/relationship/build.d.ts +14 -7
- package/dist-sdk/src/entities/relationship/from-tf.js +14 -14
- package/dist-sdk/src/entities/relationship/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/relationship/to-tf.js +18 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +15 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +21 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +16 -4
- package/dist-sdk/src/entities/skill/tools.d.ts +10 -0
- package/dist-sdk/src/entities/skill/tools.js +10 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +7 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +22 -2
- package/dist-sdk/src/entities/skill-tool/to-tf.js +21 -0
- package/dist-sdk/src/entities/table/catalog-render.js +2 -1
- package/dist-sdk/src/entities/view/from-tf.js +9 -0
- package/dist-sdk/src/entities/view/to-tf.d.ts +7 -0
- package/dist-sdk/src/entities/view/to-tf.js +34 -5
- package/dist-sdk/src/entities/widget/build.d.ts +17 -7
- package/dist-sdk/src/entities/widget/from-tf.d.ts +1 -1
- package/dist-sdk/src/entities/widget/from-tf.js +132 -18
- package/dist-sdk/src/entities/widget/to-tf.d.ts +17 -0
- package/dist-sdk/src/entities/widget/to-tf.js +40 -0
- package/dist-sdk/src/graph/types.d.ts +8 -0
- package/package.json +1 -1
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { dataRefLabel, optionalBoolean, optionalString, plainObject, resourceRefLabel } from "../../engine/pull/context.js";
|
|
2
|
-
import { isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
2
|
+
import { bareChildResourceLabel, isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
3
3
|
import { AUTOMATION_RESOURCE_TYPE } from "../automation/types.js";
|
|
4
4
|
import { fieldKeyFromTfRef } from "../field/from-tf.js";
|
|
5
5
|
import { SUB_TYPE_BY_RESOURCE } from "../field/types.js";
|
|
6
6
|
import { WIDGET_RESOURCE_TYPE } from "./module.js";
|
|
7
7
|
import { filterFromTf } from "../access-policy/from-tf.js";
|
|
8
|
+
import { resolveDataAspectTarget } from "../shared/aspect-target-from-tf.js";
|
|
8
9
|
const KNOWN_ROOT_ATTRS = new Set(["object_id", "related_object", "related_link_action", "related_create_action", "run_automation_action"]);
|
|
9
|
-
export function widgetsFromTf(blocks, owner, ctx) {
|
|
10
|
+
export function widgetsFromTf(blocks, owner, ctx, dynamicLayoutCompanionLabels = new Set()) {
|
|
10
11
|
const out = [];
|
|
11
12
|
for (const block of blocks) {
|
|
12
|
-
const widget = widgetFromTf(block, owner, ctx);
|
|
13
|
+
const widget = widgetFromTf(block, owner, ctx, dynamicLayoutCompanionLabels);
|
|
13
14
|
if (widget !== undefined)
|
|
14
15
|
out.push(widget);
|
|
15
16
|
}
|
|
16
17
|
return out;
|
|
17
18
|
}
|
|
18
|
-
function widgetFromTf(block, owner, ctx) {
|
|
19
|
+
function widgetFromTf(block, owner, ctx, dynamicLayoutCompanionLabels) {
|
|
19
20
|
const label = block.label ?? "";
|
|
20
21
|
const where = `${WIDGET_RESOURCE_TYPE}.${label || "?"}`;
|
|
21
22
|
for (const attr of Object.keys(block.attrs)) {
|
|
@@ -32,6 +33,8 @@ function widgetFromTf(block, owner, ctx) {
|
|
|
32
33
|
return undefined;
|
|
33
34
|
}
|
|
34
35
|
const variant = variants[0];
|
|
36
|
+
if (variant === "run_automation_action" && dynamicLayoutCompanionLabels.has(label))
|
|
37
|
+
return undefined;
|
|
35
38
|
const body = plainObject(block.attrs[variant]);
|
|
36
39
|
if (body === undefined) {
|
|
37
40
|
ctx.diagnostics.push(`${where}.${variant}: expected an object; skipped`);
|
|
@@ -54,9 +57,26 @@ function widgetFromTf(block, owner, ctx) {
|
|
|
54
57
|
const target = aspectRef(body["object_id"], owner, ctx);
|
|
55
58
|
if (target === undefined)
|
|
56
59
|
return undefined;
|
|
57
|
-
const
|
|
58
|
-
?
|
|
59
|
-
:
|
|
60
|
+
const targetTfLabel = typeof target !== "string" && (target.kind === "app" || target.kind === "element")
|
|
61
|
+
? (target.key === owner.ownerRefName ? owner.ownerTfLabel : target.namespace ?? tsLabelToTfLabel(target.key))
|
|
62
|
+
: undefined;
|
|
63
|
+
const filterOwner = targetTfLabel !== undefined && typeof target !== "string" && (target.kind === "app" || target.kind === "element")
|
|
64
|
+
? {
|
|
65
|
+
type: target.kind === "app" ? "elementum_app" : "elementum_element",
|
|
66
|
+
label: targetTfLabel,
|
|
67
|
+
ownerRefName: target.key,
|
|
68
|
+
ownerTfLabel: targetTfLabel,
|
|
69
|
+
scope: target.kind,
|
|
70
|
+
foreignFieldRefsById: ctx.foreignFieldRefsById,
|
|
71
|
+
}
|
|
72
|
+
: {
|
|
73
|
+
type: owner.type,
|
|
74
|
+
label: owner.label,
|
|
75
|
+
ownerRefName: owner.ownerRefName,
|
|
76
|
+
ownerTfLabel: owner.ownerTfLabel,
|
|
77
|
+
scope: owner.scope,
|
|
78
|
+
foreignFieldRefsById: ctx.foreignFieldRefsById,
|
|
79
|
+
};
|
|
60
80
|
const filter = body["filter"] === undefined
|
|
61
81
|
? undefined
|
|
62
82
|
: filterFromTf(body["filter"], filterOwner, `${where}.${variant}.filter`);
|
|
@@ -89,7 +109,7 @@ function widgetFromTf(block, owner, ctx) {
|
|
|
89
109
|
return [];
|
|
90
110
|
}
|
|
91
111
|
const rec = raw;
|
|
92
|
-
const field = ownerFieldRef(rec["field_id"], owner);
|
|
112
|
+
const field = ownerFieldRef(rec["field_id"], owner, ctx);
|
|
93
113
|
return [{
|
|
94
114
|
name: typeof rec["name"] === "string" ? rec["name"] : "",
|
|
95
115
|
fieldType: typeof rec["field_type"] === "string" ? rec["field_type"] : "TEXT",
|
|
@@ -146,7 +166,7 @@ function columnsAndRows(attrs, target, owner, ctx, where) {
|
|
|
146
166
|
}
|
|
147
167
|
function aspectRef(value, owner, ctx) {
|
|
148
168
|
if (typeof value === "string")
|
|
149
|
-
return value;
|
|
169
|
+
return aspectRefFromRawId(value, owner, ctx) ?? value;
|
|
150
170
|
if (resourceRefLabel(value, owner.type) === owner.label) {
|
|
151
171
|
return { kind: owner.scope, key: owner.ownerRefName, name: owner.ownerRefName };
|
|
152
172
|
}
|
|
@@ -155,18 +175,45 @@ function aspectRef(value, owner, ctx) {
|
|
|
155
175
|
if (resourceLabel !== undefined)
|
|
156
176
|
return { kind, key: tfLabelToTsLabel(resourceLabel), name: tfLabelToTsLabel(resourceLabel) };
|
|
157
177
|
const dataLabel = dataRefLabel(value, type);
|
|
158
|
-
if (dataLabel !== undefined)
|
|
159
|
-
|
|
160
|
-
return { kind, key: tfLabelToTsLabel(dataLabel), name };
|
|
161
|
-
}
|
|
178
|
+
if (dataLabel !== undefined)
|
|
179
|
+
return { kind, ...resolveDataAspectTarget(ctx, kind, dataLabel) };
|
|
162
180
|
}
|
|
163
181
|
return undefined;
|
|
164
182
|
}
|
|
183
|
+
function aspectRefFromRawId(id, owner, ctx) {
|
|
184
|
+
if (id === "")
|
|
185
|
+
return undefined;
|
|
186
|
+
const imported = ctx.importedResource?.(id);
|
|
187
|
+
if (imported === undefined)
|
|
188
|
+
return undefined;
|
|
189
|
+
if (imported.type === owner.type && imported.label === owner.label) {
|
|
190
|
+
return { kind: owner.scope, key: owner.ownerRefName, name: owner.ownerRefName };
|
|
191
|
+
}
|
|
192
|
+
if (imported.type !== "elementum_app" && imported.type !== "elementum_element")
|
|
193
|
+
return undefined;
|
|
194
|
+
const kind = imported.type === "elementum_app" ? "app" : "element";
|
|
195
|
+
const name = typeof imported.attrs["name"] === "string" ? imported.attrs["name"] : tfLabelToTsLabel(imported.label);
|
|
196
|
+
const namespace = typeof imported.attrs["namespace"] === "string" ? imported.attrs["namespace"] : undefined;
|
|
197
|
+
const refName = namespace !== undefined
|
|
198
|
+
? (kind === "app" ? ctx.foreignAppRefNamespaces?.get(namespace) : ctx.foreignElementRefNamespaces?.get(namespace))
|
|
199
|
+
: (kind === "app" ? ctx.foreignAppRefNames?.get(name) : ctx.foreignElementRefNames?.get(name));
|
|
200
|
+
return {
|
|
201
|
+
kind,
|
|
202
|
+
key: refName ?? tfLabelToTsLabel(imported.label),
|
|
203
|
+
name,
|
|
204
|
+
...(namespace !== undefined ? { namespace } : {}),
|
|
205
|
+
...(refName !== undefined ? { catalogRef: true } : {}),
|
|
206
|
+
};
|
|
207
|
+
}
|
|
165
208
|
function widgetFieldRef(value, target, owner, ctx) {
|
|
166
209
|
if (typeof value === "string")
|
|
167
|
-
return value;
|
|
168
|
-
const targetLabel = typeof target === "string"
|
|
169
|
-
|
|
210
|
+
return fieldRefFromRawId(value, target, owner, ctx) ?? value;
|
|
211
|
+
const targetLabel = typeof target === "string"
|
|
212
|
+
? undefined
|
|
213
|
+
: target.key === owner.ownerRefName
|
|
214
|
+
? owner.ownerTfLabel
|
|
215
|
+
: target.namespace ?? tsLabelToTfLabel(target.key);
|
|
216
|
+
const targetScope = typeof target === "string" || target.kind === "automation" || target.kind === "field" || target.kind === "recordIdentity" ? owner.scope : target.kind;
|
|
170
217
|
if (targetLabel !== undefined) {
|
|
171
218
|
const key = fieldKeyFromTfRef(value, targetLabel, targetScope);
|
|
172
219
|
if (key !== undefined) {
|
|
@@ -179,6 +226,10 @@ function widgetFieldRef(value, target, owner, ctx) {
|
|
|
179
226
|
return { kind: "field", key: tfLabelToTsLabel(dataLabel), name, ...(typeof target !== "string" && { parent: target.key }), fieldType: "TEXT" };
|
|
180
227
|
}
|
|
181
228
|
if (isTfExpr(value) && value.$expr === "resource-attr" && value.path.length === 1 && value.path[0] === "id") {
|
|
229
|
+
const identityTarget = recordIdentityTarget(value.type, target);
|
|
230
|
+
if (identityTarget !== undefined) {
|
|
231
|
+
return { kind: "recordIdentity", key: "id", name: "Record ID", target: identityTarget };
|
|
232
|
+
}
|
|
182
233
|
const subType = SUB_TYPE_BY_RESOURCE.get(value.type);
|
|
183
234
|
if (subType !== undefined) {
|
|
184
235
|
return { kind: "field", key: tfLabelToTsLabel(value.label), name: tfLabelToTsLabel(value.label), ...(typeof target !== "string" && { parent: target.key }), fieldType: subType.authoringType };
|
|
@@ -186,6 +237,12 @@ function widgetFieldRef(value, target, owner, ctx) {
|
|
|
186
237
|
}
|
|
187
238
|
return undefined;
|
|
188
239
|
}
|
|
240
|
+
function recordIdentityTarget(resourceType, target) {
|
|
241
|
+
if (typeof target === "string" || (target.kind !== "app" && target.kind !== "element"))
|
|
242
|
+
return undefined;
|
|
243
|
+
const targetType = target.kind === "app" ? "elementum_app" : "elementum_element";
|
|
244
|
+
return resourceType === WIDGET_RESOURCE_TYPE || resourceType === targetType ? target : undefined;
|
|
245
|
+
}
|
|
189
246
|
function automationRef(value, owner) {
|
|
190
247
|
if (typeof value === "string")
|
|
191
248
|
return value;
|
|
@@ -199,11 +256,68 @@ function automationRef(value, owner) {
|
|
|
199
256
|
parent: owner.ownerRefName,
|
|
200
257
|
};
|
|
201
258
|
}
|
|
202
|
-
function ownerFieldRef(value, owner) {
|
|
259
|
+
function ownerFieldRef(value, owner, ctx) {
|
|
203
260
|
if (value === undefined || value === null)
|
|
204
261
|
return undefined;
|
|
205
262
|
if (typeof value === "string")
|
|
206
|
-
return value;
|
|
263
|
+
return fieldRefFromRawId(value, owner.ownerRefName, owner, ctx) ?? value;
|
|
207
264
|
const key = fieldKeyFromTfRef(value, owner.ownerTfLabel, owner.scope);
|
|
208
265
|
return key === undefined ? undefined : { kind: "field", key, name: key, parent: owner.ownerRefName, fieldType: "TEXT" };
|
|
209
266
|
}
|
|
267
|
+
function fieldRefFromRawId(id, target, owner, ctx) {
|
|
268
|
+
if (id === "")
|
|
269
|
+
return undefined;
|
|
270
|
+
const stateRef = ctx.foreignFieldRefsById?.get(id);
|
|
271
|
+
if (stateRef !== undefined) {
|
|
272
|
+
// runAutomation field_id is owner-scoped (same check as fieldKeyFromTfValue).
|
|
273
|
+
// Widget columns accept any registry hit and keep the field's real parent.
|
|
274
|
+
if (typeof target === "string" && target === owner.ownerRefName && stateRef.ownerRefName !== owner.ownerRefName) {
|
|
275
|
+
return undefined;
|
|
276
|
+
}
|
|
277
|
+
return {
|
|
278
|
+
kind: "field",
|
|
279
|
+
key: stateRef.fieldKey,
|
|
280
|
+
name: stateRef.fieldName ?? stateRef.fieldKey,
|
|
281
|
+
parent: stateRef.ownerRefName,
|
|
282
|
+
fieldType: "TEXT",
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
const imported = ctx.importedResource?.(id);
|
|
286
|
+
if (imported === undefined)
|
|
287
|
+
return undefined;
|
|
288
|
+
const subType = SUB_TYPE_BY_RESOURCE.get(imported.type);
|
|
289
|
+
if (subType === undefined)
|
|
290
|
+
return undefined;
|
|
291
|
+
const ownerKey = fieldKeyIfScopedTo(imported.type, imported.label, owner.ownerTfLabel, owner.scope);
|
|
292
|
+
if (ownerKey !== undefined) {
|
|
293
|
+
return {
|
|
294
|
+
kind: "field",
|
|
295
|
+
key: ownerKey,
|
|
296
|
+
name: typeof imported.attrs["name"] === "string" ? imported.attrs["name"] : ownerKey,
|
|
297
|
+
parent: owner.ownerRefName,
|
|
298
|
+
fieldType: subType.authoringType,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
if (typeof target !== "string" && target.kind !== "automation" && target.kind !== "field" && target.kind !== "recordIdentity") {
|
|
302
|
+
const targetTfLabel = target.key === owner.ownerRefName
|
|
303
|
+
? owner.ownerTfLabel
|
|
304
|
+
: target.namespace ?? tsLabelToTfLabel(target.key);
|
|
305
|
+
const targetKey = fieldKeyIfScopedTo(imported.type, imported.label, targetTfLabel, target.kind);
|
|
306
|
+
if (targetKey !== undefined) {
|
|
307
|
+
return {
|
|
308
|
+
kind: "field",
|
|
309
|
+
key: targetKey,
|
|
310
|
+
name: typeof imported.attrs["name"] === "string" ? imported.attrs["name"] : targetKey,
|
|
311
|
+
parent: target.key,
|
|
312
|
+
fieldType: subType.authoringType,
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return undefined;
|
|
317
|
+
}
|
|
318
|
+
/** `fieldKeyFromTfRef` camelCases any label; only treat it as owned when the scoped prefix was actually stripped. */
|
|
319
|
+
function fieldKeyIfScopedTo(type, label, ownerTfLabel, scope) {
|
|
320
|
+
if (bareChildResourceLabel(ownerTfLabel, label, scope) === label)
|
|
321
|
+
return undefined;
|
|
322
|
+
return fieldKeyFromTfRef({ $expr: "resource-attr", type, label, path: ["id"] }, ownerTfLabel, scope);
|
|
323
|
+
}
|
|
@@ -8,6 +8,7 @@ interface RefWire {
|
|
|
8
8
|
readonly namespace?: string;
|
|
9
9
|
readonly parent?: string;
|
|
10
10
|
readonly fieldType?: string;
|
|
11
|
+
readonly target?: RefWire | string;
|
|
11
12
|
}
|
|
12
13
|
interface WidgetParameterWire {
|
|
13
14
|
readonly name?: string;
|
|
@@ -31,6 +32,16 @@ export interface AppWidgetWire {
|
|
|
31
32
|
readonly automation?: RefWire | string;
|
|
32
33
|
readonly parameters?: readonly WidgetParameterWire[];
|
|
33
34
|
}
|
|
35
|
+
export interface RelationshipTargetWire {
|
|
36
|
+
readonly kind?: string;
|
|
37
|
+
readonly refName?: string;
|
|
38
|
+
}
|
|
39
|
+
export declare function relationshipTargetsFromBag(relationships: Readonly<Record<string, {
|
|
40
|
+
readonly target?: {
|
|
41
|
+
readonly __kind?: string;
|
|
42
|
+
readonly refName?: string;
|
|
43
|
+
};
|
|
44
|
+
}>> | undefined): RelationshipTargetWire[];
|
|
34
45
|
export interface WidgetsToTfOptions {
|
|
35
46
|
readonly ownerRefName: string;
|
|
36
47
|
readonly ownerTfLabel: string;
|
|
@@ -41,6 +52,12 @@ export interface WidgetsToTfOptions {
|
|
|
41
52
|
readonly workspaceAspects?: ReadonlyMap<string, WorkspaceAspect>;
|
|
42
53
|
readonly diagnostics: string[];
|
|
43
54
|
readonly fieldAddresses?: ReadonlyMap<string, string>;
|
|
55
|
+
/**
|
|
56
|
+
* Targets of this owner's authored `relationships[]` joins. A foreign
|
|
57
|
+
* `relatedRecords` widget needs one of these; child `relationField` /
|
|
58
|
+
* `autoRelate` does not populate the widget.
|
|
59
|
+
*/
|
|
60
|
+
readonly relationshipTargets?: readonly RelationshipTargetWire[];
|
|
44
61
|
}
|
|
45
62
|
export declare function widgetsToTf(widgets: Readonly<Record<string, AppWidgetWire>> | undefined, opts: WidgetsToTfOptions): TfBlock[];
|
|
46
63
|
export {};
|
|
@@ -5,6 +5,12 @@ import { AUTOMATION_RESOURCE_TYPE } from "../automation/types.js";
|
|
|
5
5
|
import { fieldRefToTfValue } from "../field/to-tf.js";
|
|
6
6
|
import { WIDGET_RESOURCE_TYPE } from "./module.js";
|
|
7
7
|
import { filterToTf } from "../access-policy/to-tf.js";
|
|
8
|
+
export function relationshipTargetsFromBag(relationships) {
|
|
9
|
+
return Object.values(relationships ?? {}).map((relationship) => ({
|
|
10
|
+
kind: relationship.target?.__kind,
|
|
11
|
+
refName: relationship.target?.refName,
|
|
12
|
+
}));
|
|
13
|
+
}
|
|
8
14
|
export function widgetsToTf(widgets, opts) {
|
|
9
15
|
const blocks = [];
|
|
10
16
|
for (const [key, widget] of Object.entries(widgets ?? {})) {
|
|
@@ -19,6 +25,7 @@ export function widgetsToTf(widgets, opts) {
|
|
|
19
25
|
const target = resolveAspect(widget.target, `${where}.target`, opts);
|
|
20
26
|
if (target === undefined)
|
|
21
27
|
continue;
|
|
28
|
+
diagnoseRelatedRecordsJoin(where, target, opts);
|
|
22
29
|
const body = { name: widget.name ?? "", object_id: target.value };
|
|
23
30
|
// Always emitted, even empty — the provider schema treats columns as
|
|
24
31
|
// always-present on related-object/related-link widgets, so omitting
|
|
@@ -86,6 +93,24 @@ export function widgetsToTf(widgets, opts) {
|
|
|
86
93
|
}
|
|
87
94
|
return blocks;
|
|
88
95
|
}
|
|
96
|
+
function diagnoseRelatedRecordsJoin(where, target, opts) {
|
|
97
|
+
if (target.refName === undefined || target.kind === undefined)
|
|
98
|
+
return;
|
|
99
|
+
const isSelf = target.kind === opts.scope && target.refName === opts.ownerRefName;
|
|
100
|
+
if (isSelf)
|
|
101
|
+
return;
|
|
102
|
+
const matches = (opts.relationshipTargets ?? []).some((relationship) => {
|
|
103
|
+
const kind = relationship.kind === "element"
|
|
104
|
+
? "element"
|
|
105
|
+
: relationship.kind === "table"
|
|
106
|
+
? "table"
|
|
107
|
+
: "app";
|
|
108
|
+
return kind === target.kind && relationship.refName === target.refName;
|
|
109
|
+
});
|
|
110
|
+
if (matches)
|
|
111
|
+
return;
|
|
112
|
+
opts.diagnostics.push(`${where}: relatedRecords lists records through an authored relationships[] join on this ${opts.scope}, not through a child relationField or autoRelate. Add relationships.<key> targeting "${target.refName}" whose columns join comparable stored values. Do not join this object's system "id" (HANDLE) to a child relationField.`);
|
|
113
|
+
}
|
|
89
114
|
function buttonBody(widget) {
|
|
90
115
|
const body = {
|
|
91
116
|
name: widget.name ?? "",
|
|
@@ -134,6 +159,21 @@ function resolveColumns(columns, target, where, opts) {
|
|
|
134
159
|
out.push(value);
|
|
135
160
|
continue;
|
|
136
161
|
}
|
|
162
|
+
if (value != null && value.__kind === "recordIdentity") {
|
|
163
|
+
if (value.target === undefined) {
|
|
164
|
+
opts.diagnostics.push(`${where}[${index}]: record identity has no target; dropped`);
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
const identityTarget = resolveAspect(value.target, `${where}[${index}].target`, opts);
|
|
168
|
+
if (identityTarget === undefined)
|
|
169
|
+
continue;
|
|
170
|
+
if (target.kind !== identityTarget.kind || target.refName !== identityTarget.refName) {
|
|
171
|
+
opts.diagnostics.push(`${where}[${index}]: record identity target does not match widget target; dropped`);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
out.push(target.value);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
137
177
|
if (value == null) {
|
|
138
178
|
opts.diagnostics.push(`${where}[${index}]: field reference is unresolved (skipped during extract); dropped`);
|
|
139
179
|
continue;
|
|
@@ -362,12 +362,20 @@ export interface BuildChildContext {
|
|
|
362
362
|
* catalog (#490).
|
|
363
363
|
*/
|
|
364
364
|
readonly fieldNamesByAppRefName?: ReadonlyMap<string, ReadonlyMap<string, string>>;
|
|
365
|
+
/**
|
|
366
|
+
* Field resource addresses for every app/element in this build, keyed the
|
|
367
|
+
* same way as {@link fieldNamesByAppRefName}. A calculation addresses a
|
|
368
|
+
* found record's field by field id, so a cross-app `recordSearch` output
|
|
369
|
+
* used in a formula needs the searched aspect's field resources.
|
|
370
|
+
*/
|
|
371
|
+
readonly fieldAddressesByAppRefName?: ReadonlyMap<string, ReadonlyMap<string, string>>;
|
|
365
372
|
/** Pulled roots may retain picklist labels removed from the live field. */
|
|
366
373
|
readonly allowUnknownPicklistOptions?: boolean;
|
|
367
374
|
/** Every app/element/table stream root in this build, by refName (see `ToTfContext.workspaceAspects`). */
|
|
368
375
|
readonly workspaceAspects?: ReadonlyMap<string, {
|
|
369
376
|
readonly kind: ChildResourceScope | "table";
|
|
370
377
|
readonly tfLabel: string;
|
|
378
|
+
readonly streamRootEntity?: DeployableEntity;
|
|
371
379
|
}>;
|
|
372
380
|
/** The current app/element/table entity, forwarded for owner-local reference resolution. */
|
|
373
381
|
readonly streamRootEntity?: DeployableEntity;
|
package/package.json
CHANGED