@elementumai/edk 0.12.0 → 0.13.1

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 (224) hide show
  1. package/README.md +8 -2
  2. package/dist-sdk/src/catalog/factories.d.ts +7 -1
  3. package/dist-sdk/src/catalog/factories.js +10 -2
  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 +12 -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/types/app.d.ts +6 -0
  13. package/dist-sdk/src/engine/build/context.d.ts +3 -0
  14. package/dist-sdk/src/engine/coverage-gaps.d.ts +2 -0
  15. package/dist-sdk/src/engine/coverage-gaps.js +4 -0
  16. package/dist-sdk/src/engine/ei/run.d.ts +8 -0
  17. package/dist-sdk/src/engine/ei/run.js +46 -7
  18. package/dist-sdk/src/engine/pull/authored-address.js +42 -6
  19. package/dist-sdk/src/engine/pull/authored-root.d.ts +88 -0
  20. package/dist-sdk/src/engine/pull/authored-root.js +306 -0
  21. package/dist-sdk/src/engine/pull/context.d.ts +34 -0
  22. package/dist-sdk/src/engine/pull/field-refs-registry.d.ts +114 -0
  23. package/dist-sdk/src/engine/pull/field-refs-registry.js +501 -0
  24. package/dist-sdk/src/engine/pull/org.d.ts +1 -0
  25. package/dist-sdk/src/engine/pull/org.js +2 -0
  26. package/dist-sdk/src/engine/pull/partition.d.ts +8 -0
  27. package/dist-sdk/src/engine/pull/partition.js +43 -0
  28. package/dist-sdk/src/engine/pull/pulled-roots.d.ts +89 -0
  29. package/dist-sdk/src/engine/pull/pulled-roots.js +203 -0
  30. package/dist-sdk/src/engine/pull/ref-only.d.ts +4 -0
  31. package/dist-sdk/src/engine/pull/ref-only.js +7 -1
  32. package/dist-sdk/src/engine/pull/source-resources.d.ts +39 -0
  33. package/dist-sdk/src/engine/pull/source-resources.js +110 -0
  34. package/dist-sdk/src/engine/pull/stream-root.d.ts +159 -0
  35. package/dist-sdk/src/engine/pull/stream-root.js +579 -0
  36. package/dist-sdk/src/engine/workspace/authoring-layout.js +16 -2
  37. package/dist-sdk/src/engine/workspace/reserved-catalog-keys.d.ts +47 -0
  38. package/dist-sdk/src/engine/workspace/reserved-catalog-keys.js +115 -0
  39. package/dist-sdk/src/entities/access-policy/build.d.ts +2 -1
  40. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +7 -0
  41. package/dist-sdk/src/entities/access-policy/from-tf.js +17 -5
  42. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +19 -0
  43. package/dist-sdk/src/entities/access-policy/to-tf.js +65 -8
  44. package/dist-sdk/src/entities/agent/build.d.ts +52 -1
  45. package/dist-sdk/src/entities/agent/build.js +34 -0
  46. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +70 -1
  47. package/dist-sdk/src/entities/agent/from-tf.d.ts +36 -1
  48. package/dist-sdk/src/entities/agent/from-tf.js +289 -2
  49. package/dist-sdk/src/entities/agent/index.d.ts +1 -1
  50. package/dist-sdk/src/entities/agent/module.js +1 -0
  51. package/dist-sdk/src/entities/agent/to-tf.d.ts +11 -11
  52. package/dist-sdk/src/entities/agent/to-tf.js +179 -17
  53. package/dist-sdk/src/entities/agent-tool/from-tf.js +6 -0
  54. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -2
  55. package/dist-sdk/src/entities/agent-tool/to-tf.js +2 -2
  56. package/dist-sdk/src/entities/app/build.d.ts +33 -13
  57. package/dist-sdk/src/entities/app/build.js +14 -12
  58. package/dist-sdk/src/entities/app/from-tf.d.ts +1 -0
  59. package/dist-sdk/src/entities/app/from-tf.js +7 -9
  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 +3 -0
  63. package/dist-sdk/src/entities/app/stage-keys.d.ts +2 -2
  64. package/dist-sdk/src/entities/app/stage-keys.js +3 -3
  65. package/dist-sdk/src/entities/app/to-tf.js +1 -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 +10 -1
  82. package/dist-sdk/src/entities/automation/build.js +70 -27
  83. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +21 -5
  84. package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -5
  85. package/dist-sdk/src/entities/automation/from-tf.js +665 -112
  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 +45 -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/slack-message-refs.d.ts +9 -0
  93. package/dist-sdk/src/entities/automation/slack-message-refs.js +75 -0
  94. package/dist-sdk/src/entities/automation/system-ref-name.d.ts +23 -3
  95. package/dist-sdk/src/entities/automation/system-ref-name.js +86 -4
  96. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +11 -0
  97. package/dist-sdk/src/entities/automation/task-output-labels.js +23 -0
  98. package/dist-sdk/src/entities/automation/tasks.d.ts +29 -4
  99. package/dist-sdk/src/entities/automation/tasks.js +34 -11
  100. package/dist-sdk/src/entities/automation/to-tf.d.ts +8 -1
  101. package/dist-sdk/src/entities/automation/to-tf.js +563 -103
  102. package/dist-sdk/src/entities/automation/triggers.d.ts +0 -8
  103. package/dist-sdk/src/entities/automation/triggers.js +26 -11
  104. package/dist-sdk/src/entities/automation/unsafe-script-output.d.ts +50 -0
  105. package/dist-sdk/src/entities/automation/unsafe-script-output.js +92 -0
  106. package/dist-sdk/src/entities/chart/build.d.ts +9 -1
  107. package/dist-sdk/src/entities/chart/from-tf.js +3 -0
  108. package/dist-sdk/src/entities/chart/to-tf.js +19 -2
  109. package/dist-sdk/src/entities/dashboard/from-tf.d.ts +3 -1
  110. package/dist-sdk/src/entities/dashboard/from-tf.js +42 -2
  111. package/dist-sdk/src/entities/dashboard/to-tf.js +9 -1
  112. package/dist-sdk/src/entities/dashboard-widget-order/module.d.ts +10 -0
  113. package/dist-sdk/src/entities/dashboard-widget-order/module.js +25 -0
  114. package/dist-sdk/src/entities/dashboard-widget-order/order.d.ts +31 -0
  115. package/dist-sdk/src/entities/dashboard-widget-order/order.js +102 -0
  116. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +2 -0
  117. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +44 -5
  118. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +46 -12
  119. package/dist-sdk/src/entities/element/audit-field-guard.d.ts +9 -0
  120. package/dist-sdk/src/entities/element/audit-field-guard.js +88 -0
  121. package/dist-sdk/src/entities/element/build.js +2 -1
  122. package/dist-sdk/src/entities/element/from-tf.d.ts +1 -0
  123. package/dist-sdk/src/entities/element/from-tf.js +4 -7
  124. package/dist-sdk/src/entities/element/module.js +5 -0
  125. package/dist-sdk/src/entities/element/system-fields.d.ts +13 -0
  126. package/dist-sdk/src/entities/element/system-fields.js +23 -0
  127. package/dist-sdk/src/entities/element/to-tf.js +1 -0
  128. package/dist-sdk/src/entities/field/build.d.ts +9 -0
  129. package/dist-sdk/src/entities/field/from-tf.d.ts +52 -1
  130. package/dist-sdk/src/entities/field/from-tf.js +212 -14
  131. package/dist-sdk/src/entities/field/module.js +4 -0
  132. package/dist-sdk/src/entities/field/to-tf.d.ts +5 -1
  133. package/dist-sdk/src/entities/field/to-tf.js +33 -12
  134. package/dist-sdk/src/entities/org/category.js +1 -0
  135. package/dist-sdk/src/entities/org/index.d.ts +1 -0
  136. package/dist-sdk/src/entities/org/index.js +1 -0
  137. package/dist-sdk/src/entities/org/voice-auth.d.ts +5 -0
  138. package/dist-sdk/src/entities/org/voice-auth.js +33 -0
  139. package/dist-sdk/src/entities/organization/build.d.ts +3 -0
  140. package/dist-sdk/src/entities/organization/build.js +2 -0
  141. package/dist-sdk/src/entities/organization/index.d.ts +1 -0
  142. package/dist-sdk/src/entities/organization/index.js +1 -0
  143. package/dist-sdk/src/entities/organization/to-tf.d.ts +2 -0
  144. package/dist-sdk/src/entities/organization/to-tf.js +59 -1
  145. package/dist-sdk/src/entities/organization/voice-auth.d.ts +60 -0
  146. package/dist-sdk/src/entities/organization/voice-auth.js +60 -0
  147. package/dist-sdk/src/entities/phone-service/build.d.ts +9 -1
  148. package/dist-sdk/src/entities/phone-service/build.js +1 -0
  149. package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.js +3 -0
  150. package/dist-sdk/src/entities/phone-service/from-tf.d.ts +1 -0
  151. package/dist-sdk/src/entities/phone-service/from-tf.js +8 -1
  152. package/dist-sdk/src/entities/phone-service/to-tf.js +16 -0
  153. package/dist-sdk/src/entities/record-create-form/from-tf.js +2 -2
  154. package/dist-sdk/src/entities/relationship/from-tf.js +9 -4
  155. package/dist-sdk/src/entities/relationship/module.js +2 -2
  156. package/dist-sdk/src/entities/relationship/pair-check.d.ts +6 -2
  157. package/dist-sdk/src/entities/relationship/pair-check.js +105 -18
  158. package/dist-sdk/src/entities/relationship/to-tf.js +5 -2
  159. package/dist-sdk/src/entities/role/build.d.ts +3 -4
  160. package/dist-sdk/src/entities/role/permission-levels.d.ts +7 -0
  161. package/dist-sdk/src/entities/role/permission-levels.js +78 -0
  162. package/dist-sdk/src/entities/role/to-tf.js +32 -2
  163. package/dist-sdk/src/entities/search-table/build.d.ts +9 -3
  164. package/dist-sdk/src/entities/search-table/build.js +4 -4
  165. package/dist-sdk/src/entities/search-table/printer.js +3 -1
  166. package/dist-sdk/src/entities/search-table/to-tf.js +20 -2
  167. package/dist-sdk/src/entities/service-account/module.d.ts +2 -1
  168. package/dist-sdk/src/entities/service-account/module.js +4 -1
  169. package/dist-sdk/src/entities/service-account/resource-type.d.ts +2 -0
  170. package/dist-sdk/src/entities/service-account/resource-type.js +2 -0
  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/context.d.ts +14 -1
  176. package/dist-sdk/src/entities/shared/filters/ast.d.ts +2 -0
  177. package/dist-sdk/src/entities/shared/filters/index.d.ts +97 -15
  178. package/dist-sdk/src/entities/shared/filters/index.js +30 -7
  179. package/dist-sdk/src/entities/shared/filters/option-lookups.d.ts +57 -0
  180. package/dist-sdk/src/entities/shared/filters/option-lookups.js +108 -0
  181. package/dist-sdk/src/entities/shared/filters/print.d.ts +2 -0
  182. package/dist-sdk/src/entities/shared/filters/print.js +19 -6
  183. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +16 -7
  184. package/dist-sdk/src/entities/shared/filters/tf-codec.js +25 -5
  185. package/dist-sdk/src/entities/shared/filters/types.d.ts +4 -0
  186. package/dist-sdk/src/entities/shared/raw-option-id.d.ts +30 -0
  187. package/dist-sdk/src/entities/shared/raw-option-id.js +41 -0
  188. package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +1 -1
  189. package/dist-sdk/src/entities/shared/tool-field-ref.js +3 -2
  190. package/dist-sdk/src/entities/skill/input-coverage.js +5 -2
  191. package/dist-sdk/src/entities/sla/build.d.ts +96 -0
  192. package/dist-sdk/src/entities/sla/build.js +124 -0
  193. package/dist-sdk/src/entities/sla/from-tf.d.ts +40 -0
  194. package/dist-sdk/src/entities/sla/from-tf.js +164 -0
  195. package/dist-sdk/src/entities/sla/index.d.ts +1 -0
  196. package/dist-sdk/src/entities/sla/index.js +1 -0
  197. package/dist-sdk/src/entities/sla/module.d.ts +4 -0
  198. package/dist-sdk/src/entities/sla/module.js +73 -0
  199. package/dist-sdk/src/entities/sla/printer.d.ts +2 -0
  200. package/dist-sdk/src/entities/sla/printer.js +84 -0
  201. package/dist-sdk/src/entities/sla/to-tf.d.ts +12 -0
  202. package/dist-sdk/src/entities/sla/to-tf.js +81 -0
  203. package/dist-sdk/src/entities/table/build.d.ts +7 -2
  204. package/dist-sdk/src/entities/table/build.js +22 -1
  205. package/dist-sdk/src/entities/table/deserializer/normalize.d.ts +4 -1
  206. package/dist-sdk/src/entities/table/from-tf.js +89 -14
  207. package/dist-sdk/src/entities/table/index.d.ts +1 -1
  208. package/dist-sdk/src/entities/table/to-tf.js +41 -2
  209. package/dist-sdk/src/entities/task/from-tf.js +3 -2
  210. package/dist-sdk/src/entities/view/custom-view-validate.d.ts +6 -4
  211. package/dist-sdk/src/entities/view/custom-view-validate.js +36 -18
  212. package/dist-sdk/src/entities/view/from-tf.js +16 -4
  213. package/dist-sdk/src/entities/view/to-tf.js +66 -47
  214. package/dist-sdk/src/entities/visual-flow/module.js +52 -1
  215. package/dist-sdk/src/entities/widget/from-tf.js +19 -8
  216. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +49 -4
  217. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
  218. package/dist-sdk/src/graph/index.d.ts +9 -0
  219. package/dist-sdk/src/graph/index.js +8 -0
  220. package/dist-sdk/src/graph/modules.js +13 -1
  221. package/dist-sdk/src/graph/resource-types.d.ts +47 -0
  222. package/dist-sdk/src/graph/resource-types.js +62 -0
  223. package/dist-sdk/src/graph/types.d.ts +113 -6
  224. package/package.json +7 -4
@@ -7,6 +7,13 @@ import type { WorkflowFieldType } from "../types/field-types.js";
7
7
  import type { AndFilter, BetweenFilter, ConsecutiveRangeFilter, ContainsFilter, CurrentRangeFilter, DateTimeUnit, EqualsFilter, FalseFilter, Filter, FilterReference, FilterValue, GreaterThanEqualsFilter, GreaterThanFilter, InFilter, IsNullFilter, LessThanEqualsFilter, LessThanFilter, LikeFilter, LikeMode, OrFilter, OverlapsFilter, TrueFilter, ValueType } from "./types.js";
8
8
  export type { AndFilter, BetweenFilter, ConsecutiveRangeFilter, ContainsFilter, CurrentRangeFilter, DateTimeUnit, EqualsFilter, FalseFilter, FieldFilterOptions, Filter, FilterReference, FilterValue, GreaterThanEqualsFilter, GreaterThanFilter, InFilter, IsNullFilter, LessThanEqualsFilter, LessThanFilter, LikeFilter, LikeMode, OrFilter, OverlapsFilter, TrueFilter, ValueType, } from "./types.js";
9
9
  export type FilterField = AppOrElementRef | FieldRef | UserFieldRef | UserGroupFieldRef | TableColumnRef | TableRef | AppField<FieldScope> | UnsafePlatformId | string;
10
+ /**
11
+ * A filter field named by a field token or `unsafePlatformId()`, never by a bare
12
+ * string. Views and access policies take only these, because their build can't
13
+ * resolve a field name (#1873); a filter whose left side is a bare string keeps
14
+ * the wider `FilterField` type, so the editor flags it there instead of build.
15
+ */
16
+ export type FilterFieldToken = Exclude<FilterField, string>;
10
17
  export type FilterReferenceValue = FilterReference | {
11
18
  readonly __rawFilterReference: string;
12
19
  };
@@ -47,29 +54,46 @@ export declare function uuid(ref: Ref<unknown> | string, options?: {
47
54
  }): FilterReferenceInput;
48
55
  export declare function isFilterReferenceInput(value: unknown): value is FilterReferenceInput;
49
56
  /**
50
- * A picklist, status, or stage option selected by its LABEL and stored behind
51
- * the platform's TEXT value wrapper, which is how many live list-view filters
52
- * hold their option ids. Build resolves the label to that option's id either
53
- * way, so the wrapper is the only difference: pass a plain label for a raw text
54
- * comparison, `"UUID"` as the comparison's value type for the UUID wrapper, and
55
- * this for the TEXT one.
57
+ * A picklist, status, or stage option selected by its LABEL. Build resolves
58
+ * the label to that option's id, which is what the platform stores.
59
+ * This is the one spelling for an option (#1733):
60
+ *
61
+ * - In a filter, a plain string is literal text, sent as written. Use this to
62
+ * compare against an option. A `"UUID"` comparison value type also resolves
63
+ * its label, behind the platform's UUID wrapper; this keeps the TEXT one.
64
+ * - In an automation field assignment to a Dropdown or Multi-Select with
65
+ * static options, this is required. A plain string there is a build error.
66
+ *
67
+ * Build fails when the label names no option of the compared field, or more
68
+ * than one. Pull prints a stored option id this way.
56
69
  */
57
- export declare function textOption(label: string): Extract<FilterValue<FilterField, FilterReferenceValue>, {
70
+ export declare function textOption(label: string): TextOptionValue;
71
+ /** An option selected by label: what {@link textOption} returns. */
72
+ export type TextOptionValue = Extract<FilterValue<FilterField, FilterReferenceValue>, {
58
73
  type: "TEXT";
59
- }>;
74
+ }> & {
75
+ readonly option: true;
76
+ };
77
+ export declare function isTextOptionValue(value: unknown): value is TextOptionValue;
60
78
  export interface CurrentUserFilterValue {
61
79
  readonly __kind: "currentUser";
62
80
  readonly valueType: "ID" | "EMAIL" | "DOMAIN";
63
81
  }
64
82
  export declare function currentUser(valueType?: "ID" | "EMAIL" | "DOMAIN"): CurrentUserFilterValue;
65
- /** A field used as an explicit comparison operand, preserving its identity. */
66
- export interface FieldLeftValue {
83
+ declare const FIELD_VALUE_SOURCE: unique symbol;
84
+ /**
85
+ * A field used as an explicit comparison operand, preserving its identity.
86
+ * `Source` is the field it was made from, so a bare string keeps a filter off
87
+ * views and access policies, as a bare-string left side does (#1873).
88
+ */
89
+ export interface FieldLeftValue<Source extends FilterField = FilterField> {
67
90
  readonly type: "FIELD";
68
91
  readonly value: FilterField;
69
92
  readonly aspect?: never;
70
93
  readonly treatNullAsEquals?: true;
94
+ readonly [FIELD_VALUE_SOURCE]?: Source;
71
95
  }
72
- export declare function fieldValue(value: FilterField): FieldLeftValue;
96
+ export declare function fieldValue<Source extends FilterField>(value: Source): FieldLeftValue<Source>;
73
97
  export declare function fieldValue(value: FilterField, options?: {
74
98
  readonly aspect?: string;
75
99
  readonly treatNullAsEquals?: boolean;
@@ -92,36 +116,80 @@ export declare function recordField(field: FilterField, options?: {
92
116
  type: "RECORD_FIELD";
93
117
  }>;
94
118
  type AuthoredFilterValue = FilterValue<FilterField, FilterReferenceValue>;
95
- export type FilterInput = string | number | boolean | null | Ref<unknown> | FilterReferenceInput | FilterField | CurrentUserFilterValue | AuthoredFilterValue;
119
+ /** A user named by email, as `userRef("…")` returns: compares as that user's id (#2891). */
120
+ export interface FilterUserRef {
121
+ readonly __kind: "user";
122
+ readonly email: string;
123
+ }
124
+ export type FilterInput = string | number | boolean | null | Ref<unknown> | FilterReferenceInput | FilterField | CurrentUserFilterValue | FilterUserRef | AuthoredFilterValue;
125
+ /**
126
+ * What a filter that list views and access policies accept can compare with:
127
+ * `userRef` builds only in automation filters, so a comparison with it takes
128
+ * the wider overload, which views and access policies reject (as #1873).
129
+ */
130
+ export type TokenFilterInput = Exclude<FilterInput, FilterUserRef>;
96
131
  export type LeftRef = FilterField | Ref<unknown> | FilterReferenceInput | FieldLeftValue;
132
+ type TokenLeftRef = FilterFieldToken | Ref<unknown> | FilterReferenceInput | FieldLeftValue<FilterFieldToken>;
97
133
  export declare const UNRESOLVED_REFERENCE_MARKER = "__edkUnresolvedReference::";
98
134
  export declare function refDataToFilterReference(data: import("../ref.js").RefData): FilterReference;
99
135
  export declare function toFilterValue(input: FilterInput, valueType?: ValueType): FilterValue<FilterField, FilterReferenceValue>;
136
+ export declare function eq(left: TokenLeftRef, input: TokenFilterInput, explicit?: ValueType): EqualsFilter<FilterFieldToken, FilterReferenceValue>;
100
137
  export declare function eq(left: LeftRef, input: FilterInput, explicit?: ValueType): EqualsFilter<FilterField, FilterReferenceValue>;
138
+ export declare function neq(left: TokenLeftRef, input: TokenFilterInput, explicit?: ValueType): EqualsFilter<FilterFieldToken, FilterReferenceValue>;
101
139
  export declare function neq(left: LeftRef, input: FilterInput, explicit?: ValueType): EqualsFilter<FilterField, FilterReferenceValue>;
140
+ export declare function gt(left: TokenLeftRef, input: TokenFilterInput, explicit?: ValueType): GreaterThanFilter<FilterFieldToken, FilterReferenceValue>;
102
141
  export declare function gt(left: LeftRef, input: FilterInput, explicit?: ValueType): GreaterThanFilter<FilterField, FilterReferenceValue>;
142
+ export declare function gte(left: TokenLeftRef, input: TokenFilterInput, explicit?: ValueType): GreaterThanEqualsFilter<FilterFieldToken, FilterReferenceValue>;
103
143
  export declare function gte(left: LeftRef, input: FilterInput, explicit?: ValueType): GreaterThanEqualsFilter<FilterField, FilterReferenceValue>;
144
+ export declare function lt(left: TokenLeftRef, input: TokenFilterInput, explicit?: ValueType): LessThanFilter<FilterFieldToken, FilterReferenceValue>;
104
145
  export declare function lt(left: LeftRef, input: FilterInput, explicit?: ValueType): LessThanFilter<FilterField, FilterReferenceValue>;
146
+ export declare function lte(left: TokenLeftRef, input: TokenFilterInput, explicit?: ValueType): LessThanEqualsFilter<FilterFieldToken, FilterReferenceValue>;
105
147
  export declare function lte(left: LeftRef, input: FilterInput, explicit?: ValueType): LessThanEqualsFilter<FilterField, FilterReferenceValue>;
148
+ export declare function like(left: TokenLeftRef, input: TokenFilterInput, options?: {
149
+ readonly not?: boolean;
150
+ readonly caseInsensitive?: boolean;
151
+ readonly mode?: Lowercase<LikeMode>;
152
+ }, explicit?: ValueType): LikeFilter<FilterFieldToken, FilterReferenceValue>;
106
153
  export declare function like(left: LeftRef, input: FilterInput, options?: {
107
154
  readonly not?: boolean;
108
155
  readonly caseInsensitive?: boolean;
109
156
  readonly mode?: Lowercase<LikeMode>;
110
157
  }, explicit?: ValueType): LikeFilter<FilterField, FilterReferenceValue>;
158
+ export declare function isNull(left: TokenLeftRef, options?: {
159
+ readonly not?: boolean;
160
+ }, explicit?: ValueType): IsNullFilter<FilterFieldToken, FilterReferenceValue>;
111
161
  export declare function isNull(left: LeftRef, options?: {
112
162
  readonly not?: boolean;
113
163
  }, explicit?: ValueType): IsNullFilter<FilterField, FilterReferenceValue>;
164
+ export declare function isNotNull(left: TokenLeftRef, explicit?: ValueType): IsNullFilter<FilterFieldToken, FilterReferenceValue>;
114
165
  export declare function isNotNull(left: LeftRef, explicit?: ValueType): IsNullFilter<FilterField, FilterReferenceValue>;
166
+ export declare function isIn(left: TokenLeftRef, input: readonly TokenFilterInput[], explicit?: ValueType): InFilter<FilterFieldToken, FilterReferenceValue>;
115
167
  export declare function isIn(left: LeftRef, input: readonly FilterInput[], explicit?: ValueType): InFilter<FilterField, FilterReferenceValue>;
168
+ export declare function isNotIn(left: TokenLeftRef, input: readonly TokenFilterInput[], explicit?: ValueType): InFilter<FilterFieldToken, FilterReferenceValue>;
116
169
  export declare function isNotIn(left: LeftRef, input: readonly FilterInput[], explicit?: ValueType): InFilter<FilterField, FilterReferenceValue>;
170
+ export declare function between(left: TokenLeftRef, min: TokenFilterInput, max: TokenFilterInput, options?: {
171
+ readonly not?: boolean;
172
+ }, explicit?: ValueType): BetweenFilter<FilterFieldToken, FilterReferenceValue>;
117
173
  export declare function between(left: LeftRef, min: FilterInput, max: FilterInput, options?: {
118
174
  readonly not?: boolean;
119
175
  }, explicit?: ValueType): BetweenFilter<FilterField, FilterReferenceValue>;
176
+ export declare function currentRange(left: TokenLeftRef, options: {
177
+ readonly unit: DateTimeUnit;
178
+ readonly semantic?: boolean;
179
+ readonly isoWeek?: boolean;
180
+ }, explicit?: ValueType): CurrentRangeFilter<FilterFieldToken, FilterReferenceValue>;
120
181
  export declare function currentRange(left: LeftRef, options: {
121
182
  readonly unit: DateTimeUnit;
122
183
  readonly semantic?: boolean;
123
184
  readonly isoWeek?: boolean;
124
185
  }, explicit?: ValueType): CurrentRangeFilter<FilterField, FilterReferenceValue>;
186
+ export declare function consecutiveRange(left: TokenLeftRef, options: {
187
+ readonly unit: DateTimeUnit;
188
+ readonly count: number;
189
+ readonly offset: number;
190
+ readonly semantic?: boolean;
191
+ readonly isoWeek?: boolean;
192
+ }, explicit?: ValueType): ConsecutiveRangeFilter<FilterFieldToken, FilterReferenceValue>;
125
193
  export declare function consecutiveRange(left: LeftRef, options: {
126
194
  readonly unit: DateTimeUnit;
127
195
  readonly count: number;
@@ -129,17 +197,31 @@ export declare function consecutiveRange(left: LeftRef, options: {
129
197
  readonly semantic?: boolean;
130
198
  readonly isoWeek?: boolean;
131
199
  }, explicit?: ValueType): ConsecutiveRangeFilter<FilterField, FilterReferenceValue>;
200
+ export declare function contains(left: TokenLeftRef, input: TokenFilterInput | readonly TokenFilterInput[], options?: {
201
+ readonly not?: boolean;
202
+ }, explicit?: ValueType): ContainsFilter<FilterFieldToken, FilterReferenceValue>;
132
203
  export declare function contains(left: LeftRef, input: FilterInput | readonly FilterInput[], options?: {
133
204
  readonly not?: boolean;
134
205
  }, explicit?: ValueType): ContainsFilter<FilterField, FilterReferenceValue>;
206
+ export declare function overlaps(left: TokenLeftRef, input: TokenFilterInput | readonly TokenFilterInput[], options?: {
207
+ readonly not?: boolean;
208
+ }, explicit?: ValueType): OverlapsFilter<FilterFieldToken, FilterReferenceValue>;
135
209
  export declare function overlaps(left: LeftRef, input: FilterInput | readonly FilterInput[], options?: {
136
210
  readonly not?: boolean;
137
211
  }, explicit?: ValueType): OverlapsFilter<FilterField, FilterReferenceValue>;
138
- export declare function and(...children: readonly Filter<FilterField, FilterReferenceValue>[]): AndFilter<FilterField, FilterReferenceValue>;
139
- export declare function or(...children: readonly Filter<FilterField, FilterReferenceValue>[]): OrFilter<FilterField, FilterReferenceValue>;
212
+ export declare function and<F extends FilterField = FilterField>(...children: readonly Filter<F, FilterReferenceValue>[]): AndFilter<F, FilterReferenceValue>;
213
+ export declare function or<F extends FilterField = FilterField>(...children: readonly Filter<F, FilterReferenceValue>[]): OrFilter<F, FilterReferenceValue>;
140
214
  export declare function whereTrue(): TrueFilter;
141
215
  export declare function whereFalse(): FalseFilter;
216
+ /**
217
+ * A token filter keeps its type only with a token `aspect`; a bare-string
218
+ * `aspect` widens it, so views and access policies reject it (#1873).
219
+ */
220
+ export declare function withOptions<T extends Filter<FilterFieldToken, FilterReferenceValue>>(value: T, options: {
221
+ readonly aspect?: FilterFieldToken;
222
+ readonly semantic?: boolean;
223
+ }): T;
142
224
  export declare function withOptions<T extends Filter<FilterField, FilterReferenceValue>>(value: T, options: {
143
225
  readonly aspect?: FilterField;
144
226
  readonly semantic?: boolean;
145
- }): T;
227
+ }): T extends Filter<FilterFieldToken, FilterReferenceValue> ? Filter<FilterField, FilterReferenceValue> : T;
@@ -76,16 +76,28 @@ export function isFilterReferenceInput(value) {
76
76
  return typeof value === "object" && value !== null && FILTER_REFERENCE_BRAND in value;
77
77
  }
78
78
  /**
79
- * A picklist, status, or stage option selected by its LABEL and stored behind
80
- * the platform's TEXT value wrapper, which is how many live list-view filters
81
- * hold their option ids. Build resolves the label to that option's id either
82
- * way, so the wrapper is the only difference: pass a plain label for a raw text
83
- * comparison, `"UUID"` as the comparison's value type for the UUID wrapper, and
84
- * this for the TEXT one.
79
+ * A picklist, status, or stage option selected by its LABEL. Build resolves
80
+ * the label to that option's id, which is what the platform stores.
81
+ * This is the one spelling for an option (#1733):
82
+ *
83
+ * - In a filter, a plain string is literal text, sent as written. Use this to
84
+ * compare against an option. A `"UUID"` comparison value type also resolves
85
+ * its label, behind the platform's UUID wrapper; this keeps the TEXT one.
86
+ * - In an automation field assignment to a Dropdown or Multi-Select with
87
+ * static options, this is required. A plain string there is a build error.
88
+ *
89
+ * Build fails when the label names no option of the compared field, or more
90
+ * than one. Pull prints a stored option id this way.
85
91
  */
86
92
  export function textOption(label) {
87
93
  return { type: "TEXT", value: label, option: true };
88
94
  }
95
+ export function isTextOptionValue(value) {
96
+ return typeof value === "object" && value !== null &&
97
+ value.type === "TEXT" &&
98
+ value.option === true &&
99
+ typeof value.value === "string";
100
+ }
89
101
  export function currentUser(valueType = "ID") {
90
102
  return { __kind: "currentUser", valueType };
91
103
  }
@@ -141,8 +153,11 @@ function hasKind(value, kind) {
141
153
  return typeof value === "object" && value !== null && value.__kind === kind;
142
154
  }
143
155
  function isCurrentUser(value) { return hasKind(value, "currentUser"); }
156
+ function isUserRef(value) {
157
+ return hasKind(value, "user") && typeof value.email === "string";
158
+ }
144
159
  const FILTER_VALUE_TYPES = new Set([
145
- "BOOLEAN", "CURRENT_USER", "DATE", "DATETIME", "FIELD", "NULL", "NUMBER", "RECORD_FIELD", "REFERENCE", "TEXT", "UUID",
160
+ "BOOLEAN", "CURRENT_USER", "DATE", "DATETIME", "FIELD", "NULL", "NUMBER", "RECORD_FIELD", "REFERENCE", "TEXT", "USER", "UUID",
146
161
  ]);
147
162
  function isCanonicalFilterValue(value) {
148
163
  return typeof value === "object" && value !== null && typeof value.type === "string" &&
@@ -213,6 +228,14 @@ export function toFilterValue(input, valueType = "TEXT") {
213
228
  return input;
214
229
  if (isCurrentUser(input))
215
230
  return { type: "CURRENT_USER", valueType: input.valueType };
231
+ if (isUserRef(input)) {
232
+ // A user compares as an id: under a number, date or boolean comparison it
233
+ // would build a value of the wrong type with no error (#2891).
234
+ if (valueType !== "TEXT" && valueType !== "UUID") {
235
+ throw new EdkValidationError(`userRef(${JSON.stringify(input.email)}) compares as a user id; use it in a text or UUID comparison, not ${valueType}`);
236
+ }
237
+ return { type: "USER", email: input.email, valueType };
238
+ }
216
239
  if (isFilterReferenceInput(input)) {
217
240
  const value = typeof input.ref === "string" && input.ref.startsWith(UNRESOLVED_REFERENCE_MARKER)
218
241
  ? { __rawFilterReference: input.ref.slice(UNRESOLVED_REFERENCE_MARKER.length) }
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Dropdown option selections in chart, table and lookup-field filters
3
+ * (#2582), the same rule #1733 gave automation, view and access-policy
4
+ * filters. `filter.textOption(label)` is the preferred spelling: it must name
5
+ * exactly one option of the field and builds to that option's id through the
6
+ * field's `<label>_options_by_label` local (an app's Status and Stage use the
7
+ * app's `<ns>_status_options_by_label` / `<ns>_stage_options_by_label`, as
8
+ * access policies, automations and dynamic layouts do). A plain string or a
9
+ * raw option id still builds as written and warns, naming
10
+ * `filter.textOption(...)`. Pull reads the export's options-by-label lookup,
11
+ * and an app's `status_option_ids_by_label`, back as `filter.textOption(label)`.
12
+ */
13
+ import type { OptionIdIndex } from "../../../engine/pull/field-refs-registry.js";
14
+ import { type ChildResourceScope, type TfValue } from "../../../engine/tf/index.js";
15
+ interface OptionFieldToken {
16
+ readonly __kind?: string;
17
+ readonly refName?: string;
18
+ readonly name?: string;
19
+ readonly options?: readonly string[];
20
+ readonly tags?: readonly string[];
21
+ /** Natural bag key when pull re-keyed off a reserved system key (#1871). */
22
+ readonly resourceKey?: string;
23
+ }
24
+ export interface OptionSelectionOwner {
25
+ /** Where the filter sits, e.g. `chart "Votes".subscriptions[0].filter`. */
26
+ readonly where: string;
27
+ /** The resource address and name that warnings name. */
28
+ readonly address: string;
29
+ readonly name: string;
30
+ readonly ownerKind: "chart" | "table" | "field";
31
+ readonly optionIds?: OptionIdIndex;
32
+ /**
33
+ * The field's options-by-label local, when the field's owner is built in
34
+ * this workspace. Without it `filter.textOption(label)` has no option id
35
+ * to build and fails.
36
+ */
37
+ readonly optionsLocal: (field: OptionFieldToken) => string | undefined;
38
+ }
39
+ /** The options-by-label local of a field owned by an app or element in this build. */
40
+ export declare function optionsLocalName(ownerTfLabel: string, scope: ChildResourceScope, field: OptionFieldToken): string | undefined;
41
+ /** The filter codec's `literal` hook for an owner that compares stored option ids. */
42
+ export declare function optionSelectionLiteral(owner: OptionSelectionOwner): (value: TfValue, field: unknown, valueType: string, isOptionLabel: boolean) => TfValue;
43
+ /**
44
+ * Pull: the export writes a stored option id as
45
+ * `local.<field>_options_by_label["<label>"]`, a stage id as
46
+ * `local.<ns>_stage_options_by_label["<label>"]` and a status id as
47
+ * `elementum_app.<ns>.status_option_ids_by_label["<label>"]`. Read each back
48
+ * as the label; build writes the same option's id back through the field,
49
+ * stage or status local (#2582 S1).
50
+ */
51
+ export declare function optionLookupLabel(value: TfValue | undefined): string | undefined;
52
+ /** The decode hooks that print a stored option lookup as `filter.textOption(label)`. */
53
+ export declare const optionLookupDecode: {
54
+ readonly literal: (value: TfValue) => TfValue;
55
+ readonly optionLookupsAreIdentities: (stored: TfValue) => boolean;
56
+ };
57
+ export {};
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Dropdown option selections in chart, table and lookup-field filters
3
+ * (#2582), the same rule #1733 gave automation, view and access-policy
4
+ * filters. `filter.textOption(label)` is the preferred spelling: it must name
5
+ * exactly one option of the field and builds to that option's id through the
6
+ * field's `<label>_options_by_label` local (an app's Status and Stage use the
7
+ * app's `<ns>_status_options_by_label` / `<ns>_stage_options_by_label`, as
8
+ * access policies, automations and dynamic layouts do). A plain string or a
9
+ * raw option id still builds as written and warns, naming
10
+ * `filter.textOption(...)`. Pull reads the export's options-by-label lookup,
11
+ * and an app's `status_option_ids_by_label`, back as `filter.textOption(label)`.
12
+ */
13
+ import { EntityTfError } from "../../../engine/entity.js";
14
+ import { recordValidations } from "../../../engine/validation.js";
15
+ import { expr, isTfExpr, isUuid, scopedResourceLabel, tsLabelToTfLabel } from "../../../engine/tf/index.js";
16
+ import { plainOptionStringWarning, rawOptionIdWarning } from "../raw-option-id.js";
17
+ function optionField(field) {
18
+ if (typeof field !== "object" || field === null)
19
+ return undefined;
20
+ const token = field;
21
+ // A Stage token carries its stage names as `options`; it resolves through the stage local below.
22
+ if (token.__kind !== "field" || token.options === undefined)
23
+ return undefined;
24
+ return token;
25
+ }
26
+ /** The options-by-label local of a field owned by an app or element in this build. */
27
+ export function optionsLocalName(ownerTfLabel, scope, field) {
28
+ // #2582 S1: an app's Status and Stage ids live on the app's own locals
29
+ // (app/locals.ts), not a field local. Hand-built refs carry no tags, so
30
+ // match the system key too, as access policies do. Elements have neither.
31
+ if (scope === "app" && (field.tags?.includes("STATUS") === true || field.refName === "status"))
32
+ return `${ownerTfLabel}_status_options_by_label`;
33
+ if (scope === "app" && (field.tags?.includes("STAGE") === true || field.refName === "stage"))
34
+ return `${ownerTfLabel}_stage_options_by_label`;
35
+ if (field.refName === undefined || field.refName === "")
36
+ return undefined;
37
+ // Same child part fieldToTf uses: resourceKey when pull re-keyed (#1871).
38
+ const childPart = tsLabelToTfLabel(field.resourceKey ?? field.refName);
39
+ return `${scopedResourceLabel(ownerTfLabel, childPart, scope)}_options_by_label`;
40
+ }
41
+ /** The filter codec's `literal` hook for an owner that compares stored option ids. */
42
+ export function optionSelectionLiteral(owner) {
43
+ return (value, field, valueType, isOptionLabel) => {
44
+ if (typeof value !== "string" || value === "")
45
+ return value;
46
+ const token = optionField(field);
47
+ if (token === undefined)
48
+ return value;
49
+ const options = token.options ?? [];
50
+ const fieldName = token.name ?? token.refName ?? "unknown";
51
+ const warn = (message) => recordValidations([{ severity: "warning", address: owner.address, name: owner.name, ownerKind: owner.ownerKind, message }]);
52
+ if (isOptionLabel && valueType !== "text") {
53
+ // #2582 N1: the codec also sets isOptionLabel for a UUID wrapper. A
54
+ // label it names builds to the option's lookup; a raw id or any other
55
+ // string falls through to the warnings below.
56
+ const local = options.filter((option) => option === value).length === 1 ? owner.optionsLocal(token) : undefined;
57
+ if (local !== undefined)
58
+ return expr.local(local, [{ index: value }]);
59
+ }
60
+ else if (isOptionLabel) {
61
+ const matches = options.filter((option) => option === value).length;
62
+ if (matches !== 1) {
63
+ throw new EntityTfError(matches === 0
64
+ ? `${owner.where}: filter.textOption(${JSON.stringify(value)}) names no option of field "${fieldName}"; expected one of: ${options.map((option) => JSON.stringify(option)).join(", ")}`
65
+ : `${owner.where}: filter.textOption(${JSON.stringify(value)}) matches ${matches} options of field "${fieldName}", so it names no single option`);
66
+ }
67
+ const local = owner.optionsLocal(token);
68
+ if (local === undefined) {
69
+ throw new EntityTfError(`${owner.where}: filter.textOption(${JSON.stringify(value)}) on field "${fieldName}" needs that field's app or element in this workspace to build its option id`);
70
+ }
71
+ return expr.local(local, [{ index: value }]);
72
+ }
73
+ const slot = owner.where;
74
+ if (isUuid(value) && !options.includes(value)) {
75
+ warn(rawOptionIdWarning({ slot, fieldName, id: value, options, localName: owner.optionsLocal(token), index: owner.optionIds }));
76
+ return value;
77
+ }
78
+ warn(plainOptionStringWarning(slot, fieldName, value, options, false));
79
+ return value;
80
+ };
81
+ }
82
+ function indexLabel(segment) {
83
+ return typeof segment === "object" && segment !== null && "index" in segment && typeof segment.index === "string" ? segment.index : undefined;
84
+ }
85
+ /**
86
+ * Pull: the export writes a stored option id as
87
+ * `local.<field>_options_by_label["<label>"]`, a stage id as
88
+ * `local.<ns>_stage_options_by_label["<label>"]` and a status id as
89
+ * `elementum_app.<ns>.status_option_ids_by_label["<label>"]`. Read each back
90
+ * as the label; build writes the same option's id back through the field,
91
+ * stage or status local (#2582 S1).
92
+ */
93
+ export function optionLookupLabel(value) {
94
+ if (value === undefined || !isTfExpr(value))
95
+ return undefined;
96
+ if (value.$expr === "local") {
97
+ return value.name.endsWith("_options_by_label") && value.path.length === 1 ? indexLabel(value.path[0]) : undefined;
98
+ }
99
+ if (value.$expr === "resource-attr" && value.type === "elementum_app" && value.path.length === 2 && value.path[0] === "status_option_ids_by_label") {
100
+ return indexLabel(value.path[1]);
101
+ }
102
+ return undefined;
103
+ }
104
+ /** The decode hooks that print a stored option lookup as `filter.textOption(label)`. */
105
+ export const optionLookupDecode = {
106
+ literal: (value) => optionLookupLabel(value) ?? value,
107
+ optionLookupsAreIdentities: (stored) => optionLookupLabel(stored) !== undefined,
108
+ };
@@ -6,6 +6,8 @@ export interface FilterPrintCodec<Field, ReferenceValue> {
6
6
  readonly quote?: (value: string) => string;
7
7
  readonly namespace?: string;
8
8
  readonly used?: (helper: string) => void;
9
+ /** Prints a `USER` value (`userRef("…")`); without it such a value cannot print (#2891). */
10
+ readonly user?: (email: string) => string;
9
11
  }
10
12
  /** Print every canonical filter through the same public `filter.*` authoring surface. */
11
13
  export declare function printFilter<Field, ReferenceValue>(filter: Filter<Field, ReferenceValue>, codec: FilterPrintCodec<Field, ReferenceValue>): string;
@@ -11,14 +11,22 @@ export function printFilter(filter, codec) {
11
11
  const literals = "value" in filter ? [filter.value]
12
12
  : "values" in filter ? filter.values
13
13
  : "min" in filter ? [filter.min, filter.max] : [];
14
- const uuidValues = literals.length > 0 && literals.every((literal) => literal.type === "UUID");
14
+ const uuidValues = literals.length > 0 && literals.every((literal) => literal.type === "UUID" || (literal.type === "USER" && literal.valueType === "UUID"));
15
15
  const explicitType = uuidValues ? `, ${quote("UUID")}` : "";
16
16
  const impliedLiteralType = stringLiteralTypeImpliedBy(filter, uuidValues);
17
- const value = (input) => input.type === "UUID"
18
- ? uuidValues ? quote(input.value) : `{ type: "UUID", value: ${quote(input.value)} }`
19
- : (input.type === "TEXT" || input.type === "DATE" || input.type === "DATETIME") && impliedLiteralType !== undefined && input.type !== impliedLiteralType
20
- ? `{ type: ${quote(input.type)}, value: ${quote(input.value)} }`
21
- : printFilterValue(input, codec, call, quote);
17
+ // An option selection prints as `filter.textOption(label)` whatever the
18
+ // left side implies: a bare or wrapped TEXT literal builds as a raw word (#1733).
19
+ const value = (input) => input.type === "TEXT" && input.option === true
20
+ ? printFilterValue(input, codec, call, quote)
21
+ // A UUID-wrapped user among other value types would rebuild as TEXT from
22
+ // a bare `userRef(...)`: name the wrapper, as a UUID literal does.
23
+ : input.type === "USER" && input.valueType === "UUID" && !uuidValues
24
+ ? `{ type: "USER", email: ${quote(input.email)}, valueType: "UUID" }`
25
+ : input.type === "UUID"
26
+ ? uuidValues ? quote(input.value) : `{ type: "UUID", value: ${quote(input.value)} }`
27
+ : (input.type === "TEXT" || input.type === "DATE" || input.type === "DATETIME") && impliedLiteralType !== undefined && input.type !== impliedLiteralType
28
+ ? `{ type: ${quote(input.type)}, value: ${quote(input.value)} }`
29
+ : printFilterValue(input, codec, call, quote);
22
30
  if ("leftValue" in filter && filter.leftValue?.type === "FIELD") {
23
31
  const operand = filter.leftValue;
24
32
  if ((operand.aspect != null && operand.aspect !== "") || (operand.treatNullAsEquals != null && operand.treatNullAsEquals !== true)) {
@@ -123,6 +131,11 @@ function printFilterValue(value, codec, call, quote) {
123
131
  return call("fieldValue", `${codec.field(value.value)}, { ${options.join(", ")} }`);
124
132
  }
125
133
  case "CURRENT_USER": return call("currentUser", quote(value.valueType ?? "ID"));
134
+ case "USER": {
135
+ if (codec.user === undefined)
136
+ throw new EntityTfError(`a user filter value (${value.email}) has no printed form here`);
137
+ return codec.user(value.email);
138
+ }
126
139
  case "REFERENCE": {
127
140
  const options = value.multiple === true ? ", { multiple: true }" : "";
128
141
  // Stored HCL real_type is uppercased as-is. DECIMAL and INTEGER are
@@ -96,6 +96,13 @@ export interface FilterToTfCodec {
96
96
  * lookup, whichever wrapper that is.
97
97
  */
98
98
  readonly literal?: (value: TfValue, field: unknown | undefined, valueType: string, isOptionLabel: boolean) => TfValue;
99
+ /** A `userRef(email)` value's user id; without it such a value cannot encode (#2891). */
100
+ readonly user?: (email: string) => TfValue;
101
+ /**
102
+ * The owner keeps an option label its field no longer lists as written
103
+ * (a pulled automation, #1733), and its `literal` hook already warned.
104
+ */
105
+ readonly keepUnresolvedOptions?: boolean;
99
106
  /** A RECORD_FIELD value's source-record field; without it only raw platform ids encode. */
100
107
  readonly recordField?: (value: unknown) => TfValue;
101
108
  /** The owning app or element an `includeOwner` RECORD_FIELD value stores; without it such a value cannot encode. */
@@ -124,19 +131,21 @@ export interface FilterFromTfCodec<Field = string, ReferenceValue = never> {
124
131
  */
125
132
  readonly referenceType?: (value: TfValue, fallback: ValueType) => ValueType;
126
133
  readonly literal?: (value: TfValue, valueType: string, field?: Field) => TfValue;
134
+ /** The email of a user lookup a TEXT or UUID value holds, or undefined when it holds none (#2891). */
135
+ readonly user?: (value: TfValue) => string | undefined;
127
136
  /** Decode a RECORD_FIELD value's source-record field reference; without it only raw platform ids decode. */
128
137
  readonly recordField?: (value: TfValue) => Field;
129
138
  /** Whether a RECORD_FIELD `object` reference names the owning app or element; without it only raw platform ids decode. */
130
139
  readonly recordFieldOwner?: (value: TfValue) => boolean;
131
140
  /**
132
- * A TEXT-wrapped literal `literal` resolved from an option-id lookup is an
133
- * option LABEL, not a stored word. Set this when the owner cannot rebuild a
134
- * bare label into the same lookup — list views keep raw words literal, so
135
- * dropping the fact there rewrites the stored wrapper type. Owners that
136
- * always resolve labels (access policies) leave it off and keep printing
137
- * plain labels.
141
+ * A TEXT-wrapped literal that `literal` resolved from an option-id lookup or
142
+ * a raw option id is an option LABEL, not a stored word. Set this when the
143
+ * owner keeps a bare string as raw text, as list views and automations do
144
+ * (#1733), so the label prints as `filter.textOption(...)`. An owner whose
145
+ * hook also rewrites non-option values (an access policy's stage keys)
146
+ * passes a predicate naming which stored values are option lookups.
138
147
  */
139
- readonly optionLookupsAreIdentities?: boolean;
148
+ readonly optionLookupsAreIdentities?: boolean | ((stored: TfValue) => boolean);
140
149
  }
141
150
  export type WireFilterValue = Readonly<{
142
151
  type: string;
@@ -199,6 +199,17 @@ function wireFilterValueToTf(value, field, codec, role = "value", operator) {
199
199
  }
200
200
  return { type, current_user_type: currentUserType.toLowerCase() };
201
201
  }
202
+ if (type === "user") {
203
+ if (typeof raw.email !== "string" || raw.email === "")
204
+ throw new EntityTfError("userRef filter value requires an email");
205
+ if (codec.user === undefined) {
206
+ throw new EntityTfError(`userRef(${JSON.stringify(raw.email)}) as a filter value is supported only in automation filters`);
207
+ }
208
+ const valueType = String(raw.valueType ?? "TEXT").toLowerCase();
209
+ if (valueType !== "text" && valueType !== "uuid")
210
+ throw new EntityTfError(`userRef filter value type must be TEXT or UUID, not ${valueType.toUpperCase()}`);
211
+ return { type: valueType, value: codec.user(raw.email) };
212
+ }
202
213
  if (type === "reference") {
203
214
  const reference = raw.value ?? raw.valueReference ?? raw.value_reference;
204
215
  if (reference === undefined)
@@ -280,7 +291,7 @@ function wireFilterValueToTf(value, field, codec, role = "value", operator) {
280
291
  const resolved = codec.literal?.(raw.value, field, type, isOptionLabel) ?? raw.value;
281
292
  // Writing an option label where the platform stored an id is a silent data
282
293
  // change on a live view. Only a resolved lookup is an expression.
283
- if (raw.option === true && !isTfExpr(resolved)) {
294
+ if (raw.option === true && !isTfExpr(resolved) && codec.keepUnresolvedOptions !== true) {
284
295
  throw new EntityTfError(`option selection ${JSON.stringify(raw.value)} has no declared option identity`);
285
296
  }
286
297
  if (isTfExpr(resolved))
@@ -564,6 +575,11 @@ export function filterFromTf(value, codec, fieldScope = "app") {
564
575
  }
565
576
  function filterValueFromTf(value, codec, fieldScope, field) {
566
577
  const type = value.type.toLowerCase();
578
+ if ((type === "text" || type === "uuid") && codec.user !== undefined && value.value !== undefined) {
579
+ const email = codec.user(value.value);
580
+ if (email !== undefined)
581
+ return { type: "USER", email, valueType: type === "uuid" ? "UUID" : "TEXT" };
582
+ }
567
583
  const literal = codec.literal?.(value.value, type, field) ?? value.value;
568
584
  if (["text", "uuid", "number", "boolean", "date", "datetime"].includes(type) && typeof literal === "object" && literal !== null) {
569
585
  throw new EntityTfError(`${type} filter literal contains an unresolved expression or object`);
@@ -641,10 +657,14 @@ function filterValueFromTf(value, codec, fieldScope, field) {
641
657
  case "number": return { type: "NUMBER", value: typeof literal === "number" ? literal : Number(literal) };
642
658
  case "boolean": return { type: "BOOLEAN", value: typeof literal === "boolean" ? literal : String(literal).toLowerCase() === "true" };
643
659
  case "text": {
644
- // `type` stays the stored wrapper. An expression the codec collapsed to a
645
- // plain string was an id lookup, so this literal is an option LABEL —
646
- // the second, independent fact, which a TEXT wrapper cannot express.
647
- const option = codec.optionLookupsAreIdentities === true && isTfExpr(value.value);
660
+ // `type` stays the stored wrapper. A value the literal hook rewrote, an
661
+ // id lookup expression or a raw option id, was an option, so this
662
+ // literal is its LABEL: the second, independent fact, which a TEXT
663
+ // wrapper cannot express. Any other stored text stays plain (#1733).
664
+ const identities = codec.optionLookupsAreIdentities;
665
+ const option = typeof identities === "function"
666
+ ? identities(value.value)
667
+ : identities === true && (isTfExpr(value.value) || literal !== value.value);
648
668
  return { type: "TEXT", value: String(literal), ...(option && { option: true }) };
649
669
  }
650
670
  case "uuid":
@@ -69,6 +69,10 @@ export type FilterValue<FieldValue = string, ReferenceValue = FilterReference> =
69
69
  } | {
70
70
  type: "CURRENT_USER";
71
71
  valueType?: "ID" | "EMAIL" | "DOMAIN";
72
+ } | {
73
+ type: "USER";
74
+ email: string;
75
+ valueType: "TEXT" | "UUID";
72
76
  } | ({
73
77
  type: "RECORD_FIELD";
74
78
  field: FieldValue | string;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * A raw option id where an option is selected (#1733). Dax, 2026-11-03: "both
3
+ * should be supported. Anything that references ids should warn and mention
4
+ * the preferred method". A raw id builds as written, and build warns with the
5
+ * `filter.textOption(label)` spelling, naming the label when it is known.
6
+ */
7
+ import type { OptionIdIndex } from "../../engine/pull/field-refs-registry.js";
8
+ export interface RawOptionIdInput {
9
+ /** Where the id is used, e.g. `automation field "Club"`. */
10
+ readonly slot: string;
11
+ readonly fieldName: string;
12
+ readonly id: string;
13
+ /** The field's current option labels from source. */
14
+ readonly options: readonly string[];
15
+ /** The field's `<label>_options_by_label` local, when it has one in this workspace. */
16
+ readonly localName?: string;
17
+ readonly index?: OptionIdIndex;
18
+ }
19
+ /**
20
+ * The warning for a plain string compared with a Dropdown or Multi-Select
21
+ * with static options (#1733). Dax, 2026-11-03: "1733: warn on plain-string
22
+ * dropdown filters and point to textOption". `resolvesLabels` says what the
23
+ * filter's owner does with a string that matches an option label: access
24
+ * policies, dashboards, relationships and dynamic layouts resolve it to the
25
+ * option id, while automations and views send the word as written. A raw
26
+ * option id gets {@link rawOptionIdWarning} instead.
27
+ */
28
+ export declare function plainOptionStringWarning(slot: string, fieldName: string, value: string, options: readonly string[], resolvesLabels: boolean): string;
29
+ /** The warning for a raw option id: its option's label, a deleted option, or an unknown label. */
30
+ export declare function rawOptionIdWarning(input: RawOptionIdInput): string;