@elementumai/edk 0.10.4 → 0.12.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 (171) hide show
  1. package/README.md +49 -13
  2. package/dist-sdk/src/catalog/token.js +2 -1
  3. package/dist-sdk/src/core/triggers/on-demand.d.ts +2 -0
  4. package/dist-sdk/src/core/triggers/on-demand.js +3 -0
  5. package/dist-sdk/src/core/wire/ref-serializer.js +26 -1
  6. package/dist-sdk/src/engine/build/context.d.ts +4 -0
  7. package/dist-sdk/src/engine/coverage-gaps.d.ts +7 -0
  8. package/dist-sdk/src/engine/coverage-gaps.js +12 -0
  9. package/dist-sdk/src/engine/ei/json-stream-reader.d.ts +43 -0
  10. package/dist-sdk/src/engine/ei/json-stream-reader.js +234 -0
  11. package/dist-sdk/src/engine/ei/run.d.ts +42 -1
  12. package/dist-sdk/src/engine/ei/run.js +201 -32
  13. package/dist-sdk/src/engine/ei/saved-plan.d.ts +16 -0
  14. package/dist-sdk/src/engine/ei/saved-plan.js +19 -0
  15. package/dist-sdk/src/engine/ei/state.d.ts +1 -1
  16. package/dist-sdk/src/engine/ei/state.js +17 -4
  17. package/dist-sdk/src/engine/progress.d.ts +3 -1
  18. package/dist-sdk/src/engine/progress.js +7 -3
  19. package/dist-sdk/src/engine/pull/authored-address.d.ts +15 -1
  20. package/dist-sdk/src/engine/pull/authored-address.js +180 -29
  21. package/dist-sdk/src/engine/pull/context.d.ts +37 -2
  22. package/dist-sdk/src/engine/pull/context.js +7 -4
  23. package/dist-sdk/src/engine/pull/ref-only.d.ts +18 -0
  24. package/dist-sdk/src/engine/pull/ref-only.js +52 -0
  25. package/dist-sdk/src/engine/tf/index.d.ts +2 -2
  26. package/dist-sdk/src/engine/tf/index.js +2 -2
  27. package/dist-sdk/src/engine/tf/labels.d.ts +22 -0
  28. package/dist-sdk/src/engine/tf/labels.js +50 -0
  29. package/dist-sdk/src/engine/tf/model.d.ts +2 -0
  30. package/dist-sdk/src/engine/tf/model.js +26 -0
  31. package/dist-sdk/src/engine/validation.d.ts +2 -0
  32. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +18 -0
  33. package/dist-sdk/src/entities/access-policy/from-tf.js +58 -24
  34. package/dist-sdk/src/entities/access-policy/member-list.d.ts +32 -0
  35. package/dist-sdk/src/entities/access-policy/member-list.js +57 -0
  36. package/dist-sdk/src/entities/access-policy/module.js +10 -0
  37. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +4 -3
  38. package/dist-sdk/src/entities/access-policy/to-tf.js +21 -12
  39. package/dist-sdk/src/entities/agent/build.js +7 -5
  40. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +2 -0
  41. package/dist-sdk/src/entities/agent/from-tf.js +13 -3
  42. package/dist-sdk/src/entities/agent/to-tf.js +11 -5
  43. package/dist-sdk/src/entities/agent/tools.d.ts +8 -0
  44. package/dist-sdk/src/entities/agent/tools.js +6 -2
  45. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +2 -0
  46. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +29 -0
  47. package/dist-sdk/src/entities/agent-tool/to-tf.js +56 -3
  48. package/dist-sdk/src/entities/agent-tool/types.d.ts +12 -8
  49. package/dist-sdk/src/entities/agent-tool/types.js +13 -9
  50. package/dist-sdk/src/entities/app/build.d.ts +12 -1
  51. package/dist-sdk/src/entities/app/build.js +80 -4
  52. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +5 -7
  53. package/dist-sdk/src/entities/app/from-tf.js +17 -12
  54. package/dist-sdk/src/entities/app/stage-keys.d.ts +18 -3
  55. package/dist-sdk/src/entities/app/stage-keys.js +40 -6
  56. package/dist-sdk/src/entities/app/to-tf.js +7 -4
  57. package/dist-sdk/src/entities/automation/build.d.ts +52 -31
  58. package/dist-sdk/src/entities/automation/build.js +59 -20
  59. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +7 -4
  60. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +39 -14
  61. package/dist-sdk/src/entities/automation/from-tf.d.ts +35 -2
  62. package/dist-sdk/src/entities/automation/from-tf.js +721 -93
  63. package/dist-sdk/src/entities/automation/index.d.ts +1 -1
  64. package/dist-sdk/src/entities/automation/module.d.ts +22 -2
  65. package/dist-sdk/src/entities/automation/module.js +244 -57
  66. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +22 -2
  67. package/dist-sdk/src/entities/automation/output-key-wire-name.js +54 -3
  68. package/dist-sdk/src/entities/automation/run-target.d.ts +61 -0
  69. package/dist-sdk/src/entities/automation/run-target.js +104 -0
  70. package/dist-sdk/src/entities/automation/script-code.d.ts +11 -1
  71. package/dist-sdk/src/entities/automation/script-code.js +106 -4
  72. package/dist-sdk/src/entities/automation/script-lint.d.ts +13 -0
  73. package/dist-sdk/src/entities/automation/script-lint.js +418 -0
  74. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +17 -1
  75. package/dist-sdk/src/entities/automation/task-output-labels.js +58 -1
  76. package/dist-sdk/src/entities/automation/tasks.d.ts +67 -22
  77. package/dist-sdk/src/entities/automation/tasks.js +18 -4
  78. package/dist-sdk/src/entities/automation/to-tf.d.ts +1 -3
  79. package/dist-sdk/src/entities/automation/to-tf.js +354 -64
  80. package/dist-sdk/src/entities/automation/triggers.d.ts +63 -11
  81. package/dist-sdk/src/entities/automation/triggers.js +45 -5
  82. package/dist-sdk/src/entities/automation/types.d.ts +21 -0
  83. package/dist-sdk/src/entities/automation/types.js +26 -0
  84. package/dist-sdk/src/entities/chart/build.d.ts +9 -1
  85. package/dist-sdk/src/entities/chart/from-tf.d.ts +2 -2
  86. package/dist-sdk/src/entities/chart/from-tf.js +25 -1
  87. package/dist-sdk/src/entities/chart/index.d.ts +1 -1
  88. package/dist-sdk/src/entities/chart/printer.js +5 -2
  89. package/dist-sdk/src/entities/chart/to-tf.js +19 -1
  90. package/dist-sdk/src/entities/dashboard/from-tf.d.ts +11 -1
  91. package/dist-sdk/src/entities/dashboard/from-tf.js +57 -7
  92. package/dist-sdk/src/entities/dashboard/to-tf.js +13 -0
  93. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +8 -2
  94. package/dist-sdk/src/entities/dynamic-layout/condition-keys.d.ts +48 -0
  95. package/dist-sdk/src/entities/dynamic-layout/condition-keys.js +261 -0
  96. package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +3 -0
  97. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +66 -20
  98. package/dist-sdk/src/entities/dynamic-layout/module.js +2 -1
  99. package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +4 -2
  100. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +341 -32
  101. package/dist-sdk/src/entities/element/build.d.ts +10 -0
  102. package/dist-sdk/src/entities/element/build.js +1 -0
  103. package/dist-sdk/src/entities/element/from-tf.js +14 -9
  104. package/dist-sdk/src/entities/element/to-tf.js +7 -4
  105. package/dist-sdk/src/entities/field/from-tf.d.ts +24 -0
  106. package/dist-sdk/src/entities/field/from-tf.js +79 -1
  107. package/dist-sdk/src/entities/field/module.js +14 -1
  108. package/dist-sdk/src/entities/field/to-tf.d.ts +38 -3
  109. package/dist-sdk/src/entities/field/to-tf.js +108 -34
  110. package/dist-sdk/src/entities/file-reader/module.js +3 -3
  111. package/dist-sdk/src/entities/file-reader/to-tf.js +3 -3
  112. package/dist-sdk/src/entities/file-reader/types.d.ts +4 -16
  113. package/dist-sdk/src/entities/file-reader/types.js +7 -0
  114. package/dist-sdk/src/entities/org/group.d.ts +1 -0
  115. package/dist-sdk/src/entities/org/group.js +2 -1
  116. package/dist-sdk/src/entities/org/role.js +5 -0
  117. package/dist-sdk/src/entities/record-create-form/from-tf.d.ts +8 -0
  118. package/dist-sdk/src/entities/record-create-form/from-tf.js +10 -2
  119. package/dist-sdk/src/entities/record-create-form/to-tf.d.ts +2 -1
  120. package/dist-sdk/src/entities/record-create-form/to-tf.js +14 -2
  121. package/dist-sdk/src/entities/relationship/from-tf.d.ts +8 -0
  122. package/dist-sdk/src/entities/relationship/from-tf.js +88 -10
  123. package/dist-sdk/src/entities/relationship/to-tf.d.ts +3 -2
  124. package/dist-sdk/src/entities/relationship/to-tf.js +79 -8
  125. package/dist-sdk/src/entities/role/from-tf.js +24 -7
  126. package/dist-sdk/src/entities/role/to-tf.js +25 -7
  127. package/dist-sdk/src/entities/service-account/from-tf.js +2 -1
  128. package/dist-sdk/src/entities/service-account/module.js +20 -0
  129. package/dist-sdk/src/entities/service-account/role-fidelity.d.ts +5 -5
  130. package/dist-sdk/src/entities/service-account/role-fidelity.js +21 -13
  131. package/dist-sdk/src/entities/service-account/to-tf.js +12 -4
  132. package/dist-sdk/src/entities/shared/filters/ast.d.ts +2 -0
  133. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +1 -1
  134. package/dist-sdk/src/entities/shared/filters/tf-codec.js +12 -7
  135. package/dist-sdk/src/entities/shared/types/field-types.d.ts +6 -3
  136. package/dist-sdk/src/entities/shared/types/field-types.js +3 -1
  137. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +5 -2
  138. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +8 -1
  139. package/dist-sdk/src/entities/skill/from-tf.js +10 -3
  140. package/dist-sdk/src/entities/skill/module.js +18 -0
  141. package/dist-sdk/src/entities/skill/to-tf.d.ts +8 -1
  142. package/dist-sdk/src/entities/skill/to-tf.js +23 -14
  143. package/dist-sdk/src/entities/skill/tools.d.ts +8 -0
  144. package/dist-sdk/src/entities/skill/tools.js +6 -2
  145. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
  146. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +8 -0
  147. package/dist-sdk/src/entities/skill-tool/to-tf.js +6 -2
  148. package/dist-sdk/src/entities/task/to-tf.js +1 -0
  149. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +8 -2
  150. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +20 -10
  151. package/dist-sdk/src/entities/view/from-tf.d.ts +68 -4
  152. package/dist-sdk/src/entities/view/from-tf.js +394 -22
  153. package/dist-sdk/src/entities/view/module.js +20 -0
  154. package/dist-sdk/src/entities/view/portable.d.ts +11 -0
  155. package/dist-sdk/src/entities/view/portable.js +47 -0
  156. package/dist-sdk/src/entities/view/to-tf.d.ts +4 -1
  157. package/dist-sdk/src/entities/view/to-tf.js +25 -7
  158. package/dist-sdk/src/entities/view/types.js +1 -1
  159. package/dist-sdk/src/entities/widget/build.d.ts +4 -3
  160. package/dist-sdk/src/entities/widget/from-tf.d.ts +3 -0
  161. package/dist-sdk/src/entities/widget/from-tf.js +100 -3
  162. package/dist-sdk/src/entities/widget/to-tf.d.ts +16 -1
  163. package/dist-sdk/src/entities/widget/to-tf.js +77 -14
  164. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +30 -9
  165. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
  166. package/dist-sdk/src/graph/field-resource-types.d.ts +2 -0
  167. package/dist-sdk/src/graph/field-resource-types.js +11 -0
  168. package/dist-sdk/src/graph/index.d.ts +41 -3
  169. package/dist-sdk/src/graph/index.js +24 -2
  170. package/dist-sdk/src/graph/types.d.ts +195 -5
  171. package/package.json +1 -1
@@ -31,8 +31,12 @@ export interface RecordTriggerOptions<A extends AppOrElementRef = AppOrElementRe
31
31
  /** Restrict to fire only when one of these fields changes. */
32
32
  readonly changedFields?: readonly FieldRef[];
33
33
  readonly thinkUi?: boolean;
34
- /** Pre-built wire `Filter` (may embed `FieldRef` tokens — resolved at deploy). */
35
- readonly filter?: Filter;
34
+ /**
35
+ * Pre-built wire `Filter` (may embed `FieldRef` tokens — resolved at deploy).
36
+ * Trigger condition. Leaving it out and `null` mean the same thing: no condition.
37
+ * On update, either one removes a condition the trigger had (apply sends `filter: null`).
38
+ */
39
+ readonly filter?: Filter | null;
36
40
  }
37
41
  /** Fires when a record is created on the given aspect. */
38
42
  export declare function recordCreated<A extends AppOrElementRef>(opts: RecordTriggerOptions<A>): TriggerChain<RecordTriggerOutput<A>>;
@@ -80,13 +84,13 @@ export interface WebhookTriggerOptions {
80
84
  readonly customResponse?: {
81
85
  readonly success: {
82
86
  readonly enabled: boolean;
83
- readonly format: "JSON" | "XML" | "Text";
87
+ readonly format: "JSON" | "XML" | "TEXT";
84
88
  readonly statusCode: number;
85
89
  readonly body: string;
86
90
  };
87
91
  readonly failure: {
88
92
  readonly enabled: boolean;
89
- readonly format: "JSON" | "XML" | "Text";
93
+ readonly format: "JSON" | "XML" | "TEXT";
90
94
  readonly statusCode: number;
91
95
  readonly body: string;
92
96
  };
@@ -94,7 +98,14 @@ export interface WebhookTriggerOptions {
94
98
  }
95
99
  /** The inbound request payload exposed to tasks. */
96
100
  export interface WebhookTriggerOutput {
101
+ /**
102
+ * `body["Plain Text"]` is the raw request body. A named key such as
103
+ * `body["Title"]` exists only after the trigger has seen a sample request,
104
+ * which only the Elementum UI can capture, so plan refuses it on a trigger
105
+ * the run creates (edk#2047).
106
+ */
97
107
  readonly body: Record<string, unknown>;
108
+ /** Named header keys, like named body keys, exist only after a sample request. */
98
109
  readonly headers: Record<string, unknown>;
99
110
  }
100
111
  /** Fires on an inbound HTTP webhook. */
@@ -107,10 +118,18 @@ export interface TemporalTriggerOptions<A extends AppOrElementRef = AppOrElement
107
118
  readonly field: FieldRef;
108
119
  readonly temporalUnit: TemporalUnit;
109
120
  readonly value: number;
121
+ /**
122
+ * Pre-built wire `Filter` (may embed `FieldRef` tokens — resolved at deploy).
123
+ * Trigger condition. Leaving it out and `null` mean the same thing: no condition.
124
+ * On update, either one removes a condition the trigger had (apply sends `filter: null`).
125
+ */
126
+ readonly filter?: Filter | null;
110
127
  }
111
128
  /** Fires relative to a date/datetime field on records in the given aspect. */
112
129
  export declare function temporal<A extends AppOrElementRef>(opts: TemporalTriggerOptions<A>): TriggerChain<RecordTriggerOutput<A>>;
113
- export type approvalProcessStatusUpdatedStatus = "ACTIVE" | "STEP_APPROVED" | "CANCELLED" | "DENIED" | "APPROVED";
130
+ export type approvalProcessStatusUpdatedStatus = "ACTIVE" | "STEP_APPROVED" | "CANCELLED" | "DENIED" | "APPROVED"
131
+ /** The approval process's exception button (shown in the web app under the button's own name). */
132
+ | "EXCEPTION";
114
133
  export interface approvalProcessStatusUpdatedTriggerOptions<A extends AppOrElementRef = AppOrElementRef> {
115
134
  readonly app: A;
116
135
  /**
@@ -123,14 +142,22 @@ export interface approvalProcessStatusUpdatedTriggerOptions<A extends AppOrEleme
123
142
  */
124
143
  readonly approvalChain?: ApprovalChainRef | UnsafePlatformId;
125
144
  readonly status: approvalProcessStatusUpdatedStatus;
126
- /** Record filter the approval-chain trigger additionally requires. */
127
- readonly filter?: Filter;
145
+ /**
146
+ * Record filter the approval-chain trigger additionally requires.
147
+ * Trigger condition. Leaving it out and `null` mean the same thing: no condition.
148
+ * On update, either one removes a condition the trigger had (apply sends `filter: null`).
149
+ */
150
+ readonly filter?: Filter | null;
128
151
  }
129
152
  /** Fires when an approval chain on a record changes to the configured status. */
130
153
  export declare function approvalProcessStatusUpdated<A extends AppOrElementRef>(opts: approvalProcessStatusUpdatedTriggerOptions<A>): TriggerChain<RecordTriggerOutput<A>>;
131
154
  export interface AttachmentTriggerOptions<A extends AppOrElementRef = AppOrElementRef> {
132
155
  readonly app: A;
133
- readonly filter?: Filter;
156
+ /**
157
+ * Trigger condition. Leaving it out and `null` mean the same thing: no condition.
158
+ * On update, either one removes a condition the trigger had (apply sends `filter: null`).
159
+ */
160
+ readonly filter?: Filter | null;
134
161
  readonly thinkUi?: boolean;
135
162
  }
136
163
  export interface AttachmentTriggerOutput<A extends AppOrElementRef = AppOrElementRef> {
@@ -155,6 +182,13 @@ export interface DataMineTriggerOptions {
155
182
  readonly datamine: DatamineRef | UnsafePlatformId;
156
183
  readonly fireOnAlert?: boolean;
157
184
  readonly fireOnRecovery?: boolean;
185
+ /**
186
+ * Trigger Condition: the datamine's records must also match it (edk#2287).
187
+ * Column references must be columns of the datamine's own table.
188
+ * Leaving it out and `null` mean the same thing: no condition.
189
+ * On update, either one removes a condition the trigger had (apply sends `filter: null`).
190
+ */
191
+ readonly filter?: Filter | null;
158
192
  }
159
193
  export interface DataMineTriggerOutput {
160
194
  readonly record: Record<string, unknown>;
@@ -179,9 +213,17 @@ export interface EmailReceivedTriggerOutput {
179
213
  export declare function emailReceived(opts: EmailReceivedTriggerOptions): TriggerChain<EmailReceivedTriggerOutput>;
180
214
  export interface CommentAddedTriggerOptions<A extends AppOrElementRef = AppOrElementRef> {
181
215
  readonly app: A;
182
- /** Conversation type the comment was added to (e.g. `"INTERNAL"`). */
216
+ /**
217
+ * Conversation type the comment was added to: `"status"` (status update comments) or
218
+ * `"general"` (general comments). Write it lowercase: pull writes it back lowercase, so
219
+ * any other spelling shows a change on the plan after the next pull.
220
+ */
183
221
  readonly conversationType: string;
184
- readonly filter?: Filter;
222
+ /**
223
+ * Trigger condition. Leaving it out and `null` mean the same thing: no condition.
224
+ * On update, either one removes a condition the trigger had (apply sends `filter: null`).
225
+ */
226
+ readonly filter?: Filter | null;
185
227
  }
186
228
  export interface CommentAddedTriggerOutput<A extends AppOrElementRef = AppOrElementRef> {
187
229
  readonly record: RecordShape<A>;
@@ -194,7 +236,11 @@ export type ConversationEndConversationType = "A2A" | "ELEMENTUM_UI" | "VOICE" |
194
236
  export interface ConversationEndTriggerOptions<A extends AppOrElementRef = AppOrElementRef> {
195
237
  readonly app: A;
196
238
  readonly conversationType: ConversationEndConversationType;
197
- readonly filter?: Filter;
239
+ /**
240
+ * Trigger condition. Leaving it out and `null` mean the same thing: no condition.
241
+ * On update, either one removes a condition the trigger had (apply sends `filter: null`).
242
+ */
243
+ readonly filter?: Filter | null;
198
244
  }
199
245
  export interface ConversationEndTriggerOutput<A extends AppOrElementRef = AppOrElementRef> {
200
246
  readonly record: RecordShape<A>;
@@ -232,6 +278,12 @@ export interface SurveyResponseCreateTriggerOptions {
232
278
  * explicit wrapper marks this platform-owned value as non-portable.
233
279
  */
234
280
  readonly survey: UnsafePlatformId;
281
+ /**
282
+ * Trigger Condition: the record the survey was completed for must match it (edk#2206).
283
+ * Leaving it out and `null` mean the same thing: no condition.
284
+ * On update, either one removes a condition the trigger had (apply sends `filter: null`).
285
+ */
286
+ readonly filter?: Filter | null;
235
287
  }
236
288
  export type SurveyResponseCreateTriggerOutput = Record<string, unknown>;
237
289
  /** Fires when a response is created for the selected survey template. */
@@ -6,7 +6,7 @@ function recordTriggerFields(opts) {
6
6
  aspectId: opts.app, // token → aspect id at deploy
7
7
  ...(opts.changedFields !== undefined ? { changedFieldIds: opts.changedFields } : {}),
8
8
  ...(opts.thinkUi !== undefined ? { thinkUi: opts.thinkUi } : {}),
9
- ...(opts.filter !== undefined ? { filter: opts.filter } : {}),
9
+ ...(opts.filter !== undefined && opts.filter !== null ? { filter: opts.filter } : {}),
10
10
  };
11
11
  }
12
12
  /** Fires when a record is created on the given aspect. */
@@ -105,6 +105,7 @@ export function temporal(opts) {
105
105
  aspectFieldId: opts.field,
106
106
  temporalUnit: opts.temporalUnit,
107
107
  value: opts.value,
108
+ ...(opts.filter !== undefined && opts.filter !== null ? { filter: opts.filter } : {}),
108
109
  type: "TEMPORAL",
109
110
  },
110
111
  },
@@ -119,7 +120,7 @@ export function approvalProcessStatusUpdated(opts) {
119
120
  aspectId: opts.app,
120
121
  ...(opts.approvalChain !== undefined ? { approvalChainTemplateId: opts.approvalChain } : {}),
121
122
  status: opts.status,
122
- ...(opts.filter !== undefined ? { filter: opts.filter } : {}),
123
+ ...(opts.filter !== undefined && opts.filter !== null ? { filter: opts.filter } : {}),
123
124
  type: "APPROVAL_CHAIN_UPDATE",
124
125
  },
125
126
  },
@@ -133,15 +134,51 @@ export function attachment(opts) {
133
134
  attachment: {
134
135
  aspectId: opts.app,
135
136
  type: "ATTACHMENT_UPDATE",
136
- ...(opts.filter !== undefined ? { filter: opts.filter } : {}),
137
+ ...(opts.filter !== undefined && opts.filter !== null ? { filter: opts.filter } : {}),
137
138
  ...(opts.thinkUi !== undefined ? { thinkUi: opts.thinkUi } : {}),
138
139
  },
139
140
  },
140
141
  __recordApp: opts.app.refName,
141
142
  });
142
143
  }
144
+ /**
145
+ * The owner check for a datamine trigger's condition (edk#2287): the record it
146
+ * tests is a row of the datamine's table, so every condition field must be a
147
+ * column of that table. Another table's column, or an app or element field,
148
+ * can't match the row. A raw `unsafePlatformId` datamine carries no table, so
149
+ * there is nothing to check against.
150
+ */
151
+ function assertDataMineFilterOnDatamineTable(datamine, condition) {
152
+ const table = datamine.__kind === "datamine" ? datamine.parent : undefined;
153
+ if (table === undefined)
154
+ return;
155
+ const datamineName = datamine.name || datamine.refName;
156
+ const visit = (node) => {
157
+ if (typeof node !== "object" || node === null)
158
+ return;
159
+ const { field, children } = node;
160
+ if (typeof field === "object" && field !== null && typeof field.__kind === "string") {
161
+ const ref = field;
162
+ const label = String(ref.name || ref.refName);
163
+ if (ref.__kind !== "tableColumn") {
164
+ throw new EdkValidationError(`dataMine filter: "${label}" is ${ref.__kind === "field" ? "an app or element field" : `a ${ref.__kind} reference`}, but a datamine trigger's ` +
165
+ `condition tests the rows of datamine "${datamineName}" (table "${table}"). Use a column of that table, ` +
166
+ `for example org.tables.${table}.columns.<column>.`);
167
+ }
168
+ if (ref.parent !== table) {
169
+ throw new EdkValidationError(`dataMine filter: column "${label}" belongs to table "${String(ref.parent)}", but datamine "${datamineName}" ` +
170
+ `reads table "${table}". A datamine trigger's condition can only test columns of the datamine's own table.`);
171
+ }
172
+ }
173
+ if (Array.isArray(children))
174
+ children.forEach(visit);
175
+ };
176
+ visit(condition);
177
+ }
143
178
  /** Fires when a data mine meets/no longer meets requirements. */
144
179
  export function dataMine(opts) {
180
+ if (opts.filter !== undefined && opts.filter !== null)
181
+ assertDataMineFilterOnDatamineTable(opts.datamine, opts.filter);
145
182
  return chainableTrigger({
146
183
  wire: {
147
184
  datamine: {
@@ -149,6 +186,7 @@ export function dataMine(opts) {
149
186
  type: "DATAMINE",
150
187
  ...(opts.fireOnAlert !== undefined ? { fireOnAlert: opts.fireOnAlert } : {}),
151
188
  ...(opts.fireOnRecovery !== undefined ? { fireOnRecovery: opts.fireOnRecovery } : {}),
189
+ ...(opts.filter !== undefined && opts.filter !== null ? { filter: opts.filter } : {}),
152
190
  },
153
191
  },
154
192
  });
@@ -171,7 +209,7 @@ export function commentAdded(opts) {
171
209
  commentAdded: {
172
210
  aspectId: opts.app,
173
211
  conversationType: opts.conversationType,
174
- ...(opts.filter !== undefined ? { filter: opts.filter } : {}),
212
+ ...(opts.filter !== undefined && opts.filter !== null ? { filter: opts.filter } : {}),
175
213
  },
176
214
  },
177
215
  __recordApp: opts.app.refName,
@@ -185,7 +223,7 @@ export function conversationEnd(opts) {
185
223
  aspectId: opts.app,
186
224
  conversationType: opts.conversationType,
187
225
  type: "CONVERSATION_END",
188
- ...(opts.filter !== undefined ? { filter: opts.filter } : {}),
226
+ ...(opts.filter !== undefined && opts.filter !== null ? { filter: opts.filter } : {}),
189
227
  },
190
228
  },
191
229
  __recordApp: opts.app.refName,
@@ -208,8 +246,10 @@ export function surveyResponseCreate(opts) {
208
246
  survey: {
209
247
  aspectId: opts.app,
210
248
  surveyTemplateId: opts.survey,
249
+ ...(opts.filter !== undefined && opts.filter !== null ? { filter: opts.filter } : {}),
211
250
  type: "SURVEY_RESPONSE_CREATE",
212
251
  },
213
252
  },
253
+ __recordApp: opts.app.refName,
214
254
  });
215
255
  }
@@ -40,6 +40,27 @@ export declare function automationResourceLabel(ownerTfLabel: string, refName: s
40
40
  export declare const TABLE_RECORDS_SEARCH_TASK_RESOURCE_TYPE = "elementum_table_records_search_task";
41
41
  /** Trigger kinds. One trigger per automation. Phase 1: onDemand only. */
42
42
  export declare const TRIGGER_SUB_TYPES: readonly AutomationSubType[];
43
+ /**
44
+ * A webhook trigger's request refs are named "Body (<key>)" and
45
+ * "Headers (<key>)": one wire key naming both the `body`/`headers` property
46
+ * of `WebhookTriggerOutput` and the request key under it.
47
+ */
48
+ export declare const WEBHOOK_REQUEST_REF_PATTERN: RegExp;
49
+ /** The raw request body, `ctx.trigger.body["Plain Text"]`. */
50
+ export declare const WEBHOOK_RAW_BODY_REF = "Body (Plain Text)";
51
+ /**
52
+ * A webhook request ref that exists only after the platform has seen a sample
53
+ * request, as the authored path (`body["Title"]` is `{ property: "body",
54
+ * key: "Title" }`), or undefined for any other ref. Named body and header keys
55
+ * appear in the trigger's refs only once a sample request has been captured,
56
+ * which only the Elementum UI can do. A newly created webhook trigger
57
+ * publishes just "Body (Plain Text)" and "contentType" (edk#2047), so indexing
58
+ * any other request ref on it fails apply with "Invalid index".
59
+ */
60
+ export declare function webhookSampleOnlyRef(refKey: string): {
61
+ readonly property: "body" | "headers";
62
+ readonly key: string;
63
+ } | undefined;
43
64
  /**
44
65
  * Task kinds. All rows are implemented as of `aiFileAnalysis` (the last
45
66
  * holdout — it needs its `elementum_ai_file_reader` target to also round-trip,
@@ -53,7 +53,33 @@ export const TRIGGER_SUB_TYPES = [
53
53
  { typeKey: "slackMessage", resourceType: "elementum_slack_message_trigger", implemented: true },
54
54
  { typeKey: "survey", resourceType: "elementum_survey_trigger", implemented: true },
55
55
  { typeKey: "schedule", resourceType: "elementum_schedule_trigger", implemented: true },
56
+ { typeKey: "temporal", resourceType: "elementum_temporal_trigger", implemented: true },
56
57
  ];
58
+ /**
59
+ * A webhook trigger's request refs are named "Body (<key>)" and
60
+ * "Headers (<key>)": one wire key naming both the `body`/`headers` property
61
+ * of `WebhookTriggerOutput` and the request key under it.
62
+ */
63
+ export const WEBHOOK_REQUEST_REF_PATTERN = /^(Body|Headers) \((.+)\)$/;
64
+ /** The raw request body, `ctx.trigger.body["Plain Text"]`. */
65
+ export const WEBHOOK_RAW_BODY_REF = "Body (Plain Text)";
66
+ /**
67
+ * A webhook request ref that exists only after the platform has seen a sample
68
+ * request, as the authored path (`body["Title"]` is `{ property: "body",
69
+ * key: "Title" }`), or undefined for any other ref. Named body and header keys
70
+ * appear in the trigger's refs only once a sample request has been captured,
71
+ * which only the Elementum UI can do. A newly created webhook trigger
72
+ * publishes just "Body (Plain Text)" and "contentType" (edk#2047), so indexing
73
+ * any other request ref on it fails apply with "Invalid index".
74
+ */
75
+ export function webhookSampleOnlyRef(refKey) {
76
+ if (refKey === WEBHOOK_RAW_BODY_REF)
77
+ return undefined;
78
+ const match = WEBHOOK_REQUEST_REF_PATTERN.exec(refKey);
79
+ if (match === null)
80
+ return undefined;
81
+ return { property: match[1] === "Body" ? "body" : "headers", key: match[2] };
82
+ }
57
83
  /**
58
84
  * Task kinds. All rows are implemented as of `aiFileAnalysis` (the last
59
85
  * holdout — it needs its `elementum_ai_file_reader` target to also round-trip,
@@ -64,6 +64,14 @@ export declare function chartJoin<const From extends ChartDatasourceRef, const T
64
64
  readonly datasource: To;
65
65
  readonly type?: ChartJoinType;
66
66
  } & ChartJoinSides<NoInfer<From>, NoInfer<To>>): ChartJoin<From, To>;
67
+ /**
68
+ * A subscription's row limit: at most `count` rows, after skipping `offset`
69
+ * rows (default 0). The platform stores it as `{count, offset}` (#2291).
70
+ */
71
+ export interface ChartSubscriptionLimit {
72
+ readonly count: number;
73
+ readonly offset?: number;
74
+ }
67
75
  declare const chartSubscriptionBrand: unique symbol;
68
76
  export interface ChartSubscription<Datasource extends ChartDatasourceRef = ChartDatasourceRef> {
69
77
  readonly [chartSubscriptionBrand]: Datasource;
@@ -72,7 +80,7 @@ export interface ChartSubscription<Datasource extends ChartDatasourceRef = Chart
72
80
  readonly groupBy?: readonly ChartGroupBy<Datasource>[];
73
81
  readonly joins?: readonly ChartJoin<Datasource, ChartDatasourceRef>[];
74
82
  readonly filter?: Filter<ChartFieldFor<Datasource>, never>;
75
- readonly limit?: string;
83
+ readonly limit?: ChartSubscriptionLimit;
76
84
  readonly tags?: readonly string[];
77
85
  }
78
86
  export type ChartSubscriptionInput = ChartSubscription | ChartOpaqueSubscription;
@@ -1,7 +1,7 @@
1
1
  import { type FromTfContext } from "../../engine/pull/context.js";
2
2
  import { type TfBlock, type TfValue } from "../../engine/tf/index.js";
3
3
  import type { Filter } from "../shared/filters/types.js";
4
- import type { ChartProperties } from "./build.js";
4
+ import type { ChartProperties, ChartSubscriptionLimit } from "./build.js";
5
5
  export interface NormalizedChartDatasource {
6
6
  readonly kind: "app" | "element" | "table" | "task";
7
7
  readonly refName: string;
@@ -39,7 +39,7 @@ export interface NormalizedChartSubscription {
39
39
  readonly groupBy?: readonly NormalizedChartGroupBy[];
40
40
  readonly joins?: readonly NormalizedChartJoin[];
41
41
  readonly filter?: Filter<NormalizedChartField, never>;
42
- readonly limit?: string;
42
+ readonly limit?: ChartSubscriptionLimit;
43
43
  readonly tags?: readonly string[];
44
44
  }
45
45
  export interface NormalizedChartOpaqueSubscription {
@@ -213,6 +213,22 @@ function opaqueSubscriptionFromTf(value, where, ctx) {
213
213
  ctx.diagnostics.push(`${where}: preserved UI chart synthetic datasource as an opaque pull-only subscription`);
214
214
  return { kind: "opaque", datasourceId, attributes };
215
215
  }
216
+ /** The platform's Limit scalar, exported as `limit = { count, offset }` (#2291). */
217
+ function limitFromTf(value) {
218
+ const rec = plainObject(value);
219
+ if (rec === undefined)
220
+ return undefined;
221
+ const isCount = (item) => typeof item === "number" && Number.isSafeInteger(item) && item >= 0;
222
+ if (Object.keys(rec).some((key) => key !== "count" && key !== "offset"))
223
+ return undefined;
224
+ const count = rec["count"];
225
+ const offset = rec["offset"];
226
+ if (!isCount(count))
227
+ return undefined;
228
+ if (offset !== undefined && offset !== null && !isCount(offset))
229
+ return undefined;
230
+ return { count, ...(isCount(offset) ? { offset } : {}) };
231
+ }
216
232
  function parseSubscription(value, appLabel, appRefName, ctx, where) {
217
233
  const opaque = opaqueSubscriptionFromTf(value, where, ctx);
218
234
  if (opaque !== undefined)
@@ -320,12 +336,20 @@ function parseSubscription(value, appLabel, appRefName, ctx, where) {
320
336
  return undefined;
321
337
  }
322
338
  }
339
+ let limit;
340
+ if (rec["limit"] !== undefined && rec["limit"] !== null) {
341
+ limit = limitFromTf(rec["limit"]);
342
+ if (limit === undefined) {
343
+ ctx.diagnostics.push(`${where}.limit: expected { count, offset } with non-negative integers; subscription skipped`);
344
+ return undefined;
345
+ }
346
+ }
323
347
  return {
324
348
  datasource, columns,
325
349
  ...(groupBy !== undefined ? { groupBy } : {}),
326
350
  ...(joins !== undefined ? { joins } : {}),
327
351
  ...(filter !== undefined ? { filter } : {}),
328
- ...(typeof rec["limit"] === "string" ? { limit: rec["limit"] } : {}),
352
+ ...(limit !== undefined ? { limit } : {}),
329
353
  ...(stringList(rec["tags"]) !== undefined ? { tags: stringList(rec["tags"]) } : {}),
330
354
  };
331
355
  }
@@ -1,4 +1,4 @@
1
- export { chartAggregation, chartColumnValueType, chartJoin, chartJoinType, chartSubscription, chartType, __pulledChartSubscription, defineChart, type ChartAggregation, type ChartColumn, type ChartColumnValueType, type ChartConfigured, type ChartDatasourceRef, type ChartFieldFor, type ChartGroupBy, type ChartJoin, type ChartJoinType, type ChartOpaqueSubscription, type ChartSubscriptionInput, type ChartProperties, type ChartSubscription, type ChartType, type DefineChartOptions, } from "./build.js";
1
+ export { chartAggregation, chartColumnValueType, chartJoin, chartJoinType, chartSubscription, chartType, __pulledChartSubscription, defineChart, type ChartAggregation, type ChartColumn, type ChartColumnValueType, type ChartConfigured, type ChartDatasourceRef, type ChartFieldFor, type ChartGroupBy, type ChartJoin, type ChartJoinType, type ChartOpaqueSubscription, type ChartSubscriptionInput, type ChartProperties, type ChartSubscription, type ChartSubscriptionLimit, type ChartType, type DefineChartOptions, } from "./build.js";
2
2
  export { dashboardChartWidget, dashboardRecordsWidget, dashboardWidgetSize, type DashboardChartWidget, type DashboardWidgetSize, } from "../dashboard/build.js";
3
3
  export * as filter from "../shared/filters/index.js";
4
4
  export { type Filter } from "../shared/filters/index.js";
@@ -77,8 +77,11 @@ function printSubscription(subscription, keys) {
77
77
  reference: () => { throw new Error("chart pull: filter references are unsupported"); },
78
78
  })},`);
79
79
  }
80
- if (subscription.limit !== undefined)
81
- lines.push(` limit: ${quote(subscription.limit)},`);
80
+ if (subscription.limit !== undefined) {
81
+ // offset 0 is the default, so the source leaves it out.
82
+ const offset = subscription.limit.offset ?? 0;
83
+ lines.push(` limit: { count: ${subscription.limit.count}${offset !== 0 ? `, offset: ${offset}` : ""} },`);
84
+ }
82
85
  if (subscription.tags !== undefined)
83
86
  lines.push(` tags: ${JSON.stringify(subscription.tags)},`);
84
87
  lines.push(" }),");
@@ -166,11 +166,29 @@ function subscriptionToTf(subscription, opts, where) {
166
166
  if (subscription.filter !== undefined)
167
167
  out["filter"] = filterToTf(subscription.filter, datasource, opts, `${where}.filter`);
168
168
  if (subscription.limit !== undefined)
169
- out["limit"] = subscription.limit;
169
+ out["limit"] = limitToTf(subscription.limit, `${where}.limit`);
170
170
  if (subscription.tags !== undefined && subscription.tags.length > 0)
171
171
  out["tags"] = [...subscription.tags];
172
172
  return out;
173
173
  }
174
+ function nonNegativeInteger(value) {
175
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
176
+ }
177
+ /**
178
+ * The platform's Limit scalar is {count, offset}; offset is written even when
179
+ * it is the default 0 so build matches what export writes (#2291).
180
+ */
181
+ function limitToTf(limit, where) {
182
+ if (limit === null || typeof limit !== "object" || Array.isArray(limit)) {
183
+ throw new EntityTfError(`${where}: limit must be { count, offset? }`);
184
+ }
185
+ if (!nonNegativeInteger(limit.count))
186
+ throw new EntityTfError(`${where}.count: must be a non-negative integer`);
187
+ if (limit.offset !== undefined && !nonNegativeInteger(limit.offset)) {
188
+ throw new EntityTfError(`${where}.offset: must be a non-negative integer`);
189
+ }
190
+ return { count: limit.count, offset: limit.offset ?? 0 };
191
+ }
174
192
  function hasSameAppChartWidget(entity, root) {
175
193
  const payload = root.payload;
176
194
  if (payload?.dashboards === undefined)
@@ -4,9 +4,19 @@ import type { NormalizedDashboard } from "../app/deserializer/normalize.js";
4
4
  export interface DashboardOwner {
5
5
  readonly type: "elementum_app" | "elementum_element";
6
6
  readonly label: string;
7
+ /**
8
+ * The owner's TF label (`preston_high`), which its child resource labels
9
+ * carry (`apps_preston_high_preston_high_board`). Never the camelCase ref:
10
+ * the two differ once the label has an underscore (#2046).
11
+ */
7
12
  readonly ownerTfLabel: string;
8
- readonly ownerRefName?: string;
13
+ /** The owner's catalog ref name (`prestonHigh`), for refs printed to source. */
14
+ readonly ownerRefName: string;
9
15
  readonly scope: ChildResourceScope;
10
16
  readonly ownerType: "APP_ASPECT" | "ELEMENT_ASPECT";
17
+ /** The owner's extracted fields, as views get them, so a widget sort's field resolves and fails closed like a view sort's (#1736, #1991). */
18
+ readonly fieldKeys?: ReadonlySet<string>;
19
+ readonly fieldKeysByName?: ReadonlyMap<string, string | null>;
20
+ readonly unextractedFieldIds?: Set<string>;
11
21
  }
12
22
  export declare function dashboardsFromTf(blocks: readonly TfBlock[], widgetBlocks: readonly TfBlock[], owner: DashboardOwner, ctx: FromTfContext): NormalizedDashboard[];
@@ -2,6 +2,7 @@ import { dataRefLabel, optionalString, plainObject, resourceRefLabel } from "../
2
2
  import { reportUnknownAttrs, stringList } from "../../engine/pull/attrs.js";
3
3
  import { isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf/index.js";
4
4
  import { filterFromTf } from "../access-policy/from-tf.js";
5
+ import { filterOwnerForAspect } from "../relationship/from-tf.js";
5
6
  import { filterWireToTf } from "../shared/filters/tf-codec.js";
6
7
  import { DASHBOARD_WIDGET_RESOURCE_TYPE } from "../dashboard-widget/module.js";
7
8
  import { DASHBOARD_RESOURCE_TYPE } from "./module.js";
@@ -72,8 +73,8 @@ function dashboardWidgetsFromTf(blocks, dashboardLabel, dashboardKey, owner, ctx
72
73
  return [];
73
74
  }
74
75
  // The chart's own file is named from the app's TF label, so derive the
75
- // key the same way: owner.ownerTfLabel is the camelCase ref, which
76
- // differs for a namespace with underscores (#1731).
76
+ // key the same way, not from the camelCase ref, which differs for a
77
+ // namespace with underscores (#1731).
77
78
  const chartKey = chartRefNameFromTfLabel(owner.label, chartLabel);
78
79
  // The chart extracts later, as an own-file child. If pull skips it and
79
80
  // no authored file for it is kept, build cannot emit this widget, so
@@ -101,7 +102,13 @@ function dashboardWidgetsFromTf(blocks, dashboardLabel, dashboardKey, owner, ctx
101
102
  let sort;
102
103
  if (aspect["sort"] !== undefined) {
103
104
  const targetsOwner = resourceRefLabel(aspect["aspect_id"], owner.type) === owner.label;
104
- const decoded = managedViewSortFromTf(aspect["sort"], owner, `${where}.aspect_widget.sort`, ctx);
105
+ // Only a sort of the owner's own records names the owner's fields, so
106
+ // only that one checks them against the extracted fields; a foreign
107
+ // target's sort is dropped below either way.
108
+ const sortOwner = targetsOwner
109
+ ? owner
110
+ : { type: owner.type, label: owner.label, ownerTfLabel: owner.ownerTfLabel, ownerRefName: owner.ownerRefName, scope: owner.scope, ownerType: owner.ownerType };
111
+ const decoded = managedViewSortFromTf(aspect["sort"], sortOwner, `${where}.aspect_widget.sort`, ctx);
105
112
  if (decoded !== undefined && !targetsOwner && decoded.orders.length > 0) {
106
113
  ctx.diagnostics.push(`${where}.aspect_widget.sort: ordering a foreign target's records has no typed public contract; sort dropped, widget kept`);
107
114
  }
@@ -111,12 +118,55 @@ function dashboardWidgetsFromTf(blocks, dashboardLabel, dashboardKey, owner, ctx
111
118
  }
112
119
  return [{ ...style, type: "records", target,
113
120
  ...(sort !== undefined && { sort }),
114
- ...(aspect["filter"] !== undefined && {
115
- filter: filterFromTf(filterWireToTf(decodeJson(aspect["filter"])), { ...owner, ownerRefName: owner.ownerRefName ?? owner.ownerTfLabel, foreignFieldRefsById: ctx.foreignFieldRefsById }, `${where}.aspect_widget.filter`, ctx),
116
- }),
121
+ ...(aspect["filter"] !== undefined && { filter: widgetFilterFromTf(aspect["filter"], aspect["aspect_id"], owner, `${where}.aspect_widget.filter`, ctx) }),
117
122
  }];
118
123
  });
119
124
  }
125
+ /**
126
+ * The filter ranges over the target's records, so its fields may belong to
127
+ * the target rather than to the dashboard's owner. A raw field id decodes
128
+ * without throwing even when it is not the owner's field, so a decode that
129
+ * leaves one unresolved is only a fallback.
130
+ */
131
+ function widgetFilterFromTf(raw, aspectId, owner, where, ctx) {
132
+ const wire = filterWireToTf(decodeJson(raw));
133
+ const filterOwners = [{ ...owner, foreignFieldRefsById: ctx.foreignFieldRefsById }];
134
+ const targetOwner = aspectId === undefined || resourceRefLabel(aspectId, owner.type) === owner.label ? undefined : filterOwnerForAspect(aspectId, ctx);
135
+ if (targetOwner !== undefined)
136
+ filterOwners.push(targetOwner);
137
+ let failure;
138
+ let best;
139
+ let bestCount = Number.POSITIVE_INFINITY;
140
+ for (const filterOwner of filterOwners) {
141
+ try {
142
+ const decoded = filterFromTf(wire, filterOwner, where, ctx);
143
+ const unresolved = unresolvedRefCount(decoded);
144
+ if (unresolved === 0)
145
+ return decoded;
146
+ // A target field the owner cannot name is unresolved on every owner
147
+ // decode. One id the target also cannot name must not throw away the
148
+ // fields the target did resolve.
149
+ if (unresolved < bestCount) {
150
+ best = decoded;
151
+ bestCount = unresolved;
152
+ }
153
+ }
154
+ catch (error) {
155
+ failure ??= error;
156
+ }
157
+ }
158
+ if (best !== undefined)
159
+ return best;
160
+ throw failure;
161
+ }
162
+ function unresolvedRefCount(value) {
163
+ if (Array.isArray(value))
164
+ return value.reduce((count, item) => count + unresolvedRefCount(item), 0);
165
+ if (typeof value !== "object" || value === null)
166
+ return 0;
167
+ const self = value.kind === "unresolved" ? 1 : 0;
168
+ return self + Object.values(value).reduce((count, item) => count + unresolvedRefCount(item), 0);
169
+ }
120
170
  /** How an unresolved `chart_id` was exported, for the skipped gap. */
121
171
  function unresolvedChartRef(value) {
122
172
  const dataLabel = dataRefLabel(value, CHART_RESOURCE_TYPE);
@@ -146,7 +196,7 @@ function aspectRef(value, owner, ctx) {
146
196
  if (typeof value === "string")
147
197
  return undefined;
148
198
  if (resourceRefLabel(value, owner.type) === owner.label)
149
- return { kind: owner.scope, key: owner.ownerTfLabel, name: owner.ownerTfLabel };
199
+ return { kind: owner.scope, key: owner.ownerRefName, name: owner.ownerRefName };
150
200
  for (const [type, kind] of [["elementum_app", "app"], ["elementum_element", "element"]]) {
151
201
  const resourceLabel = resourceRefLabel(value, type);
152
202
  if (resourceLabel !== undefined)
@@ -3,6 +3,7 @@ import { workspaceAspectKey } from "../../engine/build/context.js";
3
3
  import { filterToTf } from "../access-policy/to-tf.js";
4
4
  import { filterTfToWire } from "../shared/filters/tf-codec.js";
5
5
  import { DASHBOARD_WIDGET_RESOURCE_TYPE } from "../dashboard-widget/module.js";
6
+ import { targetFilterFieldResolver } from "../relationship/to-tf.js";
6
7
  import { resolveForeignRef } from "../shared/foreign-ref.js";
7
8
  import { DASHBOARD_RESOURCE_TYPE } from "./module.js";
8
9
  import { CHART_RESOURCE_TYPE } from "../chart/types.js";
@@ -51,6 +52,17 @@ export function dashboardsToTf(dashboards, opts) {
51
52
  continue;
52
53
  const body = { aspect_id: aspectId };
53
54
  if (widget.filter !== undefined) {
55
+ const foreignField = typeof widget.target === "object" && opts.orgRefs !== undefined && !targetsOwner(widget.target, opts)
56
+ ? targetFilterFieldResolver(widget.target, `${where}.target`, {
57
+ ownerRefName: opts.ownerRefName ?? opts.ownerTfLabel,
58
+ ownerTfLabel: opts.ownerTfLabel,
59
+ scope: opts.scope,
60
+ objectId: opts.ownerId,
61
+ orgRefs: opts.orgRefs,
62
+ ...(opts.workspaceAspects !== undefined && { workspaceAspects: opts.workspaceAspects }),
63
+ diagnostics: opts.diagnostics,
64
+ })
65
+ : undefined;
54
66
  const hclFilter = filterToTf(widget.filter, `${where}.filter`, {
55
67
  ownerTfLabel: opts.ownerTfLabel,
56
68
  appRefName: opts.ownerRefName,
@@ -58,6 +70,7 @@ export function dashboardsToTf(dashboards, opts) {
58
70
  objectId: opts.ownerId,
59
71
  diagnostics: opts.diagnostics,
60
72
  orgRefs: opts.orgRefs,
73
+ ...(foreignField !== undefined && { foreignField }),
61
74
  });
62
75
  body["filter"] = expr.jsonencode(filterTfToWire(hclFilter));
63
76
  }