@dxos/plugin-automation 0.8.4-main.fffef41 → 0.8.4-staging.60fe92afc8

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 (407) hide show
  1. package/LICENSE +102 -5
  2. package/PLUGIN.mdl +428 -0
  3. package/README.md +1 -1
  4. package/dist/lib/neutral/AutomationArticle-GN36NUX2.mjs +17 -0
  5. package/dist/lib/neutral/AutomationCompanion-M26WR6VP.mjs +165 -0
  6. package/dist/lib/neutral/AutomationCompanion-M26WR6VP.mjs.map +7 -0
  7. package/dist/lib/neutral/AutomationPlugin.mjs +10 -0
  8. package/dist/lib/neutral/AutomationPlugin.node.mjs +1132 -0
  9. package/dist/lib/neutral/AutomationPlugin.node.mjs.map +7 -0
  10. package/dist/lib/neutral/AutomationPlugin.workerd.mjs +36 -0
  11. package/dist/lib/neutral/AutomationPlugin.workerd.mjs.map +7 -0
  12. package/dist/lib/neutral/AutomationSettings-YXUJDRQA.mjs +27 -0
  13. package/dist/lib/neutral/AutomationSettings-YXUJDRQA.mjs.map +7 -0
  14. package/dist/lib/neutral/TriggerSettings-XCHIZPOR.mjs +9 -0
  15. package/dist/lib/neutral/app-graph-builder-BTTHS4VK.mjs +102 -0
  16. package/dist/lib/neutral/app-graph-builder-BTTHS4VK.mjs.map +7 -0
  17. package/dist/lib/neutral/capabilities/index.mjs +25 -0
  18. package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
  19. package/dist/lib/neutral/capabilities/node.mjs +19 -0
  20. package/dist/lib/neutral/capabilities/node.mjs.map +7 -0
  21. package/dist/lib/neutral/chunk-24JKY6NU.mjs +21 -0
  22. package/dist/lib/neutral/chunk-24JKY6NU.mjs.map +7 -0
  23. package/dist/lib/neutral/chunk-2JP77CMN.mjs +42 -0
  24. package/dist/lib/neutral/chunk-2JP77CMN.mjs.map +7 -0
  25. package/dist/lib/neutral/chunk-DUGOIM7G.mjs +36 -0
  26. package/dist/lib/neutral/chunk-DUGOIM7G.mjs.map +7 -0
  27. package/dist/lib/neutral/chunk-FE7YFBX7.mjs +486 -0
  28. package/dist/lib/neutral/chunk-FE7YFBX7.mjs.map +7 -0
  29. package/dist/lib/neutral/chunk-GARB7S5R.mjs +157 -0
  30. package/dist/lib/neutral/chunk-GARB7S5R.mjs.map +7 -0
  31. package/dist/lib/neutral/chunk-HPUHQ3L6.mjs +64 -0
  32. package/dist/lib/neutral/chunk-HPUHQ3L6.mjs.map +7 -0
  33. package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
  34. package/dist/lib/neutral/chunk-SONGOJRB.mjs +8 -0
  35. package/dist/lib/neutral/chunk-SONGOJRB.mjs.map +7 -0
  36. package/dist/lib/neutral/components/index.mjs +48 -0
  37. package/dist/lib/neutral/components/index.mjs.map +7 -0
  38. package/dist/lib/neutral/containers/index.mjs +15 -0
  39. package/dist/lib/neutral/containers/index.mjs.map +7 -0
  40. package/dist/lib/neutral/create-automation-OE3TNXYE.mjs +41 -0
  41. package/dist/lib/neutral/create-automation-OE3TNXYE.mjs.map +7 -0
  42. package/dist/lib/neutral/create-object-MEJOWGMH.mjs +25 -0
  43. package/dist/lib/neutral/create-object-MEJOWGMH.mjs.map +7 -0
  44. package/dist/lib/neutral/create-trigger-from-template-TERHKWJM.mjs +68 -0
  45. package/dist/lib/neutral/create-trigger-from-template-TERHKWJM.mjs.map +7 -0
  46. package/dist/lib/neutral/hooks/index.mjs +47 -0
  47. package/dist/lib/neutral/hooks/index.mjs.map +7 -0
  48. package/dist/lib/neutral/index.mjs +22 -0
  49. package/dist/lib/neutral/layer-specs-G6GCH7BE.mjs +137 -0
  50. package/dist/lib/neutral/layer-specs-G6GCH7BE.mjs.map +7 -0
  51. package/dist/lib/neutral/meta.json +1 -0
  52. package/dist/lib/neutral/meta.mjs +8 -0
  53. package/dist/lib/neutral/navigation-resolver-I3L5FHJO.mjs +14 -0
  54. package/dist/lib/neutral/navigation-resolver-I3L5FHJO.mjs.map +7 -0
  55. package/dist/lib/neutral/operation-handler-YXGYH5W5.mjs +13 -0
  56. package/dist/lib/neutral/operation-handler-YXGYH5W5.mjs.map +7 -0
  57. package/dist/lib/neutral/operations/index.mjs +8 -0
  58. package/dist/lib/neutral/plugin.mjs +16 -0
  59. package/dist/lib/neutral/plugin.mjs.map +7 -0
  60. package/dist/lib/neutral/react-surface-IBRWUKPC.mjs +54 -0
  61. package/dist/lib/neutral/react-surface-IBRWUKPC.mjs.map +7 -0
  62. package/dist/lib/neutral/registry-sync-G6TKKZGK.mjs +86 -0
  63. package/dist/lib/neutral/registry-sync-G6TKKZGK.mjs.map +7 -0
  64. package/dist/lib/neutral/templates-ETXVD3VE.mjs +16 -0
  65. package/dist/lib/neutral/templates-ETXVD3VE.mjs.map +7 -0
  66. package/dist/lib/neutral/testing.mjs +8 -0
  67. package/dist/lib/neutral/translations.mjs +64 -0
  68. package/dist/lib/neutral/translations.mjs.map +7 -0
  69. package/dist/lib/neutral/trigger-runtime-controller-BOEJYGWC.mjs +77 -0
  70. package/dist/lib/neutral/trigger-runtime-controller-BOEJYGWC.mjs.map +7 -0
  71. package/dist/lib/neutral/types/index.mjs +18 -0
  72. package/dist/lib/neutral/types/index.mjs.map +7 -0
  73. package/dist/types/src/AutomationPlugin.d.ts +3 -1
  74. package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
  75. package/dist/types/src/AutomationPlugin.node.d.ts +4 -0
  76. package/dist/types/src/AutomationPlugin.node.d.ts.map +1 -0
  77. package/dist/types/src/AutomationPlugin.test.d.ts +2 -0
  78. package/dist/types/src/AutomationPlugin.test.d.ts.map +1 -0
  79. package/dist/types/src/AutomationPlugin.workerd.d.ts +4 -0
  80. package/dist/types/src/AutomationPlugin.workerd.d.ts.map +1 -0
  81. package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
  82. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  83. package/dist/types/src/capabilities/create-object.d.ts +11 -0
  84. package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
  85. package/dist/types/src/capabilities/create-object.test.d.ts +2 -0
  86. package/dist/types/src/capabilities/create-object.test.d.ts.map +1 -0
  87. package/dist/types/src/capabilities/index.d.ts +16 -5
  88. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  89. package/dist/types/src/capabilities/layer-specs.d.ts +6 -0
  90. package/dist/types/src/capabilities/layer-specs.d.ts.map +1 -0
  91. package/dist/types/src/capabilities/navigation-resolver.d.ts +6 -0
  92. package/dist/types/src/capabilities/navigation-resolver.d.ts.map +1 -0
  93. package/dist/types/src/capabilities/node.d.ts +9 -0
  94. package/dist/types/src/capabilities/node.d.ts.map +1 -0
  95. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  96. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  97. package/dist/types/src/capabilities/react-surface.d.ts +3 -2
  98. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  99. package/dist/types/src/capabilities/registry-sync.d.ts +21 -0
  100. package/dist/types/src/capabilities/registry-sync.d.ts.map +1 -0
  101. package/dist/types/src/capabilities/templates.d.ts +6 -0
  102. package/dist/types/src/capabilities/templates.d.ts.map +1 -0
  103. package/dist/types/src/capabilities/trigger-runtime-controller.d.ts +5 -0
  104. package/dist/types/src/capabilities/trigger-runtime-controller.d.ts.map +1 -0
  105. package/dist/types/src/capabilities/trigger-runtime-controller.test.d.ts +2 -0
  106. package/dist/types/src/capabilities/trigger-runtime-controller.test.d.ts.map +1 -0
  107. package/dist/types/src/commands/index.d.ts +2 -0
  108. package/dist/types/src/commands/index.d.ts.map +1 -0
  109. package/dist/types/src/commands/trigger/create/index.d.ts +25 -0
  110. package/dist/types/src/commands/trigger/create/index.d.ts.map +1 -0
  111. package/dist/types/src/commands/trigger/create/queue.d.ts +13 -0
  112. package/dist/types/src/commands/trigger/create/queue.d.ts.map +1 -0
  113. package/dist/types/src/commands/trigger/create/subscription.d.ts +15 -0
  114. package/dist/types/src/commands/trigger/create/subscription.d.ts.map +1 -0
  115. package/dist/types/src/commands/trigger/create/timer.d.ts +13 -0
  116. package/dist/types/src/commands/trigger/create/timer.d.ts.map +1 -0
  117. package/dist/types/src/commands/trigger/index.d.ts +57 -0
  118. package/dist/types/src/commands/trigger/index.d.ts.map +1 -0
  119. package/dist/types/src/commands/trigger/list.d.ts +7 -0
  120. package/dist/types/src/commands/trigger/list.d.ts.map +1 -0
  121. package/dist/types/src/commands/trigger/options.d.ts +10 -0
  122. package/dist/types/src/commands/trigger/options.d.ts.map +1 -0
  123. package/dist/types/src/commands/trigger/remove.d.ts +8 -0
  124. package/dist/types/src/commands/trigger/remove.d.ts.map +1 -0
  125. package/dist/types/src/commands/trigger/update/index.d.ts +28 -0
  126. package/dist/types/src/commands/trigger/update/index.d.ts.map +1 -0
  127. package/dist/types/src/commands/trigger/update/queue.d.ts +11 -0
  128. package/dist/types/src/commands/trigger/update/queue.d.ts.map +1 -0
  129. package/dist/types/src/commands/trigger/update/subscription.d.ts +13 -0
  130. package/dist/types/src/commands/trigger/update/subscription.d.ts.map +1 -0
  131. package/dist/types/src/commands/trigger/update/timer.d.ts +11 -0
  132. package/dist/types/src/commands/trigger/update/timer.d.ts.map +1 -0
  133. package/dist/types/src/commands/trigger/util.d.ts +85 -0
  134. package/dist/types/src/commands/trigger/util.d.ts.map +1 -0
  135. package/dist/types/src/components/CreateAutomationPanel/CreateAutomationPanel.d.ts +14 -0
  136. package/dist/types/src/components/CreateAutomationPanel/CreateAutomationPanel.d.ts.map +1 -0
  137. package/dist/types/src/components/CreateAutomationPanel/index.d.ts +2 -0
  138. package/dist/types/src/components/CreateAutomationPanel/index.d.ts.map +1 -0
  139. package/dist/types/src/components/index.d.ts +1 -7
  140. package/dist/types/src/components/index.d.ts.map +1 -1
  141. package/dist/types/src/containers/AutomationArticle/AutomationArticle.d.ts +35 -0
  142. package/dist/types/src/containers/AutomationArticle/AutomationArticle.d.ts.map +1 -0
  143. package/dist/types/src/containers/AutomationArticle/index.d.ts +3 -0
  144. package/dist/types/src/containers/AutomationArticle/index.d.ts.map +1 -0
  145. package/dist/types/src/containers/AutomationCompanion/AutomationCompanion.d.ts +13 -0
  146. package/dist/types/src/containers/AutomationCompanion/AutomationCompanion.d.ts.map +1 -0
  147. package/dist/types/src/containers/AutomationCompanion/index.d.ts +3 -0
  148. package/dist/types/src/containers/AutomationCompanion/index.d.ts.map +1 -0
  149. package/dist/types/src/containers/AutomationSettings/AutomationSettings.d.ts +10 -0
  150. package/dist/types/src/containers/AutomationSettings/AutomationSettings.d.ts.map +1 -0
  151. package/dist/types/src/containers/AutomationSettings/index.d.ts +2 -0
  152. package/dist/types/src/containers/AutomationSettings/index.d.ts.map +1 -0
  153. package/dist/types/src/containers/TriggerSettings/TriggerSettings.d.ts.map +1 -0
  154. package/dist/types/src/containers/TriggerSettings/index.d.ts +3 -0
  155. package/dist/types/src/containers/TriggerSettings/index.d.ts.map +1 -0
  156. package/dist/types/src/containers/index.d.ts +6 -0
  157. package/dist/types/src/containers/index.d.ts.map +1 -0
  158. package/dist/types/src/hooks/index.d.ts +0 -1
  159. package/dist/types/src/hooks/index.d.ts.map +1 -1
  160. package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts +5 -4
  161. package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts.map +1 -1
  162. package/dist/types/src/index.d.ts +1 -5
  163. package/dist/types/src/index.d.ts.map +1 -1
  164. package/dist/types/src/meta.d.ts +2 -2
  165. package/dist/types/src/meta.d.ts.map +1 -1
  166. package/dist/types/src/operations/create-automation.d.ts +5 -0
  167. package/dist/types/src/operations/create-automation.d.ts.map +1 -0
  168. package/dist/types/src/operations/create-trigger-from-template.d.ts +5 -0
  169. package/dist/types/src/operations/create-trigger-from-template.d.ts.map +1 -0
  170. package/dist/types/src/operations/index.d.ts +3 -0
  171. package/dist/types/src/operations/index.d.ts.map +1 -0
  172. package/dist/types/src/paths.d.ts +3 -0
  173. package/dist/types/src/paths.d.ts.map +1 -0
  174. package/dist/types/src/plugin.d.ts +4 -0
  175. package/dist/types/src/plugin.d.ts.map +1 -0
  176. package/dist/types/src/templates/index.d.ts +10 -0
  177. package/dist/types/src/templates/index.d.ts.map +1 -0
  178. package/dist/types/src/testing/test-functions.d.ts +318 -3
  179. package/dist/types/src/testing/test-functions.d.ts.map +1 -1
  180. package/dist/types/src/testing.d.ts +2 -0
  181. package/dist/types/src/testing.d.ts.map +1 -0
  182. package/dist/types/src/translations.d.ts +90 -31
  183. package/dist/types/src/translations.d.ts.map +1 -1
  184. package/dist/types/src/types/Automation.d.ts +41 -0
  185. package/dist/types/src/types/Automation.d.ts.map +1 -0
  186. package/dist/types/src/types/Automation.test.d.ts +2 -0
  187. package/dist/types/src/types/Automation.test.d.ts.map +1 -0
  188. package/dist/types/src/types/AutomationCapabilities.d.ts +42 -0
  189. package/dist/types/src/types/AutomationCapabilities.d.ts.map +1 -0
  190. package/dist/types/src/types/AutomationOperation.d.ts +31 -0
  191. package/dist/types/src/types/AutomationOperation.d.ts.map +1 -0
  192. package/dist/types/src/types/Runnable.d.ts +14 -0
  193. package/dist/types/src/types/Runnable.d.ts.map +1 -0
  194. package/dist/types/src/types/index.d.ts +4 -0
  195. package/dist/types/src/types/index.d.ts.map +1 -1
  196. package/dist/types/src/types/schema.d.ts +13 -5
  197. package/dist/types/src/types/schema.d.ts.map +1 -1
  198. package/dist/types/src/util/automations-for-object.d.ts +20 -0
  199. package/dist/types/src/util/automations-for-object.d.ts.map +1 -0
  200. package/dist/types/src/util/automations-for-object.test.d.ts +2 -0
  201. package/dist/types/src/util/automations-for-object.test.d.ts.map +1 -0
  202. package/dist/types/tsconfig.tsbuildinfo +1 -1
  203. package/package.json +136 -71
  204. package/src/AutomationPlugin.node.ts +48 -0
  205. package/src/AutomationPlugin.test.ts +27 -0
  206. package/src/AutomationPlugin.tsx +47 -35
  207. package/src/AutomationPlugin.workerd.ts +24 -0
  208. package/src/capabilities/app-graph-builder.ts +81 -78
  209. package/src/capabilities/create-object.test.ts +18 -0
  210. package/src/capabilities/create-object.ts +26 -0
  211. package/src/capabilities/index.ts +17 -7
  212. package/src/capabilities/layer-specs.ts +196 -0
  213. package/src/capabilities/navigation-resolver.ts +19 -0
  214. package/src/capabilities/node.ts +19 -0
  215. package/src/capabilities/operation-handler.ts +16 -0
  216. package/src/capabilities/react-surface.tsx +45 -46
  217. package/src/capabilities/registry-sync.ts +114 -0
  218. package/src/capabilities/templates.ts +17 -0
  219. package/src/capabilities/trigger-runtime-controller.test.ts +107 -0
  220. package/src/capabilities/trigger-runtime-controller.ts +126 -0
  221. package/src/commands/index.ts +5 -0
  222. package/src/commands/trigger/create/index.ts +14 -0
  223. package/src/commands/trigger/create/queue.ts +87 -0
  224. package/src/commands/trigger/create/subscription.ts +126 -0
  225. package/src/commands/trigger/create/timer.ts +90 -0
  226. package/src/commands/trigger/index.ts +16 -0
  227. package/src/commands/trigger/list.ts +69 -0
  228. package/src/commands/trigger/options.ts +47 -0
  229. package/src/commands/trigger/remove.ts +45 -0
  230. package/src/commands/trigger/update/index.ts +14 -0
  231. package/src/commands/trigger/update/queue.ts +191 -0
  232. package/src/commands/trigger/update/subscription.ts +279 -0
  233. package/src/commands/trigger/update/timer.ts +195 -0
  234. package/src/commands/trigger/util.ts +410 -0
  235. package/src/components/CreateAutomationPanel/CreateAutomationPanel.tsx +68 -0
  236. package/src/components/CreateAutomationPanel/index.ts +5 -0
  237. package/src/components/index.ts +1 -8
  238. package/src/containers/AutomationArticle/AutomationArticle.tsx +586 -0
  239. package/src/containers/AutomationArticle/index.ts +6 -0
  240. package/src/containers/AutomationCompanion/AutomationCompanion.tsx +183 -0
  241. package/src/containers/AutomationCompanion/index.ts +6 -0
  242. package/src/containers/AutomationSettings/AutomationSettings.tsx +34 -0
  243. package/src/containers/AutomationSettings/index.ts +5 -0
  244. package/src/containers/TriggerSettings/TriggerSettings.tsx +48 -0
  245. package/src/containers/TriggerSettings/index.ts +6 -0
  246. package/src/containers/index.ts +10 -0
  247. package/src/hooks/index.ts +1 -1
  248. package/src/hooks/useTriggerRuntimeControls.ts +38 -19
  249. package/src/index.ts +1 -6
  250. package/src/meta.ts +23 -7
  251. package/src/operations/create-automation.ts +38 -0
  252. package/src/operations/create-trigger-from-template.ts +70 -0
  253. package/src/operations/index.ts +10 -0
  254. package/src/paths.ts +13 -0
  255. package/src/plugin.ts +11 -0
  256. package/src/templates/index.ts +22 -0
  257. package/src/testing/test-functions.ts +43 -9
  258. package/src/testing.ts +7 -0
  259. package/src/translations.ts +49 -33
  260. package/src/types/Automation.test.ts +37 -0
  261. package/src/types/Automation.ts +45 -0
  262. package/src/types/AutomationCapabilities.ts +52 -0
  263. package/src/types/AutomationOperation.ts +61 -0
  264. package/src/types/Runnable.ts +14 -0
  265. package/src/types/index.ts +5 -0
  266. package/src/types/schema.ts +6 -6
  267. package/src/util/automations-for-object.test.ts +86 -0
  268. package/src/util/automations-for-object.ts +72 -0
  269. package/src/vite-env.d.ts +10 -0
  270. package/dist/lib/browser/AutomationPanel-7OECLR5N.mjs +0 -11
  271. package/dist/lib/browser/AutomationSettings-KCZISXI6.mjs +0 -68
  272. package/dist/lib/browser/AutomationSettings-KCZISXI6.mjs.map +0 -7
  273. package/dist/lib/browser/FunctionsContainer-MIWEISRR.mjs +0 -151
  274. package/dist/lib/browser/FunctionsContainer-MIWEISRR.mjs.map +0 -7
  275. package/dist/lib/browser/FunctionsPanel-CRW6SJUN.mjs +0 -10
  276. package/dist/lib/browser/app-graph-builder-W7LLC6XW.mjs +0 -81
  277. package/dist/lib/browser/app-graph-builder-W7LLC6XW.mjs.map +0 -7
  278. package/dist/lib/browser/chunk-EPEXQP45.mjs +0 -14
  279. package/dist/lib/browser/chunk-EPEXQP45.mjs.map +0 -7
  280. package/dist/lib/browser/chunk-JW7XSPYW.mjs +0 -267
  281. package/dist/lib/browser/chunk-JW7XSPYW.mjs.map +0 -7
  282. package/dist/lib/browser/chunk-LZQFZO3B.mjs +0 -17
  283. package/dist/lib/browser/chunk-LZQFZO3B.mjs.map +0 -7
  284. package/dist/lib/browser/chunk-NAPXRXTY.mjs +0 -100
  285. package/dist/lib/browser/chunk-NAPXRXTY.mjs.map +0 -7
  286. package/dist/lib/browser/chunk-QKFBHAGN.mjs +0 -184
  287. package/dist/lib/browser/chunk-QKFBHAGN.mjs.map +0 -7
  288. package/dist/lib/browser/chunk-TWWFNOIR.mjs +0 -109
  289. package/dist/lib/browser/chunk-TWWFNOIR.mjs.map +0 -7
  290. package/dist/lib/browser/chunk-XAKZ4ANY.mjs +0 -15
  291. package/dist/lib/browser/chunk-XAKZ4ANY.mjs.map +0 -7
  292. package/dist/lib/browser/chunk-YBPJCY3F.mjs +0 -38
  293. package/dist/lib/browser/chunk-YBPJCY3F.mjs.map +0 -7
  294. package/dist/lib/browser/compute-runtime-EIQTHJFZ.mjs +0 -113
  295. package/dist/lib/browser/compute-runtime-EIQTHJFZ.mjs.map +0 -7
  296. package/dist/lib/browser/hooks/index.mjs +0 -13
  297. package/dist/lib/browser/index.mjs +0 -130
  298. package/dist/lib/browser/index.mjs.map +0 -7
  299. package/dist/lib/browser/intent-resolver-5HR7M7T6.mjs +0 -77
  300. package/dist/lib/browser/intent-resolver-5HR7M7T6.mjs.map +0 -7
  301. package/dist/lib/browser/meta.json +0 -1
  302. package/dist/lib/browser/react-surface-YQW7WCFW.mjs +0 -64
  303. package/dist/lib/browser/react-surface-YQW7WCFW.mjs.map +0 -7
  304. package/dist/lib/browser/types/index.mjs +0 -8
  305. package/dist/lib/node-esm/AutomationPanel-HCVFNHGQ.mjs +0 -12
  306. package/dist/lib/node-esm/AutomationSettings-UUUPVNUJ.mjs +0 -69
  307. package/dist/lib/node-esm/AutomationSettings-UUUPVNUJ.mjs.map +0 -7
  308. package/dist/lib/node-esm/FunctionsContainer-6OB3JN5O.mjs +0 -152
  309. package/dist/lib/node-esm/FunctionsContainer-6OB3JN5O.mjs.map +0 -7
  310. package/dist/lib/node-esm/FunctionsPanel-RVVCS6VH.mjs +0 -11
  311. package/dist/lib/node-esm/app-graph-builder-SLQOO7GH.mjs +0 -82
  312. package/dist/lib/node-esm/app-graph-builder-SLQOO7GH.mjs.map +0 -7
  313. package/dist/lib/node-esm/chunk-6YRKST6M.mjs +0 -185
  314. package/dist/lib/node-esm/chunk-6YRKST6M.mjs.map +0 -7
  315. package/dist/lib/node-esm/chunk-CEVIVRTY.mjs +0 -19
  316. package/dist/lib/node-esm/chunk-CEVIVRTY.mjs.map +0 -7
  317. package/dist/lib/node-esm/chunk-CPP35BE6.mjs +0 -16
  318. package/dist/lib/node-esm/chunk-CPP35BE6.mjs.map +0 -7
  319. package/dist/lib/node-esm/chunk-ECJKIUBO.mjs +0 -39
  320. package/dist/lib/node-esm/chunk-ECJKIUBO.mjs.map +0 -7
  321. package/dist/lib/node-esm/chunk-KB7NFEYY.mjs +0 -16
  322. package/dist/lib/node-esm/chunk-KB7NFEYY.mjs.map +0 -7
  323. package/dist/lib/node-esm/chunk-PICJ2REN.mjs +0 -101
  324. package/dist/lib/node-esm/chunk-PICJ2REN.mjs.map +0 -7
  325. package/dist/lib/node-esm/chunk-RVK52XGK.mjs +0 -110
  326. package/dist/lib/node-esm/chunk-RVK52XGK.mjs.map +0 -7
  327. package/dist/lib/node-esm/chunk-W76WUTZY.mjs +0 -268
  328. package/dist/lib/node-esm/chunk-W76WUTZY.mjs.map +0 -7
  329. package/dist/lib/node-esm/compute-runtime-URROOC34.mjs +0 -114
  330. package/dist/lib/node-esm/compute-runtime-URROOC34.mjs.map +0 -7
  331. package/dist/lib/node-esm/hooks/index.mjs +0 -14
  332. package/dist/lib/node-esm/index.mjs +0 -131
  333. package/dist/lib/node-esm/index.mjs.map +0 -7
  334. package/dist/lib/node-esm/intent-resolver-KDRYB5BC.mjs +0 -78
  335. package/dist/lib/node-esm/intent-resolver-KDRYB5BC.mjs.map +0 -7
  336. package/dist/lib/node-esm/meta.json +0 -1
  337. package/dist/lib/node-esm/react-surface-NNHYNBO6.mjs +0 -65
  338. package/dist/lib/node-esm/react-surface-NNHYNBO6.mjs.map +0 -7
  339. package/dist/lib/node-esm/types/index.mjs +0 -9
  340. package/dist/types/src/capabilities/capabilities.d.ts +0 -20
  341. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  342. package/dist/types/src/capabilities/compute-runtime.d.ts +0 -5
  343. package/dist/types/src/capabilities/compute-runtime.d.ts.map +0 -1
  344. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  345. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  346. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +0 -13
  347. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +0 -1
  348. package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts +0 -50
  349. package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +0 -1
  350. package/dist/types/src/components/AutomationPanel/index.d.ts +0 -4
  351. package/dist/types/src/components/AutomationPanel/index.d.ts.map +0 -1
  352. package/dist/types/src/components/AutomationSettings.d.ts +0 -5
  353. package/dist/types/src/components/AutomationSettings.d.ts.map +0 -1
  354. package/dist/types/src/components/FunctionsContainer.d.ts +0 -7
  355. package/dist/types/src/components/FunctionsContainer.d.ts.map +0 -1
  356. package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts +0 -7
  357. package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts.map +0 -1
  358. package/dist/types/src/components/FunctionsPanel/index.d.ts +0 -4
  359. package/dist/types/src/components/FunctionsPanel/index.d.ts.map +0 -1
  360. package/dist/types/src/components/FunctionsRegistry/FunctionsRegistry.d.ts +0 -8
  361. package/dist/types/src/components/FunctionsRegistry/FunctionsRegistry.d.ts.map +0 -1
  362. package/dist/types/src/components/FunctionsRegistry/index.d.ts +0 -2
  363. package/dist/types/src/components/FunctionsRegistry/index.d.ts.map +0 -1
  364. package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts +0 -12
  365. package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts.map +0 -1
  366. package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts +0 -5
  367. package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts.map +0 -1
  368. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +0 -13
  369. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +0 -1
  370. package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +0 -51
  371. package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +0 -1
  372. package/dist/types/src/components/TriggerEditor/index.d.ts +0 -2
  373. package/dist/types/src/components/TriggerEditor/index.d.ts.map +0 -1
  374. package/dist/types/src/components/TriggerSettings.d.ts.map +0 -1
  375. package/dist/types/src/events.d.ts +0 -4
  376. package/dist/types/src/events.d.ts.map +0 -1
  377. package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts +0 -12
  378. package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts.map +0 -1
  379. package/src/capabilities/capabilities.ts +0 -41
  380. package/src/capabilities/compute-runtime.ts +0 -127
  381. package/src/capabilities/intent-resolver.ts +0 -72
  382. package/src/components/AutomationPanel/AutomationPanel.stories.tsx +0 -56
  383. package/src/components/AutomationPanel/AutomationPanel.tsx +0 -223
  384. package/src/components/AutomationPanel/index.ts +0 -9
  385. package/src/components/AutomationSettings.tsx +0 -30
  386. package/src/components/FunctionsContainer.tsx +0 -36
  387. package/src/components/FunctionsPanel/FunctionsPanel.tsx +0 -116
  388. package/src/components/FunctionsPanel/index.ts +0 -8
  389. package/src/components/FunctionsRegistry/FunctionsRegistry.tsx +0 -135
  390. package/src/components/FunctionsRegistry/index.ts +0 -5
  391. package/src/components/TriggerEditor/FunctionInputEditor.tsx +0 -84
  392. package/src/components/TriggerEditor/SpecSelector.tsx +0 -65
  393. package/src/components/TriggerEditor/TriggerEditor.stories.tsx +0 -121
  394. package/src/components/TriggerEditor/TriggerEditor.tsx +0 -127
  395. package/src/components/TriggerEditor/index.ts +0 -5
  396. package/src/components/TriggerSettings.tsx +0 -25
  397. package/src/events.ts +0 -11
  398. package/src/hooks/useComputeRuntimeCallback.ts +0 -68
  399. /package/dist/lib/{browser/AutomationPanel-7OECLR5N.mjs.map → neutral/AutomationArticle-GN36NUX2.mjs.map} +0 -0
  400. /package/dist/lib/{browser/FunctionsPanel-CRW6SJUN.mjs.map → neutral/AutomationPlugin.mjs.map} +0 -0
  401. /package/dist/lib/{browser/hooks/index.mjs.map → neutral/TriggerSettings-XCHIZPOR.mjs.map} +0 -0
  402. /package/dist/lib/{browser/types/index.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
  403. /package/dist/lib/{node-esm/hooks → neutral}/index.mjs.map +0 -0
  404. /package/dist/lib/{node-esm/AutomationPanel-HCVFNHGQ.mjs.map → neutral/meta.mjs.map} +0 -0
  405. /package/dist/lib/{node-esm/types → neutral/operations}/index.mjs.map +0 -0
  406. /package/dist/lib/{node-esm/FunctionsPanel-RVVCS6VH.mjs.map → neutral/testing.mjs.map} +0 -0
  407. /package/dist/types/src/{components → containers/TriggerSettings}/TriggerSettings.d.ts +0 -0
@@ -1,223 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
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 { useTypeOptions } from '@dxos/plugin-space';
14
- import { type Client, useClient } from '@dxos/react-client';
15
- import { type Space, getSpace, useQuery } from '@dxos/react-client/echo';
16
- import { Clipboard, IconButton, Input, Separator, type ThemedClassName, useTranslation } from '@dxos/react-ui';
17
- import { ControlItem, controlItemClasses } from '@dxos/react-ui-form';
18
- import { List } from '@dxos/react-ui-list';
19
- import { ghostHover, mx } from '@dxos/react-ui-theme';
20
- import { View } from '@dxos/schema';
21
- import { Project } from '@dxos/types';
22
-
23
- import { meta } from '../../meta';
24
- import { TriggerEditor, type TriggerEditorProps } from '../TriggerEditor';
25
-
26
- const grid = 'grid grid-cols-[40px_1fr_32px] min-bs-[2.5rem]';
27
-
28
- export type AutomationPanelProps = ThemedClassName<{
29
- space: Space;
30
- object?: Obj.Any;
31
- initialTrigger?: Trigger.Trigger;
32
- onDone?: () => void;
33
- }>;
34
-
35
- // TODO(burdon): Factor out common layout with ViewEditor.
36
- export const AutomationPanel = ({ classNames, space, object, initialTrigger, onDone }: AutomationPanelProps) => {
37
- const { t } = useTranslation(meta.id);
38
- const client = useClient();
39
- const functions = useQuery(space, Filter.type(Function.Function));
40
- const triggers = useQuery(space, Filter.type(Trigger.Trigger));
41
- const filteredTriggers = useMemo(() => {
42
- return object ? triggers.filter(triggerMatch(object)) : triggers;
43
- }, [object, triggers]);
44
- const tags = useQuery(space, Filter.type(Tag.Tag));
45
- const types = useTypeOptions({ space, annotation: ['dynamic', 'limited-static', 'object-form'] });
46
-
47
- const [trigger, setTrigger] = useState<Trigger.Trigger | undefined>(initialTrigger);
48
- const [selected, setSelected] = useState<Trigger.Trigger>();
49
-
50
- const handleSelect = (trigger: Trigger.Trigger) => {
51
- setTrigger(trigger);
52
- setSelected(trigger);
53
- };
54
-
55
- const handleAdd = () => {
56
- setTrigger(Trigger.make({}));
57
- setSelected(undefined);
58
- };
59
-
60
- const handleDelete = (trigger: Trigger.Trigger) => {
61
- space.db.remove(trigger);
62
- setTrigger(undefined);
63
- setSelected(undefined);
64
- };
65
-
66
- const handleSave: TriggerEditorProps['onSave'] = (trigger) => {
67
- if (selected) {
68
- Object.assign(selected, trigger);
69
- } else {
70
- space.db.add(Trigger.make(trigger));
71
- }
72
-
73
- setTrigger(undefined);
74
- setSelected(undefined);
75
- onDone?.();
76
- };
77
-
78
- const handleCancel: TriggerEditorProps['onCancel'] = () => {
79
- setTrigger(undefined);
80
- onDone?.();
81
- };
82
-
83
- if (trigger) {
84
- return (
85
- <ControlItem title={t('trigger editor title')}>
86
- <TriggerEditor
87
- space={space}
88
- trigger={trigger}
89
- readonlySpec={Boolean(object)}
90
- tags={tags}
91
- types={types}
92
- onSave={handleSave}
93
- onCancel={handleCancel}
94
- />
95
- </ControlItem>
96
- );
97
- }
98
-
99
- return (
100
- <div className={mx(controlItemClasses, classNames)}>
101
- {filteredTriggers.length > 0 && (
102
- <List.Root<Trigger.Trigger>
103
- items={filteredTriggers}
104
- isItem={Schema.is(Trigger.Trigger)}
105
- getId={(field) => field.id}
106
- >
107
- {({ items: filteredTriggers }) => (
108
- <div role='list' className='flex flex-col is-full'>
109
- {filteredTriggers?.map((trigger) => {
110
- const copyAction = getCopyAction(client, trigger);
111
- return (
112
- <List.Item<Trigger.Trigger>
113
- key={trigger.id}
114
- item={trigger}
115
- classNames={mx(grid, ghostHover, 'items-center', 'pli-2')}
116
- >
117
- <Input.Root>
118
- <Input.Switch
119
- checked={trigger.enabled}
120
- onCheckedChange={(checked) => (trigger.enabled = checked)}
121
- />
122
- </Input.Root>
123
-
124
- <div className={'flex'}>
125
- <List.ItemTitle
126
- classNames='pli-1 cursor-pointer is-0 shrink truncate'
127
- onClick={() => handleSelect(trigger)}
128
- >
129
- {getFunctionName(functions, trigger) ?? '∅'}
130
- </List.ItemTitle>
131
-
132
- {/* TODO: a better way to expose copy action */}
133
- {copyAction && (
134
- <Clipboard.IconButton
135
- label={t(copyAction.translationKey)}
136
- value={copyAction.contentProvider()}
137
- />
138
- )}
139
- </div>
140
-
141
- <List.ItemDeleteButton onClick={() => handleDelete(trigger)} />
142
- </List.Item>
143
- );
144
- })}
145
- </div>
146
- )}
147
- </List.Root>
148
- )}
149
- {filteredTriggers.length > 0 && <Separator classNames='mlb-4' />}
150
- <IconButton icon='ph--plus--regular' label={t('new trigger label')} onClick={handleAdd} />
151
- </div>
152
- );
153
- };
154
-
155
- const getCopyAction = (client: Client, trigger: Trigger.Trigger | undefined) => {
156
- if (trigger?.spec?.kind === 'email') {
157
- return { translationKey: 'trigger copy email', contentProvider: () => `${getSpace(trigger)!.id}@dxos.network` };
158
- }
159
-
160
- if (trigger?.spec?.kind === 'webhook') {
161
- return { translationKey: 'trigger copy url', contentProvider: () => getWebhookUrl(client, trigger) };
162
- }
163
-
164
- return undefined;
165
- };
166
-
167
- const getWebhookUrl = (client: Client, trigger: Trigger.Trigger) => {
168
- const spaceId = getSpace(trigger)!.id;
169
- const edgeUrl = new URL(client.config.values.runtime!.services!.edge!.url!);
170
- const isSecure = edgeUrl.protocol.startsWith('https') || edgeUrl.protocol.startsWith('wss');
171
- edgeUrl.protocol = isSecure ? 'https' : 'http';
172
- return new URL(`/webhook/${spaceId}:${trigger.id}`, edgeUrl).toString();
173
- };
174
-
175
- const getFunctionName = (functions: Function.Function[], trigger: Trigger.Trigger) => {
176
- // TODO(wittjosiah): Truncation should be done in the UI.
177
- // Warning that the List component is currently a can of worms.
178
- const shortId = trigger.function && `${trigger.function.dxn.toString().slice(0, 16)}…`;
179
- const functionObject = functions.find((fn) => fn === trigger.function?.target);
180
- return functionObject?.name ?? shortId;
181
- };
182
-
183
- const scriptMatch = (script: Script.Script) => (trigger: Trigger.Trigger) => {
184
- const fn = trigger.function?.target;
185
- if (!Obj.instanceOf(Function.Function, fn)) {
186
- return false;
187
- }
188
-
189
- return fn.source?.target === script;
190
- };
191
-
192
- const projectMatch = (project: Project.Project) => {
193
- const viewQueries = EFn.pipe(
194
- project.collections,
195
- Array.map((collection) => collection.target),
196
- Array.filter(Schema.is(View.View)),
197
- Array.map((view) => Obj.getSnapshot(view).query.ast),
198
- Array.map((ast) => JSON.stringify(ast)),
199
- );
200
-
201
- return (trigger: Trigger.Trigger) => {
202
- const spec = Obj.getSnapshot(trigger).spec;
203
- if (spec?.kind !== 'subscription') {
204
- return false;
205
- }
206
-
207
- // TODO(wittjosiah): Implement better way of comparing query ASTs.
208
- return viewQueries.some((query) => JSON.stringify(spec.query) === query);
209
- };
210
- };
211
-
212
- const triggerMatch = Match.type<Obj.Any>().pipe(
213
- Match.withReturnType<(trigger: Trigger.Trigger) => boolean>(),
214
- Match.when(
215
- (obj) => Obj.instanceOf(Script.Script, obj),
216
- (obj) => scriptMatch(obj),
217
- ),
218
- Match.when(
219
- (obj) => Obj.instanceOf(Project.Project, obj),
220
- (obj) => projectMatch(obj),
221
- ),
222
- Match.orElse((_obj) => () => true),
223
- );
@@ -1,9 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { AutomationPanel } from './AutomationPanel';
6
-
7
- export * from './AutomationPanel';
8
-
9
- export default AutomationPanel;
@@ -1,30 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- import { useTranslation } from '@dxos/react-ui';
8
- import { ControlPage, ControlSection } from '@dxos/react-ui-form';
9
-
10
- import { meta } from '../meta';
11
-
12
- import { AutomationPanel, type AutomationPanelProps } from './AutomationPanel';
13
- import { TriggersSettings } from './TriggerSettings';
14
-
15
- export const AutomationSettings = (props: AutomationPanelProps) => {
16
- const { t } = useTranslation(meta.id);
17
- return (
18
- <ControlPage>
19
- <ControlSection
20
- title={t('automation verbose label', { ns: meta.id })}
21
- description={t('automation description', { ns: meta.id })}
22
- >
23
- <AutomationPanel {...props} />
24
- <TriggersSettings space={props.space} />
25
- </ControlSection>
26
- </ControlPage>
27
- );
28
- };
29
-
30
- export default AutomationSettings;
@@ -1,36 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- import { type Space } from '@dxos/react-client/echo';
8
- import { useTranslation } from '@dxos/react-ui';
9
- import { ControlPage, ControlSection } from '@dxos/react-ui-form';
10
-
11
- import { meta } from '../meta';
12
-
13
- import { FunctionsPanel } from './FunctionsPanel';
14
- import { FunctionsRegistry } from './FunctionsRegistry';
15
-
16
- export const FunctionsContainer = ({ space }: { space: Space }) => {
17
- const { t } = useTranslation(meta.id);
18
- return (
19
- <ControlPage>
20
- <ControlSection
21
- title={t('functions verbose label', { ns: meta.id })}
22
- description={t('functions description', { ns: meta.id })}
23
- >
24
- <FunctionsPanel space={space} />
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>
32
- </ControlPage>
33
- );
34
- };
35
-
36
- export default FunctionsContainer;
@@ -1,116 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import * as Schema from 'effect/Schema';
6
- import React, { useCallback, useMemo } from 'react';
7
-
8
- import { LayoutAction, createIntent } from '@dxos/app-framework';
9
- import { useIntentDispatcher } from '@dxos/app-framework/react';
10
- import { Obj } from '@dxos/echo';
11
- import { Function, Script } from '@dxos/functions';
12
- import { SpaceAction } 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';
15
- import { controlItemClasses } from '@dxos/react-ui-form';
16
- import { List } from '@dxos/react-ui-list';
17
- import { ghostHover, mx } from '@dxos/react-ui-theme';
18
-
19
- import { meta } from '../../meta';
20
-
21
- const grid = 'grid grid-cols-[1fr_auto] min-bs-[2.5rem]';
22
-
23
- export type FunctionsPanelProps = {
24
- space: Space;
25
- };
26
-
27
- export const FunctionsPanel = ({ space }: FunctionsPanelProps) => {
28
- const { t } = useTranslation(meta.id);
29
- const functions = useQuery(space, Filter.type(Function.Function));
30
- const scripts = useQuery(space, Filter.type(Script.Script));
31
- const { dispatchPromise: dispatch } = useIntentDispatcher();
32
-
33
- const functionToScriptMap = useMemo(
34
- () =>
35
- functions.reduce(
36
- (map, func) => {
37
- const scriptId = func.source?.target?.id;
38
- if (scriptId) {
39
- const script = scripts.find((s) => s.id === scriptId);
40
- if (script) {
41
- map[func.id] = script;
42
- }
43
- }
44
- return map;
45
- },
46
- {} as Record<string, Script.Script>,
47
- ),
48
- [functions, scripts],
49
- );
50
-
51
- const getScriptName = useCallback(
52
- (func: Function.Function) => {
53
- const script = functionToScriptMap[func.id];
54
- return script?.name;
55
- },
56
- [functionToScriptMap],
57
- );
58
-
59
- const handleGoToScript = useCallback(
60
- (func: Function.Function) => {
61
- const script = functionToScriptMap[func.id];
62
- if (script) {
63
- void dispatch(
64
- createIntent(LayoutAction.Open, {
65
- part: 'main',
66
- subject: [Obj.getDXN(script).toString()],
67
- }),
68
- );
69
- }
70
- },
71
- [functionToScriptMap, dispatch],
72
- );
73
-
74
- const handleDelete = useCallback(
75
- (func: Function.Function) => dispatch(createIntent(SpaceAction.RemoveObjects, { objects: [func] })),
76
- [dispatch],
77
- );
78
-
79
- return (
80
- <div role='none' className={mx(controlItemClasses)}>
81
- {functions.length > 0 && (
82
- <List.Root<Function.Function> items={functions} isItem={Schema.is(Function.Function)} getId={(func) => func.id}>
83
- {({ items }) => (
84
- <div role='list' className='flex flex-col is-full'>
85
- {items?.map((func) => (
86
- <List.Item<Function.Function>
87
- key={func.id}
88
- item={func}
89
- classNames={mx(grid, ghostHover, 'items-center', 'pli-2', 'min-bs-[3rem]')}
90
- >
91
- <div className='flex flex-col truncate'>
92
- <List.ItemTitle classNames='truncate'>{func.name}</List.ItemTitle>
93
- {getScriptName(func) && (
94
- <div className='text-xs text-description truncate'>{getScriptName(func)}</div>
95
- )}
96
- </div>
97
- {functionToScriptMap[func.id] && (
98
- <Button onClick={() => handleGoToScript(func)}>{t('go to function source button label')}</Button>
99
- )}
100
- <IconButton
101
- iconOnly
102
- icon='ph--trash--regular'
103
- label={t('delete function button label')}
104
- onClick={() => handleDelete(func)}
105
- />
106
- </List.Item>
107
- ))}
108
- </div>
109
- )}
110
- </List.Root>
111
- )}
112
-
113
- {functions.length === 0 && <div className='text-center plb-4 text-gray-500'>{t('no functions found')}</div>}
114
- </div>
115
- );
116
- };
@@ -1,8 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import { FunctionsPanel } from './FunctionsPanel';
6
-
7
- export * from './FunctionsPanel';
8
- export default FunctionsPanel;
@@ -1,135 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import * as Array from 'effect/Array';
6
- import * as EffectFunction from 'effect/Function';
7
- import * as Order from 'effect/Order';
8
- import * as Schema from 'effect/Schema';
9
- import { useState } from 'react';
10
- import React, { useCallback } from 'react';
11
-
12
- import { Obj } from '@dxos/echo';
13
- import { Function } from '@dxos/functions';
14
- import { getDeployedFunctions } from '@dxos/functions-runtime/edge';
15
- import { useClient } from '@dxos/react-client';
16
- import { Filter, Query, type Space, useQuery } from '@dxos/react-client/echo';
17
- import { useAsyncEffect } from '@dxos/react-ui';
18
- import { IconButton, useTranslation } from '@dxos/react-ui';
19
- import { controlItemClasses } from '@dxos/react-ui-form';
20
- import { List } from '@dxos/react-ui-list';
21
- import { ghostHover, mx } from '@dxos/react-ui-theme';
22
-
23
- import { meta } from '../../meta';
24
-
25
- const grid = 'grid grid-cols-[1fr_1fr_auto] min-bs-[2.5rem]';
26
-
27
- type FunctionsRegistryProps = {
28
- space: Space;
29
- };
30
-
31
- export const FunctionsRegistry = ({ space }: FunctionsRegistryProps) => {
32
- const client = useClient();
33
- const [loading, setLoading] = useState(true);
34
- const [functions, setFunctions] = useState<Function.Function[]>([]);
35
- const { t } = useTranslation(meta.id);
36
-
37
- const dbFunctions = useQuery(space, Filter.type(Function.Function));
38
-
39
- const state = (func: Function.Function) => {
40
- const dbFunction = dbFunctions.find((f) => f.key === func.key);
41
- if (!dbFunction) {
42
- return 'import';
43
- }
44
- if (dbFunction.version === func.version && dbFunction.updated === func.updated) {
45
- return 'none';
46
- }
47
- return 'update';
48
- };
49
-
50
- useAsyncEffect(async () => {
51
- setLoading(true);
52
- const functions = await getDeployedFunctions(client);
53
- setFunctions(functions);
54
- setLoading(false);
55
- }, []);
56
-
57
- const dedupedFunctions = EffectFunction.pipe(
58
- functions,
59
- Array.filter((_) => _.key !== undefined),
60
- Array.sort(Order.reverse(Order.mapInput(Order.string, (_: Function.Function) => _.updated ?? ''))),
61
- Array.dedupeWith((self, that) => self.key === that.key),
62
- Array.sort(Order.mapInput(Order.string, (_: Function.Function) => _.key ?? '')),
63
- );
64
-
65
- const hanleImportOrUpdate = useCallback(
66
- async (func: Function.Function) => {
67
- const {
68
- objects: [existingFunc],
69
- } = await space.db.query(Query.type(Function.Function, { key: func.key })).run();
70
- if (!existingFunc) {
71
- space.db.add(func);
72
- return;
73
- }
74
- existingFunc.version = func.version;
75
- existingFunc.updated = func.updated;
76
- existingFunc.name = func.name;
77
- existingFunc.description = func.description;
78
- // TODO(dmaretskyi): A workaround for an ECHO bug.
79
- existingFunc.inputSchema = JSON.parse(JSON.stringify(func.inputSchema));
80
- existingFunc.outputSchema = JSON.parse(JSON.stringify(func.outputSchema));
81
- Obj.getMeta(existingFunc).keys = JSON.parse(JSON.stringify(Obj.getMeta(func).keys));
82
- },
83
- [space],
84
- );
85
-
86
- return (
87
- <div role='none' className={mx(controlItemClasses)}>
88
- {dedupedFunctions.length > 0 && (
89
- <List.Root<Function.Function>
90
- items={dedupedFunctions}
91
- isItem={Schema.is(Function.Function)}
92
- getId={(func) => func.id}
93
- >
94
- {({ items }) => (
95
- <div role='list' className='flex flex-col is-full'>
96
- {items?.map((func) => (
97
- <List.Item<Function.Function>
98
- key={func.id}
99
- item={func}
100
- classNames={mx(grid, ghostHover, 'items-center', 'pli-2', 'min-bs-[3rem]')}
101
- >
102
- <div className='flex flex-col truncate'>
103
- <List.ItemTitle classNames='truncate'>{func.name}</List.ItemTitle>
104
- <div className='text-xs text-description truncate'>{func.key}</div>
105
- </div>
106
- <div className='flex flex-col truncate'>
107
- <div className='text-xs text-description truncate'>{func.version}</div>
108
- <div className='text-xs text-description truncate'>
109
- {func.updated ? `Uploaded ${new Date(func.updated).toLocaleString()}` : ''}
110
- </div>
111
- </div>
112
-
113
- <IconButton
114
- iconOnly
115
- icon={state(func) === 'update' ? 'ph--arrows-clockwise--regular' : 'ph--download--regular'}
116
- label={
117
- state(func) === 'update' ? t('update function button label') : t('import function button label')
118
- }
119
- disabled={state(func) === 'none'}
120
- onClick={() => hanleImportOrUpdate(func)}
121
- />
122
- </List.Item>
123
- ))}
124
- </div>
125
- )}
126
- </List.Root>
127
- )}
128
-
129
- {dedupedFunctions.length === 0 && !loading && (
130
- <div className='text-center plb-4 text-gray-500'>{t('no functions found')}</div>
131
- )}
132
- {loading && <div className='text-center plb-4 text-gray-500'>{t('loading functions')}</div>}
133
- </div>
134
- );
135
- };
@@ -1,5 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- export { FunctionsRegistry } from './FunctionsRegistry';
@@ -1,84 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React, { useCallback, useMemo } from 'react';
6
-
7
- import { Ref, Type } from '@dxos/echo';
8
- import { type JsonPath } from '@dxos/echo/internal';
9
- import { type Function } from '@dxos/functions';
10
- import { useOnTransition } from '@dxos/react-ui';
11
- import { Form, type FormInputStateProps, type QueryRefOptions, useFormValues } from '@dxos/react-ui-form';
12
-
13
- export type FunctionInputEditorProps = {
14
- functions: Function.Function[];
15
- onQueryRefOptions: QueryRefOptions;
16
- } & FormInputStateProps;
17
-
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]);
28
- const selectedFunctionId = useMemo(() => {
29
- if (Ref.isRef(selectedFunctionValue)) {
30
- return selectedFunctionValue.dxn.toString().split('dxn:echo:@:').at(1);
31
- }
32
- }, [selectedFunctionValue]);
33
-
34
- const selectedFunction = useMemo(
35
- () => functions.find((fn) => fn.id === selectedFunctionId),
36
- [functions, selectedFunctionId],
37
- );
38
-
39
- useOnTransition(
40
- // Clear function parameter input when the function changes.
41
- selectedFunctionValue,
42
- (prevValue) => {
43
- if (!Ref.isRef(prevValue) || !Ref.isRef(selectedFunctionValue)) {
44
- return false;
45
- }
46
-
47
- return prevValue.dxn.toString() !== selectedFunctionValue.dxn.toString();
48
- },
49
- (currValue) => currValue !== undefined,
50
- () => onValueChange('object', {}),
51
- );
52
-
53
- const inputSchema = useMemo(() => selectedFunction?.inputSchema, [selectedFunction]);
54
- const effectSchema = useMemo(() => (inputSchema ? Type.toEffectSchema(inputSchema) : undefined), [inputSchema]);
55
- const propertyCount = inputSchema?.properties ? Object.keys(inputSchema.properties).length : 0;
56
-
57
- const values = useMemo(() => getValue() ?? {}, [getValue]);
58
-
59
- const handleValuesChanged = useCallback(
60
- (values: any) => {
61
- onValueChange('object', values);
62
- },
63
- [onValueChange],
64
- );
65
-
66
- if (selectedFunction === undefined || effectSchema === undefined || propertyCount === 0) {
67
- return null;
68
- }
69
-
70
- return (
71
- <>
72
- <h3 className='text-md'>Function parameters</h3>
73
- {/* TODO(ZaymonFC): Try using <FormFields /> internal component for this nesting.
74
- This would allow errors to flow up to the root context. */}
75
- <Form
76
- schema={effectSchema}
77
- values={values}
78
- onValuesChanged={handleValuesChanged}
79
- onQueryRefOptions={onQueryRefOptions}
80
- outerSpacing={false}
81
- />
82
- </>
83
- );
84
- };