@elementumai/edk 0.13.3 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/dist-sdk/src/catalog/factories.d.ts +4 -2
  2. package/dist-sdk/src/catalog/factories.js +3 -1
  3. package/dist-sdk/src/catalog/from-authoring.d.ts +8 -3
  4. package/dist-sdk/src/catalog/from-authoring.js +21 -8
  5. package/dist-sdk/src/engine/build/context.d.ts +17 -0
  6. package/dist-sdk/src/engine/coverage-gaps.d.ts +13 -0
  7. package/dist-sdk/src/engine/coverage-gaps.js +21 -0
  8. package/dist-sdk/src/engine/pull/context.d.ts +57 -1
  9. package/dist-sdk/src/engine/pull/context.js +9 -1
  10. package/dist-sdk/src/engine/pull/pulled-roots.d.ts +14 -1
  11. package/dist-sdk/src/engine/pull/pulled-roots.js +23 -3
  12. package/dist-sdk/src/engine/pull/ref-only.d.ts +6 -1
  13. package/dist-sdk/src/engine/pull/ref-only.js +4 -1
  14. package/dist-sdk/src/engine/pull/stream-root.d.ts +17 -1
  15. package/dist-sdk/src/engine/pull/stream-root.js +57 -4
  16. package/dist-sdk/src/engine/tf/index.d.ts +1 -0
  17. package/dist-sdk/src/engine/tf/index.js +1 -0
  18. package/dist-sdk/src/engine/tf/jsonencode.d.ts +19 -0
  19. package/dist-sdk/src/engine/tf/jsonencode.js +49 -0
  20. package/dist-sdk/src/engine/validation.d.ts +36 -1
  21. package/dist-sdk/src/engine/validation.js +56 -2
  22. package/dist-sdk/src/engine/workspace/loader.d.ts +6 -0
  23. package/dist-sdk/src/engine/workspace/loader.js +87 -2
  24. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +7 -0
  25. package/dist-sdk/src/entities/access-policy/from-tf.js +58 -17
  26. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +3 -1
  27. package/dist-sdk/src/entities/access-policy/to-tf.js +1 -1
  28. package/dist-sdk/src/entities/agent/build.d.ts +15 -0
  29. package/dist-sdk/src/entities/agent/build.js +139 -16
  30. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +3 -3
  31. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +39 -25
  32. package/dist-sdk/src/entities/agent/module.js +95 -3
  33. package/dist-sdk/src/entities/agent/to-tf.js +6 -4
  34. package/dist-sdk/src/entities/agent-evaluation/from-tf.d.ts +7 -0
  35. package/dist-sdk/src/entities/agent-evaluation/from-tf.js +14 -5
  36. package/dist-sdk/src/entities/agent-evaluation/module.js +4 -2
  37. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +11 -2
  38. package/dist-sdk/src/entities/agent-tool/from-tf.js +38 -40
  39. package/dist-sdk/src/entities/agent-tool/to-tf.js +12 -5
  40. package/dist-sdk/src/entities/app/build.d.ts +1 -1
  41. package/dist-sdk/src/entities/app/index.d.ts +1 -1
  42. package/dist-sdk/src/entities/automation/approval-trigger-refs.d.ts +20 -0
  43. package/dist-sdk/src/entities/automation/approval-trigger-refs.js +83 -0
  44. package/dist-sdk/src/entities/automation/build.d.ts +75 -42
  45. package/dist-sdk/src/entities/automation/build.js +18 -8
  46. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +14 -2
  47. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +9 -0
  48. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +64 -12
  49. package/dist-sdk/src/entities/automation/from-tf.d.ts +53 -0
  50. package/dist-sdk/src/entities/automation/from-tf.js +579 -106
  51. package/dist-sdk/src/entities/automation/index.d.ts +2 -2
  52. package/dist-sdk/src/entities/automation/index.js +1 -1
  53. package/dist-sdk/src/entities/automation/lookup-owner.d.ts +23 -0
  54. package/dist-sdk/src/entities/automation/lookup-owner.js +27 -0
  55. package/dist-sdk/src/entities/automation/module.js +265 -26
  56. package/dist-sdk/src/entities/automation/operators.d.ts +6 -2
  57. package/dist-sdk/src/entities/automation/operators.js +0 -2
  58. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +8 -0
  59. package/dist-sdk/src/entities/automation/task-output-labels.js +11 -0
  60. package/dist-sdk/src/entities/automation/tasks.d.ts +37 -2
  61. package/dist-sdk/src/entities/automation/tasks.js +38 -1
  62. package/dist-sdk/src/entities/automation/to-tf.d.ts +8 -0
  63. package/dist-sdk/src/entities/automation/to-tf.js +576 -52
  64. package/dist-sdk/src/entities/automation/triggers.d.ts +47 -1
  65. package/dist-sdk/src/entities/automation/unsafe-script-output.d.ts +10 -5
  66. package/dist-sdk/src/entities/automation/unsafe-script-output.js +10 -5
  67. package/dist-sdk/src/entities/chart/to-tf.js +18 -5
  68. package/dist-sdk/src/entities/dashboard/from-tf.js +45 -11
  69. package/dist-sdk/src/entities/dashboard-widget-order/order.d.ts +5 -3
  70. package/dist-sdk/src/entities/dashboard-widget-order/order.js +6 -4
  71. package/dist-sdk/src/entities/datamine/from-tf.js +10 -3
  72. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +38 -11
  73. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +35 -7
  74. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +101 -9
  75. package/dist-sdk/src/entities/element/build.d.ts +4 -1
  76. package/dist-sdk/src/entities/element/build.js +3 -4
  77. package/dist-sdk/src/entities/element/index.d.ts +1 -1
  78. package/dist-sdk/src/entities/field/from-tf.js +8 -1
  79. package/dist-sdk/src/entities/field/to-tf.d.ts +29 -2
  80. package/dist-sdk/src/entities/field/to-tf.js +106 -7
  81. package/dist-sdk/src/entities/phone-service/from-tf.d.ts +7 -0
  82. package/dist-sdk/src/entities/phone-service/from-tf.js +15 -7
  83. package/dist-sdk/src/entities/phone-service/module.js +4 -2
  84. package/dist-sdk/src/entities/portal/to-tf.d.ts +1 -1
  85. package/dist-sdk/src/entities/portal/to-tf.js +61 -2
  86. package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -1
  87. package/dist-sdk/src/entities/relationship/from-tf.js +34 -4
  88. package/dist-sdk/src/entities/relationship/to-tf.js +24 -6
  89. package/dist-sdk/src/entities/role/from-tf.js +3 -1
  90. package/dist-sdk/src/entities/search-table/from-tf.d.ts +3 -1
  91. package/dist-sdk/src/entities/search-table/from-tf.js +6 -3
  92. package/dist-sdk/src/entities/search-table/module.js +18 -2
  93. package/dist-sdk/src/entities/search-table/to-tf.js +10 -16
  94. package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +6 -1
  95. package/dist-sdk/src/entities/shared/filters/ast.d.ts +6 -0
  96. package/dist-sdk/src/entities/shared/filters/index.d.ts +21 -4
  97. package/dist-sdk/src/entities/shared/filters/index.js +27 -3
  98. package/dist-sdk/src/entities/shared/filters/print.js +23 -7
  99. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +24 -0
  100. package/dist-sdk/src/entities/shared/filters/tf-codec.js +98 -3
  101. package/dist-sdk/src/entities/shared/filters/types.d.ts +8 -1
  102. package/dist-sdk/src/entities/shared/run-automation-requirement.d.ts +15 -0
  103. package/dist-sdk/src/entities/shared/run-automation-requirement.js +28 -0
  104. package/dist-sdk/src/entities/shared/search-table-address.d.ts +17 -0
  105. package/dist-sdk/src/entities/shared/search-table-address.js +24 -0
  106. package/dist-sdk/src/entities/shared/skip-release.d.ts +49 -0
  107. package/dist-sdk/src/entities/shared/skip-release.js +74 -0
  108. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +3 -3
  109. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +11 -5
  110. package/dist-sdk/src/entities/skill/module.js +3 -25
  111. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +4 -2
  112. package/dist-sdk/src/entities/skill-tool/from-tf.js +28 -27
  113. package/dist-sdk/src/entities/skill-tool/to-tf.js +12 -5
  114. package/dist-sdk/src/entities/skill-tool/types.d.ts +1 -0
  115. package/dist-sdk/src/entities/skill-tool/types.js +2 -1
  116. package/dist-sdk/src/entities/table/catalog.d.ts +16 -0
  117. package/dist-sdk/src/entities/table/catalog.js +44 -2
  118. package/dist-sdk/src/entities/table/from-tf.js +30 -4
  119. package/dist-sdk/src/entities/table/keys.d.ts +27 -0
  120. package/dist-sdk/src/entities/table/keys.js +46 -0
  121. package/dist-sdk/src/entities/table/to-tf.js +2 -2
  122. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +12 -1
  123. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +9 -4
  124. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +215 -10
  125. package/dist-sdk/src/entities/view/agent-view-layout.d.ts +10 -4
  126. package/dist-sdk/src/entities/view/custom-view-runtime-rules.d.ts +43 -0
  127. package/dist-sdk/src/entities/view/custom-view-runtime-rules.js +285 -0
  128. package/dist-sdk/src/entities/view/custom-view-validate.d.ts +3 -1
  129. package/dist-sdk/src/entities/view/custom-view-validate.js +24 -5
  130. package/dist-sdk/src/entities/view/from-tf.js +14 -1
  131. package/dist-sdk/src/entities/widget/from-tf.js +14 -7
  132. package/dist-sdk/src/entities/widget/to-tf.js +9 -6
  133. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +4 -2
  134. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
  135. package/dist-sdk/src/graph/index.d.ts +14 -1
  136. package/dist-sdk/src/graph/index.js +2 -0
  137. package/dist-sdk/src/graph/resource-types.d.ts +2 -0
  138. package/dist-sdk/src/graph/resource-types.js +3 -0
  139. package/dist-sdk/src/graph/types.d.ts +105 -0
  140. package/package.json +1 -1
@@ -11,6 +11,7 @@
11
11
  import type { ApprovalChainRef, AppOrElementRef, DatamineRef, FieldRef } from "../../catalog/index.js";
12
12
  import type { UnsafePlatformId } from "../../core/platform-id.js";
13
13
  import type { RecordShape } from "../field/record-shape.js";
14
+ import type { CalculationTypedValue } from "../shared/ref.js";
14
15
  import { type InferTriggerType, type WithOnDemandTriggeredBy, type TriggerInputFieldDef, type TriggerInputSchema } from "../../core/triggers/on-demand.js";
15
16
  import type { OnDemandParamTypeAlias } from "../shared/types/field-types.js";
16
17
  import type { Filter } from "./filter.js";
@@ -153,8 +154,53 @@ export interface approvalProcessStatusUpdatedTriggerOptions<A extends AppOrEleme
153
154
  */
154
155
  readonly filter?: Filter | null;
155
156
  }
157
+ /**
158
+ * The user the platform records as having moved the approval process to the
159
+ * trigger's status (the web app's "Final Approval By"): the approver when a
160
+ * person decided, or the user who cancelled. When an approval process expires
161
+ * on its deadline nobody decided, so it doesn't name a decider. The bare
162
+ * `ctx.trigger.approver` reads the id.
163
+ */
164
+ export interface ApprovalProcessStatusUpdatedApprover {
165
+ readonly id: CalculationTypedValue<string, "user">;
166
+ readonly email: string;
167
+ readonly name: string;
168
+ }
169
+ /**
170
+ * What an approval process status trigger gives its steps (#2990): the
171
+ * record, plus who moved the approval process to the status, when, and the
172
+ * status and reason.
173
+ *
174
+ * An approval process with a deadline can expire with nobody acting. It then
175
+ * reports `"APPROVED"` or `"DENIED"` (by its expiration outcome), the same
176
+ * statuses a person's decision gives, but nobody decided, so `approver` is not
177
+ * a person who approved. Only `reason` tells the two apart: on expiry it is
178
+ * "Approval expired due to SLA breach". An expiry that cancels reports the
179
+ * same `"CANCELLED"` as a person cancelling.
180
+ */
181
+ export interface ApprovalProcessStatusUpdatedTriggerOutput<A extends AppOrElementRef = AppOrElementRef> {
182
+ readonly record: RecordShape<A>;
183
+ /** Who the platform records as moving the approval process to this status (the web app's "Final Approval By"); see the expiry note above. */
184
+ readonly approver: ApprovalProcessStatusUpdatedApprover;
185
+ /** When the approval process reached this status (date and time; the web app's "Final Approval At"). */
186
+ readonly approvalUpdatedAt: CalculationTypedValue<string, "datetime">;
187
+ /**
188
+ * The approval process's status, such as `"APPROVED"`. On a
189
+ * `"STEP_APPROVED"` trigger it is that step's own status (`"APPROVED"`),
190
+ * never `"STEP_APPROVED"`, and `approver` and `reason` are that step's
191
+ * decider and comment.
192
+ */
193
+ readonly status: approvalProcessStatusUpdatedStatus;
194
+ /**
195
+ * The approval process's reason: the comment given with a person's
196
+ * decision, the platform's message when it is cancelled, "Approval expired
197
+ * due to SLA breach" on expiry, or the reason an automation passed when it
198
+ * set the status.
199
+ */
200
+ readonly reason: string;
201
+ }
156
202
  /** Fires when an approval chain on a record changes to the configured status. */
157
- export declare function approvalProcessStatusUpdated<A extends AppOrElementRef>(opts: approvalProcessStatusUpdatedTriggerOptions<A>): TriggerChain<RecordTriggerOutput<A>>;
203
+ export declare function approvalProcessStatusUpdated<A extends AppOrElementRef>(opts: approvalProcessStatusUpdatedTriggerOptions<A>): TriggerChain<ApprovalProcessStatusUpdatedTriggerOutput<A>>;
158
204
  export interface AttachmentTriggerOptions<A extends AppOrElementRef = AppOrElementRef> {
159
205
  readonly app: A;
160
206
  /**
@@ -5,11 +5,16 @@ import { type Ref } from "../shared/ref.js";
5
5
  * an output, so the reference round-trips unchanged (#1725).
6
6
  *
7
7
  * The platform resolves only declared outputs, so at runtime this reads
8
- * nothing. Prefer adding the output to the script's `outputs` and reading
9
- * `ctx.actions.<script>.result.<output>`. Build rejects a plain undeclared
10
- * `result.<output>` in a filter, rejects this marker on an undeclared output in a task input, and
11
- * accepts it in filters, workflow outputs and field assignments. On an output
12
- * the script does declare, it builds the same reference as the plain read.
8
+ * nothing, and its publish check rejects the reference ("has a value
9
+ * reference that is no longer valid"): an automation that still uses it
10
+ * plans clean after pull, but any apply that republishes it fails until the
11
+ * script declares the output (#3050). Prefer adding the output to the
12
+ * script's `outputs` and reading `ctx.actions.<script>.result.<output>`.
13
+ * Build rejects a plain undeclared `result.<output>` in a filter, rejects
14
+ * this marker on an undeclared output in a task input, and accepts it in
15
+ * filters, workflow outputs and field assignments, so pulled automations
16
+ * round-trip. On an output the script does declare, it builds the same
17
+ * reference as the plain read.
13
18
  *
14
19
  * @example
15
20
  * ```ts
@@ -13,11 +13,16 @@ const UNSAFE_SCRIPT_OUTPUT_MARKER = "__edkUnsafeScriptOutput::";
13
13
  * an output, so the reference round-trips unchanged (#1725).
14
14
  *
15
15
  * The platform resolves only declared outputs, so at runtime this reads
16
- * nothing. Prefer adding the output to the script's `outputs` and reading
17
- * `ctx.actions.<script>.result.<output>`. Build rejects a plain undeclared
18
- * `result.<output>` in a filter, rejects this marker on an undeclared output in a task input, and
19
- * accepts it in filters, workflow outputs and field assignments. On an output
20
- * the script does declare, it builds the same reference as the plain read.
16
+ * nothing, and its publish check rejects the reference ("has a value
17
+ * reference that is no longer valid"): an automation that still uses it
18
+ * plans clean after pull, but any apply that republishes it fails until the
19
+ * script declares the output (#3050). Prefer adding the output to the
20
+ * script's `outputs` and reading `ctx.actions.<script>.result.<output>`.
21
+ * Build rejects a plain undeclared `result.<output>` in a filter, rejects
22
+ * this marker on an undeclared output in a task input, and accepts it in
23
+ * filters, workflow outputs and field assignments, so pulled automations
24
+ * round-trip. On an output the script does declare, it builds the same
25
+ * reference as the plain read.
21
26
  *
22
27
  * @example
23
28
  * ```ts
@@ -1,7 +1,7 @@
1
1
  import { workspaceAspectKey, } from "../../engine/build/context.js";
2
2
  import { EntityTfError } from "../../engine/entity.js";
3
3
  import { expr, sanitizeName, scopedResourceLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
4
- import { authoredFieldKeysFromPayload, fieldRefToTfValue, } from "../field/to-tf.js";
4
+ import { fieldRefToTfValue, siblingFieldOwnership, } from "../field/to-tf.js";
5
5
  import { filterToTf as serializeFilterToTf } from "../shared/filters/tf-codec.js";
6
6
  import { optionSelectionLiteral, optionsLocalName } from "../shared/filters/option-lookups.js";
7
7
  import { isUnsafePlatformId } from "../../core/platform-id.js";
@@ -26,7 +26,13 @@ function datasourceId(ref, opts, where) {
26
26
  id: expr.resourceAttr(type, local.tfLabel, ["id"]),
27
27
  tfLabel: local.tfLabel,
28
28
  local: true,
29
- fieldOwnership: authoredFieldKeysFromPayload(local.streamRootEntity?.payload),
29
+ // The address each field's own build gives it, whatever type the
30
+ // reference carries (#3088). Only app and element datasources need it:
31
+ // a table exposes columns, not fields, and `fieldId` resolves a field
32
+ // of a task datasource through a lookup, not the task's field resources.
33
+ fieldOwnership: kind === "app" || kind === "element"
34
+ ? siblingFieldOwnership(local.streamRootEntity?.payload, local.tfLabel, kind)
35
+ : undefined,
30
36
  };
31
37
  }
32
38
  const name = ref.name ?? ref.refName;
@@ -43,7 +49,12 @@ function datasourceId(ref, opts, where) {
43
49
  return { ref, kind, id: expr.dataAttr(type, label, ["id"]), tfLabel: label, local: false };
44
50
  }
45
51
  function fieldId(ref, datasource, opts, where) {
46
- if (ref?.refName === undefined || ref.refName === "")
52
+ if (ref === undefined) {
53
+ // Usually a catalog key the column's table or app no longer has, e.g. a
54
+ // chart pulled before its table's column keys changed (#3063).
55
+ throw new EntityTfError(`${where}: the field is undefined, so it names a catalog key its table or app does not have (pull the chart's app or dashboard again, or fix the key)`);
56
+ }
57
+ if (ref.refName === undefined || ref.refName === "")
47
58
  throw new EntityTfError(`${where}: field ref is missing its key`);
48
59
  if (ref.parent !== undefined && ref.parent !== datasource.ref.refName) {
49
60
  throw new EntityTfError(`${where}: field belongs to ${JSON.stringify(ref.parent)}, not datasource ${JSON.stringify(datasource.ref.refName)}`);
@@ -60,7 +71,7 @@ function fieldId(ref, datasource, opts, where) {
60
71
  throw new EntityTfError(`${where}: app/element fields cannot belong to a table datasource`);
61
72
  if (datasource.local && datasource.ref.__kind !== "task") {
62
73
  const scope = datasource.ref.__kind === "element" ? "element" : "app";
63
- const direct = fieldRefToTfValue(ref.fieldType ?? "", ref.refName, datasource.tfLabel, scope, datasource.fieldOwnership);
74
+ const direct = fieldRefToTfValue(ref.fieldType ?? "", ref.refName, datasource.tfLabel, scope, datasource.fieldOwnership, undefined, ref.name);
64
75
  if (direct !== undefined)
65
76
  return direct;
66
77
  }
@@ -70,7 +81,9 @@ function fieldId(ref, datasource, opts, where) {
70
81
  }
71
82
  function columnToTf(column, datasource, opts, where) {
72
83
  const out = {};
73
- if (column.field !== undefined)
84
+ // A `field` that is present but undefined is a stale catalog key, not an
85
+ // unbound column: dropping it would unbind the live chart column (#3063).
86
+ if (column.field !== undefined || Object.hasOwn(column, "field"))
74
87
  out["column_id"] = fieldId(column.field, datasource, opts, `${where}.field`);
75
88
  if (column.aggregation !== undefined)
76
89
  out["aggregation"] = column.aggregation;
@@ -12,6 +12,7 @@ import { chartRefNameFromTfLabel } from "../chart/from-tf.js";
12
12
  import { dashboardWidgetSize } from "./build.js";
13
13
  import { resolveDataAspectTarget } from "../shared/aspect-target-from-tf.js";
14
14
  import { managedViewSortFromTf } from "../view/from-tf.js";
15
+ import { skipAndRelease, unresolvedReferenceName } from "../shared/skip-release.js";
15
16
  const KNOWN_DASHBOARD_ATTRS = new Set(["name", "owner_id", "owner_type", "favorite", "tags"]);
16
17
  export function dashboardsFromTf(blocks, widgetBlocks, owner, ctx,
17
18
  /** `elementum_dashboard_widget_order` blocks; each orders its dashboard's widgets. */
@@ -67,8 +68,11 @@ function dashboardWidgetsFromTf(blocks, dashboardLabel, dashboardKey, owner, ctx
67
68
  const key = tfLabelToTsLabel(label.startsWith(`${dashboardLabel}_`) ? label.slice(dashboardLabel.length + 1) : label);
68
69
  const name = optionalString(block.attrs, "name", where, ctx) ?? "";
69
70
  const size = optionalString(block.attrs, "size", where, ctx) ?? "MEDIUM";
71
+ // A widget written to no source is also left out of adoption, or the
72
+ // next plan destroys it (edk#3166); skipAndRelease does both.
73
+ const address = `${DASHBOARD_WIDGET_RESOURCE_TYPE}.${label}`;
70
74
  if (!Object.values(dashboardWidgetSize).includes(size)) {
71
- ctx.diagnostics.push(`${where}.size: unsupported dashboard widget size ${JSON.stringify(size)}; skipped`);
75
+ skipAndRelease(ctx, address, { problem: `its size ${JSON.stringify(size)} is not a dashboard widget size` }, `${where}.size: unsupported dashboard widget size ${JSON.stringify(size)}; skipped`);
72
76
  return [];
73
77
  }
74
78
  const color = optionalString(block.attrs, "color", where, ctx);
@@ -77,7 +81,6 @@ function dashboardWidgetsFromTf(blocks, dashboardLabel, dashboardKey, owner, ctx
77
81
  const style = { key, name, size, ...(color !== undefined && { color }), ...(icon !== undefined && { icon }) };
78
82
  const chart = plainObject(block.attrs["chart_widget"]);
79
83
  if (chart !== undefined) {
80
- const address = `${DASHBOARD_WIDGET_RESOURCE_TYPE}.${label}`;
81
84
  const chartLabel = resourceRefLabel(chart["chart_id"], CHART_RESOURCE_TYPE);
82
85
  if (chartLabel === undefined) {
83
86
  // A raw chart id or a data.elementum_chart ref names no chart this
@@ -106,12 +109,14 @@ function dashboardWidgetsFromTf(blocks, dashboardLabel, dashboardKey, owner, ctx
106
109
  return [{ ...style, type: "chart", chartKey }];
107
110
  }
108
111
  if (aspect === undefined) {
109
- ctx.diagnostics.push(`${where}: expected an aspect_widget or chart_widget; skipped`);
112
+ skipAndRelease(ctx, address, { problem: "the export gives it neither an aspect_widget nor a chart_widget" }, `${where}: expected an aspect_widget or chart_widget; skipped`);
110
113
  return [];
111
114
  }
112
115
  const target = aspectRef(aspect["aspect_id"], owner, ctx);
113
116
  if (target === undefined) {
114
- ctx.diagnostics.push(`${where}.aspect_widget.aspect_id: unresolved; skipped`);
117
+ // For example a task-type app's records: a records widget has no
118
+ // target for it yet.
119
+ skipAndRelease(ctx, address, { reference: unresolvedReferenceName(aspect["aspect_id"], "aspect_id") }, `${where}.aspect_widget.aspect_id: unresolved; skipped`);
115
120
  return [];
116
121
  }
117
122
  // An unsupported sort is dropped on its own: skipping the widget would
@@ -142,26 +147,55 @@ function dashboardWidgetsFromTf(blocks, dashboardLabel, dashboardKey, owner, ctx
142
147
  /**
143
148
  * The order's import lists every chart and records widget of the dashboard,
144
149
  * but build lists only the widgets source holds. A widget this pull leaves out
145
- * would therefore plan a reorder no source edit asked for, so the order is
146
- * skipped and released with it. It runs after the widgets' own requirements,
147
- * so a chart widget skipped for its chart takes the order along. The next
148
- * plan imports the order for the widgets source holds (the kind's
149
- * stateAdoption), so it plans no change.
150
+ * would therefore plan a reorder no source edit asked for. The order stays in
151
+ * source and adoption without it: adoption drops it from the export's
152
+ * `widget_ids` and imports the order as `<owner id>:<dashboard id>:<ids of the
153
+ * widgets left in>`, which tracks only those widgets (the provider's tracked
154
+ * import, also used by the kind's stateAdoption), so the next plan shows no
155
+ * change. It runs after the widgets' own requirements, so a chart widget
156
+ * skipped for its chart is left out of the order too. With no widget left,
157
+ * build writes no order, so it is skipped and released.
150
158
  */
151
159
  function requireEveryWidget(order, widgetBlocks, written, dashboardLabel, ctx) {
152
160
  if (ctx.requiresExtracted === undefined)
153
161
  return;
154
162
  const address = `${DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE}.${order.label ?? ""}`;
155
163
  const writtenKeys = new Set(written.map((widget) => widget.key));
164
+ const listEntry = { attribute: "widget_ids", trackedWithout: (leftOut) => trackedOrderImport(order, address, leftOut, ctx) };
156
165
  for (const block of widgetBlocks) {
157
166
  const label = block.label ?? "";
158
167
  const key = tfLabelToTsLabel(label.startsWith(`${dashboardLabel}_`) ? label.slice(dashboardLabel.length + 1) : label);
159
168
  const requires = `${DASHBOARD_WIDGET_RESOURCE_TYPE}.${label}`;
160
169
  ctx.requiresExtracted.push(writtenKeys.has(key)
161
- ? { address, requires, prune: (root) => root }
162
- : { address, requires, unresolved: true, prune: (root) => root });
170
+ ? { address, requires, listEntry, prune: (root) => root }
171
+ : { address, requires, unresolved: true, listEntry, prune: (root) => root });
163
172
  }
164
173
  }
174
+ /**
175
+ * The order's tracked import without the `leftOut` widgets: its id and the
176
+ * widget ids it tracks, in the order's live widget order. Undefined when no
177
+ * widget is left or an id is unknown.
178
+ */
179
+ function trackedOrderImport(order, address, leftOut, ctx) {
180
+ const orderId = ctx.importId(address);
181
+ const widgetIds = order.attrs["widget_ids"];
182
+ if (orderId === undefined || orderId.split(":").length !== 2 || !Array.isArray(widgetIds))
183
+ return undefined;
184
+ const kept = [];
185
+ for (const value of widgetIds) {
186
+ const label = resourceRefLabel(value, DASHBOARD_WIDGET_RESOURCE_TYPE);
187
+ if (label === undefined)
188
+ return undefined;
189
+ const widget = `${DASHBOARD_WIDGET_RESOURCE_TYPE}.${label}`;
190
+ if (leftOut.has(widget))
191
+ continue;
192
+ const id = ctx.importId(widget)?.split(":").at(-1);
193
+ if (id === undefined || id === "")
194
+ return undefined;
195
+ kept.push(id);
196
+ }
197
+ return kept.length === 0 ? undefined : { importId: `${orderId}:${kept.join(",")}`, keptIds: kept };
198
+ }
165
199
  /**
166
200
  * The filter ranges over the target's records, so its fields may belong to
167
201
  * the target rather than to the dashboard's owner. A raw field id decodes
@@ -19,9 +19,11 @@ export declare function dashboardWidgetOrderFor(orderBlocks: readonly TfBlock[],
19
19
  export declare function inDashboardWidgetOrder(widgetBlocks: readonly TfBlock[], orderBlock: TfBlock | undefined): readonly TfBlock[];
20
20
  /**
21
21
  * A dashboard whose order has no state would plan a hidden create (a live
22
- * reorder): a workspace pulled before widget order was managed, or a pull that
23
- * left one of the dashboard's widgets out of source and released the order
24
- * with it. When the dashboard is in state but its order isn't, import the live
22
+ * reorder): a workspace pulled before widget order was managed, or by a pull
23
+ * that left one of the dashboard's widgets out of source and released the
24
+ * order with it (before #3071; a pull now adopts the order for the widgets
25
+ * source holds, the same import as below). When the dashboard is in state but
26
+ * its order isn't, import the live
25
27
  * order, keyed `<owner id>:<dashboard id>:<widget ids>` with the ids of the
26
28
  * widgets build lists that state already holds. The provider then tracks only
27
29
  * those widgets, so a widget source doesn't hold never shows as a change, and
@@ -54,9 +54,11 @@ export function inDashboardWidgetOrder(widgetBlocks, orderBlock) {
54
54
  }
55
55
  /**
56
56
  * A dashboard whose order has no state would plan a hidden create (a live
57
- * reorder): a workspace pulled before widget order was managed, or a pull that
58
- * left one of the dashboard's widgets out of source and released the order
59
- * with it. When the dashboard is in state but its order isn't, import the live
57
+ * reorder): a workspace pulled before widget order was managed, or by a pull
58
+ * that left one of the dashboard's widgets out of source and released the
59
+ * order with it (before #3071; a pull now adopts the order for the widgets
60
+ * source holds, the same import as below). When the dashboard is in state but
61
+ * its order isn't, import the live
60
62
  * order, keyed `<owner id>:<dashboard id>:<widget ids>` with the ids of the
61
63
  * widgets build lists that state already holds. The provider then tracks only
62
64
  * those widgets, so a widget source doesn't hold never shows as a change, and
@@ -95,7 +97,7 @@ export const dashboardWidgetOrderStateAdoption = {
95
97
  const names = imports.slice(0, 5).map((i) => i.label).join(", ");
96
98
  const more = imports.length > 5 ? `, … (+${imports.length - 5} more)` : "";
97
99
  return [
98
- `${imports.length} dashboard(s) have no ${DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE} state (a workspace pulled before widget order was managed, or a pull that left one of the dashboard's widgets out): ${names}${more}.`,
100
+ `${imports.length} dashboard(s) have no ${DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE} state (a workspace pulled before widget order was managed, or an earlier pull that left one of the dashboard's widgets out): ${names}${more}.`,
99
101
  "Importing their live widget order for the widgets in source; a widget_ids change in the plan reorders the dashboard to match the widgets' order in source.",
100
102
  ].join("\n");
101
103
  },
@@ -2,7 +2,9 @@ import { dataRefLabel, optionalString, plainObject, resourceRefLabel } from "../
2
2
  import { reportUnknownAttrs } from "../../engine/pull/attrs.js";
3
3
  import { EntityTfError } from "../../engine/entity.js";
4
4
  import { isTfExpr, snakeSlug, tfLabelToTsLabel } from "../../engine/tf/index.js";
5
+ import { tableColumnKey as tableColumnCatalogKey } from "../table/keys.js";
5
6
  import { filterFromTf } from "../shared/filters/tf-codec.js";
7
+ import { skipAndRelease } from "../shared/skip-release.js";
6
8
  const KNOWN_DATAMINE_ATTRS = new Set([
7
9
  "id",
8
10
  "table_id",
@@ -36,8 +38,11 @@ export function tableDataminesFromTf(blocks, tableTfLabel, columnKeyByName, ctx,
36
38
  }
37
39
  const rawNames = block.attrs["primary_column_names"];
38
40
  const rawIDs = block.attrs["primary_column_ids"];
41
+ // A datamine written to no source is also left out of adoption, or
42
+ // released if state has it, so the next plan doesn't destroy it (edk#3172).
43
+ const address = `elementum_datamine.${label}`;
39
44
  if (!Array.isArray(rawNames) && !Array.isArray(rawIDs)) {
40
- ctx.diagnostics.push(`${where}: expected primary_column_names or primary_column_ids; skipped`);
45
+ skipAndRelease(ctx, address, { problem: "the export gives it neither primary_column_names nor primary_column_ids" }, `${where}: expected primary_column_names or primary_column_ids; skipped`);
41
46
  return [];
42
47
  }
43
48
  const rawColumns = Array.isArray(rawNames) ? rawNames : rawIDs;
@@ -47,7 +52,9 @@ export function tableDataminesFromTf(blocks, tableTfLabel, columnKeyByName, ctx,
47
52
  return key === undefined ? [] : [key];
48
53
  });
49
54
  if (primaryColumns.length !== rawColumns.length) {
50
- ctx.diagnostics.push(`${where}.${Array.isArray(rawNames) ? "primary_column_names" : "primary_column_ids"}: one or more columns could not be resolved to this table; skipped`);
55
+ const attribute = Array.isArray(rawNames) ? "primary_column_names" : "primary_column_ids";
56
+ const unresolved = rawColumns.filter((value) => typeof value !== "string" || !lookup.has(value)).map((value) => JSON.stringify(value));
57
+ skipAndRelease(ctx, address, { problem: `${unresolved.length === 1 ? `its primary column ${unresolved[0]} is not a column` : `its primary columns ${unresolved.join(", ")} are not columns`} of this table that pull extracted` }, `${where}.${attribute}: one or more columns could not be resolved to this table; skipped`);
51
58
  return [];
52
59
  }
53
60
  const fixed = plainObject(block.attrs["schedule_fixed"]);
@@ -90,7 +97,7 @@ function tableColumnKey(value, tableTfLabel, columnKeyByName, columnKeyById, ctx
90
97
  const name = typeof index === "object" && index !== null && "index" in index && typeof index.index === "string"
91
98
  ? index.index
92
99
  : typeof index === "string" ? index : undefined;
93
- const key = name === undefined ? undefined : columnKeyByName.get(name) ?? tfLabelToTsLabel(name);
100
+ const key = name === undefined ? undefined : columnKeyByName.get(name) ?? tableColumnCatalogKey(name);
94
101
  if (key !== undefined)
95
102
  return key;
96
103
  }
@@ -2,15 +2,30 @@ import type { AgentRef, AppOrElementRef, AutomationRef, FieldRef, WidgetRef } fr
2
2
  import type { UnsafePlatformId } from "../../core/platform-id.js";
3
3
  import type { AppViewFieldRef } from "../app/build.js";
4
4
  import type { Filter } from "../shared/filters/types.js";
5
- export type DynamicLayoutTypedValue = {
5
+ interface DynamicLayoutValueMap {
6
6
  readonly string: string;
7
- } | {
8
7
  readonly number: number;
9
- } | {
10
8
  readonly boolean: boolean;
11
- } | {
12
9
  readonly strings: readonly string[];
13
- };
10
+ /**
11
+ * The person viewing the record, as the layout editor's **Current User**.
12
+ * Compare a user field with it using `equals` or `notEquals`.
13
+ */
14
+ readonly currentUser: true;
15
+ /**
16
+ * The groups of the person viewing the record, as the layout editor's
17
+ * **Current User's Groups**. Compare a group field with it: `equals` and
18
+ * `in` are true when the field's group is one of the viewer's groups,
19
+ * `notEquals` and `notIn` when it is not.
20
+ */
21
+ readonly currentUserGroups: true;
22
+ }
23
+ /** A fixed comparison value or default: exactly one of `string`, `number`, `boolean`, `strings`. */
24
+ export type DynamicLayoutTypedValue = ExactlyOneVariant<Pick<DynamicLayoutValueMap, "string" | "number" | "boolean" | "strings">>;
25
+ /** The person viewing the record (the editor's **Current User**); exactly `{ currentUser: true }`. */
26
+ export type DynamicLayoutCurrentUserValue = ExactlyOneVariant<Pick<DynamicLayoutValueMap, "currentUser">>;
27
+ /** The viewer's groups (the editor's **Current User's Groups**); exactly `{ currentUserGroups: true }`. */
28
+ export type DynamicLayoutCurrentUserGroupsValue = ExactlyOneVariant<Pick<DynamicLayoutValueMap, "currentUserGroups">>;
14
29
  export type DynamicLayoutCssLength = {
15
30
  readonly px: number;
16
31
  } | {
@@ -165,6 +180,7 @@ export interface DynamicLayoutComponentVariantMap {
165
180
  readonly variant?: "default" | "outline" | "ghost" | "destructive";
166
181
  readonly icon?: string;
167
182
  readonly confirmMessage?: string;
183
+ readonly fieldName?: string;
168
184
  /** App or element that owns the automation, as the layout editor records it. */
169
185
  readonly automationApp?: AppOrElementRef;
170
186
  readonly color?: string;
@@ -235,21 +251,32 @@ type ExactlyOneVariant<Map extends object> = {
235
251
  };
236
252
  }[keyof Map];
237
253
  export type DynamicLayoutComponent<ComponentKey extends string = string, ConditionKey extends string = string, SaveGroupKey extends string = string> = DynamicLayoutComponentCommon<ComponentKey, ConditionKey, SaveGroupKey> & ExactlyOneVariant<DynamicLayoutComponentVariantMap>;
238
- export type DynamicLayoutComparison = {
254
+ export type DynamicLayoutComparison<Value = DynamicLayoutTypedValue> = {
239
255
  readonly field: AppViewFieldRef;
240
- readonly value: DynamicLayoutTypedValue;
256
+ readonly value: Value;
241
257
  };
258
+ /** `equals` / `notEquals`: a typed value, the viewer, or the viewer's groups. */
259
+ export type DynamicLayoutEqualityComparison = DynamicLayoutComparison<ExactlyOneVariant<Pick<DynamicLayoutValueMap, "string" | "number" | "boolean" | "strings" | "currentUser" | "currentUserGroups">>>;
260
+ /**
261
+ * `in` / `notIn`: a list of strings, a single value, or the viewer's groups.
262
+ * The layout editor stores a single value when it shows a plain input for
263
+ * the field (any field but a Dropdown or Multi-Select with options). The
264
+ * record page treats a single string as a one-item list, but not a single
265
+ * number or boolean (`in` never matches, `notIn` always does), so build warns
266
+ * about those; use `equals` / `notEquals` (lists hold strings only).
267
+ */
268
+ export type DynamicLayoutMembershipComparison = DynamicLayoutComparison<ExactlyOneVariant<Pick<DynamicLayoutValueMap, "string" | "number" | "boolean" | "strings" | "currentUserGroups">>>;
242
269
  interface DynamicLayoutConditionVariantMap<ConditionKey extends string> {
243
- readonly equals: DynamicLayoutComparison;
244
- readonly notEquals: DynamicLayoutComparison;
270
+ readonly equals: DynamicLayoutEqualityComparison;
271
+ readonly notEquals: DynamicLayoutEqualityComparison;
245
272
  readonly greaterThan: DynamicLayoutComparison;
246
273
  readonly greaterThanOrEqual: DynamicLayoutComparison;
247
274
  readonly lessThan: DynamicLayoutComparison;
248
275
  readonly lessThanOrEqual: DynamicLayoutComparison;
249
276
  readonly contains: DynamicLayoutComparison;
250
277
  readonly notContains: DynamicLayoutComparison;
251
- readonly in: DynamicLayoutComparison;
252
- readonly notIn: DynamicLayoutComparison;
278
+ readonly in: DynamicLayoutMembershipComparison;
279
+ readonly notIn: DynamicLayoutMembershipComparison;
253
280
  readonly empty: {
254
281
  readonly field: AppViewFieldRef;
255
282
  };
@@ -5,11 +5,12 @@ import { filterFromTf } from "../access-policy/from-tf.js";
5
5
  import { elementAuditFieldReference, fieldKeyFromTfValue } from "../field/from-tf.js";
6
6
  import { omittedAutomationKey } from "../automation/omitted-ref.js";
7
7
  import { filterOwnerForAspect } from "../relationship/from-tf.js";
8
- import { filterWireToTf } from "../shared/filters/tf-codec.js";
8
+ import { filterWireToTf, UnauthorableFilterValueError } from "../shared/filters/tf-codec.js";
9
9
  import { resolveDataAspectTarget } from "../shared/aspect-target-from-tf.js";
10
10
  import { WIDGET_RESOURCE_TYPE } from "../widget/module.js";
11
11
  import { lostStageMessage, pulledStageHandle } from "../app/stage-keys.js";
12
12
  import { unextractedFieldRefId } from "../view/from-tf.js";
13
+ import { skipAndRelease } from "../shared/skip-release.js";
13
14
  import { DYNAMIC_LAYOUT_RESOURCE_TYPE } from "./module.js";
14
15
  import { DYNAMIC_LAYOUT_COMPARISON_KEYS, DYNAMIC_LAYOUT_FIELD_COMPONENT_WIRE_KEY_BY_PUBLIC_KEY, dynamicLayoutCompanionWidgetLabel, } from "./dialect.js";
15
16
  const KNOWN_ATTRS = new Set([
@@ -69,7 +70,8 @@ function dynamicLayoutFromTf(block, owner, ctx) {
69
70
  }
70
71
  const componentsRaw = plainObject(block.attrs["components"]);
71
72
  if (componentsRaw === undefined) {
72
- ctx.diagnostics.push(`${where}: components is not an object; skipped`);
73
+ // Written to no source, so also left out of adoption (edk#3172).
74
+ skipAndRelease(ctx, `${DYNAMIC_LAYOUT_RESOURCE_TYPE}.${block.label ?? ""}`, { problem: "its components is not an object" }, `${where}: components is not an object; skipped`);
73
75
  return undefined;
74
76
  }
75
77
  // A stage reference whose only handle is another stage's own key would
@@ -355,6 +357,7 @@ function relatedItemsBlock(block, owner, ctx, where) {
355
357
  // A raw field id decodes without throwing even when it is not the owner's
356
358
  // field, so a decode that leaves one unresolved is only a fallback.
357
359
  let failure;
360
+ let unauthorable;
358
361
  let partial;
359
362
  for (const filterOwner of filterOwners) {
360
363
  try {
@@ -367,8 +370,22 @@ function relatedItemsBlock(block, owner, ctx, where) {
367
370
  }
368
371
  catch (error) {
369
372
  failure ??= error;
373
+ if (error instanceof UnauthorableFilterValueError)
374
+ unauthorable ??= error;
370
375
  }
371
376
  }
377
+ // A value source can't hold (a field value's aspect) fails the pull: the
378
+ // drop below would write the block without its filter, and the next apply
379
+ // would remove the live filter (#3144). Other undecodable filters keep
380
+ // the drop rule.
381
+ if (unauthorable !== undefined) {
382
+ reportAuthoringBlocker(ctx, {
383
+ address: where.split(".").slice(0, 2).join("."),
384
+ description: `${unauthorable.message}, so the related-items block can't be written to source with its filter`,
385
+ remedy: "Remove the app or element restriction from that field comparison in the layout editor and pull again; if the layout keeps holding it, report it to the EDK maintainers.",
386
+ });
387
+ return;
388
+ }
372
389
  if (partial !== undefined) {
373
390
  block["filter"] = partial;
374
391
  return;
@@ -397,6 +414,15 @@ function decodeJson(value) {
397
414
  }
398
415
  return value;
399
416
  }
417
+ /** The label of an option reference (`local.<field>_options_by_label["<label>"]`), or undefined. */
418
+ function optionLabel(value) {
419
+ if (value === undefined || !isTfExpr(value) || value.$expr !== "local")
420
+ return undefined;
421
+ const segment = value.path[0];
422
+ return value.path.length === 1 && typeof segment === "object" && segment !== null && "index" in segment && typeof segment.index === "string"
423
+ ? segment.index
424
+ : undefined;
425
+ }
400
426
  function conditionMap(values, owner, ctx, where) {
401
427
  const out = {};
402
428
  for (const [id, raw] of Object.entries(values)) {
@@ -408,11 +434,13 @@ function conditionMap(values, owner, ctx, where) {
408
434
  comparison["field"] = fieldKey(comparison["fieldId"], owner, ctx, `${where}.conditions.${id}.${key}`, `${where}.conditions.${id}`);
409
435
  delete comparison["fieldId"];
410
436
  const value = plainUnknownObject(comparison["value"]);
411
- const stringValue = value?.["string"];
412
- if (value !== undefined && stringValue !== undefined && isTfExpr(stringValue) && stringValue.$expr === "local") {
413
- const segment = stringValue.path[0];
414
- if (stringValue.path.length === 1 && typeof segment === "object" && segment !== null && "index" in segment) {
415
- value["string"] = segment.index;
437
+ if (value !== undefined) {
438
+ const label = optionLabel(value["string"]);
439
+ if (label !== undefined)
440
+ value["string"] = label;
441
+ // A Multi-Select condition's list of options (edk#3044).
442
+ if (Array.isArray(value["strings"])) {
443
+ value["strings"] = value["strings"].map((item) => optionLabel(item) ?? item);
416
444
  }
417
445
  }
418
446
  }