@elementumai/edk 0.9.2 → 0.9.6

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 (296) hide show
  1. package/README.md +34 -26
  2. package/dist-sdk/elementum-entity-client/clients/automation/models/automation.d.ts +1 -1
  3. package/dist-sdk/elementum-entity-client/clients/skills/models/skill.d.ts +1 -1
  4. package/dist-sdk/elementum-entity-client/clients/skills/models/skill.js +1 -1
  5. package/dist-sdk/pull/util.d.ts +1 -1
  6. package/dist-sdk/pull/util.js +3 -3
  7. package/dist-sdk/src/catalog/factories.d.ts +49 -10
  8. package/dist-sdk/src/catalog/factories.js +94 -13
  9. package/dist-sdk/src/catalog/from-authoring.d.ts +5 -5
  10. package/dist-sdk/src/catalog/from-authoring.js +7 -7
  11. package/dist-sdk/src/catalog/index.d.ts +2 -2
  12. package/dist-sdk/src/catalog/index.js +1 -1
  13. package/dist-sdk/src/catalog/org.js +62 -4
  14. package/dist-sdk/src/catalog/render-helpers.d.ts +1 -1
  15. package/dist-sdk/src/catalog/render-helpers.js +1 -1
  16. package/dist-sdk/src/catalog/render.d.ts +1 -0
  17. package/dist-sdk/src/catalog/render.js +2 -2
  18. package/dist-sdk/src/catalog/token.js +11 -4
  19. package/dist-sdk/src/catalog/types.d.ts +33 -4
  20. package/dist-sdk/src/catalog/types.js +5 -0
  21. package/dist-sdk/src/core/index.d.ts +10 -10
  22. package/dist-sdk/src/core/index.js +9 -9
  23. package/dist-sdk/src/core/render-tree.d.ts +1 -1
  24. package/dist-sdk/src/core/render-tree.js +1 -2
  25. package/dist-sdk/src/core/types/ai-provider.d.ts +1 -1
  26. package/dist-sdk/src/core/types/ai-provider.js +1 -1
  27. package/dist-sdk/src/core/types/app.d.ts +66 -30
  28. package/dist-sdk/src/core/types/app.js +2 -2
  29. package/dist-sdk/src/core/types/aspect-category.d.ts +4 -4
  30. package/dist-sdk/src/core/types/aspect-category.js +4 -4
  31. package/dist-sdk/src/core/types/cloud-link.d.ts +3 -3
  32. package/dist-sdk/src/core/types/cloud-link.js +3 -3
  33. package/dist-sdk/src/core/types/display-block.d.ts +2 -2
  34. package/dist-sdk/src/core/types/display-block.js +2 -2
  35. package/dist-sdk/src/core/types/group.d.ts +1 -1
  36. package/dist-sdk/src/core/types/group.js +1 -1
  37. package/dist-sdk/src/core/types/user.d.ts +1 -1
  38. package/dist-sdk/src/core/types/user.js +1 -1
  39. package/dist-sdk/src/core/wire/ref-serializer.js +3 -3
  40. package/dist-sdk/src/engine/build/context.d.ts +20 -13
  41. package/dist-sdk/src/engine/entity.d.ts +1 -1
  42. package/dist-sdk/src/engine/pull/context.d.ts +34 -0
  43. package/dist-sdk/src/engine/pull/context.js +14 -0
  44. package/dist-sdk/src/engine/pull/org.d.ts +9 -0
  45. package/dist-sdk/src/engine/pull/org.js +33 -0
  46. package/dist-sdk/src/engine/pull/ref-only.d.ts +37 -0
  47. package/dist-sdk/src/engine/pull/ref-only.js +204 -0
  48. package/dist-sdk/src/engine/tf/expr.d.ts +6 -2
  49. package/dist-sdk/src/engine/tf/expr.js +18 -13
  50. package/dist-sdk/src/engine/tf/index.d.ts +1 -1
  51. package/dist-sdk/src/engine/tf/index.js +1 -1
  52. package/dist-sdk/src/engine/tf/model.d.ts +8 -1
  53. package/dist-sdk/src/engine/tf/model.js +4 -0
  54. package/dist-sdk/src/engine/tf/parse.js +13 -2
  55. package/dist-sdk/src/engine/tf/render.js +4 -0
  56. package/dist-sdk/src/entities/access-policy/build.d.ts +4 -5
  57. package/dist-sdk/src/entities/access-policy/build.js +1 -1
  58. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +4 -4
  59. package/dist-sdk/src/entities/access-policy/from-tf.js +12 -13
  60. package/dist-sdk/src/entities/access-policy/principal.d.ts +14 -4
  61. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +14 -2
  62. package/dist-sdk/src/entities/access-policy/to-tf.js +36 -6
  63. package/dist-sdk/src/entities/agent/build.d.ts +3 -3
  64. package/dist-sdk/src/entities/agent/build.js +5 -5
  65. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +6 -1
  66. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +68 -18
  67. package/dist-sdk/src/entities/agent/from-tf.d.ts +3 -1
  68. package/dist-sdk/src/entities/agent/from-tf.js +12 -4
  69. package/dist-sdk/src/entities/agent/index.d.ts +2 -2
  70. package/dist-sdk/src/entities/agent/index.js +1 -1
  71. package/dist-sdk/src/entities/agent/module.js +2 -0
  72. package/dist-sdk/src/entities/agent/to-tf.d.ts +5 -2
  73. package/dist-sdk/src/entities/agent/to-tf.js +56 -8
  74. package/dist-sdk/src/entities/agent/tools.d.ts +38 -23
  75. package/dist-sdk/src/entities/agent/tools.js +21 -7
  76. package/dist-sdk/src/entities/agent-evaluation/build.d.ts +19 -0
  77. package/dist-sdk/src/entities/agent-evaluation/build.js +41 -0
  78. package/dist-sdk/src/entities/agent-evaluation/deserializer/print-agent-evaluation.d.ts +4 -0
  79. package/dist-sdk/src/entities/agent-evaluation/deserializer/print-agent-evaluation.js +30 -0
  80. package/dist-sdk/src/entities/agent-evaluation/from-tf.d.ts +12 -0
  81. package/dist-sdk/src/entities/agent-evaluation/from-tf.js +46 -0
  82. package/dist-sdk/src/entities/agent-evaluation/index.d.ts +1 -0
  83. package/dist-sdk/src/entities/agent-evaluation/index.js +1 -0
  84. package/dist-sdk/src/entities/agent-evaluation/module.d.ts +3 -0
  85. package/dist-sdk/src/entities/agent-evaluation/module.js +58 -0
  86. package/dist-sdk/src/entities/agent-evaluation/to-tf.d.ts +12 -0
  87. package/dist-sdk/src/entities/agent-evaluation/to-tf.js +35 -0
  88. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +8 -7
  89. package/dist-sdk/src/entities/agent-tool/from-tf.js +48 -6
  90. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +10 -2
  91. package/dist-sdk/src/entities/agent-tool/to-tf.js +76 -28
  92. package/dist-sdk/src/entities/agent-tool/types.d.ts +0 -1
  93. package/dist-sdk/src/entities/agent-tool/types.js +10 -37
  94. package/dist-sdk/src/entities/app/build.d.ts +97 -42
  95. package/dist-sdk/src/entities/app/build.js +25 -14
  96. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +32 -24
  97. package/dist-sdk/src/entities/app/deserializer/pulled-expression.d.ts +1 -1
  98. package/dist-sdk/src/entities/app/deserializer/pulled-expression.js +2 -0
  99. package/dist-sdk/src/entities/app/index.d.ts +11 -8
  100. package/dist-sdk/src/entities/app/index.js +10 -7
  101. package/dist-sdk/src/entities/app/module.js +2 -2
  102. package/dist-sdk/src/entities/app/to-tf.d.ts +1 -1
  103. package/dist-sdk/src/entities/app/to-tf.js +22 -6
  104. package/dist-sdk/src/entities/approval-chain/build.d.ts +1 -1
  105. package/dist-sdk/src/entities/approval-chain/build.js +5 -5
  106. package/dist-sdk/src/entities/approval-chain/index.d.ts +1 -1
  107. package/dist-sdk/src/entities/approval-chain/index.js +1 -1
  108. package/dist-sdk/src/entities/approval-chain/printer.js +2 -2
  109. package/dist-sdk/src/entities/automation/build.d.ts +172 -94
  110. package/dist-sdk/src/entities/automation/build.js +159 -68
  111. package/dist-sdk/src/entities/automation/calculation-expression.d.ts +191 -0
  112. package/dist-sdk/src/entities/automation/calculation-expression.js +57 -0
  113. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +11 -4
  114. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +18 -14
  115. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +164 -198
  116. package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -2
  117. package/dist-sdk/src/entities/automation/from-tf.js +510 -80
  118. package/dist-sdk/src/entities/automation/index.d.ts +9 -12
  119. package/dist-sdk/src/entities/automation/index.js +11 -13
  120. package/dist-sdk/src/entities/automation/module.js +74 -6
  121. package/dist-sdk/src/entities/automation/operators.d.ts +32 -48
  122. package/dist-sdk/src/entities/automation/operators.js +10 -37
  123. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +1 -1
  124. package/dist-sdk/src/entities/automation/output-key-wire-name.js +1 -1
  125. package/dist-sdk/src/entities/automation/script-code.js +13 -22
  126. package/dist-sdk/src/entities/automation/serialize.js +1 -1
  127. package/dist-sdk/src/entities/automation/tasks.d.ts +153 -89
  128. package/dist-sdk/src/entities/automation/tasks.js +64 -11
  129. package/dist-sdk/src/entities/automation/to-tf.d.ts +10 -1
  130. package/dist-sdk/src/entities/automation/to-tf.js +342 -71
  131. package/dist-sdk/src/entities/automation/triggers.d.ts +17 -10
  132. package/dist-sdk/src/entities/automation/triggers.js +7 -1
  133. package/dist-sdk/src/entities/automation/types.d.ts +3 -2
  134. package/dist-sdk/src/entities/automation/types.js +3 -2
  135. package/dist-sdk/src/entities/chart/build.d.ts +95 -0
  136. package/dist-sdk/src/entities/chart/build.js +42 -0
  137. package/dist-sdk/src/entities/chart/from-tf.d.ts +55 -0
  138. package/dist-sdk/src/entities/chart/from-tf.js +269 -0
  139. package/dist-sdk/src/entities/chart/index.d.ts +4 -0
  140. package/dist-sdk/src/entities/chart/index.js +3 -0
  141. package/dist-sdk/src/entities/chart/module.d.ts +3 -0
  142. package/dist-sdk/src/entities/chart/module.js +61 -0
  143. package/dist-sdk/src/entities/chart/printer.d.ts +5 -0
  144. package/dist-sdk/src/entities/chart/printer.js +104 -0
  145. package/dist-sdk/src/entities/chart/to-tf.d.ts +15 -0
  146. package/dist-sdk/src/entities/chart/to-tf.js +150 -0
  147. package/dist-sdk/src/entities/chart/types.d.ts +53 -0
  148. package/dist-sdk/src/entities/chart/types.js +22 -0
  149. package/dist-sdk/src/entities/dashboard/build.d.ts +34 -7
  150. package/dist-sdk/src/entities/dashboard/build.js +16 -1
  151. package/dist-sdk/src/entities/dashboard/from-tf.js +22 -4
  152. package/dist-sdk/src/entities/dashboard/to-tf.d.ts +16 -3
  153. package/dist-sdk/src/entities/dashboard/to-tf.js +37 -10
  154. package/dist-sdk/src/entities/datamine/module.js +1 -1
  155. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +4 -3
  156. package/dist-sdk/src/entities/dynamic-layout/build.js +1 -1
  157. package/dist-sdk/src/entities/dynamic-layout/dialect.d.ts +2 -0
  158. package/dist-sdk/src/entities/dynamic-layout/dialect.js +43 -5
  159. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +12 -6
  160. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +10 -10
  161. package/dist-sdk/src/entities/element/build.d.ts +25 -32
  162. package/dist-sdk/src/entities/element/build.js +15 -32
  163. package/dist-sdk/src/entities/element/index.d.ts +7 -5
  164. package/dist-sdk/src/entities/element/index.js +7 -4
  165. package/dist-sdk/src/entities/element/module.js +7 -3
  166. package/dist-sdk/src/entities/element/to-tf.d.ts +2 -1
  167. package/dist-sdk/src/entities/element/to-tf.js +7 -3
  168. package/dist-sdk/src/entities/field/build.d.ts +51 -24
  169. package/dist-sdk/src/entities/field/build.js +31 -6
  170. package/dist-sdk/src/entities/field/calc/aggregate.d.ts +52 -21
  171. package/dist-sdk/src/entities/field/calc/aggregate.js +59 -29
  172. package/dist-sdk/src/entities/field/calc/date.d.ts +78 -29
  173. package/dist-sdk/src/entities/field/calc/date.js +120 -29
  174. package/dist-sdk/src/entities/field/calc/index.d.ts +80 -85
  175. package/dist-sdk/src/entities/field/calc/index.js +82 -139
  176. package/dist-sdk/src/entities/field/calc/numeric.d.ts +8 -12
  177. package/dist-sdk/src/entities/field/calc/numeric.js +10 -27
  178. package/dist-sdk/src/entities/field/calc/runtime.d.ts +19 -2
  179. package/dist-sdk/src/entities/field/calc/runtime.js +79 -8
  180. package/dist-sdk/src/entities/field/calc/text.d.ts +32 -23
  181. package/dist-sdk/src/entities/field/calc/text.js +43 -31
  182. package/dist-sdk/src/entities/field/calc/types.d.ts +36 -81
  183. package/dist-sdk/src/entities/field/calc/types.js +1 -22
  184. package/dist-sdk/src/entities/field/calc.d.ts +71 -48
  185. package/dist-sdk/src/entities/field/calc.js +5 -15
  186. package/dist-sdk/src/entities/field/calculation-types.js +10 -3
  187. package/dist-sdk/src/entities/field/from-tf.js +156 -10
  188. package/dist-sdk/src/entities/field/locals.d.ts +11 -3
  189. package/dist-sdk/src/entities/field/locals.js +15 -2
  190. package/dist-sdk/src/entities/field/module.js +23 -6
  191. package/dist-sdk/src/entities/field/record-shape.d.ts +24 -10
  192. package/dist-sdk/src/entities/field/to-tf.d.ts +40 -1
  193. package/dist-sdk/src/entities/field/to-tf.js +293 -35
  194. package/dist-sdk/src/entities/field/types.d.ts +1 -1
  195. package/dist-sdk/src/entities/field/types.js +7 -1
  196. package/dist-sdk/src/entities/file-reader/build.d.ts +5 -0
  197. package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.js +1 -1
  198. package/dist-sdk/src/entities/org/cloud-link.js +4 -5
  199. package/dist-sdk/src/entities/org/email-alias.d.ts +2 -0
  200. package/dist-sdk/src/entities/org/email-alias.js +12 -0
  201. package/dist-sdk/src/entities/org/index.d.ts +1 -0
  202. package/dist-sdk/src/entities/org/index.js +1 -0
  203. package/dist-sdk/src/entities/org/phone-provider.js +4 -7
  204. package/dist-sdk/src/entities/organization/build.d.ts +214 -2
  205. package/dist-sdk/src/entities/organization/build.js +145 -4
  206. package/dist-sdk/src/entities/organization/index.d.ts +1 -1
  207. package/dist-sdk/src/entities/organization/index.js +1 -1
  208. package/dist-sdk/src/entities/organization/module.js +4 -1
  209. package/dist-sdk/src/entities/organization/to-tf.d.ts +1 -0
  210. package/dist-sdk/src/entities/organization/to-tf.js +118 -1
  211. package/dist-sdk/src/entities/phone-service/build.d.ts +1 -1
  212. package/dist-sdk/src/entities/phone-service/build.js +2 -2
  213. package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.js +5 -3
  214. package/dist-sdk/src/entities/phone-service/index.d.ts +1 -1
  215. package/dist-sdk/src/entities/phone-service/index.js +1 -1
  216. package/dist-sdk/src/entities/phone-service/types.js +1 -1
  217. package/dist-sdk/src/entities/record-create-form/to-tf.js +9 -1
  218. package/dist-sdk/src/entities/relationship/to-tf.d.ts +1 -0
  219. package/dist-sdk/src/entities/relationship/to-tf.js +5 -13
  220. package/dist-sdk/src/entities/search-table/build.d.ts +4 -4
  221. package/dist-sdk/src/entities/search-table/build.js +13 -13
  222. package/dist-sdk/src/entities/search-table/index.d.ts +2 -2
  223. package/dist-sdk/src/entities/search-table/index.js +2 -2
  224. package/dist-sdk/src/entities/search-table/printer.js +5 -5
  225. package/dist-sdk/src/entities/service-account/to-tf.d.ts +21 -0
  226. package/dist-sdk/src/entities/service-account/to-tf.js +32 -1
  227. package/dist-sdk/src/entities/shared/context.d.ts +25 -24
  228. package/dist-sdk/src/entities/shared/context.js +36 -35
  229. package/dist-sdk/src/entities/shared/filters/ast.d.ts +10 -3
  230. package/dist-sdk/src/entities/shared/filters/ast.js +1 -0
  231. package/dist-sdk/src/entities/shared/filters/index.d.ts +2 -1
  232. package/dist-sdk/src/entities/shared/filters/index.js +11 -4
  233. package/dist-sdk/src/entities/shared/foreign-ref.d.ts +14 -0
  234. package/dist-sdk/src/entities/shared/foreign-ref.js +12 -0
  235. package/dist-sdk/src/entities/shared/ref.d.ts +26 -11
  236. package/dist-sdk/src/entities/shared/ref.js +8 -3
  237. package/dist-sdk/src/entities/shared/types/common.d.ts +2 -2
  238. package/dist-sdk/src/entities/shared/types/field-types.d.ts +1 -1
  239. package/dist-sdk/src/entities/shared/types/field-types.js +1 -1
  240. package/dist-sdk/src/entities/skill/build.d.ts +2 -2
  241. package/dist-sdk/src/entities/skill/build.js +3 -3
  242. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +1 -1
  243. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +26 -7
  244. package/dist-sdk/src/entities/skill/index.d.ts +1 -1
  245. package/dist-sdk/src/entities/skill/index.js +1 -1
  246. package/dist-sdk/src/entities/skill/module.js +2 -2
  247. package/dist-sdk/src/entities/skill/to-tf.d.ts +1 -1
  248. package/dist-sdk/src/entities/skill/to-tf.js +2 -2
  249. package/dist-sdk/src/entities/skill/tools.d.ts +4 -3
  250. package/dist-sdk/src/entities/skill/tools.js +4 -3
  251. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +13 -0
  252. package/dist-sdk/src/entities/skill-tool/from-tf.js +42 -0
  253. package/dist-sdk/src/entities/skill-tool/to-tf.js +6 -6
  254. package/dist-sdk/src/entities/table/build.d.ts +1 -1
  255. package/dist-sdk/src/entities/table/build.js +9 -9
  256. package/dist-sdk/src/entities/table/catalog-render.js +9 -1
  257. package/dist-sdk/src/entities/table/deserializer/normalize.js +4 -4
  258. package/dist-sdk/src/entities/table/fields/types.d.ts +1 -1
  259. package/dist-sdk/src/entities/table/fields/types.js +1 -1
  260. package/dist-sdk/src/entities/table/index.d.ts +2 -2
  261. package/dist-sdk/src/entities/table/index.js +3 -3
  262. package/dist-sdk/src/entities/table/module.js +1 -1
  263. package/dist-sdk/src/entities/table/to-tf.js +22 -30
  264. package/dist-sdk/src/entities/task/build.d.ts +1 -1
  265. package/dist-sdk/src/entities/task/build.js +5 -5
  266. package/dist-sdk/src/entities/task/index.d.ts +1 -1
  267. package/dist-sdk/src/entities/task/index.js +1 -1
  268. package/dist-sdk/src/entities/view/build.d.ts +46 -0
  269. package/dist-sdk/src/entities/view/build.js +19 -0
  270. package/dist-sdk/src/entities/view/from-tf.js +68 -18
  271. package/dist-sdk/src/entities/view/module.d.ts +6 -13
  272. package/dist-sdk/src/entities/view/module.js +7 -14
  273. package/dist-sdk/src/entities/view/sharing.d.ts +10 -0
  274. package/dist-sdk/src/entities/view/sharing.js +6 -0
  275. package/dist-sdk/src/entities/view/to-tf.d.ts +21 -19
  276. package/dist-sdk/src/entities/view/to-tf.js +61 -26
  277. package/dist-sdk/src/entities/view/types.js +3 -0
  278. package/dist-sdk/src/entities/visual-flow/build.d.ts +1 -1
  279. package/dist-sdk/src/entities/visual-flow/build.js +8 -8
  280. package/dist-sdk/src/entities/visual-flow/index.d.ts +1 -1
  281. package/dist-sdk/src/entities/visual-flow/index.js +1 -1
  282. package/dist-sdk/src/entities/visual-flow/module.js +1 -1
  283. package/dist-sdk/src/entities/visual-flow/printer.js +3 -3
  284. package/dist-sdk/src/entities/visual-flow/to-tf.d.ts +1 -0
  285. package/dist-sdk/src/entities/visual-flow/to-tf.js +3 -7
  286. package/dist-sdk/src/entities/widget/to-tf.d.ts +1 -0
  287. package/dist-sdk/src/entities/widget/to-tf.js +9 -7
  288. package/dist-sdk/src/graph/index.d.ts +5 -1
  289. package/dist-sdk/src/graph/index.js +4 -1
  290. package/dist-sdk/src/graph/modules.js +6 -1
  291. package/dist-sdk/src/graph/types.d.ts +52 -1
  292. package/dist-sdk/src/internal/safe-identifier.d.ts +4 -0
  293. package/dist-sdk/src/internal/safe-identifier.js +13 -0
  294. package/dist-sdk/src/internal/sdk-package.d.ts +1 -1
  295. package/dist-sdk/src/internal/sdk-package.js +1 -0
  296. package/package.json +12 -3
@@ -3,16 +3,16 @@
3
3
  *
4
4
  * The platform's calc grammar treats DATE and DATETIME as distinct
5
5
  * brands — DATE is calendar date (no time component), DATETIME is
6
- * instant-in-time. Most extraction functions accept either, and a few
7
- * builders are DATETIME-only (HOUR, MINUTE, SECOND, DATETIME_TRUNC).
6
+ * instant-in-time. Knowhere accepts either brand for date-part extraction
7
+ * and DATETIME_TRUNC.
8
8
  *
9
9
  * Constrained string arguments are typed as literal unions so the
10
10
  * agent gets autocomplete and compile-time validation:
11
- * - `dateDif` unit: 'D' | 'H' | 'M'
11
+ * - `dateDif` unit: 'S' | 'MIN' | 'H' | 'Y' | 'M' | 'D'
12
12
  * - `dateTimeTrunc` precision: a date-part literal union
13
13
  * - `weekday` mode: 1 | 2 | 3
14
14
  */
15
- import { coerce, makeExpr, emitStringLiteral } from "./runtime.js";
15
+ import { coerce, makeComposedExpr, makeExpr, emitStringLiteral } from "./runtime.js";
16
16
  // ---------------------------------------------------------------------------
17
17
  // Constructors
18
18
  // ---------------------------------------------------------------------------
@@ -20,10 +20,6 @@ import { coerce, makeExpr, emitStringLiteral } from "./runtime.js";
20
20
  export function now() {
21
21
  return makeExpr("datetime", () => `NOW()`);
22
22
  }
23
- /** Today's calendar date. Wire `TODAY()`. Returns DATE. */
24
- export function today() {
25
- return makeExpr("date", () => `TODAY()`);
26
- }
27
23
  /**
28
24
  * Build a DATE from numeric year / month / day components.
29
25
  * Wire `DATE(year, month, day)`. The `make` prefix avoids colliding
@@ -33,7 +29,16 @@ export function makeDate(year, month, day) {
33
29
  const y = coerce(year);
34
30
  const m = coerce(month);
35
31
  const d = coerce(day);
36
- return makeExpr("date", () => `DATE(${y.toCalcString()}, ${m.toCalcString()}, ${d.toCalcString()})`);
32
+ return makeComposedExpr("date", [y, m, d], () => `DATE(${y.toCalcString()}, ${m.toCalcString()}, ${d.toCalcString()})`);
33
+ }
34
+ /**
35
+ * Build a DATETIME from numeric date and time components.
36
+ * Wire `DATETIME(year, month, day, hour, minute, second)`.
37
+ */
38
+ export function dateTime(...values) {
39
+ const [year, month, day, hour, minute, second] = values;
40
+ const parts = [year, month, day, hour, minute, second].map((part) => coerce(part));
41
+ return makeComposedExpr("datetime", parts, () => `DATETIME(${parts.map((part) => part.toCalcString()).join(", ")})`);
37
42
  }
38
43
  /**
39
44
  * Parse a text expression into a DATE. The server accepts ISO-style
@@ -42,68 +47,154 @@ export function makeDate(year, month, day) {
42
47
  */
43
48
  export function dateValue(value) {
44
49
  const v = coerce(value);
45
- return makeExpr("date", () => `DATEVALUE(${v.toCalcString()})`);
50
+ return makeComposedExpr("date", [v], () => `DATEVALUE(${v.toCalcString()})`);
46
51
  }
52
+ // ---------------------------------------------------------------------------
53
+ // DATEDIF — difference between two dates/datetimes, in the specified unit.
54
+ // ---------------------------------------------------------------------------
55
+ /** Discoverable unit codes accepted by the wire `DATEDIF` function. */
56
+ export const dateDifUnit = {
57
+ seconds: "S",
58
+ minutes: "MIN",
59
+ hours: "H",
60
+ years: "Y",
61
+ months: "M",
62
+ days: "D",
63
+ };
64
+ /** Human-readable date difference units accepted by {@link dateDiff}. */
65
+ export const dateDiffUnit = {
66
+ seconds: "seconds",
67
+ minutes: "minutes",
68
+ hours: "hours",
69
+ years: "years",
70
+ months: "months",
71
+ days: "days",
72
+ };
73
+ const DATE_DIFF_UNIT_WIRE = {
74
+ seconds: "S",
75
+ minutes: "MIN",
76
+ hours: "H",
77
+ years: "Y",
78
+ months: "M",
79
+ days: "D",
80
+ };
47
81
  /**
48
82
  * Difference between `end` and `start` in the specified unit.
49
- * - `'D'` — days
50
- * - `'H'` — hours
51
- * - `'M'` — months
83
+ * - `'S'` — seconds; `'MIN'` — minutes; `'H'` — hours
84
+ * - `'D'` — days; `'M'` — months; `'Y'` — years
52
85
  */
86
+ /** @deprecated Prefer {@link dateDiff} with human-readable units. */
53
87
  export function dateDif(start, end, unit) {
54
88
  const s = coerce(start);
55
89
  const e = coerce(end);
56
- return makeExpr("number", () => `DATEDIF(${s.toCalcString()}, ${e.toCalcString()}, ${emitStringLiteral(unit)})`);
90
+ return makeComposedExpr("number", [s, e], () => `DATEDIF(${s.toCalcString()}, ${e.toCalcString()}, ${emitStringLiteral(unit)})`);
91
+ }
92
+ /** Difference between two dates using a readable unit name. */
93
+ export function dateDiff(start, end, unit) {
94
+ return dateDif(start, end, DATE_DIFF_UNIT_WIRE[unit]);
57
95
  }
96
+ // ---------------------------------------------------------------------------
97
+ // DATETIME_TRUNC — truncate a datetime to the given precision.
98
+ // ---------------------------------------------------------------------------
99
+ /** Discoverable precision values accepted by `DATETIME_TRUNC`. */
100
+ export const dateTimeTruncPrecision = {
101
+ microseconds: "MICROSECONDS",
102
+ milliseconds: "MILLISECONDS",
103
+ second: "SECOND",
104
+ minute: "MINUTE",
105
+ hour: "HOUR",
106
+ day: "DAY",
107
+ week: "WEEK",
108
+ month: "MONTH",
109
+ quarter: "QUARTER",
110
+ year: "YEAR",
111
+ decade: "DECADE",
112
+ century: "CENTURY",
113
+ millennium: "MILLENNIUM",
114
+ };
115
+ const DATE_TIME_PRECISION_WIRE = {
116
+ microseconds: "MICROSECONDS",
117
+ milliseconds: "MILLISECONDS",
118
+ second: "SECOND",
119
+ minute: "MINUTE",
120
+ hour: "HOUR",
121
+ day: "DAY",
122
+ week: "WEEK",
123
+ month: "MONTH",
124
+ quarter: "QUARTER",
125
+ year: "YEAR",
126
+ decade: "DECADE",
127
+ century: "CENTURY",
128
+ millennium: "MILLENNIUM",
129
+ };
58
130
  /**
59
- * Truncate a DATETIME to the given precision. E.g.
131
+ * Truncate a DATE or DATETIME to the given precision. E.g.
60
132
  * `dateTimeTrunc(t, "MONTH")` returns the first instant of `t`'s month.
61
133
  */
134
+ /** @deprecated Prefer {@link truncateDateTime} with human-readable precision. */
62
135
  export function dateTimeTrunc(value, precision) {
63
136
  const v = coerce(value);
64
- return makeExpr("datetime", () => `DATETIME_TRUNC(${v.toCalcString()}, ${emitStringLiteral(precision)})`);
137
+ return makeComposedExpr("datetime", [v], () => `DATETIME_TRUNC(${v.toCalcString()}, ${emitStringLiteral(precision)})`);
65
138
  }
139
+ /** Truncate a date/datetime using a readable precision name. */
140
+ export function truncateDateTime(value, precision) {
141
+ return dateTimeTrunc(value, DATE_TIME_PRECISION_WIRE[precision]);
142
+ }
143
+ // ---------------------------------------------------------------------------
144
+ // WEEKDAY — day-of-week as a number, with optional mode.
145
+ // ---------------------------------------------------------------------------
146
+ /**
147
+ * Modes accepted by the wire `WEEKDAY` function.
148
+ * - 1 — Sunday=1 .. Saturday=7 (default)
149
+ * - 2 — Monday=1 .. Sunday=7
150
+ * - 3 — Monday=0 .. Sunday=6
151
+ */
152
+ export const weekdayMode = {
153
+ sundayOne: 1,
154
+ mondayOne: 2,
155
+ mondayZero: 3,
156
+ };
66
157
  /**
67
158
  * Day-of-week as a numeric, optionally selecting the numbering scheme.
68
159
  */
69
160
  export function weekday(value, mode) {
70
161
  const v = coerce(value);
71
162
  if (mode === undefined) {
72
- return makeExpr("number", () => `WEEKDAY(${v.toCalcString()})`);
163
+ return makeComposedExpr("number", [v], () => `WEEKDAY(${v.toCalcString()})`);
73
164
  }
74
- return makeExpr("number", () => `WEEKDAY(${v.toCalcString()}, ${mode})`);
165
+ const wireMode = typeof mode === "string" ? weekdayMode[mode] : mode;
166
+ return makeComposedExpr("number", [v], () => `WEEKDAY(${v.toCalcString()}, ${wireMode})`);
75
167
  }
76
168
  // ---------------------------------------------------------------------------
77
- // Date-part extraction — YEAR/MONTH/DAY accept date|datetime;
78
- // HOUR/MINUTE/SECOND accept datetime only.
169
+ // Date-part extraction — all six functions accept date|datetime in Knowhere.
79
170
  // ---------------------------------------------------------------------------
80
171
  /** Year component as NUMBER. */
81
172
  export function year(value) {
82
173
  const v = coerce(value);
83
- return makeExpr("number", () => `YEAR(${v.toCalcString()})`);
174
+ return makeComposedExpr("number", [v], () => `YEAR(${v.toCalcString()})`);
84
175
  }
85
176
  /** Month component (1–12) as NUMBER. */
86
177
  export function month(value) {
87
178
  const v = coerce(value);
88
- return makeExpr("number", () => `MONTH(${v.toCalcString()})`);
179
+ return makeComposedExpr("number", [v], () => `MONTH(${v.toCalcString()})`);
89
180
  }
90
181
  /** Day-of-month (1–31) as NUMBER. */
91
182
  export function day(value) {
92
183
  const v = coerce(value);
93
- return makeExpr("number", () => `DAY(${v.toCalcString()})`);
184
+ return makeComposedExpr("number", [v], () => `DAY(${v.toCalcString()})`);
94
185
  }
95
- /** Hour (0–23) from a DATETIME. */
186
+ /** Hour (0–23) from a DATE or DATETIME. */
96
187
  export function hour(value) {
97
188
  const v = coerce(value);
98
- return makeExpr("number", () => `HOUR(${v.toCalcString()})`);
189
+ return makeComposedExpr("number", [v], () => `HOUR(${v.toCalcString()})`);
99
190
  }
100
- /** Minute (0–59) from a DATETIME. */
191
+ /** Minute (0–59) from a DATE or DATETIME. */
101
192
  export function minute(value) {
102
193
  const v = coerce(value);
103
- return makeExpr("number", () => `MINUTE(${v.toCalcString()})`);
194
+ return makeComposedExpr("number", [v], () => `MINUTE(${v.toCalcString()})`);
104
195
  }
105
- /** Second (0–59) from a DATETIME. */
196
+ /** Second (0–59) from a DATE or DATETIME. */
106
197
  export function second(value) {
107
198
  const v = coerce(value);
108
- return makeExpr("number", () => `SECOND(${v.toCalcString()})`);
199
+ return makeComposedExpr("number", [v], () => `SECOND(${v.toCalcString()})`);
109
200
  }
@@ -1,32 +1,23 @@
1
1
  /**
2
2
  * Public surface of the calculated-field DSL — the `calc` namespace.
3
3
  *
4
- * v1 minimal scope:
5
- * - Arithmetic operators: plus, minus, times, dividedBy
6
- * - Comparison operators: gt, lt, gte, lte, eq, ne
7
- * - Logical operators: and, or, not
8
- * - Conditional: if
9
- * - Literals: num, dec, text, bool (mostly disambiguation helpers —
10
- * coercion handles the common case automatically)
11
- * - Sub-select projections: label, id, email, name
12
- *
13
- * Out of scope for v1 (lands in PR 3+ per the agreed scoping):
14
- * - IFS, COALESCE, NULLIF, ISBLANK, BLANK
15
- * - Aggregations (SUM, COUNT, AVG, MIN, MAX, …)
16
- * - Date functions (NOW, DATEDIF, YEAR, …)
17
- * - Text functions (CONCAT, LEN, UPPER, …)
18
- * - Regex, JSON, manifest-driven tier-2 functions
19
- * - Parameters ({{trigger}}, {{task}}), UDFs
4
+ * Covers the public Knowhere calculated-expression grammar: arithmetic and
5
+ * comparisons; logical/conditional functions; aggregate functions; date,
6
+ * text, regex, JSON, and numeric functions; literals; and field projections.
7
+ * Automation workflow parameters layer on in
8
+ * `automation/calculation-expression.ts` because they are not calculated-field
9
+ * concepts.
20
10
  *
21
11
  * Operator naming: `plus` / `minus` / `times` / `dividedBy` instead of
22
12
  * `add` / `subtract` / `multiply` / `divide` so the resulting code
23
13
  * reads close to the math expression. Same shape as the Java
24
14
  * `ExpressionUtil.addition` / `subtraction` / etc. helpers.
25
15
  */
26
- import type { BoolLike, ComparableExprType, Expr, ExprLike, ExprType, NumericExpr, NumericLike } from "./types.js";
27
- import { concat, toText, len, trim, upper, lower, left, right, mid, substitute, find, search, splitText, regexMatch, regexReplace, regexExtract, jsonEscape, jsonUnescape } from "./text.js";
28
- import { round, power, sqrt, mod, abs, toNumber, uuid } from "./numeric.js";
29
- import { now, today, makeDate, dateValue, dateDif, dateTimeTrunc, weekday, year, month, day, hour, minute, second } from "./date.js";
16
+ import type { StoredFunctionRef, StoredFunctionScalarType } from "../../../catalog/types.js";
17
+ import type { BoolLike, ComposedExpr, ComparableExprType, DateMathPromotion, Expr, ExprLike, ExprType, ExprTypeOf, NumericPromotion, NumericLike } from "./types.js";
18
+ import { concat, toText, len, trim, upper, lower, left, right, mid, substitute, find, search, splitText, regexMatch, regexReplace, regexExtract, jsonEscape, jsonUnescape, repeat } from "./text.js";
19
+ import { round, power, sqrt, toNumber, uuid } from "./numeric.js";
20
+ import { now, makeDate, dateTime, dateValue, dateDiff, dateDif, truncateDateTime, dateTimeTrunc, weekday, year, month, day, hour, minute, second } from "./date.js";
30
21
  import { countIf, sumIf, stringAgg, stringAggUnique } from "./aggregate.js";
31
22
  /** Integer literal — `Expr<"number">`. */
32
23
  declare function num(value: number): Expr<"number">;
@@ -36,62 +27,52 @@ declare function dec(value: number): Expr<"decimal">;
36
27
  declare function text(value: string): Expr<"text">;
37
28
  /** Boolean literal — `Expr<"bool">`. Emits `TRUE()` / `FALSE()`. */
38
29
  declare function bool(value: boolean): Expr<"bool">;
39
- declare function plus(a: NumericLike, b: NumericLike): NumericExpr;
40
- declare function plus(a: ExprLike<"date">, b: NumericLike): Expr<"date">;
41
- declare function plus(a: ExprLike<"datetime">, b: NumericLike): Expr<"datetime">;
42
- declare function minus(a: NumericLike, b: NumericLike): NumericExpr;
43
- declare function minus(a: ExprLike<"date">, b: NumericLike): Expr<"date">;
44
- declare function minus(a: ExprLike<"datetime">, b: NumericLike): Expr<"datetime">;
45
- declare function times(a: NumericLike, b: NumericLike): NumericExpr;
46
- declare function dividedBy(a: NumericLike, b: NumericLike): NumericExpr;
47
- declare function gt<T extends ComparableExprType>(a: ExprLike<T>, b: ExprLike<T>): Expr<"bool">;
48
- declare function lt<T extends ComparableExprType>(a: ExprLike<T>, b: ExprLike<T>): Expr<"bool">;
49
- declare function gte<T extends ComparableExprType>(a: ExprLike<T>, b: ExprLike<T>): Expr<"bool">;
50
- declare function lte<T extends ComparableExprType>(a: ExprLike<T>, b: ExprLike<T>): Expr<"bool">;
51
- declare function eq<T extends ExprType>(a: ExprLike<T>, b: ExprLike<T>): Expr<"bool">;
52
- declare function ne<T extends ExprType>(a: ExprLike<T>, b: ExprLike<T>): Expr<"bool">;
53
- declare function and(a: BoolLike, b: BoolLike, ...rest: BoolLike[]): Expr<"bool">;
54
- declare function or(a: BoolLike, b: BoolLike, ...rest: BoolLike[]): Expr<"bool">;
55
- declare function not(value: BoolLike): Expr<"bool">;
56
- declare function if_<T extends ExprType>(cond: BoolLike, thenArm: ExprLike<T>, elseArm: ExprLike<T>): Expr<T>;
30
+ declare function plus<const A extends NumericLike | ExprLike<"date"> | ExprLike<"datetime">, const B extends NumericLike>(a: A, b: B): ComposedExpr<DateMathPromotion<A, B>, [A, B]>;
31
+ declare function minus<const A extends NumericLike | ExprLike<"date"> | ExprLike<"datetime">, const B extends NumericLike>(a: A, b: B): ComposedExpr<DateMathPromotion<A, B>, [A, B]>;
32
+ declare function times<const A extends NumericLike, const B extends NumericLike>(a: A, b: B): ComposedExpr<NumericPromotion<A, B>, [A, B]>;
33
+ declare function dividedBy<const A extends NumericLike, const B extends NumericLike>(a: A, b: B): ComposedExpr<"decimal", [A, B]>;
34
+ type NonNumericComparableExprType = Exclude<ComparableExprType, "number" | "decimal">;
35
+ declare function gt<const A extends NumericLike, const B extends NumericLike>(a: A, b: B): ComposedExpr<"bool", [A, B]>;
36
+ declare function gt<T extends NonNumericComparableExprType, const A extends ExprLike<T>, const B extends ExprLike<NoInfer<T>>>(a: A, b: B): ComposedExpr<"bool", [A, B]>;
37
+ declare function lt<const A extends NumericLike, const B extends NumericLike>(a: A, b: B): ComposedExpr<"bool", [A, B]>;
38
+ declare function lt<T extends NonNumericComparableExprType, const A extends ExprLike<T>, const B extends ExprLike<NoInfer<T>>>(a: A, b: B): ComposedExpr<"bool", [A, B]>;
39
+ declare function gte<const A extends NumericLike, const B extends NumericLike>(a: A, b: B): ComposedExpr<"bool", [A, B]>;
40
+ declare function gte<T extends NonNumericComparableExprType, const A extends ExprLike<T>, const B extends ExprLike<NoInfer<T>>>(a: A, b: B): ComposedExpr<"bool", [A, B]>;
41
+ declare function lte<const A extends NumericLike, const B extends NumericLike>(a: A, b: B): ComposedExpr<"bool", [A, B]>;
42
+ declare function lte<T extends NonNumericComparableExprType, const A extends ExprLike<T>, const B extends ExprLike<NoInfer<T>>>(a: A, b: B): ComposedExpr<"bool", [A, B]>;
43
+ type NonNumericExprType = Exclude<ExprType, "number" | "decimal">;
44
+ declare function eq<const A extends NumericLike, const B extends NumericLike>(a: A, b: B): ComposedExpr<"bool", [A, B]>;
45
+ declare function eq<T extends NonNumericExprType, const A extends ExprLike<T>, const B extends ExprLike<NoInfer<T>>>(a: A, b: B): ComposedExpr<"bool", [A, B]>;
46
+ declare function ne<const A extends NumericLike, const B extends NumericLike>(a: A, b: B): ComposedExpr<"bool", [A, B]>;
47
+ declare function ne<T extends NonNumericExprType, const A extends ExprLike<T>, const B extends ExprLike<NoInfer<T>>>(a: A, b: B): ComposedExpr<"bool", [A, B]>;
48
+ declare function and<const A extends BoolLike, const B extends BoolLike, const Rest extends readonly BoolLike[]>(a: A, b: B, ...rest: Rest): ComposedExpr<"bool", [A, B, ...Rest]>;
49
+ declare function or<const A extends BoolLike, const B extends BoolLike, const Rest extends readonly BoolLike[]>(a: A, b: B, ...rest: Rest): ComposedExpr<"bool", [A, B, ...Rest]>;
50
+ declare function if_<const Condition extends BoolLike, const Then extends NumericLike, const Else extends NumericLike>(cond: Condition, thenArm: Then, elseArm: Else): ComposedExpr<NumericPromotion<Then, Else>, [Condition, Then, Else]>;
51
+ declare function if_<T extends NonNumericExprType, const Condition extends BoolLike, const Then extends ExprLike<T>, const Else extends ExprLike<NoInfer<T>>>(cond: Condition, thenArm: Then, elseArm: Else): ComposedExpr<T, [Condition, Then, Else]>;
57
52
  /**
58
- * Multi-branch conditional — `IFS(c1, v1, c2, v2, …, finalElse?)`.
53
+ * Multi-branch conditional — `IFS(c1, v1, c2, v2, …)`.
59
54
  * Conditions are evaluated in order; the first one whose check
60
- * passes determines the result. If no condition matches and no
61
- * final-else value is supplied, the result is null (BLANK on the
62
- * wire).
55
+ * passes determines the result. If no condition matches, the result is null.
63
56
  *
64
- * Args must come in (cond, value) pairs, optionally with one
65
- * trailing value as the final else. The typing accepts the pairs
66
- * as `[BoolLike, ExprLike<T>]` tuples plus an optional final
67
- * `ExprLike<T>` so all branches share the same result brand.
57
+ * Args must come in complete `(condition, value)` pairs, and all value arms
58
+ * share the same result brand.
68
59
  *
69
60
  * Runtime validates parity — the EDK throws if an odd-then-even-
70
61
  * looking arg list slips past TS (e.g. when args is spread from an
71
62
  * untyped source).
72
63
  */
73
- declare function ifs<T extends ExprType>(...args: readonly [
74
- BoolLike,
75
- ExprLike<T>,
76
- ...Array<BoolLike | ExprLike<T>>
77
- ]): Expr<T>;
78
- /**
79
- * Return the first non-null argument. All args must share the same
80
- * result brand. The wire emits `COALESCE(a, b, …)`.
81
- */
82
- declare function coalesce<T extends ExprType>(...args: readonly [ExprLike<T>, ExprLike<T>, ...ExprLike<T>[]]): Expr<T>;
83
- /**
84
- * Return null when `a` and `b` are equal; otherwise return `a`.
85
- * Mirrors SQL `NULLIF`. Useful for guarding against divide-by-zero:
86
- * `calc.dividedBy(x, calc.nullIf(y, 0))`.
87
- */
88
- declare function nullIf<T extends ExprType>(a: ExprLike<T>, b: ExprLike<T>): Expr<T>;
64
+ type IfsRest<T extends ExprType, Args extends readonly unknown[]> = Args extends readonly [] ? readonly [] : Args extends readonly [infer Condition, infer Value, ...infer Rest] ? readonly [
65
+ Condition & BoolLike,
66
+ Value & ExprLike<T>,
67
+ ...IfsRest<T, Rest>
68
+ ] : never;
69
+ declare function ifs<T extends ExprType, const Rest extends readonly unknown[]>(condition: BoolLike, value: ExprLike<T>, ...rest: Rest & IfsRest<NoInfer<T>, Rest>): ComposedExpr<T, [typeof condition, typeof value, ...Rest]>;
89
70
  /**
90
71
  * True when the argument is null/empty. Accepts any expression type.
91
72
  * Equivalent to SQL `IS NULL` for non-text values; for text values
92
73
  * the server also treats whitespace-only strings as blank.
93
74
  */
94
- declare function isBlank<T extends ExprType>(value: ExprLike<T>): Expr<"bool">;
75
+ declare function isBlank<T extends ExprType, const Value extends ExprLike<T>>(value: Value): ComposedExpr<"bool", [Value]>;
95
76
  /**
96
77
  * Null literal — the wire `BLANK()` function. Returns an `Expr<T>`
97
78
  * whose brand is inferred from surrounding context (e.g. an
@@ -99,49 +80,57 @@ declare function isBlank<T extends ExprType>(value: ExprLike<T>): Expr<"bool">;
99
80
  * (`calc.blank<"text">()`) because TS can't infer T from a
100
81
  * zero-argument call site.
101
82
  */
83
+ declare function blank<T extends ExprType>(type: T): Expr<T>;
102
84
  declare function blank<T extends ExprType>(): Expr<T>;
85
+ /** Explicitly typed escape hatch for pulled and legacy formula text. */
86
+ declare function raw<T extends ExprType>(formula: string, resultType: T): Expr<T>;
87
+ type StoredFunctionArguments<Parameters extends readonly ExprType[]> = {
88
+ readonly [Index in keyof Parameters]: Parameters[Index] extends ExprType ? ExprLike<Parameters[Index]> : never;
89
+ };
90
+ /** Invoke a configured scalar user-defined function from its CloudLink catalog ref. */
91
+ declare function call<const Parameters extends readonly StoredFunctionScalarType[], const Result extends StoredFunctionScalarType>(udf: StoredFunctionRef<Parameters, Result>, ...args: StoredFunctionArguments<Parameters>): Expr<Result, "single", "record">;
103
92
  /**
104
93
  * Sum of a numeric expression across related rows. Server preserves
105
94
  * the input brand — `sum(NUMBER)` → NUMBER on the wire,
106
- * `sum(DECIMAL)` → DECIMAL. The DSL collapses the output to
107
- * `NumericExpr` (the number-or-decimal union) since the caller's
108
- * downstream usage typically doesn't distinguish.
95
+ * `sum(DECIMAL)` → DECIMAL. Overloads retain that exact brand for callers.
109
96
  */
110
- declare function sum(value: NumericLike): NumericExpr;
97
+ declare function sum<const Value extends ExprLike<"number">>(value: Value): ComposedExpr<"number", [Value]>;
98
+ declare function sum<const Value extends ExprLike<"decimal">>(value: Value): ComposedExpr<"decimal", [Value]>;
111
99
  /**
112
100
  * Count of non-null values for the argument expression across related
113
101
  * rows. Always returns `NUMBER` regardless of input brand.
114
102
  */
115
- declare function count<T extends ExprType>(value: ExprLike<T>): Expr<"number">;
103
+ declare function count<T extends ExprType, const Value extends ExprLike<T>>(value: Value): ComposedExpr<"number", [Value]>;
116
104
  /**
117
105
  * Distinct count of the argument expression across related rows.
118
106
  * Wire emits `COUNTUNIQUE` (matches the Java grammar's
119
107
  * `countDistinct` alias).
120
108
  */
121
- declare function countUnique<T extends ExprType>(value: ExprLike<T>): Expr<"number">;
109
+ declare function countUnique<T extends ExprType, const Value extends ExprLike<T>>(value: Value): ComposedExpr<"number", [Value]>;
122
110
  /**
123
111
  * Arithmetic mean of a numeric expression across related rows.
124
112
  * Always returns `DECIMAL` (the server casts even integer fields to
125
113
  * decimal for division).
126
114
  */
127
- declare function average(value: NumericLike): Expr<"decimal">;
115
+ declare function average<const Value extends NumericLike>(value: Value): ComposedExpr<"decimal", [Value]>;
128
116
  /**
129
117
  * Standard deviation of a numeric expression across related rows.
130
118
  * Always returns `DECIMAL`.
131
119
  */
132
- declare function stdev(value: NumericLike): Expr<"decimal">;
133
- declare function min<T extends ComparableExprType>(value: ExprLike<T>): Expr<T>;
134
- declare function min<T extends ComparableExprType>(a: ExprLike<T>, b: ExprLike<T>, ...rest: ExprLike<T>[]): Expr<T>;
135
- declare function max<T extends ComparableExprType>(value: ExprLike<T>): Expr<T>;
136
- declare function max<T extends ComparableExprType>(a: ExprLike<T>, b: ExprLike<T>, ...rest: ExprLike<T>[]): Expr<T>;
120
+ declare function stdev<const Value extends NumericLike>(value: Value): ComposedExpr<"decimal", [Value]>;
121
+ type MinMaxExprType = "number" | "decimal" | "date" | "datetime";
122
+ declare function min<const Value extends ExprLike<MinMaxExprType>>(value: Value): ComposedExpr<Extract<ExprTypeOf<Value>, MinMaxExprType>, [Value]>;
123
+ declare function min<const A extends ExprLike<MinMaxExprType>, const B extends ExprLike<Extract<ExprTypeOf<A>, MinMaxExprType>>, const Rest extends readonly ExprLike<Extract<ExprTypeOf<A>, MinMaxExprType>>[]>(a: A, b: B, ...rest: Rest): ComposedExpr<Extract<ExprTypeOf<A>, MinMaxExprType>, [A, B, ...Rest]>;
124
+ declare function max<const Value extends ExprLike<MinMaxExprType>>(value: Value): ComposedExpr<Extract<ExprTypeOf<Value>, MinMaxExprType>, [Value]>;
125
+ declare function max<const A extends ExprLike<MinMaxExprType>, const B extends ExprLike<Extract<ExprTypeOf<A>, MinMaxExprType>>, const Rest extends readonly ExprLike<Extract<ExprTypeOf<A>, MinMaxExprType>>[]>(a: A, b: B, ...rest: Rest): ComposedExpr<Extract<ExprTypeOf<A>, MinMaxExprType>, [A, B, ...Rest]>;
137
126
  /** Project a picklist field reference to its display label (text). */
138
- declare function label(field: ExprLike<"picklist">): Expr<"text">;
127
+ declare function label<const Field extends ExprLike<"picklist">>(field: Field): ComposedExpr<"text", [Field]>;
139
128
  /** Project a reference-typed field to its id form (no-op for already-id refs). */
140
- declare function id<T extends "picklist" | "user" | "group" | "attachment">(field: ExprLike<T>): Expr<T>;
129
+ declare function id<T extends "picklist" | "user" | "group" | "attachment", const Field extends ExprLike<T>>(field: Field): ComposedExpr<T, [Field]>;
141
130
  /** Project a user field reference to its email address (text). */
142
- declare function email(field: ExprLike<"user">): Expr<"text">;
131
+ declare function email<const Field extends ExprLike<"user">>(field: Field): ComposedExpr<"text", [Field]>;
143
132
  /** Project a group field reference to its name (text). */
144
- declare function name(field: ExprLike<"group">): Expr<"text">;
133
+ declare function name<const Field extends ExprLike<"group">>(field: Field): ComposedExpr<"text", [Field]>;
145
134
  /**
146
135
  * The `calc` namespace — every public builder lives here so authors
147
136
  * have one discoverable entry point. `calc.if` works because object
@@ -154,6 +143,8 @@ export declare const calc: {
154
143
  readonly text: typeof text;
155
144
  readonly bool: typeof bool;
156
145
  readonly blank: typeof blank;
146
+ readonly raw: typeof raw;
147
+ readonly call: typeof call;
157
148
  readonly plus: typeof plus;
158
149
  readonly minus: typeof minus;
159
150
  readonly times: typeof times;
@@ -166,11 +157,8 @@ export declare const calc: {
166
157
  readonly ne: typeof ne;
167
158
  readonly and: typeof and;
168
159
  readonly or: typeof or;
169
- readonly not: typeof not;
170
160
  readonly if: typeof if_;
171
161
  readonly ifs: typeof ifs;
172
- readonly coalesce: typeof coalesce;
173
- readonly nullIf: typeof nullIf;
174
162
  readonly isBlank: typeof isBlank;
175
163
  readonly sum: typeof sum;
176
164
  readonly count: typeof count;
@@ -191,24 +179,26 @@ export declare const calc: {
191
179
  readonly substitute: typeof substitute;
192
180
  readonly find: typeof find;
193
181
  readonly search: typeof search;
182
+ readonly split: typeof splitText;
194
183
  readonly splitText: typeof splitText;
195
184
  readonly regexMatch: typeof regexMatch;
196
185
  readonly regexReplace: typeof regexReplace;
197
186
  readonly regexExtract: typeof regexExtract;
198
187
  readonly jsonEscape: typeof jsonEscape;
199
188
  readonly jsonUnescape: typeof jsonUnescape;
189
+ readonly repeat: typeof repeat;
200
190
  readonly round: typeof round;
201
191
  readonly power: typeof power;
202
192
  readonly sqrt: typeof sqrt;
203
- readonly mod: typeof mod;
204
- readonly abs: typeof abs;
205
193
  readonly toNumber: typeof toNumber;
206
194
  readonly uuid: typeof uuid;
207
195
  readonly now: typeof now;
208
- readonly today: typeof today;
209
196
  readonly makeDate: typeof makeDate;
197
+ readonly dateTime: typeof dateTime;
210
198
  readonly dateValue: typeof dateValue;
199
+ readonly dateDiff: typeof dateDiff;
211
200
  readonly dateDif: typeof dateDif;
201
+ readonly truncateDateTime: typeof truncateDateTime;
212
202
  readonly dateTimeTrunc: typeof dateTimeTrunc;
213
203
  readonly weekday: typeof weekday;
214
204
  readonly year: typeof year;
@@ -227,3 +217,8 @@ export declare const calc: {
227
217
  readonly name: typeof name;
228
218
  };
229
219
  export type { Expr, ExprLike, ExprType, NumericExpr, BoolLike } from "./types.js";
220
+ export type { ConcatExprType } from "./text.js";
221
+ export { dateDiffUnit, dateDifUnit, dateTimeTruncPrecision, weekdayMode, } from "./date.js";
222
+ export type { DateDiffUnit, DateDifUnit, DateTimePrecision, DateTimeTruncPrecision, WeekdayConvention, WeekdayMode } from "./date.js";
223
+ export { orderByDirection, predicateOp } from "./aggregate.js";
224
+ export type { OrderByDirection, ErgonomicOrderByDirection, ErgonomicPredicate, Predicate, PredicateInput, PredicateOp, StringAggOptions, StringAggOrderBy, } from "./aggregate.js";