@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 decodeJson(value) {
22
22
  return value;
23
23
  }
24
24
  function datasourceFromTf(value, appLabel, appRefName, ctx, where) {
25
- for (const [type, kind] of [[APP_RESOURCE_TYPE, "app"], ["elementum_element", "element"], [TABLE_RESOURCE_TYPE, "table"]]) {
25
+ for (const [type, kind] of [[APP_RESOURCE_TYPE, "app"], ["elementum_element", "element"], ["elementum_task", "task"], [TABLE_RESOURCE_TYPE, "table"]]) {
26
26
  const resourceLabel = resourceRefLabel(value, type);
27
27
  if (resourceLabel !== undefined) {
28
28
  return {
@@ -39,15 +39,17 @@ function datasourceFromTf(value, appLabel, appRefName, ctx, where) {
39
39
  ? ctx.foreignAppRefNames?.get(name) ?? tfLabelToTsLabel(dataLabel)
40
40
  : kind === "element"
41
41
  ? ctx.foreignElementRefNames?.get(name) ?? tfLabelToTsLabel(dataLabel)
42
- : (() => {
43
- const attrs = ctx.dataAttrs?.(type, dataLabel);
44
- const id = typeof attrs?.["id"] === "string" ? attrs["id"] : ctx.importId(`data.${type}.${dataLabel}`);
45
- const byId = id === undefined ? undefined : ctx.foreignTableRefsById?.get(id);
46
- if (byId !== undefined)
47
- return byId.tableRefName;
48
- const matches = [...(ctx.foreignTableRefsById?.values() ?? [])].filter((candidate) => candidate.name === name);
49
- return matches.length === 1 ? matches[0].tableRefName : undefined;
50
- })();
42
+ : kind === "task"
43
+ ? tfLabelToTsLabel(dataLabel)
44
+ : (() => {
45
+ const attrs = ctx.dataAttrs?.(type, dataLabel);
46
+ const id = typeof attrs?.["id"] === "string" ? attrs["id"] : ctx.importId(`data.${type}.${dataLabel}`);
47
+ const byId = id === undefined ? undefined : ctx.foreignTableRefsById?.get(id);
48
+ if (byId !== undefined)
49
+ return byId.tableRefName;
50
+ const matches = [...(ctx.foreignTableRefsById?.values() ?? [])].filter((candidate) => candidate.name === name);
51
+ return matches.length === 1 ? matches[0].tableRefName : undefined;
52
+ })();
51
53
  if (refName === undefined) {
52
54
  ctx.diagnostics.push(`${where}: table datasource ${name} cannot be resolved to the org catalog; skipped`);
53
55
  return undefined;
@@ -60,7 +62,7 @@ function datasourceFromTf(value, appLabel, appRefName, ctx, where) {
60
62
  if (table !== undefined)
61
63
  return { kind: "table", refName: table.tableRefName, name: table.name, local: false, tfLabel: table.tableRefName };
62
64
  }
63
- ctx.diagnostics.push(`${where}: datasource_id is not a typed app, element, or table reference; skipped`);
65
+ ctx.diagnostics.push(`${where}: datasource_id is not a typed app, element, task, or table reference; skipped`);
64
66
  return undefined;
65
67
  }
66
68
  function indexedField(value) {
@@ -72,8 +74,8 @@ function indexedField(value) {
72
74
  return { label: value.label, name: index.index, data: value.$expr === "data-attr" };
73
75
  }
74
76
  function fieldFromTf(value, datasource, ctx, where) {
75
- if (value !== undefined && (datasource.kind === "app" || datasource.kind === "element")) {
76
- const refName = fieldKeyFromTfValue(value, datasource.refName, datasource.tfLabel, datasource.kind, ctx);
77
+ if (value !== undefined && (datasource.kind === "app" || datasource.kind === "element" || datasource.kind === "task")) {
78
+ const refName = fieldKeyFromTfValue(value, datasource.refName, datasource.tfLabel, datasource.kind === "task" ? "app" : datasource.kind, ctx);
77
79
  if (refName !== undefined)
78
80
  return { kind: "field", parentKind: datasource.kind, parentRefName: datasource.refName, refName };
79
81
  }
@@ -108,7 +110,12 @@ function fieldFromTf(value, datasource, ctx, where) {
108
110
  const id = typeof attrs?.["id"] === "string"
109
111
  ? attrs["id"]
110
112
  : ctx.importId(`data.elementum_field.${dataLabel}`);
113
+ const fromDataAddr = ctx.foreignFieldRefsByDataAddress?.get(`data.elementum_field.${dataLabel}`)
114
+ ?? ctx.foreignFieldRefsByDataAddress?.get(`elementum_field.${dataLabel}`);
111
115
  let resolved = id === undefined ? undefined : ctx.foreignFieldRefsById?.get(id);
116
+ if (resolved === undefined && fromDataAddr !== undefined) {
117
+ resolved = { ownerRefName: fromDataAddr.ownerRefName, fieldKey: fromDataAddr.fieldKey, fieldName: fromDataAddr.fieldName };
118
+ }
112
119
  if (resolved === undefined && name !== undefined) {
113
120
  const matches = [...(ctx.foreignFieldRefsById?.values() ?? [])].filter((candidate) => candidate.ownerRefName === datasource.refName && candidate.fieldName === name);
114
121
  if (matches.length === 1)
@@ -9,14 +9,14 @@ const APP_RESOURCE_TYPE = "elementum_app";
9
9
  const TABLE_RESOURCE_TYPE = "elementum_table";
10
10
  function datasourceId(ref, opts, where) {
11
11
  if (ref?.refName === undefined || ref.refName === "" || ref.__kind === undefined) {
12
- throw new EntityTfError(`${where}: datasource must be a typed app, element, or table ref`);
12
+ throw new EntityTfError(`${where}: datasource must be a typed app, element, task, or table ref`);
13
13
  }
14
- if (ref.__kind !== "app" && ref.__kind !== "element" && ref.__kind !== "table") {
14
+ if (ref.__kind !== "app" && ref.__kind !== "element" && ref.__kind !== "table" && ref.__kind !== "task") {
15
15
  throw new EntityTfError(`${where}: unsupported datasource kind ${JSON.stringify(ref.__kind)}`);
16
16
  }
17
17
  const local = opts.workspaceAspects?.get(workspaceAspectKey(ref.__kind, ref.refName));
18
18
  if (local !== undefined) {
19
- const type = ref.__kind === "app" ? APP_RESOURCE_TYPE : ref.__kind === "element" ? "elementum_element" : TABLE_RESOURCE_TYPE;
19
+ const type = ref.__kind === "app" ? APP_RESOURCE_TYPE : ref.__kind === "element" ? "elementum_element" : ref.__kind === "task" ? "elementum_task" : TABLE_RESOURCE_TYPE;
20
20
  return { ref, id: expr.resourceAttr(type, local.tfLabel, ["id"]), tfLabel: local.tfLabel, local: true };
21
21
  }
22
22
  const name = ref.name ?? ref.refName;
@@ -25,9 +25,11 @@ function datasourceId(ref, opts, where) {
25
25
  opts.orgRefs.foreignApp(label, name);
26
26
  else if (ref.__kind === "element")
27
27
  opts.orgRefs.foreignElement(label, name);
28
+ else if (ref.__kind === "task")
29
+ opts.orgRefs.rawLookup("elementum_task", label, name);
28
30
  else
29
31
  opts.orgRefs.rawLookup(TABLE_RESOURCE_TYPE, label, name);
30
- const type = ref.__kind === "app" ? APP_RESOURCE_TYPE : ref.__kind === "element" ? "elementum_element" : TABLE_RESOURCE_TYPE;
32
+ const type = ref.__kind === "app" ? APP_RESOURCE_TYPE : ref.__kind === "element" ? "elementum_element" : ref.__kind === "task" ? "elementum_task" : TABLE_RESOURCE_TYPE;
31
33
  return { ref, id: expr.dataAttr(type, label, ["id"]), tfLabel: label, local: false };
32
34
  }
33
35
  function fieldId(ref, datasource, opts, where) {
@@ -46,7 +48,7 @@ function fieldId(ref, datasource, opts, where) {
46
48
  throw new EntityTfError(`${where}: expected a field or table-column ref`);
47
49
  if (datasource.ref.__kind === "table")
48
50
  throw new EntityTfError(`${where}: app/element fields cannot belong to a table datasource`);
49
- if (datasource.local) {
51
+ if (datasource.local && datasource.ref.__kind !== "task") {
50
52
  const scope = datasource.ref.__kind === "element" ? "element" : "app";
51
53
  const direct = fieldRefToTfValue(ref.fieldType ?? "", ref.refName, datasource.tfLabel, scope);
52
54
  if (direct !== undefined)
@@ -79,7 +79,7 @@ function dashboardWidgetsFromTf(blocks, dashboardLabel, owner, ctx) {
79
79
  }
80
80
  return [{ ...style, type: "records", target,
81
81
  ...(aspect["filter"] !== undefined && {
82
- filter: filterFromTf(filterWireToTf(decodeJson(aspect["filter"])), { ...owner, ownerRefName: owner.ownerRefName ?? owner.ownerTfLabel, foreignFieldRefsById: ctx.foreignFieldRefsById }, `${where}.aspect_widget.filter`),
82
+ filter: filterFromTf(filterWireToTf(decodeJson(aspect["filter"])), { ...owner, ownerRefName: owner.ownerRefName ?? owner.ownerTfLabel, foreignFieldRefsById: ctx.foreignFieldRefsById }, `${where}.aspect_widget.filter`, ctx),
83
83
  }),
84
84
  }];
85
85
  });
@@ -52,6 +52,7 @@ export function dashboardsToTf(dashboards, opts) {
52
52
  if (widget.filter !== undefined) {
53
53
  const hclFilter = filterToTf(widget.filter, `${where}.filter`, {
54
54
  ownerTfLabel: opts.ownerTfLabel,
55
+ appRefName: opts.ownerRefName,
55
56
  scope: opts.scope,
56
57
  objectId: opts.ownerId,
57
58
  diagnostics: opts.diagnostics,
@@ -222,8 +222,9 @@ function dependency(value, owner, ctx, where) {
222
222
  }
223
223
  function fieldKey(value, owner, ctx, where) {
224
224
  const key = fieldKeyFromTfRef(value, owner.ownerTfLabel, "app");
225
- if (key === undefined)
226
- ctx.diagnostics.push(`${where}: field reference is not resolvable; dropped`);
225
+ if (key === undefined) {
226
+ ctx.diagnostics.push(`${where}: field reference ${JSON.stringify(value)} is not resolvable; dropped`);
227
+ }
227
228
  return key;
228
229
  }
229
230
  function stageKey(value, owner) {
@@ -6,13 +6,12 @@ import { type DisplayBlock } from "../app/display-blocks.js";
6
6
  import type { AppRelationship } from "../relationship/build.js";
7
7
  import type { AppRole } from "../role/build.js";
8
8
  import type { AppWidget } from "../widget/build.js";
9
+ import { type ElementSystemFieldKey } from "./system-fields.js";
9
10
  export type { AppCalendarView, AppCategory, AppDashboard, AppDashboardView, AppField, AppKanbanView, AppLayout, AppListView, AppRecordCreateForm, AppRecordCreateFormSection, AppSystemFieldOverride, PicklistOption } from "../app/build.js";
10
11
  export type { AppRelationship, AppRelationshipColumn } from "../relationship/build.js";
11
12
  export type { AppWidget, CreateRecordWidget, LinkRecordsWidget, RelatedRecordsWidget, RunAutomationWidget, RunAutomationWidgetParameter, WidgetButtonStyle, WidgetButtonType } from "../widget/build.js";
12
- /** The system fields elements actually have (per `locals.ts`) — unlike apps, no status/stage/audit fields. */
13
- export type ElementSystemFieldKey = "id" | "title";
14
- export declare const ELEMENT_SYSTEM_FIELD_KEYS: readonly ElementSystemFieldKey[];
15
- /** Overrides for an element's platform-owned `id`/`title` fields — see `AppSystemFields` for the full rationale. */
13
+ export { ELEMENT_SYSTEM_FIELD_KEYS, type ElementSystemFieldKey } from "./system-fields.js";
14
+ /** Overrides for the two required element system fields; optional audit fields remain platform-owned. */
16
15
  export interface ElementSystemFields {
17
16
  readonly id?: AppSystemFieldOverride;
18
17
  readonly title?: AppSystemFieldOverride;
@@ -60,9 +59,9 @@ export interface ElementV2Options<F extends Record<string, AppField> = Record<st
60
59
  /** Fields keyed by ref name. At least one required by the compose API. */
61
60
  readonly fields: F;
62
61
  /**
63
- * Overrides for the platform's auto-provisioned `id`/`title` fields — the
64
- * only two system fields an element has (per `locals.ts`, unlike an app's
65
- * fuller set). Omit entirely to keep the deploy defaults.
62
+ * Overrides for the platform's auto-provisioned `id`/`title` fields.
63
+ * Audit fields may be referenced when matching platform-tagged fields exist,
64
+ * but they are not authored through this option.
66
65
  */
67
66
  readonly systemFields?: ElementSystemFields;
68
67
  /**
@@ -134,10 +133,14 @@ export interface ElementV2Options<F extends Record<string, AppField> = Record<st
134
133
  /** Custom roles keyed by stable authoring name. */
135
134
  readonly roles?: Readonly<Record<string, AppRole>>;
136
135
  }
137
- /** `id`/`title`'s platform field type — `id` is `HANDLE`, `title` is `TEXT`, same as an app's (`SYSTEM_FIELD_TAG_TO_TYPE`). */
136
+ /** Platform field type for each supported element system-field role. */
138
137
  type ElementSystemFieldTypeByKey = {
139
138
  readonly id: "HANDLE";
140
139
  readonly title: "TEXT";
140
+ readonly createdAt: "DATETIME";
141
+ readonly createdBy: "USER";
142
+ readonly updatedAt: "DATETIME";
143
+ readonly updatedBy: "USER";
141
144
  };
142
145
  /**
143
146
  * Per-element-system-field `FieldRef`s, each carrying its own literal
@@ -2,7 +2,9 @@ import { slimTokens } from "../../catalog/index.js";
2
2
  import { DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES, SYSTEM_FIELD_REQUIRED, SYSTEM_FIELD_TAG_BY_KEY } from "../../core/system-fields.js";
3
3
  import { assertNoSystemKeyCollision, picklistOptionLabels, serializeField, } from "../app/build.js";
4
4
  import { serializeDisplayBlocks } from "../app/display-blocks.js";
5
- export const ELEMENT_SYSTEM_FIELD_KEYS = ["id", "title"];
5
+ import { ELEMENT_SYSTEM_FIELD_KEYS } from "./system-fields.js";
6
+ export { ELEMENT_SYSTEM_FIELD_KEYS } from "./system-fields.js";
7
+ const ELEMENT_OVERRIDEABLE_SYSTEM_FIELD_KEYS = ["id", "title"];
6
8
  /**
7
9
  * Client-side validation for `element` — the authoring-time home for
8
10
  * element validation rules, so a malformed definition fails at define time
@@ -24,11 +26,11 @@ function validateElementOptions(opts) {
24
26
  throw new Error(`element "${opts.name}": namespace "${opts.namespace}" must be lowercase letters only (a–z).`);
25
27
  }
26
28
  }
27
- /** Serialize authored `systemFields` overrides into compose entries — mirrors `serializeSystemFields` in `app/build.ts`, scoped to id/title (no picklist branch needed). */
29
+ /** Serialize authored id/title overrides; optional audit fields remain platform-owned. */
28
30
  function serializeElementSystemFields(overrides) {
29
31
  if (overrides === undefined)
30
32
  return [];
31
- return ELEMENT_SYSTEM_FIELD_KEYS.filter((key) => overrides[key] !== undefined).map((key) => {
33
+ return ELEMENT_OVERRIDEABLE_SYSTEM_FIELD_KEYS.filter((key) => overrides[key] !== undefined).map((key) => {
32
34
  const tag = SYSTEM_FIELD_TAG_BY_KEY[key];
33
35
  const override = overrides[key];
34
36
  const field = {
@@ -78,7 +80,7 @@ export function element(opts) {
78
80
  if (fields[key] !== undefined)
79
81
  continue;
80
82
  const tag = SYSTEM_FIELD_TAG_BY_KEY[key];
81
- const override = opts.systemFields?.[key];
83
+ const override = key === "id" || key === "title" ? opts.systemFields?.[key] : undefined;
82
84
  fields[key] = {
83
85
  __kind: "field",
84
86
  refName: key,
@@ -86,7 +88,14 @@ export function element(opts) {
86
88
  parent: refName,
87
89
  parentKind: "element",
88
90
  parentName: opts.name,
89
- fieldType: key === "id" ? "HANDLE" : "TEXT",
91
+ fieldType: {
92
+ id: "HANDLE",
93
+ title: "TEXT",
94
+ createdAt: "DATETIME",
95
+ createdBy: "USER",
96
+ updatedAt: "DATETIME",
97
+ updatedBy: "USER",
98
+ }[key],
90
99
  tags: [tag],
91
100
  };
92
101
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Element locals.tf contribution — ei emits only title/id system lookups
3
- * for `elementum_element` (no status/stage maps).
2
+ * Element locals.tf contribution for identity and optional audit fields.
3
+ * Elements do not expose app-only status/stage fields.
4
4
  */
5
5
  import { type TfValue } from "../../engine/tf/index.js";
6
6
  /** Append one element's system lookup locals, keyed by its namespace (= tfLabel). */
@@ -1,6 +1,6 @@
1
1
  /**
2
- * Element locals.tf contribution — ei emits only title/id system lookups
3
- * for `elementum_element` (no status/stage maps).
2
+ * Element locals.tf contribution for identity and optional audit fields.
3
+ * Elements do not expose app-only status/stage fields.
4
4
  */
5
5
  import { expr } from "../../engine/tf/index.js";
6
6
  import { ELEMENT_RESOURCE_TYPE } from "./module.js";
@@ -9,4 +9,8 @@ export function appendElementLocals(attrs, ns) {
9
9
  const element = (path) => expr.resourceAttr(ELEMENT_RESOURCE_TYPE, ns, [path]);
10
10
  attrs[`${ns}_title_field_id`] = element("title_field_id");
11
11
  attrs[`${ns}_id_field_id`] = element("id_field_id");
12
+ attrs[`${ns}_created_at_field_id`] = element("created_at_field_id");
13
+ attrs[`${ns}_created_by_field_id`] = element("created_by_field_id");
14
+ attrs[`${ns}_updated_at_field_id`] = element("updated_at_field_id");
15
+ attrs[`${ns}_updated_by_field_id`] = element("updated_by_field_id");
12
16
  }
@@ -0,0 +1,4 @@
1
+ /** System-field roles EDK can reference when those tagged fields exist on an element. */
2
+ export declare const ELEMENT_AUDIT_SYSTEM_FIELD_KEYS: readonly ["createdAt", "createdBy", "updatedAt", "updatedBy"];
3
+ export declare const ELEMENT_SYSTEM_FIELD_KEYS: readonly ["id", "title", "createdAt", "createdBy", "updatedAt", "updatedBy"];
4
+ export type ElementSystemFieldKey = typeof ELEMENT_SYSTEM_FIELD_KEYS[number];
@@ -0,0 +1,12 @@
1
+ /** System-field roles EDK can reference when those tagged fields exist on an element. */
2
+ export const ELEMENT_AUDIT_SYSTEM_FIELD_KEYS = [
3
+ "createdAt",
4
+ "createdBy",
5
+ "updatedAt",
6
+ "updatedBy",
7
+ ];
8
+ export const ELEMENT_SYSTEM_FIELD_KEYS = [
9
+ "id",
10
+ "title",
11
+ ...ELEMENT_AUDIT_SYSTEM_FIELD_KEYS,
12
+ ];
@@ -261,6 +261,7 @@ export function elementToTf(entity, ctx) {
261
261
  for (const [index, entry] of (payload.accessPolicies ?? []).entries()) {
262
262
  const { block } = accessPolicyToTf(entry, index, {
263
263
  ownerTfLabel: ctx.appTfLabel,
264
+ ownerRefName: ctx.appRefName,
264
265
  scope: "element",
265
266
  objectId,
266
267
  orgRefs: ctx.orgRefs,
@@ -18,7 +18,7 @@
18
18
  * AppField is accepted.
19
19
  */
20
20
  import type { AppField, AppPicklistConfig, PicklistOption } from "../app/build.js";
21
- import type { AppOrElementRef, FieldRef } from "../../catalog/index.js";
21
+ import type { AppOrElementOrTaskRef, AppOrElementRef, FieldRef } from "../../catalog/index.js";
22
22
  import type { AppFieldOfExprType, CalculationInclude, Expr, ExprContext, ExprType, ExprTypeOf, FieldRefOfExprType } from "./calc/types.js";
23
23
  import type { UnsafePlatformId } from "../../core/platform-id.js";
24
24
  import type { AspectFieldQrFormat, AspectNumericFieldFormat } from "../../../elementum-entity-client/clients/aspects/models/format.js";
@@ -151,7 +151,7 @@ export interface TextFieldOptions extends BaseFieldOptions {
151
151
  * workspace needs that.
152
152
  */
153
153
  export interface RelationFieldOptions extends BaseFieldOptions {
154
- readonly relatedObject: AppOrElementRef | UnsafePlatformId;
154
+ readonly relatedObject: AppOrElementOrTaskRef | UnsafePlatformId;
155
155
  readonly relatedLabelField: FieldRef | UnsafePlatformId;
156
156
  /**
157
157
  * Defaults to `true` on the platform. Selecting a related record creates an
@@ -14,6 +14,8 @@ import { __pulledExpression } from "../app/deserializer/pulled-expression.js";
14
14
  import { optionsFromTf } from "./options.js";
15
15
  import { isCalculationResultType } from "./calculation-types.js";
16
16
  import { KNOWN_FIELD_ATTRS, SUB_TYPE_BY_RESOURCE } from "./types.js";
17
+ import { ELEMENT_AUDIT_SYSTEM_FIELD_KEYS } from "../element/system-fields.js";
18
+ const ELEMENT_AUDIT_SYSTEM_FIELD_KEY_SET = new Set(ELEMENT_AUDIT_SYSTEM_FIELD_KEYS);
17
19
  /**
18
20
  * A related_object_id/related_label_field_id value → its raw platform id, if
19
21
  * recoverable: a literal string as-is, or a `<type>.<label>.id` resource
@@ -80,6 +82,14 @@ function resolveRelatedObject(v, ctx) {
80
82
  ctx.unresolvedForeignRefs?.elements.add(name);
81
83
  return undefined;
82
84
  }
85
+ if (v.type === "elementum_task") {
86
+ const attrs = ctx.dataAttrs?.("elementum_task", v.label);
87
+ const namespace = typeof attrs?.namespace === "string" ? attrs.namespace : undefined;
88
+ const name = ctx.dataName("elementum_task", v.label) ?? (typeof attrs?.name === "string" ? attrs.name : undefined);
89
+ const refName = namespace !== undefined ? ctx.foreignTaskRefNamespaces?.get(namespace) : name !== undefined ? ctx.foreignTaskRefNames?.get(name) : undefined;
90
+ const finalRefName = refName ?? tfLabelToTsLabel(v.label);
91
+ return { __kind: "task", refName: finalRefName, name: name ?? finalRefName, ...(namespace !== undefined ? { namespace } : {}) };
92
+ }
83
93
  return undefined;
84
94
  }
85
95
  function resolveRelatedField(v, ctx) {
@@ -88,7 +98,31 @@ function resolveRelatedField(v, ctx) {
88
98
  return raw;
89
99
  if (v === undefined || !isTfExpr(v) || v.$expr !== "data-attr" || v.path.join(".") !== "id")
90
100
  return undefined;
91
- return ctx.foreignFieldRefsByDataAddress?.get(`${v.type}.${v.label}`);
101
+ const fromMap = ctx.foreignFieldRefsByDataAddress?.get(`${v.type}.${v.label}`);
102
+ if (fromMap !== undefined)
103
+ return fromMap;
104
+ if (v.type === "elementum_field") {
105
+ const attrs = ctx.dataAttrs?.("elementum_field", v.label);
106
+ const objectId = attrs?.["object_id"];
107
+ if (objectId !== undefined && isTfExpr(objectId) && objectId.$expr === "data-attr" && objectId.type === "elementum_task") {
108
+ const taskAttrs = ctx.dataAttrs?.("elementum_task", objectId.label);
109
+ const taskName = ctx.dataName("elementum_task", objectId.label) ?? (typeof taskAttrs?.name === "string" ? taskAttrs.name : objectId.label);
110
+ const taskNamespace = typeof taskAttrs?.namespace === "string" ? taskAttrs.namespace : undefined;
111
+ const taskRefName = (taskNamespace !== undefined ? ctx.foreignTaskRefNamespaces?.get(taskNamespace) : undefined) ?? (taskName !== undefined ? ctx.foreignTaskRefNames?.get(taskName) : undefined) ?? tfLabelToTsLabel(objectId.label);
112
+ const fieldName = typeof attrs?.name === "string" ? attrs.name : undefined;
113
+ const strippedKey = fieldKeyFromForeignDataLabel(v.label, { key: taskRefName, name: taskName, kind: "task" });
114
+ const fieldKey = strippedKey ?? tfLabelToTsLabel(v.label);
115
+ return {
116
+ ownerRefName: taskRefName,
117
+ ownerKind: "task",
118
+ ownerName: taskName,
119
+ ...(taskNamespace !== undefined ? { ownerNamespace: taskNamespace } : {}),
120
+ fieldKey,
121
+ ...(fieldName !== undefined ? { fieldName } : {}),
122
+ };
123
+ }
124
+ }
125
+ return undefined;
92
126
  }
93
127
  /**
94
128
  * A dynamic picklist filter's field reference → `RefExpr`. Every field a
@@ -172,7 +206,39 @@ function dynamicConfigFromTf(value, owner, ctx, where) {
172
206
  if (attrs["sort"] !== undefined) {
173
207
  const sortValue = attrs["sort"];
174
208
  if (isTfExpr(sortValue) && sortValue.$expr === "jsonencode" && typeof sortValue.value === "object" && sortValue.value !== null && !Array.isArray(sortValue.value)) {
175
- sort = sortValue.value;
209
+ const rawSort = sortValue.value;
210
+ const rawOrders = rawSort["orders"];
211
+ // Only rewrite the known `orders` shape. Other sort payloads have
212
+ // historically been opaque pass-through values and may be valid for
213
+ // platform configurations that this EDK version does not understand.
214
+ if (!Array.isArray(rawOrders)) {
215
+ sort = rawSort;
216
+ }
217
+ else {
218
+ let unresolvedField = false;
219
+ const orders = rawOrders.map((rawOrder) => {
220
+ if (typeof rawOrder !== "object" || rawOrder === null || Array.isArray(rawOrder) || isTfExpr(rawOrder)) {
221
+ unresolvedField = true;
222
+ return rawOrder;
223
+ }
224
+ const order = rawOrder;
225
+ const field = order["field"];
226
+ if (field === undefined) {
227
+ unresolvedField = true;
228
+ return rawOrder;
229
+ }
230
+ const resolved = resolveRelatedField(field, ctx);
231
+ if (resolved === undefined)
232
+ unresolvedField = true;
233
+ return resolved === undefined ? rawOrder : { ...order, field: resolved };
234
+ });
235
+ if (unresolvedField) {
236
+ ctx.diagnostics.push(`${where}: dynamic_config.sort has an unresolved order field; dropped sort`);
237
+ }
238
+ else {
239
+ sort = { ...rawSort, orders };
240
+ }
241
+ }
176
242
  }
177
243
  else {
178
244
  ctx.diagnostics.push(`${where}: dynamic_config.sort is not a jsonencode(...) object; dropped`);
@@ -508,6 +574,18 @@ export function fieldKeyFromTfValue(v, ownerRefName, ownerTfLabel, scope, ctx) {
508
574
  const stateRef = ctx.foreignFieldRefsById?.get(v);
509
575
  return stateRef?.ownerRefName === ownerRefName ? stateRef.fieldKey : undefined;
510
576
  }
577
+ if (isTfExpr(v) &&
578
+ v.$expr === "data-attr" &&
579
+ v.type === "elementum_field" &&
580
+ v.path.length === 1 &&
581
+ v.path[0] === "id") {
582
+ const prefix = `${ownerTfLabel}_`;
583
+ if (v.label.startsWith(prefix)) {
584
+ const key = tfLabelToTsLabel(v.label.slice(prefix.length));
585
+ if (scope === "element" && ELEMENT_AUDIT_SYSTEM_FIELD_KEY_SET.has(key))
586
+ return key;
587
+ }
588
+ }
511
589
  return fieldKeyFromTfRef(v, ownerTfLabel, scope);
512
590
  }
513
591
  /**
@@ -559,8 +637,8 @@ function fieldTypeFromRegistry(ctx, ownerRefName, fieldKey) {
559
637
  }
560
638
  /** Strip ei's owner-display prefix from a `data.elementum_field` label. */
561
639
  export function fieldKeyFromForeignDataLabel(dataLabel, target) {
562
- const kind = target.kind === "element" || target.kind === "app" ? target.kind : undefined;
563
- const ownerType = kind === "element" ? "elementum_element" : kind === "app" ? "elementum_app" : undefined;
640
+ const kind = target.kind === "element" || target.kind === "app" || target.kind === "task" ? target.kind : undefined;
641
+ const ownerType = kind === "element" ? "elementum_element" : kind === "app" ? "elementum_app" : kind === "task" ? "elementum_task" : undefined;
564
642
  const slugs = [
565
643
  target.name !== undefined && target.name !== "" ? sanitizeName(target.name) : undefined,
566
644
  target.namespace,
@@ -26,7 +26,7 @@ interface FieldTokenWire {
26
26
  readonly name?: string;
27
27
  readonly parent?: string;
28
28
  readonly parentNamespace?: string;
29
- readonly parentKind?: "app" | "element";
29
+ readonly parentKind?: "app" | "element" | "task";
30
30
  readonly parentName?: string;
31
31
  readonly fieldType?: string;
32
32
  }
@@ -86,11 +86,11 @@ function resolveRelatedObject(token, opts, where) {
86
86
  return { value: token };
87
87
  }
88
88
  const refName = token.refName ?? "";
89
- const kind = token.__kind === "element" ? "element" : "app";
89
+ const kind = token.__kind === "element" ? "element" : token.__kind === "task" ? "task" : "app";
90
90
  if (kind === (opts.scope ?? "app") && refName === opts.appRefName) {
91
91
  return { value: opts.objectId, refName, kind, target: { kind: opts.scope ?? "app", tfLabel: opts.ownerTfLabel } };
92
92
  }
93
- const sibling = opts.workspaceAspects?.get(workspaceAspectKey(kind, refName));
93
+ const sibling = kind !== "task" ? opts.workspaceAspects?.get(workspaceAspectKey(kind, refName)) : undefined;
94
94
  if (sibling !== undefined) {
95
95
  const resourceType = kind === "element" ? "elementum_element" : "elementum_app";
96
96
  return { value: expr.resourceAttr(resourceType, sibling.tfLabel, ["id"]), refName, kind, target: sibling };
@@ -111,6 +111,12 @@ function resolveRelatedObject(token, opts, where) {
111
111
  opts.diagnostics.push(`${where}: foreign element ${JSON.stringify(name)} has no namespace; using less-stable name lookup`);
112
112
  return { value: expr.dataAttr("elementum_element", tfLabel, ["id"]), refName, kind, foreignTfLabel: tfLabel };
113
113
  }
114
+ if (kind === "task") {
115
+ opts.orgRefs.foreignTask(tfLabel, name, token.namespace);
116
+ if (token.namespace === undefined)
117
+ opts.diagnostics.push(`${where}: foreign task ${JSON.stringify(name)} has no namespace; using less-stable name lookup`);
118
+ return { value: expr.dataAttr("elementum_task", tfLabel, ["id"]), refName, kind, foreignTfLabel: tfLabel };
119
+ }
114
120
  opts.orgRefs.foreignApp(tfLabel, name, token.namespace);
115
121
  if (token.namespace === undefined)
116
122
  opts.diagnostics.push(`${where}: foreign app ${JSON.stringify(name)} has no namespace; using less-stable name lookup`);
@@ -154,7 +160,7 @@ function resolveFieldOnObject(token, object, opts, where, attrName = "relatedLab
154
160
  opts.diagnostics.push(`${where}: ${attrName} token "${refName}" belongs to "${token.parent}", not the resolved target "${object.refName}"; dropped`);
155
161
  return undefined;
156
162
  }
157
- if (object.target !== undefined) {
163
+ if (object.target !== undefined && object.target.kind !== "task") {
158
164
  // A field belongs to an app or element; a table exposes columns, not fields.
159
165
  // Guard rather than widen fieldRefToTfValue's scope parameter.
160
166
  if (object.target.kind === "table") {
@@ -177,7 +183,7 @@ function resolveFieldOnObject(token, object, opts, where, attrName = "relatedLab
177
183
  // display name. Re-deriving it from the public refName produces a second,
178
184
  // semantically identical data block when (for example) a relationship and
179
185
  // a dynamic Dropdown both reference the same foreign field.
180
- const ownerType = object.kind === "element" ? "elementum_element" : object.kind === "app" ? "elementum_app" : undefined;
186
+ const ownerType = object.kind === "element" ? "elementum_element" : object.kind === "app" ? "elementum_app" : object.kind === "task" ? "elementum_task" : undefined;
181
187
  const parentLabel = object.foreignTfLabel ?? (token.parent !== undefined ? tsLabelToTfLabel(token.parent) : "related");
182
188
  const tfLabel = ownerType === undefined
183
189
  ? sanitizeName(`${parentLabel}_${name}`)
@@ -211,6 +217,7 @@ function stageOrgRefs(real) {
211
217
  foreignSkill: (tfLabel, name, appId) => pending.push(() => real.foreignSkill(tfLabel, name, appId)),
212
218
  rawLookup: (type, tfLabel, value, extraAttrs) => pending.push(() => real.rawLookup(type, tfLabel, value, extraAttrs)),
213
219
  foreignApp: (tfLabel, name, namespace) => pending.push(() => real.foreignApp(tfLabel, name, namespace)),
220
+ foreignTask: (tfLabel, name, namespace) => pending.push(() => real.foreignTask(tfLabel, name, namespace)),
214
221
  foreignElement: (tfLabel, name, namespace) => pending.push(() => real.foreignElement(tfLabel, name, namespace)),
215
222
  foreignField: (type, tfLabel, objectId, name) => pending.push(() => real.foreignField(type, tfLabel, objectId, name)),
216
223
  };
@@ -47,8 +47,9 @@ function sectionFromTf(raw, index, formWhere, owner, ctx) {
47
47
  const fields = [];
48
48
  for (const fieldId of fieldIds) {
49
49
  const key = fieldKeyFromTfValue(fieldId, tfLabelToTsLabel(owner.label), owner.ownerTfLabel, owner.scope, ctx);
50
- if (key === undefined)
51
- ctx.diagnostics.push(`${where}: a field_ids entry is not a known field reference; dropped`);
50
+ if (key === undefined) {
51
+ ctx.diagnostics.push(`${where}: field_ids entry ${JSON.stringify(fieldId)} is not a known field reference; dropped`);
52
+ }
52
53
  else
53
54
  fields.push(key);
54
55
  }
@@ -67,7 +67,7 @@ function relationshipFromTf(block, owner, ctx) {
67
67
  // (row-level filtering keyed off the owner's own field - the
68
68
  // existing, already-tested case) - try that first so existing
69
69
  // behavior is unchanged.
70
- filter = filterFromTf(block.attrs["filter"], ownerFilterOwner, `${where}.filter`);
70
+ filter = filterFromTf(block.attrs["filter"], ownerFilterOwner, `${where}.filter`, ctx);
71
71
  }
72
72
  catch (ownerErr) {
73
73
  // ... but it can equally reference a field on the TARGET (e.g. a
@@ -89,7 +89,7 @@ function relationshipFromTf(block, owner, ctx) {
89
89
  try {
90
90
  if (targetFilterOwner === undefined)
91
91
  throw ownerErr;
92
- filter = filterFromTf(block.attrs["filter"], targetFilterOwner, `${where}.filter`);
92
+ filter = filterFromTf(block.attrs["filter"], targetFilterOwner, `${where}.filter`, ctx);
93
93
  }
94
94
  catch (targetErr) {
95
95
  // Never let one unreconstructable filter reference crash the whole
@@ -116,13 +116,14 @@ function targetRef(value, owner, ctx) {
116
116
  ["elementum_app", "app"],
117
117
  ["elementum_element", "element"],
118
118
  ["elementum_table", "table"],
119
+ ["elementum_task", "task"],
119
120
  ]) {
120
121
  const resourceLabel = resourceRefLabel(value, type);
121
122
  if (resourceLabel !== undefined)
122
123
  return { kind, key: tfLabelToTsLabel(resourceLabel), name: tfLabelToTsLabel(resourceLabel), tfLabel: resourceLabel, managed: true };
123
124
  const dataLabel = dataRefLabel(value, type);
124
125
  if (dataLabel !== undefined) {
125
- if (kind === "app" || kind === "element") {
126
+ if (kind === "app" || kind === "element" || kind === "task") {
126
127
  return { kind, tfLabel: dataLabel, managed: false, ...resolveDataAspectTarget(ctx, kind, dataLabel) };
127
128
  }
128
129
  const name = ctx.dataName(type, dataLabel) ?? tfLabelToTsLabel(dataLabel);
@@ -134,14 +135,16 @@ function targetRef(value, owner, ctx) {
134
135
  function relatedFieldRef(value, target, ctx) {
135
136
  if (value === undefined)
136
137
  return undefined;
137
- if (isTfExpr(value) && value.$expr === "resource-attr" && value.path.length === 1 && value.path[0] === "id") {
138
+ if (isTfExpr(value) && (value.$expr === "resource-attr" || value.$expr === "data-attr") && value.path.length === 1 && value.path[0] === "id") {
138
139
  const targetType = target.kind === "app"
139
140
  ? "elementum_app"
140
141
  : target.kind === "element"
141
142
  ? "elementum_element"
142
143
  : target.kind === "table"
143
144
  ? "elementum_table"
144
- : undefined;
145
+ : target.kind === "task"
146
+ ? "elementum_task"
147
+ : undefined;
145
148
  if (value.type === RELATIONSHIP_RESOURCE_TYPE || value.type === targetType) {
146
149
  return { kind: "recordIdentity", key: "id", name: "Record ID", target };
147
150
  }
@@ -44,6 +44,7 @@ export function relationshipsToTf(relationships, opts) {
44
44
  if (relationship.filter !== undefined) {
45
45
  attrs["filter"] = filterToTf(relationship.filter, `${where}.filter`, {
46
46
  ownerTfLabel: opts.ownerTfLabel,
47
+ appRefName: opts.ownerRefName,
47
48
  scope: opts.scope,
48
49
  objectId: opts.objectId,
49
50
  orgRefs: opts.orgRefs,
@@ -91,7 +92,9 @@ function resolveTarget(value, where, opts) {
91
92
  ? "element"
92
93
  : value?.__kind === "table"
93
94
  ? "table"
94
- : "app";
95
+ : value?.__kind === "task"
96
+ ? "task"
97
+ : "app";
95
98
  const refName = value?.refName ?? "";
96
99
  if (kind === opts.scope && refName === opts.ownerRefName) {
97
100
  return {
@@ -106,7 +109,11 @@ function resolveTarget(value, where, opts) {
106
109
  const sibling = opts.workspaceAspects?.get(workspaceAspectKey(kind, refName));
107
110
  if (sibling !== undefined) {
108
111
  return {
109
- value: expr.resourceAttr(kind === "app" ? "elementum_app" : "elementum_element", sibling.tfLabel, ["id"]),
112
+ value: expr.resourceAttr(kind === "app"
113
+ ? "elementum_app"
114
+ : kind === "element"
115
+ ? "elementum_element"
116
+ : "elementum_task", sibling.tfLabel, ["id"]),
110
117
  kind,
111
118
  refName,
112
119
  tfLabel: sibling.tfLabel,
@@ -159,6 +166,7 @@ function resolveRelatedField(value, target, where, opts) {
159
166
  }
160
167
  if (target.managed &&
161
168
  target.kind !== "table" &&
169
+ target.kind !== "task" &&
162
170
  target.tfLabel !== undefined) {
163
171
  const direct = fieldRefToTfValue(value?.fieldType ?? "", refName, target.tfLabel, target.kind);
164
172
  if (direct !== undefined)
@@ -169,7 +177,9 @@ function resolveRelatedField(value, target, where, opts) {
169
177
  ? "elementum_app"
170
178
  : target.kind === "element"
171
179
  ? "elementum_element"
172
- : "elementum_table";
180
+ : target.kind === "task"
181
+ ? "elementum_task"
182
+ : "elementum_table";
173
183
  const label = sanitizeName(`${targetResourceType}_${target.tfLabel ?? target.refName}_${name}`);
174
184
  opts.orgRefs.foreignField("elementum_field", label, target.value, name);
175
185
  return expr.dataAttr("elementum_field", label, ["id"]);