@elementumai/edk 0.9.2 → 0.9.5

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
@@ -2,8 +2,51 @@ import { expr, sanitizeName, tsLabelToTfLabel } from "../../engine/tf/index.js";
2
2
  const CATEGORY = "elementum_category";
3
3
  const GROUP = "elementum_group";
4
4
  const USER = "elementum_user";
5
+ const CLOUD_LINK = "elementum_cloudlink";
6
+ const EMAIL_ALIAS = "elementum_email_alias";
7
+ const PHONE_PROVIDER = "elementum_phone_provider";
8
+ function secretValue(value, variables) {
9
+ if (value.__kind === "redactedOrganizationSecret")
10
+ return undefined;
11
+ variables.set(value.variable, { kind: "variable", label: value.variable, attrs: {
12
+ sensitive: true,
13
+ description: `Sensitive organization credential. Supply as TF_VAR_${value.variable}.`,
14
+ } });
15
+ return expr.variable(value.variable);
16
+ }
17
+ function credentialsValue(value, variables) {
18
+ if (value.redacted !== undefined)
19
+ return undefined;
20
+ if (value.bearerToken !== undefined) {
21
+ const token = secretValue(value.bearerToken.token, variables);
22
+ return token === undefined ? undefined : { bearer_token: { token } };
23
+ }
24
+ if (value.password !== undefined) {
25
+ const password = secretValue(value.password.password, variables);
26
+ return password === undefined ? undefined : { password: { username: value.password.username, password } };
27
+ }
28
+ if (value.privateKey !== undefined)
29
+ return { private_key: { username: value.privateKey.username } };
30
+ if (value.serviceAccount !== undefined) {
31
+ const json = secretValue(value.serviceAccount.json, variables);
32
+ return json === undefined ? undefined : { service_account: { json } };
33
+ }
34
+ const clientSecret = secretValue(value.externalOauth.clientSecret, variables);
35
+ const password = value.externalOauth.password === undefined ? undefined : secretValue(value.externalOauth.password, variables);
36
+ if (clientSecret === undefined || (value.externalOauth.password !== undefined && password === undefined))
37
+ return undefined;
38
+ return { external_oauth: {
39
+ client_id: value.externalOauth.clientId,
40
+ client_secret: clientSecret,
41
+ url: value.externalOauth.url,
42
+ ...(value.externalOauth.username !== undefined && { username: value.externalOauth.username }),
43
+ ...(password !== undefined && { password }),
44
+ } };
45
+ }
46
+ const schedule = (value) => value === undefined ? undefined : { interval: value.interval, unit: value.unit };
5
47
  export function organizationToTf(organization, ctx) {
6
48
  const blocks = [];
49
+ const variables = new Map();
7
50
  for (const [key, category] of Object.entries(organization.categories)) {
8
51
  const attrs = { name: category.name };
9
52
  if (category.color !== undefined)
@@ -33,5 +76,79 @@ export function organizationToTf(organization, ctx) {
33
76
  }
34
77
  blocks.push({ kind: "resource", type: GROUP, label: tsLabelToTfLabel(key), attrs });
35
78
  }
36
- return blocks;
79
+ for (const [key, cloudLink] of Object.entries(organization.cloudLinks)) {
80
+ const resourceVariables = new Map();
81
+ const attrs = { name: cloudLink.name, type: cloudLink.type };
82
+ if (cloudLink.cache !== undefined)
83
+ attrs["cache"] = cloudLink.cache;
84
+ if (cloudLink.encryptCache !== undefined)
85
+ attrs["encrypt_cache"] = cloudLink.encryptCache;
86
+ if (cloudLink.usageType !== undefined)
87
+ attrs["usage_type"] = cloudLink.usageType;
88
+ if (cloudLink.credentials !== undefined) {
89
+ const credentials = credentialsValue(cloudLink.credentials, resourceVariables);
90
+ if (credentials === undefined) {
91
+ ctx.diagnostics?.push(`cloudLinks.${key}: credentials are write-only; replace redactedSecret(...) with secret(...) before this CloudLink can be managed`);
92
+ continue;
93
+ }
94
+ attrs["credentials"] = credentials;
95
+ }
96
+ if (cloudLink.api !== undefined)
97
+ attrs["api_config"] = { base_url: cloudLink.api.baseUrl };
98
+ if (cloudLink.bigQuery !== undefined)
99
+ attrs["bigquery_config"] = {
100
+ project_id: cloudLink.bigQuery.projectId, dataset_id: cloudLink.bigQuery.datasetId,
101
+ location: cloudLink.bigQuery.location, read_only: cloudLink.bigQuery.readOnly,
102
+ ...(schedule(cloudLink.bigQuery.schedule) !== undefined && { schedule: schedule(cloudLink.bigQuery.schedule) }),
103
+ };
104
+ if (cloudLink.databricks !== undefined)
105
+ attrs["databricks_config"] = {
106
+ hostname: cloudLink.databricks.hostname, port: cloudLink.databricks.port,
107
+ database: cloudLink.databricks.database, schema: cloudLink.databricks.schema,
108
+ read_only: cloudLink.databricks.readOnly,
109
+ ...(schedule(cloudLink.databricks.schedule) !== undefined && { schedule: schedule(cloudLink.databricks.schedule) }),
110
+ };
111
+ if (cloudLink.elementumSnowflake !== undefined) {
112
+ if (typeof cloudLink.elementumSnowflake.region !== "string") {
113
+ ctx.diagnostics?.push(`cloudLinks.${key}: region is input-only; replace unavailableValue("region") before this CloudLink can be managed`);
114
+ continue;
115
+ }
116
+ attrs["elementum_snowflake_config"] = {
117
+ region: cloudLink.elementumSnowflake.region, warehouse_size: cloudLink.elementumSnowflake.warehouseSize,
118
+ ...(schedule(cloudLink.elementumSnowflake.schedule) !== undefined && { schedule: schedule(cloudLink.elementumSnowflake.schedule) }),
119
+ };
120
+ }
121
+ if (cloudLink.snowflake !== undefined)
122
+ attrs["snowflake_config"] = {
123
+ url: cloudLink.snowflake.url, account: cloudLink.snowflake.account,
124
+ warehouse: cloudLink.snowflake.warehouse, role: cloudLink.snowflake.role,
125
+ read_only: cloudLink.snowflake.readOnly,
126
+ ...(cloudLink.snowflake.createDatabase !== undefined && { create_database: cloudLink.snowflake.createDatabase }),
127
+ ...(cloudLink.snowflake.createSchema !== undefined && { create_schema: cloudLink.snowflake.createSchema }),
128
+ ...(cloudLink.snowflake.gzip !== undefined && { gzip: cloudLink.snowflake.gzip }),
129
+ ...(schedule(cloudLink.snowflake.schedule) !== undefined && { schedule: schedule(cloudLink.snowflake.schedule) }),
130
+ };
131
+ blocks.push({ kind: "resource", type: CLOUD_LINK, label: tsLabelToTfLabel(key), attrs });
132
+ for (const [name, block] of resourceVariables)
133
+ variables.set(name, block);
134
+ }
135
+ for (const [key, emailAlias] of Object.entries(organization.emailAliases)) {
136
+ blocks.push({ kind: "resource", type: EMAIL_ALIAS, label: tsLabelToTfLabel(key), attrs: { alias: emailAlias.alias } });
137
+ }
138
+ for (const [key, phoneProvider] of Object.entries(organization.phoneProviders)) {
139
+ const resourceVariables = new Map();
140
+ const accountId = secretValue(phoneProvider.twilio.accountId, resourceVariables);
141
+ const authToken = secretValue(phoneProvider.twilio.authToken, resourceVariables);
142
+ if (accountId === undefined || authToken === undefined) {
143
+ ctx.diagnostics?.push(`phoneProviders.${key}: Twilio credentials are write-only; replace redactedSecret(...) with secret(...) before this provider can be managed`);
144
+ continue;
145
+ }
146
+ blocks.push({ kind: "resource", type: PHONE_PROVIDER, label: tsLabelToTfLabel(key), attrs: {
147
+ name: phoneProvider.name,
148
+ twilio: { account_id: accountId, auth_token: authToken },
149
+ } });
150
+ for (const [name, block] of resourceVariables)
151
+ variables.set(name, block);
152
+ }
153
+ return [...variables.values(), ...blocks];
37
154
  }
@@ -14,4 +14,4 @@ export interface PhoneServiceConfigured {
14
14
  ref(refName: string): PhoneServiceRef;
15
15
  def(refName: string): DeployableEntity;
16
16
  }
17
- export declare function definePhoneService<const AppRefName extends string>(opts: PhoneServiceOptions<AppRefName>): PhoneServiceConfigured;
17
+ export declare function phoneService<const AppRefName extends string>(opts: PhoneServiceOptions<AppRefName>): PhoneServiceConfigured;
@@ -1,6 +1,6 @@
1
1
  import { slimTokens } from "../../catalog/index.js";
2
2
  import { validatePhoneService } from "./types.js";
3
- export function definePhoneService(opts) {
3
+ export function phoneService(opts) {
4
4
  return {
5
5
  ref(refName) {
6
6
  return { __kind: "phone-service", refName, name: refName, parent: opts.app.refName };
@@ -8,7 +8,7 @@ export function definePhoneService(opts) {
8
8
  def(refName) {
9
9
  validatePhoneService(refName, opts);
10
10
  if (opts.agent.parent !== opts.app.refName) {
11
- throw new Error(`definePhoneService "${refName}": agent "${opts.agent.refName}" belongs to app ` +
11
+ throw new Error(`phoneService "${refName}": agent "${opts.agent.refName}" belongs to app ` +
12
12
  `"${opts.agent.parent ?? "unknown"}", not "${opts.app.refName}"`);
13
13
  }
14
14
  return {
@@ -1,5 +1,6 @@
1
1
  import { quote } from "../../../../pull/util.js";
2
2
  import { sdkPackageSpecifier } from "../../../internal/sdk-package.js";
3
+ import { safeIdentifier } from "../../../internal/safe-identifier.js";
3
4
  import { callerAccessMode } from "../types.js";
4
5
  function constantKey(values, value) {
5
6
  const entry = Object.entries(values).find(([, candidate]) => candidate === value);
@@ -15,13 +16,14 @@ export function printPhoneService(service, opts) {
15
16
  " */",
16
17
  "",
17
18
  ];
18
- const imports = ["definePhoneService"];
19
+ const imports = ["phoneService"];
19
20
  if (service.callerAccessMode !== undefined)
20
21
  imports.push("callerAccessMode");
21
22
  lines.push(`import { ${imports.sort().join(", ")} } from ${quote(sdkPackageSpecifier("app"))};`);
22
23
  lines.push('import catalog from "@catalog";');
23
24
  lines.push("");
24
- lines.push(`const ${service.refName} = definePhoneService({`);
25
+ const identifier = safeIdentifier(service.refName, "phoneService");
26
+ lines.push(`const ${identifier} = phoneService({`);
25
27
  lines.push(` app: catalog.${opts.appRefName},`);
26
28
  lines.push(` agent: catalog.${opts.appRefName}.agents.${service.agentKey},`);
27
29
  lines.push(` provider: catalog.phoneProviders.${service.providerKey},`);
@@ -49,6 +51,6 @@ export function printPhoneService(service, opts) {
49
51
  parts.push(`preferredLanguages: ${JSON.stringify(registration.preferredLanguages)}`);
50
52
  lines.push(` registration: { ${parts.join(", ")} },`);
51
53
  }
52
- lines.push("});", "", `export default ${service.refName};`, "");
54
+ lines.push("});", "", `export default ${identifier};`, "");
53
55
  return lines.join("\n");
54
56
  }
@@ -1,2 +1,2 @@
1
- export { definePhoneService, type PhoneServiceConfigured, type PhoneServiceOptions, } from "./build.js";
1
+ export { phoneService, type PhoneServiceConfigured, type PhoneServiceOptions, } from "./build.js";
2
2
  export { callerAccessMode, type CallerAccessMode, type E164PhoneNumber, type PhoneServiceNumber, type PhoneServiceRegistration, } from "./types.js";
@@ -1,2 +1,2 @@
1
- export { definePhoneService, } from "./build.js";
1
+ export { phoneService, } from "./build.js";
2
2
  export { callerAccessMode, } from "./types.js";
@@ -6,7 +6,7 @@ export const callerAccessMode = {
6
6
  /** Runtime backstop for JavaScript callers and dynamically constructed input. */
7
7
  export function validatePhoneService(name, service) {
8
8
  const fail = (message) => {
9
- throw new Error(`definePhoneService "${name}": ${message}`);
9
+ throw new Error(`phoneService "${name}": ${message}`);
10
10
  };
11
11
  const existing = service.twilioExistingNumber;
12
12
  const created = service.twilioNewNumber;
@@ -3,6 +3,11 @@ import { fieldRefToTfValue } from "../field/to-tf.js";
3
3
  import { SUB_TYPE_BY_AUTHORING_TYPE } from "../field/types.js";
4
4
  import { SYSTEM_FIELD_ID_ATTR_BY_KEY } from "../view/types.js";
5
5
  import { RECORD_CREATE_FORM_RESOURCE_TYPE } from "./module.js";
6
+ // The platform export uses Int32 max for its terminal "Other fields"
7
+ // position, but a newly created form canonicalizes that value to the actual
8
+ // zero-based list position. Sending the sentinel back verbatim therefore
9
+ // makes Terraform see an inconsistent post-create value.
10
+ const PLATFORM_TERMINAL_DISPLAY_ORDER = 2147483647;
6
11
  /** Typed authoring form -> the provider's immutable sections resource. */
7
12
  export function recordCreateFormToTf(form, opts) {
8
13
  if (form === undefined)
@@ -10,10 +15,13 @@ export function recordCreateFormToTf(form, opts) {
10
15
  const sections = [];
11
16
  for (const [index, section] of (form.sections ?? []).entries()) {
12
17
  const where = `recordCreateForm.sections[${index}]`;
18
+ const displayOrder = section.displayOrder === PLATFORM_TERMINAL_DISPLAY_ORDER
19
+ ? index
20
+ : section.displayOrder ?? index;
13
21
  const attrs = {
14
22
  name: section.name ?? "",
15
23
  field_ids: resolveFields(section.fields ?? [], where, opts),
16
- display_order: section.displayOrder ?? index,
24
+ display_order: displayOrder,
17
25
  display_location: section.displayLocation ?? "CENTER",
18
26
  side_nav_item: section.sideNavItem ?? true,
19
27
  hidden: section.hidden ?? false,
@@ -5,6 +5,7 @@ interface RefWire {
5
5
  readonly __kind?: string;
6
6
  readonly refName?: string;
7
7
  readonly name?: string;
8
+ readonly namespace?: string;
8
9
  readonly parent?: string;
9
10
  readonly fieldType?: string;
10
11
  readonly tfLabel?: string;
@@ -1,6 +1,7 @@
1
1
  import { workspaceAspectKey, } from "../../engine/build/context.js";
2
2
  import { expr, isCanonicalTsLabel, sanitizeName, scopedResourceLabel, tsLabelToTfLabel, } from "../../engine/tf/index.js";
3
3
  import { filterToTf } from "../access-policy/to-tf.js";
4
+ import { resolveForeignRef } from "../shared/foreign-ref.js";
4
5
  import { fieldRefToTfValue } from "../field/to-tf.js";
5
6
  import { SYSTEM_FIELD_ID_ATTR_BY_KEY } from "../view/types.js";
6
7
  import { RELATIONSHIP_RESOURCE_TYPE } from "./module.js";
@@ -105,22 +106,13 @@ function resolveTarget(value, where, opts) {
105
106
  opts.diagnostics.push(`${where}: target has no name/refName; dropped`);
106
107
  return undefined;
107
108
  }
108
- const tfLabel = value?.tfLabel ?? sanitizeName(name);
109
- if (kind === "table")
110
- opts.orgRefs.rawLookup("elementum_table", tfLabel, name);
111
- else if (kind === "element")
112
- opts.orgRefs.foreignElement(tfLabel, name);
113
- else
114
- opts.orgRefs.foreignApp(tfLabel, name);
109
+ const namespace = value?.namespace;
110
+ const foreign = resolveForeignRef(kind, { name, ...(kind !== "table" && namespace !== undefined ? { namespace } : {}), tfLabel: value?.tfLabel }, opts.orgRefs, opts.diagnostics, where);
115
111
  return {
116
- value: expr.dataAttr(kind === "table"
117
- ? "elementum_table"
118
- : kind === "element"
119
- ? "elementum_element"
120
- : "elementum_app", tfLabel, ["id"]),
112
+ value: foreign.value,
121
113
  kind,
122
114
  refName,
123
- tfLabel,
115
+ tfLabel: foreign.tfLabel,
124
116
  managed: false,
125
117
  };
126
118
  }
@@ -20,7 +20,7 @@ export declare const searchTableDuration: {
20
20
  * tables (target object has storageType HYBRID)").
21
21
  *
22
22
  * Table-owned search is a separate product concept with its own builder,
23
- * `defineTableSearchTable`, so `TableRef` deliberately does not appear here.
23
+ * `tableSearchTable`, so `TableRef` deliberately does not appear here.
24
24
  */
25
25
  type SearchTableOwner = ElementCatalogRef;
26
26
  /** One vector-index column plus the AI service that indexes it. */
@@ -73,8 +73,8 @@ export interface SearchTableConfigured<Parent extends string = string> {
73
73
  def(refName: string): DeployableEntity;
74
74
  }
75
75
  /** Build an element-owned managed search table. */
76
- export declare function defineSearchTable<Owner extends SearchTableOwner>(opts: DefineSearchTableOptions<Owner>): SearchTableConfigured<Owner["refName"]>;
76
+ export declare function searchTable<Owner extends SearchTableOwner>(opts: DefineSearchTableOptions<Owner>): SearchTableConfigured<Owner["refName"]>;
77
77
  /** Link an existing Cortex Search Service to an element. */
78
- export declare function defineLinkedSearchTable<Owner extends SearchTableOwner>(opts: DefineLinkedSearchTableOptions<Owner>): SearchTableConfigured<Owner["refName"]>;
78
+ export declare function linkedSearchTable<Owner extends SearchTableOwner>(opts: DefineLinkedSearchTableOptions<Owner>): SearchTableConfigured<Owner["refName"]>;
79
79
  /** Build an immutable AI search index owned by an organization table. */
80
- export declare function defineTableSearchTable<Table extends TableRef>(opts: DefineTableSearchTableOptions<Table>): SearchTableConfigured<Table["refName"]>;
80
+ export declare function tableSearchTable<Table extends TableRef>(opts: DefineTableSearchTableOptions<Table>): SearchTableConfigured<Table["refName"]>;
@@ -18,7 +18,7 @@ function ownerOf(opts) {
18
18
  if (app !== undefined) {
19
19
  throw new EdkValidationError(`search table owner: got \`app: ${app.refName ?? "?"}\` — a managed or linked search table is owned by an ` +
20
20
  `element, never an app (an app's backing Snowflake table is hybrid, which Cortex cannot index). Pass ` +
21
- `\`element:\`, or use defineTableSearchTable for a table-owned search table.`);
21
+ `\`element:\`, or use tableSearchTable for a table-owned search table.`);
22
22
  }
23
23
  if (element === undefined) {
24
24
  throw new EdkValidationError("search table owner: `element` is required — a search table is owned by an element.");
@@ -36,21 +36,21 @@ function assertPositiveLag(targetLag) {
36
36
  function managedBody(opts) {
37
37
  assertPositiveLag(opts.targetLag);
38
38
  if (opts.attributeFields.length === 0) {
39
- throw new EdkValidationError("defineSearchTable requires at least one attributeField.");
39
+ throw new EdkValidationError("searchTable requires at least one attributeField.");
40
40
  }
41
41
  if (opts.vectorIndex === undefined) {
42
- throw new EdkValidationError("defineSearchTable requires a vectorIndex.");
42
+ throw new EdkValidationError("searchTable requires a vectorIndex.");
43
43
  }
44
44
  const primaryField = opts.vectorIndex.field;
45
45
  const owner = ownerOf(opts);
46
46
  for (const field of [primaryField, ...opts.attributeFields, ...(opts.textIndexFields ?? [])]) {
47
47
  if (field.parent !== owner.refName) {
48
- throw new EdkValidationError(`defineSearchTable field ${JSON.stringify(field.refName)} belongs to ${JSON.stringify(field.parent)}, not ${owner.__kind} ${JSON.stringify(owner.refName)}.`);
48
+ throw new EdkValidationError(`searchTable field ${JSON.stringify(field.refName)} belongs to ${JSON.stringify(field.parent)}, not ${owner.__kind} ${JSON.stringify(owner.refName)}.`);
49
49
  }
50
50
  }
51
51
  for (const attribute of opts.attributeFields) {
52
52
  if (primaryField.refName === attribute.refName && primaryField.parent === attribute.parent) {
53
- throw new EdkValidationError(`defineSearchTable: primary search field ${JSON.stringify(attribute.refName)} must not also appear in attributeFields; it is indexed automatically.`);
53
+ throw new EdkValidationError(`searchTable: primary search field ${JSON.stringify(attribute.refName)} must not also appear in attributeFields; it is indexed automatically.`);
54
54
  }
55
55
  }
56
56
  return {
@@ -66,7 +66,7 @@ function managedBody(opts) {
66
66
  }
67
67
  function linkedBody(opts) {
68
68
  if (opts.serviceName.trim() === "")
69
- throw new EdkValidationError("defineLinkedSearchTable requires a non-empty serviceName.");
69
+ throw new EdkValidationError("linkedSearchTable requires a non-empty serviceName.");
70
70
  return {
71
71
  name: opts.name,
72
72
  cloudLinkId: opts.cloudLink,
@@ -89,27 +89,27 @@ function configuredSearchTable(opts, variant, body) {
89
89
  };
90
90
  }
91
91
  /** Build an element-owned managed search table. */
92
- export function defineSearchTable(opts) {
92
+ export function searchTable(opts) {
93
93
  if (opts.name.trim() === "")
94
- throw new EdkValidationError("defineSearchTable requires a non-empty name.");
94
+ throw new EdkValidationError("searchTable requires a non-empty name.");
95
95
  return configuredSearchTable(opts, "snowflake", managedBody(opts));
96
96
  }
97
97
  /** Link an existing Cortex Search Service to an element. */
98
- export function defineLinkedSearchTable(opts) {
98
+ export function linkedSearchTable(opts) {
99
99
  if (opts.name.trim() === "")
100
- throw new EdkValidationError("defineLinkedSearchTable requires a non-empty name.");
100
+ throw new EdkValidationError("linkedSearchTable requires a non-empty name.");
101
101
  return configuredSearchTable(opts, "linked", linkedBody(opts));
102
102
  }
103
103
  /** Build an immutable AI search index owned by an organization table. */
104
- export function defineTableSearchTable(opts) {
104
+ export function tableSearchTable(opts) {
105
105
  assertPositiveLag(opts.targetLag);
106
106
  for (const column of [opts.field, ...opts.attributeFields]) {
107
107
  if (column.parent !== opts.table.refName) {
108
- throw new EdkValidationError(`defineTableSearchTable column ${JSON.stringify(column.refName)} belongs to ${JSON.stringify(column.parent)}, not table ${JSON.stringify(opts.table.refName)}.`);
108
+ throw new EdkValidationError(`tableSearchTable column ${JSON.stringify(column.refName)} belongs to ${JSON.stringify(column.parent)}, not table ${JSON.stringify(opts.table.refName)}.`);
109
109
  }
110
110
  }
111
111
  if (opts.attributeFields.some((column) => column.refName === opts.field.refName)) {
112
- throw new EdkValidationError("defineTableSearchTable: field cannot also appear in attributeFields.");
112
+ throw new EdkValidationError("tableSearchTable: field cannot also appear in attributeFields.");
113
113
  }
114
114
  const payload = slimTokens({
115
115
  __variant: "table",
@@ -1,5 +1,5 @@
1
1
  /**
2
- * v2 search-table authoring — `defineSearchTable`. Element-owned; create-only.
2
+ * v2 search-table authoring — `searchTable`. Element-owned; create-only.
3
3
  * Standalone from v1's `src/searchTables`.
4
4
  */
5
- export { defineLinkedSearchTable, defineSearchTable, defineTableSearchTable, searchTableDuration, type DefineLinkedSearchTableOptions, type DefineSearchTableOptions, type DefineTableSearchTableOptions, type SearchTableDuration, type SearchTableConfigured, type SearchTableTimeUnit, type VectorIndex, } from "./build.js";
5
+ export { linkedSearchTable, searchTable, tableSearchTable, searchTableDuration, type DefineLinkedSearchTableOptions, type DefineSearchTableOptions, type DefineTableSearchTableOptions, type SearchTableDuration, type SearchTableConfigured, type SearchTableTimeUnit, type VectorIndex, } from "./build.js";
@@ -1,5 +1,5 @@
1
1
  /**
2
- * v2 search-table authoring — `defineSearchTable`. Element-owned; create-only.
2
+ * v2 search-table authoring — `searchTable`. Element-owned; create-only.
3
3
  * Standalone from v1's `src/searchTables`.
4
4
  */
5
- export { defineLinkedSearchTable, defineSearchTable, defineTableSearchTable, searchTableDuration, } from "./build.js";
5
+ export { linkedSearchTable, searchTable, tableSearchTable, searchTableDuration, } from "./build.js";
@@ -13,10 +13,10 @@ export function printSearchTable(table, ownerRefName,
13
13
  // "element" for managed/linked, "table" for table-owned. Never "app".
14
14
  parentScope, orgImportPath) {
15
15
  const builder = table.kind === "linked"
16
- ? "defineLinkedSearchTable"
16
+ ? "linkedSearchTable"
17
17
  : table.kind === "table"
18
- ? "defineTableSearchTable"
19
- : "defineSearchTable";
18
+ ? "tableSearchTable"
19
+ : "searchTable";
20
20
  const lines = [
21
21
  "/** Auto-generated by EDK pull. Hand-edit freely. */",
22
22
  `import { ${builder}, searchTableDuration } from ${quote(sdkPackageSpecifier("searchTables"))};`,
@@ -25,7 +25,7 @@ parentScope, orgImportPath) {
25
25
  ...(parentScope === "table" ? [`import tableDefinition from ${quote(`../${ownerRefName}.js`)};`] : []),
26
26
  "",
27
27
  ...(parentScope === "table" ? [`const table = tableDefinition.ref(${quote(ownerRefName)});`, ""] : []),
28
- `const searchTable = ${builder}({`,
28
+ `const configuredSearchTable = ${builder}({`,
29
29
  ];
30
30
  if (table.kind === "table") {
31
31
  const tableExpr = "table";
@@ -47,6 +47,6 @@ parentScope, orgImportPath) {
47
47
  if (table.warehouse !== undefined)
48
48
  lines.push(` warehouse: ${quote(table.warehouse)},`);
49
49
  }
50
- lines.push("});", "", "export default searchTable;", "");
50
+ lines.push("});", "", "export default configuredSearchTable;", "");
51
51
  return lines.join("\n");
52
52
  }
@@ -2,6 +2,27 @@ import type { OrgRefLookup } from "../../engine/build/context.js";
2
2
  import { type TfBlock, type TfValue } from "../../engine/tf/index.js";
3
3
  import type { AppRole } from "../role/build.js";
4
4
  import type { AppServiceAccount } from "./build.js";
5
+ /**
6
+ * Resolve a `serviceAccountRef({ app, name })` token to its terraform value:
7
+ * `elementum_service_account.<label>.id` when the name matches an account
8
+ * authored on the SAME app's `serviceAccounts` bag, otherwise a foreign
9
+ * `data.elementum_service_account` lookup (name/app_id-scoped, matching the
10
+ * provider's data source). Cross-app references are rejected with a
11
+ * diagnostic rather than silently guessed at — same restriction skill tool
12
+ * `runAs` already applies (a service account has no email to disambiguate
13
+ * it, only its owning app + name).
14
+ */
15
+ export declare function serviceAccountRefToTf(token: {
16
+ readonly __kind?: string;
17
+ readonly appRefName?: string;
18
+ readonly name?: string;
19
+ }, opts: {
20
+ readonly appRefName: string;
21
+ readonly appTfLabel: string;
22
+ readonly appId: TfValue;
23
+ readonly serviceAccounts?: Readonly<Record<string, AppServiceAccount>>;
24
+ readonly orgRefs: OrgRefLookup;
25
+ }, where: string, diagnostics: string[]): TfValue | undefined;
5
26
  export declare function serviceAccountsToTf(accounts: Readonly<Record<string, AppServiceAccount>> | undefined, opts: {
6
27
  readonly ownerTfLabel: string;
7
28
  readonly appId: TfValue;
@@ -1,5 +1,36 @@
1
- import { expr, sanitizeName, scopedResourceLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
1
+ import { appScopedResourceLabel, expr, sanitizeName, scopedResourceLabel, tsLabelToTfLabel } from "../../engine/tf/index.js";
2
2
  import { SERVICE_ACCOUNT_ACCESS_POLICY_RESOURCE_TYPE, SERVICE_ACCOUNT_RESOURCE_TYPE } from "./module.js";
3
+ /**
4
+ * Resolve a `serviceAccountRef({ app, name })` token to its terraform value:
5
+ * `elementum_service_account.<label>.id` when the name matches an account
6
+ * authored on the SAME app's `serviceAccounts` bag, otherwise a foreign
7
+ * `data.elementum_service_account` lookup (name/app_id-scoped, matching the
8
+ * provider's data source). Cross-app references are rejected with a
9
+ * diagnostic rather than silently guessed at — same restriction skill tool
10
+ * `runAs` already applies (a service account has no email to disambiguate
11
+ * it, only its owning app + name).
12
+ */
13
+ export function serviceAccountRefToTf(token, opts, where, diagnostics) {
14
+ if (token.__kind !== "serviceAccount" || token.name === undefined || token.name === "") {
15
+ diagnostics.push(`${where}: serviceAccount must be a serviceAccountRef({ app, name }); dropped`);
16
+ return undefined;
17
+ }
18
+ if (token.appRefName !== opts.appRefName) {
19
+ diagnostics.push(`${where}: service account ${JSON.stringify(token.name)} belongs to app ${JSON.stringify(token.appRefName ?? "")}, not owning app ${JSON.stringify(opts.appRefName)}; dropped`);
20
+ return undefined;
21
+ }
22
+ const local = Object.entries(opts.serviceAccounts ?? {}).filter(([, account]) => `${account.firstName} ${account.lastName}`.trim() === token.name);
23
+ if (local.length > 1) {
24
+ diagnostics.push(`${where}: service account name ${JSON.stringify(token.name)} is ambiguous in app ${JSON.stringify(opts.appRefName)}; dropped`);
25
+ return undefined;
26
+ }
27
+ if (local.length === 1) {
28
+ return expr.resourceAttr(SERVICE_ACCOUNT_RESOURCE_TYPE, appScopedResourceLabel(opts.appTfLabel, tsLabelToTfLabel(local[0][0])), ["id"]);
29
+ }
30
+ const label = appScopedResourceLabel(opts.appTfLabel, sanitizeName(token.name));
31
+ opts.orgRefs.rawLookup(SERVICE_ACCOUNT_RESOURCE_TYPE, label, token.name, { app_id: opts.appId });
32
+ return expr.dataAttr(SERVICE_ACCOUNT_RESOURCE_TYPE, label, ["id"]);
33
+ }
3
34
  function principalValues(values, type, where, orgRefs, diagnostics) {
4
35
  if (values === undefined || values.length === 0)
5
36
  return undefined;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Context & Proxy factory — builds the typed `ctx` object passed to each
3
- * .task() callback.
3
+ * fluent action method.
4
4
  *
5
5
  * At the TypeScript level, ctx.trigger.vendorName is Ref<string>.
6
6
  * At runtime, a Proxy intercepts the property access and returns a Ref
@@ -8,22 +8,22 @@
8
8
  *
9
9
  * This bridges compile-time type safety with runtime reference building.
10
10
  */
11
- import type { Ref, ToRefs, Simplify } from "./ref.js";
11
+ import type { CalculationTypeOfValue, Ref, Simplify, ToRefs } from "./ref.js";
12
12
  /**
13
13
  * Deep ref — a `Ref<T>` that also exposes `T`'s string-keyed properties as
14
- * nested deep refs. This is what makes `ctx.tasks.x.record.id` and
14
+ * nested deep refs. This is what makes `ctx.actions.x.record.id` and
15
15
  * `ctx.trigger.record.summary` type-check: each property access yields
16
16
  * another `Ref` whose runtime proxy extends the dotted path in `RefData.name`.
17
17
  *
18
18
  * Arrays stop the recursion — you can't drill into an array element by type.
19
19
  */
20
- export type DeepRef<T> = Ref<T> & (T extends ReadonlyArray<unknown> ? unknown : T extends object ? {
20
+ export type DeepRef<T> = Ref<T, CalculationTypeOfValue<T>> & (T extends ReadonlyArray<unknown> ? unknown : T extends string | number | boolean | bigint | null | undefined ? unknown : T extends object ? {
21
21
  [K in keyof T & string]: DeepRef<T[K]>;
22
22
  } : unknown);
23
23
  /**
24
24
  * Maps each key of `T` to a `DeepRef` — used for both trigger outputs and
25
- * task outputs so that property drilling (`ctx.trigger.record.summary`,
26
- * `ctx.tasks.x.record.id`) type-checks uniformly.
25
+ * action outputs so that property drilling (`ctx.trigger.record.summary`,
26
+ * `ctx.actions.x.record.id`) type-checks uniformly.
27
27
  */
28
28
  export type DeepRefs<T> = {
29
29
  [K in keyof T]: DeepRef<T[K]>;
@@ -31,27 +31,27 @@ export type DeepRefs<T> = {
31
31
  /**
32
32
  * Default open-ended shape for variables when the builder hasn't tracked
33
33
  * any typed `setVariable` calls yet — the generic-path form, where a variable
34
- * task may create several variables: `ctx.variables.<varTask>.<varName>` is
34
+ * an action may create several variables: `ctx.variables.<action>.<varName>` is
35
35
  * `Ref<unknown>`.
36
36
  */
37
37
  export type VariableRefs = {
38
- [taskName: string]: {
38
+ [actionName: string]: {
39
39
  [varName: string]: Ref<unknown>;
40
40
  };
41
41
  };
42
42
  /**
43
- * Narrow variable refs from the fluent `setVariable` tracking (task name →
44
- * the variable's TS value type). A fluent variable task holds exactly ONE
45
- * variable named after the task, so the task-name access IS the ref:
43
+ * Narrow variable refs from fluent `setVariable` tracking (action name →
44
+ * the variable's TS value type). A fluent variable action holds exactly one
45
+ * variable named after the action, so the action-name access is the ref:
46
46
  * `ctx.variables.<name>` is `Ref<T>` — no second hop.
47
47
  */
48
48
  type TypedVariableRefs<TVariables extends Record<string, unknown>> = {
49
- [TaskName in keyof TVariables]: Ref<TVariables[TaskName]>;
49
+ [ActionName in keyof TVariables]: Ref<TVariables[ActionName]>;
50
50
  };
51
- export type Context<TTrigger, TTasks extends Record<string, unknown>, TVariables extends Record<string, unknown> = Record<string, never>> = {
51
+ export type Context<TTrigger, TActions extends Record<string, unknown>, TVariables extends Record<string, unknown> = Record<string, never>> = {
52
52
  readonly trigger: DeepRefs<TTrigger>;
53
- readonly tasks: Simplify<{
54
- [K in keyof TTasks]: DeepRefs<TTasks[K]>;
53
+ readonly actions: Simplify<{
54
+ [K in keyof TActions]: DeepRefs<TActions[K]>;
55
55
  }>;
56
56
  readonly variables: keyof TVariables extends never ? VariableRefs : TypedVariableRefs<TVariables> & VariableRefs;
57
57
  };
@@ -63,15 +63,16 @@ export type Context<TTrigger, TTasks extends Record<string, unknown>, TVariables
63
63
  */
64
64
  export declare function createTriggerProxy<T>(): DeepRefs<T>;
65
65
  /**
66
- * Creates a proxy for a single task's outputs.
67
- * ctx.tasks.findVendor.records → Ref with { kind: "task", taskRefKey: "findVendor", name: "records" }
66
+ * Creates a proxy for a single action's outputs.
67
+ * ctx.actions.findVendor.records → Ref with
68
+ * { kind: "task", actionRefKey: "findVendor", name: "records" }
68
69
  */
69
- export declare function createTaskOutputProxy<T>(taskRefKey: string): DeepRefs<T>;
70
+ export declare function createActionOutputProxy<T>(actionRefKey: string): DeepRefs<T>;
70
71
  /**
71
- * Creates a proxy for the tasks namespace.
72
- * ctx.tasks → Proxy where each property access returns a task output proxy.
72
+ * Creates a proxy for the actions namespace.
73
+ * ctx.actions → Proxy where each property access returns an action output proxy.
73
74
  */
74
- export declare function createTasksProxy<TTasks extends Record<string, unknown>>(taskNames: string[]): Context<never, TTasks>["tasks"];
75
+ export declare function createActionsProxy<TActions extends Record<string, unknown>>(actionNames: string[]): Context<never, TActions>["actions"];
75
76
  /**
76
77
  * A forEach item that is both a Ref to the whole item and a proxy
77
78
  * with typed field access: item.fieldName → Ref<T[fieldName]>.
@@ -79,15 +80,15 @@ export declare function createTasksProxy<TTasks extends Record<string, unknown>>
79
80
  export type ForEachItem<T> = Ref<T> & ToRefs<T>;
80
81
  /**
81
82
  * Creates a forEach item proxy.
82
- * item.fieldName → Ref with { kind: "forEach", forEachTaskName, name: "fieldName" }
83
+ * item.fieldName → Ref with { kind: "forEach", forEachActionName, name: "fieldName" }
83
84
  * Accessing the item directly (without a property) returns a Ref to the whole item.
84
85
  */
85
- export declare function createForEachItemProxy<T>(forEachTaskName: string): ForEachItem<T>;
86
+ export declare function createForEachItemProxy<T>(forEachActionName: string): ForEachItem<T>;
86
87
  /**
87
88
  * Build a complete Context object for a given point in the chain.
88
89
  *
89
90
  * `TVariables` is a phantom — it only affects the compile-time shape of
90
91
  * `ctx.variables`. The runtime proxy is still an open-ended lookup.
91
92
  */
92
- export declare function buildContext<TTrigger, TTasks extends Record<string, unknown>, TVariables extends Record<string, unknown> = Record<string, never>>(taskNames: string[]): Context<TTrigger, TTasks, TVariables>;
93
+ export declare function buildContext<TTrigger, TActions extends Record<string, unknown>, TVariables extends Record<string, unknown> = Record<string, never>>(actionNames: string[]): Context<TTrigger, TActions, TVariables>;
93
94
  export {};