@elementumai/edk 0.9.20 → 0.10.2

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 (159) hide show
  1. package/README.md +19 -7
  2. package/dist-sdk/src/catalog/factories.d.ts +10 -2
  3. package/dist-sdk/src/catalog/factories.js +10 -1
  4. package/dist-sdk/src/catalog/index.d.ts +2 -2
  5. package/dist-sdk/src/catalog/index.js +1 -1
  6. package/dist-sdk/src/catalog/token.js +4 -0
  7. package/dist-sdk/src/catalog/types.d.ts +7 -1
  8. package/dist-sdk/src/catalog/types.js +1 -0
  9. package/dist-sdk/src/core/triggers/on-demand.d.ts +2 -2
  10. package/dist-sdk/src/core/triggers/on-demand.js +7 -0
  11. package/dist-sdk/src/core/types/app.d.ts +2 -2
  12. package/dist-sdk/src/engine/coverage-gaps.d.ts +86 -0
  13. package/dist-sdk/src/engine/coverage-gaps.js +156 -0
  14. package/dist-sdk/src/engine/ei/run.d.ts +21 -1
  15. package/dist-sdk/src/engine/ei/run.js +89 -2
  16. package/dist-sdk/src/engine/pull/catalog-ref.d.ts +16 -0
  17. package/dist-sdk/src/engine/pull/catalog-ref.js +24 -0
  18. package/dist-sdk/src/engine/pull/context.d.ts +68 -6
  19. package/dist-sdk/src/engine/pull/context.js +40 -1
  20. package/dist-sdk/src/engine/pull/procedure-refs.d.ts +8 -0
  21. package/dist-sdk/src/engine/pull/procedure-refs.js +28 -0
  22. package/dist-sdk/src/engine/pull/result-output.js +27 -1
  23. package/dist-sdk/src/engine/tf/index.d.ts +1 -1
  24. package/dist-sdk/src/engine/tf/index.js +1 -1
  25. package/dist-sdk/src/engine/tf/labels.d.ts +22 -5
  26. package/dist-sdk/src/engine/tf/labels.js +45 -3
  27. package/dist-sdk/src/engine/tf/parse.js +3 -2
  28. package/dist-sdk/src/engine/validation.d.ts +5 -0
  29. package/dist-sdk/src/engine/validation.js +12 -2
  30. package/dist-sdk/src/entities/access-policy/from-tf.js +38 -1
  31. package/dist-sdk/src/entities/access-policy/principal.d.ts +2 -0
  32. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +3 -0
  33. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +42 -19
  34. package/dist-sdk/src/entities/agent/from-tf.js +11 -3
  35. package/dist-sdk/src/entities/agent/module.js +2 -0
  36. package/dist-sdk/src/entities/agent/to-tf.js +14 -3
  37. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +8 -1
  38. package/dist-sdk/src/entities/agent-tool/from-tf.js +11 -5
  39. package/dist-sdk/src/entities/agent-tool/module.js +3 -0
  40. package/dist-sdk/src/entities/app/auto-share.d.ts +38 -0
  41. package/dist-sdk/src/entities/app/auto-share.js +49 -0
  42. package/dist-sdk/src/entities/app/build.d.ts +17 -3
  43. package/dist-sdk/src/entities/app/build.js +56 -4
  44. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +6 -1
  45. package/dist-sdk/src/entities/app/from-tf.js +4 -0
  46. package/dist-sdk/src/entities/app/index.d.ts +2 -1
  47. package/dist-sdk/src/entities/app/index.js +1 -8
  48. package/dist-sdk/src/entities/app/module.js +2 -1
  49. package/dist-sdk/src/entities/app/to-tf.d.ts +6 -0
  50. package/dist-sdk/src/entities/app/to-tf.js +25 -2
  51. package/dist-sdk/src/entities/automation/build.d.ts +12 -2
  52. package/dist-sdk/src/entities/automation/build.js +105 -17
  53. package/dist-sdk/src/entities/automation/calculation-expression.d.ts +7 -7
  54. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +17 -4
  55. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +187 -27
  56. package/dist-sdk/src/entities/automation/from-tf.d.ts +9 -2
  57. package/dist-sdk/src/entities/automation/from-tf.js +397 -89
  58. package/dist-sdk/src/entities/automation/index.d.ts +1 -1
  59. package/dist-sdk/src/entities/automation/index.js +1 -1
  60. package/dist-sdk/src/entities/automation/module.d.ts +3 -0
  61. package/dist-sdk/src/entities/automation/module.js +70 -7
  62. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +21 -0
  63. package/dist-sdk/src/entities/automation/output-key-wire-name.js +38 -0
  64. package/dist-sdk/src/entities/automation/script-code.d.ts +5 -2
  65. package/dist-sdk/src/entities/automation/script-code.js +23 -5
  66. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +37 -0
  67. package/dist-sdk/src/entities/automation/task-output-labels.js +76 -0
  68. package/dist-sdk/src/entities/automation/tasks.d.ts +92 -20
  69. package/dist-sdk/src/entities/automation/tasks.js +48 -15
  70. package/dist-sdk/src/entities/automation/to-tf.d.ts +20 -3
  71. package/dist-sdk/src/entities/automation/to-tf.js +656 -65
  72. package/dist-sdk/src/entities/automation/triggers.d.ts +8 -4
  73. package/dist-sdk/src/entities/automation/types.d.ts +9 -0
  74. package/dist-sdk/src/entities/automation/types.js +19 -0
  75. package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +1 -1
  76. package/dist-sdk/src/entities/automation/value-ref-tf.js +1 -1
  77. package/dist-sdk/src/entities/chart/from-tf.js +9 -1
  78. package/dist-sdk/src/entities/data-lookup/module.js +2 -0
  79. package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +1 -0
  80. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +7 -5
  81. package/dist-sdk/src/entities/element/build.d.ts +3 -0
  82. package/dist-sdk/src/entities/element/build.js +1 -0
  83. package/dist-sdk/src/entities/element/from-tf.js +4 -0
  84. package/dist-sdk/src/entities/element/module.js +2 -1
  85. package/dist-sdk/src/entities/element/to-tf.d.ts +1 -1
  86. package/dist-sdk/src/entities/element/to-tf.js +12 -14
  87. package/dist-sdk/src/entities/field/build.d.ts +3 -2
  88. package/dist-sdk/src/entities/field/calc.d.ts +7 -7
  89. package/dist-sdk/src/entities/field/from-tf.d.ts +4 -4
  90. package/dist-sdk/src/entities/field/from-tf.js +255 -80
  91. package/dist-sdk/src/entities/field/module.d.ts +6 -0
  92. package/dist-sdk/src/entities/field/module.js +23 -2
  93. package/dist-sdk/src/entities/field/options.js +6 -1
  94. package/dist-sdk/src/entities/field/order.d.ts +16 -0
  95. package/dist-sdk/src/entities/field/order.js +41 -0
  96. package/dist-sdk/src/entities/field/to-tf.d.ts +4 -4
  97. package/dist-sdk/src/entities/field/to-tf.js +7 -1
  98. package/dist-sdk/src/entities/field/types.d.ts +7 -0
  99. package/dist-sdk/src/entities/field/types.js +32 -0
  100. package/dist-sdk/src/entities/role/from-tf.js +3 -3
  101. package/dist-sdk/src/entities/role/to-tf.d.ts +2 -0
  102. package/dist-sdk/src/entities/role/to-tf.js +12 -4
  103. package/dist-sdk/src/entities/service-account/from-tf.js +3 -3
  104. package/dist-sdk/src/entities/service-account/workspace-owner.d.ts +16 -0
  105. package/dist-sdk/src/entities/service-account/workspace-owner.js +22 -0
  106. package/dist-sdk/src/entities/shared/filters/ast.d.ts +15 -1
  107. package/dist-sdk/src/entities/shared/filters/ast.js +2 -0
  108. package/dist-sdk/src/entities/shared/filters/index.d.ts +5 -0
  109. package/dist-sdk/src/entities/shared/filters/index.js +5 -0
  110. package/dist-sdk/src/entities/shared/filters/print.js +7 -2
  111. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +5 -0
  112. package/dist-sdk/src/entities/shared/filters/tf-codec.js +42 -7
  113. package/dist-sdk/src/entities/shared/filters/types.d.ts +8 -3
  114. package/dist-sdk/src/entities/shared/ref.d.ts +5 -7
  115. package/dist-sdk/src/entities/shared/ref.js +5 -7
  116. package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +9 -0
  117. package/dist-sdk/src/entities/shared/tool-field-ref.js +35 -2
  118. package/dist-sdk/src/entities/shared/types/field-types.d.ts +10 -0
  119. package/dist-sdk/src/entities/shared/types/field-types.js +4 -0
  120. package/dist-sdk/src/entities/skill/access-policy.js +3 -3
  121. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +3 -0
  122. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +12 -5
  123. package/dist-sdk/src/entities/skill/from-tf.js +4 -2
  124. package/dist-sdk/src/entities/skill/module.js +2 -0
  125. package/dist-sdk/src/entities/skill-tool/from-tf.js +41 -8
  126. package/dist-sdk/src/entities/skill-tool/module.js +3 -0
  127. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +0 -6
  128. package/dist-sdk/src/entities/skill-tool/to-tf.js +22 -9
  129. package/dist-sdk/src/entities/task/build.d.ts +8 -0
  130. package/dist-sdk/src/entities/task/build.js +10 -1
  131. package/dist-sdk/src/entities/task/from-tf.d.ts +4 -2
  132. package/dist-sdk/src/entities/task/from-tf.js +7 -2
  133. package/dist-sdk/src/entities/task/module.js +3 -2
  134. package/dist-sdk/src/entities/task/to-tf.d.ts +8 -4
  135. package/dist-sdk/src/entities/task/to-tf.js +32 -1
  136. package/dist-sdk/src/entities/view/from-tf.js +9 -1
  137. package/dist-sdk/src/entities/view/module.js +4 -1
  138. package/dist-sdk/src/entities/view/to-tf.d.ts +6 -7
  139. package/dist-sdk/src/entities/view/to-tf.js +30 -11
  140. package/dist-sdk/src/entities/view/types.d.ts +6 -0
  141. package/dist-sdk/src/entities/view/types.js +6 -0
  142. package/dist-sdk/src/entities/visual-flow/build.d.ts +16 -1
  143. package/dist-sdk/src/entities/visual-flow/build.js +9 -0
  144. package/dist-sdk/src/entities/visual-flow/from-tf.d.ts +14 -0
  145. package/dist-sdk/src/entities/visual-flow/from-tf.js +51 -3
  146. package/dist-sdk/src/entities/visual-flow/index.d.ts +1 -1
  147. package/dist-sdk/src/entities/visual-flow/index.js +1 -1
  148. package/dist-sdk/src/entities/visual-flow/printer.js +19 -0
  149. package/dist-sdk/src/entities/visual-flow/to-tf.js +87 -3
  150. package/dist-sdk/src/entities/widget/from-tf.js +3 -3
  151. package/dist-sdk/src/entities/widget/to-tf.d.ts +2 -0
  152. package/dist-sdk/src/entities/widget/to-tf.js +7 -6
  153. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +133 -9
  154. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
  155. package/dist-sdk/src/graph/index.d.ts +4 -2
  156. package/dist-sdk/src/graph/index.js +3 -0
  157. package/dist-sdk/src/graph/modules.js +2 -1
  158. package/dist-sdk/src/graph/types.d.ts +41 -3
  159. package/package.json +7 -3
@@ -10,14 +10,14 @@
10
10
  * with the same `EntityTfError` path used by access-policy row filters.
11
11
  */
12
12
  import { agentViewLayoutToTf, viewBlocksToTf } from "./agent-view-layout-to-tf.js";
13
- import { expr, isCanonicalTsLabel, sanitizeName, scopedResourceLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
13
+ import { expr, isCanonicalTsLabel, scopedResourceLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
14
14
  import { fieldRefToTfValue as customFieldRefToTfValue } from "../field/to-tf.js";
15
15
  import { ELEMENT_SYSTEM_FIELD_KEYS } from "../element/system-fields.js";
16
16
  import { filterToTf, principalListToTf } from "../access-policy/to-tf.js";
17
17
  import { SUB_TYPE_BY_AUTHORING_TYPE } from "../field/types.js";
18
18
  import { DASHBOARD_RESOURCE_TYPE } from "../dashboard/module.js";
19
19
  import { WIDGET_RESOURCE_TYPE } from "../widget/module.js";
20
- import { AGENT_VIEW_RESOURCE_TYPE, CUSTOM_VIEW_RESOURCE_TYPE, CALENDAR_VIEW_RESOURCE_TYPE, DASHBOARD_VIEW_RESOURCE_TYPE, GROUP_SECTION_WIRE_TYPE, LAYOUT_RESOURCE_TYPE, 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";
20
+ import { AGENT_VIEW_RESOURCE_TYPE, CUSTOM_VIEW_RESOURCE_TYPE, CALENDAR_VIEW_RESOURCE_TYPE, DASHBOARD_VIEW_RESOURCE_TYPE, GROUP_SECTION_WIRE_TYPE, LAYOUT_RESOURCE_TYPE, LIST_VIEW_RESOURCE_TYPE, KANBAN_VIEW_RESOURCE_TYPE, MANAGED_VIEW_ORDER_RESOURCE_TYPE, PLATFORM_DEFAULT_LIST_VIEW_NAME, SECTION_TYPE_TO_WIRE, SYSTEM_FIELD_ID_ATTR_BY_KEY, UPDATE_SECTION_WIRE_TYPE, } from "./types.js";
21
21
  function appendViewSharingAttrs(attrs, view, where, ctx) {
22
22
  const userIds = principalListToTf(view.userIds, "elementum_user", `${where}.userIds`, ctx);
23
23
  const groupIds = principalListToTf(view.groupIds, "elementum_group", `${where}.groupIds`, ctx);
@@ -36,7 +36,7 @@ function appendViewSharingAttrs(attrs, view, where, ctx) {
36
36
  }
37
37
  /** `layouts`/`listViews`/`viewOrder` → their resource blocks, in ei's dialect. */
38
38
  export function viewToTf(layouts, listViews, calendarViews, kanbanViews, dashboardViews, agentViews, viewOrder, opts, customViews) {
39
- const { ownerRefName, ownerTfLabel, scope = "app", aspectName, objectId, diagnostics, fieldAddresses } = opts;
39
+ const { ownerRefName, ownerTfLabel, scope = "app", objectId, diagnostics, fieldAddresses } = opts;
40
40
  const principalCtx = { ...opts, scope, objectId };
41
41
  const blocks = [];
42
42
  for (const [stageKey, layout] of Object.entries(layouts ?? {})) {
@@ -301,18 +301,28 @@ export function viewToTf(layouts, listViews, calendarViews, kanbanViews, dashboa
301
301
  }
302
302
  // Every declared list view must appear even if viewOrder omitted it —
303
303
  // otherwise the omitted view has no ordering entry and the platform
304
- // may reject or silently exclude it from the managed order.
304
+ // may reject or silently exclude it from the managed order. The exception
305
+ // is the platform's default "List" view: the platform keeps it in the order
306
+ // itself, and the provider leaves it out of an order that doesn't list it
307
+ // (#1598), so appending it would plan a change after every pull (#1658).
308
+ const viewNames = new Map([listViews, calendarViews, kanbanViews, dashboardViews, agentViews, customViews]
309
+ .flatMap((bag) => Object.entries(bag ?? {}).map(([key, view]) => [key, view.name])));
305
310
  for (const [key, address] of viewAddressByKey) {
306
311
  if (placed.has(key))
307
312
  continue;
313
+ if (viewOrder !== undefined && viewNames.get(key) === PLATFORM_DEFAULT_LIST_VIEW_NAME)
314
+ continue;
308
315
  diagnostics.push(`view "${key}" is not listed in viewOrder; appended`);
309
316
  viewIds.push(expr.resourceAttr(address.type, address.label, ["id"]));
310
317
  }
311
- if (viewIds.length > 0) {
318
+ // An explicitly empty viewOrder keeps an empty order (#1658).
319
+ if (viewIds.length > 0 || viewOrder !== undefined) {
312
320
  blocks.push({
313
321
  kind: "resource",
314
322
  type: MANAGED_VIEW_ORDER_RESOURCE_TYPE,
315
- label: `${sanitizeName(aspectName)}_view_order`,
323
+ // No name of its own: labelled from the owner's namespace, like the record
324
+ // create form, so renaming the app or element keeps its address.
325
+ label: scopedResourceLabel(ownerTfLabel, "view_order", scope),
316
326
  attrs: { object_id: objectId, view_ids: viewIds },
317
327
  });
318
328
  }
@@ -386,6 +396,7 @@ function layoutToTf(stageKey, layout, ownerRefName, ownerTfLabel, scope, objectI
386
396
  // provider re-places them when it recreates the layout.
387
397
  const fields = section.fields ?? [];
388
398
  const widgetIds = [];
399
+ const inserted = [];
389
400
  for (const [index, widget] of (section.widgets ?? []).entries()) {
390
401
  const widgetWhere = `${where}.widgets[${index}]`;
391
402
  const key = widget.refName ?? "";
@@ -401,12 +412,20 @@ function layoutToTf(stageKey, layout, ownerRefName, ownerTfLabel, scope, objectI
401
412
  diagnostics.push(`${widgetWhere}: widget ${JSON.stringify(key)} is not declared in this ${scope}; dropped`);
402
413
  continue;
403
414
  }
404
- widgetIds.push(expr.resourceAttr(WIDGET_RESOURCE_TYPE, scopedResourceLabel(ownerTfLabel, tsLabelToTfLabel(key), scope), ["id"]));
415
+ const widgetId = expr.resourceAttr(WIDGET_RESOURCE_TYPE, scopedResourceLabel(ownerTfLabel, tsLabelToTfLabel(key), scope), ["id"]);
416
+ if (typeof widget.at === "number")
417
+ inserted.push({ at: widget.at, id: widgetId });
418
+ else
419
+ widgetIds.push(widgetId);
420
+ }
421
+ const fieldIds = resolveFieldRefs(fields, ownerTfLabel, scope, where, diagnostics, fieldAddresses);
422
+ // Insert from the back so each `at` is an index in the original field
423
+ // list, not an index that earlier inserts have already shifted.
424
+ for (const widget of inserted.sort((left, right) => right.at - left.at)) {
425
+ const index = Math.max(0, Math.min(widget.at, fieldIds.length));
426
+ fieldIds.splice(index, 0, widget.id);
405
427
  }
406
- sec.field_ids = [
407
- ...resolveFieldRefs(fields, ownerTfLabel, scope, where, diagnostics, fieldAddresses),
408
- ...widgetIds,
409
- ];
428
+ sec.field_ids = [...fieldIds, ...widgetIds];
410
429
  }
411
430
  else if (wireType === UPDATE_SECTION_WIRE_TYPE && section.name !== undefined) {
412
431
  sec.name = section.name;
@@ -18,6 +18,12 @@ export declare const CALENDAR_VIEW_RESOURCE_TYPE = "elementum_calendar_view";
18
18
  export declare const KANBAN_VIEW_RESOURCE_TYPE = "elementum_kanban_view";
19
19
  export declare const DASHBOARD_VIEW_RESOURCE_TYPE = "elementum_dashboard_view";
20
20
  export declare const MANAGED_VIEW_ORDER_RESOURCE_TYPE = "elementum_managed_view_order";
21
+ /**
22
+ * The name the platform gives the list view it creates on every app, element
23
+ * and task. Like the provider (`platformDefaultListViewName`), EDK recognises
24
+ * that view only by this name; the platform has no other marker for it.
25
+ */
26
+ export declare const PLATFORM_DEFAULT_LIST_VIEW_NAME = "List";
21
27
  /** Looks up a managed view by owner and name (a portal menu's view outside the workspace). */
22
28
  export declare const VIEW_DATA_RESOURCE_TYPE = "elementum_view";
23
29
  /**
@@ -20,6 +20,12 @@ export const CALENDAR_VIEW_RESOURCE_TYPE = "elementum_calendar_view";
20
20
  export const KANBAN_VIEW_RESOURCE_TYPE = "elementum_kanban_view";
21
21
  export const DASHBOARD_VIEW_RESOURCE_TYPE = "elementum_dashboard_view";
22
22
  export const MANAGED_VIEW_ORDER_RESOURCE_TYPE = "elementum_managed_view_order";
23
+ /**
24
+ * The name the platform gives the list view it creates on every app, element
25
+ * and task. Like the provider (`platformDefaultListViewName`), EDK recognises
26
+ * that view only by this name; the platform has no other marker for it.
27
+ */
28
+ export const PLATFORM_DEFAULT_LIST_VIEW_NAME = "List";
23
29
  /** Looks up a managed view by owner and name (a portal menu's view outside the workspace). */
24
30
  export const VIEW_DATA_RESOURCE_TYPE = "elementum_view";
25
31
  /**
@@ -1,4 +1,4 @@
1
- import { type AgentRef, type AppCatalogRef, type AppOrElementRef, type AutomationRef } from "../../catalog/index.js";
1
+ import { type AgentRef, type AppCatalogRef, type AppOrElementRef, type AutomationRef, type DatamineRef, type RelationshipRef, type TableRef } from "../../catalog/index.js";
2
2
  import type { DeployableEntity, EntityDeployOptions } from "../../engine/entity.js";
3
3
  declare const positionBrand: unique symbol;
4
4
  declare const symbolBrand: unique symbol;
@@ -39,6 +39,18 @@ type ActionPayload = {
39
39
  readonly kind: "object";
40
40
  readonly object: AppOrElementRef;
41
41
  readonly name?: string;
42
+ } | {
43
+ readonly kind: "datamine";
44
+ readonly datamine: DatamineRef;
45
+ readonly name?: string;
46
+ } | {
47
+ readonly kind: "table";
48
+ readonly table: TableRef;
49
+ readonly name?: string;
50
+ } | {
51
+ readonly kind: "relationship";
52
+ readonly relationship: RelationshipRef;
53
+ readonly name?: string;
42
54
  };
43
55
  export type VisualFlowAction = ActionPayload & {
44
56
  readonly [actionBrand]: "VisualFlowAction";
@@ -54,6 +66,9 @@ export declare function flowAutomationAction(automation: AutomationRef, name?: s
54
66
  export declare function flowUserAction(name: string): VisualFlowAction;
55
67
  export declare function flowApiAction(name: string): VisualFlowAction;
56
68
  export declare function flowObjectAction(object: AppOrElementRef, name?: string): VisualFlowAction;
69
+ export declare function flowDatamineAction(datamine: DatamineRef, name?: string): VisualFlowAction;
70
+ export declare function flowTableAction(table: TableRef, name?: string): VisualFlowAction;
71
+ export declare function flowRelationshipAction(relationship: RelationshipRef, name?: string): VisualFlowAction;
57
72
  export declare function flowObjectTarget(object: AppOrElementRef, name?: string): VisualFlowTarget;
58
73
  export interface VisualFlowConnection {
59
74
  readonly target: string;
@@ -26,6 +26,15 @@ export function flowApiAction(name) {
26
26
  export function flowObjectAction(object, name) {
27
27
  return { kind: "object", object, ...(name !== undefined ? { name } : {}) };
28
28
  }
29
+ export function flowDatamineAction(datamine, name) {
30
+ return { kind: "datamine", datamine, ...(name !== undefined ? { name } : {}) };
31
+ }
32
+ export function flowTableAction(table, name) {
33
+ return { kind: "table", table, ...(name !== undefined ? { name } : {}) };
34
+ }
35
+ export function flowRelationshipAction(relationship, name) {
36
+ return { kind: "relationship", relationship, ...(name !== undefined ? { name } : {}) };
37
+ }
29
38
  export function flowObjectTarget(object, name) {
30
39
  return { object, ...(name !== undefined ? { name } : {}) };
31
40
  }
@@ -20,6 +20,20 @@ export type NormalizedVisualFlowAction = {
20
20
  readonly kind: "object";
21
21
  readonly object: NormalizedFlowObject;
22
22
  readonly name?: string;
23
+ } | {
24
+ readonly kind: "datamine";
25
+ readonly refName: string;
26
+ readonly parent: string;
27
+ readonly parentName?: string;
28
+ readonly name?: string;
29
+ } | {
30
+ readonly kind: "table";
31
+ readonly refName: string;
32
+ readonly name?: string;
33
+ } | {
34
+ readonly kind: "relationship";
35
+ readonly refName: string;
36
+ readonly name?: string;
23
37
  };
24
38
  export interface NormalizedVisualFlowNode {
25
39
  readonly description?: string;
@@ -1,7 +1,10 @@
1
1
  import { EntityTfError } from "../../engine/entity.js";
2
- import { plainObject, resourceRefLabel } from "../../engine/pull/context.js";
2
+ import { dataRefLabel, plainObject, resourceRefLabel } from "../../engine/pull/context.js";
3
3
  import { isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf/index.js";
4
4
  import { dataAspectDisplayName, dataAspectRefName } from "../shared/aspect-target-from-tf.js";
5
+ import { DATAMINE_RESOURCE_TYPE } from "../datamine/module.js";
6
+ import { RELATIONSHIP_RESOURCE_TYPE } from "../relationship/module.js";
7
+ import { TABLE_RESOURCE_TYPE } from "../table/module.js";
5
8
  import { VISUAL_FLOW_RESOURCE_TYPE } from "./module.js";
6
9
  const KNOWN = new Set(["id", "object_id", "stages"]);
7
10
  const symbols = new Set(["SQUARE", "DIAMOND", "CIRCLE"]);
@@ -37,7 +40,7 @@ function objectRef(value, ctx, where) {
37
40
  }
38
41
  function actionFromTf(value, ownerLabel, scope, ctx, where) {
39
42
  const action = requiredObject(value, where);
40
- const variants = ["agent", "automation", "user", "api", "object"].filter((key) => action[key] !== undefined);
43
+ const variants = ["agent", "automation", "user", "api", "object", "datamine", "table", "relationship"].filter((key) => action[key] !== undefined);
41
44
  if (variants.length !== 1)
42
45
  throw new EntityTfError(`${where}: expected exactly one action variant`);
43
46
  const kind = variants[0];
@@ -52,7 +55,52 @@ function actionFromTf(value, ownerLabel, scope, ctx, where) {
52
55
  throw new EntityTfError(`${where}.${kind}: name is required`);
53
56
  return { kind, name };
54
57
  }
55
- return { kind: "object", object: objectRef(body["object_id"], ctx, `${where}.object`), ...(name !== undefined ? { name } : {}) };
58
+ if (kind === "object")
59
+ return { kind: "object", object: objectRef(body["object_id"], ctx, `${where}.object`), ...(name !== undefined ? { name } : {}) };
60
+ if (kind === "datamine")
61
+ return { kind: "datamine", ...datamineFromTf(body["datamine_id"], ctx, `${where}.datamine`), ...(name !== undefined ? { name } : {}) };
62
+ if (kind === "table")
63
+ return { kind: "table", refName: tableFromTf(body["table_id"], ctx, `${where}.table`), ...(name !== undefined ? { name } : {}) };
64
+ return { kind: "relationship", refName: ownedRef(body["relationship_id"], RELATIONSHIP_RESOURCE_TYPE, ownerLabel, scope, where), ...(name !== undefined ? { name } : {}) };
65
+ }
66
+ function tableFromTf(value, ctx, where) {
67
+ if (value === undefined || !isTfExpr(value) || (value.$expr !== "resource-attr" && value.$expr !== "data-attr") || value.type !== TABLE_RESOURCE_TYPE || value.path.length !== 1 || value.path[0] !== "id") {
68
+ throw new EntityTfError(`${where}: expected a typed elementum_table reference`);
69
+ }
70
+ if (value.$expr === "data-attr") {
71
+ const display = ctx.dataName(TABLE_RESOURCE_TYPE, value.label);
72
+ return display !== undefined ? ( /* prefer stable tf label */tfLabelToTsLabel(value.label)) : tfLabelToTsLabel(value.label);
73
+ }
74
+ return tfLabelToTsLabel(value.label);
75
+ }
76
+ function datamineFromTf(value, ctx, where) {
77
+ if (value === undefined || !isTfExpr(value) || (value.$expr !== "resource-attr" && value.$expr !== "data-attr") || value.type !== DATAMINE_RESOURCE_TYPE || value.path.length !== 1 || value.path[0] !== "id") {
78
+ throw new EntityTfError(`${where}: expected a typed elementum_datamine reference`);
79
+ }
80
+ const label = value.label;
81
+ let tableLabel;
82
+ let parentName;
83
+ if (value.$expr === "resource-attr") {
84
+ const block = ctx.resourceByAddress?.(`${DATAMINE_RESOURCE_TYPE}.${label}`);
85
+ tableLabel = block !== undefined ? resourceRefLabel(block.attrs["table_id"], TABLE_RESOURCE_TYPE) : undefined;
86
+ }
87
+ else {
88
+ const attrs = ctx.dataAttrs?.(DATAMINE_RESOURCE_TYPE, label);
89
+ const tableId = attrs?.["table_id"];
90
+ tableLabel = tableId !== undefined ? (resourceRefLabel(tableId, TABLE_RESOURCE_TYPE) ?? dataRefLabel(tableId, TABLE_RESOURCE_TYPE)) : undefined;
91
+ if (tableLabel !== undefined)
92
+ parentName = ctx.dataName(TABLE_RESOURCE_TYPE, tableLabel);
93
+ }
94
+ if (tableLabel !== undefined) {
95
+ const prefix = `${tableLabel}_`;
96
+ const refName = label.startsWith(prefix) ? tfLabelToTsLabel(label.slice(prefix.length)) : tfLabelToTsLabel(label);
97
+ return { refName, parent: tfLabelToTsLabel(tableLabel), ...(parentName !== undefined ? { parentName } : {}) };
98
+ }
99
+ const underscore = label.indexOf("_");
100
+ if (underscore > 0) {
101
+ return { refName: tfLabelToTsLabel(label.slice(underscore + 1)), parent: tfLabelToTsLabel(label.slice(0, underscore)) };
102
+ }
103
+ throw new EntityTfError(`${where}: datamine reference is missing its owning table`);
56
104
  }
57
105
  function nodeFromTf(value, ownerLabel, scope, ctx, where) {
58
106
  const node = requiredObject(value, where);
@@ -1 +1 @@
1
- export { visualFlow, flowAgentAction, flowApiAction, flowAutomationAction, flowObjectAction, flowObjectTarget, flowUserAction, visualFlowPosition, visualFlowSymbol, type DefineVisualFlowOptions, type VisualFlowAction, type VisualFlowConnection, type VisualFlowNode, type VisualFlowPosition, type VisualFlowStage, type VisualFlowSymbol, type VisualFlowTarget, } from "./build.js";
1
+ export { visualFlow, flowAgentAction, flowApiAction, flowAutomationAction, flowObjectAction, flowRelationshipAction, flowTableAction, flowDatamineAction, flowObjectTarget, flowUserAction, visualFlowPosition, visualFlowSymbol, type DefineVisualFlowOptions, type VisualFlowAction, type VisualFlowConnection, type VisualFlowNode, type VisualFlowPosition, type VisualFlowStage, type VisualFlowSymbol, type VisualFlowTarget, } from "./build.js";
@@ -1 +1 @@
1
- export { visualFlow, flowAgentAction, flowApiAction, flowAutomationAction, flowObjectAction, flowObjectTarget, flowUserAction, visualFlowPosition, visualFlowSymbol, } from "./build.js";
1
+ export { visualFlow, flowAgentAction, flowApiAction, flowAutomationAction, flowObjectAction, flowRelationshipAction, flowTableAction, flowDatamineAction, flowObjectTarget, flowUserAction, visualFlowPosition, visualFlowSymbol, } from "./build.js";
@@ -18,6 +18,19 @@ function actionExpr(action, owner, refs) {
18
18
  case "user": return `flowUserAction(${quote(action.name)})`;
19
19
  case "api": return `flowApiAction(${quote(action.name)})`;
20
20
  case "object": return `flowObjectAction(${objectExpr(action.object, refs)}${action.name !== undefined ? `, ${quote(action.name)}` : ""})`;
21
+ case "datamine": {
22
+ const parentName = action.parentName !== undefined ? `, parentName: ${quote(action.parentName)}` : "";
23
+ const nameArg = action.name !== undefined ? `, ${quote(action.name)}` : "";
24
+ return `flowDatamineAction({ __kind: "datamine", refName: ${quote(action.refName)}, name: ${quote(action.name ?? action.refName)}, parent: ${quote(action.parent)}${parentName} }${nameArg})`;
25
+ }
26
+ case "table": {
27
+ const nameArg = action.name !== undefined ? `, ${quote(action.name)}` : "";
28
+ return `flowTableAction({ __kind: "table", refName: ${quote(action.refName)}, name: ${quote(action.name ?? action.refName)} }${nameArg})`;
29
+ }
30
+ case "relationship": {
31
+ const nameArg = action.name !== undefined ? `, ${quote(action.name)}` : "";
32
+ return `flowRelationshipAction({ __kind: "relationship", refName: ${quote(action.refName)}, name: ${quote(action.name ?? action.refName)}, parent: ${quote(owner)} }${nameArg})`;
33
+ }
21
34
  }
22
35
  }
23
36
  function nodeLines(node, owner, refs) {
@@ -56,6 +69,9 @@ export function printVisualFlow(flow, owner, scope, refs = {}) {
56
69
  user: "flowUserAction",
57
70
  api: "flowApiAction",
58
71
  object: "flowObjectAction",
72
+ datamine: "flowDatamineAction",
73
+ table: "flowTableAction",
74
+ relationship: "flowRelationshipAction",
59
75
  }[node.action.kind]);
60
76
  }
61
77
  }
@@ -65,8 +81,11 @@ export function printVisualFlow(flow, owner, scope, refs = {}) {
65
81
  "flowAgentAction",
66
82
  "flowApiAction",
67
83
  "flowAutomationAction",
84
+ "flowDatamineAction",
68
85
  "flowObjectAction",
69
86
  "flowObjectTarget",
87
+ "flowRelationshipAction",
88
+ "flowTableAction",
70
89
  "flowUserAction",
71
90
  "visualFlowPosition",
72
91
  "visualFlowSymbol",
@@ -4,6 +4,9 @@ import { EntityTfError } from "../../engine/entity.js";
4
4
  import { appScopedResourceLabel, expr, tsLabelToTfLabel } from "../../engine/tf/index.js";
5
5
  import { APP_RESOURCE_TYPE } from "../app/module.js";
6
6
  import { ELEMENT_RESOURCE_TYPE } from "../element/module.js";
7
+ import { DATAMINE_RESOURCE_TYPE } from "../datamine/module.js";
8
+ import { RELATIONSHIP_RESOURCE_TYPE } from "../relationship/module.js";
9
+ import { TABLE_RESOURCE_TYPE } from "../table/module.js";
7
10
  import { VISUAL_FLOW_RESOURCE_TYPE } from "./module.js";
8
11
  function ownedResourceRef(ref, expected, ctx) {
9
12
  if (ref.__kind !== expected || !ref.refName || ref.parent !== ctx.appRefName) {
@@ -27,7 +30,7 @@ function objectRef(ref, ctx) {
27
30
  const name = ref.name ?? ref.refName;
28
31
  return resolveForeignRef(kind, { name, namespace: ref.namespace }, ctx.orgRefs, ctx.diagnostics, "visual flow object").value;
29
32
  }
30
- function actionToTf(action, ctx) {
33
+ function actionToTf(action, ctx, dataBlocks) {
31
34
  switch (action.kind) {
32
35
  case "agent": {
33
36
  const ref = action.agent;
@@ -55,10 +58,90 @@ function actionToTf(action, ctx) {
55
58
  throw new EntityTfError("visual flow object action is missing its object reference");
56
59
  return { object: { object_id: objectRef(ref, ctx), ...(action.name !== undefined && action.name !== "" ? { name: action.name } : {}) } };
57
60
  }
61
+ case "datamine": {
62
+ const ref = action.datamine;
63
+ if (ref === undefined)
64
+ throw new EntityTfError("visual flow datamine action is missing its datamine reference");
65
+ return { datamine: { datamine_id: datamineRefToTf(ref, ctx, dataBlocks), ...(action.name !== undefined && action.name !== "" ? { name: action.name } : {}) } };
66
+ }
67
+ case "table": {
68
+ const ref = action.table;
69
+ if (ref === undefined)
70
+ throw new EntityTfError("visual flow table action is missing its table reference");
71
+ return { table: { table_id: tableRefToTf(ref, ctx, dataBlocks), ...(action.name !== undefined && action.name !== "" ? { name: action.name } : {}) } };
72
+ }
73
+ case "relationship": {
74
+ const ref = action.relationship;
75
+ if (ref === undefined)
76
+ throw new EntityTfError("visual flow relationship action is missing its relationship reference");
77
+ if (ref.__kind !== "relationship" || !ref.refName || ref.parent !== ctx.appRefName) {
78
+ throw new EntityTfError(`visual flow relationship must be a typed reference owned by ${ctx.appRefName}`);
79
+ }
80
+ return {
81
+ relationship: {
82
+ relationship_id: expr.resourceAttr(RELATIONSHIP_RESOURCE_TYPE, appScopedResourceLabel(ctx.appTfLabel, tsLabelToTfLabel(ref.refName)), ["id"]),
83
+ ...(action.name !== undefined && action.name !== "" ? { name: action.name } : {}),
84
+ },
85
+ };
86
+ }
58
87
  default:
59
88
  throw new EntityTfError("visual flow action must come from a public action factory");
60
89
  }
61
90
  }
91
+ function tableRefToTf(ref, ctx, dataBlocks) {
92
+ if (ref.__kind !== "table" || !ref.refName) {
93
+ throw new EntityTfError("visual flow table must be a typed table reference");
94
+ }
95
+ const local = ctx.workspaceAspects?.get(workspaceAspectKey("table", ref.refName));
96
+ if (local !== undefined)
97
+ return expr.resourceAttr(TABLE_RESOURCE_TYPE, local.tfLabel, ["id"]);
98
+ const name = ref.name ?? ref.refName;
99
+ const label = tsLabelToTfLabel(ref.refName);
100
+ ctx.orgRefs.rawLookup(TABLE_RESOURCE_TYPE, label, name);
101
+ dataBlocks.set(`${TABLE_RESOURCE_TYPE}.${label}`, {
102
+ kind: "data",
103
+ type: TABLE_RESOURCE_TYPE,
104
+ label,
105
+ attrs: { name },
106
+ });
107
+ return expr.dataAttr(TABLE_RESOURCE_TYPE, label, ["id"]);
108
+ }
109
+ function datamineRefToTf(ref, ctx, dataBlocks) {
110
+ if (ref.__kind !== "datamine" || !ref.refName) {
111
+ throw new EntityTfError("visual flow datamine must be a typed datamine reference");
112
+ }
113
+ if (ref.parent === undefined || ref.parent === "") {
114
+ throw new EntityTfError(`visual flow datamine ${JSON.stringify(ref.refName)} is missing its owning table`);
115
+ }
116
+ const label = `${tsLabelToTfLabel(ref.parent)}_${tsLabelToTfLabel(ref.refName)}`;
117
+ const tableSibling = ctx.workspaceAspects?.get(workspaceAspectKey("table", ref.parent));
118
+ if (tableSibling !== undefined && tableSibling.managedDatamineLabels?.has(label) === true) {
119
+ return expr.resourceAttr(DATAMINE_RESOURCE_TYPE, label, ["id"]);
120
+ }
121
+ let tableId;
122
+ if (tableSibling !== undefined) {
123
+ tableId = expr.resourceAttr(TABLE_RESOURCE_TYPE, tableSibling.tfLabel, ["id"]);
124
+ }
125
+ else {
126
+ const tableLabel = tsLabelToTfLabel(ref.parent);
127
+ const tableName = typeof ref.parentName === "string" && ref.parentName !== "" ? ref.parentName : ref.parent;
128
+ ctx.orgRefs.rawLookup(TABLE_RESOURCE_TYPE, tableLabel, tableName);
129
+ dataBlocks.set(`${TABLE_RESOURCE_TYPE}.${tableLabel}`, {
130
+ kind: "data",
131
+ type: TABLE_RESOURCE_TYPE,
132
+ label: tableLabel,
133
+ attrs: { name: tableName },
134
+ });
135
+ tableId = expr.dataAttr(TABLE_RESOURCE_TYPE, tableLabel, ["id"]);
136
+ }
137
+ dataBlocks.set(`${DATAMINE_RESOURCE_TYPE}.${label}`, {
138
+ kind: "data",
139
+ type: DATAMINE_RESOURCE_TYPE,
140
+ label,
141
+ attrs: { table_id: tableId, name: ref.name ?? ref.refName },
142
+ });
143
+ return expr.dataAttr(DATAMINE_RESOURCE_TYPE, label, ["id"]);
144
+ }
62
145
  export function visualFlowToTf(entity, ctx) {
63
146
  if (entity.kind !== "visual-flow")
64
147
  throw new EntityTfError(`visualFlowToTf expects visual-flow; got ${entity.kind}`);
@@ -73,6 +156,7 @@ export function visualFlowToTf(entity, ctx) {
73
156
  throw new EntityTfError(`visual flow ${entity.refName} has no payload`);
74
157
  const ownerType = APP_RESOURCE_TYPE;
75
158
  const label = appScopedResourceLabel(ctx.appTfLabel, tsLabelToTfLabel(entity.refName));
159
+ const dataBlocks = new Map();
76
160
  const stages = (payload.stages ?? []).map((stage) => {
77
161
  if (!stage.stage)
78
162
  throw new EntityTfError(`visual flow ${entity.refName}: every stage requires a stable key`);
@@ -87,11 +171,11 @@ export function visualFlowToTf(entity, ctx) {
87
171
  x: node.x ?? 0,
88
172
  y: node.y ?? 0,
89
173
  connects_to: (node.connectsTo ?? []).map((connection) => typeof connection === "string" ? { target: connection } : { target: connection.target ?? "", ...(connection.label !== undefined && { label: connection.label }) }),
90
- ...(node.action !== undefined && { action: actionToTf(node.action, ctx) }),
174
+ ...(node.action !== undefined && { action: actionToTf(node.action, ctx, dataBlocks) }),
91
175
  ...(node.target?.object !== undefined && { target: { object: { object_id: objectRef(node.target.object, ctx), name: node.target.name ?? node.target.object.name ?? node.target.object.refName ?? "Object" } } }),
92
176
  })),
93
177
  };
94
178
  });
95
179
  const block = { kind: "resource", type: VISUAL_FLOW_RESOURCE_TYPE, label, attrs: { object_id: expr.resourceAttr(ownerType, ctx.appTfLabel, ["id"]), stages } };
96
- return { blocks: [block], address: `${VISUAL_FLOW_RESOURCE_TYPE}.${label}` };
180
+ return { blocks: [...dataBlocks.values(), block], address: `${VISUAL_FLOW_RESOURCE_TYPE}.${label}` };
97
181
  }
@@ -119,8 +119,8 @@ function widgetFromTf(block, owner, ctx, dynamicLayoutCompanionLabels) {
119
119
  ...(typeof rec["value"] === "string" && { value: rec["value"] }),
120
120
  }];
121
121
  })
122
- : undefined;
123
- if (parametersRaw !== undefined && !Array.isArray(parametersRaw)) {
122
+ : [];
123
+ if (parametersRaw !== undefined && parametersRaw !== null && !Array.isArray(parametersRaw)) {
124
124
  ctx.diagnostics.push(`${where}.run_automation_action.parameters: expected a list; dropped`);
125
125
  }
126
126
  return {
@@ -129,7 +129,7 @@ function widgetFromTf(block, owner, ctx, dynamicLayoutCompanionLabels) {
129
129
  name,
130
130
  automation,
131
131
  ...buttonStyle(body, where, ctx),
132
- ...(parameters !== undefined && { parameters }),
132
+ parameters,
133
133
  };
134
134
  }
135
135
  function buttonStyle(attrs, where, ctx) {
@@ -45,6 +45,8 @@ export declare function relationshipTargetsFromBag(relationships: Readonly<Recor
45
45
  export interface WidgetsToTfOptions {
46
46
  readonly ownerRefName: string;
47
47
  readonly ownerTfLabel: string;
48
+ /** Element handle, used to prefix element automation resource labels. */
49
+ readonly ownerHandle?: string;
48
50
  readonly ownerType: "elementum_app" | "elementum_element";
49
51
  readonly scope: ChildResourceScope;
50
52
  readonly objectId: TfValue;
@@ -1,7 +1,7 @@
1
1
  import { workspaceAspectKey } from "../../engine/build/context.js";
2
2
  import { foreignFieldDataLabel, resolveForeignRef } from "../shared/foreign-ref.js";
3
- import { appScopedResourceLabel, expr, isCanonicalTsLabel, sanitizeName, scopedResourceLabel, tfLabelToTsLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
4
- import { AUTOMATION_RESOURCE_TYPE } from "../automation/types.js";
3
+ import { expr, isCanonicalTsLabel, sanitizeName, scopedResourceLabel, tfLabelToTsLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
4
+ import { AUTOMATION_RESOURCE_TYPE, automationResourceLabel } from "../automation/types.js";
5
5
  import { fieldMetadataFromEntries } from "../field/metadata.js";
6
6
  import { authoredFieldKeysFromPayload, fieldRefToTfValue, } from "../field/to-tf.js";
7
7
  import { runAutomationParameterValue } from "./build.js";
@@ -274,6 +274,10 @@ function runAutomationParameters(widget, where, opts) {
274
274
  value,
275
275
  };
276
276
  });
277
+ // An authored list, including an empty one, is the live parameter set.
278
+ // CURRENT_RECORD is injected only when the author omitted parameters.
279
+ if (widget.parameters !== undefined)
280
+ return authored;
277
281
  const recordParam = onDemandRecordParamForWidget(widget.automation, opts);
278
282
  if (recordParam === undefined || authored.some((parameter) => parameter.name === recordParam)) {
279
283
  return authored;
@@ -311,10 +315,7 @@ function resolveAutomation(value, where, opts) {
311
315
  opts.diagnostics.push(`${where}: foreign automation references require a provider data lookup with app_id; use a raw id until that data-source tranche lands`);
312
316
  return undefined;
313
317
  }
314
- // Automations always use `appScopedResourceLabel` (`apps_<owner>_…`), even
315
- // when the owner is an element. `scopedResourceLabel(..., opts.scope)` would
316
- // mint `elements_…` here and plan an undeclared resource.
317
- return expr.resourceAttr(AUTOMATION_RESOURCE_TYPE, appScopedResourceLabel(opts.ownerTfLabel, tsLabelToTfLabel(refName)), ["id"]);
318
+ return expr.resourceAttr(AUTOMATION_RESOURCE_TYPE, automationResourceLabel(opts.ownerTfLabel, refName, opts.scope, opts.scope === "element" ? opts.ownerHandle : undefined), ["id"]);
318
319
  }
319
320
  function resolveManagedColumn(value, refName, target, opts) {
320
321
  const meta = siblingFieldMetadata(target, opts);