@elementumai/edk 0.9.6 → 0.9.9
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 +34 -3
- package/dist-sdk/src/catalog/factories.d.ts +26 -6
- package/dist-sdk/src/catalog/factories.js +41 -6
- package/dist-sdk/src/catalog/from-authoring.js +27 -33
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +2 -2
- package/dist-sdk/src/catalog/org.js +93 -42
- package/dist-sdk/src/catalog/token.js +10 -0
- package/dist-sdk/src/catalog/types.d.ts +42 -3
- package/dist-sdk/src/catalog/types.js +5 -0
- package/dist-sdk/src/core/index.d.ts +2 -2
- package/dist-sdk/src/core/index.js +1 -1
- package/dist-sdk/src/core/platform-id.d.ts +2 -0
- package/dist-sdk/src/core/platform-id.js +4 -0
- package/dist-sdk/src/core/system-fields.d.ts +18 -0
- package/dist-sdk/src/core/system-fields.js +21 -0
- package/dist-sdk/src/core/triggers/on-demand.d.ts +27 -24
- package/dist-sdk/src/core/triggers/on-demand.js +33 -12
- package/dist-sdk/src/core/types/app.d.ts +14 -9
- package/dist-sdk/src/core/types/aspect-category.d.ts +1 -0
- package/dist-sdk/src/core/types/aspect-category.js +1 -0
- package/dist-sdk/src/core/types/platform.d.ts +1 -1
- package/dist-sdk/src/engine/build/context.d.ts +24 -8
- package/dist-sdk/src/engine/build/source-context.d.ts +14 -17
- package/dist-sdk/src/engine/build/source-context.js +1 -1
- package/dist-sdk/src/engine/pull/context.d.ts +18 -0
- package/dist-sdk/src/engine/pull/org.d.ts +4 -0
- package/dist-sdk/src/engine/pull/org.js +17 -2
- package/dist-sdk/src/engine/pull/procedure-refs.d.ts +16 -0
- package/dist-sdk/src/engine/pull/procedure-refs.js +69 -0
- package/dist-sdk/src/engine/pull/ref-only.d.ts +14 -0
- package/dist-sdk/src/engine/pull/ref-only.js +35 -2
- package/dist-sdk/src/engine/tf/expr.js +1 -1
- package/dist-sdk/src/engine/workspace/authoring-layout.d.ts +15 -0
- package/dist-sdk/src/engine/workspace/authoring-layout.js +33 -1
- package/dist-sdk/src/engine/workspace/loader.d.ts +40 -0
- package/dist-sdk/src/engine/workspace/loader.js +328 -0
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +4 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +24 -4
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +7 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +11 -3
- package/dist-sdk/src/entities/agent/build.d.ts +54 -8
- package/dist-sdk/src/entities/agent/build.js +36 -1
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +144 -3
- package/dist-sdk/src/entities/agent/from-tf.d.ts +7 -6
- package/dist-sdk/src/entities/agent/from-tf.js +176 -5
- package/dist-sdk/src/entities/agent/index.d.ts +2 -2
- package/dist-sdk/src/entities/agent/index.js +1 -1
- package/dist-sdk/src/entities/agent/module.js +1 -0
- package/dist-sdk/src/entities/agent/to-tf.d.ts +5 -4
- package/dist-sdk/src/entities/agent/to-tf.js +186 -11
- package/dist-sdk/src/entities/agent/tools.d.ts +16 -5
- package/dist-sdk/src/entities/agent/tools.js +13 -1
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +16 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.js +39 -6
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.js +12 -12
- package/dist-sdk/src/entities/agent-tool/types.js +1 -0
- package/dist-sdk/src/entities/app/build.d.ts +44 -24
- package/dist-sdk/src/entities/app/build.js +18 -8
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +15 -0
- package/dist-sdk/src/entities/app/display-blocks-to-layout.d.ts +45 -0
- package/dist-sdk/src/entities/app/display-blocks-to-layout.js +98 -0
- package/dist-sdk/src/entities/app/display-blocks-to-record-create-form.d.ts +55 -0
- package/dist-sdk/src/entities/app/display-blocks-to-record-create-form.js +99 -0
- package/dist-sdk/src/entities/app/from-tf.js +79 -14
- package/dist-sdk/src/entities/app/index.d.ts +3 -2
- package/dist-sdk/src/entities/app/index.js +2 -1
- package/dist-sdk/src/entities/app/to-tf.js +30 -6
- package/dist-sdk/src/entities/automation/build.d.ts +37 -18
- package/dist-sdk/src/entities/automation/build.js +121 -12
- package/dist-sdk/src/entities/automation/catalog-render.js +5 -2
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +8 -10
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +2 -0
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +103 -20
- package/dist-sdk/src/entities/automation/from-tf.d.ts +10 -1
- package/dist-sdk/src/entities/automation/from-tf.js +1165 -91
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/module.js +15 -5
- package/dist-sdk/src/entities/automation/operators.d.ts +2 -2
- package/dist-sdk/src/entities/automation/operators.js +1 -0
- package/dist-sdk/src/entities/automation/output-field-types.d.ts +17 -0
- package/dist-sdk/src/entities/automation/output-field-types.js +45 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +20 -4
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +33 -6
- package/dist-sdk/src/entities/automation/script-code.d.ts +1 -1
- package/dist-sdk/src/entities/automation/script-code.js +168 -36
- package/dist-sdk/src/entities/automation/task-label.d.ts +2 -0
- package/dist-sdk/src/entities/automation/task-label.js +18 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +159 -45
- package/dist-sdk/src/entities/automation/tasks.js +60 -47
- package/dist-sdk/src/entities/automation/to-tf.d.ts +7 -1
- package/dist-sdk/src/entities/automation/to-tf.js +816 -87
- package/dist-sdk/src/entities/automation/triggers.d.ts +14 -5
- package/dist-sdk/src/entities/automation/triggers.js +1 -1
- package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +78 -0
- package/dist-sdk/src/entities/automation/value-ref-tf.js +193 -0
- package/dist-sdk/src/entities/dashboard/from-tf.js +1 -1
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +1 -1
- package/dist-sdk/src/entities/element/build.d.ts +30 -7
- package/dist-sdk/src/entities/element/build.js +7 -3
- package/dist-sdk/src/entities/element/from-tf.js +7 -3
- package/dist-sdk/src/entities/element/index.d.ts +3 -2
- package/dist-sdk/src/entities/element/index.js +3 -2
- package/dist-sdk/src/entities/element/to-tf.js +49 -8
- package/dist-sdk/src/entities/field/build.d.ts +94 -3
- package/dist-sdk/src/entities/field/build.js +82 -3
- package/dist-sdk/src/entities/field/from-tf.d.ts +6 -0
- package/dist-sdk/src/entities/field/from-tf.js +104 -1
- package/dist-sdk/src/entities/field/locals.js +6 -7
- package/dist-sdk/src/entities/field/module.js +1 -0
- package/dist-sdk/src/entities/field/options.d.ts +2 -0
- package/dist-sdk/src/entities/field/options.js +12 -2
- package/dist-sdk/src/entities/field/record-shape.d.ts +12 -15
- package/dist-sdk/src/entities/field/to-tf.d.ts +13 -3
- package/dist-sdk/src/entities/field/to-tf.js +191 -56
- package/dist-sdk/src/entities/field/types.js +2 -0
- package/dist-sdk/src/entities/org/category-ref.d.ts +5 -0
- package/dist-sdk/src/entities/org/category-ref.js +12 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -3
- package/dist-sdk/src/entities/record-create-form/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/record-create-form/to-tf.js +18 -13
- package/dist-sdk/src/entities/relationship/from-tf.js +100 -7
- package/dist-sdk/src/entities/role/from-tf.js +10 -4
- package/dist-sdk/src/entities/search-table/build.d.ts +1 -1
- package/dist-sdk/src/entities/search-table/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/search-table/from-tf.js +6 -0
- package/dist-sdk/src/entities/search-table/printer.js +3 -1
- package/dist-sdk/src/entities/search-table/to-tf.js +3 -3
- package/dist-sdk/src/entities/search-table/types.js +1 -0
- package/dist-sdk/src/entities/service-account/from-tf.js +10 -4
- package/dist-sdk/src/entities/service-account/to-tf.d.ts +2 -1
- package/dist-sdk/src/entities/service-account/to-tf.js +7 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +9 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +39 -0
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +24 -1
- package/dist-sdk/src/entities/shared/filters/ast.js +4 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +13 -2
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +14 -8
- package/dist-sdk/src/entities/shared/handle-description.d.ts +12 -0
- package/dist-sdk/src/entities/shared/handle-description.js +20 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +5 -3
- package/dist-sdk/src/entities/shared/tool-field-ref.js +11 -16
- package/dist-sdk/src/entities/shared/types/common.d.ts +7 -5
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +6 -1
- package/dist-sdk/src/entities/shared/types/field-types.js +5 -8
- package/dist-sdk/src/entities/shared/types/platform.d.ts +15 -2
- package/dist-sdk/src/entities/skill/build.d.ts +51 -2
- package/dist-sdk/src/entities/skill/build.js +65 -8
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +1 -1
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +79 -18
- package/dist-sdk/src/entities/skill/from-tf.d.ts +11 -0
- package/dist-sdk/src/entities/skill/from-tf.js +47 -5
- package/dist-sdk/src/entities/skill/index.d.ts +1 -1
- package/dist-sdk/src/entities/skill/index.js +1 -1
- package/dist-sdk/src/entities/skill/input-coverage.d.ts +89 -0
- package/dist-sdk/src/entities/skill/input-coverage.js +327 -0
- package/dist-sdk/src/entities/skill/module.js +2 -0
- package/dist-sdk/src/entities/skill/to-tf.d.ts +9 -25
- package/dist-sdk/src/entities/skill/to-tf.js +29 -40
- package/dist-sdk/src/entities/skill/tools.d.ts +12 -2
- package/dist-sdk/src/entities/skill/tools.js +3 -6
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +19 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +50 -14
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +9 -7
- package/dist-sdk/src/entities/skill-tool/to-tf.js +29 -23
- package/dist-sdk/src/entities/table/to-tf.js +21 -5
- package/dist-sdk/src/entities/task/to-tf.js +3 -2
- package/dist-sdk/src/entities/view/from-tf.js +36 -10
- package/dist-sdk/src/entities/view/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/view/to-tf.js +49 -30
- package/dist-sdk/src/entities/visual-flow/from-tf.js +6 -2
- package/dist-sdk/src/entities/widget/from-tf.js +2 -2
- package/dist-sdk/src/entities/widget/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/widget/to-tf.js +52 -23
- package/dist-sdk/src/graph/index.d.ts +19 -1
- package/dist-sdk/src/graph/index.js +20 -0
- package/dist-sdk/src/graph/types.d.ts +22 -0
- package/package.json +11 -5
|
@@ -22,18 +22,6 @@ function asOrgFieldRef(v) {
|
|
|
22
22
|
return undefined;
|
|
23
23
|
return v;
|
|
24
24
|
}
|
|
25
|
-
/**
|
|
26
|
-
* True when `sort` is the one known `{ orders: [{ field, ... }] }` shape —
|
|
27
|
-
* a single `orders` key whose value is an array of objects each carrying a
|
|
28
|
-
* `field`. Anything else (including an empty/absent `orders`) is opaque data
|
|
29
|
-
* and passes through unresolved, same as before #484.
|
|
30
|
-
*/
|
|
31
|
-
function isDynamicPicklistOrdersSort(sort) {
|
|
32
|
-
const keys = Object.keys(sort);
|
|
33
|
-
const orders = sort.orders;
|
|
34
|
-
return keys.length === 1 && keys[0] === "orders" && Array.isArray(orders) &&
|
|
35
|
-
orders.length > 0 && orders.every((o) => typeof o === "object" && o !== null && "field" in o);
|
|
36
|
-
}
|
|
37
25
|
/**
|
|
38
26
|
* Project the subset of the public numeric-format contract that the field
|
|
39
27
|
* resources own today. Unsupported properties are diagnosed individually so
|
|
@@ -121,12 +109,12 @@ function resolveRelatedObject(token, opts, where) {
|
|
|
121
109
|
opts.orgRefs.foreignElement(tfLabel, name, token.namespace);
|
|
122
110
|
if (token.namespace === undefined)
|
|
123
111
|
opts.diagnostics.push(`${where}: foreign element ${JSON.stringify(name)} has no namespace; using less-stable name lookup`);
|
|
124
|
-
return { value: expr.dataAttr("elementum_element", tfLabel, ["id"]), refName, kind };
|
|
112
|
+
return { value: expr.dataAttr("elementum_element", tfLabel, ["id"]), refName, kind, foreignTfLabel: tfLabel };
|
|
125
113
|
}
|
|
126
114
|
opts.orgRefs.foreignApp(tfLabel, name, token.namespace);
|
|
127
115
|
if (token.namespace === undefined)
|
|
128
116
|
opts.diagnostics.push(`${where}: foreign app ${JSON.stringify(name)} has no namespace; using less-stable name lookup`);
|
|
129
|
-
return { value: expr.dataAttr("elementum_app", tfLabel, ["id"]), refName, kind };
|
|
117
|
+
return { value: expr.dataAttr("elementum_app", tfLabel, ["id"]), refName, kind, foreignTfLabel: tfLabel };
|
|
130
118
|
}
|
|
131
119
|
/**
|
|
132
120
|
* A field token naming a field on an already-resolved target aspect →
|
|
@@ -184,8 +172,16 @@ function resolveFieldOnObject(token, object, opts, where, attrName = "relatedLab
|
|
|
184
172
|
return undefined;
|
|
185
173
|
}
|
|
186
174
|
const name = token.name ?? refName;
|
|
187
|
-
|
|
188
|
-
|
|
175
|
+
// Match ei export and every other object-scoped field lookup: the label is
|
|
176
|
+
// based on the provider root type + the ACTUAL root lookup label + field
|
|
177
|
+
// display name. Re-deriving it from the public refName produces a second,
|
|
178
|
+
// semantically identical data block when (for example) a relationship and
|
|
179
|
+
// a dynamic Dropdown both reference the same foreign field.
|
|
180
|
+
const ownerType = object.kind === "element" ? "elementum_element" : object.kind === "app" ? "elementum_app" : undefined;
|
|
181
|
+
const parentLabel = object.foreignTfLabel ?? (token.parent !== undefined ? tsLabelToTfLabel(token.parent) : "related");
|
|
182
|
+
const tfLabel = ownerType === undefined
|
|
183
|
+
? sanitizeName(`${parentLabel}_${name}`)
|
|
184
|
+
: sanitizeName(`${ownerType}_${parentLabel}_${name}`);
|
|
189
185
|
opts.orgRefs.foreignField("elementum_field", tfLabel, object.value, name);
|
|
190
186
|
return expr.dataAttr("elementum_field", tfLabel, ["id"]);
|
|
191
187
|
}
|
|
@@ -214,8 +210,8 @@ function stageOrgRefs(real) {
|
|
|
214
210
|
byName: (bag, name) => real.byName(bag, name),
|
|
215
211
|
foreignSkill: (tfLabel, name, appId) => pending.push(() => real.foreignSkill(tfLabel, name, appId)),
|
|
216
212
|
rawLookup: (type, tfLabel, value, extraAttrs) => pending.push(() => real.rawLookup(type, tfLabel, value, extraAttrs)),
|
|
217
|
-
foreignApp: (tfLabel, name) => pending.push(() => real.foreignApp(tfLabel, name)),
|
|
218
|
-
foreignElement: (tfLabel, name) => pending.push(() => real.foreignElement(tfLabel, name)),
|
|
213
|
+
foreignApp: (tfLabel, name, namespace) => pending.push(() => real.foreignApp(tfLabel, name, namespace)),
|
|
214
|
+
foreignElement: (tfLabel, name, namespace) => pending.push(() => real.foreignElement(tfLabel, name, namespace)),
|
|
219
215
|
foreignField: (type, tfLabel, objectId, name) => pending.push(() => real.foreignField(type, tfLabel, objectId, name)),
|
|
220
216
|
};
|
|
221
217
|
return { orgRefs, commit: () => { for (const apply of pending)
|
|
@@ -235,7 +231,7 @@ function stageOrgRefs(real) {
|
|
|
235
231
|
* and committed only once the ENTIRE config resolves — an early `undefined`
|
|
236
232
|
* return anywhere below leaves no orphaned `data.tf` block behind.
|
|
237
233
|
*/
|
|
238
|
-
function buildDynamicPicklistConfigAttr(cfg, opts, where) {
|
|
234
|
+
function buildDynamicPicklistConfigAttr(cfg, opts, where, typeKey) {
|
|
239
235
|
if (cfg.relatedAspectId === undefined || cfg.relatedLabelFieldId === undefined) {
|
|
240
236
|
opts.diagnostics.push(`${where}: dynamic picklist config requires relatedAspectId and relatedLabelFieldId; dropped`);
|
|
241
237
|
return undefined;
|
|
@@ -263,8 +259,33 @@ function buildDynamicPicklistConfigAttr(cfg, opts, where) {
|
|
|
263
259
|
return undefined;
|
|
264
260
|
attrs["parent_field_id"] = parentFieldId;
|
|
265
261
|
}
|
|
266
|
-
if (cfg.
|
|
267
|
-
|
|
262
|
+
if (cfg.parentMappings !== undefined) {
|
|
263
|
+
const mappings = [];
|
|
264
|
+
for (const mapping of cfg.parentMappings) {
|
|
265
|
+
if (mapping.parentAspectFieldId === undefined || mapping.relatedAspectFieldId === undefined) {
|
|
266
|
+
opts.diagnostics.push(`${where}: dynamic parent mapping requires parentAspectFieldId and relatedAspectFieldId; dropped`);
|
|
267
|
+
return undefined;
|
|
268
|
+
}
|
|
269
|
+
const parentMappingObject = resolveDynamicMappingFieldOwner(mapping.parentAspectFieldId, opts, where);
|
|
270
|
+
if (parentMappingObject === undefined)
|
|
271
|
+
return undefined;
|
|
272
|
+
const parentAspectFieldId = resolveFieldOnObject(mapping.parentAspectFieldId, parentMappingObject, opts, where, "parentMappings.parentAspectFieldId");
|
|
273
|
+
const relatedAspectFieldId = resolveFieldOnObject(mapping.relatedAspectFieldId, resolvedObject, opts, where, "parentMappings.relatedAspectFieldId");
|
|
274
|
+
if (parentAspectFieldId === undefined || relatedAspectFieldId === undefined)
|
|
275
|
+
return undefined;
|
|
276
|
+
mappings.push({ parent_aspect_field_id: parentAspectFieldId, related_aspect_field_id: relatedAspectFieldId });
|
|
277
|
+
}
|
|
278
|
+
attrs["parent_mappings"] = mappings;
|
|
279
|
+
}
|
|
280
|
+
if (cfg.autoRelate !== undefined) {
|
|
281
|
+
// MULTI_PICKLIST create accepts auto_relate=true, but Read hydrates false.
|
|
282
|
+
if (typeKey === "multiPicklist" && cfg.autoRelate === true) {
|
|
283
|
+
opts.diagnostics.push(`${where}: autoRelate is not persisted on multi-select fields and was omitted`);
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
attrs["auto_relate"] = cfg.autoRelate;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
268
289
|
if (cfg.valuesRenderType !== undefined)
|
|
269
290
|
attrs["values_render_type"] = cfg.valuesRenderType;
|
|
270
291
|
if (cfg.filter !== undefined) {
|
|
@@ -296,32 +317,85 @@ function buildDynamicPicklistConfigAttr(cfg, opts, where) {
|
|
|
296
317
|
}
|
|
297
318
|
}
|
|
298
319
|
if (cfg.sort !== undefined) {
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
320
|
+
const sort = resolveDynamicPicklistSort(cfg.sort, resolvedObject, opts, where);
|
|
321
|
+
if (sort === undefined)
|
|
322
|
+
return undefined;
|
|
323
|
+
attrs["sort"] = expr.jsonencode(sort);
|
|
324
|
+
}
|
|
325
|
+
staged?.commit();
|
|
326
|
+
return attrs;
|
|
327
|
+
}
|
|
328
|
+
/** Resolve the aspect that owns a dynamic parent's source-field mapping. */
|
|
329
|
+
function resolveDynamicMappingFieldOwner(token, opts, where) {
|
|
330
|
+
if (typeof token === "string")
|
|
331
|
+
return { value: "" };
|
|
332
|
+
if (token.parent === opts.appRefName) {
|
|
333
|
+
return {
|
|
334
|
+
value: opts.objectId,
|
|
335
|
+
refName: opts.appRefName,
|
|
336
|
+
kind: opts.scope ?? "app",
|
|
337
|
+
target: { kind: opts.scope ?? "app", tfLabel: opts.ownerTfLabel },
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
if (token.parent === undefined || token.parentKind === undefined) {
|
|
341
|
+
opts.diagnostics.push(`${where}: parentSourceField must identify its owning app or element; dropped`);
|
|
342
|
+
return undefined;
|
|
343
|
+
}
|
|
344
|
+
return resolveRelatedObject({
|
|
345
|
+
__kind: token.parentKind,
|
|
346
|
+
refName: token.parent,
|
|
347
|
+
name: token.parentName ?? token.parent,
|
|
348
|
+
}, opts, where);
|
|
349
|
+
}
|
|
350
|
+
function resolveDynamicPicklistSort(sort, relatedObject, opts, where) {
|
|
351
|
+
const orders = sort["orders"];
|
|
352
|
+
if (!Array.isArray(orders))
|
|
353
|
+
return sort;
|
|
354
|
+
const resolved = [];
|
|
355
|
+
for (const order of orders) {
|
|
356
|
+
if (typeof order !== "object" || order === null || Array.isArray(order)) {
|
|
357
|
+
opts.diagnostics.push(`${where}: sort order has an unexpected shape; dropped`);
|
|
358
|
+
return undefined;
|
|
319
359
|
}
|
|
320
|
-
|
|
321
|
-
|
|
360
|
+
const record = order;
|
|
361
|
+
const fieldToken = record["field"];
|
|
362
|
+
if (fieldToken === undefined) {
|
|
363
|
+
opts.diagnostics.push(`${where}: sort order requires a field; dropped`);
|
|
364
|
+
return undefined;
|
|
322
365
|
}
|
|
366
|
+
const field = resolveFieldOnObject(fieldToken, relatedObject, opts, where, "sort field");
|
|
367
|
+
if (field === undefined)
|
|
368
|
+
return undefined;
|
|
369
|
+
resolved.push({
|
|
370
|
+
...Object.fromEntries(Object.entries(record).filter(([key]) => key !== "field")),
|
|
371
|
+
aggregation: (record["aggregation"] ?? null),
|
|
372
|
+
field,
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
return { ...sort, orders: resolved };
|
|
376
|
+
}
|
|
377
|
+
function buildStaticPicklistConfigAttr(cfg, opts, where) {
|
|
378
|
+
const attrs = {};
|
|
379
|
+
const owner = {
|
|
380
|
+
value: opts.objectId,
|
|
381
|
+
refName: opts.appRefName,
|
|
382
|
+
kind: opts.scope ?? "app",
|
|
383
|
+
target: { kind: opts.scope ?? "app", tfLabel: opts.ownerTfLabel },
|
|
384
|
+
};
|
|
385
|
+
if (cfg.parentFieldId !== undefined) {
|
|
386
|
+
const parentFieldId = resolveFieldOnObject(cfg.parentFieldId, owner, opts, where, "parentFieldId");
|
|
387
|
+
if (parentFieldId === undefined)
|
|
388
|
+
return undefined;
|
|
389
|
+
attrs["parent_field_id"] = parentFieldId;
|
|
390
|
+
}
|
|
391
|
+
if (cfg.filter !== undefined) {
|
|
392
|
+
opts.diagnostics.push(`${where}: static dropdown filters are not product-authorable; dropped`);
|
|
393
|
+
return undefined;
|
|
394
|
+
}
|
|
395
|
+
if (cfg.sort !== undefined) {
|
|
396
|
+
opts.diagnostics.push(`${where}: static dropdown sort is not product-authorable; dropped`);
|
|
397
|
+
return undefined;
|
|
323
398
|
}
|
|
324
|
-
staged?.commit();
|
|
325
399
|
return attrs;
|
|
326
400
|
}
|
|
327
401
|
/** One custom field → its resource block; undefined = degraded (diagnostic already pushed). */
|
|
@@ -333,14 +407,17 @@ export function fieldToTf(typeKey, inner, opts) {
|
|
|
333
407
|
diagnostics.push(`field "${name}": field type key "${typeKey}" has no terraform field resource mapping; dropped`);
|
|
334
408
|
return undefined;
|
|
335
409
|
}
|
|
336
|
-
if (inner.config !== undefined &&
|
|
337
|
-
|
|
338
|
-
// excludes non-picklist fields, `config.static`, and any other
|
|
339
|
-
// unmodeled config shape (e.g. an `api`/`stage` variant) — all three
|
|
340
|
-
// must degrade here, not fall through as if config were absent.
|
|
341
|
-
diagnostics.push(`field "${name}": ${subType.hasOptions === true ? "static/dependent" : "dependent/dynamic"} picklist config is not supported by the terraform provider yet; dropped`);
|
|
410
|
+
if (inner.config !== undefined && subType.hasOptions !== true) {
|
|
411
|
+
diagnostics.push(`field "${name}": dependent/dynamic dropdown config is only valid on Dropdown and Multi-Select fields; dropped`);
|
|
342
412
|
return undefined;
|
|
343
413
|
}
|
|
414
|
+
if (inner.config !== undefined) {
|
|
415
|
+
const variants = Number(inner.config.dynamic !== undefined) + Number(inner.config.static !== undefined);
|
|
416
|
+
if (variants !== 1) {
|
|
417
|
+
diagnostics.push(`field "${name}": dropdown config requires exactly one of static or dynamic; dropped`);
|
|
418
|
+
return undefined;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
344
421
|
if (subType.hasOptions === true && inner.config?.dynamic !== undefined && inner.picklistValues !== undefined && inner.picklistValues.length > 0) {
|
|
345
422
|
diagnostics.push(`field "${name}": config.dynamic and options are mutually exclusive; dropped`);
|
|
346
423
|
return undefined;
|
|
@@ -471,17 +548,68 @@ export function fieldToTf(typeKey, inner, opts) {
|
|
|
471
548
|
}
|
|
472
549
|
if (subType.hasOptions === true && inner.config?.dynamic !== undefined) {
|
|
473
550
|
const where = `field "${name}"`;
|
|
474
|
-
const dynamicConfig = buildDynamicPicklistConfigAttr(inner.config.dynamic, opts, where);
|
|
551
|
+
const dynamicConfig = buildDynamicPicklistConfigAttr(inner.config.dynamic, opts, where, typeKey);
|
|
475
552
|
if (dynamicConfig === undefined)
|
|
476
553
|
return undefined;
|
|
477
554
|
attrs["dynamic_config"] = dynamicConfig;
|
|
478
555
|
}
|
|
556
|
+
if (subType.hasOptions === true && inner.config?.static !== undefined) {
|
|
557
|
+
const staticConfig = buildStaticPicklistConfigAttr(inner.config.static, opts, `field "${name}"`);
|
|
558
|
+
if (staticConfig === undefined)
|
|
559
|
+
return undefined;
|
|
560
|
+
if (Object.keys(staticConfig).length > 0)
|
|
561
|
+
attrs["static_config"] = staticConfig;
|
|
562
|
+
}
|
|
479
563
|
if (subType.hasOptions === true && inner.picklistValues !== undefined) {
|
|
480
|
-
if (inner.picklistValues.some((pv) => pv.relatedParentValues !== undefined)) {
|
|
481
|
-
diagnostics.push(`field "${name}": dependent option links (parentValues) are not supported by the terraform provider yet; dropped`);
|
|
482
|
-
}
|
|
483
564
|
if (inner.picklistValues.length > 0) {
|
|
484
|
-
attrs["options"] = inner.picklistValues.map((pv) =>
|
|
565
|
+
attrs["options"] = inner.picklistValues.map((pv) => {
|
|
566
|
+
const option = { label: picklistLabel(pv) };
|
|
567
|
+
if (pv.color !== undefined)
|
|
568
|
+
option["color"] = pv.color;
|
|
569
|
+
if (pv.icon !== undefined)
|
|
570
|
+
option["icon"] = pv.icon;
|
|
571
|
+
if (pv.active !== undefined)
|
|
572
|
+
option["active"] = pv.active;
|
|
573
|
+
if (pv.tags !== undefined && pv.tags.length > 0)
|
|
574
|
+
option["tags"] = [...pv.tags];
|
|
575
|
+
if (pv.relatedParentValues !== undefined) {
|
|
576
|
+
if (!Array.isArray(pv.relatedParentValues)) {
|
|
577
|
+
diagnostics.push(`field "${name}": option "${picklistLabel(pv)}" parent values are not a list; dropped`);
|
|
578
|
+
}
|
|
579
|
+
else {
|
|
580
|
+
const parentValueIds = [];
|
|
581
|
+
for (const value of pv.relatedParentValues) {
|
|
582
|
+
if (typeof value === "string") {
|
|
583
|
+
parentValueIds.push(value);
|
|
584
|
+
continue;
|
|
585
|
+
}
|
|
586
|
+
if (typeof value !== "object" || value === null || value.__kind !== "dropdownValue") {
|
|
587
|
+
diagnostics.push(`field "${name}": option "${picklistLabel(pv)}" has an invalid parent value reference; dropped`);
|
|
588
|
+
continue;
|
|
589
|
+
}
|
|
590
|
+
const ref = value;
|
|
591
|
+
if (ref.field === undefined || typeof ref.label !== "string") {
|
|
592
|
+
diagnostics.push(`field "${name}": option "${picklistLabel(pv)}" has an incomplete parent value reference; dropped`);
|
|
593
|
+
continue;
|
|
594
|
+
}
|
|
595
|
+
if (ref.field.parent !== undefined && ref.field.parent !== opts.appRefName) {
|
|
596
|
+
diagnostics.push(`field "${name}": static parent values must belong to the same app/element; dropped`);
|
|
597
|
+
continue;
|
|
598
|
+
}
|
|
599
|
+
const parentType = SUB_TYPE_BY_AUTHORING_TYPE.get(ref.field.fieldType ?? "");
|
|
600
|
+
if (parentType?.hasOptions !== true || ref.field.refName === undefined) {
|
|
601
|
+
diagnostics.push(`field "${name}": parent value reference must target a Dropdown or Multi-Select field; dropped`);
|
|
602
|
+
continue;
|
|
603
|
+
}
|
|
604
|
+
const parentTfLabel = scopedResourceLabel(opts.ownerTfLabel, tsLabelToTfLabel(ref.field.refName), opts.scope ?? "app");
|
|
605
|
+
parentValueIds.push(expr.local(`${parentTfLabel}_options_by_label`, [{ index: ref.label }]));
|
|
606
|
+
}
|
|
607
|
+
if (parentValueIds.length > 0)
|
|
608
|
+
option["parent_value_ids"] = parentValueIds;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
return option;
|
|
612
|
+
});
|
|
485
613
|
}
|
|
486
614
|
}
|
|
487
615
|
const block = { kind: "resource", type: subType.resourceType, label: tfLabel, attrs };
|
|
@@ -506,13 +634,20 @@ function scalarOrUndefined(v) {
|
|
|
506
634
|
*/
|
|
507
635
|
/** Elements only have `id`/`title` as real system fields (no status/stage/audit fields) — see `element/locals.ts`. */
|
|
508
636
|
const ELEMENT_SYSTEM_FIELD_KEYS = new Set(["id", "title"]);
|
|
509
|
-
export function fieldRefToTfValue(fieldType, refName, ownerTfLabel, scope = "app") {
|
|
637
|
+
export function fieldRefToTfValue(fieldType, refName, ownerTfLabel, scope = "app", fieldAddresses) {
|
|
510
638
|
if (!isCanonicalTsLabel(refName))
|
|
511
639
|
return undefined;
|
|
512
640
|
const isSystemField = scope === "element" ? ELEMENT_SYSTEM_FIELD_KEYS.has(refName) : SYSTEM_FIELD_KEY_SET.has(refName);
|
|
513
641
|
if (isSystemField) {
|
|
514
642
|
return expr.local(`${ownerTfLabel}_${tsLabelToTfLabel(refName)}_field_id`);
|
|
515
643
|
}
|
|
644
|
+
const knownAddress = fieldAddresses?.get(refName);
|
|
645
|
+
if (knownAddress !== undefined) {
|
|
646
|
+
const dotIndex = knownAddress.indexOf(".");
|
|
647
|
+
if (dotIndex !== -1) {
|
|
648
|
+
return expr.resourceAttr(knownAddress.slice(0, dotIndex), knownAddress.slice(dotIndex + 1), ["id"]);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
516
651
|
const subType = SUB_TYPE_BY_AUTHORING_TYPE.get(fieldType);
|
|
517
652
|
if (subType === undefined)
|
|
518
653
|
return undefined;
|
|
@@ -66,6 +66,7 @@ export const KNOWN_FIELD_ATTRS = new Set([
|
|
|
66
66
|
"related_label_field_id",
|
|
67
67
|
"auto_relate",
|
|
68
68
|
"dynamic_config",
|
|
69
|
+
"static_config",
|
|
69
70
|
"decimal_places",
|
|
70
71
|
"currency",
|
|
71
72
|
"percentage",
|
|
@@ -74,4 +75,5 @@ export const KNOWN_FIELD_ATTRS = new Set([
|
|
|
74
75
|
"calculation_type",
|
|
75
76
|
"include_type",
|
|
76
77
|
"picklist_field_id",
|
|
78
|
+
"media_types",
|
|
77
79
|
]);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { OrgRefResolution } from "../../engine/build/context.js";
|
|
2
|
+
import { type TfExpr } from "../../engine/tf/index.js";
|
|
3
|
+
/** Resource ID when the category is created in this apply; otherwise a live data lookup. */
|
|
4
|
+
export declare function categoryIdExpr(resolved: OrgRefResolution): TfExpr;
|
|
5
|
+
export declare function missingCategoryDiagnostic(name: string): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { expr } from "../../engine/tf/index.js";
|
|
2
|
+
const CATEGORY_RESOURCE_TYPE = "elementum_category";
|
|
3
|
+
/** Resource ID when the category is created in this apply; otherwise a live data lookup. */
|
|
4
|
+
export function categoryIdExpr(resolved) {
|
|
5
|
+
return resolved.managed === true
|
|
6
|
+
? expr.resourceAttr(CATEGORY_RESOURCE_TYPE, resolved.tfLabel, ["id"])
|
|
7
|
+
: expr.dataAttr(CATEGORY_RESOURCE_TYPE, resolved.tfLabel, ["id"]);
|
|
8
|
+
}
|
|
9
|
+
export function missingCategoryDiagnostic(name) {
|
|
10
|
+
return (`category ${JSON.stringify(name)} is not in organization.ts or the org catalog — ` +
|
|
11
|
+
`add it to organization.ts (same apply) or re-run \`elementum pull org --data-only\``);
|
|
12
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { optionalString, plainObject, resourceRefLabel } from "../../engine/pull/context.js";
|
|
2
2
|
import { reportUnknownAttrs } from "../../engine/pull/attrs.js";
|
|
3
|
-
import { scopedLabelToBagKey } from "../../engine/tf/index.js";
|
|
4
|
-
import {
|
|
3
|
+
import { scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
4
|
+
import { fieldKeyFromTfValue } from "../field/from-tf.js";
|
|
5
5
|
import { RECORD_CREATE_FORM_RESOURCE_TYPE } from "./module.js";
|
|
6
6
|
const KNOWN_ATTRS = new Set(["app_id", "sections"]);
|
|
7
7
|
const KNOWN_SECTION_ATTRS = new Set([
|
|
@@ -46,7 +46,7 @@ function sectionFromTf(raw, index, formWhere, owner, ctx) {
|
|
|
46
46
|
}
|
|
47
47
|
const fields = [];
|
|
48
48
|
for (const fieldId of fieldIds) {
|
|
49
|
-
const key =
|
|
49
|
+
const key = fieldKeyFromTfValue(fieldId, tfLabelToTsLabel(owner.label), owner.ownerTfLabel, owner.scope, ctx);
|
|
50
50
|
if (key === undefined)
|
|
51
51
|
ctx.diagnostics.push(`${where}: a field_ids entry is not a known field reference; dropped`);
|
|
52
52
|
else
|
|
@@ -28,6 +28,7 @@ export interface RecordCreateFormToTfOptions {
|
|
|
28
28
|
readonly scope: ChildResourceScope;
|
|
29
29
|
readonly objectId: TfValue;
|
|
30
30
|
readonly diagnostics: string[];
|
|
31
|
+
readonly fieldAddresses?: ReadonlyMap<string, string>;
|
|
31
32
|
}
|
|
32
33
|
/** Typed authoring form -> the provider's immutable sections resource. */
|
|
33
34
|
export declare function recordCreateFormToTf(form: RecordCreateFormWire | undefined, opts: RecordCreateFormToTfOptions): TfBlock | undefined;
|
|
@@ -3,11 +3,6 @@ import { fieldRefToTfValue } from "../field/to-tf.js";
|
|
|
3
3
|
import { SUB_TYPE_BY_AUTHORING_TYPE } from "../field/types.js";
|
|
4
4
|
import { SYSTEM_FIELD_ID_ATTR_BY_KEY } from "../view/types.js";
|
|
5
5
|
import { RECORD_CREATE_FORM_RESOURCE_TYPE } from "./module.js";
|
|
6
|
-
// The platform export uses Int32 max for its terminal "Other fields"
|
|
7
|
-
// position, but a newly created form canonicalizes that value to the actual
|
|
8
|
-
// zero-based list position. Sending the sentinel back verbatim therefore
|
|
9
|
-
// makes Terraform see an inconsistent post-create value.
|
|
10
|
-
const PLATFORM_TERMINAL_DISPLAY_ORDER = 2147483647;
|
|
11
6
|
/** Typed authoring form -> the provider's immutable sections resource. */
|
|
12
7
|
export function recordCreateFormToTf(form, opts) {
|
|
13
8
|
if (form === undefined)
|
|
@@ -15,9 +10,11 @@ export function recordCreateFormToTf(form, opts) {
|
|
|
15
10
|
const sections = [];
|
|
16
11
|
for (const [index, section] of (form.sections ?? []).entries()) {
|
|
17
12
|
const where = `recordCreateForm.sections[${index}]`;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
// Emit the authored displayOrder verbatim — including the platform's
|
|
14
|
+
// Int32-max "Other fields" sentinel (2147483647). Rewriting the sentinel
|
|
15
|
+
// to the list index planned a RequiresReplace against adopted Sanofi
|
|
16
|
+
// forms whose state still carries the export value.
|
|
17
|
+
const displayOrder = section.displayOrder ?? index;
|
|
21
18
|
const attrs = {
|
|
22
19
|
name: section.name ?? "",
|
|
23
20
|
field_ids: resolveFields(section.fields ?? [], where, opts),
|
|
@@ -72,15 +69,23 @@ function resolveFields(refs, where, opts) {
|
|
|
72
69
|
opts.diagnostics.push(`${where}: field "${refName}" targets a different aspect; dropped`);
|
|
73
70
|
continue;
|
|
74
71
|
}
|
|
75
|
-
if (!SUB_TYPE_BY_AUTHORING_TYPE.has(ref.fieldType ?? "")) {
|
|
76
|
-
opts.diagnostics.push(`${where}: field "${refName}" has no Terraform field mapping; dropped`);
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
72
|
if (!isCanonicalTsLabel(refName)) {
|
|
80
73
|
opts.diagnostics.push(`${where}: field key "${refName}" is not a canonical tsLabel; dropped`);
|
|
81
74
|
continue;
|
|
82
75
|
}
|
|
83
|
-
const
|
|
76
|
+
const knownAddress = opts.fieldAddresses?.get(refName);
|
|
77
|
+
if (knownAddress !== undefined) {
|
|
78
|
+
const dotIndex = knownAddress.indexOf(".");
|
|
79
|
+
if (dotIndex !== -1) {
|
|
80
|
+
out.push(expr.resourceAttr(knownAddress.slice(0, dotIndex), knownAddress.slice(dotIndex + 1), ["id"]));
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (!SUB_TYPE_BY_AUTHORING_TYPE.has(ref.fieldType ?? "")) {
|
|
85
|
+
opts.diagnostics.push(`${where}: field "${refName}" has no Terraform field mapping; dropped`);
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const value = fieldRefToTfValue(ref.fieldType, refName, opts.ownerTfLabel, opts.scope, opts.fieldAddresses);
|
|
84
89
|
if (value !== undefined)
|
|
85
90
|
out.push(value);
|
|
86
91
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { dataRefLabel, resourceRefLabel } from "../../engine/pull/context.js";
|
|
2
2
|
import { isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel, } from "../../engine/tf/index.js";
|
|
3
3
|
import { filterFromTf } from "../access-policy/from-tf.js";
|
|
4
|
-
import { fieldKeyFromTfRef } from "../field/from-tf.js";
|
|
4
|
+
import { fieldKeyFromTfRef, fieldKeyFromTfValue } from "../field/from-tf.js";
|
|
5
|
+
import { dataAspectDisplayName, dataAspectRefName } from "../shared/aspect-target-from-tf.js";
|
|
5
6
|
import { SUB_TYPE_BY_RESOURCE } from "../field/types.js";
|
|
6
7
|
import { RELATIONSHIP_RESOURCE_TYPE } from "./module.js";
|
|
7
8
|
const KNOWN_ATTRS = new Set(["object_id", "related_object_id", "columns", "filter"]);
|
|
@@ -42,7 +43,7 @@ function relationshipFromTf(block, owner, ctx) {
|
|
|
42
43
|
continue;
|
|
43
44
|
}
|
|
44
45
|
const rec = raw;
|
|
45
|
-
const field =
|
|
46
|
+
const field = fieldKeyFromTfValue(rec["field_id"], owner.ownerRefName, owner.ownerTfLabel, owner.scope, ctx);
|
|
46
47
|
const relatedField = relatedFieldRef(rec["related_field_id"], target, ctx);
|
|
47
48
|
if (field === undefined || relatedField === undefined) {
|
|
48
49
|
ctx.diagnostics.push(`${where}.columns[${index}]: field references are not resolvable; dropped`);
|
|
@@ -51,15 +52,57 @@ function relationshipFromTf(block, owner, ctx) {
|
|
|
51
52
|
columns.push({ field, relatedField });
|
|
52
53
|
}
|
|
53
54
|
const key = scopedLabelToBagKey(owner.ownerTfLabel, block.label ?? "", owner.scope);
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
let filter;
|
|
56
|
+
if (block.attrs["filter"] !== undefined) {
|
|
57
|
+
const ownerFilterOwner = {
|
|
56
58
|
type: ownerResourceType,
|
|
57
59
|
label: owner.label,
|
|
58
60
|
ownerRefName: owner.ownerRefName,
|
|
59
61
|
ownerTfLabel: owner.ownerTfLabel,
|
|
60
62
|
scope: owner.scope,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
foreignFieldRefsById: ctx.foreignFieldRefsById,
|
|
64
|
+
};
|
|
65
|
+
try {
|
|
66
|
+
// A relationship's filter can reference a field on its own owner
|
|
67
|
+
// (row-level filtering keyed off the owner's own field - the
|
|
68
|
+
// existing, already-tested case) - try that first so existing
|
|
69
|
+
// behavior is unchanged.
|
|
70
|
+
filter = filterFromTf(block.attrs["filter"], ownerFilterOwner, `${where}.filter`);
|
|
71
|
+
}
|
|
72
|
+
catch (ownerErr) {
|
|
73
|
+
// ... but it can equally reference a field on the TARGET (e.g. a
|
|
74
|
+
// target-scoped system-field local like `<targetTfLabel>_status_field_id`,
|
|
75
|
+
// restricting which of the target's records are related) (edk#650).
|
|
76
|
+
// Only "app"/"element" targets carry a resolvable field scope here -
|
|
77
|
+
// a table target has no fallback, since table columns never go
|
|
78
|
+
// through this `_field` resource-attr path anyway.
|
|
79
|
+
const targetFilterOwner = target.kind === "app" || target.kind === "element"
|
|
80
|
+
? {
|
|
81
|
+
type: target.kind === "element" ? "elementum_element" : "elementum_app",
|
|
82
|
+
label: target.tfLabel ?? target.key,
|
|
83
|
+
ownerRefName: target.key,
|
|
84
|
+
ownerTfLabel: target.tfLabel ?? target.key,
|
|
85
|
+
scope: target.kind,
|
|
86
|
+
foreignFieldRefsById: ctx.foreignFieldRefsById,
|
|
87
|
+
}
|
|
88
|
+
: undefined;
|
|
89
|
+
try {
|
|
90
|
+
if (targetFilterOwner === undefined)
|
|
91
|
+
throw ownerErr;
|
|
92
|
+
filter = filterFromTf(block.attrs["filter"], targetFilterOwner, `${where}.filter`);
|
|
93
|
+
}
|
|
94
|
+
catch (targetErr) {
|
|
95
|
+
// Never let one unreconstructable filter reference crash the whole
|
|
96
|
+
// app pull - diagnose and drop the relationship, same as the other
|
|
97
|
+
// unresolvable cases in this function (e.g. `related_object_id is
|
|
98
|
+
// not resolvable`), rather than risk silently rebuilding it with no
|
|
99
|
+
// filter at all.
|
|
100
|
+
const err = targetErr ?? ownerErr;
|
|
101
|
+
ctx.diagnostics.push(`${where}.filter: ${err instanceof Error ? err.message : String(err)}; skipped`);
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
63
106
|
return { key, target, columns, ...(filter !== undefined && { filter }) };
|
|
64
107
|
}
|
|
65
108
|
function targetRef(value, owner, ctx) {
|
|
@@ -79,6 +122,21 @@ function targetRef(value, owner, ctx) {
|
|
|
79
122
|
return { kind, key: tfLabelToTsLabel(resourceLabel), name: tfLabelToTsLabel(resourceLabel), tfLabel: resourceLabel, managed: true };
|
|
80
123
|
const dataLabel = dataRefLabel(value, type);
|
|
81
124
|
if (dataLabel !== undefined) {
|
|
125
|
+
if (kind === "app" || kind === "element") {
|
|
126
|
+
const displayName = dataAspectDisplayName(ctx, kind, dataLabel);
|
|
127
|
+
const refName = dataAspectRefName(ctx, kind, dataLabel, displayName);
|
|
128
|
+
const attrs = ctx.dataAttrs?.(type, dataLabel);
|
|
129
|
+
const namespace = typeof attrs?.namespace === "string" ? attrs.namespace : undefined;
|
|
130
|
+
return {
|
|
131
|
+
kind,
|
|
132
|
+
key: refName ?? tfLabelToTsLabel(dataLabel),
|
|
133
|
+
name: displayName ?? refName ?? tfLabelToTsLabel(dataLabel),
|
|
134
|
+
tfLabel: dataLabel,
|
|
135
|
+
managed: false,
|
|
136
|
+
...(namespace !== undefined ? { namespace } : {}),
|
|
137
|
+
...(refName !== undefined ? { catalogRef: true } : {}),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
82
140
|
const name = ctx.dataName(type, dataLabel) ?? tfLabelToTsLabel(dataLabel);
|
|
83
141
|
return { kind, key: tfLabelToTsLabel(dataLabel), name, tfLabel: dataLabel, managed: false };
|
|
84
142
|
}
|
|
@@ -93,6 +151,9 @@ function relatedFieldRef(value, target, ctx) {
|
|
|
93
151
|
if (subType !== undefined) {
|
|
94
152
|
const scope = target.kind === "element" ? "element" : "app";
|
|
95
153
|
const ownerLabel = target.tfLabel ?? target.key;
|
|
154
|
+
// value is already narrowed to a TfExpr above, so fieldKeyFromTfValue's
|
|
155
|
+
// string-literal (state-registry) branch can never fire here - a plain
|
|
156
|
+
// fieldKeyFromTfRef is what this branch actually needs.
|
|
96
157
|
const key = fieldKeyFromTfRef(value, ownerLabel, scope);
|
|
97
158
|
if (key !== undefined)
|
|
98
159
|
return { kind: target.kind === "table" ? "tableColumn" : "field", key, name: key, parent: target.key, fieldType: subType.authoringType };
|
|
@@ -100,10 +161,42 @@ function relatedFieldRef(value, target, ctx) {
|
|
|
100
161
|
}
|
|
101
162
|
const dataLabel = dataRefLabel(value, "elementum_field");
|
|
102
163
|
if (dataLabel !== undefined) {
|
|
164
|
+
const resolved = ctx.foreignFieldRefsByDataAddress?.get(`elementum_field.${dataLabel}`);
|
|
165
|
+
if (resolved !== undefined && resolved.ownerRefName === target.key) {
|
|
166
|
+
return {
|
|
167
|
+
kind: target.kind === "table" ? "tableColumn" : "field",
|
|
168
|
+
key: resolved.fieldKey,
|
|
169
|
+
name: ctx.dataName("elementum_field", dataLabel) ?? resolved.fieldName ?? resolved.fieldKey,
|
|
170
|
+
parent: resolved.ownerRefName,
|
|
171
|
+
fieldType: resolved.fieldType ?? "TEXT",
|
|
172
|
+
catalogRef: true,
|
|
173
|
+
...(resolved.ownerKind !== undefined ? { parentKind: resolved.ownerKind } : {}),
|
|
174
|
+
...(resolved.ownerName !== undefined ? { parentName: resolved.ownerName } : {}),
|
|
175
|
+
...(resolved.ownerNamespace !== undefined ? { parentNamespace: resolved.ownerNamespace } : {}),
|
|
176
|
+
};
|
|
177
|
+
}
|
|
103
178
|
const name = ctx.dataName("elementum_field", dataLabel) ?? tfLabelToTsLabel(dataLabel);
|
|
179
|
+
// The target may already be a full on-disk catalog rather than a ref-only
|
|
180
|
+
// dependency from this one export stream. Resolve the exported field's
|
|
181
|
+
// display name against that catalog before falling back to the data label;
|
|
182
|
+
// the latter is an exporter implementation label, not a public field key.
|
|
183
|
+
const catalogFieldKey = ctx.fieldNamesByOwnerRefName?.get(target.key)?.get(name.toLowerCase());
|
|
184
|
+
if (catalogFieldKey !== undefined) {
|
|
185
|
+
return {
|
|
186
|
+
kind: target.kind === "table" ? "tableColumn" : "field",
|
|
187
|
+
key: catalogFieldKey,
|
|
188
|
+
name,
|
|
189
|
+
parent: target.key,
|
|
190
|
+
fieldType: "TEXT",
|
|
191
|
+
catalogRef: true,
|
|
192
|
+
...(target.kind === "app" || target.kind === "element" ? { parentKind: target.kind } : {}),
|
|
193
|
+
parentName: target.name,
|
|
194
|
+
...(target.namespace !== undefined ? { parentNamespace: target.namespace } : {}),
|
|
195
|
+
};
|
|
196
|
+
}
|
|
104
197
|
return { kind: target.kind === "table" ? "tableColumn" : "field", key: tfLabelToTsLabel(dataLabel), name, parent: target.key, fieldType: "TEXT" };
|
|
105
198
|
}
|
|
106
199
|
const scope = target.kind === "element" ? "element" : "app";
|
|
107
|
-
const key =
|
|
200
|
+
const key = fieldKeyFromTfValue(value, target.key, target.tfLabel ?? target.key, scope, ctx);
|
|
108
201
|
return key === undefined ? undefined : { kind: target.kind === "table" ? "tableColumn" : "field", key, name: key, parent: target.key, fieldType: "TEXT" };
|
|
109
202
|
}
|
|
@@ -15,10 +15,16 @@ function principal(value, type, where, ctx) {
|
|
|
15
15
|
const label = dataRefLabel(value, type);
|
|
16
16
|
if (label !== undefined) {
|
|
17
17
|
const name = ctx.dataName(type, label);
|
|
18
|
-
if (name !== undefined)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
if (name !== undefined) {
|
|
19
|
+
if (type === "elementum_user") {
|
|
20
|
+
if (name.trim() === "" || !name.includes("@")) {
|
|
21
|
+
ctx.diagnostics.push(`${where}: data.${type}.${label} has invalid email ${JSON.stringify(name)}; dropped`);
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
return { __kind: "user", email: name.trim() };
|
|
25
|
+
}
|
|
26
|
+
return { __kind: "group", refName: tfLabelToTsLabel(label), name };
|
|
27
|
+
}
|
|
22
28
|
ctx.diagnostics.push(`${where}: data.${type}.${label} has no lookup value; dropped`);
|
|
23
29
|
return undefined;
|
|
24
30
|
}
|
|
@@ -42,7 +42,7 @@ export type DefineSearchTableOptions<Owner extends SearchTableOwner = SearchTabl
|
|
|
42
42
|
readonly attributeFields: readonly [OwnedField<Owner>, ...OwnedField<Owner>[]];
|
|
43
43
|
readonly duration: SearchTableDuration;
|
|
44
44
|
readonly targetLag: number;
|
|
45
|
-
readonly textIndexFields?: readonly
|
|
45
|
+
readonly textIndexFields?: readonly OwnedField<Owner>[];
|
|
46
46
|
readonly vectorIndex: VectorIndex<Owner>;
|
|
47
47
|
readonly warehouse?: string;
|
|
48
48
|
readonly creationTimeout?: string;
|