@elementumai/edk 0.9.19 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +159 -7
- package/dist-sdk/src/catalog/factories.d.ts +33 -2
- package/dist-sdk/src/catalog/factories.js +40 -1
- package/dist-sdk/src/catalog/from-authoring.d.ts +13 -8
- package/dist-sdk/src/catalog/from-authoring.js +34 -9
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +2 -2
- package/dist-sdk/src/catalog/render.js +6 -6
- package/dist-sdk/src/catalog/token.js +11 -0
- package/dist-sdk/src/catalog/types.d.ts +40 -1
- package/dist-sdk/src/catalog/types.js +12 -0
- package/dist-sdk/src/core/triggers/on-demand.d.ts +40 -4
- package/dist-sdk/src/core/triggers/on-demand.js +17 -2
- package/dist-sdk/src/core/types/app.d.ts +2 -2
- package/dist-sdk/src/engine/build/context.d.ts +1 -1
- package/dist-sdk/src/engine/coverage-gaps.d.ts +86 -0
- package/dist-sdk/src/engine/coverage-gaps.js +156 -0
- package/dist-sdk/src/engine/ei/run.d.ts +169 -0
- package/dist-sdk/src/engine/ei/run.js +1219 -0
- package/dist-sdk/src/engine/logging.d.ts +17 -0
- package/dist-sdk/src/engine/logging.js +18 -0
- package/dist-sdk/src/engine/pull/catalog-ref.d.ts +16 -0
- package/dist-sdk/src/engine/pull/catalog-ref.js +24 -0
- package/dist-sdk/src/engine/pull/context.d.ts +68 -6
- package/dist-sdk/src/engine/pull/context.js +40 -1
- package/dist-sdk/src/engine/pull/procedure-refs.d.ts +8 -0
- package/dist-sdk/src/engine/pull/procedure-refs.js +28 -0
- package/dist-sdk/src/engine/pull/ref-only.d.ts +5 -0
- package/dist-sdk/src/engine/pull/ref-only.js +10 -7
- package/dist-sdk/src/engine/pull/result-output.d.ts +6 -0
- package/dist-sdk/src/engine/pull/result-output.js +113 -3
- package/dist-sdk/src/engine/tf/expr.js +1 -1
- package/dist-sdk/src/engine/tf/index.d.ts +2 -2
- package/dist-sdk/src/engine/tf/index.js +1 -1
- package/dist-sdk/src/engine/tf/labels.d.ts +28 -5
- package/dist-sdk/src/engine/tf/labels.js +54 -3
- package/dist-sdk/src/engine/tf/model.d.ts +22 -1
- package/dist-sdk/src/engine/tf/parse.js +93 -4
- package/dist-sdk/src/engine/tf/render.d.ts +4 -2
- package/dist-sdk/src/engine/tf/render.js +41 -7
- package/dist-sdk/src/engine/validation.d.ts +44 -0
- package/dist-sdk/src/engine/validation.js +95 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +38 -1
- package/dist-sdk/src/entities/access-policy/principal.d.ts +2 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +5 -2
- package/dist-sdk/src/entities/agent/build.d.ts +4 -16
- package/dist-sdk/src/entities/agent/build.js +40 -5
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +3 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +46 -21
- package/dist-sdk/src/entities/agent/from-tf.js +11 -3
- package/dist-sdk/src/entities/agent/module.js +2 -0
- package/dist-sdk/src/entities/agent/to-tf.js +20 -6
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +10 -1
- package/dist-sdk/src/entities/agent-tool/from-tf.js +18 -6
- package/dist-sdk/src/entities/agent-tool/module.js +3 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +27 -5
- package/dist-sdk/src/entities/app/auto-share.d.ts +38 -0
- package/dist-sdk/src/entities/app/auto-share.js +49 -0
- package/dist-sdk/src/entities/app/build.d.ts +105 -22
- package/dist-sdk/src/entities/app/build.js +107 -10
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +22 -1
- package/dist-sdk/src/entities/app/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/app/from-tf.js +11 -2
- package/dist-sdk/src/entities/app/index.d.ts +7 -6
- package/dist-sdk/src/entities/app/index.js +2 -8
- package/dist-sdk/src/entities/app/module.js +5 -2
- package/dist-sdk/src/entities/app/to-tf.d.ts +6 -0
- package/dist-sdk/src/entities/app/to-tf.js +40 -13
- package/dist-sdk/src/entities/automation/build.d.ts +56 -6
- package/dist-sdk/src/entities/automation/build.js +230 -26
- package/dist-sdk/src/entities/automation/calculation-expression.d.ts +7 -7
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +41 -5
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +470 -58
- package/dist-sdk/src/entities/automation/from-tf.d.ts +37 -8
- package/dist-sdk/src/entities/automation/from-tf.js +791 -131
- package/dist-sdk/src/entities/automation/generated/task-output-contracts.d.ts +33 -0
- package/dist-sdk/src/entities/automation/generated/task-output-contracts.js +183 -0
- 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/module.d.ts +3 -0
- package/dist-sdk/src/entities/automation/module.js +107 -15
- package/dist-sdk/src/entities/automation/output-field-types.d.ts +7 -0
- package/dist-sdk/src/entities/automation/output-field-types.js +36 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +9 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +13 -0
- package/dist-sdk/src/entities/automation/script-code.d.ts +20 -0
- package/dist-sdk/src/entities/automation/script-code.js +109 -5
- package/dist-sdk/src/entities/automation/system-ref-name.js +4 -0
- package/dist-sdk/src/entities/automation/task-output-labels.d.ts +39 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +85 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +116 -22
- package/dist-sdk/src/entities/automation/tasks.js +86 -24
- package/dist-sdk/src/entities/automation/to-tf.d.ts +24 -3
- package/dist-sdk/src/entities/automation/to-tf.js +1082 -132
- package/dist-sdk/src/entities/automation/triggers.d.ts +12 -6
- package/dist-sdk/src/entities/automation/triggers.js +4 -0
- package/dist-sdk/src/entities/automation/types.d.ts +9 -0
- package/dist-sdk/src/entities/automation/types.js +19 -0
- package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +1 -1
- package/dist-sdk/src/entities/automation/value-ref-tf.js +1 -1
- package/dist-sdk/src/entities/chart/from-tf.js +9 -1
- package/dist-sdk/src/entities/chart/to-tf.js +10 -3
- package/dist-sdk/src/entities/data-lookup/module.js +2 -0
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +24 -31
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +7 -5
- package/dist-sdk/src/entities/element/build.d.ts +28 -13
- package/dist-sdk/src/entities/element/build.js +5 -1
- package/dist-sdk/src/entities/element/from-tf.d.ts +11 -0
- package/dist-sdk/src/entities/element/from-tf.js +62 -1
- package/dist-sdk/src/entities/element/index.d.ts +5 -3
- package/dist-sdk/src/entities/element/index.js +1 -0
- package/dist-sdk/src/entities/element/module.js +9 -3
- package/dist-sdk/src/entities/element/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/element/to-tf.js +16 -16
- package/dist-sdk/src/entities/field/build.d.ts +17 -3
- package/dist-sdk/src/entities/field/build.js +3 -0
- package/dist-sdk/src/entities/field/calc.d.ts +7 -7
- package/dist-sdk/src/entities/field/from-tf.d.ts +5 -4
- package/dist-sdk/src/entities/field/from-tf.js +244 -49
- package/dist-sdk/src/entities/field/media-types.d.ts +6 -0
- package/dist-sdk/src/entities/field/media-types.js +30 -0
- package/dist-sdk/src/entities/field/module.js +2 -0
- package/dist-sdk/src/entities/field/options.js +6 -1
- package/dist-sdk/src/entities/field/to-tf.d.ts +26 -5
- package/dist-sdk/src/entities/field/to-tf.js +137 -15
- package/dist-sdk/src/entities/field/types.d.ts +2 -0
- package/dist-sdk/src/entities/field/types.js +27 -0
- package/dist-sdk/src/entities/file-reader/from-tf.js +14 -5
- package/dist-sdk/src/entities/file-reader/module.js +1 -0
- package/dist-sdk/src/entities/file-reader/types.d.ts +2 -0
- package/dist-sdk/src/entities/file-reader/types.js +1 -1
- package/dist-sdk/src/entities/portal/build.d.ts +26 -0
- package/dist-sdk/src/entities/portal/build.js +37 -0
- package/dist-sdk/src/entities/portal/from-tf.d.ts +27 -0
- package/dist-sdk/src/entities/portal/from-tf.js +75 -0
- package/dist-sdk/src/entities/portal/index.d.ts +1 -0
- package/dist-sdk/src/entities/portal/index.js +1 -0
- package/dist-sdk/src/entities/portal/module.d.ts +3 -0
- package/dist-sdk/src/entities/portal/module.js +28 -0
- package/dist-sdk/src/entities/portal/to-tf.d.ts +12 -0
- package/dist-sdk/src/entities/portal/to-tf.js +73 -0
- package/dist-sdk/src/entities/portal/types.d.ts +1 -0
- package/dist-sdk/src/entities/portal/types.js +1 -0
- package/dist-sdk/src/entities/relationship/module.js +2 -0
- package/dist-sdk/src/entities/relationship/pair-check.d.ts +7 -0
- package/dist-sdk/src/entities/relationship/pair-check.js +68 -0
- package/dist-sdk/src/entities/relationship/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/relationship/to-tf.js +12 -3
- package/dist-sdk/src/entities/role/from-tf.js +3 -3
- package/dist-sdk/src/entities/role/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/role/to-tf.js +12 -4
- package/dist-sdk/src/entities/search-table/module.js +1 -0
- package/dist-sdk/src/entities/search-table/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/search-table/to-tf.js +1 -1
- package/dist-sdk/src/entities/service-account/build.d.ts +15 -2
- package/dist-sdk/src/entities/service-account/from-tf.d.ts +2 -4
- package/dist-sdk/src/entities/service-account/from-tf.js +20 -8
- package/dist-sdk/src/entities/service-account/role-fidelity.d.ts +56 -0
- package/dist-sdk/src/entities/service-account/role-fidelity.js +243 -0
- package/dist-sdk/src/entities/service-account/to-tf.d.ts +14 -0
- package/dist-sdk/src/entities/service-account/to-tf.js +17 -0
- package/dist-sdk/src/entities/service-account/workspace-owner.d.ts +16 -0
- package/dist-sdk/src/entities/service-account/workspace-owner.js +22 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +1 -1
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +5 -2
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +23 -1
- package/dist-sdk/src/entities/shared/filters/ast.js +2 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +7 -0
- package/dist-sdk/src/entities/shared/filters/index.js +19 -4
- package/dist-sdk/src/entities/shared/filters/print.js +24 -3
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +7 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +46 -7
- package/dist-sdk/src/entities/shared/filters/types.d.ts +15 -2
- package/dist-sdk/src/entities/shared/ref.d.ts +5 -7
- package/dist-sdk/src/entities/shared/ref.js +5 -7
- package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +9 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.js +35 -2
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +20 -5
- package/dist-sdk/src/entities/shared/types/field-types.js +8 -0
- package/dist-sdk/src/entities/skill/access-policy.js +3 -3
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +3 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +14 -6
- package/dist-sdk/src/entities/skill/from-tf.js +70 -15
- package/dist-sdk/src/entities/skill/input-coverage.d.ts +7 -0
- package/dist-sdk/src/entities/skill/input-coverage.js +11 -0
- package/dist-sdk/src/entities/skill/module.js +2 -0
- package/dist-sdk/src/entities/skill/to-tf.js +14 -4
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +49 -10
- package/dist-sdk/src/entities/skill-tool/module.js +3 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +2 -8
- package/dist-sdk/src/entities/skill-tool/to-tf.js +49 -14
- package/dist-sdk/src/entities/table/catalog.d.ts +14 -0
- package/dist-sdk/src/entities/table/catalog.js +66 -0
- package/dist-sdk/src/entities/table/module.js +2 -1
- package/dist-sdk/src/entities/table/to-tf.js +2 -2
- package/dist-sdk/src/entities/task/build.d.ts +8 -0
- package/dist-sdk/src/entities/task/build.js +10 -1
- package/dist-sdk/src/entities/task/from-tf.d.ts +4 -2
- package/dist-sdk/src/entities/task/from-tf.js +7 -2
- package/dist-sdk/src/entities/task/module.js +2 -2
- package/dist-sdk/src/entities/task/to-tf.d.ts +8 -4
- package/dist-sdk/src/entities/task/to-tf.js +28 -1
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +49 -9
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +71 -18
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +19 -4
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +82 -10
- package/dist-sdk/src/entities/view/agent-view-layout.d.ts +53 -23
- package/dist-sdk/src/entities/view/agent-view-layout.js +1 -1
- package/dist-sdk/src/entities/view/from-tf.d.ts +3 -2
- package/dist-sdk/src/entities/view/from-tf.js +133 -13
- package/dist-sdk/src/entities/view/module.js +30 -3
- package/dist-sdk/src/entities/view/to-tf.d.ts +20 -8
- package/dist-sdk/src/entities/view/to-tf.js +86 -18
- package/dist-sdk/src/entities/view/types.d.ts +4 -15
- package/dist-sdk/src/entities/view/types.js +15 -15
- package/dist-sdk/src/entities/visual-flow/build.d.ts +16 -1
- package/dist-sdk/src/entities/visual-flow/build.js +9 -0
- package/dist-sdk/src/entities/visual-flow/from-tf.d.ts +14 -0
- package/dist-sdk/src/entities/visual-flow/from-tf.js +51 -3
- package/dist-sdk/src/entities/visual-flow/index.d.ts +1 -1
- package/dist-sdk/src/entities/visual-flow/index.js +1 -1
- package/dist-sdk/src/entities/visual-flow/printer.js +19 -0
- package/dist-sdk/src/entities/visual-flow/to-tf.js +87 -3
- package/dist-sdk/src/entities/widget/build.d.ts +16 -1
- package/dist-sdk/src/entities/widget/build.js +11 -1
- package/dist-sdk/src/entities/widget/from-tf.js +3 -3
- package/dist-sdk/src/entities/widget/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/widget/to-tf.js +41 -14
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +148 -13
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +12 -0
- package/dist-sdk/src/graph/index.js +21 -0
- package/dist-sdk/src/graph/modules.js +2 -0
- package/dist-sdk/src/graph/types.d.ts +83 -4
- package/dist-sdk/src/internal/sdk-package.d.ts +1 -1
- package/dist-sdk/src/internal/sdk-package.js +1 -0
- package/package.json +16 -3
|
@@ -6,10 +6,22 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { EntityTfError } from "../../engine/entity.js";
|
|
8
8
|
import { dataRefLabel, optionalString, resourceRefLabel } from "../../engine/pull/context.js";
|
|
9
|
-
import { isTfExpr, sanitizeName, scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
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 { resolveToolFieldKey } from "../shared/tool-field-ref.js";
|
|
11
|
+
import { droppedToolFieldDiagnostic, resolveToolFieldKey } from "../shared/tool-field-ref.js";
|
|
12
12
|
import { KNOWN_SKILL_TOOL_ATTRS, SKILL_TOOL_SUB_TYPE_BY_RESOURCE, UNAUTHORABLE_SKILL_TOOL_ATTRS, } from "./types.js";
|
|
13
|
+
/** Namespace-map key for a catalog ref, skipping UUID index entries. */
|
|
14
|
+
function stateScopeLabel(catalogRef, namespaces) {
|
|
15
|
+
if (namespaces !== undefined) {
|
|
16
|
+
for (const [key, value] of namespaces) {
|
|
17
|
+
if (value !== catalogRef || isUuid(key))
|
|
18
|
+
continue;
|
|
19
|
+
return key;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
// UUID-only index: the stored ref is tfLabelToTsLabel(resource.name).
|
|
23
|
+
return tsLabelToTfLabel(catalogRef);
|
|
24
|
+
}
|
|
13
25
|
/**
|
|
14
26
|
* One tool block → its normalized shape; undefined = skipped with a
|
|
15
27
|
* diagnostic (unimplemented sub-type, wrong owner, unresolvable target).
|
|
@@ -217,6 +229,7 @@ export function skillToolFromTf(block, owner, ctx) {
|
|
|
217
229
|
}
|
|
218
230
|
let searchTableKey;
|
|
219
231
|
let searchTableName;
|
|
232
|
+
let searchTableId;
|
|
220
233
|
let tableOwnedSearchTable = false;
|
|
221
234
|
let searchTableOwnerName;
|
|
222
235
|
let searchTableOwnerRefName;
|
|
@@ -240,11 +253,15 @@ export function skillToolFromTf(block, owner, ctx) {
|
|
|
240
253
|
}
|
|
241
254
|
else if (isTfExpr(value) && value.$expr === "data-attr" && value.type === "elementum_search_table") {
|
|
242
255
|
searchTableName = ctx.dataName(value.type, value.label);
|
|
256
|
+
const dataAttrs = ctx.dataAttrs?.(value.type, value.label);
|
|
257
|
+
const pinnedId = dataAttrs?.["id"];
|
|
258
|
+
if (typeof pinnedId === "string" && pinnedId !== "")
|
|
259
|
+
searchTableId = pinnedId;
|
|
243
260
|
// The generic search-table data source is used for both aspect-owned and
|
|
244
261
|
// table-owned tables. The presence of table_id is the only portable
|
|
245
262
|
// discriminator available in the HCL stream.
|
|
246
|
-
tableOwnedSearchTable =
|
|
247
|
-
const tableLabel = dataRefLabel(
|
|
263
|
+
tableOwnedSearchTable = dataAttrs?.["table_id"] !== undefined;
|
|
264
|
+
const tableLabel = dataRefLabel(dataAttrs?.["table_id"], "elementum_table");
|
|
248
265
|
if (tableLabel !== undefined) {
|
|
249
266
|
searchTableOwnerName = ctx.dataName("elementum_table", tableLabel);
|
|
250
267
|
if (searchTableOwnerName !== undefined) {
|
|
@@ -350,11 +367,32 @@ export function skillToolFromTf(block, owner, ctx) {
|
|
|
350
367
|
fieldScope = "task";
|
|
351
368
|
}
|
|
352
369
|
else if (typeof targetAttr === "string") {
|
|
353
|
-
//
|
|
354
|
-
//
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
370
|
+
// Same state join as automations (#1427 / #1452): when the element/app is
|
|
371
|
+
// already in OpenTofu state, the UUID is indexed on the namespace map.
|
|
372
|
+
const elementRefName = ctx.foreignElementRefNamespaces?.get(targetAttr);
|
|
373
|
+
if (elementRefName !== undefined) {
|
|
374
|
+
const displayName = [...(ctx.foreignElementRefNames?.entries() ?? [])]
|
|
375
|
+
.find(([, refName]) => refName === elementRefName)?.[0] ?? elementRefName;
|
|
376
|
+
target = { kind: "foreignElement", name: displayName, refName: elementRefName };
|
|
377
|
+
fieldScopeLabel = stateScopeLabel(elementRefName, ctx.foreignElementRefNamespaces);
|
|
378
|
+
fieldScope = "element";
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
const appRefName = ctx.foreignAppRefNamespaces?.get(targetAttr);
|
|
382
|
+
if (appRefName !== undefined) {
|
|
383
|
+
const displayName = [...(ctx.foreignAppRefNames?.entries() ?? [])]
|
|
384
|
+
.find(([, refName]) => refName === appRefName)?.[0] ?? appRefName;
|
|
385
|
+
target = { kind: "foreignApp", name: displayName, refName: appRefName };
|
|
386
|
+
fieldScopeLabel = stateScopeLabel(appRefName, ctx.foreignAppRefNamespaces);
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
// No portable reference was available at export time (ei fell back to
|
|
390
|
+
// the raw platform UUID) — keep the tool with an unresolved target
|
|
391
|
+
// instead of dropping it entirely (board issue #648).
|
|
392
|
+
ctx.diagnostics.push(`${where}: target_id could not be resolved to a portable reference ("${targetAttr}"); kept as unresolved`);
|
|
393
|
+
target = { kind: "unresolved", uuid: targetAttr };
|
|
394
|
+
}
|
|
395
|
+
}
|
|
358
396
|
}
|
|
359
397
|
else {
|
|
360
398
|
ctx.diagnostics.push(`${where}: target_id has an unrecognized shape (${JSON.stringify(targetAttr)}); skipped`);
|
|
@@ -377,7 +415,7 @@ export function skillToolFromTf(block, owner, ctx) {
|
|
|
377
415
|
// than silently dropping the field.
|
|
378
416
|
const rawFieldId = fieldKey === undefined && typeof rec["field_id"] === "string" && rec["field_id"] !== "" ? rec["field_id"] : undefined;
|
|
379
417
|
if (fieldKey === undefined && rawFieldId === undefined) {
|
|
380
|
-
ctx.diagnostics.push(
|
|
418
|
+
ctx.diagnostics.push(droppedToolFieldDiagnostic(where, rec["field_id"], fieldScopeLabel, fieldScope));
|
|
381
419
|
continue;
|
|
382
420
|
}
|
|
383
421
|
fields.push({
|
|
@@ -445,6 +483,7 @@ export function skillToolFromTf(block, owner, ctx) {
|
|
|
445
483
|
}),
|
|
446
484
|
...(searchTableKey !== undefined && { searchTableKey }),
|
|
447
485
|
...(searchTableName !== undefined && { searchTableName }),
|
|
486
|
+
...(searchTableId !== undefined && { searchTableId }),
|
|
448
487
|
...(searchTableOwnerName !== undefined && { searchTableOwnerName }),
|
|
449
488
|
...(searchTableOwnerRefName !== undefined && { searchTableOwnerRefName }),
|
|
450
489
|
...(searchTableRawId !== undefined && { searchTableRawId }),
|
|
@@ -26,5 +26,8 @@ export const skillToolModule = {
|
|
|
26
26
|
nestedAttribute: "field_id",
|
|
27
27
|
dataType: FIELD_DATA_RESOURCE_TYPE,
|
|
28
28
|
}],
|
|
29
|
+
// The provider reads an omitted `required` as false (edk#1429): the
|
|
30
|
+
// export leaves it out, the build may spell it out.
|
|
31
|
+
nestedOmittedDefaults: [{ attribute: "fields", defaults: { required: false } }],
|
|
29
32
|
},
|
|
30
33
|
};
|
|
@@ -29,13 +29,13 @@ export interface SkillToolToTfContext {
|
|
|
29
29
|
/** Records a foreign-TASK data lookup for data.tf. */
|
|
30
30
|
foreignTaskRef?(tfLabel: string, name: string, namespace?: string): void;
|
|
31
31
|
/** Records an object-scoped data lookup owned by a foreign app/element. */
|
|
32
|
-
foreignFieldRef(type: string, tfLabel: string, objectId: TfValue, name: string): void;
|
|
32
|
+
foreignFieldRef(type: string, tfLabel: string, objectId: TfValue, name: string, extraAttrs?: Readonly<Record<string, TfValue>>): void;
|
|
33
33
|
/** App/element roots authored in this same workspace. */
|
|
34
34
|
readonly workspaceAspects?: ReadonlyMap<string, WorkspaceAspect>;
|
|
35
35
|
/** Records an app-scoped service-account lookup by name. */
|
|
36
36
|
serviceAccountRef?(tfLabel: string, name: string): TfValue | void;
|
|
37
37
|
/** Records a table-owned search-table data lookup for a pulled public ref. */
|
|
38
|
-
tableSearchTableRef?(tfLabel: string, tableRefName: string, tableName: string, searchTableName: string): TfValue | void;
|
|
38
|
+
tableSearchTableRef?(tfLabel: string, tableRefName: string, tableName: string, searchTableName: string, searchTableId?: string): TfValue | void;
|
|
39
39
|
/**
|
|
40
40
|
* Records a cross-app/element automation data lookup (a `runAutomation`
|
|
41
41
|
* skill/agent tool targeting an automation this workspace doesn't own),
|
|
@@ -54,10 +54,4 @@ export interface SkillToolToTfResult {
|
|
|
54
54
|
/** `<resourceType>.<tfLabel>` — bookkeeping for the skill catalog. */
|
|
55
55
|
readonly address: string;
|
|
56
56
|
}
|
|
57
|
-
/**
|
|
58
|
-
* One authored tool entry (`{ createRecord: {...} }`) → its resource block;
|
|
59
|
-
* undefined = degraded with a diagnostic (unimplemented sub-type, missing
|
|
60
|
-
* target). Tool-name validity is enforced in the authoring builders
|
|
61
|
-
* (entities/skill/tools.ts), not here.
|
|
62
|
-
*/
|
|
63
57
|
export declare function skillToolToTf(entry: Record<string, unknown>, ctx: SkillToolToTfContext): SkillToolToTfResult | undefined;
|
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
* (`skill_id`) — this module never names the skill or app resource types.
|
|
7
7
|
* Mirrors `entities/agent-tool/to-tf.ts`.
|
|
8
8
|
*/
|
|
9
|
+
import { typedCoverageGap } from "../../engine/coverage-gaps.js";
|
|
9
10
|
import { workspaceAspectKey } from "../../engine/build/context.js";
|
|
10
11
|
import { automationRunTargetResourceAttr } from "../automation/to-tf.js";
|
|
11
|
-
import { appScopedResourceLabel, childPartFromScopedLabel, expr, sanitizeName, scopedResourceLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
12
|
-
import { fieldRefToTfValue } from "../field/to-tf.js";
|
|
12
|
+
import { appScopedResourceLabel, childPartFromScopedLabel, expr, sanitizeName, scopedResourceLabel, stableIdSuffix, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
13
|
+
import { authoredFieldKeysFromPayload, fieldRefToTfValue, } from "../field/to-tf.js";
|
|
13
14
|
import { foreignFieldDataLabel } from "../shared/foreign-ref.js";
|
|
14
15
|
import { encodeOptionalHandleDescription } from "../shared/handle-description.js";
|
|
15
16
|
import { SKILL_TOOL_SUB_TYPE_BY_TYPE_KEY } from "./types.js";
|
|
@@ -63,6 +64,7 @@ function targetIdValue(token, ctx) {
|
|
|
63
64
|
refName,
|
|
64
65
|
kind,
|
|
65
66
|
localTfLabel: sibling.tfLabel,
|
|
67
|
+
fieldOwnership: authoredFieldKeysFromPayload(sibling.streamRootEntity?.payload),
|
|
66
68
|
};
|
|
67
69
|
}
|
|
68
70
|
const name = token.name ?? refName;
|
|
@@ -131,7 +133,7 @@ function fieldRefValue(token, where, ctx, target) {
|
|
|
131
133
|
const authoringType = token.fieldType ?? "";
|
|
132
134
|
const ref = refName === ""
|
|
133
135
|
? undefined
|
|
134
|
-
: fieldRefToTfValue(authoringType, refName, target.localTfLabel, target.kind);
|
|
136
|
+
: fieldRefToTfValue(authoringType, refName, target.localTfLabel, target.kind, target.fieldOwnership);
|
|
135
137
|
if (ref === undefined) {
|
|
136
138
|
ctx.diagnostics.push(`${where}: field token "${refName}" has no terraform field resource mapping (fieldType ${JSON.stringify(authoringType)}); dropped`);
|
|
137
139
|
return undefined;
|
|
@@ -144,6 +146,18 @@ function fieldRefValue(token, where, ctx, target) {
|
|
|
144
146
|
* target). Tool-name validity is enforced in the authoring builders
|
|
145
147
|
* (entities/skill/tools.ts), not here.
|
|
146
148
|
*/
|
|
149
|
+
/**
|
|
150
|
+
* A whole skill tool the build cannot emit (edk#1480): the site states the
|
|
151
|
+
* consequence itself instead of leaving it to the generic "dropped" wording.
|
|
152
|
+
*/
|
|
153
|
+
function droppedSkillTool(entity, detail) {
|
|
154
|
+
return typedCoverageGap({
|
|
155
|
+
kind: "dropped",
|
|
156
|
+
entity,
|
|
157
|
+
detail,
|
|
158
|
+
consequence: "the skill is built without this tool, so an agent's call to it does nothing",
|
|
159
|
+
});
|
|
160
|
+
}
|
|
147
161
|
export function skillToolToTf(entry, ctx) {
|
|
148
162
|
const typeKey = Object.keys(entry)[0];
|
|
149
163
|
if (typeKey === undefined)
|
|
@@ -152,15 +166,15 @@ export function skillToolToTf(entry, ctx) {
|
|
|
152
166
|
const inner = entry[typeKey];
|
|
153
167
|
const name = inner?.name ?? "";
|
|
154
168
|
if (subType === undefined) {
|
|
155
|
-
ctx.diagnostics.push(`skill tool "${name}"
|
|
169
|
+
ctx.diagnostics.push(droppedSkillTool(`skill tool "${name}"`, `unknown tool kind "${typeKey}"; dropped`));
|
|
156
170
|
return undefined;
|
|
157
171
|
}
|
|
158
172
|
if (subType.implemented !== true) {
|
|
159
|
-
ctx.diagnostics.push(`skill tool "${name}"
|
|
173
|
+
ctx.diagnostics.push(droppedSkillTool(`skill tool "${name}"`, `tool kind "${typeKey}" is not supported on the terraform path yet; dropped`));
|
|
160
174
|
return undefined;
|
|
161
175
|
}
|
|
162
176
|
if (inner === undefined || typeof inner !== "object") {
|
|
163
|
-
ctx.diagnostics.push(`skill tool entry "${typeKey}"
|
|
177
|
+
ctx.diagnostics.push(droppedSkillTool(`skill tool entry "${typeKey}"`, "non-object body; dropped"));
|
|
164
178
|
return undefined;
|
|
165
179
|
}
|
|
166
180
|
const where = `skill tool "${name}"`;
|
|
@@ -203,7 +217,7 @@ export function skillToolToTf(entry, ctx) {
|
|
|
203
217
|
? sanitizeName(automation.name)
|
|
204
218
|
: undefined;
|
|
205
219
|
if (automationTfLabel === undefined) {
|
|
206
|
-
ctx.diagnostics.push(
|
|
220
|
+
ctx.diagnostics.push(droppedSkillTool(where, "no target automation token; dropped"));
|
|
207
221
|
return undefined;
|
|
208
222
|
}
|
|
209
223
|
if (automation?.parent !== undefined && automation.parent !== ctx.appRefName) {
|
|
@@ -217,13 +231,13 @@ export function skillToolToTf(entry, ctx) {
|
|
|
217
231
|
typeof automation.name === "string" && automation.name !== "") {
|
|
218
232
|
const lookup = ctx.foreignAutomationRef(automationTfLabel, automation.parentKind ?? "app", automation.parent, automation.parentName, automation.name);
|
|
219
233
|
if (lookup === undefined) {
|
|
220
|
-
ctx.diagnostics.push(
|
|
234
|
+
ctx.diagnostics.push(droppedSkillTool(where, "foreign automation lookup could not be materialized; dropped"));
|
|
221
235
|
return undefined;
|
|
222
236
|
}
|
|
223
237
|
attrs["automation_id"] = lookup;
|
|
224
238
|
}
|
|
225
239
|
else {
|
|
226
|
-
ctx.diagnostics.push(
|
|
240
|
+
ctx.diagnostics.push(droppedSkillTool(where, "cross-app automation targets are not supported; dropped"));
|
|
227
241
|
return undefined;
|
|
228
242
|
}
|
|
229
243
|
}
|
|
@@ -255,11 +269,11 @@ export function skillToolToTf(entry, ctx) {
|
|
|
255
269
|
if (typeKey === "runAgent") {
|
|
256
270
|
const target = inner.targetAgentId;
|
|
257
271
|
if (target?.refName === undefined || target.refName === "") {
|
|
258
|
-
ctx.diagnostics.push(
|
|
272
|
+
ctx.diagnostics.push(droppedSkillTool(where, "no target agent token; dropped"));
|
|
259
273
|
return undefined;
|
|
260
274
|
}
|
|
261
275
|
if (target.parent !== undefined && target.parent !== ctx.appRefName) {
|
|
262
|
-
ctx.diagnostics.push(
|
|
276
|
+
ctx.diagnostics.push(droppedSkillTool(where, "cross-app target agents are not supported; dropped"));
|
|
263
277
|
return undefined;
|
|
264
278
|
}
|
|
265
279
|
attrs["target_agent_id"] = expr.resourceAttr("elementum_agent", appScopedResourceLabel(ctx.appTfLabel, tsLabelToTfLabel(target.refName)), ["id"]);
|
|
@@ -268,7 +282,7 @@ export function skillToolToTf(entry, ctx) {
|
|
|
268
282
|
return { block, address: `${subType.resourceType}.${tfLabel}` };
|
|
269
283
|
}
|
|
270
284
|
if (inner.aspectId === undefined && typeKey !== "searchTable") {
|
|
271
|
-
ctx.diagnostics.push(
|
|
285
|
+
ctx.diagnostics.push(droppedSkillTool(where, "no target aspect token; dropped"));
|
|
272
286
|
return undefined;
|
|
273
287
|
}
|
|
274
288
|
const aspectId = inner.aspectId;
|
|
@@ -279,6 +293,7 @@ export function skillToolToTf(entry, ctx) {
|
|
|
279
293
|
attrs["target_id"] = "";
|
|
280
294
|
if (typeKey === "searchTable") {
|
|
281
295
|
const table = inner.searchTableId;
|
|
296
|
+
const pinnedSearchTableId = typeof table?.id === "string" && table.id !== "" ? table.id : undefined;
|
|
282
297
|
// The search table itself (not its owner - that's the __variant/parent
|
|
283
298
|
// fallback below) has no portable lookup at all: unsafePlatformId()
|
|
284
299
|
// round-trips it as a raw id directly, before the refName check below,
|
|
@@ -310,11 +325,25 @@ export function skillToolToTf(entry, ctx) {
|
|
|
310
325
|
const workspaceTable = table.parent === undefined
|
|
311
326
|
? undefined
|
|
312
327
|
: ctx.workspaceAspects?.get(workspaceAspectKey("table", table.parent));
|
|
313
|
-
|
|
328
|
+
const searchName = table.name ?? table.refName;
|
|
329
|
+
const tableLookupLabel = `${sanitizeName(table.parent ?? "")}_${sanitizeName(searchName)}`;
|
|
330
|
+
const tableLookup = pinnedSearchTableId === undefined
|
|
331
|
+
? tableLookupLabel
|
|
332
|
+
: `${tableLookupLabel}_${stableIdSuffix(pinnedSearchTableId)}`;
|
|
333
|
+
if (pinnedSearchTableId !== undefined && ctx.tableSearchTableRef !== undefined && table.parent !== undefined && table.parent !== "") {
|
|
334
|
+
const lookup = ctx.tableSearchTableRef(tableLookup, table.parent, table.parentName ?? table.parent, searchName, pinnedSearchTableId);
|
|
335
|
+
if (lookup !== undefined)
|
|
336
|
+
attrs["search_table_id"] = lookup;
|
|
337
|
+
else {
|
|
338
|
+
ctx.diagnostics.push(`${where}: table-owned search table lookup could not be materialized; dropped`);
|
|
339
|
+
return undefined;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
else if (workspaceTable !== undefined) {
|
|
314
343
|
attrs["search_table_id"] = expr.resourceAttr("elementum_table_search_table", `tables_${workspaceTable.tfLabel}_${tsLabelToTfLabel(table.refName)}`, ["id"]);
|
|
315
344
|
}
|
|
316
345
|
else if (ctx.tableSearchTableRef !== undefined && table.parent !== undefined && table.parent !== "") {
|
|
317
|
-
const lookup = ctx.tableSearchTableRef(
|
|
346
|
+
const lookup = ctx.tableSearchTableRef(tableLookup, table.parent, table.parentName ?? table.parent, searchName);
|
|
318
347
|
if (lookup !== undefined)
|
|
319
348
|
attrs["search_table_id"] = lookup;
|
|
320
349
|
else {
|
|
@@ -330,6 +359,12 @@ export function skillToolToTf(entry, ctx) {
|
|
|
330
359
|
return undefined;
|
|
331
360
|
}
|
|
332
361
|
}
|
|
362
|
+
else if (pinnedSearchTableId !== undefined) {
|
|
363
|
+
const ownerPart = target.localTfLabel ?? target.foreignTfLabel ?? sanitizeName(target.refName);
|
|
364
|
+
const lookupLabel = `${sanitizeName(`${ownerPart}_${table.name ?? table.refName}`)}_${stableIdSuffix(pinnedSearchTableId)}`;
|
|
365
|
+
ctx.foreignFieldRef("elementum_search_table", lookupLabel, target.value, table.name ?? table.refName, { id: pinnedSearchTableId });
|
|
366
|
+
attrs["search_table_id"] = expr.dataAttr("elementum_search_table", lookupLabel, ["id"]);
|
|
367
|
+
}
|
|
333
368
|
else if (target.localTfLabel === undefined) {
|
|
334
369
|
const targetName = aspectId?.name ?? aspectId?.refName ?? table.parent;
|
|
335
370
|
const lookupLabel = sanitizeName(`${targetName}_${table.name ?? table.refName}`);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TableColumnStateV2 } from "./state.js";
|
|
2
|
+
export interface TableCatalogInput {
|
|
3
|
+
readonly handle: string;
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly categoryId?: string;
|
|
6
|
+
readonly tableColumns?: Record<string, TableColumnStateV2>;
|
|
7
|
+
readonly datamines?: Record<string, {
|
|
8
|
+
readonly name: string;
|
|
9
|
+
}>;
|
|
10
|
+
}
|
|
11
|
+
export declare function renderTableCatalog(table: TableCatalogInput): string;
|
|
12
|
+
export declare function writeTableCatalog(orgRoot: string, table: TableCatalogInput): Promise<{
|
|
13
|
+
catalogPath: string;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { sdkPackageSpecifier } from "../../internal/sdk-package.js";
|
|
4
|
+
const RESERVED_IDENT = new Set([
|
|
5
|
+
"break", "case", "catch", "class", "const", "continue", "debugger", "default",
|
|
6
|
+
"delete", "do", "else", "export", "extends", "false", "finally", "for",
|
|
7
|
+
"function", "if", "import", "in", "instanceof", "new", "null", "return",
|
|
8
|
+
"super", "switch", "this", "throw", "true", "try", "typeof", "var", "void",
|
|
9
|
+
"while", "with", "let", "static", "yield", "enum",
|
|
10
|
+
]);
|
|
11
|
+
function q(value) {
|
|
12
|
+
return JSON.stringify(value);
|
|
13
|
+
}
|
|
14
|
+
function safeKey(name) {
|
|
15
|
+
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name) && !RESERVED_IDENT.has(name)
|
|
16
|
+
? name
|
|
17
|
+
: q(name);
|
|
18
|
+
}
|
|
19
|
+
export function renderTableCatalog(table) {
|
|
20
|
+
const lines = [];
|
|
21
|
+
lines.push(`import { datamineRef, tableColumnRef, tableRef } from "${sdkPackageSpecifier("catalog")}";`);
|
|
22
|
+
lines.push("");
|
|
23
|
+
lines.push("export const table = tableRef({");
|
|
24
|
+
// This catalog is imported directly by generated/catalog.ts, so there is no
|
|
25
|
+
// enclosing `orgCatalog({ tables: ... })` call to stamp the bag key later.
|
|
26
|
+
lines.push(` refName: ${q(table.handle)},`);
|
|
27
|
+
lines.push(` name: ${q(table.name)},`);
|
|
28
|
+
const columns = Object.entries(table.tableColumns ?? {}).sort(([a], [b]) => a.localeCompare(b));
|
|
29
|
+
if (columns.length > 0) {
|
|
30
|
+
lines.push(" columns: {");
|
|
31
|
+
for (const [key, col] of columns) {
|
|
32
|
+
// `parent` is stamped explicitly here (rather than left for a downstream
|
|
33
|
+
// barrel to fix up) so this per-table catalog file is correct even if
|
|
34
|
+
// something imports it directly instead of through the org catalog.
|
|
35
|
+
const parts = [`name: ${q(col.name)}`, `parent: ${q(table.handle)}`, `parentName: ${q(table.name)}`];
|
|
36
|
+
if (col.fieldType !== undefined)
|
|
37
|
+
parts.push(`fieldType: ${q(col.fieldType)}`);
|
|
38
|
+
if (col.tags !== undefined)
|
|
39
|
+
parts.push(`tags: ${JSON.stringify(col.tags)}`);
|
|
40
|
+
lines.push(` ${safeKey(key)}: tableColumnRef({ ${parts.join(", ")} }),`);
|
|
41
|
+
}
|
|
42
|
+
lines.push(" },");
|
|
43
|
+
}
|
|
44
|
+
const datamines = Object.entries(table.datamines ?? {}).sort(([a], [b]) => a.localeCompare(b));
|
|
45
|
+
if (datamines.length > 0) {
|
|
46
|
+
lines.push(" datamines: {");
|
|
47
|
+
for (const [key, datamine] of datamines) {
|
|
48
|
+
lines.push(` ${safeKey(key)}: datamineRef({ name: ${q(datamine.name)}, parent: ${q(table.handle)}, parentName: ${q(table.name)} }),`);
|
|
49
|
+
}
|
|
50
|
+
lines.push(" },");
|
|
51
|
+
}
|
|
52
|
+
if (table.categoryId !== undefined)
|
|
53
|
+
lines.push(` categoryId: ${q(table.categoryId)},`);
|
|
54
|
+
lines.push("});");
|
|
55
|
+
lines.push("");
|
|
56
|
+
lines.push("export default table;");
|
|
57
|
+
lines.push("");
|
|
58
|
+
return lines.join("\n");
|
|
59
|
+
}
|
|
60
|
+
export async function writeTableCatalog(orgRoot, table) {
|
|
61
|
+
const generatedDir = join(orgRoot, "tables", table.handle, "generated");
|
|
62
|
+
const catalogPath = join(generatedDir, "catalog.ts");
|
|
63
|
+
await mkdir(generatedDir, { recursive: true });
|
|
64
|
+
await writeFile(catalogPath, renderTableCatalog(table), "utf8");
|
|
65
|
+
return { catalogPath };
|
|
66
|
+
}
|
|
@@ -13,7 +13,8 @@ export const tableModule = {
|
|
|
13
13
|
stream: { role: "streamRoot", exportVerb: "tables" },
|
|
14
14
|
authoring: { unit: "ownFile", bag: "tables" },
|
|
15
15
|
parents: [{ parent: "org", child: "table" }],
|
|
16
|
-
|
|
16
|
+
// The platform's Table type has no description, icon or color to read back.
|
|
17
|
+
resource: { shape: "single", resourceType: TABLE_RESOURCE_TYPE, adoptable: true, unreadableAttributes: ["description", "icon", "color"] },
|
|
17
18
|
// Cross-table relationships already emit name-keyed data lookups through
|
|
18
19
|
// OrgRefLookup.rawLookup; register that real build surface in the graph.
|
|
19
20
|
data: { participates: true, resourceType: "elementum_table", lookupAttr: "name", referencedByBuild: true, referenceLookups: [{ strategy: "rootName" }] },
|
|
@@ -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 { fieldRefToTfValue } from "../field/to-tf.js";
|
|
8
|
+
import { authoredFieldKeysFromPayload, fieldRefToTfValue } 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 { TABLE_RESOURCE_TYPE } from "./module.js";
|
|
@@ -91,7 +91,7 @@ function fieldId(value, orgRefs, ownRef, ownLabel, ownColumnNames, workspaceAspe
|
|
|
91
91
|
if (local !== undefined &&
|
|
92
92
|
ref.fieldType !== undefined &&
|
|
93
93
|
ref.refName !== undefined) {
|
|
94
|
-
const resolved = fieldRefToTfValue(ref.fieldType, ref.refName, local.tfLabel, kind);
|
|
94
|
+
const resolved = fieldRefToTfValue(ref.fieldType, ref.refName, local.tfLabel, kind, authoredFieldKeysFromPayload(local.streamRootEntity?.payload));
|
|
95
95
|
if (resolved !== undefined)
|
|
96
96
|
return resolved;
|
|
97
97
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type CategoryRef, type CloudLinkRef } from "../../catalog/index.js";
|
|
2
2
|
import type { DeployableEntity, EntityDeployOptions } from "../../engine/entity.js";
|
|
3
|
+
import { type AppField } from "../app/build.js";
|
|
3
4
|
declare const taskStatusTagBrand: unique symbol;
|
|
4
5
|
export type TaskStatusTag = string & {
|
|
5
6
|
readonly [taskStatusTagBrand]: "TaskStatusTag";
|
|
@@ -35,6 +36,13 @@ export interface DefineTaskOptions extends EntityDeployOptions {
|
|
|
35
36
|
readonly options?: readonly TaskStatusOption[];
|
|
36
37
|
};
|
|
37
38
|
readonly commentsEnabled?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Custom fields, authored inline with the same field builders apps use
|
|
41
|
+
* (`textField`, `dropdownField`, …), keyed by a stable bag key that names
|
|
42
|
+
* the field's terraform address (edk#1464). The task's title, ID and status
|
|
43
|
+
* fields stay on `titleField`/`idField`/`statusField`.
|
|
44
|
+
*/
|
|
45
|
+
readonly fields?: Record<string, AppField>;
|
|
38
46
|
}
|
|
39
47
|
export interface TaskConfigured {
|
|
40
48
|
def(refName: string): DeployableEntity;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { slimTokens } from "../../catalog/index.js";
|
|
2
|
+
import { serializeField } from "../app/build.js";
|
|
2
3
|
export const taskStatusTag = { closed: "CLOSED" };
|
|
4
|
+
/** Keys the task's own system fields use; a custom field can't take one (its id local would collide). */
|
|
5
|
+
const TASK_SYSTEM_FIELD_KEYS = new Set(["title", "id", "status"]);
|
|
3
6
|
export function task(opts) {
|
|
4
7
|
if (opts.name.trim() === "")
|
|
5
8
|
throw new Error("task requires a non-empty name.");
|
|
@@ -12,6 +15,12 @@ export function task(opts) {
|
|
|
12
15
|
return { def(refName) {
|
|
13
16
|
const handle = opts.handle ?? refName.replace(/[^A-Za-z]/g, "").toUpperCase();
|
|
14
17
|
const namespace = opts.namespace ?? refName.replace(/[^A-Za-z]/g, "").toLowerCase();
|
|
15
|
-
|
|
18
|
+
const { fields: authoredFields, ...rest } = opts;
|
|
19
|
+
for (const key of Object.keys(authoredFields ?? {})) {
|
|
20
|
+
if (TASK_SYSTEM_FIELD_KEYS.has(key))
|
|
21
|
+
throw new Error(`task ${JSON.stringify(opts.name)}: fields.${key} collides with the task's ${key} system field; use ${key}Field or another key.`);
|
|
22
|
+
}
|
|
23
|
+
const fields = authoredFields === undefined ? undefined : Object.entries(authoredFields).map(([bagKey, field]) => serializeField(field, bagKey));
|
|
24
|
+
return { kind: "task", parent: "org", refName, payload: slimTokens({ ...rest, handle, namespace, ...(fields !== undefined && fields.length > 0 ? { fields } : {}) }), ...(opts.enabled !== undefined ? { enabled: opts.enabled } : {}) };
|
|
16
25
|
} };
|
|
17
26
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type FromTfContext } from "../../engine/pull/context.js";
|
|
2
2
|
import { type TfBlock } from "../../engine/tf/index.js";
|
|
3
|
+
import type { NormalizedField } from "../app/deserializer/normalize.js";
|
|
3
4
|
export interface NormalizedTask {
|
|
4
5
|
readonly refName: string;
|
|
5
6
|
readonly name: string;
|
|
@@ -23,6 +24,7 @@ export interface NormalizedTask {
|
|
|
23
24
|
readonly name?: string;
|
|
24
25
|
readonly description?: string;
|
|
25
26
|
readonly options?: readonly Record<string, unknown>[];
|
|
26
|
-
};
|
|
27
|
+
}; /** Custom fields (edk#1464). */
|
|
28
|
+
readonly fields?: readonly NormalizedField[];
|
|
27
29
|
}
|
|
28
|
-
export declare function taskFromTf(block: TfBlock, ctx: FromTfContext): NormalizedTask;
|
|
30
|
+
export declare function taskFromTf(block: TfBlock, ctx: FromTfContext, fieldBlocks?: readonly TfBlock[]): NormalizedTask;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { dataRefLabel, optionalBoolean, optionalString, plainObject } from "../../engine/pull/context.js";
|
|
2
2
|
import { tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
3
|
+
import { fieldFromTf } from "../field/from-tf.js";
|
|
3
4
|
import { TASK_RESOURCE_TYPE } from "./module.js";
|
|
4
5
|
const KNOWN = new Set(["id", "name", "handle", "namespace", "category_id", "cloud_link_id", "description", "icon", "color", "title_field_name", "title_field_description", "id_field_name", "id_field_description", "status_field_name", "status_field_description", "status_options", "status_option_ids_by_label", "title_field_id", "id_field_id", "status_field_id", "comments_enabled", "comments_display_block_id"]);
|
|
5
|
-
export function taskFromTf(block, ctx) {
|
|
6
|
+
export function taskFromTf(block, ctx, fieldBlocks = []) {
|
|
6
7
|
if (block.type !== TASK_RESOURCE_TYPE || !block.label)
|
|
7
8
|
throw new Error(`expected ${TASK_RESOURCE_TYPE}`);
|
|
8
9
|
for (const key of Object.keys(block.attrs))
|
|
@@ -25,7 +26,11 @@ export function taskFromTf(block, ctx) {
|
|
|
25
26
|
const idDescription = optionalString(block.attrs, "id_field_description", `task ${block.label}`, ctx);
|
|
26
27
|
const statusName = optionalString(block.attrs, "status_field_name", `task ${block.label}`, ctx);
|
|
27
28
|
const statusDescription = optionalString(block.attrs, "status_field_description", `task ${block.label}`, ctx);
|
|
28
|
-
|
|
29
|
+
const refName = tfLabelToTsLabel(block.label);
|
|
30
|
+
const owner = { type: TASK_RESOURCE_TYPE, label: block.label, scope: "task", refName };
|
|
31
|
+
const fields = fieldBlocks.flatMap((fieldBlock) => fieldFromTf(fieldBlock, owner, ctx) ?? []);
|
|
32
|
+
return { refName, name, handle, namespace,
|
|
33
|
+
...(fields.length > 0 && { fields }),
|
|
29
34
|
...(categoryLabel !== undefined && { categoryRef: tfLabelToTsLabel(categoryLabel) }),
|
|
30
35
|
...(cloudLabel !== undefined && { cloudLinkRef: tfLabelToTsLabel(cloudLabel) }),
|
|
31
36
|
...(optionalString(block.attrs, "description", `task ${block.label}`, ctx) !== undefined && { description: optionalString(block.attrs, "description", `task ${block.label}`, ctx) }),
|
|
@@ -3,10 +3,10 @@ import { taskFromTf } from "./from-tf.js";
|
|
|
3
3
|
import { taskToTf } from "./to-tf.js";
|
|
4
4
|
export const TASK_RESOURCE_TYPE = "elementum_task";
|
|
5
5
|
function extract(stream, ctx) { const blocks = stream.byKind.get("task") ?? []; if (blocks.length !== 1)
|
|
6
|
-
throw new Error(`expected exactly one ${TASK_RESOURCE_TYPE}, found ${blocks.length}`); return { instance: taskFromTf(blocks[0], ctx) }; }
|
|
6
|
+
throw new Error(`expected exactly one ${TASK_RESOURCE_TYPE}, found ${blocks.length}`); return { instance: taskFromTf(blocks[0], ctx, stream.byKind.get("field") ?? []) }; }
|
|
7
7
|
export const taskModule = {
|
|
8
8
|
kind: "task", stream: { role: "streamRoot", exportVerb: "tasks" }, authoring: { unit: "ownFile", bag: "tasks" }, parents: [{ parent: "org", child: "task" }],
|
|
9
9
|
resource: { shape: "single", resourceType: TASK_RESOURCE_TYPE, adoptable: true }, data: { participates: true, lookupAttr: "name", referencedByBuild: true, referenceLookups: [{ strategy: "rootNamespace", compatibilityFallback: "name" }] },
|
|
10
|
-
lifecycle: { participates: true, extractStreamRoot: extract, toTf: (entity, ctx) => taskToTf(entity, { orgRefs: ctx.orgRefs, diagnostics: ctx.diagnostics }) },
|
|
10
|
+
lifecycle: { participates: true, extractStreamRoot: extract, toTf: (entity, ctx) => taskToTf(entity, { orgRefs: ctx.orgRefs, diagnostics: ctx.diagnostics, workspaceAspects: ctx.workspaceAspects }) },
|
|
11
11
|
canvas: { participates: true, label: "Tasks", glyph: "☑", component: "appDetail" }, catalog: NO_CATALOG,
|
|
12
12
|
};
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import type { OrgRefLookup } from "../../engine/build/context.js";
|
|
1
|
+
import type { OrgRefLookup, WorkspaceAspect } from "../../engine/build/context.js";
|
|
2
2
|
import { type DeployableEntity } from "../../engine/entity.js";
|
|
3
3
|
import { type TfBlock } from "../../engine/tf/index.js";
|
|
4
|
+
export interface TaskToTfResult {
|
|
5
|
+
readonly blocks: readonly TfBlock[];
|
|
6
|
+
/** Custom field bag key → `<resourceType>.<tfLabel>` (edk#1464). */
|
|
7
|
+
readonly fieldAddresses: ReadonlyMap<string, string>;
|
|
8
|
+
}
|
|
4
9
|
export declare function taskToTf(entity: DeployableEntity, ctx: {
|
|
5
10
|
orgRefs: OrgRefLookup;
|
|
6
11
|
diagnostics: string[];
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
12
|
+
workspaceAspects?: ReadonlyMap<string, WorkspaceAspect>;
|
|
13
|
+
}): TaskToTfResult;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { authoredFieldKeysFromPayload, claimFieldDisplayName, fieldToTf } from "../field/to-tf.js";
|
|
1
2
|
import { EntityTfError } from "../../engine/entity.js";
|
|
2
3
|
import { expr } from "../../engine/tf/index.js";
|
|
3
4
|
import { CATEGORY_ORG_BAG } from "../org/category.js";
|
|
@@ -46,5 +47,31 @@ export function taskToTf(entity, ctx) {
|
|
|
46
47
|
attrs["status_field_description"] = p.statusField.description;
|
|
47
48
|
if (p.statusField?.options !== undefined)
|
|
48
49
|
attrs["status_options"] = p.statusField.options.map((option) => ({ label: option.label ?? "", ...(option.color !== undefined && { color: option.color }), tags: [...(option.tags ?? [])] }));
|
|
49
|
-
|
|
50
|
+
const blocks = [{ kind: "resource", type: TASK_RESOURCE_TYPE, label: p.namespace, attrs }];
|
|
51
|
+
// Custom fields (edk#1464): the same field resources apps emit, owned by the task.
|
|
52
|
+
const fieldAddresses = new Map();
|
|
53
|
+
const fieldOwnership = authoredFieldKeysFromPayload(p);
|
|
54
|
+
const displayNames = new Map();
|
|
55
|
+
const objectId = expr.resourceAttr(TASK_RESOURCE_TYPE, p.namespace, ["id"]);
|
|
56
|
+
for (const entry of p.fields ?? []) {
|
|
57
|
+
const typeKey = Object.keys(entry)[0];
|
|
58
|
+
if (typeKey === undefined)
|
|
59
|
+
continue;
|
|
60
|
+
const field = fieldToTf(typeKey, entry[typeKey], {
|
|
61
|
+
ownerTfLabel: p.namespace,
|
|
62
|
+
appRefName: entity.refName,
|
|
63
|
+
scope: "task",
|
|
64
|
+
objectId,
|
|
65
|
+
diagnostics: ctx.diagnostics,
|
|
66
|
+
orgRefs: ctx.orgRefs,
|
|
67
|
+
...(ctx.workspaceAspects !== undefined && { workspaceAspects: ctx.workspaceAspects }),
|
|
68
|
+
...(fieldOwnership !== undefined && { fieldOwnership }),
|
|
69
|
+
});
|
|
70
|
+
if (field === undefined)
|
|
71
|
+
continue;
|
|
72
|
+
claimFieldDisplayName(displayNames, field);
|
|
73
|
+
blocks.push(field.block);
|
|
74
|
+
fieldAddresses.set(field.bagKey, field.address);
|
|
75
|
+
}
|
|
76
|
+
return { blocks, fieldAddresses };
|
|
50
77
|
}
|