@elementumai/edk 0.9.15 → 0.9.17

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 (86) 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/engine/build/context.d.ts +2 -2
  4. package/dist-sdk/src/engine/progress.d.ts +4 -0
  5. package/dist-sdk/src/engine/progress.js +16 -4
  6. package/dist-sdk/src/engine/pull/context.d.ts +5 -0
  7. package/dist-sdk/src/engine/pull/ref-only.d.ts +4 -0
  8. package/dist-sdk/src/engine/pull/ref-only.js +11 -0
  9. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +1 -1
  10. package/dist-sdk/src/entities/access-policy/from-tf.js +47 -12
  11. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +5 -3
  12. package/dist-sdk/src/entities/access-policy/to-tf.js +23 -1
  13. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +27 -2
  14. package/dist-sdk/src/entities/agent/from-tf.d.ts +1 -0
  15. package/dist-sdk/src/entities/agent/from-tf.js +18 -3
  16. package/dist-sdk/src/entities/agent/to-tf.js +14 -0
  17. package/dist-sdk/src/entities/agent/tools.d.ts +79 -2
  18. package/dist-sdk/src/entities/agent/tools.js +2 -1
  19. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +11 -0
  20. package/dist-sdk/src/entities/agent-tool/from-tf.js +45 -3
  21. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +7 -0
  22. package/dist-sdk/src/entities/agent-tool/to-tf.js +72 -20
  23. package/dist-sdk/src/entities/app/module.js +8 -0
  24. package/dist-sdk/src/entities/app/to-tf.js +1 -0
  25. package/dist-sdk/src/entities/automation/build.d.ts +12 -5
  26. package/dist-sdk/src/entities/automation/build.js +30 -11
  27. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +4 -0
  28. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +108 -23
  29. package/dist-sdk/src/entities/automation/from-tf.d.ts +73 -5
  30. package/dist-sdk/src/entities/automation/from-tf.js +270 -30
  31. package/dist-sdk/src/entities/automation/index.d.ts +2 -1
  32. package/dist-sdk/src/entities/automation/index.js +2 -1
  33. package/dist-sdk/src/entities/automation/module.js +6 -7
  34. package/dist-sdk/src/entities/automation/output-field-types.d.ts +5 -0
  35. package/dist-sdk/src/entities/automation/output-field-types.js +12 -0
  36. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +20 -0
  37. package/dist-sdk/src/entities/automation/output-key-wire-name.js +22 -0
  38. package/dist-sdk/src/entities/automation/script-code.js +13 -4
  39. package/dist-sdk/src/entities/automation/tasks.d.ts +61 -5
  40. package/dist-sdk/src/entities/automation/tasks.js +42 -9
  41. package/dist-sdk/src/entities/automation/to-tf.d.ts +0 -2
  42. package/dist-sdk/src/entities/automation/to-tf.js +85 -36
  43. package/dist-sdk/src/entities/automation/triggers.d.ts +5 -2
  44. package/dist-sdk/src/entities/automation/types.d.ts +2 -0
  45. package/dist-sdk/src/entities/automation/types.js +5 -0
  46. package/dist-sdk/src/entities/automation/workflow-output.d.ts +35 -0
  47. package/dist-sdk/src/entities/automation/workflow-output.js +53 -0
  48. package/dist-sdk/src/entities/dashboard/from-tf.js +1 -1
  49. package/dist-sdk/src/entities/dashboard/to-tf.js +1 -0
  50. package/dist-sdk/src/entities/element/build.d.ts +11 -8
  51. package/dist-sdk/src/entities/element/build.js +14 -5
  52. package/dist-sdk/src/entities/element/locals.d.ts +2 -2
  53. package/dist-sdk/src/entities/element/locals.js +6 -2
  54. package/dist-sdk/src/entities/element/system-fields.d.ts +4 -0
  55. package/dist-sdk/src/entities/element/system-fields.js +12 -0
  56. package/dist-sdk/src/entities/element/to-tf.js +1 -0
  57. package/dist-sdk/src/entities/field/from-tf.js +47 -1
  58. package/dist-sdk/src/entities/relationship/from-tf.js +2 -2
  59. package/dist-sdk/src/entities/relationship/to-tf.js +1 -0
  60. package/dist-sdk/src/entities/search-table/from-tf.js +6 -6
  61. package/dist-sdk/src/entities/search-table/module.js +2 -2
  62. package/dist-sdk/src/entities/search-table/types.d.ts +1 -0
  63. package/dist-sdk/src/entities/search-table/types.js +1 -0
  64. package/dist-sdk/src/entities/shared/filters/ast.d.ts +2 -0
  65. package/dist-sdk/src/entities/shared/filters/index.d.ts +12 -2
  66. package/dist-sdk/src/entities/shared/filters/index.js +17 -1
  67. package/dist-sdk/src/entities/shared/filters/print.js +25 -11
  68. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +1 -1
  69. package/dist-sdk/src/entities/shared/filters/tf-codec.js +39 -7
  70. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +18 -2
  71. package/dist-sdk/src/entities/skill/module.js +9 -0
  72. package/dist-sdk/src/entities/skill/to-tf.js +18 -0
  73. package/dist-sdk/src/entities/skill/tools.d.ts +18 -4
  74. package/dist-sdk/src/entities/skill/tools.js +1 -1
  75. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +12 -0
  76. package/dist-sdk/src/entities/skill-tool/from-tf.js +58 -3
  77. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +6 -0
  78. package/dist-sdk/src/entities/skill-tool/to-tf.js +78 -43
  79. package/dist-sdk/src/entities/view/from-tf.js +30 -9
  80. package/dist-sdk/src/entities/view/to-tf.js +18 -10
  81. package/dist-sdk/src/entities/widget/from-tf.js +1 -1
  82. package/dist-sdk/src/entities/widget/to-tf.js +1 -0
  83. package/dist-sdk/src/graph/index.d.ts +13 -0
  84. package/dist-sdk/src/graph/index.js +5 -0
  85. package/dist-sdk/src/graph/types.d.ts +10 -0
  86. package/package.json +2 -1
@@ -131,3 +131,8 @@ export const AUTOMATION_TASK_TYPE_SET = new Set(AUTOMATION_TASK_TYPES);
131
131
  */
132
132
  export const ALL_AUTOMATION_TASK_TYPE_SET = new Set(TASK_SUB_TYPES.map((t) => t.resourceType));
133
133
  export const AUTOMATION_BRANCH_TYPE_SET = new Set(AUTOMATION_BRANCH_TYPES);
134
+ /** Whether an exported address belongs to an automation composite. */
135
+ export function isAutomationResourceAddress(address) {
136
+ const separator = address.indexOf(".");
137
+ return separator > 0 && ALL_AUTOMATION_RESOURCE_TYPES.includes(address.slice(0, separator));
138
+ }
@@ -0,0 +1,35 @@
1
+ import type { Ref } from "../shared/ref.js";
2
+ /** Product-shaped output types an automation may publish for downstream use. */
3
+ export declare const workflowOutputType: {
4
+ readonly text: "text";
5
+ readonly number: "number";
6
+ readonly decimal: "decimal";
7
+ readonly boolean: "boolean";
8
+ readonly date: "date";
9
+ readonly datetime: "datetime";
10
+ readonly json: "json";
11
+ readonly object: "object";
12
+ readonly record: "record";
13
+ readonly tableRecord: "tableRecord";
14
+ };
15
+ export type WorkflowOutputType = (typeof workflowOutputType)[keyof typeof workflowOutputType];
16
+ export interface WorkflowOutputDeclaration<Value extends Ref<unknown> = Ref<unknown>, Type extends WorkflowOutputType = WorkflowOutputType, Multiple extends boolean = boolean> {
17
+ /** @internal */
18
+ readonly __kind: "workflowOutput";
19
+ readonly value: Value;
20
+ readonly type: Type;
21
+ readonly multiple: Multiple;
22
+ }
23
+ /**
24
+ * Explicitly type one published automation output when its reference alone
25
+ * cannot reproduce the metadata stored by the platform. The value must be a
26
+ * task or trigger reference; variable and template references do not carry
27
+ * this metadata in the workflow HCL contract.
28
+ */
29
+ export declare function workflowOutput<const Value extends Ref<unknown>, const Type extends WorkflowOutputType, const Multiple extends boolean>(value: Value, options: {
30
+ readonly type: Type;
31
+ readonly multiple: Multiple;
32
+ }): WorkflowOutputDeclaration<Value, Type, Multiple>;
33
+ export declare function isWorkflowOutputDeclaration(value: unknown): value is WorkflowOutputDeclaration;
34
+ export declare function workflowOutputFieldType(type: WorkflowOutputType): string;
35
+ export declare function workflowOutputTypeFromFieldType(fieldType: string): WorkflowOutputType | undefined;
@@ -0,0 +1,53 @@
1
+ /** Product-shaped output types an automation may publish for downstream use. */
2
+ export const workflowOutputType = {
3
+ text: "text",
4
+ number: "number",
5
+ decimal: "decimal",
6
+ boolean: "boolean",
7
+ date: "date",
8
+ datetime: "datetime",
9
+ json: "json",
10
+ object: "object",
11
+ record: "record",
12
+ tableRecord: "tableRecord",
13
+ };
14
+ /**
15
+ * Explicitly type one published automation output when its reference alone
16
+ * cannot reproduce the metadata stored by the platform. The value must be a
17
+ * task or trigger reference; variable and template references do not carry
18
+ * this metadata in the workflow HCL contract.
19
+ */
20
+ export function workflowOutput(value, options) {
21
+ return {
22
+ __kind: "workflowOutput",
23
+ value,
24
+ type: options.type,
25
+ multiple: options.multiple,
26
+ };
27
+ }
28
+ export function isWorkflowOutputDeclaration(value) {
29
+ return typeof value === "object" && value !== null &&
30
+ value.__kind === "workflowOutput";
31
+ }
32
+ const WORKFLOW_OUTPUT_FIELD_TYPE = {
33
+ text: "TEXT",
34
+ number: "NUMBER",
35
+ decimal: "DECIMAL",
36
+ boolean: "BOOLEAN",
37
+ date: "DATE",
38
+ datetime: "DATETIME",
39
+ json: "JSON",
40
+ object: "OBJECT",
41
+ record: "ASPECT_RECORD_ID",
42
+ tableRecord: "TABLE_RECORD",
43
+ };
44
+ export function workflowOutputFieldType(type) {
45
+ return WORKFLOW_OUTPUT_FIELD_TYPE[type];
46
+ }
47
+ const FIELD_TYPE_TO_WORKFLOW_OUTPUT = new Map(Object.entries(WORKFLOW_OUTPUT_FIELD_TYPE).map(([type, fieldType]) => [
48
+ fieldType,
49
+ type,
50
+ ]));
51
+ export function workflowOutputTypeFromFieldType(fieldType) {
52
+ return FIELD_TYPE_TO_WORKFLOW_OUTPUT.get(fieldType);
53
+ }
@@ -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,
@@ -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,
@@ -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
@@ -204,7 +206,39 @@ function dynamicConfigFromTf(value, owner, ctx, where) {
204
206
  if (attrs["sort"] !== undefined) {
205
207
  const sortValue = attrs["sort"];
206
208
  if (isTfExpr(sortValue) && sortValue.$expr === "jsonencode" && typeof sortValue.value === "object" && sortValue.value !== null && !Array.isArray(sortValue.value)) {
207
- 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
+ }
208
242
  }
209
243
  else {
210
244
  ctx.diagnostics.push(`${where}: dynamic_config.sort is not a jsonencode(...) object; dropped`);
@@ -540,6 +574,18 @@ export function fieldKeyFromTfValue(v, ownerRefName, ownerTfLabel, scope, ctx) {
540
574
  const stateRef = ctx.foreignFieldRefsById?.get(v);
541
575
  return stateRef?.ownerRefName === ownerRefName ? stateRef.fieldKey : undefined;
542
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
+ }
543
589
  return fieldKeyFromTfRef(v, ownerTfLabel, scope);
544
590
  }
545
591
  /**
@@ -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
@@ -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,
@@ -1,7 +1,7 @@
1
1
  import { EntityTfError } from "../../engine/entity.js";
2
2
  import { resourceRefLabel } from "../../engine/pull/context.js";
3
3
  import { isTfExpr, sanitizeName, scopedLabelToBagKey, tfLabelToTsLabel, } from "../../engine/tf/index.js";
4
- import { fieldKeyFromTfRef } from "../field/from-tf.js";
4
+ import { fieldKeyFromTfValue } from "../field/from-tf.js";
5
5
  import { KNOWN_SEARCH_TABLE_ATTRS, SEARCH_TABLE_VARIANT_BY_RESOURCE } from "./types.js";
6
6
  import { connectorIdentityFromTf } from "../shared/connector-from-tf.js";
7
7
  function requiredString(attrs, key, where) {
@@ -17,10 +17,10 @@ function assertKnown(block, variant) {
17
17
  }
18
18
  }
19
19
  }
20
- function fieldKey(value, ownerTfLabel, scope, where) {
20
+ function fieldKey(value, ownerRefName, ownerTfLabel, scope, ctx, where) {
21
21
  if (value === undefined)
22
22
  throw new EntityTfError(`${where}: field reference is required`);
23
- const key = fieldKeyFromTfRef(value, ownerTfLabel, scope);
23
+ const key = fieldKeyFromTfValue(value, ownerRefName, ownerTfLabel, scope, ctx);
24
24
  if (key === undefined)
25
25
  throw new EntityTfError(`${where}: field value is not a field resource reference`);
26
26
  return key;
@@ -105,10 +105,10 @@ export function searchTableFromTf(block, ownerTfLabel, scope, ctx) {
105
105
  kind: "snowflake",
106
106
  refName,
107
107
  ...(typeof block.attrs["name"] === "string" && { name: block.attrs["name"] }),
108
- fieldKey: fieldKey(block.attrs["field_id"], ownerTfLabel, aspectScope, where),
109
- attributeFieldKeys: rawAttributes.map((value) => fieldKey(value, ownerTfLabel, aspectScope, where)),
108
+ fieldKey: fieldKey(block.attrs["field_id"], tfLabelToTsLabel(ownerTfLabel), ownerTfLabel, aspectScope, ctx, where),
109
+ attributeFieldKeys: rawAttributes.map((value) => fieldKey(value, tfLabelToTsLabel(ownerTfLabel), ownerTfLabel, aspectScope, ctx, where)),
110
110
  ...(rawTextIndexFields !== undefined && {
111
- textIndexFieldKeys: rawTextIndexFields.map((value) => fieldKey(value, ownerTfLabel, aspectScope, where)),
111
+ textIndexFieldKeys: rawTextIndexFields.map((value) => fieldKey(value, tfLabelToTsLabel(ownerTfLabel), ownerTfLabel, aspectScope, ctx, where)),
112
112
  }),
113
113
  connectorKey: connectorKey(block.attrs["ai_provider_connector_id"], ctx, where),
114
114
  duration: duration,
@@ -7,7 +7,7 @@ import { EntityTfError } from "../../engine/entity.js";
7
7
  import { searchTableFromTf } from "./from-tf.js";
8
8
  import { printSearchTable } from "./printer.js";
9
9
  import { searchTableToTf } from "./to-tf.js";
10
- import { SEARCH_TABLE_RESOURCE_TYPES } from "./types.js";
10
+ import { SEARCH_TABLE_DATA_SOURCE_TYPE, SEARCH_TABLE_RESOURCE_TYPES } from "./types.js";
11
11
  function isConfigured(value) {
12
12
  return (typeof value === "object" &&
13
13
  value !== null &&
@@ -89,7 +89,7 @@ export const searchTableModule = {
89
89
  },
90
90
  data: {
91
91
  participates: true,
92
- resourceType: "elementum_search_table",
92
+ resourceType: SEARCH_TABLE_DATA_SOURCE_TYPE,
93
93
  lookupAttr: "name",
94
94
  referencedByBuild: true,
95
95
  },
@@ -3,6 +3,7 @@ export declare const SEARCH_TABLE_RESOURCE_TYPES: {
3
3
  readonly linked: "elementum_linked_ai_search_table";
4
4
  readonly table: "elementum_table_search_table";
5
5
  };
6
+ export declare const SEARCH_TABLE_DATA_SOURCE_TYPE: "elementum_search_table";
6
7
  export type SearchTableResourceVariant = keyof typeof SEARCH_TABLE_RESOURCE_TYPES;
7
8
  export declare const SEARCH_TABLE_VARIANT_BY_RESOURCE: Map<string, "snowflake" | "table" | "linked">;
8
9
  export declare const KNOWN_SEARCH_TABLE_ATTRS: Readonly<Record<"snowflake" | "linked" | "table", ReadonlySet<string>>>;
@@ -3,6 +3,7 @@ export const SEARCH_TABLE_RESOURCE_TYPES = {
3
3
  linked: "elementum_linked_ai_search_table",
4
4
  table: "elementum_table_search_table",
5
5
  };
6
+ export const SEARCH_TABLE_DATA_SOURCE_TYPE = "elementum_search_table";
6
7
  export const SEARCH_TABLE_VARIANT_BY_RESOURCE = new Map(Object.entries(SEARCH_TABLE_RESOURCE_TYPES).map(([variant, resource]) => [resource, variant]));
7
8
  export const KNOWN_SEARCH_TABLE_ATTRS = {
8
9
  snowflake: new Set([
@@ -210,6 +210,8 @@ export type RefExpr =
210
210
  kind: "taskRef";
211
211
  task: string;
212
212
  path: readonly string[];
213
+ /** Pulled task-reference envelope names an execute-script output absent from its schema. */
214
+ undeclaredScriptOutput?: true;
213
215
  }
214
216
  /** Reference to a trigger input: `ctx.trigger.<path...>`. */
215
217
  | {
@@ -49,13 +49,23 @@ export interface CurrentUserFilterValue {
49
49
  readonly valueType: "ID" | "EMAIL" | "DOMAIN";
50
50
  }
51
51
  export declare function currentUser(valueType?: "ID" | "EMAIL" | "DOMAIN"): CurrentUserFilterValue;
52
+ /** A field used as an explicit comparison operand, preserving its identity. */
53
+ export interface FieldLeftValue {
54
+ readonly type: "FIELD";
55
+ readonly value: FilterField;
56
+ readonly aspect?: never;
57
+ readonly treatNullAsEquals?: true;
58
+ }
59
+ export declare function fieldValue(value: FilterField): FieldLeftValue;
52
60
  export declare function fieldValue(value: FilterField, options?: {
53
61
  readonly aspect?: string;
54
62
  readonly treatNullAsEquals?: boolean;
55
- }): FilterValue<FilterField, FilterReferenceValue>;
63
+ }): Extract<FilterValue<FilterField, FilterReferenceValue>, {
64
+ type: "FIELD";
65
+ }>;
56
66
  type AuthoredFilterValue = FilterValue<FilterField, FilterReferenceValue>;
57
67
  export type FilterInput = string | number | boolean | null | Ref<unknown> | FilterReferenceInput | FilterField | CurrentUserFilterValue | AuthoredFilterValue;
58
- export type LeftRef = FilterField | Ref<unknown> | FilterReferenceInput;
68
+ export type LeftRef = FilterField | Ref<unknown> | FilterReferenceInput | FieldLeftValue;
59
69
  export declare const UNRESOLVED_REFERENCE_MARKER = "__edkUnresolvedReference::";
60
70
  export declare function refDataToFilterReference(data: import("../ref.js").RefData): FilterReference;
61
71
  export declare function toFilterValue(input: FilterInput, valueType?: ValueType): FilterValue<FilterField, FilterReferenceValue>;
@@ -78,13 +78,17 @@ export function isFilterReferenceInput(value) {
78
78
  export function currentUser(valueType = "ID") {
79
79
  return { __kind: "currentUser", valueType };
80
80
  }
81
+ // Retain authoring-only type/options without adding them to the wire value.
82
+ const FIELD_VALUE_SOURCE = Symbol("FieldValueSource");
81
83
  export function fieldValue(value, options) {
82
- return {
84
+ const operand = {
83
85
  type: "FIELD",
84
86
  value: fieldWireValue(value),
85
87
  ...(options?.aspect !== undefined && { aspect: options.aspect }),
86
88
  ...(options?.treatNullAsEquals !== undefined && { treatNullAsEquals: options.treatNullAsEquals }),
87
89
  };
90
+ Object.defineProperty(operand, FIELD_VALUE_SOURCE, { value });
91
+ return operand;
88
92
  }
89
93
  export const UNRESOLVED_REFERENCE_MARKER = "__edkUnresolvedReference::";
90
94
  export function refDataToFilterReference(data) {
@@ -130,7 +134,15 @@ function fieldWireValue(field) {
130
134
  return field.value;
131
135
  return isAppField(field) ? field.id : field;
132
136
  }
137
+ function isFieldLeftValue(value) {
138
+ return typeof value === "object" && value !== null && "type" in value && value.type === "FIELD";
139
+ }
140
+ function sourceField(left) {
141
+ return left[FIELD_VALUE_SOURCE] ?? left.value;
142
+ }
133
143
  function leftType(left, fallback, explicit) {
144
+ if (isFieldLeftValue(left))
145
+ return leftType(sourceField(left), fallback, explicit);
134
146
  if (explicit !== undefined)
135
147
  return explicit;
136
148
  if (isFilterReferenceInput(left))
@@ -140,6 +152,8 @@ function leftType(left, fallback, explicit) {
140
152
  return fieldTypeToValueType(isAppField(left) ? left.type : "fieldType" in left ? left.fieldType : undefined);
141
153
  }
142
154
  function leftDescriptor(left, fallback, explicit) {
155
+ if (isFieldLeftValue(left))
156
+ return { leftValue: left };
143
157
  if (isFilterReferenceInput(left))
144
158
  return { leftValue: toFilterValue(left) };
145
159
  if (isRef(left))
@@ -150,6 +164,8 @@ function leftDescriptor(left, fallback, explicit) {
150
164
  return { field: fieldWireValue(left) };
151
165
  }
152
166
  function resolveStaticFieldValue(field, input) {
167
+ if (isFieldLeftValue(field))
168
+ return resolveStaticFieldValue(sourceField(field), input);
153
169
  if (isRef(input) || isFilterReferenceInput(input) || !isAppField(field))
154
170
  return input;
155
171
  return picklistStaticValueToApiId(field, input);
@@ -1,3 +1,4 @@
1
+ import { EntityTfError } from "../../../engine/entity.js";
1
2
  function defaultQuote(value) { return JSON.stringify(value); }
2
3
  /** Print every canonical filter through the same public `filter.*` authoring surface. */
3
4
  export function printFilter(filter, codec) {
@@ -7,11 +8,24 @@ export function printFilter(filter, codec) {
7
8
  codec.used?.(helper);
8
9
  return `${namespace}.${helper}(${args})`;
9
10
  };
10
- const value = (input) => printFilterValue(input, codec, call, quote);
11
+ const literals = "value" in filter ? [filter.value]
12
+ : "values" in filter ? filter.values
13
+ : "min" in filter ? [filter.min, filter.max] : [];
14
+ const uuidValues = literals.length > 0 && literals.every((literal) => literal.type === "UUID");
15
+ const explicitType = uuidValues ? `, ${quote("UUID")}` : "";
16
+ const value = (input) => input.type === "UUID"
17
+ ? uuidValues ? quote(input.value) : `{ type: "UUID", value: ${quote(input.value)} }`
18
+ : printFilterValue(input, codec, call, quote);
19
+ if ("leftValue" in filter && filter.leftValue?.type === "FIELD") {
20
+ const operand = filter.leftValue;
21
+ if ((operand.aspect != null && operand.aspect !== "") || (operand.treatNullAsEquals != null && operand.treatNullAsEquals !== true)) {
22
+ throw new EntityTfError("filter FIELD left operand cannot represent aspect or nondefault treatNullAsEquals");
23
+ }
24
+ }
11
25
  const left = "field" in filter && filter.field !== undefined
12
26
  ? codec.field(filter.field)
13
27
  : "leftValue" in filter && filter.leftValue !== undefined
14
- ? filter.leftValue.type === "FIELD" ? codec.field(filter.leftValue.value) : value(filter.leftValue)
28
+ ? filter.leftValue.type === "FIELD" ? call("fieldValue", codec.field(filter.leftValue.value)) : value(filter.leftValue)
15
29
  : "undefined /* TODO: filter has no left side */";
16
30
  const core = () => {
17
31
  switch (filter.type) {
@@ -19,19 +33,19 @@ export function printFilter(filter, codec) {
19
33
  case "FALSE": return call("whereFalse", "");
20
34
  case "AND": return call("and", filter.children.map((child) => printFilter(child, codec)).join(", "));
21
35
  case "OR": return call("or", filter.children.map((child) => printFilter(child, codec)).join(", "));
22
- case "EQUALS": return call(filter.not === true ? "neq" : "eq", `${left}, ${value(filter.value)}`);
23
- case "GREATER_THAN": return call("gt", `${left}, ${value(filter.value)}`);
24
- case "GREATER_THAN_EQUALS": return call("gte", `${left}, ${value(filter.value)}`);
25
- case "LESS_THAN": return call("lt", `${left}, ${value(filter.value)}`);
26
- case "LESS_THAN_EQUALS": return call("lte", `${left}, ${value(filter.value)}`);
27
- case "LIKE": return call("like", `${left}, ${value(filter.value)}${printLikeOptions(filter, quote)}`);
36
+ case "EQUALS": return call(filter.not === true ? "neq" : "eq", `${left}, ${value(filter.value)}${explicitType}`);
37
+ case "GREATER_THAN": return call("gt", `${left}, ${value(filter.value)}${explicitType}`);
38
+ case "GREATER_THAN_EQUALS": return call("gte", `${left}, ${value(filter.value)}${explicitType}`);
39
+ case "LESS_THAN": return call("lt", `${left}, ${value(filter.value)}${explicitType}`);
40
+ case "LESS_THAN_EQUALS": return call("lte", `${left}, ${value(filter.value)}${explicitType}`);
41
+ case "LIKE": return call("like", `${left}, ${value(filter.value)}${printLikeOptions(filter, quote) || (uuidValues ? ", undefined" : "")}${explicitType}`);
28
42
  case "IS_NULL": return call(filter.not === true ? "isNotNull" : "isNull", left);
29
- case "IN": return call(filter.not === true ? "isNotIn" : "isIn", `${left}, [${filter.values.map(value).join(", ")}]`);
30
- case "BETWEEN": return call("between", `${left}, ${value(filter.min)}, ${value(filter.max)}${filter.not === true ? ", { not: true }" : ""}`);
43
+ case "IN": return call(filter.not === true ? "isNotIn" : "isIn", `${left}, [${filter.values.map(value).join(", ")}]${explicitType}`);
44
+ case "BETWEEN": return call("between", `${left}, ${value(filter.min)}, ${value(filter.max)}${filter.not === true ? ", { not: true }" : uuidValues ? ", undefined" : ""}${explicitType}`);
31
45
  case "CONTAINS":
32
46
  case "OVERLAPS": {
33
47
  const helper = filter.type === "CONTAINS" ? "contains" : "overlaps";
34
- return call(helper, `${left}, [${filter.values.map(value).join(", ")}]${filter.not === true ? ", { not: true }" : ""}`);
48
+ return call(helper, `${left}, [${filter.values.map(value).join(", ")}]${filter.not === true ? ", { not: true }" : uuidValues ? ", undefined" : ""}${explicitType}`);
35
49
  }
36
50
  case "CURRENT_RANGE": {
37
51
  const options = [`unit: ${quote(filter.unit)}`];
@@ -103,7 +103,7 @@ export interface FilterToTfCodec {
103
103
  export interface FilterFromTfCodec<Field = string, ReferenceValue = never> {
104
104
  readonly field: (value: TfValue, fieldScope: "app" | "user") => Field;
105
105
  readonly aspect?: (value: TfValue) => Field;
106
- readonly reference: (value: TfValue) => ReferenceValue;
106
+ readonly reference: (value: TfValue, role: "left" | "value") => ReferenceValue;
107
107
  /**
108
108
  * A structured reference envelope can carry a more authoritative output
109
109
  * type than the provider's legacy outer `real_type` default. Consumers