@dxos/plugin-automation 0.8.4-main.1da679c → 0.8.4-main.21d9917

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 (290) hide show
  1. package/dist/lib/browser/AutomationPanel-FAS6ADCW.mjs +11 -0
  2. package/dist/lib/browser/AutomationSettings-XN2OIYWL.mjs +56 -0
  3. package/dist/lib/browser/AutomationSettings-XN2OIYWL.mjs.map +7 -0
  4. package/dist/lib/browser/FunctionsContainer-6QLC7JP4.mjs +129 -0
  5. package/dist/lib/browser/FunctionsContainer-6QLC7JP4.mjs.map +7 -0
  6. package/dist/lib/browser/{FunctionsPanel-I443Y6KB.mjs → FunctionsPanel-ZX4J75UM.mjs} +3 -3
  7. package/dist/lib/browser/app-graph-builder-LAQMEBMH.mjs +84 -0
  8. package/dist/lib/browser/app-graph-builder-LAQMEBMH.mjs.map +7 -0
  9. package/dist/lib/browser/{chunk-NQGKPPXI.mjs → chunk-54PANILA.mjs} +5 -5
  10. package/dist/lib/browser/chunk-BFUIVUQH.mjs +102 -0
  11. package/dist/lib/browser/chunk-BFUIVUQH.mjs.map +7 -0
  12. package/dist/lib/browser/chunk-BKFQBKYO.mjs +8 -0
  13. package/dist/lib/browser/chunk-BKFQBKYO.mjs.map +7 -0
  14. package/dist/lib/browser/chunk-JOXPQ27I.mjs +83 -0
  15. package/dist/lib/browser/chunk-JOXPQ27I.mjs.map +7 -0
  16. package/dist/lib/browser/chunk-PZNBEKO5.mjs +17 -0
  17. package/dist/lib/browser/chunk-PZNBEKO5.mjs.map +7 -0
  18. package/dist/lib/browser/chunk-QW3EM35H.mjs +248 -0
  19. package/dist/lib/browser/chunk-QW3EM35H.mjs.map +7 -0
  20. package/dist/lib/browser/chunk-RAF2FJST.mjs +86 -0
  21. package/dist/lib/browser/chunk-RAF2FJST.mjs.map +7 -0
  22. package/dist/lib/browser/chunk-YWLEY2FD.mjs +200 -0
  23. package/dist/lib/browser/chunk-YWLEY2FD.mjs.map +7 -0
  24. package/dist/lib/browser/cli/index.mjs +1107 -0
  25. package/dist/lib/browser/cli/index.mjs.map +7 -0
  26. package/dist/lib/browser/compute-runtime-WTWLQ67J.mjs +114 -0
  27. package/dist/lib/browser/compute-runtime-WTWLQ67J.mjs.map +7 -0
  28. package/dist/lib/browser/hooks/index.mjs +5 -4
  29. package/dist/lib/browser/index.mjs +61 -51
  30. package/dist/lib/browser/index.mjs.map +4 -4
  31. package/dist/lib/browser/meta.json +1 -1
  32. package/dist/lib/browser/operation-resolver-Q3MWOR7K.mjs +82 -0
  33. package/dist/lib/browser/operation-resolver-Q3MWOR7K.mjs.map +7 -0
  34. package/dist/lib/browser/{react-surface-IYFH2BEM.mjs → react-surface-EV3AC62F.mjs} +14 -13
  35. package/dist/lib/browser/react-surface-EV3AC62F.mjs.map +7 -0
  36. package/dist/lib/browser/types/index.mjs +10 -4
  37. package/dist/lib/node-esm/{AutomationPanel-MKOLA2FE.mjs → AutomationPanel-B7NAGDFA.mjs} +4 -4
  38. package/dist/lib/node-esm/AutomationSettings-M5PMZJ6P.mjs +57 -0
  39. package/dist/lib/node-esm/AutomationSettings-M5PMZJ6P.mjs.map +7 -0
  40. package/dist/lib/node-esm/FunctionsContainer-J4O2ULWR.mjs +130 -0
  41. package/dist/lib/node-esm/FunctionsContainer-J4O2ULWR.mjs.map +7 -0
  42. package/dist/lib/node-esm/{FunctionsPanel-ELINCXPW.mjs → FunctionsPanel-SS6GIVNU.mjs} +3 -3
  43. package/dist/lib/node-esm/app-graph-builder-4UCMXHYY.mjs +85 -0
  44. package/dist/lib/node-esm/app-graph-builder-4UCMXHYY.mjs.map +7 -0
  45. package/dist/lib/node-esm/chunk-2CKVH7JC.mjs +201 -0
  46. package/dist/lib/node-esm/chunk-2CKVH7JC.mjs.map +7 -0
  47. package/dist/lib/node-esm/chunk-5FXNN3MV.mjs +19 -0
  48. package/dist/lib/node-esm/chunk-5FXNN3MV.mjs.map +7 -0
  49. package/dist/lib/node-esm/{chunk-UAOO5IZQ.mjs → chunk-7QRUPEHH.mjs} +5 -5
  50. package/dist/lib/node-esm/chunk-HQLVREIX.mjs +87 -0
  51. package/dist/lib/node-esm/chunk-HQLVREIX.mjs.map +7 -0
  52. package/dist/lib/node-esm/chunk-K7GCM342.mjs +10 -0
  53. package/dist/lib/node-esm/chunk-K7GCM342.mjs.map +7 -0
  54. package/dist/lib/node-esm/chunk-KWKWOGS5.mjs +103 -0
  55. package/dist/lib/node-esm/chunk-KWKWOGS5.mjs.map +7 -0
  56. package/dist/lib/node-esm/chunk-LJAXQ6CX.mjs +249 -0
  57. package/dist/lib/node-esm/chunk-LJAXQ6CX.mjs.map +7 -0
  58. package/dist/lib/node-esm/chunk-RX52VKI2.mjs +84 -0
  59. package/dist/lib/node-esm/chunk-RX52VKI2.mjs.map +7 -0
  60. package/dist/lib/node-esm/cli/index.mjs +1108 -0
  61. package/dist/lib/node-esm/cli/index.mjs.map +7 -0
  62. package/dist/lib/node-esm/compute-runtime-ZHROOBLY.mjs +115 -0
  63. package/dist/lib/node-esm/compute-runtime-ZHROOBLY.mjs.map +7 -0
  64. package/dist/lib/node-esm/hooks/index.mjs +5 -4
  65. package/dist/lib/node-esm/index.mjs +61 -51
  66. package/dist/lib/node-esm/index.mjs.map +4 -4
  67. package/dist/lib/node-esm/meta.json +1 -1
  68. package/dist/lib/node-esm/operation-resolver-R5GA4YNO.mjs +83 -0
  69. package/dist/lib/node-esm/operation-resolver-R5GA4YNO.mjs.map +7 -0
  70. package/dist/lib/node-esm/{react-surface-FDRJ76PK.mjs → react-surface-S6VZJCEZ.mjs} +14 -13
  71. package/dist/lib/node-esm/react-surface-S6VZJCEZ.mjs.map +7 -0
  72. package/dist/lib/node-esm/types/index.mjs +10 -4
  73. package/dist/types/src/AutomationPlugin.d.ts +2 -1
  74. package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
  75. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
  76. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
  77. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
  78. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
  79. package/dist/types/src/capabilities/compute-runtime/compute-runtime.d.ts +6 -0
  80. package/dist/types/src/capabilities/compute-runtime/compute-runtime.d.ts.map +1 -0
  81. package/dist/types/src/capabilities/compute-runtime/index.d.ts +3 -0
  82. package/dist/types/src/capabilities/compute-runtime/index.d.ts.map +1 -0
  83. package/dist/types/src/capabilities/index.d.ts +4 -5
  84. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  85. package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
  86. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
  87. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
  88. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
  89. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  90. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  91. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  92. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  93. package/dist/types/src/cli/commands/index.d.ts +2 -0
  94. package/dist/types/src/cli/commands/index.d.ts.map +1 -0
  95. package/dist/types/src/cli/commands/trigger/create/index.d.ts +25 -0
  96. package/dist/types/src/cli/commands/trigger/create/index.d.ts.map +1 -0
  97. package/dist/types/src/cli/commands/trigger/create/queue.d.ts +13 -0
  98. package/dist/types/src/cli/commands/trigger/create/queue.d.ts.map +1 -0
  99. package/dist/types/src/cli/commands/trigger/create/subscription.d.ts +15 -0
  100. package/dist/types/src/cli/commands/trigger/create/subscription.d.ts.map +1 -0
  101. package/dist/types/src/cli/commands/trigger/create/timer.d.ts +13 -0
  102. package/dist/types/src/cli/commands/trigger/create/timer.d.ts.map +1 -0
  103. package/dist/types/src/cli/commands/trigger/index.d.ts +57 -0
  104. package/dist/types/src/cli/commands/trigger/index.d.ts.map +1 -0
  105. package/dist/types/src/cli/commands/trigger/list.d.ts +7 -0
  106. package/dist/types/src/cli/commands/trigger/list.d.ts.map +1 -0
  107. package/dist/types/src/cli/commands/trigger/options.d.ts +11 -0
  108. package/dist/types/src/cli/commands/trigger/options.d.ts.map +1 -0
  109. package/dist/types/src/cli/commands/trigger/remove.d.ts +8 -0
  110. package/dist/types/src/cli/commands/trigger/remove.d.ts.map +1 -0
  111. package/dist/types/src/cli/commands/trigger/update/index.d.ts +28 -0
  112. package/dist/types/src/cli/commands/trigger/update/index.d.ts.map +1 -0
  113. package/dist/types/src/cli/commands/trigger/update/queue.d.ts +12 -0
  114. package/dist/types/src/cli/commands/trigger/update/queue.d.ts.map +1 -0
  115. package/dist/types/src/cli/commands/trigger/update/subscription.d.ts +13 -0
  116. package/dist/types/src/cli/commands/trigger/update/subscription.d.ts.map +1 -0
  117. package/dist/types/src/cli/commands/trigger/update/timer.d.ts +11 -0
  118. package/dist/types/src/cli/commands/trigger/update/timer.d.ts.map +1 -0
  119. package/dist/types/src/cli/commands/trigger/util.d.ts +46 -0
  120. package/dist/types/src/cli/commands/trigger/util.d.ts.map +1 -0
  121. package/dist/types/src/cli/index.d.ts +2 -0
  122. package/dist/types/src/cli/index.d.ts.map +1 -0
  123. package/dist/types/src/cli/plugin.d.ts +3 -0
  124. package/dist/types/src/cli/plugin.d.ts.map +1 -0
  125. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +3 -3
  126. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
  127. package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts +4 -1
  128. package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
  129. package/dist/types/src/components/FunctionsContainer.d.ts.map +1 -1
  130. package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts.map +1 -1
  131. package/dist/types/src/components/FunctionsRegistry/FunctionsRegistry.d.ts +8 -0
  132. package/dist/types/src/components/FunctionsRegistry/FunctionsRegistry.d.ts.map +1 -0
  133. package/dist/types/src/components/FunctionsRegistry/index.d.ts +2 -0
  134. package/dist/types/src/components/FunctionsRegistry/index.d.ts.map +1 -0
  135. package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts +12 -9
  136. package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts.map +1 -1
  137. package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts +6 -3
  138. package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts.map +1 -1
  139. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +11 -8
  140. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
  141. package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +77 -6
  142. package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
  143. package/dist/types/src/components/TriggerSettings.d.ts +3 -3
  144. package/dist/types/src/components/TriggerSettings.d.ts.map +1 -1
  145. package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts +8 -4
  146. package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts.map +1 -1
  147. package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts +4 -4
  148. package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts.map +1 -1
  149. package/dist/types/src/index.d.ts +2 -1
  150. package/dist/types/src/index.d.ts.map +1 -1
  151. package/dist/types/src/meta.d.ts +2 -3
  152. package/dist/types/src/meta.d.ts.map +1 -1
  153. package/dist/types/src/testing/test-functions.d.ts +2 -3
  154. package/dist/types/src/testing/test-functions.d.ts.map +1 -1
  155. package/dist/types/src/translations.d.ts +4 -0
  156. package/dist/types/src/translations.d.ts.map +1 -1
  157. package/dist/types/src/types/capabilities.d.ts +22 -0
  158. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  159. package/dist/types/src/types/events.d.ts +5 -0
  160. package/dist/types/src/types/events.d.ts.map +1 -0
  161. package/dist/types/src/types/index.d.ts +2 -0
  162. package/dist/types/src/types/index.d.ts.map +1 -1
  163. package/dist/types/src/types/schema.d.ts +31 -2
  164. package/dist/types/src/types/schema.d.ts.map +1 -1
  165. package/dist/types/tsconfig.tsbuildinfo +1 -1
  166. package/package.json +62 -46
  167. package/src/AutomationPlugin.tsx +18 -37
  168. package/src/capabilities/app-graph-builder/app-graph-builder.ts +71 -0
  169. package/src/capabilities/app-graph-builder/index.ts +7 -0
  170. package/src/capabilities/compute-runtime/compute-runtime.ts +133 -0
  171. package/src/capabilities/compute-runtime/index.ts +7 -0
  172. package/src/capabilities/index.ts +4 -8
  173. package/src/capabilities/operation-resolver/index.ts +7 -0
  174. package/src/capabilities/operation-resolver/operation-resolver.ts +79 -0
  175. package/src/capabilities/react-surface/index.ts +7 -0
  176. package/src/capabilities/react-surface/react-surface.tsx +60 -0
  177. package/src/cli/commands/index.ts +5 -0
  178. package/src/cli/commands/trigger/create/index.ts +14 -0
  179. package/src/cli/commands/trigger/create/queue.ts +89 -0
  180. package/src/cli/commands/trigger/create/subscription.ts +128 -0
  181. package/src/cli/commands/trigger/create/timer.ts +93 -0
  182. package/src/cli/commands/trigger/index.ts +16 -0
  183. package/src/cli/commands/trigger/list.ts +67 -0
  184. package/src/cli/commands/trigger/options.ts +59 -0
  185. package/src/cli/commands/trigger/remove.ts +45 -0
  186. package/src/cli/commands/trigger/update/index.ts +14 -0
  187. package/src/cli/commands/trigger/update/queue.ts +195 -0
  188. package/src/cli/commands/trigger/update/subscription.ts +278 -0
  189. package/src/cli/commands/trigger/update/timer.ts +193 -0
  190. package/src/cli/commands/trigger/util.ts +395 -0
  191. package/src/cli/index.ts +5 -0
  192. package/src/cli/plugin.ts +23 -0
  193. package/src/components/AutomationPanel/AutomationPanel.stories.tsx +7 -11
  194. package/src/components/AutomationPanel/AutomationPanel.tsx +132 -40
  195. package/src/components/AutomationSettings.tsx +5 -5
  196. package/src/components/FunctionsContainer.tsx +11 -4
  197. package/src/components/FunctionsPanel/FunctionsPanel.tsx +33 -19
  198. package/src/components/FunctionsRegistry/FunctionsRegistry.tsx +111 -0
  199. package/src/components/FunctionsRegistry/index.ts +5 -0
  200. package/src/components/TriggerEditor/FunctionInputEditor.tsx +33 -35
  201. package/src/components/TriggerEditor/SpecSelector.tsx +21 -13
  202. package/src/components/TriggerEditor/TriggerEditor.stories.tsx +70 -27
  203. package/src/components/TriggerEditor/TriggerEditor.tsx +81 -42
  204. package/src/components/TriggerSettings.tsx +3 -3
  205. package/src/hooks/useComputeRuntimeCallback.ts +45 -8
  206. package/src/hooks/useTriggerRuntimeControls.ts +11 -10
  207. package/src/index.ts +2 -1
  208. package/src/meta.ts +8 -7
  209. package/src/testing/test-functions.ts +3 -3
  210. package/src/translations.ts +5 -0
  211. package/src/types/capabilities.ts +42 -0
  212. package/src/types/events.ts +11 -0
  213. package/src/types/index.ts +2 -0
  214. package/src/types/schema.ts +24 -3
  215. package/dist/lib/browser/AutomationPanel-N5HFJJXW.mjs +0 -11
  216. package/dist/lib/browser/AutomationSettings-S3F2VT7Q.mjs +0 -70
  217. package/dist/lib/browser/AutomationSettings-S3F2VT7Q.mjs.map +0 -7
  218. package/dist/lib/browser/FunctionsContainer-U4HASI4P.mjs +0 -36
  219. package/dist/lib/browser/FunctionsContainer-U4HASI4P.mjs.map +0 -7
  220. package/dist/lib/browser/app-graph-builder-SRA3X2GQ.mjs +0 -80
  221. package/dist/lib/browser/app-graph-builder-SRA3X2GQ.mjs.map +0 -7
  222. package/dist/lib/browser/chunk-4TWQV33E.mjs +0 -143
  223. package/dist/lib/browser/chunk-4TWQV33E.mjs.map +0 -7
  224. package/dist/lib/browser/chunk-CRUNQZ2M.mjs +0 -15
  225. package/dist/lib/browser/chunk-CRUNQZ2M.mjs.map +0 -7
  226. package/dist/lib/browser/chunk-GW5U2DGT.mjs +0 -15
  227. package/dist/lib/browser/chunk-GW5U2DGT.mjs.map +0 -7
  228. package/dist/lib/browser/chunk-HN7OHFCB.mjs +0 -38
  229. package/dist/lib/browser/chunk-HN7OHFCB.mjs.map +0 -7
  230. package/dist/lib/browser/chunk-P6YOYDXP.mjs +0 -53
  231. package/dist/lib/browser/chunk-P6YOYDXP.mjs.map +0 -7
  232. package/dist/lib/browser/chunk-S4SM663I.mjs +0 -230
  233. package/dist/lib/browser/chunk-S4SM663I.mjs.map +0 -7
  234. package/dist/lib/browser/chunk-UHXDXRP4.mjs +0 -14
  235. package/dist/lib/browser/chunk-UHXDXRP4.mjs.map +0 -7
  236. package/dist/lib/browser/chunk-Z5DT4MHW.mjs +0 -94
  237. package/dist/lib/browser/chunk-Z5DT4MHW.mjs.map +0 -7
  238. package/dist/lib/browser/compute-runtime-G25R3RSS.mjs +0 -154
  239. package/dist/lib/browser/compute-runtime-G25R3RSS.mjs.map +0 -7
  240. package/dist/lib/browser/intent-resolver-CMLGPFD6.mjs +0 -77
  241. package/dist/lib/browser/intent-resolver-CMLGPFD6.mjs.map +0 -7
  242. package/dist/lib/browser/react-surface-IYFH2BEM.mjs.map +0 -7
  243. package/dist/lib/node-esm/AutomationSettings-C3GNAUYC.mjs +0 -71
  244. package/dist/lib/node-esm/AutomationSettings-C3GNAUYC.mjs.map +0 -7
  245. package/dist/lib/node-esm/FunctionsContainer-VZIVURH6.mjs +0 -37
  246. package/dist/lib/node-esm/FunctionsContainer-VZIVURH6.mjs.map +0 -7
  247. package/dist/lib/node-esm/app-graph-builder-R5XQJKZS.mjs +0 -81
  248. package/dist/lib/node-esm/app-graph-builder-R5XQJKZS.mjs.map +0 -7
  249. package/dist/lib/node-esm/chunk-AONUBWBE.mjs +0 -144
  250. package/dist/lib/node-esm/chunk-AONUBWBE.mjs.map +0 -7
  251. package/dist/lib/node-esm/chunk-BTD2B4SZ.mjs +0 -16
  252. package/dist/lib/node-esm/chunk-BTD2B4SZ.mjs.map +0 -7
  253. package/dist/lib/node-esm/chunk-CTAX6WBZ.mjs +0 -16
  254. package/dist/lib/node-esm/chunk-CTAX6WBZ.mjs.map +0 -7
  255. package/dist/lib/node-esm/chunk-CX2AILIS.mjs +0 -95
  256. package/dist/lib/node-esm/chunk-CX2AILIS.mjs.map +0 -7
  257. package/dist/lib/node-esm/chunk-NK5N3QKD.mjs +0 -17
  258. package/dist/lib/node-esm/chunk-NK5N3QKD.mjs.map +0 -7
  259. package/dist/lib/node-esm/chunk-OEZNHUL2.mjs +0 -39
  260. package/dist/lib/node-esm/chunk-OEZNHUL2.mjs.map +0 -7
  261. package/dist/lib/node-esm/chunk-XL33Y62M.mjs +0 -54
  262. package/dist/lib/node-esm/chunk-XL33Y62M.mjs.map +0 -7
  263. package/dist/lib/node-esm/chunk-ZOJVKPCA.mjs +0 -231
  264. package/dist/lib/node-esm/chunk-ZOJVKPCA.mjs.map +0 -7
  265. package/dist/lib/node-esm/compute-runtime-LHO62OVM.mjs +0 -155
  266. package/dist/lib/node-esm/compute-runtime-LHO62OVM.mjs.map +0 -7
  267. package/dist/lib/node-esm/intent-resolver-NUPI6NC6.mjs +0 -78
  268. package/dist/lib/node-esm/intent-resolver-NUPI6NC6.mjs.map +0 -7
  269. package/dist/lib/node-esm/react-surface-FDRJ76PK.mjs.map +0 -7
  270. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  271. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  272. package/dist/types/src/capabilities/capabilities.d.ts +0 -18
  273. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  274. package/dist/types/src/capabilities/compute-runtime.d.ts +0 -5
  275. package/dist/types/src/capabilities/compute-runtime.d.ts.map +0 -1
  276. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  277. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  278. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  279. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  280. package/src/capabilities/app-graph-builder.ts +0 -86
  281. package/src/capabilities/capabilities.ts +0 -52
  282. package/src/capabilities/compute-runtime.ts +0 -124
  283. package/src/capabilities/intent-resolver.ts +0 -72
  284. package/src/capabilities/react-surface.tsx +0 -56
  285. /package/dist/lib/browser/{AutomationPanel-N5HFJJXW.mjs.map → AutomationPanel-FAS6ADCW.mjs.map} +0 -0
  286. /package/dist/lib/browser/{FunctionsPanel-I443Y6KB.mjs.map → FunctionsPanel-ZX4J75UM.mjs.map} +0 -0
  287. /package/dist/lib/browser/{chunk-NQGKPPXI.mjs.map → chunk-54PANILA.mjs.map} +0 -0
  288. /package/dist/lib/node-esm/{AutomationPanel-MKOLA2FE.mjs.map → AutomationPanel-B7NAGDFA.mjs.map} +0 -0
  289. /package/dist/lib/node-esm/{FunctionsPanel-ELINCXPW.mjs.map → FunctionsPanel-SS6GIVNU.mjs.map} +0 -0
  290. /package/dist/lib/node-esm/{chunk-UAOO5IZQ.mjs.map → chunk-7QRUPEHH.mjs.map} +0 -0
@@ -2,52 +2,71 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
6
- import React, { useState } from 'react';
7
-
8
- import { Filter, Obj } from '@dxos/echo';
9
- import { FunctionTrigger, FunctionType, ScriptType } from '@dxos/functions';
5
+ import * as Array from 'effect/Array';
6
+ import * as EFn from 'effect/Function';
7
+ import * as Match from 'effect/Match';
8
+ import * as Schema from 'effect/Schema';
9
+ import React, { useMemo, useState } from 'react';
10
+
11
+ import { Filter, Obj, Tag } from '@dxos/echo';
12
+ import { Function, Script, Trigger } from '@dxos/functions';
13
+ import { FunctionsServiceClient } from '@dxos/functions-runtime/edge';
14
+ import { useTypeOptions } from '@dxos/plugin-space';
10
15
  import { type Client, useClient } from '@dxos/react-client';
11
- import { type Space, getSpace, useQuery } from '@dxos/react-client/echo';
16
+ import { type Space, useQuery } from '@dxos/react-client/echo';
12
17
  import { Clipboard, IconButton, Input, Separator, type ThemedClassName, useTranslation } from '@dxos/react-ui';
13
18
  import { ControlItem, controlItemClasses } from '@dxos/react-ui-form';
14
19
  import { List } from '@dxos/react-ui-list';
15
- import { ghostHover, mx } from '@dxos/react-ui-theme';
20
+ import { Project } from '@dxos/types';
21
+ import { ghostHover, mx } from '@dxos/ui-theme';
22
+ import { isNonNullable } from '@dxos/util';
16
23
 
17
- import { AUTOMATION_PLUGIN } from '../../meta';
24
+ import { meta } from '../../meta';
18
25
  import { TriggerEditor, type TriggerEditorProps } from '../TriggerEditor';
19
26
 
20
- const grid = 'grid grid-cols-[40px_1fr_32px] min-bs-[2.5rem]';
27
+ const grid = 'grid grid-cols-[40px_1fr_32px_32px] min-bs-[2.5rem]';
21
28
 
22
29
  export type AutomationPanelProps = ThemedClassName<{
23
30
  space: Space;
24
- object?: Obj.Any;
25
- initialTrigger?: FunctionTrigger;
31
+ object?: Obj.Unknown;
32
+ initialTrigger?: Trigger.Trigger;
26
33
  onDone?: () => void;
27
34
  }>;
28
35
 
29
36
  // TODO(burdon): Factor out common layout with ViewEditor.
30
37
  export const AutomationPanel = ({ classNames, space, object, initialTrigger, onDone }: AutomationPanelProps) => {
31
- const { t } = useTranslation(AUTOMATION_PLUGIN);
38
+ const { t } = useTranslation(meta.id);
32
39
  const client = useClient();
33
- const triggers = useQuery(space, Filter.type(FunctionTrigger));
34
- const functions = useQuery(space, Filter.type(FunctionType));
35
- const scripts = useQuery(space, Filter.type(ScriptType));
36
-
37
- const [trigger, setTrigger] = useState<FunctionTrigger | undefined>(initialTrigger);
38
- const [selected, setSelected] = useState<FunctionTrigger>();
39
-
40
- const handleSelect = (trigger: FunctionTrigger) => {
40
+ const functionsServiceClient = useMemo(() => FunctionsServiceClient.fromClient(client), [client]);
41
+ const functions = useQuery(space.db, Filter.type(Function.Function));
42
+ const triggers = useQuery(space.db, Filter.type(Trigger.Trigger));
43
+ const filteredTriggers = useMemo(() => {
44
+ return object ? triggers.filter(triggerMatch(object)) : triggers;
45
+ }, [object, triggers]);
46
+ const tags = useQuery(space.db, Filter.type(Tag.Tag));
47
+ const types = useTypeOptions({
48
+ space,
49
+ annotation: {
50
+ location: ['database', 'runtime'],
51
+ kind: ['user'],
52
+ registered: ['registered'],
53
+ },
54
+ });
55
+
56
+ const [trigger, setTrigger] = useState<Trigger.Trigger | undefined>(initialTrigger);
57
+ const [selected, setSelected] = useState<Trigger.Trigger>();
58
+
59
+ const handleSelect = (trigger: Trigger.Trigger) => {
41
60
  setTrigger(trigger);
42
61
  setSelected(trigger);
43
62
  };
44
63
 
45
64
  const handleAdd = () => {
46
- setTrigger(Obj.make(FunctionTrigger, {}));
65
+ setTrigger(Trigger.make({}));
47
66
  setSelected(undefined);
48
67
  };
49
68
 
50
- const handleDelete = (trigger: FunctionTrigger) => {
69
+ const handleDelete = (trigger: Trigger.Trigger) => {
51
70
  space.db.remove(trigger);
52
71
  setTrigger(undefined);
53
72
  setSelected(undefined);
@@ -57,7 +76,7 @@ export const AutomationPanel = ({ classNames, space, object, initialTrigger, onD
57
76
  if (selected) {
58
77
  Object.assign(selected, trigger);
59
78
  } else {
60
- space.db.add(Obj.make(FunctionTrigger, trigger));
79
+ space.db.add(Trigger.make(trigger));
61
80
  }
62
81
 
63
82
  setTrigger(undefined);
@@ -70,41 +89,61 @@ export const AutomationPanel = ({ classNames, space, object, initialTrigger, onD
70
89
  onDone?.();
71
90
  };
72
91
 
92
+ const handleForceRunTrigger = async (trigger: Trigger.Trigger) => {
93
+ await functionsServiceClient.forceRunCronTrigger(space.id, trigger.id);
94
+ };
95
+
73
96
  if (trigger) {
74
97
  return (
75
98
  <ControlItem title={t('trigger editor title')}>
76
- <TriggerEditor space={space} trigger={trigger} onSave={handleSave} onCancel={handleCancel} />
99
+ <TriggerEditor
100
+ db={space.db}
101
+ trigger={trigger}
102
+ readonlySpec={Boolean(object)}
103
+ tags={tags}
104
+ types={types}
105
+ onSave={handleSave}
106
+ onCancel={handleCancel}
107
+ />
77
108
  </ControlItem>
78
109
  );
79
110
  }
80
111
 
81
112
  return (
82
113
  <div className={mx(controlItemClasses, classNames)}>
83
- {triggers.length > 0 && (
84
- <List.Root<FunctionTrigger> items={triggers} isItem={Schema.is(FunctionTrigger)} getId={(field) => field.id}>
85
- {({ items: triggers }) => (
86
- <div role='list' className='flex flex-col w-full'>
87
- {triggers?.map((trigger) => {
114
+ {filteredTriggers.length > 0 && (
115
+ <List.Root<Trigger.Trigger>
116
+ items={filteredTriggers}
117
+ isItem={Schema.is(Trigger.Trigger)}
118
+ getId={(field) => field.id}
119
+ >
120
+ {({ items: filteredTriggers }) => (
121
+ <div role='list' className='flex flex-col is-full'>
122
+ {filteredTriggers?.map((trigger) => {
88
123
  const copyAction = getCopyAction(client, trigger);
89
124
  return (
90
- <List.Item<FunctionTrigger>
125
+ <List.Item<Trigger.Trigger>
91
126
  key={trigger.id}
92
127
  item={trigger}
93
- classNames={mx(grid, ghostHover, 'items-center', 'px-2')}
128
+ classNames={mx(grid, ghostHover, 'items-center', 'pli-2')}
94
129
  >
95
130
  <Input.Root>
96
131
  <Input.Switch
97
132
  checked={trigger.enabled}
98
- onCheckedChange={(checked) => (trigger.enabled = checked)}
133
+ onCheckedChange={(checked) =>
134
+ Obj.change(trigger, (t) => {
135
+ t.enabled = checked;
136
+ })
137
+ }
99
138
  />
100
139
  </Input.Root>
101
140
 
102
141
  <div className={'flex'}>
103
142
  <List.ItemTitle
104
- classNames='px-1 cursor-pointer w-0 shrink truncate'
143
+ classNames='pli-1 cursor-pointer is-0 shrink truncate'
105
144
  onClick={() => handleSelect(trigger)}
106
145
  >
107
- {getFunctionName(scripts, functions, trigger) ?? '∅'}
146
+ {getFunctionName(functions, trigger) ?? '∅'}
108
147
  </List.ItemTitle>
109
148
 
110
149
  {/* TODO: a better way to expose copy action */}
@@ -116,6 +155,14 @@ export const AutomationPanel = ({ classNames, space, object, initialTrigger, onD
116
155
  )}
117
156
  </div>
118
157
 
158
+ <List.ItemButton
159
+ autoHide={false}
160
+ disabled={!trigger.enabled || trigger.spec?.kind !== 'timer'}
161
+ icon='ph--play--regular'
162
+ label='Force run'
163
+ onClick={() => handleForceRunTrigger(trigger)}
164
+ />
165
+
119
166
  <List.ItemDeleteButton onClick={() => handleDelete(trigger)} />
120
167
  </List.Item>
121
168
  );
@@ -124,15 +171,18 @@ export const AutomationPanel = ({ classNames, space, object, initialTrigger, onD
124
171
  )}
125
172
  </List.Root>
126
173
  )}
127
- {triggers.length > 0 && <Separator classNames='mlb-4' />}
174
+ {filteredTriggers.length > 0 && <Separator classNames='mlb-4' />}
128
175
  <IconButton icon='ph--plus--regular' label={t('new trigger label')} onClick={handleAdd} />
129
176
  </div>
130
177
  );
131
178
  };
132
179
 
133
- const getCopyAction = (client: Client, trigger: FunctionTrigger | undefined) => {
180
+ const getCopyAction = (client: Client, trigger: Trigger.Trigger | undefined) => {
134
181
  if (trigger?.spec?.kind === 'email') {
135
- return { translationKey: 'trigger copy email', contentProvider: () => `${getSpace(trigger)!.id}@dxos.network` };
182
+ return {
183
+ translationKey: 'trigger copy email',
184
+ contentProvider: () => `${Obj.getDatabase(trigger)!.spaceId}@dxos.network`,
185
+ };
136
186
  }
137
187
 
138
188
  if (trigger?.spec?.kind === 'webhook') {
@@ -142,18 +192,60 @@ const getCopyAction = (client: Client, trigger: FunctionTrigger | undefined) =>
142
192
  return undefined;
143
193
  };
144
194
 
145
- const getWebhookUrl = (client: Client, trigger: FunctionTrigger) => {
146
- const spaceId = getSpace(trigger)!.id;
195
+ const getWebhookUrl = (client: Client, trigger: Trigger.Trigger) => {
196
+ const spaceId = Obj.getDatabase(trigger)!.spaceId;
147
197
  const edgeUrl = new URL(client.config.values.runtime!.services!.edge!.url!);
148
198
  const isSecure = edgeUrl.protocol.startsWith('https') || edgeUrl.protocol.startsWith('wss');
149
199
  edgeUrl.protocol = isSecure ? 'https' : 'http';
150
200
  return new URL(`/webhook/${spaceId}:${trigger.id}`, edgeUrl).toString();
151
201
  };
152
202
 
153
- const getFunctionName = (scripts: ScriptType[], functions: FunctionType[], trigger: FunctionTrigger) => {
203
+ const getFunctionName = (functions: Function.Function[], trigger: Trigger.Trigger) => {
154
204
  // TODO(wittjosiah): Truncation should be done in the UI.
155
205
  // Warning that the List component is currently a can of worms.
156
206
  const shortId = trigger.function && `${trigger.function.dxn.toString().slice(0, 16)}…`;
157
207
  const functionObject = functions.find((fn) => fn === trigger.function?.target);
158
208
  return functionObject?.name ?? shortId;
159
209
  };
210
+
211
+ const scriptMatch = (script: Script.Script) => (trigger: Trigger.Trigger) => {
212
+ const fn = trigger.function?.target;
213
+ if (!Obj.instanceOf(Function.Function, fn)) {
214
+ return false;
215
+ }
216
+
217
+ return fn.source?.target === script;
218
+ };
219
+
220
+ const projectMatch = (project: Project.Project) => {
221
+ const viewQueries = EFn.pipe(
222
+ project.columns,
223
+ Array.map((column) => column.view.target),
224
+ Array.filter(isNonNullable),
225
+ Array.map((view) => Obj.getSnapshot(view).query.ast),
226
+ Array.map((ast) => JSON.stringify(ast)),
227
+ );
228
+
229
+ return (trigger: Trigger.Trigger) => {
230
+ const spec = Obj.getSnapshot(trigger).spec;
231
+ if (spec?.kind !== 'subscription') {
232
+ return false;
233
+ }
234
+
235
+ // TODO(wittjosiah): Implement better way of comparing query ASTs.
236
+ return viewQueries.some((query) => JSON.stringify(spec.query) === query);
237
+ };
238
+ };
239
+
240
+ const triggerMatch = Match.type<Obj.Unknown>().pipe(
241
+ Match.withReturnType<(trigger: Trigger.Trigger) => boolean>(),
242
+ Match.when(
243
+ (obj) => Obj.instanceOf(Script.Script, obj),
244
+ (obj) => scriptMatch(obj),
245
+ ),
246
+ Match.when(
247
+ (obj) => Obj.instanceOf(Project.Project, obj),
248
+ (obj) => projectMatch(obj),
249
+ ),
250
+ Match.orElse((_obj) => () => true),
251
+ );
@@ -7,21 +7,21 @@ import React from 'react';
7
7
  import { useTranslation } from '@dxos/react-ui';
8
8
  import { ControlPage, ControlSection } from '@dxos/react-ui-form';
9
9
 
10
- import { AUTOMATION_PLUGIN } from '../meta';
10
+ import { meta } from '../meta';
11
11
 
12
12
  import { AutomationPanel, type AutomationPanelProps } from './AutomationPanel';
13
13
  import { TriggersSettings } from './TriggerSettings';
14
14
 
15
15
  export const AutomationSettings = (props: AutomationPanelProps) => {
16
- const { t } = useTranslation(AUTOMATION_PLUGIN);
16
+ const { t } = useTranslation(meta.id);
17
17
  return (
18
18
  <ControlPage>
19
19
  <ControlSection
20
- title={t('automation verbose label', { ns: AUTOMATION_PLUGIN })}
21
- description={t('automation description', { ns: AUTOMATION_PLUGIN })}
20
+ title={t('automation verbose label', { ns: meta.id })}
21
+ description={t('automation description', { ns: meta.id })}
22
22
  >
23
23
  <AutomationPanel {...props} />
24
- <TriggersSettings space={props.space} />
24
+ <TriggersSettings db={props.space.db} />
25
25
  </ControlSection>
26
26
  </ControlPage>
27
27
  );
@@ -8,20 +8,27 @@ import { type Space } from '@dxos/react-client/echo';
8
8
  import { useTranslation } from '@dxos/react-ui';
9
9
  import { ControlPage, ControlSection } from '@dxos/react-ui-form';
10
10
 
11
- import { AUTOMATION_PLUGIN } from '../meta';
11
+ import { meta } from '../meta';
12
12
 
13
13
  import { FunctionsPanel } from './FunctionsPanel';
14
+ import { FunctionsRegistry } from './FunctionsRegistry';
14
15
 
15
16
  export const FunctionsContainer = ({ space }: { space: Space }) => {
16
- const { t } = useTranslation(AUTOMATION_PLUGIN);
17
+ const { t } = useTranslation(meta.id);
17
18
  return (
18
19
  <ControlPage>
19
20
  <ControlSection
20
- title={t('functions verbose label', { ns: AUTOMATION_PLUGIN })}
21
- description={t('functions description', { ns: AUTOMATION_PLUGIN })}
21
+ title={t('functions verbose label', { ns: meta.id })}
22
+ description={t('functions description', { ns: meta.id })}
22
23
  >
23
24
  <FunctionsPanel space={space} />
24
25
  </ControlSection>
26
+ <ControlSection
27
+ title={t('functions registry verbose label', { ns: meta.id })}
28
+ description={t('functions registry description', { ns: meta.id })}
29
+ >
30
+ <FunctionsRegistry space={space} />
31
+ </ControlSection>
25
32
  </ControlPage>
26
33
  );
27
34
  };
@@ -2,18 +2,21 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
5
+ import * as Schema from 'effect/Schema';
6
6
  import React, { useCallback, useMemo } from 'react';
7
7
 
8
- import { LayoutAction, createIntent, useIntentDispatcher } from '@dxos/app-framework';
9
- import { FunctionType, ScriptType } from '@dxos/functions';
10
- import { Filter, type Space, fullyQualifiedId, useQuery } from '@dxos/react-client/echo';
11
- import { Button, useTranslation } from '@dxos/react-ui';
8
+ import { Common } from '@dxos/app-framework';
9
+ import { useOperationInvoker } from '@dxos/app-framework/react';
10
+ import { Obj } from '@dxos/echo';
11
+ import { Function, Script } from '@dxos/functions';
12
+ import { SpaceOperation } from '@dxos/plugin-space/types';
13
+ import { Filter, type Space, useQuery } from '@dxos/react-client/echo';
14
+ import { Button, IconButton, useTranslation } from '@dxos/react-ui';
12
15
  import { controlItemClasses } from '@dxos/react-ui-form';
13
16
  import { List } from '@dxos/react-ui-list';
14
- import { ghostHover, mx } from '@dxos/react-ui-theme';
17
+ import { ghostHover, mx } from '@dxos/ui-theme';
15
18
 
16
- import { AUTOMATION_PLUGIN } from '../../meta';
19
+ import { meta } from '../../meta';
17
20
 
18
21
  const grid = 'grid grid-cols-[1fr_auto] min-bs-[2.5rem]';
19
22
 
@@ -22,10 +25,10 @@ export type FunctionsPanelProps = {
22
25
  };
23
26
 
24
27
  export const FunctionsPanel = ({ space }: FunctionsPanelProps) => {
25
- const { t } = useTranslation(AUTOMATION_PLUGIN);
26
- const functions = useQuery(space, Filter.type(FunctionType));
27
- const scripts = useQuery(space, Filter.type(ScriptType));
28
- const { dispatchPromise: dispatch } = useIntentDispatcher();
28
+ const { t } = useTranslation(meta.id);
29
+ const functions = useQuery(space.db, Filter.type(Function.Function));
30
+ const scripts = useQuery(space.db, Filter.type(Script.Script));
31
+ const { invokePromise } = useOperationInvoker();
29
32
 
30
33
  const functionToScriptMap = useMemo(
31
34
  () =>
@@ -40,13 +43,13 @@ export const FunctionsPanel = ({ space }: FunctionsPanelProps) => {
40
43
  }
41
44
  return map;
42
45
  },
43
- {} as Record<string, ScriptType>,
46
+ {} as Record<string, Script.Script>,
44
47
  ),
45
48
  [functions, scripts],
46
49
  );
47
50
 
48
51
  const getScriptName = useCallback(
49
- (func: FunctionType) => {
52
+ (func: Function.Function) => {
50
53
  const script = functionToScriptMap[func.id];
51
54
  return script?.name;
52
55
  },
@@ -54,23 +57,28 @@ export const FunctionsPanel = ({ space }: FunctionsPanelProps) => {
54
57
  );
55
58
 
56
59
  const handleGoToScript = useCallback(
57
- (func: FunctionType) => {
60
+ (func: Function.Function) => {
58
61
  const script = functionToScriptMap[func.id];
59
62
  if (script) {
60
- void dispatch(createIntent(LayoutAction.Open, { part: 'main', subject: [fullyQualifiedId(script)] }));
63
+ void invokePromise(Common.LayoutOperation.Open, { subject: [Obj.getDXN(script).toString()] });
61
64
  }
62
65
  },
63
- [functionToScriptMap, dispatch],
66
+ [functionToScriptMap, invokePromise],
67
+ );
68
+
69
+ const handleDelete = useCallback(
70
+ (func: Function.Function) => invokePromise(SpaceOperation.RemoveObjects, { objects: [func] }),
71
+ [invokePromise],
64
72
  );
65
73
 
66
74
  return (
67
75
  <div role='none' className={mx(controlItemClasses)}>
68
76
  {functions.length > 0 && (
69
- <List.Root<FunctionType> items={functions} isItem={Schema.is(FunctionType)} getId={(func) => func.id}>
77
+ <List.Root<Function.Function> items={functions} isItem={Schema.is(Function.Function)} getId={(func) => func.id}>
70
78
  {({ items }) => (
71
- <div role='list' className='flex flex-col w-full'>
79
+ <div role='list' className='flex flex-col is-full'>
72
80
  {items?.map((func) => (
73
- <List.Item<FunctionType>
81
+ <List.Item<Function.Function>
74
82
  key={func.id}
75
83
  item={func}
76
84
  classNames={mx(grid, ghostHover, 'items-center', 'pli-2', 'min-bs-[3rem]')}
@@ -84,6 +92,12 @@ export const FunctionsPanel = ({ space }: FunctionsPanelProps) => {
84
92
  {functionToScriptMap[func.id] && (
85
93
  <Button onClick={() => handleGoToScript(func)}>{t('go to function source button label')}</Button>
86
94
  )}
95
+ <IconButton
96
+ iconOnly
97
+ icon='ph--trash--regular'
98
+ label={t('delete function button label')}
99
+ onClick={() => handleDelete(func)}
100
+ />
87
101
  </List.Item>
88
102
  ))}
89
103
  </div>
@@ -0,0 +1,111 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+ import { useState } from 'react';
7
+ import React, { useCallback } from 'react';
8
+
9
+ import { Function } from '@dxos/functions';
10
+ import { getDeployedFunctions } from '@dxos/functions-runtime/edge';
11
+ import { useClient } from '@dxos/react-client';
12
+ import { Filter, Query, type Space, useQuery } from '@dxos/react-client/echo';
13
+ import { useAsyncEffect } from '@dxos/react-ui';
14
+ import { IconButton, useTranslation } from '@dxos/react-ui';
15
+ import { controlItemClasses } from '@dxos/react-ui-form';
16
+ import { List } from '@dxos/react-ui-list';
17
+ import { ghostHover, mx } from '@dxos/ui-theme';
18
+
19
+ import { meta } from '../../meta';
20
+
21
+ const grid = 'grid grid-cols-[1fr_1fr_auto] min-bs-[2.5rem]';
22
+
23
+ type FunctionsRegistryProps = {
24
+ space: Space;
25
+ };
26
+
27
+ export const FunctionsRegistry = ({ space }: FunctionsRegistryProps) => {
28
+ const client = useClient();
29
+ const [loading, setLoading] = useState(true);
30
+ const [functions, setFunctions] = useState<Function.Function[]>([]);
31
+ const { t } = useTranslation(meta.id);
32
+
33
+ const dbFunctions = useQuery(space.db, Filter.type(Function.Function));
34
+
35
+ const state = (func: Function.Function) => {
36
+ const dbFunction = dbFunctions.find((f) => f.key === func.key);
37
+ if (!dbFunction) {
38
+ return 'import';
39
+ }
40
+ if (dbFunction.version === func.version && dbFunction.updated === func.updated) {
41
+ return 'none';
42
+ }
43
+ return 'update';
44
+ };
45
+
46
+ useAsyncEffect(async () => {
47
+ setLoading(true);
48
+ const functions = await getDeployedFunctions(client, true);
49
+ setFunctions(functions);
50
+ setLoading(false);
51
+ }, []);
52
+
53
+ const hanleImportOrUpdate = useCallback(
54
+ async (func: Function.Function) => {
55
+ const functions = await space.db.query(Query.type(Function.Function, { key: func.key })).run();
56
+ const [existingFunc] = functions;
57
+ if (!existingFunc) {
58
+ space.db.add(func);
59
+ return;
60
+ }
61
+ Function.setFrom(existingFunc, func);
62
+ },
63
+ [space],
64
+ );
65
+
66
+ return (
67
+ <div role='none' className={mx(controlItemClasses)}>
68
+ {functions.length > 0 && (
69
+ <List.Root<Function.Function> items={functions} isItem={Schema.is(Function.Function)} getId={(func) => func.id}>
70
+ {({ items }) => (
71
+ <div role='list' className='flex flex-col is-full'>
72
+ {items?.map((func) => (
73
+ <List.Item<Function.Function>
74
+ key={func.id}
75
+ item={func}
76
+ classNames={mx(grid, ghostHover, 'items-center', 'pli-2', 'min-bs-[3rem]')}
77
+ >
78
+ <div className='flex flex-col truncate'>
79
+ <List.ItemTitle classNames='truncate'>{func.name}</List.ItemTitle>
80
+ <div className='text-xs text-description truncate'>{func.key}</div>
81
+ </div>
82
+ <div className='flex flex-col truncate'>
83
+ <div className='text-xs text-description truncate'>{func.version}</div>
84
+ <div className='text-xs text-description truncate'>
85
+ {func.updated ? `Uploaded ${new Date(func.updated).toLocaleString()}` : ''}
86
+ </div>
87
+ </div>
88
+
89
+ <IconButton
90
+ iconOnly
91
+ icon={state(func) === 'update' ? 'ph--arrows-clockwise--regular' : 'ph--download--regular'}
92
+ label={
93
+ state(func) === 'update' ? t('update function button label') : t('import function button label')
94
+ }
95
+ disabled={state(func) === 'none'}
96
+ onClick={() => hanleImportOrUpdate(func)}
97
+ />
98
+ </List.Item>
99
+ ))}
100
+ </div>
101
+ )}
102
+ </List.Root>
103
+ )}
104
+
105
+ {functions.length === 0 && !loading && (
106
+ <div className='text-center plb-4 text-gray-500'>{t('no functions found')}</div>
107
+ )}
108
+ {loading && <div className='text-center plb-4 text-gray-500'>{t('loading functions')}</div>}
109
+ </div>
110
+ );
111
+ };
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export { FunctionsRegistry } from './FunctionsRegistry';
@@ -2,29 +2,26 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
+ import type * as SchemaAST from 'effect/SchemaAST';
5
6
  import React, { useCallback, useMemo } from 'react';
6
7
 
7
- import { Ref, Type } from '@dxos/echo';
8
- import { type JsonPath } from '@dxos/echo-schema';
9
- import { type FunctionType } from '@dxos/functions';
10
- import { useOnTransition } from '@dxos/react-ui';
11
- import { Form, type FormInputStateProps, type QueryRefOptions, useFormValues } from '@dxos/react-ui-form';
8
+ import { type Database, Ref, Type } from '@dxos/echo';
9
+ import { type JsonPath } from '@dxos/echo/internal';
10
+ import { type Function } from '@dxos/functions';
11
+ import { useOnTransition, useTranslation } from '@dxos/react-ui';
12
+ import { Form, type FormFieldStateProps, type FormRootProps, useFormValues } from '@dxos/react-ui-form';
13
+
14
+ import { meta } from '../../meta';
12
15
 
13
16
  export type FunctionInputEditorProps = {
14
- functions: FunctionType[];
15
- onQueryRefOptions: QueryRefOptions;
16
- } & FormInputStateProps;
17
+ type: SchemaAST.AST;
18
+ functions: Function.Function[];
19
+ db?: Database.Database;
20
+ } & FormFieldStateProps;
17
21
 
18
- /**
19
- * Editor component for function input parameters.
20
- */
21
- export const FunctionInputEditor = ({
22
- functions,
23
- getValue,
24
- onValueChange,
25
- onQueryRefOptions,
26
- }: FunctionInputEditorProps) => {
27
- const selectedFunctionValue = useFormValues(['function' as JsonPath]);
22
+ export const FunctionInputEditor = ({ type, functions, db, getValue, onValueChange }: FunctionInputEditorProps) => {
23
+ const { t } = useTranslation(meta.id);
24
+ const selectedFunctionValue = useFormValues(FunctionInputEditor.displayName, ['function' as JsonPath]);
28
25
  const selectedFunctionId = useMemo(() => {
29
26
  if (Ref.isRef(selectedFunctionValue)) {
30
27
  return selectedFunctionValue.dxn.toString().split('dxn:echo:@:').at(1);
@@ -39,22 +36,27 @@ export const FunctionInputEditor = ({
39
36
  useOnTransition(
40
37
  // Clear function parameter input when the function changes.
41
38
  selectedFunctionValue,
42
- (prevValue) => prevValue !== undefined && prevValue !== selectedFunctionValue,
39
+ (prevValue) => {
40
+ if (!Ref.isRef(prevValue) || !Ref.isRef(selectedFunctionValue)) {
41
+ return false;
42
+ }
43
+
44
+ return prevValue.dxn.toString() !== selectedFunctionValue.dxn.toString();
45
+ },
43
46
  (currValue) => currValue !== undefined,
44
- () => onValueChange('object', {}),
47
+ () => onValueChange(type, {}),
45
48
  );
46
49
 
47
50
  const inputSchema = useMemo(() => selectedFunction?.inputSchema, [selectedFunction]);
48
51
  const effectSchema = useMemo(() => (inputSchema ? Type.toEffectSchema(inputSchema) : undefined), [inputSchema]);
49
52
  const propertyCount = inputSchema?.properties ? Object.keys(inputSchema.properties).length : 0;
50
-
51
53
  const values = useMemo(() => getValue() ?? {}, [getValue]);
52
54
 
53
- const handleValuesChanged = useCallback(
54
- (values: any) => {
55
- onValueChange('object', values);
55
+ const handleValuesChanged = useCallback<NonNullable<FormRootProps['onValuesChanged']>>(
56
+ (values) => {
57
+ onValueChange(type, values);
56
58
  },
57
- [onValueChange],
59
+ [type, onValueChange],
58
60
  );
59
61
 
60
62
  if (selectedFunction === undefined || effectSchema === undefined || propertyCount === 0) {
@@ -63,16 +65,12 @@ export const FunctionInputEditor = ({
63
65
 
64
66
  return (
65
67
  <>
66
- <h3 className='text-md'>Function parameters</h3>
67
- {/* TODO(ZaymonFC): Try using <FormFields /> internal component for this nesting.
68
- This would allow errors to flow up to the root context. */}
69
- <Form
70
- schema={effectSchema}
71
- values={values}
72
- onValuesChanged={handleValuesChanged}
73
- onQueryRefOptions={onQueryRefOptions}
74
- outerSpacing={false}
75
- />
68
+ <Form.Label label={t('function parameters label')} asChild />
69
+ <Form.Root schema={effectSchema} values={values} db={db} onValuesChanged={handleValuesChanged}>
70
+ <Form.FieldSet />
71
+ </Form.Root>
76
72
  </>
77
73
  );
78
74
  };
75
+
76
+ FunctionInputEditor.displayName = 'AutomationTrigger.FunctionInputEditor';