@elementumai/edk 0.9.14 → 0.9.16

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 (124) hide show
  1. package/dist-sdk/pull/util.d.ts +0 -15
  2. package/dist-sdk/pull/util.js +44 -5
  3. package/dist-sdk/src/catalog/factories.d.ts +4 -2
  4. package/dist-sdk/src/catalog/factories.js +4 -0
  5. package/dist-sdk/src/catalog/from-authoring.js +5 -1
  6. package/dist-sdk/src/catalog/index.d.ts +2 -2
  7. package/dist-sdk/src/catalog/index.js +1 -1
  8. package/dist-sdk/src/catalog/token.js +2 -2
  9. package/dist-sdk/src/catalog/types.d.ts +7 -2
  10. package/dist-sdk/src/core/types/app.d.ts +4 -4
  11. package/dist-sdk/src/engine/build/context.d.ts +5 -4
  12. package/dist-sdk/src/engine/build/source-context.d.ts +2 -0
  13. package/dist-sdk/src/engine/build/source-context.js +16 -0
  14. package/dist-sdk/src/engine/progress.d.ts +19 -1
  15. package/dist-sdk/src/engine/progress.js +33 -5
  16. package/dist-sdk/src/engine/pull/context.d.ts +9 -1
  17. package/dist-sdk/src/engine/pull/ref-only.d.ts +6 -2
  18. package/dist-sdk/src/engine/pull/ref-only.js +14 -3
  19. package/dist-sdk/src/engine/workspace/loader.js +23 -2
  20. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +1 -1
  21. package/dist-sdk/src/entities/access-policy/from-tf.js +47 -12
  22. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +5 -3
  23. package/dist-sdk/src/entities/access-policy/to-tf.js +23 -1
  24. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +6 -0
  25. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +50 -4
  26. package/dist-sdk/src/entities/agent/from-tf.d.ts +1 -0
  27. package/dist-sdk/src/entities/agent/from-tf.js +18 -3
  28. package/dist-sdk/src/entities/agent/module.js +1 -0
  29. package/dist-sdk/src/entities/agent/to-tf.js +15 -0
  30. package/dist-sdk/src/entities/agent/tools.d.ts +98 -5
  31. package/dist-sdk/src/entities/agent/tools.js +12 -3
  32. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +15 -0
  33. package/dist-sdk/src/entities/agent-tool/from-tf.js +47 -4
  34. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +9 -0
  35. package/dist-sdk/src/entities/agent-tool/to-tf.js +82 -25
  36. package/dist-sdk/src/entities/app/build.d.ts +2 -2
  37. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +4 -4
  38. package/dist-sdk/src/entities/app/module.js +8 -0
  39. package/dist-sdk/src/entities/app/to-tf.js +1 -0
  40. package/dist-sdk/src/entities/approval-chain/build.d.ts +8 -1
  41. package/dist-sdk/src/entities/approval-chain/build.js +3 -0
  42. package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +2 -1
  43. package/dist-sdk/src/entities/approval-chain/from-tf.js +20 -7
  44. package/dist-sdk/src/entities/approval-chain/printer.js +13 -2
  45. package/dist-sdk/src/entities/approval-chain/to-tf.js +3 -0
  46. package/dist-sdk/src/entities/automation/build.d.ts +19 -12
  47. package/dist-sdk/src/entities/automation/build.js +36 -13
  48. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +4 -0
  49. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +19 -0
  50. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +222 -65
  51. package/dist-sdk/src/entities/automation/from-tf.d.ts +86 -6
  52. package/dist-sdk/src/entities/automation/from-tf.js +360 -63
  53. package/dist-sdk/src/entities/automation/index.d.ts +3 -2
  54. package/dist-sdk/src/entities/automation/index.js +3 -2
  55. package/dist-sdk/src/entities/automation/module.js +21 -16
  56. package/dist-sdk/src/entities/automation/output-field-types.d.ts +5 -0
  57. package/dist-sdk/src/entities/automation/output-field-types.js +12 -0
  58. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +20 -0
  59. package/dist-sdk/src/entities/automation/output-key-wire-name.js +22 -0
  60. package/dist-sdk/src/entities/automation/script-code.d.ts +32 -0
  61. package/dist-sdk/src/entities/automation/script-code.js +72 -5
  62. package/dist-sdk/src/entities/automation/tasks.d.ts +60 -24
  63. package/dist-sdk/src/entities/automation/tasks.js +33 -14
  64. package/dist-sdk/src/entities/automation/to-tf.d.ts +0 -2
  65. package/dist-sdk/src/entities/automation/to-tf.js +123 -46
  66. package/dist-sdk/src/entities/automation/triggers.d.ts +5 -2
  67. package/dist-sdk/src/entities/automation/types.d.ts +2 -0
  68. package/dist-sdk/src/entities/automation/types.js +5 -0
  69. package/dist-sdk/src/entities/automation/workflow-output.d.ts +35 -0
  70. package/dist-sdk/src/entities/automation/workflow-output.js +53 -0
  71. package/dist-sdk/src/entities/chart/build.d.ts +3 -3
  72. package/dist-sdk/src/entities/chart/from-tf.d.ts +2 -2
  73. package/dist-sdk/src/entities/chart/from-tf.js +20 -13
  74. package/dist-sdk/src/entities/chart/to-tf.js +7 -5
  75. package/dist-sdk/src/entities/dashboard/from-tf.js +1 -1
  76. package/dist-sdk/src/entities/dashboard/to-tf.js +1 -0
  77. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +3 -2
  78. package/dist-sdk/src/entities/element/build.d.ts +11 -8
  79. package/dist-sdk/src/entities/element/build.js +14 -5
  80. package/dist-sdk/src/entities/element/locals.d.ts +2 -2
  81. package/dist-sdk/src/entities/element/locals.js +6 -2
  82. package/dist-sdk/src/entities/element/system-fields.d.ts +4 -0
  83. package/dist-sdk/src/entities/element/system-fields.js +12 -0
  84. package/dist-sdk/src/entities/element/to-tf.js +1 -0
  85. package/dist-sdk/src/entities/field/build.d.ts +2 -2
  86. package/dist-sdk/src/entities/field/from-tf.js +82 -4
  87. package/dist-sdk/src/entities/field/to-tf.d.ts +1 -1
  88. package/dist-sdk/src/entities/field/to-tf.js +11 -4
  89. package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -2
  90. package/dist-sdk/src/entities/relationship/from-tf.js +8 -5
  91. package/dist-sdk/src/entities/relationship/to-tf.js +13 -3
  92. package/dist-sdk/src/entities/search-table/from-tf.js +6 -6
  93. package/dist-sdk/src/entities/search-table/module.js +2 -2
  94. package/dist-sdk/src/entities/search-table/types.d.ts +1 -0
  95. package/dist-sdk/src/entities/search-table/types.js +1 -0
  96. package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +3 -3
  97. package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +10 -6
  98. package/dist-sdk/src/entities/shared/filters/ast.d.ts +4 -2
  99. package/dist-sdk/src/entities/shared/filters/index.d.ts +12 -2
  100. package/dist-sdk/src/entities/shared/filters/index.js +17 -1
  101. package/dist-sdk/src/entities/shared/filters/print.js +25 -11
  102. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +1 -1
  103. package/dist-sdk/src/entities/shared/filters/tf-codec.js +39 -7
  104. package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +1 -1
  105. package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -2
  106. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +6 -0
  107. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +47 -18
  108. package/dist-sdk/src/entities/skill/module.js +10 -0
  109. package/dist-sdk/src/entities/skill/to-tf.js +19 -0
  110. package/dist-sdk/src/entities/skill/tools.d.ts +29 -7
  111. package/dist-sdk/src/entities/skill/tools.js +6 -2
  112. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +18 -0
  113. package/dist-sdk/src/entities/skill-tool/from-tf.js +77 -4
  114. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +8 -0
  115. package/dist-sdk/src/entities/skill-tool/to-tf.js +90 -46
  116. package/dist-sdk/src/entities/task/module.js +1 -1
  117. package/dist-sdk/src/entities/view/from-tf.js +30 -9
  118. package/dist-sdk/src/entities/view/to-tf.js +18 -10
  119. package/dist-sdk/src/entities/widget/from-tf.js +3 -3
  120. package/dist-sdk/src/entities/widget/to-tf.js +1 -0
  121. package/dist-sdk/src/graph/index.d.ts +15 -0
  122. package/dist-sdk/src/graph/index.js +19 -0
  123. package/dist-sdk/src/graph/types.d.ts +37 -1
  124. package/package.json +2 -1
@@ -22,7 +22,7 @@ function viewFilter(value, owner, where, ctx) {
22
22
  ownerTfLabel: owner.ownerTfLabel,
23
23
  scope: owner.scope ?? "app",
24
24
  foreignFieldRefsById: ctx.foreignFieldRefsById,
25
- }, `${where}.filter`);
25
+ }, `${where}.filter`, ctx);
26
26
  }
27
27
  /** All three view resource kinds → the normalized shapes the app printer consumes. */
28
28
  export function viewsFromTf(layoutBlocks, listViewBlocks, calendarViewBlocks, kanbanViewBlocks, dashboardViewBlocks, agentViewBlocks, managedViewOrderBlocks, owner, ctx) {
@@ -106,6 +106,8 @@ function dashboardViewFromTf(block, owner, ctx) {
106
106
  const sort = managedViewSortFromTf(attrs["sort"], owner, where, ctx);
107
107
  const userIds = principalList(attrs["user_ids"], "elementum_user", `${where}: user_ids`, ctx);
108
108
  const groupIds = principalList(attrs["group_ids"], "elementum_group", `${where}: group_ids`, ctx);
109
+ const emptyUserIds = Array.isArray(attrs["user_ids"]) && attrs["user_ids"].length === 0;
110
+ const emptyGroupIds = Array.isArray(attrs["group_ids"]) && attrs["group_ids"].length === 0;
109
111
  const filter = viewFilter(attrs["filter"], owner, where, ctx);
110
112
  return {
111
113
  key: scopedLabelToBagKey(owner.ownerTfLabel, label, scope),
@@ -114,8 +116,8 @@ function dashboardViewFromTf(block, owner, ctx) {
114
116
  ...(typeof attrs["allow_record_creation"] === "boolean" && { allowRecordCreation: attrs["allow_record_creation"] }),
115
117
  ...(filter !== undefined && { filter }),
116
118
  ...(sort !== undefined && { sort }),
117
- ...(userIds !== undefined && { userIds }),
118
- ...(groupIds !== undefined && { groupIds }),
119
+ ...(userIds !== undefined ? { userIds } : emptyUserIds ? { userIds: [] } : {}),
120
+ ...(groupIds !== undefined ? { groupIds } : emptyGroupIds ? { groupIds: [] } : {}),
119
121
  };
120
122
  }
121
123
  function calendarViewFromTf(block, owner, ctx) {
@@ -163,6 +165,8 @@ function typedFieldViewFromTf(block, owner, resourceType, knownAttrs, includeAll
163
165
  const sort = managedViewSortFromTf(attrs["sort"], owner, where, ctx);
164
166
  const userIds = principalList(attrs["user_ids"], "elementum_user", `${where}: user_ids`, ctx);
165
167
  const groupIds = principalList(attrs["group_ids"], "elementum_group", `${where}: group_ids`, ctx);
168
+ const emptyUserIds = Array.isArray(attrs["user_ids"]) && attrs["user_ids"].length === 0;
169
+ const emptyGroupIds = Array.isArray(attrs["group_ids"]) && attrs["group_ids"].length === 0;
166
170
  const filter = viewFilter(attrs["filter"], owner, where, ctx);
167
171
  return {
168
172
  key: scopedLabelToBagKey(owner.ownerTfLabel, label, scope),
@@ -173,8 +177,8 @@ function typedFieldViewFromTf(block, owner, resourceType, knownAttrs, includeAll
173
177
  ...(typeof attrs["allow_record_creation"] === "boolean" && { allowRecordCreation: attrs["allow_record_creation"] }),
174
178
  ...(filter !== undefined && { filter }),
175
179
  ...(sort !== undefined && { sort }),
176
- ...(userIds !== undefined && { userIds }),
177
- ...(groupIds !== undefined && { groupIds }),
180
+ ...(userIds !== undefined ? { userIds } : emptyUserIds ? { userIds: [] } : {}),
181
+ ...(groupIds !== undefined ? { groupIds } : emptyGroupIds ? { groupIds: [] } : {}),
178
182
  };
179
183
  }
180
184
  function agentViewFromTf(block, owner, ctx) {
@@ -199,6 +203,8 @@ function agentViewFromTf(block, owner, ctx) {
199
203
  const sort = managedViewSortFromTf(attrs["sort"], owner, where, ctx);
200
204
  const userIds = principalList(attrs["user_ids"], "elementum_user", `${where}: user_ids`, ctx);
201
205
  const groupIds = principalList(attrs["group_ids"], "elementum_group", `${where}: group_ids`, ctx);
206
+ const emptyUserIds = Array.isArray(attrs["user_ids"]) && attrs["user_ids"].length === 0;
207
+ const emptyGroupIds = Array.isArray(attrs["group_ids"]) && attrs["group_ids"].length === 0;
202
208
  const filter = viewFilter(attrs["filter"], owner, where, ctx);
203
209
  return {
204
210
  key: scopedLabelToBagKey(owner.ownerTfLabel, label, scope),
@@ -207,8 +213,8 @@ function agentViewFromTf(block, owner, ctx) {
207
213
  ...(typeof attrs["allow_record_creation"] === "boolean" && { allowRecordCreation: attrs["allow_record_creation"] }),
208
214
  ...(filter !== undefined && { filter }),
209
215
  ...(sort !== undefined && { sort }),
210
- ...(userIds !== undefined && { userIds }),
211
- ...(groupIds !== undefined && { groupIds }),
216
+ ...(userIds !== undefined ? { userIds } : emptyUserIds ? { userIds: [] } : {}),
217
+ ...(groupIds !== undefined ? { groupIds } : emptyGroupIds ? { groupIds: [] } : {}),
212
218
  ...(typeof attrs["display_order"] === "number" && { displayOrder: attrs["display_order"] }),
213
219
  };
214
220
  }
@@ -334,6 +340,19 @@ function fieldRefFromTf(v, ownerLabel, ownerTfLabel, scope, ctx) {
334
340
  const fieldKey = fieldKeyFromTfValue(v, tfLabelToTsLabel(ownerLabel), ownerTfLabel, scope, ctx);
335
341
  if (fieldKey !== undefined)
336
342
  return fieldKey;
343
+ if (typeof v === "string" && v !== "") {
344
+ // The field itself couldn't be resolved to a portable reference at all
345
+ // - ei's own export already fell back to a bare platform-id string here
346
+ // (live-confirmed on sanofi/eu: two purchaseorder layout sections mix
347
+ // resolved field refs with raw ids). Keep it as-is instead of dropping
348
+ // the entry: printViewFieldRef recognizes a raw platform id and prints
349
+ // unsafePlatformId(...), the same fallback printManagedViewSort already
350
+ // uses for a sort field. Dropping it silently shrank the rebuilt
351
+ // section's field_ids, forcing a destructive replace on every plan
352
+ // (#1178).
353
+ ctx.diagnostics.push(`field reference "${v}" could not be resolved to a portable reference; kept as unresolved`);
354
+ return v;
355
+ }
337
356
  if (!isTfExpr(v)) {
338
357
  ctx.diagnostics.push(`field reference has an unrecognized (non-expression) shape; dropped`);
339
358
  return undefined;
@@ -390,6 +409,8 @@ function listViewFromTf(block, owner, ctx) {
390
409
  const density = listViewDensityFromTf(attrs["density"], where, ctx);
391
410
  const userIds = principalList(attrs["user_ids"], "elementum_user", `${where}: user_ids`, ctx);
392
411
  const groupIds = principalList(attrs["group_ids"], "elementum_group", `${where}: group_ids`, ctx);
412
+ const emptyUserIds = Array.isArray(attrs["user_ids"]) && attrs["user_ids"].length === 0;
413
+ const emptyGroupIds = Array.isArray(attrs["group_ids"]) && attrs["group_ids"].length === 0;
393
414
  return {
394
415
  key: scopedLabelToBagKey(owner.ownerTfLabel, label, scope),
395
416
  name,
@@ -399,8 +420,8 @@ function listViewFromTf(block, owner, ctx) {
399
420
  ...(typeof attrs["rows"] === "number" && { rows: attrs["rows"] }),
400
421
  ...(filter !== undefined && { filter }),
401
422
  ...(sort !== undefined && { sort }),
402
- ...(userIds !== undefined && { userIds }),
403
- ...(groupIds !== undefined && { groupIds }),
423
+ ...(userIds !== undefined ? { userIds } : emptyUserIds ? { userIds: [] } : {}),
424
+ ...(groupIds !== undefined ? { groupIds } : emptyGroupIds ? { groupIds: [] } : {}),
404
425
  };
405
426
  }
406
427
  /** `jsonencode({...})` → its decoded payload; undefined for any other shape. */
@@ -11,20 +11,27 @@
11
11
  */
12
12
  import { expr, isCanonicalTsLabel, sanitizeName, scopedResourceLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
13
13
  import { fieldRefToTfValue as customFieldRefToTfValue } from "../field/to-tf.js";
14
+ import { ELEMENT_SYSTEM_FIELD_KEYS } from "../element/system-fields.js";
14
15
  import { filterToTf, principalListToTf } from "../access-policy/to-tf.js";
15
16
  import { SUB_TYPE_BY_AUTHORING_TYPE } from "../field/types.js";
16
17
  import { DASHBOARD_RESOURCE_TYPE } from "../dashboard/module.js";
17
18
  import { WIDGET_RESOURCE_TYPE } from "../widget/module.js";
18
19
  import { AGENT_VIEW_RESOURCE_TYPE, CALENDAR_VIEW_RESOURCE_TYPE, DASHBOARD_VIEW_RESOURCE_TYPE, GROUP_SECTION_WIRE_TYPE, LAYOUT_RESOURCE_TYPE, LAYOUT_RESTRICTED_SYSTEM_FIELD_KEYS, LIST_VIEW_RESOURCE_TYPE, KANBAN_VIEW_RESOURCE_TYPE, MANAGED_VIEW_ORDER_RESOURCE_TYPE, SECTION_TYPE_TO_WIRE, SYSTEM_FIELD_ID_ATTR_BY_KEY, UPDATE_SECTION_WIRE_TYPE, } from "./types.js";
19
- /** Elements only have `id`/`title` as real system fields (no status/stage/audit fields) — see `element/locals.ts`. */
20
- const ELEMENT_SYSTEM_FIELD_KEYS = new Set(["id", "title"]);
21
20
  function appendViewSharingAttrs(attrs, view, where, ctx) {
22
21
  const userIds = principalListToTf(view.userIds, "elementum_user", `${where}.userIds`, ctx);
23
22
  const groupIds = principalListToTf(view.groupIds, "elementum_group", `${where}.groupIds`, ctx);
24
- if (userIds !== undefined)
25
- attrs["user_ids"] = userIds;
26
- if (groupIds !== undefined)
27
- attrs["group_ids"] = groupIds;
23
+ if (view.userIds !== undefined) {
24
+ if (view.userIds.length === 0)
25
+ attrs["user_ids"] = [];
26
+ else if (userIds !== undefined)
27
+ attrs["user_ids"] = userIds;
28
+ }
29
+ if (view.groupIds !== undefined) {
30
+ if (view.groupIds.length === 0)
31
+ attrs["group_ids"] = [];
32
+ else if (groupIds !== undefined)
33
+ attrs["group_ids"] = groupIds;
34
+ }
28
35
  }
29
36
  /** `layouts`/`listViews`/`viewOrder` → their resource blocks, in ei's dialect. */
30
37
  export function viewToTf(layouts, listViews, calendarViews, kanbanViews, dashboardViews, agentViews, viewOrder, opts) {
@@ -71,6 +78,7 @@ export function viewToTf(layouts, listViews, calendarViews, kanbanViews, dashboa
71
78
  if (view.filter !== undefined) {
72
79
  attrs.filter = filterToTf(view.filter, `${where}.filter`, {
73
80
  ownerTfLabel,
81
+ appRefName: ownerRefName,
74
82
  scope,
75
83
  objectId,
76
84
  diagnostics,
@@ -119,7 +127,7 @@ export function viewToTf(layouts, listViews, calendarViews, kanbanViews, dashboa
119
127
  }
120
128
  }
121
129
  if (view.filter !== undefined)
122
- attrs["filter"] = filterToTf(view.filter, `${where}.filter`, { ownerTfLabel, scope, objectId, diagnostics, resolvePicklistLiterals: false, fieldAddresses });
130
+ attrs["filter"] = filterToTf(view.filter, `${where}.filter`, { ownerTfLabel, appRefName: ownerRefName, scope, objectId, diagnostics, resolvePicklistLiterals: false, fieldAddresses });
123
131
  if (view.sort !== undefined)
124
132
  attrs["sort"] = managedViewSortToTf(view.sort, ownerTfLabel, scope, `${where}.sort`, diagnostics, fieldAddresses);
125
133
  appendViewSharingAttrs(attrs, view, where, principalCtx);
@@ -161,7 +169,7 @@ export function viewToTf(layouts, listViews, calendarViews, kanbanViews, dashboa
161
169
  allow_record_creation: view.allowRecordCreation ?? true,
162
170
  };
163
171
  if (view.filter !== undefined)
164
- attrs["filter"] = filterToTf(view.filter, `dashboardViews.${viewKey}.filter`, { ownerTfLabel, scope, objectId, diagnostics, resolvePicklistLiterals: false, fieldAddresses });
172
+ attrs["filter"] = filterToTf(view.filter, `dashboardViews.${viewKey}.filter`, { ownerTfLabel, appRefName: ownerRefName, scope, objectId, diagnostics, resolvePicklistLiterals: false, fieldAddresses });
165
173
  if (view.sort !== undefined)
166
174
  attrs["sort"] = managedViewSortToTf(view.sort, ownerTfLabel, scope, `dashboardViews.${viewKey}.sort`, diagnostics, fieldAddresses);
167
175
  appendViewSharingAttrs(attrs, view, `dashboardViews.${viewKey}`, principalCtx);
@@ -194,7 +202,7 @@ export function viewToTf(layouts, listViews, calendarViews, kanbanViews, dashboa
194
202
  allow_record_creation: view.allowRecordCreation ?? true,
195
203
  };
196
204
  if (view.filter !== undefined)
197
- attrs["filter"] = filterToTf(view.filter, `agentViews.${viewKey}.filter`, { ownerTfLabel, scope, objectId, diagnostics, resolvePicklistLiterals: false, fieldAddresses });
205
+ attrs["filter"] = filterToTf(view.filter, `agentViews.${viewKey}.filter`, { ownerTfLabel, appRefName: ownerRefName, scope, objectId, diagnostics, resolvePicklistLiterals: false, fieldAddresses });
198
206
  if (view.sort !== undefined)
199
207
  attrs["sort"] = managedViewSortToTf(view.sort, ownerTfLabel, scope, `agentViews.${viewKey}.sort`, diagnostics, fieldAddresses);
200
208
  appendViewSharingAttrs(attrs, view, `agentViews.${viewKey}`, principalCtx);
@@ -360,7 +368,7 @@ function fieldRefToTfValue(ref, ownerTfLabel, scope, where, diagnostics, fieldAd
360
368
  return undefined;
361
369
  }
362
370
  if (typeof ref === "string") {
363
- if (scope === "element" && !ELEMENT_SYSTEM_FIELD_KEYS.has(ref)) {
371
+ if (scope === "element" && !ELEMENT_SYSTEM_FIELD_KEYS.includes(ref)) {
364
372
  diagnostics.push(`${where}: "${ref}" is not a known system field key on an element; dropped`);
365
373
  return undefined;
366
374
  }
@@ -79,7 +79,7 @@ function widgetFromTf(block, owner, ctx, dynamicLayoutCompanionLabels) {
79
79
  };
80
80
  const filter = body["filter"] === undefined
81
81
  ? undefined
82
- : filterFromTf(body["filter"], filterOwner, `${where}.${variant}.filter`);
82
+ : filterFromTf(body["filter"], filterOwner, `${where}.${variant}.filter`, ctx);
83
83
  return {
84
84
  key,
85
85
  type: "linkRecords",
@@ -213,7 +213,7 @@ function widgetFieldRef(value, target, owner, ctx) {
213
213
  : target.key === owner.ownerRefName
214
214
  ? owner.ownerTfLabel
215
215
  : target.namespace ?? tsLabelToTfLabel(target.key);
216
- const targetScope = typeof target === "string" || target.kind === "automation" || target.kind === "field" || target.kind === "recordIdentity" ? owner.scope : target.kind;
216
+ const targetScope = typeof target === "string" || target.kind === "automation" || target.kind === "field" || target.kind === "recordIdentity" || target.kind === "task" ? owner.scope : target.kind;
217
217
  if (targetLabel !== undefined) {
218
218
  const key = fieldKeyFromTfRef(value, targetLabel, targetScope);
219
219
  if (key !== undefined) {
@@ -323,7 +323,7 @@ function fieldRefFromRawId(id, target, owner, ctx) {
323
323
  fieldType: subType.authoringType,
324
324
  };
325
325
  }
326
- if (typeof target !== "string" && target.kind !== "automation" && target.kind !== "field" && target.kind !== "recordIdentity") {
326
+ if (typeof target !== "string" && target.kind !== "automation" && target.kind !== "field" && target.kind !== "recordIdentity" && target.kind !== "task") {
327
327
  const targetTfLabel = target.key === owner.ownerRefName
328
328
  ? owner.ownerTfLabel
329
329
  : target.namespace ?? tsLabelToTfLabel(target.key);
@@ -52,6 +52,7 @@ export function widgetsToTf(widgets, opts) {
52
52
  if (widget.filter !== undefined)
53
53
  body["filter"] = filterToTf(widget.filter, `${where}.filter`, {
54
54
  ownerTfLabel: opts.ownerTfLabel,
55
+ appRefName: opts.ownerRefName,
55
56
  scope: opts.scope,
56
57
  objectId: opts.objectId,
57
58
  diagnostics: opts.diagnostics,
@@ -80,6 +80,19 @@ export declare const STREAM_ROOT_RESOURCE_TYPES: ReadonlySet<string>;
80
80
  * entities/ directly.
81
81
  */
82
82
  export declare const AUTHORING_TYPE_BY_RESOURCE_TYPE: ReadonlyMap<string, string>;
83
+ /** Entity-declared value equivalences used to compare builder and exporter HCL. */
84
+ export declare const BUILD_VS_EXPORT_NORMALIZATIONS: {
85
+ readonly omittedAttributeDefaults: {
86
+ attribute: string;
87
+ value: import("../engine/tf/model.js").TfValue;
88
+ blockType: string;
89
+ }[];
90
+ readonly stringSuffixAliases: {
91
+ attribute: string;
92
+ suffix: string;
93
+ blockType: string;
94
+ }[];
95
+ };
83
96
  /** Own-file children of a parent kind (build discovery + pull print paths). */
84
97
  export declare function ownFileChildrenOf(parent: KindId): readonly EntityKindModule[];
85
98
  /**
@@ -89,6 +102,8 @@ export declare function ownFileChildrenOf(parent: KindId): readonly EntityKindMo
89
102
  export declare function ownFileCatalogChildrenOf(parent: KindId): readonly EntityKindModule[];
90
103
  /** All own-file bags declared under a parent (including stubs without lifecycle). */
91
104
  export declare function ownFileBagsUnder(parent: KindId): readonly string[];
105
+ /** Own-file bag -> printer-owned companion subfolders (skipped when looking for entity files). */
106
+ export declare function companionDirsByBag(): ReadonlyMap<string, ReadonlySet<string>>;
92
107
  /** Org-root own-file bags (apps, tables, …) — authoring path roots. */
93
108
  export declare function orgRootOwnFileBags(): readonly string[];
94
109
  /** Parent edges for tests / docs. */
@@ -98,6 +98,11 @@ export const STREAM_ROOT_RESOURCE_TYPES = new Set(STREAM_ROOT_MODULES.flatMap((m
98
98
  export const AUTHORING_TYPE_BY_RESOURCE_TYPE = new Map(KIND_MODULES.flatMap((m) => m.resource.shape === "subTypes"
99
99
  ? m.resource.rows.flatMap((row) => (row.authoringType === undefined ? [] : [[row.resourceType, row.authoringType]]))
100
100
  : []));
101
+ /** Entity-declared value equivalences used to compare builder and exporter HCL. */
102
+ export const BUILD_VS_EXPORT_NORMALIZATIONS = {
103
+ omittedAttributeDefaults: KIND_MODULES.flatMap((module) => (module.roundtrip?.omittedAttributeDefaults ?? []).flatMap((equivalence) => implementedResourceTypes(module.resource).map((blockType) => ({ blockType, ...equivalence })))),
104
+ stringSuffixAliases: KIND_MODULES.flatMap((module) => (module.roundtrip?.stringSuffixAliases ?? []).flatMap((equivalence) => implementedResourceTypes(module.resource).map((blockType) => ({ blockType, ...equivalence })))),
105
+ };
101
106
  /** Own-file children of a parent kind (build discovery + pull print paths). */
102
107
  export function ownFileChildrenOf(parent) {
103
108
  return KIND_MODULES.filter((m) => m.authoring.unit === "ownFile" &&
@@ -126,6 +131,20 @@ export function ownFileBagsUnder(parent) {
126
131
  }
127
132
  return [...bags].sort();
128
133
  }
134
+ /** Own-file bag -> printer-owned companion subfolders (skipped when looking for entity files). */
135
+ export function companionDirsByBag() {
136
+ const out = new Map();
137
+ for (const m of KIND_MODULES) {
138
+ const dirs = m.lifecycle.participates ? m.lifecycle.companionDirs : undefined;
139
+ if (m.authoring.unit !== "ownFile" || dirs === undefined)
140
+ continue;
141
+ const set = out.get(m.authoring.bag) ?? new Set();
142
+ for (const dir of dirs)
143
+ set.add(dir);
144
+ out.set(m.authoring.bag, set);
145
+ }
146
+ return out;
147
+ }
129
148
  /** Org-root own-file bags (apps, tables, …) — authoring path roots. */
130
149
  export function orgRootOwnFileBags() {
131
150
  return ownFileBagsUnder("org");
@@ -262,6 +262,14 @@ export interface AdoptionAddressAlias {
262
262
  export interface PrintedOwnFile {
263
263
  readonly refName: string;
264
264
  readonly source: string;
265
+ /**
266
+ * Extra files printed with this one (e.g. an automation's plain-JS script
267
+ * files). `path` is relative to the kind's own folder (`automations/`).
268
+ */
269
+ readonly companionFiles?: readonly {
270
+ readonly path: string;
271
+ readonly content: string;
272
+ }[];
265
273
  }
266
274
  /** Bridge diagnostic attached to a raw, source-organization-only UUID fallback. */
267
275
  export interface UnresolvedReferenceDiagnostic {
@@ -320,6 +328,12 @@ export interface PrintOwnFileOptions {
320
328
  * prints `catalog.<refName>` instead of the literal stub.
321
329
  */
322
330
  readonly foreignElementRefNames?: ReadonlyMap<string, string>;
331
+ /**
332
+ * Same as {@link foreignAppRefNames}, keyed for tasks (#1011) — a
333
+ * task target whose name is a key here prints `catalog.<refName>` instead
334
+ * of the literal stub.
335
+ */
336
+ readonly foreignTaskRefNames?: ReadonlyMap<string, string>;
323
337
  /**
324
338
  * Live field id → pulled catalog identity. Recursive pull populates this
325
339
  * from each dependency export's import blocks so a root export that can
@@ -378,7 +392,7 @@ export interface BuildChildContext {
378
392
  readonly allowUnknownPicklistOptions?: boolean;
379
393
  /** Every app/element/table stream root in this build, by refName (see `ToTfContext.workspaceAspects`). */
380
394
  readonly workspaceAspects?: ReadonlyMap<string, {
381
- readonly kind: ChildResourceScope | "table";
395
+ readonly kind: ChildResourceScope | "table" | "task";
382
396
  readonly tfLabel: string;
383
397
  readonly streamRootEntity?: DeployableEntity;
384
398
  }>;
@@ -457,6 +471,18 @@ export type LifecycleFacet = {
457
471
  * (plus the full partitioned stream for cross-block grouping).
458
472
  */
459
473
  readonly extractOwnFile?: (ownBlocks: readonly TfBlock[], stream: StreamPartition, ctx: StreamExtractContext) => OwnFileExtractResult;
474
+ /**
475
+ * Subfolders of this kind's own folder that hold printer-owned
476
+ * companion files (e.g. `scripts` under `automations/`). Walkers that
477
+ * look for entity source files skip them. After a complete pull, files
478
+ * in them that no source file of the kind references are archived.
479
+ */
480
+ readonly companionDirs?: readonly string[];
481
+ /**
482
+ * Paths of the companion files a source file references, as written in
483
+ * the source (relative to its folder). Required for the pruning above.
484
+ */
485
+ readonly companionRefs?: (source: string) => readonly string[];
460
486
  /** Print one extracted own-file instance to TypeScript source. */
461
487
  readonly printOwnFile?: (item: unknown, opts: PrintOwnFileOptions) => PrintedOwnFile;
462
488
  /** Re-pull: preserve author-owned values that the live export cannot represent. */
@@ -512,6 +538,16 @@ export interface EntityKindModule {
512
538
  readonly nestedAttribute: string;
513
539
  readonly dataType: string;
514
540
  }[];
541
+ /** Values the exporter writes explicitly while the builder omits them as provider defaults. */
542
+ readonly omittedAttributeDefaults?: readonly {
543
+ readonly attribute: string;
544
+ readonly value: TfValue;
545
+ }[];
546
+ /** Exact exporter-only suffixes that carry no additional authored meaning. */
547
+ readonly stringSuffixAliases?: readonly {
548
+ readonly attribute: string;
549
+ readonly suffix: string;
550
+ }[];
515
551
  };
516
552
  }
517
553
  export declare function implementedResourceTypes(resource: ResourceFacet): readonly string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementumai/edk",
3
- "version": "0.9.14",
3
+ "version": "0.9.16",
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",
@@ -195,6 +195,7 @@
195
195
  "test:cli": "vitest run __tests__/cli",
196
196
  "test:binary": "npm run build:sdk && npm run build:binary:bun && npm run smoke:binary:bun",
197
197
  "test:integration": "node integration/run.mjs",
198
+ "reap:orphans": "node integration/tools/reap-orphaned-test-entities.mjs",
198
199
  "typecheck": "npm run typecheck:ci",
199
200
  "typecheck:ci": "tsc --noEmit -p tsconfig.ci.json && tsc --noEmit -p tsconfig.examples-check.json",
200
201
  "typecheck:src": "tsc --noEmit",