@elementumai/edk 0.13.4 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/dist-sdk/src/catalog/factories.d.ts +4 -2
  2. package/dist-sdk/src/catalog/factories.js +3 -1
  3. package/dist-sdk/src/catalog/from-authoring.d.ts +8 -3
  4. package/dist-sdk/src/catalog/from-authoring.js +21 -8
  5. package/dist-sdk/src/engine/build/context.d.ts +17 -0
  6. package/dist-sdk/src/engine/coverage-gaps.d.ts +10 -0
  7. package/dist-sdk/src/engine/coverage-gaps.js +16 -0
  8. package/dist-sdk/src/engine/pull/context.d.ts +56 -0
  9. package/dist-sdk/src/engine/pull/context.js +8 -0
  10. package/dist-sdk/src/engine/pull/pulled-roots.d.ts +14 -1
  11. package/dist-sdk/src/engine/pull/pulled-roots.js +23 -3
  12. package/dist-sdk/src/engine/pull/ref-only.d.ts +6 -1
  13. package/dist-sdk/src/engine/pull/ref-only.js +4 -1
  14. package/dist-sdk/src/engine/pull/stream-root.d.ts +13 -1
  15. package/dist-sdk/src/engine/pull/stream-root.js +54 -4
  16. package/dist-sdk/src/engine/validation.d.ts +36 -1
  17. package/dist-sdk/src/engine/validation.js +56 -2
  18. package/dist-sdk/src/engine/workspace/loader.d.ts +6 -0
  19. package/dist-sdk/src/engine/workspace/loader.js +87 -2
  20. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +7 -0
  21. package/dist-sdk/src/entities/access-policy/from-tf.js +58 -17
  22. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +3 -1
  23. package/dist-sdk/src/entities/access-policy/to-tf.js +1 -1
  24. package/dist-sdk/src/entities/agent/build.d.ts +15 -0
  25. package/dist-sdk/src/entities/agent/build.js +139 -16
  26. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +3 -3
  27. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +39 -25
  28. package/dist-sdk/src/entities/agent/module.js +95 -3
  29. package/dist-sdk/src/entities/agent/to-tf.js +6 -4
  30. package/dist-sdk/src/entities/agent-evaluation/from-tf.d.ts +7 -0
  31. package/dist-sdk/src/entities/agent-evaluation/from-tf.js +14 -5
  32. package/dist-sdk/src/entities/agent-evaluation/module.js +4 -2
  33. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +11 -2
  34. package/dist-sdk/src/entities/agent-tool/from-tf.js +38 -40
  35. package/dist-sdk/src/entities/agent-tool/to-tf.js +12 -5
  36. package/dist-sdk/src/entities/app/build.d.ts +1 -1
  37. package/dist-sdk/src/entities/automation/build.d.ts +75 -42
  38. package/dist-sdk/src/entities/automation/build.js +17 -7
  39. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +14 -2
  40. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +9 -0
  41. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +57 -12
  42. package/dist-sdk/src/entities/automation/from-tf.d.ts +51 -0
  43. package/dist-sdk/src/entities/automation/from-tf.js +476 -93
  44. package/dist-sdk/src/entities/automation/index.d.ts +1 -1
  45. package/dist-sdk/src/entities/automation/index.js +1 -1
  46. package/dist-sdk/src/entities/automation/module.js +90 -9
  47. package/dist-sdk/src/entities/automation/operators.d.ts +6 -2
  48. package/dist-sdk/src/entities/automation/operators.js +0 -2
  49. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +8 -0
  50. package/dist-sdk/src/entities/automation/task-output-labels.js +11 -0
  51. package/dist-sdk/src/entities/automation/tasks.d.ts +37 -2
  52. package/dist-sdk/src/entities/automation/tasks.js +38 -1
  53. package/dist-sdk/src/entities/automation/to-tf.d.ts +8 -0
  54. package/dist-sdk/src/entities/automation/to-tf.js +413 -47
  55. package/dist-sdk/src/entities/chart/to-tf.js +18 -5
  56. package/dist-sdk/src/entities/dashboard/from-tf.js +45 -11
  57. package/dist-sdk/src/entities/dashboard-widget-order/order.d.ts +5 -3
  58. package/dist-sdk/src/entities/dashboard-widget-order/order.js +6 -4
  59. package/dist-sdk/src/entities/datamine/from-tf.js +10 -3
  60. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +9 -2
  61. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +35 -7
  62. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +63 -7
  63. package/dist-sdk/src/entities/element/build.d.ts +4 -1
  64. package/dist-sdk/src/entities/element/build.js +3 -4
  65. package/dist-sdk/src/entities/field/from-tf.js +8 -1
  66. package/dist-sdk/src/entities/field/to-tf.d.ts +29 -2
  67. package/dist-sdk/src/entities/field/to-tf.js +106 -7
  68. package/dist-sdk/src/entities/phone-service/from-tf.d.ts +7 -0
  69. package/dist-sdk/src/entities/phone-service/from-tf.js +15 -7
  70. package/dist-sdk/src/entities/phone-service/module.js +4 -2
  71. package/dist-sdk/src/entities/portal/to-tf.d.ts +1 -1
  72. package/dist-sdk/src/entities/portal/to-tf.js +61 -2
  73. package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -1
  74. package/dist-sdk/src/entities/relationship/from-tf.js +34 -4
  75. package/dist-sdk/src/entities/relationship/to-tf.js +24 -6
  76. package/dist-sdk/src/entities/role/from-tf.js +3 -1
  77. package/dist-sdk/src/entities/search-table/from-tf.d.ts +3 -1
  78. package/dist-sdk/src/entities/search-table/from-tf.js +6 -3
  79. package/dist-sdk/src/entities/search-table/module.js +18 -2
  80. package/dist-sdk/src/entities/search-table/to-tf.js +10 -16
  81. package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +6 -1
  82. package/dist-sdk/src/entities/shared/filters/index.d.ts +6 -1
  83. package/dist-sdk/src/entities/shared/filters/index.js +8 -2
  84. package/dist-sdk/src/entities/shared/filters/print.js +18 -7
  85. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +11 -0
  86. package/dist-sdk/src/entities/shared/filters/tf-codec.js +24 -2
  87. package/dist-sdk/src/entities/shared/run-automation-requirement.d.ts +15 -0
  88. package/dist-sdk/src/entities/shared/run-automation-requirement.js +28 -0
  89. package/dist-sdk/src/entities/shared/search-table-address.d.ts +17 -0
  90. package/dist-sdk/src/entities/shared/search-table-address.js +24 -0
  91. package/dist-sdk/src/entities/shared/skip-release.d.ts +49 -0
  92. package/dist-sdk/src/entities/shared/skip-release.js +74 -0
  93. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +3 -3
  94. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +11 -5
  95. package/dist-sdk/src/entities/skill/module.js +3 -25
  96. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +4 -2
  97. package/dist-sdk/src/entities/skill-tool/from-tf.js +28 -27
  98. package/dist-sdk/src/entities/skill-tool/to-tf.js +12 -5
  99. package/dist-sdk/src/entities/skill-tool/types.d.ts +1 -0
  100. package/dist-sdk/src/entities/skill-tool/types.js +2 -1
  101. package/dist-sdk/src/entities/table/catalog.d.ts +16 -0
  102. package/dist-sdk/src/entities/table/catalog.js +44 -2
  103. package/dist-sdk/src/entities/table/from-tf.js +30 -4
  104. package/dist-sdk/src/entities/table/keys.d.ts +27 -0
  105. package/dist-sdk/src/entities/table/keys.js +46 -0
  106. package/dist-sdk/src/entities/table/to-tf.js +2 -2
  107. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +12 -1
  108. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +9 -4
  109. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +215 -10
  110. package/dist-sdk/src/entities/view/agent-view-layout.d.ts +10 -4
  111. package/dist-sdk/src/entities/view/custom-view-runtime-rules.d.ts +43 -0
  112. package/dist-sdk/src/entities/view/custom-view-runtime-rules.js +285 -0
  113. package/dist-sdk/src/entities/view/custom-view-validate.d.ts +3 -1
  114. package/dist-sdk/src/entities/view/custom-view-validate.js +24 -5
  115. package/dist-sdk/src/entities/view/from-tf.js +14 -1
  116. package/dist-sdk/src/entities/widget/from-tf.js +14 -7
  117. package/dist-sdk/src/entities/widget/to-tf.js +7 -5
  118. package/dist-sdk/src/graph/index.d.ts +14 -1
  119. package/dist-sdk/src/graph/index.js +2 -0
  120. package/dist-sdk/src/graph/resource-types.d.ts +2 -0
  121. package/dist-sdk/src/graph/resource-types.js +3 -0
  122. package/dist-sdk/src/graph/types.d.ts +82 -0
  123. package/package.json +1 -1
@@ -1,12 +1,12 @@
1
1
  import { EntityTfError } from "../../engine/entity.js";
2
2
  import { checkCustomViewReferences } from "./custom-view-references.js";
3
+ import { calcProblems, ELEMENT_KEYS_NOT_IN_PROPS, pageFillsStatePath, pageReplacesStatePath, replacedStateValues, VISIBLE_FORMS, visibilityProblem } from "./custom-view-runtime-rules.js";
3
4
  const CONTAINERS = new Set(["PanesBlock", "StackBlock", "RowBlock", "CardBlock"]);
4
5
  const LIST_BLOCKS = new Set(["ListCollectionBlock", "DataTableBlock"]);
5
6
  const FILTER_GROUPS = new Set(["AND", "OR"]);
6
7
  /** The record query ignores "not" on these, so the filter silently means the opposite. */
7
8
  const NOT_IGNORED = new Set(["AND", "OR", "CONSECUTIVE_RANGE", "CURRENT_RANGE"]);
8
9
  const DATE = /^\d{4}-\d{2}-\d{2}$/;
9
- const AVG_CALL = /\bAVG\(/;
10
10
  const EMPTY_COUNT = /COUNT\(\s*\)/;
11
11
  const SELECTION_KEYS = ["selectedId", "selectedAspectId", "selectedHandle"];
12
12
  function isObj(v) {
@@ -93,6 +93,10 @@ export function validateCustomViewLayout(spec, where, opts = {}) {
93
93
  opts.diagnostics?.push(`${where}.root: "${root}" is ${rootType === "" ? "untyped" : `a ${rootType}`}; the root is usually a PanesBlock (needed for record lists to open the details pane)`);
94
94
  }
95
95
  const state = isObj(spec["state"]) ? spec["state"] : {};
96
+ // The page replaces these roots when it opens the view (#3205).
97
+ for (const [path, why] of replacedStateValues(spec["state"])) {
98
+ warn(`${where}.state${path.replaceAll("/", ".")}`, `${why} when it opens the view, so this initial value never takes effect. Keep the view's own state under another root, e.g. /page/...`);
99
+ }
96
100
  const parents = {};
97
101
  for (const [id, raw] of Object.entries(elements)) {
98
102
  const elWhere = `${where}.elements.${id}`;
@@ -217,13 +221,27 @@ export function validateCustomViewLayout(spec, where, opts = {}) {
217
221
  const elWhere = `${where}.elements.${id}`;
218
222
  const props = raw["props"];
219
223
  const type = raw["type"];
224
+ // The page refuses the whole view on a bad `visible` (#3205).
225
+ if (raw["visible"] !== undefined) {
226
+ const problem = visibilityProblem(raw["visible"]);
227
+ if (problem !== undefined) {
228
+ note(`${elWhere}.visible`, `${problem}. The page refuses the whole custom view on this. Use ${VISIBLE_FORMS}`);
229
+ }
230
+ }
231
+ for (const key of ELEMENT_KEYS_NOT_IN_PROPS) {
232
+ if (props[key] !== undefined) {
233
+ note(`${elWhere}.props.${key}`, `"${key}" belongs on the element, next to "props", not inside it; the page refuses the whole custom view otherwise`);
234
+ }
235
+ }
220
236
  const scan = (value, path) => {
221
237
  if (isBinding(value)) {
222
238
  const target = bindingTarget(value);
223
- if (typeof target === "string" && !target.startsWith("/host/") && !readState(target).found) {
239
+ if (typeof target === "string" && !pageFillsStatePath(target) && !readState(target).found) {
224
240
  // Warn, not fail (edk#2923): the page reads a missing path as undefined,
225
241
  // and pulled live layouts rely on that, so failing would block the build.
226
- warn(`${elWhere}.${path}`, `binds to "${target}", which is not in spec.state, so it starts undefined. Add an initial value there to set its default.`);
242
+ warn(`${elWhere}.${path}`, pageReplacesStatePath(target)
243
+ ? `binds to "${target}", which starts undefined: the page replaces /${target.split("/").filter(Boolean)[0]} when it opens the view, so an initial value there is dropped. Keep the view's own state under another root, e.g. /page/... (#3205)`
244
+ : `binds to "${target}", which is not in spec.state, so it starts undefined. Add an initial value there to set its default.`);
227
245
  }
228
246
  return;
229
247
  }
@@ -239,10 +257,11 @@ export function validateCustomViewLayout(spec, where, opts = {}) {
239
257
  walkFilter(props["filterJson"], `${elWhere}.filterJson`);
240
258
  if (typeof props["calc"] === "string") {
241
259
  const calc = props["calc"];
242
- if (AVG_CALL.test(calc))
243
- note(`${elWhere}.calc`, "use AVERAGE, not AVG");
244
260
  if (EMPTY_COUNT.test(calc))
245
261
  note(`${elWhere}.calc`, "COUNT needs a field, e.g. COUNT(\"Title\")");
262
+ // The calculation fails and the metric shows nothing (#3205).
263
+ for (const problem of calcProblems(calc))
264
+ note(`${elWhere}.calc`, problem);
246
265
  }
247
266
  if (type === "ChartBlock" && (typeof props["dateFieldId"] === "string" || isObj(props["dateFieldId"]))) {
248
267
  const range = props["range"];
@@ -16,8 +16,10 @@ import { lostStageMessage, pulledStageHandle } from "../app/stage-keys.js";
16
16
  import { decodeForeignDataField, elementAuditFieldReference, fieldBlockOwner, fieldKeyFromForeignDataLabel, fieldKeyFromTfValue, ownerMayHaveCustomField } from "../field/from-tf.js";
17
17
  import { resolveDataAspectTarget } from "../shared/aspect-target-from-tf.js";
18
18
  import { DASHBOARD_RESOURCE_TYPE } from "../dashboard/module.js";
19
+ import { skipAndRelease, unresolvedReferenceName } from "../shared/skip-release.js";
19
20
  import { DASHBOARD_WIDGET_RESOURCE_TYPE } from "../dashboard-widget/module.js";
20
21
  import { WIDGET_RESOURCE_TYPE } from "../widget/module.js";
22
+ import { AUTOMATION_RESOURCE_TYPE } from "../automation/types.js";
21
23
  import { filterFromTf, principalList } from "../access-policy/from-tf.js";
22
24
  import { listViewDensity, } from "./build.js";
23
25
  import { AGENT_VIEW_RESOURCE_TYPE, CALENDAR_VIEW_RESOURCE_TYPE, CUSTOM_VIEW_RESOURCE_TYPE, LAYOUT_RESOURCE_TYPE, DASHBOARD_VIEW_RESOURCE_TYPE, GROUP_SECTION_WIRE_TYPE, KNOWN_AGENT_VIEW_ATTRS, KNOWN_CALENDAR_VIEW_ATTRS, KNOWN_CUSTOM_VIEW_ATTRS, KNOWN_DASHBOARD_VIEW_ATTRS, KNOWN_KANBAN_VIEW_ATTRS, KNOWN_LAYOUT_ATTRS, KNOWN_LAYOUT_SECTION_ATTRS, KNOWN_LIST_VIEW_ATTRS, KNOWN_MANAGED_VIEW_ORDER_ATTRS, LIST_VIEW_RESOURCE_TYPE, KANBAN_VIEW_RESOURCE_TYPE, SECTION_TYPE_FROM_WIRE, SYSTEM_FIELD_KEY_BY_ID_ATTR, UPDATE_SECTION_WIRE_TYPE, } from "./types.js";
@@ -186,7 +188,8 @@ function dashboardViewFromTf(block, owner, ctx) {
186
188
  }
187
189
  const dashboardLabel = resourceRefLabel(attrs["dashboard_id"], DASHBOARD_RESOURCE_TYPE);
188
190
  if (dashboardLabel === undefined) {
189
- ctx.diagnostics.push(`${where}: dashboard_id is not a ${DASHBOARD_RESOURCE_TYPE} resource reference; skipped`);
191
+ // Written to no source, so also left out of adoption (edk#3172).
192
+ skipAndRelease(ctx, `${DASHBOARD_VIEW_RESOURCE_TYPE}.${label}`, { reference: unresolvedReferenceName(attrs["dashboard_id"], "dashboard_id") }, `${where}: dashboard_id is not a ${DASHBOARD_RESOURCE_TYPE} resource reference; skipped`);
190
193
  return undefined;
191
194
  }
192
195
  const scope = owner.scope ?? "app";
@@ -283,7 +286,17 @@ function layoutRefOptions(owner, ctx, where) {
283
286
  }
284
287
  return undefined;
285
288
  };
289
+ // The owner's automations, as run-automation widgets pull them (#3207).
290
+ const automation = (value) => {
291
+ const label = resourceRefLabel(value, AUTOMATION_RESOURCE_TYPE);
292
+ if (label === undefined)
293
+ return undefined;
294
+ const key = scopedLabelToBagKey(owner.ownerTfLabel, label, "app");
295
+ const exportedName = ctx.resourceByAddress?.(`${AUTOMATION_RESOURCE_TYPE}.${label}`)?.attrs["name"];
296
+ return { __specRef: "automation", key, name: typeof exportedName === "string" && exportedName !== "" ? exportedName : key };
297
+ };
286
298
  return {
299
+ automation,
287
300
  isOwnApp: (value) => resourceRefLabel(value, owner.type) === owner.label,
288
301
  fieldKey: (value) => fieldRefFromTf(value, owner, ctx, `${where} layout`),
289
302
  ownFieldKey: (id, systemKeys) => ownExtractedFieldKey(id, owner, ctx, systemKeys),
@@ -8,6 +8,7 @@ import { SUB_TYPE_BY_RESOURCE } from "../field/types.js";
8
8
  import { WIDGET_RESOURCE_TYPE } from "./module.js";
9
9
  import { filterFromTf } from "../access-policy/from-tf.js";
10
10
  import { resolveDataAspectTarget } from "../shared/aspect-target-from-tf.js";
11
+ import { skipAndRelease, unresolvedReferenceName } from "../shared/skip-release.js";
11
12
  import { bareForeignFieldIdRef, isBarePlatformId, isUnextractedFieldKey, resolveOwnDataFieldRef, unextractedFieldRefId } from "../view/from-tf.js";
12
13
  const KNOWN_ROOT_ATTRS = new Set(["object_id", "related_object", "related_link_action", "related_create_action", "run_automation_action"]);
13
14
  export function widgetsFromTf(blocks, owner, ctx, dynamicLayoutCompanionLabels = new Set()) {
@@ -29,10 +30,17 @@ function widgetFromTf(block, owner, ctx, dynamicLayoutCompanionLabels) {
29
30
  if (resourceRefLabel(block.attrs["object_id"], owner.type) !== owner.label)
30
31
  return undefined;
31
32
  const key = scopedLabelToBagKey(owner.ownerTfLabel, label, owner.scope);
33
+ // A widget written to no source is also left out of adoption, or released
34
+ // if state has it, so the next plan doesn't destroy it (edk#3172).
35
+ const address = `${WIDGET_RESOURCE_TYPE}.${label}`;
36
+ const skipReference = (attribute, value, fallback) => {
37
+ skipAndRelease(ctx, address, { reference: unresolvedReferenceName(value, attribute) }, fallback ?? `${where}: ${attribute} is not resolvable; skipped`);
38
+ return undefined;
39
+ };
32
40
  const variants = ["related_object", "related_link_action", "related_create_action", "run_automation_action"]
33
41
  .filter((attr) => block.attrs[attr] !== undefined);
34
42
  if (variants.length !== 1) {
35
- ctx.diagnostics.push(`${where}: expected exactly one widget variant, found ${variants.length}; skipped`);
43
+ skipAndRelease(ctx, address, { problem: `the export gives it ${variants.length} widget variants, not one` }, `${where}: expected exactly one widget variant, found ${variants.length}; skipped`);
36
44
  return undefined;
37
45
  }
38
46
  const variant = variants[0];
@@ -40,7 +48,7 @@ function widgetFromTf(block, owner, ctx, dynamicLayoutCompanionLabels) {
40
48
  return undefined;
41
49
  const body = plainObject(block.attrs[variant]);
42
50
  if (body === undefined) {
43
- ctx.diagnostics.push(`${where}.${variant}: expected an object; skipped`);
51
+ skipAndRelease(ctx, address, { problem: `its ${variant} is not an object` }, `${where}.${variant}: expected an object; skipped`);
44
52
  return undefined;
45
53
  }
46
54
  // name is required and build always sends it, so a value pull cannot read
@@ -58,7 +66,7 @@ function widgetFromTf(block, owner, ctx, dynamicLayoutCompanionLabels) {
58
66
  if (variant === "related_object") {
59
67
  const target = aspectRef(body["object_id"], owner, ctx);
60
68
  if (target === undefined)
61
- return undefined;
69
+ return skipReference(`${variant}.object_id`, body["object_id"]);
62
70
  return {
63
71
  key,
64
72
  type: "relatedRecords",
@@ -70,7 +78,7 @@ function widgetFromTf(block, owner, ctx, dynamicLayoutCompanionLabels) {
70
78
  if (variant === "related_link_action") {
71
79
  const target = aspectRef(body["object_id"], owner, ctx);
72
80
  if (target === undefined)
73
- return undefined;
81
+ return skipReference(`${variant}.object_id`, body["object_id"]);
74
82
  const targetTfLabel = typeof target !== "string" && (target.kind === "app" || target.kind === "element")
75
83
  ? (target.key === owner.ownerRefName ? owner.ownerTfLabel : target.namespace ?? tsLabelToTfLabel(target.key))
76
84
  : undefined;
@@ -107,13 +115,12 @@ function widgetFromTf(block, owner, ctx, dynamicLayoutCompanionLabels) {
107
115
  if (variant === "related_create_action") {
108
116
  const target = aspectRef(body["object_id"], owner, ctx);
109
117
  if (target === undefined)
110
- return undefined;
118
+ return skipReference(`${variant}.object_id`, body["object_id"]);
111
119
  return { key, type: "createRecord", name, target, ...buttonStyle(body, where, ctx) };
112
120
  }
113
121
  const automation = automationRef(body["automation_id"], owner, ctx);
114
122
  if (automation === undefined) {
115
- ctx.diagnostics.push(`${where}.run_automation_action: automation_id is not resolvable; skipped`);
116
- return undefined;
123
+ return skipReference("run_automation_action.automation_id", body["automation_id"], `${where}.run_automation_action: automation_id is not resolvable; skipped`);
117
124
  }
118
125
  const droppedGap = typeof automation === "string" ? droppedAutomationGap(key, automation, owner, ctx) : undefined;
119
126
  if (droppedGap !== undefined)
@@ -5,7 +5,7 @@ import { expr, isCanonicalTsLabel, sanitizeName, scopedResourceLabel, tfLabelToT
5
5
  import { AUTOMATION_RESOURCE_TYPE, automationResourceLabel } from "../automation/types.js";
6
6
  import { automationLookupOwnerId } from "../automation/lookup-owner.js";
7
7
  import { fieldMetadataFromEntries } from "../field/metadata.js";
8
- import { authoredFieldKeysFromPayload, droppedEntryGap, fieldLookupName, fieldRefToTfValue, unauthoredSiblingFieldRef, UNRESOLVED_FIELD_REF, } from "../field/to-tf.js";
8
+ import { droppedEntryGap, fieldLookupName, fieldRefToTfValue, siblingFieldOwnership, unauthoredSiblingFieldRef, UNRESOLVED_FIELD_REF, } from "../field/to-tf.js";
9
9
  import { runAutomationParameterValue } from "./build.js";
10
10
  import { WIDGET_RESOURCE_TYPE } from "./module.js";
11
11
  import { filterToTf } from "../access-policy/to-tf.js";
@@ -173,7 +173,9 @@ function resolveAspect(value, where, opts) {
173
173
  tfLabel: sibling.tfLabel,
174
174
  name: value?.name ?? payloadName,
175
175
  managed: true,
176
- fieldOwnership: authoredFieldKeysFromPayload(sibling.streamRootEntity?.payload),
176
+ // The address each field's own build gives it, whatever type the
177
+ // reference carries (#3088).
178
+ fieldOwnership: siblingFieldOwnership(sibling.streamRootEntity?.payload, sibling.tfLabel, kind),
177
179
  };
178
180
  }
179
181
  const name = value?.name ?? refName;
@@ -220,7 +222,7 @@ function columnAspect(value, target, where, opts) {
220
222
  const refName = value.refName ?? "";
221
223
  const owning = kinds.find((kind) => {
222
224
  const aspect = opts.workspaceAspects?.get(workspaceAspectKey(kind, parent));
223
- return authoredFieldKeysFromPayload(aspect?.streamRootEntity?.payload)?.has(refName) === true;
225
+ return aspect !== undefined && siblingFieldOwnership(aspect.streamRootEntity?.payload, aspect.tfLabel, kind)?.has(refName) === true;
224
226
  });
225
227
  const kind = owning ?? kinds[0];
226
228
  return resolveAspect({ __kind: kind, refName: parent, name: parent }, where, opts) ?? target;
@@ -284,14 +286,14 @@ function resolveColumns(columns, target, where, opts) {
284
286
  const ownTarget = columnTarget.kind === opts.scope && columnTarget.refName === opts.ownerRefName;
285
287
  const unauthored = ownTarget
286
288
  ? undefined
287
- : unauthoredSiblingFieldRef(column.refName, { kind: columnTarget.kind, refName: columnTarget.refName ?? refName, fieldOwnership: columnTarget.fieldOwnership });
289
+ : unauthoredSiblingFieldRef(column.refName, { kind: columnTarget.kind, refName: columnTarget.refName ?? refName, fieldOwnership: columnTarget.fieldOwnership }, fieldLookupName(value));
288
290
  if (unauthored !== undefined && fieldLookupName(value) === undefined) {
289
291
  opts.diagnostics.push(droppedEntryGap(`${where}[${index}]`, `${unauthored}; dropped`, "widget"));
290
292
  continue;
291
293
  }
292
294
  const direct = unauthored !== undefined
293
295
  ? undefined
294
- : fieldRefToTfValue(column.fieldType, column.refName, columnTarget.tfLabel, columnTarget.kind, columnTarget.fieldOwnership);
296
+ : fieldRefToTfValue(column.fieldType, column.refName, columnTarget.tfLabel, columnTarget.kind, columnTarget.fieldOwnership, undefined, fieldLookupName(value));
295
297
  if (direct !== undefined) {
296
298
  out.push(direct);
297
299
  continue;
@@ -2,7 +2,7 @@
2
2
  * Public graph barrel: KIND_MODULES + derived views for pull/build/canvas.
3
3
  */
4
4
  import { type CatalogRenderArgs, type CatalogRenderResult, type EntityKindModule, type KindId, type ParentEdge, type PortableEmptiedList, type PortableLeaveOut, type PortablePrincipals, type StateAlignment, type StateScopedPlatformEntry, type TaskOutputReference, matchType } from "./types.js";
5
- export type { AdoptionAddressAlias, AuthoringFacet, CanvasComponentId, CanvasFacet, CanvasView, CatalogAuthoringArgs, CatalogFacet, CatalogRenderArgs, CatalogRenderResult, CatalogRoot, DataFacet, DataFacetCatalogKind, EntityKindId, EntityKindModule, KindId, LifecycleFacet, OrgIdentityBag, ParentEdge, ParentageFacet, ResourceFacet, StateAlignment, StateReferenceResolver, StateScopedPlatformEntry, StreamFacet, StreamMatch, StreamPartition, StreamRootExtractResult, TaskOutputReference, ToTfResult, UnmanagedLookup, SkippedOwnFileReport, } from "./types.js";
5
+ export type { AdoptionAddressAlias, AuthoringFacet, CanvasComponentId, CanvasFacet, CanvasView, CatalogAuthoringArgs, CatalogFacet, CatalogRenderArgs, CatalogRenderResult, CatalogRoot, DataFacet, DataFacetCatalogKind, EntityKindId, EntityKindModule, KindId, LifecycleFacet, OrgIdentityBag, ParentEdge, ParentageFacet, ResourceFacet, StateAlignment, StateReferenceResolver, StateScopedPlatformEntry, StreamFacet, StreamMatch, StreamPartition, StreamRootExtractResult, TaskOutputReference, ToTfResult, UnmanagedLookup, TrimmedList, SkippedOwnFileReport, TriggerReferenceRepair, } from "./types.js";
6
6
  export type { ReferenceLookupStrategy } from "./types.js";
7
7
  export { NO_CANVAS, NO_CATALOG, NO_DATA, NO_LIFECYCLE, defaultMatchResourceType, implementedResourceTypes, isResourceAdoptable, isTfLive, knownResourceTypes, matchType, singleResourceType, } from "./types.js";
8
8
  export { KIND_MODULES } from "./modules.js";
@@ -88,6 +88,19 @@ export declare const BUILD_VS_EXPORT_RECORD_FIELD_OUTPUT_KEYS: {
88
88
  readonly nameAttribute: string;
89
89
  readonly ownerAttribute: string;
90
90
  }[];
91
+ /** Task outputs named `<prefix><entry id>` whose refs key is that list entry's key attribute (#3085). */
92
+ export declare const BUILD_VS_EXPORT_LIST_ENTRY_OUTPUT_KEYS: {
93
+ readonly resourceType: string;
94
+ readonly prefix: string;
95
+ readonly listAttribute: string;
96
+ readonly idAttribute: string;
97
+ readonly keyAttribute: string;
98
+ readonly types: {
99
+ readonly localPrefix: string;
100
+ readonly typeAttribute: string;
101
+ readonly multipleAttribute: string;
102
+ };
103
+ }[];
91
104
  export declare const BUILD_VS_EXPORT_MAP_KEY_ALIASES: {
92
105
  readonly attribute: string;
93
106
  readonly canonicalKey: (key: string) => string | undefined;
@@ -63,6 +63,8 @@ export const BUILD_VS_EXPORT_COMPUTED_MAP_ATTRIBUTES = KIND_MODULES.flatMap((mod
63
63
  export const BUILD_VS_EXPORT_NESTED_OMITTED_DEFAULTS = KIND_MODULES.flatMap((module) => (module.roundtrip?.nestedOmittedDefaults ?? []).flatMap((declared) => implementedResourceTypes(module.resource).map((blockType) => ({ blockType, ...declared }))));
64
64
  export const BUILD_VS_EXPORT_COMPUTED_REFERENCE_MAPS = KIND_MODULES.flatMap((module) => module.roundtrip?.computedReferenceMaps ?? []);
65
65
  export const BUILD_VS_EXPORT_RECORD_FIELD_OUTPUT_KEYS = KIND_MODULES.flatMap((module) => module.roundtrip?.recordFieldOutputKeys ?? []);
66
+ /** Task outputs named `<prefix><entry id>` whose refs key is that list entry's key attribute (#3085). */
67
+ export const BUILD_VS_EXPORT_LIST_ENTRY_OUTPUT_KEYS = KIND_MODULES.flatMap((module) => module.roundtrip?.listEntryOutputKeys ?? []);
66
68
  export const BUILD_VS_EXPORT_MAP_KEY_ALIASES = KIND_MODULES.flatMap((module) => module.roundtrip?.mapKeyAliases ?? []);
67
69
  export const BUILD_VS_EXPORT_ATTRIBUTE_LOCALS = KIND_MODULES.flatMap((module) => module.roundtrip?.exportedAttributeLocals ?? []);
68
70
  export const BUILD_VS_EXPORT_PICKLIST_LABEL_ASSIGNMENTS = KIND_MODULES.flatMap((module) => module.roundtrip?.picklistLabelAssignments ?? []);
@@ -8,6 +8,8 @@ export declare const SCOPE_OWNER_RESOURCE_TYPES: {
8
8
  readonly app: "elementum_app";
9
9
  readonly element: "elementum_element";
10
10
  };
11
+ /** A portal: an org-level scope owner with no children (`--scope portal:<x>`, #3209). */
12
+ export declare const SCOPE_PORTAL_RESOURCE_TYPE = "elementum_portal";
11
13
  /**
12
14
  * App, element and field resources: a scoped plan reads other owners'
13
15
  * definitions through these, so they are not reported as dependencies
@@ -12,8 +12,11 @@ import { ACCESS_POLICY_RESOURCE_TYPE } from "../entities/access-policy/types.js"
12
12
  import { RELATIONSHIP_RESOURCE_TYPE } from "../entities/relationship/module.js";
13
13
  import { MANAGED_FIELD_ORDER_RESOURCE_TYPE } from "../entities/field/types.js";
14
14
  import { MANAGED_VIEW_ORDER_RESOURCE_TYPE } from "../entities/view/types.js";
15
+ import { PORTAL_RESOURCE_TYPE } from "../entities/portal/types.js";
15
16
  /** Definition resource of each scope-owner kind. */
16
17
  export const SCOPE_OWNER_RESOURCE_TYPES = { app: APP_RESOURCE_TYPE, element: ELEMENT_RESOURCE_TYPE };
18
+ /** A portal: an org-level scope owner with no children (`--scope portal:<x>`, #3209). */
19
+ export const SCOPE_PORTAL_RESOURCE_TYPE = PORTAL_RESOURCE_TYPE;
17
20
  /**
18
21
  * App, element and field resources: a scoped plan reads other owners'
19
22
  * definitions through these, so they are not reported as dependencies
@@ -350,6 +350,19 @@ export interface OwnFileExtractResult {
350
350
  readonly unmanagedLookups?: readonly UnmanagedLookup[];
351
351
  /** One entry per own-file child this pull skipped, for the pull summary (see {@link SkippedOwnFileReport}). */
352
352
  readonly skippedReports?: readonly SkippedOwnFileReport[];
353
+ /** References the first plan after this pull rewrites, for the pull summary (see {@link TriggerReferenceRepair}). */
354
+ readonly triggerReferenceRepairs?: readonly TriggerReferenceRepair[];
355
+ /**
356
+ * Export addresses whose state must hold their live settings after this
357
+ * pull. Adoption imports only what state lacks, so one already in state
358
+ * keeps the settings it was imported or applied with; adoption re-imports
359
+ * these (state only, a provider Read) when they are already bound. For a
360
+ * check that compares source with state, e.g. a stale run-automation tool
361
+ * and, for an unmapped required parameter, its automation's on-demand
362
+ * trigger (edk#3230, #3231). Never a resource whose import rewrites
363
+ * authored bookkeeping (a publish's revision).
364
+ */
365
+ readonly reimportForLive?: readonly string[];
353
366
  /**
354
367
  * Own-file ref names released from state on this pull. Their authored files
355
368
  * are archived so the next plan does not recreate the live resource (#1858).
@@ -401,6 +414,27 @@ export interface SkippedOwnFileReport {
401
414
  readonly reason: string;
402
415
  readonly causedBy?: string;
403
416
  }
417
+ /**
418
+ * A live reference to an on-demand input saved with the input's declared
419
+ * spelling ("ticket_number") instead of the normalized name the platform
420
+ * expects ("ticketNumber"). The platform marks such a reference invalid;
421
+ * source builds the normalized name, so the first plan after the pull
422
+ * rewrites it. Both spellings resolve to the same value at run time (#3109).
423
+ */
424
+ export interface TriggerReferenceRepair {
425
+ /** The automation's display name. */
426
+ readonly automation: string;
427
+ /** The automation's resource address in the export. */
428
+ readonly automationAddress: string;
429
+ /** The task's display name; absent for a workflow output. */
430
+ readonly task?: string;
431
+ /** The resource the plan updates (the task, switch case or publish). */
432
+ readonly address: string;
433
+ /** Where in that resource the reference is, e.g. `input "answers"`. */
434
+ readonly input: string;
435
+ readonly declared: string;
436
+ readonly normalized: string;
437
+ }
404
438
  /**
405
439
  * A data lookup that stands in for skipped resources in the export adoption
406
440
  * plans (#3023). Adoption replaces each `.id` reference to a skipped resource
@@ -421,6 +455,21 @@ export interface UnmanagedLookup {
421
455
  /** Data blocks `lookup` reads (its owner's lookup), declared with it when not already declared. */
422
456
  readonly supporting?: readonly TfBlock[];
423
457
  }
458
+ /**
459
+ * A resource pull keeps although some entries of one of its lists were left
460
+ * out of source (a dashboard's widget order without a skipped widget).
461
+ * Adoption drops the references to `leftOut` from the export's block and
462
+ * imports it with `importId`, which tracks only the entries left in.
463
+ */
464
+ export interface TrimmedList {
465
+ readonly address: string;
466
+ /** Addresses whose `.id` references the export's block lists, left out of source. */
467
+ readonly leftOut: readonly string[];
468
+ readonly importId: string;
469
+ /** The list attribute, and the ids it holds once imported with `importId`. */
470
+ readonly attribute: string;
471
+ readonly keptIds: readonly string[];
472
+ }
424
473
  export interface PrintedOwnFile {
425
474
  readonly refName: string;
426
475
  readonly source: string;
@@ -627,6 +676,16 @@ export interface BuildChildContext {
627
676
  readonly name: string;
628
677
  readonly namespace?: string;
629
678
  }>;
679
+ /** See `ToTfContext.outOfScopeElements`. */
680
+ readonly outOfScopeElements?: ReadonlyMap<string, {
681
+ readonly name: string;
682
+ readonly namespace?: string;
683
+ }>;
684
+ /** See `ToTfContext.catalogElementIdentities`. */
685
+ readonly catalogElementIdentities?: ReadonlyMap<string, {
686
+ readonly name: string;
687
+ readonly namespace?: string;
688
+ }>;
630
689
  /** The current app/element/table entity, forwarded for owner-local reference resolution. */
631
690
  readonly streamRootEntity?: DeployableEntity;
632
691
  /**
@@ -987,6 +1046,29 @@ export interface EntityKindModule {
987
1046
  readonly nameAttribute: string;
988
1047
  readonly ownerAttribute: string;
989
1048
  }[];
1049
+ /**
1050
+ * A task output whose reference name is `<prefix><entry id>` (or the
1051
+ * legacy `<prefix><entry key>`): the task's refs list it under that
1052
+ * entry's `<keyAttribute>` in its own `<listAttribute>` (a Calculation's
1053
+ * `calculationOutputMap.<id>` is its variable name, #3085).
1054
+ */
1055
+ readonly listEntryOutputKeys?: readonly {
1056
+ readonly resourceType: string;
1057
+ readonly prefix: string;
1058
+ readonly listAttribute: string;
1059
+ readonly idAttribute: string;
1060
+ readonly keyAttribute: string;
1061
+ /**
1062
+ * Where the export carries each entry's output type: a list local
1063
+ * `<localPrefix><task label>` of objects keyed by `<keyAttribute>`. An
1064
+ * envelope whose `fieldType`/`multiple` differ isn't that key's read.
1065
+ */
1066
+ readonly types: {
1067
+ readonly localPrefix: string;
1068
+ readonly typeAttribute: string;
1069
+ readonly multipleAttribute: string;
1070
+ };
1071
+ }[];
990
1072
  /**
991
1073
  * Computed map attributes (`refs`, also read as `inner.refs`) whose
992
1074
  * provider publishes one value under several keys: `canonicalKey` names
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementumai/edk",
3
- "version": "0.13.4",
3
+ "version": "0.14.0",
4
4
  "description": "Elementum Development Kit — statically typed SDK for building Elementum apps, automations, and agents",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",