@elementumai/edk 0.11.0 → 0.13.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 (222) hide show
  1. package/README.md +40 -6
  2. package/dist-sdk/src/catalog/factories.d.ts +7 -1
  3. package/dist-sdk/src/catalog/factories.js +2 -0
  4. package/dist-sdk/src/catalog/index.d.ts +2 -2
  5. package/dist-sdk/src/catalog/index.js +1 -1
  6. package/dist-sdk/src/catalog/org.js +79 -34
  7. package/dist-sdk/src/catalog/token.js +5 -0
  8. package/dist-sdk/src/catalog/types.d.ts +7 -1
  9. package/dist-sdk/src/catalog/types.js +3 -0
  10. package/dist-sdk/src/core/system-fields.d.ts +1 -1
  11. package/dist-sdk/src/core/system-fields.js +1 -1
  12. package/dist-sdk/src/core/triggers/on-demand.d.ts +2 -0
  13. package/dist-sdk/src/core/triggers/on-demand.js +3 -0
  14. package/dist-sdk/src/core/types/app.d.ts +6 -0
  15. package/dist-sdk/src/engine/build/context.d.ts +3 -0
  16. package/dist-sdk/src/engine/coverage-gaps.d.ts +5 -0
  17. package/dist-sdk/src/engine/coverage-gaps.js +9 -0
  18. package/dist-sdk/src/engine/ei/run.d.ts +20 -1
  19. package/dist-sdk/src/engine/ei/run.js +102 -14
  20. package/dist-sdk/src/engine/pull/authored-address.js +42 -6
  21. package/dist-sdk/src/engine/pull/authored-root.d.ts +88 -0
  22. package/dist-sdk/src/engine/pull/authored-root.js +306 -0
  23. package/dist-sdk/src/engine/pull/context.d.ts +10 -0
  24. package/dist-sdk/src/engine/pull/field-refs-registry.d.ts +114 -0
  25. package/dist-sdk/src/engine/pull/field-refs-registry.js +501 -0
  26. package/dist-sdk/src/engine/pull/org.d.ts +1 -0
  27. package/dist-sdk/src/engine/pull/org.js +2 -0
  28. package/dist-sdk/src/engine/pull/partition.d.ts +8 -0
  29. package/dist-sdk/src/engine/pull/partition.js +43 -0
  30. package/dist-sdk/src/engine/pull/pulled-roots.d.ts +89 -0
  31. package/dist-sdk/src/engine/pull/pulled-roots.js +203 -0
  32. package/dist-sdk/src/engine/pull/ref-only.d.ts +22 -0
  33. package/dist-sdk/src/engine/pull/ref-only.js +59 -1
  34. package/dist-sdk/src/engine/pull/source-resources.d.ts +39 -0
  35. package/dist-sdk/src/engine/pull/source-resources.js +110 -0
  36. package/dist-sdk/src/engine/pull/stream-root.d.ts +148 -0
  37. package/dist-sdk/src/engine/pull/stream-root.js +563 -0
  38. package/dist-sdk/src/engine/workspace/reserved-catalog-keys.d.ts +47 -0
  39. package/dist-sdk/src/engine/workspace/reserved-catalog-keys.js +115 -0
  40. package/dist-sdk/src/entities/access-policy/build.d.ts +2 -1
  41. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +9 -1
  42. package/dist-sdk/src/entities/access-policy/from-tf.js +25 -4
  43. package/dist-sdk/src/entities/access-policy/module.js +5 -0
  44. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +19 -0
  45. package/dist-sdk/src/entities/access-policy/to-tf.js +65 -8
  46. package/dist-sdk/src/entities/agent/build.d.ts +52 -1
  47. package/dist-sdk/src/entities/agent/build.js +34 -0
  48. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +68 -0
  49. package/dist-sdk/src/entities/agent/from-tf.d.ts +34 -1
  50. package/dist-sdk/src/entities/agent/from-tf.js +262 -2
  51. package/dist-sdk/src/entities/agent/index.d.ts +1 -1
  52. package/dist-sdk/src/entities/agent/to-tf.d.ts +8 -10
  53. package/dist-sdk/src/entities/agent/to-tf.js +158 -14
  54. package/dist-sdk/src/entities/agent-tool/from-tf.js +6 -0
  55. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -2
  56. package/dist-sdk/src/entities/agent-tool/to-tf.js +2 -2
  57. package/dist-sdk/src/entities/app/build.d.ts +34 -14
  58. package/dist-sdk/src/entities/app/build.js +93 -16
  59. package/dist-sdk/src/entities/app/from-tf.js +25 -11
  60. package/dist-sdk/src/entities/app/index.d.ts +1 -0
  61. package/dist-sdk/src/entities/app/index.js +1 -0
  62. package/dist-sdk/src/entities/app/module.js +1 -0
  63. package/dist-sdk/src/entities/app/stage-keys.d.ts +20 -5
  64. package/dist-sdk/src/entities/app/stage-keys.js +43 -9
  65. package/dist-sdk/src/entities/app/to-tf.js +2 -0
  66. package/dist-sdk/src/entities/approval-chain/build.d.ts +46 -11
  67. package/dist-sdk/src/entities/approval-chain/build.js +120 -8
  68. package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +24 -2
  69. package/dist-sdk/src/entities/approval-chain/from-tf.js +148 -6
  70. package/dist-sdk/src/entities/approval-chain/index.d.ts +4 -1
  71. package/dist-sdk/src/entities/approval-chain/index.js +4 -1
  72. package/dist-sdk/src/entities/approval-chain/module.js +23 -5
  73. package/dist-sdk/src/entities/approval-chain/printer.d.ts +1 -1
  74. package/dist-sdk/src/entities/approval-chain/printer.js +91 -5
  75. package/dist-sdk/src/entities/approval-chain/steps-tf.d.ts +77 -0
  76. package/dist-sdk/src/entities/approval-chain/steps-tf.js +255 -0
  77. package/dist-sdk/src/entities/approval-chain/steps.d.ts +71 -0
  78. package/dist-sdk/src/entities/approval-chain/steps.js +83 -0
  79. package/dist-sdk/src/entities/approval-chain/to-tf.d.ts +16 -6
  80. package/dist-sdk/src/entities/approval-chain/to-tf.js +37 -4
  81. package/dist-sdk/src/entities/automation/build.d.ts +50 -24
  82. package/dist-sdk/src/entities/automation/build.js +86 -33
  83. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +52 -8
  84. package/dist-sdk/src/entities/automation/from-tf.d.ts +38 -6
  85. package/dist-sdk/src/entities/automation/from-tf.js +855 -157
  86. package/dist-sdk/src/entities/automation/index.d.ts +2 -1
  87. package/dist-sdk/src/entities/automation/index.js +1 -0
  88. package/dist-sdk/src/entities/automation/module.d.ts +4 -3
  89. package/dist-sdk/src/entities/automation/module.js +33 -12
  90. package/dist-sdk/src/entities/automation/refs-read.d.ts +19 -0
  91. package/dist-sdk/src/entities/automation/refs-read.js +48 -0
  92. package/dist-sdk/src/entities/automation/run-target.d.ts +2 -0
  93. package/dist-sdk/src/entities/automation/run-target.js +5 -0
  94. package/dist-sdk/src/entities/automation/script-code.d.ts +2 -1
  95. package/dist-sdk/src/entities/automation/script-code.js +82 -1
  96. package/dist-sdk/src/entities/automation/script-lint.d.ts +13 -0
  97. package/dist-sdk/src/entities/automation/script-lint.js +418 -0
  98. package/dist-sdk/src/entities/automation/slack-message-refs.d.ts +9 -0
  99. package/dist-sdk/src/entities/automation/slack-message-refs.js +75 -0
  100. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +12 -1
  101. package/dist-sdk/src/entities/automation/task-output-labels.js +32 -1
  102. package/dist-sdk/src/entities/automation/tasks.d.ts +76 -18
  103. package/dist-sdk/src/entities/automation/tasks.js +52 -15
  104. package/dist-sdk/src/entities/automation/to-tf.d.ts +3 -0
  105. package/dist-sdk/src/entities/automation/to-tf.js +585 -97
  106. package/dist-sdk/src/entities/automation/triggers.d.ts +48 -23
  107. package/dist-sdk/src/entities/automation/triggers.js +27 -12
  108. package/dist-sdk/src/entities/automation/unsafe-script-output.d.ts +50 -0
  109. package/dist-sdk/src/entities/automation/unsafe-script-output.js +92 -0
  110. package/dist-sdk/src/entities/chart/build.d.ts +18 -2
  111. package/dist-sdk/src/entities/chart/from-tf.d.ts +2 -2
  112. package/dist-sdk/src/entities/chart/from-tf.js +28 -1
  113. package/dist-sdk/src/entities/chart/index.d.ts +1 -1
  114. package/dist-sdk/src/entities/chart/printer.js +5 -2
  115. package/dist-sdk/src/entities/chart/to-tf.js +38 -3
  116. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +3 -0
  117. package/dist-sdk/src/entities/dynamic-layout/condition-keys.d.ts +48 -0
  118. package/dist-sdk/src/entities/dynamic-layout/condition-keys.js +261 -0
  119. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +45 -6
  120. package/dist-sdk/src/entities/dynamic-layout/module.js +2 -1
  121. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +46 -12
  122. package/dist-sdk/src/entities/element/audit-field-guard.d.ts +9 -0
  123. package/dist-sdk/src/entities/element/audit-field-guard.js +88 -0
  124. package/dist-sdk/src/entities/element/build.js +2 -1
  125. package/dist-sdk/src/entities/element/from-tf.js +15 -2
  126. package/dist-sdk/src/entities/element/module.js +3 -0
  127. package/dist-sdk/src/entities/element/system-fields.d.ts +13 -0
  128. package/dist-sdk/src/entities/element/system-fields.js +23 -0
  129. package/dist-sdk/src/entities/element/to-tf.js +2 -0
  130. package/dist-sdk/src/entities/field/build.d.ts +9 -0
  131. package/dist-sdk/src/entities/field/from-tf.d.ts +29 -1
  132. package/dist-sdk/src/entities/field/from-tf.js +99 -6
  133. package/dist-sdk/src/entities/field/module.js +12 -2
  134. package/dist-sdk/src/entities/field/to-tf.d.ts +13 -3
  135. package/dist-sdk/src/entities/field/to-tf.js +90 -46
  136. package/dist-sdk/src/entities/org/category.js +1 -0
  137. package/dist-sdk/src/entities/org/index.d.ts +1 -0
  138. package/dist-sdk/src/entities/org/index.js +1 -0
  139. package/dist-sdk/src/entities/org/role.js +5 -0
  140. package/dist-sdk/src/entities/org/voice-auth.d.ts +5 -0
  141. package/dist-sdk/src/entities/org/voice-auth.js +33 -0
  142. package/dist-sdk/src/entities/organization/build.d.ts +3 -0
  143. package/dist-sdk/src/entities/organization/build.js +2 -0
  144. package/dist-sdk/src/entities/organization/index.d.ts +1 -0
  145. package/dist-sdk/src/entities/organization/index.js +1 -0
  146. package/dist-sdk/src/entities/organization/to-tf.d.ts +2 -0
  147. package/dist-sdk/src/entities/organization/to-tf.js +59 -1
  148. package/dist-sdk/src/entities/organization/voice-auth.d.ts +60 -0
  149. package/dist-sdk/src/entities/organization/voice-auth.js +60 -0
  150. package/dist-sdk/src/entities/phone-service/build.d.ts +9 -1
  151. package/dist-sdk/src/entities/phone-service/build.js +1 -0
  152. package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.js +3 -0
  153. package/dist-sdk/src/entities/phone-service/from-tf.d.ts +1 -0
  154. package/dist-sdk/src/entities/phone-service/from-tf.js +8 -1
  155. package/dist-sdk/src/entities/phone-service/to-tf.js +16 -0
  156. package/dist-sdk/src/entities/record-create-form/from-tf.js +2 -2
  157. package/dist-sdk/src/entities/relationship/from-tf.js +7 -2
  158. package/dist-sdk/src/entities/relationship/module.js +2 -2
  159. package/dist-sdk/src/entities/relationship/pair-check.d.ts +6 -2
  160. package/dist-sdk/src/entities/relationship/pair-check.js +105 -18
  161. package/dist-sdk/src/entities/relationship/to-tf.js +5 -2
  162. package/dist-sdk/src/entities/role/permission-levels.d.ts +7 -0
  163. package/dist-sdk/src/entities/role/permission-levels.js +78 -0
  164. package/dist-sdk/src/entities/role/to-tf.js +32 -2
  165. package/dist-sdk/src/entities/service-account/module.d.ts +2 -1
  166. package/dist-sdk/src/entities/service-account/module.js +9 -1
  167. package/dist-sdk/src/entities/service-account/resource-type.d.ts +2 -0
  168. package/dist-sdk/src/entities/service-account/resource-type.js +2 -0
  169. package/dist-sdk/src/entities/service-account/role-fidelity.d.ts +5 -5
  170. package/dist-sdk/src/entities/service-account/role-fidelity.js +21 -13
  171. package/dist-sdk/src/entities/service-account/role-membership-check.d.ts +20 -0
  172. package/dist-sdk/src/entities/service-account/role-membership-check.js +80 -0
  173. package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +15 -0
  174. package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +36 -0
  175. package/dist-sdk/src/entities/shared/filters/ast.d.ts +4 -0
  176. package/dist-sdk/src/entities/shared/filters/index.d.ts +85 -14
  177. package/dist-sdk/src/entities/shared/filters/index.js +18 -6
  178. package/dist-sdk/src/entities/shared/filters/option-lookups.d.ts +57 -0
  179. package/dist-sdk/src/entities/shared/filters/option-lookups.js +108 -0
  180. package/dist-sdk/src/entities/shared/filters/print.js +9 -5
  181. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +12 -7
  182. package/dist-sdk/src/entities/shared/filters/tf-codec.js +9 -5
  183. package/dist-sdk/src/entities/shared/raw-option-id.d.ts +30 -0
  184. package/dist-sdk/src/entities/shared/raw-option-id.js +41 -0
  185. package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -2
  186. package/dist-sdk/src/entities/shared/types/field-types.d.ts +6 -3
  187. package/dist-sdk/src/entities/shared/types/field-types.js +3 -1
  188. package/dist-sdk/src/entities/skill/input-coverage.js +5 -2
  189. package/dist-sdk/src/entities/skill/module.js +2 -0
  190. package/dist-sdk/src/entities/sla/build.d.ts +96 -0
  191. package/dist-sdk/src/entities/sla/build.js +124 -0
  192. package/dist-sdk/src/entities/sla/from-tf.d.ts +40 -0
  193. package/dist-sdk/src/entities/sla/from-tf.js +164 -0
  194. package/dist-sdk/src/entities/sla/index.d.ts +1 -0
  195. package/dist-sdk/src/entities/sla/index.js +1 -0
  196. package/dist-sdk/src/entities/sla/module.d.ts +4 -0
  197. package/dist-sdk/src/entities/sla/module.js +73 -0
  198. package/dist-sdk/src/entities/sla/printer.d.ts +2 -0
  199. package/dist-sdk/src/entities/sla/printer.js +84 -0
  200. package/dist-sdk/src/entities/sla/to-tf.d.ts +12 -0
  201. package/dist-sdk/src/entities/sla/to-tf.js +81 -0
  202. package/dist-sdk/src/entities/table/build.d.ts +7 -2
  203. package/dist-sdk/src/entities/table/build.js +22 -1
  204. package/dist-sdk/src/entities/table/deserializer/normalize.d.ts +4 -1
  205. package/dist-sdk/src/entities/table/from-tf.js +89 -14
  206. package/dist-sdk/src/entities/table/index.d.ts +1 -1
  207. package/dist-sdk/src/entities/table/to-tf.js +41 -2
  208. package/dist-sdk/src/entities/task/from-tf.js +2 -1
  209. package/dist-sdk/src/entities/task/to-tf.js +1 -0
  210. package/dist-sdk/src/entities/view/from-tf.d.ts +8 -4
  211. package/dist-sdk/src/entities/view/from-tf.js +10 -9
  212. package/dist-sdk/src/entities/view/module.js +5 -0
  213. package/dist-sdk/src/entities/widget/from-tf.js +15 -4
  214. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +51 -4
  215. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
  216. package/dist-sdk/src/graph/index.d.ts +20 -2
  217. package/dist-sdk/src/graph/index.js +19 -0
  218. package/dist-sdk/src/graph/modules.js +11 -1
  219. package/dist-sdk/src/graph/resource-types.d.ts +47 -0
  220. package/dist-sdk/src/graph/resource-types.js +62 -0
  221. package/dist-sdk/src/graph/types.d.ts +116 -6
  222. package/package.json +6 -3
@@ -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>>;
@@ -114,8 +118,12 @@ export interface TemporalTriggerOptions<A extends AppOrElementRef = AppOrElement
114
118
  readonly field: FieldRef;
115
119
  readonly temporalUnit: TemporalUnit;
116
120
  readonly value: number;
117
- /** Pre-built wire `Filter` (may embed `FieldRef` tokens — resolved at deploy). */
118
- readonly filter?: Filter;
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;
119
127
  }
120
128
  /** Fires relative to a date/datetime field on records in the given aspect. */
121
129
  export declare function temporal<A extends AppOrElementRef>(opts: TemporalTriggerOptions<A>): TriggerChain<RecordTriggerOutput<A>>;
@@ -134,14 +142,22 @@ export interface approvalProcessStatusUpdatedTriggerOptions<A extends AppOrEleme
134
142
  */
135
143
  readonly approvalChain?: ApprovalChainRef | UnsafePlatformId;
136
144
  readonly status: approvalProcessStatusUpdatedStatus;
137
- /** Record filter the approval-chain trigger additionally requires. */
138
- 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;
139
151
  }
140
152
  /** Fires when an approval chain on a record changes to the configured status. */
141
153
  export declare function approvalProcessStatusUpdated<A extends AppOrElementRef>(opts: approvalProcessStatusUpdatedTriggerOptions<A>): TriggerChain<RecordTriggerOutput<A>>;
142
154
  export interface AttachmentTriggerOptions<A extends AppOrElementRef = AppOrElementRef> {
143
155
  readonly app: A;
144
- 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;
145
161
  readonly thinkUi?: boolean;
146
162
  }
147
163
  export interface AttachmentTriggerOutput<A extends AppOrElementRef = AppOrElementRef> {
@@ -168,10 +184,11 @@ export interface DataMineTriggerOptions {
168
184
  readonly fireOnRecovery?: boolean;
169
185
  /**
170
186
  * Trigger Condition: the datamine's records must also match it (edk#2287).
171
- * Column references must be columns of the datamine's own table. Leaving it
172
- * out means no condition, the same as the platform's `filter: null`.
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`).
173
190
  */
174
- readonly filter?: Filter;
191
+ readonly filter?: Filter | null;
175
192
  }
176
193
  export interface DataMineTriggerOutput {
177
194
  readonly record: Record<string, unknown>;
@@ -196,9 +213,17 @@ export interface EmailReceivedTriggerOutput {
196
213
  export declare function emailReceived(opts: EmailReceivedTriggerOptions): TriggerChain<EmailReceivedTriggerOutput>;
197
214
  export interface CommentAddedTriggerOptions<A extends AppOrElementRef = AppOrElementRef> {
198
215
  readonly app: A;
199
- /** 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
+ */
200
221
  readonly conversationType: string;
201
- 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;
202
227
  }
203
228
  export interface CommentAddedTriggerOutput<A extends AppOrElementRef = AppOrElementRef> {
204
229
  readonly record: RecordShape<A>;
@@ -211,7 +236,11 @@ export type ConversationEndConversationType = "A2A" | "ELEMENTUM_UI" | "VOICE" |
211
236
  export interface ConversationEndTriggerOptions<A extends AppOrElementRef = AppOrElementRef> {
212
237
  readonly app: A;
213
238
  readonly conversationType: ConversationEndConversationType;
214
- 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;
215
244
  }
216
245
  export interface ConversationEndTriggerOutput<A extends AppOrElementRef = AppOrElementRef> {
217
246
  readonly record: RecordShape<A>;
@@ -231,14 +260,6 @@ export interface SlackMessageTriggerOutput {
231
260
  readonly content: string;
232
261
  readonly messageId: string;
233
262
  readonly meta: Record<string, unknown>;
234
- /** Compatibility aliases retained for existing automations. */
235
- readonly slackThreadId: string;
236
- readonly slackChannelId: string;
237
- readonly messageAuthorEmail: string;
238
- readonly messageAuthorId: string;
239
- readonly messageAuthorName: string;
240
- readonly messageContent: string;
241
- readonly messageMetadata: Record<string, unknown>;
242
263
  }
243
264
  /** Fires when a Slack message is received. */
244
265
  export declare function slackMessage(): TriggerChain<SlackMessageTriggerOutput>;
@@ -249,8 +270,12 @@ export interface SurveyResponseCreateTriggerOptions {
249
270
  * explicit wrapper marks this platform-owned value as non-portable.
250
271
  */
251
272
  readonly survey: UnsafePlatformId;
252
- /** Trigger Condition: the record the survey was completed for must match it (edk#2206). */
253
- readonly filter?: Filter;
273
+ /**
274
+ * Trigger Condition: the record the survey was completed for must match it (edk#2206).
275
+ * Leaving it out and `null` mean the same thing: no condition.
276
+ * On update, either one removes a condition the trigger had (apply sends `filter: null`).
277
+ */
278
+ readonly filter?: Filter | null;
254
279
  }
255
280
  export type SurveyResponseCreateTriggerOutput = Record<string, unknown>;
256
281
  /** Fires when a response is created for the selected survey template. */
@@ -1,21 +1,36 @@
1
1
  import { EdkValidationError } from "../../../elementum-entity-client/errors.js";
2
2
  import { serializeOnDemandTrigger, } from "../../core/triggers/on-demand.js";
3
3
  import { chainableTrigger } from "./build.js";
4
- function recordTriggerFields(opts) {
4
+ function recordTriggerFields(trigger, opts) {
5
5
  return {
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
+ ...triggerFilterField(trigger, opts.filter),
10
10
  };
11
11
  }
12
+ /**
13
+ * The `filter` key of a trigger's wire input. A top-level `filter.whereTrue()`
14
+ * is rejected here, at build: the platform stores a trigger filter that matches
15
+ * every record as no filter (and sends no `not` for TRUE), so the next read comes
16
+ * back with no filter and every plan adds it again (#2514).
17
+ */
18
+ function triggerFilterField(trigger, filter) {
19
+ if (filter === undefined || filter === null)
20
+ return {};
21
+ if (String(filter.type).toUpperCase() === "TRUE") {
22
+ throw new EdkValidationError(`${trigger} filter: filter.whereTrue() matches every record, and the platform stores it as no filter, ` +
23
+ "so every plan would add it again. Leave filter out to fire on every record.");
24
+ }
25
+ return { filter };
26
+ }
12
27
  /** Fires when a record is created on the given aspect. */
13
28
  export function recordCreated(opts) {
14
- return chainableTrigger({ wire: { createRecord: recordTriggerFields(opts) }, __recordApp: opts.app.refName });
29
+ return chainableTrigger({ wire: { createRecord: recordTriggerFields("recordCreated", opts) }, __recordApp: opts.app.refName });
15
30
  }
16
31
  /** Fires when a record is updated on the given aspect. */
17
32
  export function recordUpdated(opts) {
18
- return chainableTrigger({ wire: { updateRecord: recordTriggerFields(opts) }, __recordApp: opts.app.refName });
33
+ return chainableTrigger({ wire: { updateRecord: recordTriggerFields("recordUpdated", opts) }, __recordApp: opts.app.refName });
19
34
  }
20
35
  function buildRrule(opts) {
21
36
  const parts = [`FREQ=${opts.frequency}`];
@@ -105,7 +120,7 @@ export function temporal(opts) {
105
120
  aspectFieldId: opts.field,
106
121
  temporalUnit: opts.temporalUnit,
107
122
  value: opts.value,
108
- ...(opts.filter !== undefined ? { filter: opts.filter } : {}),
123
+ ...triggerFilterField("temporal", opts.filter),
109
124
  type: "TEMPORAL",
110
125
  },
111
126
  },
@@ -120,7 +135,7 @@ export function approvalProcessStatusUpdated(opts) {
120
135
  aspectId: opts.app,
121
136
  ...(opts.approvalChain !== undefined ? { approvalChainTemplateId: opts.approvalChain } : {}),
122
137
  status: opts.status,
123
- ...(opts.filter !== undefined ? { filter: opts.filter } : {}),
138
+ ...triggerFilterField("approvalProcessStatusUpdated", opts.filter),
124
139
  type: "APPROVAL_CHAIN_UPDATE",
125
140
  },
126
141
  },
@@ -134,7 +149,7 @@ export function attachment(opts) {
134
149
  attachment: {
135
150
  aspectId: opts.app,
136
151
  type: "ATTACHMENT_UPDATE",
137
- ...(opts.filter !== undefined ? { filter: opts.filter } : {}),
152
+ ...triggerFilterField("attachment", opts.filter),
138
153
  ...(opts.thinkUi !== undefined ? { thinkUi: opts.thinkUi } : {}),
139
154
  },
140
155
  },
@@ -177,7 +192,7 @@ function assertDataMineFilterOnDatamineTable(datamine, condition) {
177
192
  }
178
193
  /** Fires when a data mine meets/no longer meets requirements. */
179
194
  export function dataMine(opts) {
180
- if (opts.filter !== undefined)
195
+ if (opts.filter !== undefined && opts.filter !== null)
181
196
  assertDataMineFilterOnDatamineTable(opts.datamine, opts.filter);
182
197
  return chainableTrigger({
183
198
  wire: {
@@ -186,7 +201,7 @@ export function dataMine(opts) {
186
201
  type: "DATAMINE",
187
202
  ...(opts.fireOnAlert !== undefined ? { fireOnAlert: opts.fireOnAlert } : {}),
188
203
  ...(opts.fireOnRecovery !== undefined ? { fireOnRecovery: opts.fireOnRecovery } : {}),
189
- ...(opts.filter !== undefined ? { filter: opts.filter } : {}),
204
+ ...triggerFilterField("dataMine", opts.filter),
190
205
  },
191
206
  },
192
207
  });
@@ -209,7 +224,7 @@ export function commentAdded(opts) {
209
224
  commentAdded: {
210
225
  aspectId: opts.app,
211
226
  conversationType: opts.conversationType,
212
- ...(opts.filter !== undefined ? { filter: opts.filter } : {}),
227
+ ...triggerFilterField("commentAdded", opts.filter),
213
228
  },
214
229
  },
215
230
  __recordApp: opts.app.refName,
@@ -223,7 +238,7 @@ export function conversationEnd(opts) {
223
238
  aspectId: opts.app,
224
239
  conversationType: opts.conversationType,
225
240
  type: "CONVERSATION_END",
226
- ...(opts.filter !== undefined ? { filter: opts.filter } : {}),
241
+ ...triggerFilterField("conversationEnd", opts.filter),
227
242
  },
228
243
  },
229
244
  __recordApp: opts.app.refName,
@@ -246,7 +261,7 @@ export function surveyResponseCreate(opts) {
246
261
  survey: {
247
262
  aspectId: opts.app,
248
263
  surveyTemplateId: opts.survey,
249
- ...(opts.filter !== undefined ? { filter: opts.filter } : {}),
264
+ ...triggerFilterField("surveyResponseCreate", opts.filter),
250
265
  type: "SURVEY_RESPONSE_CREATE",
251
266
  },
252
267
  },
@@ -0,0 +1,50 @@
1
+ import { type Ref } from "../shared/ref.js";
2
+ /**
3
+ * Read an executeScript output that the script's `outputs` schema doesn't
4
+ * declare. Pull prints this for a live automation that still references such
5
+ * an output, so the reference round-trips unchanged (#1725).
6
+ *
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.
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * condition: filter.eq(filter.text(unsafeScriptOutput(ctx.actions.RESOLVE_IDS, "legacyFlag")), "yes"),
17
+ * ```
18
+ */
19
+ export declare function unsafeScriptOutput(script: {
20
+ readonly result: unknown;
21
+ readonly textResult: unknown;
22
+ readonly stringArrayResult: unknown;
23
+ readonly numberArrayResult: unknown;
24
+ }, output: string): Ref<unknown>;
25
+ /** Member access for each `.`-separated segment of an output path. */
26
+ export declare function memberPath(path: string): string;
27
+ /** `ctx.actions.<script>` as valid TypeScript for any action name. */
28
+ export declare function scriptActionAccess(taskRefKey: string | undefined): string;
29
+ /**
30
+ * How a reference position treats a `result.<prop>` that the script's
31
+ * output schema doesn't declare (#1725):
32
+ * - `reject`: task inputs read the refs map, which holds only declared outputs.
33
+ * - `unsafeOnly`: filters reject it unless it is wrapped in
34
+ * {@link unsafeScriptOutput}, the form pull prints for a live dangling
35
+ * reference (#1151). to-tf keeps that envelope and emits a diagnostic.
36
+ * - `allow`: workflow outputs and field assignments rebuild it as a value envelope.
37
+ */
38
+ export type UndeclaredScriptResult = "reject" | "unsafeOnly" | "allow";
39
+ /**
40
+ * Unwrap an {@link unsafeScriptOutput} reference name to its
41
+ * `result.<output>`, checking that it names an undeclared output of an
42
+ * executeScript task at a position that can carry one. Build finalize calls
43
+ * this on every task reference; any other name comes back unchanged.
44
+ * `declared` is the script's top-level output names, `undefined` when it has
45
+ * no schema.
46
+ */
47
+ export declare function unwrapUnsafeScriptOutput(rawName: string, taskKey: string | undefined, taskRefKey: string, declared: ReadonlySet<string> | undefined, undeclared: UndeclaredScriptResult): {
48
+ readonly name: string;
49
+ readonly unsafe: boolean;
50
+ };
@@ -0,0 +1,92 @@
1
+ import { EdkValidationError } from "../../../elementum-entity-client/errors.js";
2
+ import { EntityTfError } from "../../engine/entity.js";
3
+ import { createRef, isRef } from "../shared/ref.js";
4
+ /**
5
+ * Prefix on the task-reference name of an {@link unsafeScriptOutput} ref.
6
+ * Build finalize (`rewriteTaskOutputRefs` in `build.ts`) strips it before
7
+ * anything reads the name, so it never reaches HCL or the wire.
8
+ */
9
+ const UNSAFE_SCRIPT_OUTPUT_MARKER = "__edkUnsafeScriptOutput::";
10
+ /**
11
+ * Read an executeScript output that the script's `outputs` schema doesn't
12
+ * declare. Pull prints this for a live automation that still references such
13
+ * an output, so the reference round-trips unchanged (#1725).
14
+ *
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.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * condition: filter.eq(filter.text(unsafeScriptOutput(ctx.actions.RESOLVE_IDS, "legacyFlag")), "yes"),
25
+ * ```
26
+ */
27
+ export function unsafeScriptOutput(script, output) {
28
+ const result = script?.result;
29
+ if (!isRef(result) || result.__data.kind !== "task" || result.__data.name !== "result") {
30
+ throw new EdkValidationError("unsafeScriptOutput() takes an executeScript action, such as ctx.actions.<script>.");
31
+ }
32
+ if (typeof output !== "string" || output === "" || output.split(".").some((segment) => segment === "")) {
33
+ throw new EdkValidationError(`unsafeScriptOutput() needs an output name such as "flag" or "obj.child"; got ${JSON.stringify(output)}.`);
34
+ }
35
+ return createRef({
36
+ kind: "task",
37
+ actionRefKey: result.__data.actionRefKey,
38
+ name: `${UNSAFE_SCRIPT_OUTPUT_MARKER}result.${output}`,
39
+ });
40
+ }
41
+ const RESERVED_IDENT = new Set([
42
+ "break", "case", "catch", "class", "const", "continue", "debugger", "default",
43
+ "delete", "do", "else", "export", "extends", "false", "finally", "for",
44
+ "function", "if", "import", "in", "instanceof", "new", "null", "return",
45
+ "super", "switch", "this", "throw", "true", "try", "typeof", "var", "void",
46
+ "while", "with", "yield",
47
+ ]);
48
+ /**
49
+ * `.name` when `name` is a plain identifier, else `["name"]`: the same rule
50
+ * the pull printer's `safeMember` uses, so a suggested fix in an error
51
+ * message is valid TypeScript for names such as `"Resolve IDs"`.
52
+ */
53
+ function member(name) {
54
+ return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name) && !RESERVED_IDENT.has(name) ? `.${name}` : `[${JSON.stringify(name)}]`;
55
+ }
56
+ /** Member access for each `.`-separated segment of an output path. */
57
+ export function memberPath(path) {
58
+ return path.split(".").map(member).join("");
59
+ }
60
+ /** `ctx.actions.<script>` as valid TypeScript for any action name. */
61
+ export function scriptActionAccess(taskRefKey) {
62
+ return taskRefKey === undefined ? "ctx.actions.<script>" : `ctx.actions${member(taskRefKey)}`;
63
+ }
64
+ /**
65
+ * Unwrap an {@link unsafeScriptOutput} reference name to its
66
+ * `result.<output>`, checking that it names an undeclared output of an
67
+ * executeScript task at a position that can carry one. Build finalize calls
68
+ * this on every task reference; any other name comes back unchanged.
69
+ * `declared` is the script's top-level output names, `undefined` when it has
70
+ * no schema.
71
+ */
72
+ export function unwrapUnsafeScriptOutput(rawName, taskKey, taskRefKey, declared, undeclared) {
73
+ if (!rawName.startsWith(UNSAFE_SCRIPT_OUTPUT_MARKER))
74
+ return { name: rawName, unsafe: false };
75
+ const name = rawName.slice(UNSAFE_SCRIPT_OUTPUT_MARKER.length);
76
+ const output = name.slice("result.".length);
77
+ const at = scriptActionAccess(taskRefKey);
78
+ const read = `${at}.result${memberPath(output)}`;
79
+ const call = `unsafeScriptOutput(${at}, ${JSON.stringify(output)})`;
80
+ if (taskKey !== "executeScript") {
81
+ throw new EntityTfError(`${call} only reads executeScript outputs; "${taskRefKey}" is ${taskKey === undefined ? "not a task in this automation" : `a ${taskKey} task`}.`);
82
+ }
83
+ // A marker on a declared output is allowed (Dax, #2221 Q1) and builds the
84
+ // same reference as the plain read, so it is checked like one.
85
+ if (declared?.has(output.split(".")[0] ?? "") === true)
86
+ return { name, unsafe: false };
87
+ if (undeclared === "reject") {
88
+ throw new EntityTfError(`${call} can't be used in a task input: inputs read the script's refs map, which holds only declared outputs. ` +
89
+ `Add ${JSON.stringify(output)} to the script's outputs and read ${read}.`);
90
+ }
91
+ return { name, unsafe: true };
92
+ }
@@ -1,6 +1,7 @@
1
1
  import { type AppCatalogRef, type AppOrElementOrTaskRef, type ChartRef, type FieldRef, type TableColumnRef, type TableRef } from "../../catalog/index.js";
2
2
  import type { DeployableEntity, EntityDeployOptions } from "../../engine/entity.js";
3
3
  import type { Filter } from "../shared/filters/types.js";
4
+ import type { FilterFieldToken } from "../shared/filters/index.js";
4
5
  import type { UnsafePlatformId } from "../../core/platform-id.js";
5
6
  import type { ChartAggregation, ChartColumnValueType, ChartJoinType, ChartType } from "./types.js";
6
7
  export { chartAggregation, chartColumnValueType, chartJoinType, chartType, type ChartAggregation, type ChartColumnValueType, type ChartJoinType, type ChartType, } from "./types.js";
@@ -64,6 +65,14 @@ export declare function chartJoin<const From extends ChartDatasourceRef, const T
64
65
  readonly datasource: To;
65
66
  readonly type?: ChartJoinType;
66
67
  } & ChartJoinSides<NoInfer<From>, NoInfer<To>>): ChartJoin<From, To>;
68
+ /**
69
+ * A subscription's row limit: at most `count` rows, after skipping `offset`
70
+ * rows (default 0). The platform stores it as `{count, offset}` (#2291).
71
+ */
72
+ export interface ChartSubscriptionLimit {
73
+ readonly count: number;
74
+ readonly offset?: number;
75
+ }
67
76
  declare const chartSubscriptionBrand: unique symbol;
68
77
  export interface ChartSubscription<Datasource extends ChartDatasourceRef = ChartDatasourceRef> {
69
78
  readonly [chartSubscriptionBrand]: Datasource;
@@ -71,8 +80,15 @@ export interface ChartSubscription<Datasource extends ChartDatasourceRef = Chart
71
80
  readonly columns: readonly ChartColumn<Datasource>[];
72
81
  readonly groupBy?: readonly ChartGroupBy<Datasource>[];
73
82
  readonly joins?: readonly ChartJoin<Datasource, ChartDatasourceRef>[];
74
- readonly filter?: Filter<ChartFieldFor<Datasource>, never>;
75
- readonly limit?: string;
83
+ /**
84
+ * Built with this module's `filter` helpers, typed as view and
85
+ * access-policy filters are (`Filter<FilterFieldToken, unknown>`, #2561):
86
+ * a narrower type here rejected every chart filter, pulled ones included
87
+ * (#2797). Build refuses a field outside the datasource, an aspect
88
+ * override and any runtime reference.
89
+ */
90
+ readonly filter?: Filter<FilterFieldToken, unknown>;
91
+ readonly limit?: ChartSubscriptionLimit;
76
92
  readonly tags?: readonly string[];
77
93
  }
78
94
  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 {
@@ -3,6 +3,7 @@ import { isTfExpr, scopedLabelToBagKey, tfLabelToTsLabel } from "../../engine/tf
3
3
  import { FIELD_RESOURCE_TYPES } from "../field/types.js";
4
4
  import { fieldKeyFromTfValue } from "../field/from-tf.js";
5
5
  import { filterFromTf } from "../shared/filters/tf-codec.js";
6
+ import { optionLookupDecode } from "../shared/filters/option-lookups.js";
6
7
  import { CHART_RESOURCE_TYPE } from "./types.js";
7
8
  import { dataAspectDisplayName } from "../shared/aspect-target-from-tf.js";
8
9
  const APP_RESOURCE_TYPE = "elementum_app";
@@ -213,6 +214,22 @@ function opaqueSubscriptionFromTf(value, where, ctx) {
213
214
  ctx.diagnostics.push(`${where}: preserved UI chart synthetic datasource as an opaque pull-only subscription`);
214
215
  return { kind: "opaque", datasourceId, attributes };
215
216
  }
217
+ /** The platform's Limit scalar, exported as `limit = { count, offset }` (#2291). */
218
+ function limitFromTf(value) {
219
+ const rec = plainObject(value);
220
+ if (rec === undefined)
221
+ return undefined;
222
+ const isCount = (item) => typeof item === "number" && Number.isSafeInteger(item) && item >= 0;
223
+ if (Object.keys(rec).some((key) => key !== "count" && key !== "offset"))
224
+ return undefined;
225
+ const count = rec["count"];
226
+ const offset = rec["offset"];
227
+ if (!isCount(count))
228
+ return undefined;
229
+ if (offset !== undefined && offset !== null && !isCount(offset))
230
+ return undefined;
231
+ return { count, ...(isCount(offset) ? { offset } : {}) };
232
+ }
216
233
  function parseSubscription(value, appLabel, appRefName, ctx, where) {
217
234
  const opaque = opaqueSubscriptionFromTf(value, where, ctx);
218
235
  if (opaque !== undefined)
@@ -313,6 +330,8 @@ function parseSubscription(value, appLabel, appRefName, ctx, where) {
313
330
  },
314
331
  aspect: () => { throw new Error("chart filter aspect overrides are unsupported"); },
315
332
  reference: () => { throw new Error("chart filter references are unsupported"); },
333
+ // #2582: a stored option lookup prints as filter.textOption(label).
334
+ ...optionLookupDecode,
316
335
  });
317
336
  }
318
337
  catch (error) {
@@ -320,12 +339,20 @@ function parseSubscription(value, appLabel, appRefName, ctx, where) {
320
339
  return undefined;
321
340
  }
322
341
  }
342
+ let limit;
343
+ if (rec["limit"] !== undefined && rec["limit"] !== null) {
344
+ limit = limitFromTf(rec["limit"]);
345
+ if (limit === undefined) {
346
+ ctx.diagnostics.push(`${where}.limit: expected { count, offset } with non-negative integers; subscription skipped`);
347
+ return undefined;
348
+ }
349
+ }
323
350
  return {
324
351
  datasource, columns,
325
352
  ...(groupBy !== undefined ? { groupBy } : {}),
326
353
  ...(joins !== undefined ? { joins } : {}),
327
354
  ...(filter !== undefined ? { filter } : {}),
328
- ...(typeof rec["limit"] === "string" ? { limit: rec["limit"] } : {}),
355
+ ...(limit !== undefined ? { limit } : {}),
329
356
  ...(stringList(rec["tags"]) !== undefined ? { tags: stringList(rec["tags"]) } : {}),
330
357
  };
331
358
  }
@@ -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(" }),");
@@ -3,6 +3,7 @@ import { EntityTfError } from "../../engine/entity.js";
3
3
  import { expr, sanitizeName, scopedResourceLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
4
4
  import { authoredFieldKeysFromPayload, fieldRefToTfValue, } from "../field/to-tf.js";
5
5
  import { filterToTf as serializeFilterToTf } from "../shared/filters/tf-codec.js";
6
+ import { optionSelectionLiteral, optionsLocalName } from "../shared/filters/option-lookups.js";
6
7
  import { isUnsafePlatformId } from "../../core/platform-id.js";
7
8
  import { CHART_RESOURCE_TYPE } from "./types.js";
8
9
  import { foreignFieldDataLabel, resolveForeignRef } from "../shared/foreign-ref.js";
@@ -84,8 +85,24 @@ function columnToTf(column, datasource, opts, where) {
84
85
  function filterToTf(value, datasource, opts, where) {
85
86
  return serializeFilterToTf(value, {
86
87
  field: (field) => fieldId(field, datasource, opts, `${where}.field`),
87
- aspect: () => datasource.id,
88
+ // A chart filter always runs on the subscription's datasource. An
89
+ // authored aspect override (filter.withOptions({ aspect })) has nowhere
90
+ // to go, and pull never prints one (printer.ts), so refuse it rather
91
+ // than silently writing the datasource in its place (#2797).
92
+ aspect: () => {
93
+ throw new EntityTfError(`${where}: a chart filter runs on its subscription's datasource; remove the filter.withOptions aspect override`);
94
+ },
88
95
  reference: () => { throw new EntityTfError(`${where}: runtime reference values are not supported in chart filters`); },
96
+ // #2582: a Dropdown option is selected with filter.textOption(label).
97
+ literal: optionSelectionLiteral({
98
+ where,
99
+ address: opts.chartAddress,
100
+ name: opts.chartName,
101
+ ownerKind: "chart",
102
+ optionsLocal: (field) => datasource.local && (datasource.kind === "app" || datasource.kind === "element")
103
+ ? optionsLocalName(datasource.tfLabel, datasource.kind, field)
104
+ : undefined,
105
+ }),
89
106
  });
90
107
  }
91
108
  function opaqueSubscriptionToTf(subscription, where) {
@@ -166,11 +183,29 @@ function subscriptionToTf(subscription, opts, where) {
166
183
  if (subscription.filter !== undefined)
167
184
  out["filter"] = filterToTf(subscription.filter, datasource, opts, `${where}.filter`);
168
185
  if (subscription.limit !== undefined)
169
- out["limit"] = subscription.limit;
186
+ out["limit"] = limitToTf(subscription.limit, `${where}.limit`);
170
187
  if (subscription.tags !== undefined && subscription.tags.length > 0)
171
188
  out["tags"] = [...subscription.tags];
172
189
  return out;
173
190
  }
191
+ function nonNegativeInteger(value) {
192
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
193
+ }
194
+ /**
195
+ * The platform's Limit scalar is {count, offset}; offset is written even when
196
+ * it is the default 0 so build matches what export writes (#2291).
197
+ */
198
+ function limitToTf(limit, where) {
199
+ if (limit === null || typeof limit !== "object" || Array.isArray(limit)) {
200
+ throw new EntityTfError(`${where}: limit must be { count, offset? }`);
201
+ }
202
+ if (!nonNegativeInteger(limit.count))
203
+ throw new EntityTfError(`${where}.count: must be a non-negative integer`);
204
+ if (limit.offset !== undefined && !nonNegativeInteger(limit.offset)) {
205
+ throw new EntityTfError(`${where}.offset: must be a non-negative integer`);
206
+ }
207
+ return { count: limit.count, offset: limit.offset ?? 0 };
208
+ }
174
209
  function hasSameAppChartWidget(entity, root) {
175
210
  const payload = root.payload;
176
211
  if (payload?.dashboards === undefined)
@@ -196,7 +231,7 @@ export function chartToTf(entity, opts) {
196
231
  const attrs = {
197
232
  name: chart.name ?? "",
198
233
  type: chart.type ?? "",
199
- subscriptions: (chart.subscriptions ?? []).map((subscription, index) => subscriptionToTf(subscription, opts, `chart ${entity.refName}.subscriptions[${index}]`)),
234
+ subscriptions: (chart.subscriptions ?? []).map((subscription, index) => subscriptionToTf(subscription, { ...opts, chartAddress: `${CHART_RESOURCE_TYPE}.${label}`, chartName: chart.name ?? entity.refName }, `chart ${entity.refName}.subscriptions[${index}]`)),
200
235
  };
201
236
  if (chart.target !== undefined)
202
237
  attrs["target"] = chart.target;
@@ -215,6 +215,8 @@ export interface DynamicLayoutComponentVariantMap {
215
215
  readonly fullWidth?: boolean;
216
216
  /** App or element whose related records the block lists. */
217
217
  readonly related?: AppOrElementRef;
218
+ /** Related-records widget on the layout's owner that holds the block's columns, rows, sort and filter. */
219
+ readonly widget?: WidgetRef;
218
220
  /** Record filter over the related app's or element's fields. */
219
221
  readonly filter?: Filter<FieldRef, never>;
220
222
  };
@@ -325,6 +327,7 @@ export interface AppDynamicLayout {
325
327
  readonly updatedAt?: string;
326
328
  readonly createdBy?: string;
327
329
  readonly description?: string;
330
+ readonly explicitUpdateBlock?: boolean;
328
331
  };
329
332
  }
330
333
  /** Element-owned DASHBOARD layout. Elements have no stages, so it is always the element's default layout. */