@dxos/plugin-automation 0.8.4-main.e8ec1fe → 0.8.4-main.effb148878

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 (346) hide show
  1. package/LICENSE +102 -5
  2. package/README.md +1 -1
  3. package/dist/lib/neutral/AutomationPanel-OS3ZWYJK.mjs +12 -0
  4. package/dist/lib/neutral/AutomationPlugin.mjs +10 -0
  5. package/dist/lib/neutral/AutomationPlugin.node.mjs +1118 -0
  6. package/dist/lib/neutral/AutomationPlugin.node.mjs.map +7 -0
  7. package/dist/lib/neutral/AutomationPlugin.workerd.mjs +23 -0
  8. package/dist/lib/neutral/AutomationPlugin.workerd.mjs.map +7 -0
  9. package/dist/lib/neutral/AutomationSettings-CAFY3J7H.mjs +32 -0
  10. package/dist/lib/neutral/AutomationSettings-CAFY3J7H.mjs.map +7 -0
  11. package/dist/lib/neutral/FunctionsContainer-V5AM45ZI.mjs +38 -0
  12. package/dist/lib/neutral/FunctionsContainer-V5AM45ZI.mjs.map +7 -0
  13. package/dist/lib/neutral/FunctionsPanel-L32Z67B7.mjs +97 -0
  14. package/dist/lib/neutral/FunctionsPanel-L32Z67B7.mjs.map +7 -0
  15. package/dist/lib/neutral/FunctionsRegistry-RTCY3LXE.mjs +95 -0
  16. package/dist/lib/neutral/FunctionsRegistry-RTCY3LXE.mjs.map +7 -0
  17. package/dist/lib/neutral/TriggerSettings-XCHIZPOR.mjs +9 -0
  18. package/dist/lib/neutral/app-graph-builder-4QOUKY5L.mjs +75 -0
  19. package/dist/lib/neutral/app-graph-builder-4QOUKY5L.mjs.map +7 -0
  20. package/dist/lib/neutral/capabilities/index.mjs +17 -0
  21. package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
  22. package/dist/lib/neutral/capabilities/node.mjs +15 -0
  23. package/dist/lib/neutral/capabilities/node.mjs.map +7 -0
  24. package/dist/lib/neutral/chunk-2H6X4VQY.mjs +435 -0
  25. package/dist/lib/neutral/chunk-2H6X4VQY.mjs.map +7 -0
  26. package/dist/lib/neutral/chunk-2JP77CMN.mjs +42 -0
  27. package/dist/lib/neutral/chunk-2JP77CMN.mjs.map +7 -0
  28. package/dist/lib/neutral/chunk-33VXVTV4.mjs +38 -0
  29. package/dist/lib/neutral/chunk-33VXVTV4.mjs.map +7 -0
  30. package/dist/lib/neutral/chunk-ARUHHM4Q.mjs +12 -0
  31. package/dist/lib/neutral/chunk-ARUHHM4Q.mjs.map +7 -0
  32. package/dist/lib/neutral/chunk-CMM3AFHR.mjs +111 -0
  33. package/dist/lib/neutral/chunk-CMM3AFHR.mjs.map +7 -0
  34. package/dist/lib/neutral/chunk-EBSOLOP6.mjs +8 -0
  35. package/dist/lib/neutral/chunk-EBSOLOP6.mjs.map +7 -0
  36. package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
  37. package/dist/lib/neutral/chunk-KV7RZLFS.mjs +344 -0
  38. package/dist/lib/neutral/chunk-KV7RZLFS.mjs.map +7 -0
  39. package/dist/lib/neutral/chunk-QLBA6Y46.mjs +39 -0
  40. package/dist/lib/neutral/chunk-QLBA6Y46.mjs.map +7 -0
  41. package/dist/lib/neutral/chunk-XC5EPVE3.mjs +76 -0
  42. package/dist/lib/neutral/chunk-XC5EPVE3.mjs.map +7 -0
  43. package/dist/lib/neutral/components/index.mjs +16 -0
  44. package/dist/lib/neutral/containers/index.mjs +13 -0
  45. package/dist/lib/neutral/containers/index.mjs.map +7 -0
  46. package/dist/lib/neutral/create-trigger-from-template-IOQZDDSH.mjs +68 -0
  47. package/dist/lib/neutral/create-trigger-from-template-IOQZDDSH.mjs.map +7 -0
  48. package/dist/lib/neutral/hooks/index.mjs +10 -0
  49. package/dist/lib/neutral/index.mjs +16 -0
  50. package/dist/lib/neutral/layer-specs-B22CIT3U.mjs +160 -0
  51. package/dist/lib/neutral/layer-specs-B22CIT3U.mjs.map +7 -0
  52. package/dist/lib/neutral/meta.json +1 -0
  53. package/dist/lib/neutral/meta.mjs +8 -0
  54. package/dist/lib/neutral/operation-handler-YXGYH5W5.mjs +13 -0
  55. package/dist/lib/neutral/operation-handler-YXGYH5W5.mjs.map +7 -0
  56. package/dist/lib/neutral/operations/index.mjs +8 -0
  57. package/dist/lib/neutral/operations/index.mjs.map +7 -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-3OGMAMKV.mjs +57 -0
  61. package/dist/lib/neutral/react-surface-3OGMAMKV.mjs.map +7 -0
  62. package/dist/lib/neutral/testing.mjs +8 -0
  63. package/dist/lib/neutral/testing.mjs.map +7 -0
  64. package/dist/lib/neutral/translations.mjs +60 -0
  65. package/dist/lib/neutral/translations.mjs.map +7 -0
  66. package/dist/lib/neutral/trigger-runtime-controller-BOEJYGWC.mjs +77 -0
  67. package/dist/lib/neutral/trigger-runtime-controller-BOEJYGWC.mjs.map +7 -0
  68. package/dist/lib/neutral/types/index.mjs +12 -0
  69. package/dist/lib/neutral/types/index.mjs.map +7 -0
  70. package/dist/types/src/AutomationPlugin.d.ts +3 -1
  71. package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
  72. package/dist/types/src/AutomationPlugin.node.d.ts +4 -0
  73. package/dist/types/src/AutomationPlugin.node.d.ts.map +1 -0
  74. package/dist/types/src/AutomationPlugin.test.d.ts +2 -0
  75. package/dist/types/src/AutomationPlugin.test.d.ts.map +1 -0
  76. package/dist/types/src/AutomationPlugin.workerd.d.ts +4 -0
  77. package/dist/types/src/AutomationPlugin.workerd.d.ts.map +1 -0
  78. package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
  79. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  80. package/dist/types/src/capabilities/index.d.ts +7 -5
  81. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  82. package/dist/types/src/capabilities/layer-specs.d.ts +5 -0
  83. package/dist/types/src/capabilities/layer-specs.d.ts.map +1 -0
  84. package/dist/types/src/capabilities/node.d.ts +7 -0
  85. package/dist/types/src/capabilities/node.d.ts.map +1 -0
  86. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  87. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  88. package/dist/types/src/capabilities/react-surface.d.ts +3 -2
  89. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  90. package/dist/types/src/capabilities/trigger-runtime-controller.d.ts +5 -0
  91. package/dist/types/src/capabilities/trigger-runtime-controller.d.ts.map +1 -0
  92. package/dist/types/src/capabilities/trigger-runtime-controller.test.d.ts +2 -0
  93. package/dist/types/src/capabilities/trigger-runtime-controller.test.d.ts.map +1 -0
  94. package/dist/types/src/commands/index.d.ts +2 -0
  95. package/dist/types/src/commands/index.d.ts.map +1 -0
  96. package/dist/types/src/commands/trigger/create/index.d.ts +25 -0
  97. package/dist/types/src/commands/trigger/create/index.d.ts.map +1 -0
  98. package/dist/types/src/commands/trigger/create/queue.d.ts +13 -0
  99. package/dist/types/src/commands/trigger/create/queue.d.ts.map +1 -0
  100. package/dist/types/src/commands/trigger/create/subscription.d.ts +15 -0
  101. package/dist/types/src/commands/trigger/create/subscription.d.ts.map +1 -0
  102. package/dist/types/src/commands/trigger/create/timer.d.ts +13 -0
  103. package/dist/types/src/commands/trigger/create/timer.d.ts.map +1 -0
  104. package/dist/types/src/commands/trigger/index.d.ts +57 -0
  105. package/dist/types/src/commands/trigger/index.d.ts.map +1 -0
  106. package/dist/types/src/commands/trigger/list.d.ts +7 -0
  107. package/dist/types/src/commands/trigger/list.d.ts.map +1 -0
  108. package/dist/types/src/commands/trigger/options.d.ts +10 -0
  109. package/dist/types/src/commands/trigger/options.d.ts.map +1 -0
  110. package/dist/types/src/commands/trigger/remove.d.ts +8 -0
  111. package/dist/types/src/commands/trigger/remove.d.ts.map +1 -0
  112. package/dist/types/src/commands/trigger/update/index.d.ts +28 -0
  113. package/dist/types/src/commands/trigger/update/index.d.ts.map +1 -0
  114. package/dist/types/src/commands/trigger/update/queue.d.ts +11 -0
  115. package/dist/types/src/commands/trigger/update/queue.d.ts.map +1 -0
  116. package/dist/types/src/commands/trigger/update/subscription.d.ts +13 -0
  117. package/dist/types/src/commands/trigger/update/subscription.d.ts.map +1 -0
  118. package/dist/types/src/commands/trigger/update/timer.d.ts +11 -0
  119. package/dist/types/src/commands/trigger/update/timer.d.ts.map +1 -0
  120. package/dist/types/src/commands/trigger/util.d.ts +85 -0
  121. package/dist/types/src/commands/trigger/util.d.ts.map +1 -0
  122. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +5 -6
  123. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
  124. package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts +45 -30
  125. package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
  126. package/dist/types/src/components/AutomationPanel/TriggerEdgeMetadata.d.ts +18 -0
  127. package/dist/types/src/components/AutomationPanel/TriggerEdgeMetadata.d.ts.map +1 -0
  128. package/dist/types/src/components/AutomationPanel/index.d.ts.map +1 -1
  129. package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts.map +1 -1
  130. package/dist/types/src/components/FunctionsPanel/index.d.ts.map +1 -1
  131. package/dist/types/src/components/FunctionsRegistry/FunctionsRegistry.d.ts.map +1 -1
  132. package/dist/types/src/components/FunctionsRegistry/index.d.ts +3 -1
  133. package/dist/types/src/components/FunctionsRegistry/index.d.ts.map +1 -1
  134. package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts +12 -9
  135. package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts.map +1 -1
  136. package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts +6 -3
  137. package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts.map +1 -1
  138. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +8 -7
  139. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
  140. package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +118 -32
  141. package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
  142. package/dist/types/src/components/index.d.ts +3 -4
  143. package/dist/types/src/components/index.d.ts.map +1 -1
  144. package/dist/types/src/containers/AutomationSettings/AutomationSettings.d.ts +6 -0
  145. package/dist/types/src/containers/AutomationSettings/AutomationSettings.d.ts.map +1 -0
  146. package/dist/types/src/containers/AutomationSettings/index.d.ts +2 -0
  147. package/dist/types/src/containers/AutomationSettings/index.d.ts.map +1 -0
  148. package/dist/types/src/containers/FunctionsContainer/FunctionsContainer.d.ts +4 -0
  149. package/dist/types/src/containers/FunctionsContainer/FunctionsContainer.d.ts.map +1 -0
  150. package/dist/types/src/containers/FunctionsContainer/index.d.ts +2 -0
  151. package/dist/types/src/containers/FunctionsContainer/index.d.ts.map +1 -0
  152. package/dist/types/src/containers/TriggerSettings/TriggerSettings.d.ts.map +1 -0
  153. package/dist/types/src/containers/TriggerSettings/index.d.ts +3 -0
  154. package/dist/types/src/containers/TriggerSettings/index.d.ts.map +1 -0
  155. package/dist/types/src/containers/index.d.ts +5 -0
  156. package/dist/types/src/containers/index.d.ts.map +1 -0
  157. package/dist/types/src/hooks/index.d.ts +1 -1
  158. package/dist/types/src/hooks/index.d.ts.map +1 -1
  159. package/dist/types/src/hooks/useEdgeTriggersDispatcherStatus.d.ts +13 -0
  160. package/dist/types/src/hooks/useEdgeTriggersDispatcherStatus.d.ts.map +1 -0
  161. package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts +5 -4
  162. package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts.map +1 -1
  163. package/dist/types/src/index.d.ts +1 -5
  164. package/dist/types/src/index.d.ts.map +1 -1
  165. package/dist/types/src/meta.d.ts +2 -2
  166. package/dist/types/src/meta.d.ts.map +1 -1
  167. package/dist/types/src/operations/create-trigger-from-template.d.ts +5 -0
  168. package/dist/types/src/operations/create-trigger-from-template.d.ts.map +1 -0
  169. package/dist/types/src/operations/index.d.ts +3 -0
  170. package/dist/types/src/operations/index.d.ts.map +1 -0
  171. package/dist/types/src/plugin.d.ts +4 -0
  172. package/dist/types/src/plugin.d.ts.map +1 -0
  173. package/dist/types/src/testing/test-functions.d.ts +204 -3
  174. package/dist/types/src/testing/test-functions.d.ts.map +1 -1
  175. package/dist/types/src/testing.d.ts +2 -0
  176. package/dist/types/src/testing.d.ts.map +1 -0
  177. package/dist/types/src/translations.d.ts +45 -31
  178. package/dist/types/src/translations.d.ts.map +1 -1
  179. package/dist/types/src/types/AutomationOperation.d.ts +21 -0
  180. package/dist/types/src/types/AutomationOperation.d.ts.map +1 -0
  181. package/dist/types/src/types/index.d.ts +1 -0
  182. package/dist/types/src/types/index.d.ts.map +1 -1
  183. package/dist/types/src/types/schema.d.ts +13 -5
  184. package/dist/types/src/types/schema.d.ts.map +1 -1
  185. package/dist/types/tsconfig.tsbuildinfo +1 -1
  186. package/package.json +145 -70
  187. package/src/AutomationPlugin.node.ts +32 -0
  188. package/src/AutomationPlugin.test.ts +27 -0
  189. package/src/AutomationPlugin.tsx +24 -38
  190. package/src/AutomationPlugin.workerd.ts +18 -0
  191. package/src/capabilities/app-graph-builder.ts +59 -80
  192. package/src/capabilities/index.ts +13 -7
  193. package/src/capabilities/layer-specs.ts +230 -0
  194. package/src/capabilities/node.ts +17 -0
  195. package/src/capabilities/operation-handler.ts +16 -0
  196. package/src/capabilities/react-surface.tsx +49 -46
  197. package/src/capabilities/trigger-runtime-controller.test.ts +103 -0
  198. package/src/capabilities/trigger-runtime-controller.ts +126 -0
  199. package/src/commands/index.ts +5 -0
  200. package/src/commands/trigger/create/index.ts +14 -0
  201. package/src/commands/trigger/create/queue.ts +87 -0
  202. package/src/commands/trigger/create/subscription.ts +125 -0
  203. package/src/commands/trigger/create/timer.ts +90 -0
  204. package/src/commands/trigger/index.ts +16 -0
  205. package/src/commands/trigger/list.ts +70 -0
  206. package/src/commands/trigger/options.ts +47 -0
  207. package/src/commands/trigger/remove.ts +45 -0
  208. package/src/commands/trigger/update/index.ts +14 -0
  209. package/src/commands/trigger/update/queue.ts +191 -0
  210. package/src/commands/trigger/update/subscription.ts +279 -0
  211. package/src/commands/trigger/update/timer.ts +195 -0
  212. package/src/commands/trigger/util.ts +410 -0
  213. package/src/components/AutomationPanel/AutomationPanel.stories.tsx +15 -8
  214. package/src/components/AutomationPanel/AutomationPanel.tsx +245 -86
  215. package/src/components/AutomationPanel/TriggerEdgeMetadata.tsx +148 -0
  216. package/src/components/FunctionsPanel/FunctionsPanel.tsx +43 -42
  217. package/src/components/FunctionsRegistry/FunctionsRegistry.tsx +38 -54
  218. package/src/components/FunctionsRegistry/index.ts +4 -1
  219. package/src/components/TriggerEditor/FunctionInputEditor.tsx +36 -35
  220. package/src/components/TriggerEditor/SpecSelector.tsx +26 -20
  221. package/src/components/TriggerEditor/TriggerEditor.stories.tsx +92 -39
  222. package/src/components/TriggerEditor/TriggerEditor.tsx +171 -54
  223. package/src/components/index.ts +1 -2
  224. package/src/containers/AutomationSettings/AutomationSettings.tsx +31 -0
  225. package/src/containers/AutomationSettings/index.ts +5 -0
  226. package/src/containers/FunctionsContainer/FunctionsContainer.tsx +33 -0
  227. package/src/containers/FunctionsContainer/index.ts +5 -0
  228. package/src/containers/TriggerSettings/TriggerSettings.tsx +48 -0
  229. package/src/containers/TriggerSettings/index.ts +6 -0
  230. package/src/containers/index.ts +9 -0
  231. package/src/hooks/index.ts +2 -1
  232. package/src/hooks/useEdgeTriggersDispatcherStatus.ts +78 -0
  233. package/src/hooks/useTriggerRuntimeControls.ts +38 -19
  234. package/src/index.ts +1 -6
  235. package/src/meta.ts +25 -6
  236. package/src/operations/create-trigger-from-template.ts +70 -0
  237. package/src/operations/index.ts +7 -0
  238. package/src/plugin.ts +11 -0
  239. package/src/testing/test-functions.ts +12 -9
  240. package/src/testing.ts +7 -0
  241. package/src/translations.ts +53 -36
  242. package/src/types/AutomationOperation.ts +39 -0
  243. package/src/types/index.ts +2 -0
  244. package/src/types/schema.ts +6 -6
  245. package/dist/lib/browser/AutomationPanel-7OECLR5N.mjs +0 -11
  246. package/dist/lib/browser/AutomationSettings-KCZISXI6.mjs +0 -68
  247. package/dist/lib/browser/AutomationSettings-KCZISXI6.mjs.map +0 -7
  248. package/dist/lib/browser/FunctionsContainer-MIWEISRR.mjs +0 -151
  249. package/dist/lib/browser/FunctionsContainer-MIWEISRR.mjs.map +0 -7
  250. package/dist/lib/browser/FunctionsPanel-CRW6SJUN.mjs +0 -10
  251. package/dist/lib/browser/app-graph-builder-W7LLC6XW.mjs +0 -81
  252. package/dist/lib/browser/app-graph-builder-W7LLC6XW.mjs.map +0 -7
  253. package/dist/lib/browser/chunk-EPEXQP45.mjs +0 -14
  254. package/dist/lib/browser/chunk-EPEXQP45.mjs.map +0 -7
  255. package/dist/lib/browser/chunk-JW7XSPYW.mjs +0 -267
  256. package/dist/lib/browser/chunk-JW7XSPYW.mjs.map +0 -7
  257. package/dist/lib/browser/chunk-LZQFZO3B.mjs +0 -17
  258. package/dist/lib/browser/chunk-LZQFZO3B.mjs.map +0 -7
  259. package/dist/lib/browser/chunk-NAPXRXTY.mjs +0 -100
  260. package/dist/lib/browser/chunk-NAPXRXTY.mjs.map +0 -7
  261. package/dist/lib/browser/chunk-QKFBHAGN.mjs +0 -184
  262. package/dist/lib/browser/chunk-QKFBHAGN.mjs.map +0 -7
  263. package/dist/lib/browser/chunk-TWWFNOIR.mjs +0 -109
  264. package/dist/lib/browser/chunk-TWWFNOIR.mjs.map +0 -7
  265. package/dist/lib/browser/chunk-XAKZ4ANY.mjs +0 -15
  266. package/dist/lib/browser/chunk-XAKZ4ANY.mjs.map +0 -7
  267. package/dist/lib/browser/chunk-YBPJCY3F.mjs +0 -38
  268. package/dist/lib/browser/chunk-YBPJCY3F.mjs.map +0 -7
  269. package/dist/lib/browser/compute-runtime-EIQTHJFZ.mjs +0 -113
  270. package/dist/lib/browser/compute-runtime-EIQTHJFZ.mjs.map +0 -7
  271. package/dist/lib/browser/hooks/index.mjs +0 -13
  272. package/dist/lib/browser/index.mjs +0 -130
  273. package/dist/lib/browser/index.mjs.map +0 -7
  274. package/dist/lib/browser/intent-resolver-5HR7M7T6.mjs +0 -77
  275. package/dist/lib/browser/intent-resolver-5HR7M7T6.mjs.map +0 -7
  276. package/dist/lib/browser/meta.json +0 -1
  277. package/dist/lib/browser/react-surface-YQW7WCFW.mjs +0 -64
  278. package/dist/lib/browser/react-surface-YQW7WCFW.mjs.map +0 -7
  279. package/dist/lib/browser/types/index.mjs +0 -8
  280. package/dist/lib/node-esm/AutomationPanel-HCVFNHGQ.mjs +0 -12
  281. package/dist/lib/node-esm/AutomationSettings-UUUPVNUJ.mjs +0 -69
  282. package/dist/lib/node-esm/AutomationSettings-UUUPVNUJ.mjs.map +0 -7
  283. package/dist/lib/node-esm/FunctionsContainer-6OB3JN5O.mjs +0 -152
  284. package/dist/lib/node-esm/FunctionsContainer-6OB3JN5O.mjs.map +0 -7
  285. package/dist/lib/node-esm/FunctionsPanel-RVVCS6VH.mjs +0 -11
  286. package/dist/lib/node-esm/app-graph-builder-SLQOO7GH.mjs +0 -82
  287. package/dist/lib/node-esm/app-graph-builder-SLQOO7GH.mjs.map +0 -7
  288. package/dist/lib/node-esm/chunk-6YRKST6M.mjs +0 -185
  289. package/dist/lib/node-esm/chunk-6YRKST6M.mjs.map +0 -7
  290. package/dist/lib/node-esm/chunk-CEVIVRTY.mjs +0 -19
  291. package/dist/lib/node-esm/chunk-CEVIVRTY.mjs.map +0 -7
  292. package/dist/lib/node-esm/chunk-CPP35BE6.mjs +0 -16
  293. package/dist/lib/node-esm/chunk-CPP35BE6.mjs.map +0 -7
  294. package/dist/lib/node-esm/chunk-ECJKIUBO.mjs +0 -39
  295. package/dist/lib/node-esm/chunk-ECJKIUBO.mjs.map +0 -7
  296. package/dist/lib/node-esm/chunk-KB7NFEYY.mjs +0 -16
  297. package/dist/lib/node-esm/chunk-KB7NFEYY.mjs.map +0 -7
  298. package/dist/lib/node-esm/chunk-PICJ2REN.mjs +0 -101
  299. package/dist/lib/node-esm/chunk-PICJ2REN.mjs.map +0 -7
  300. package/dist/lib/node-esm/chunk-RVK52XGK.mjs +0 -110
  301. package/dist/lib/node-esm/chunk-RVK52XGK.mjs.map +0 -7
  302. package/dist/lib/node-esm/chunk-W76WUTZY.mjs +0 -268
  303. package/dist/lib/node-esm/chunk-W76WUTZY.mjs.map +0 -7
  304. package/dist/lib/node-esm/compute-runtime-URROOC34.mjs +0 -114
  305. package/dist/lib/node-esm/compute-runtime-URROOC34.mjs.map +0 -7
  306. package/dist/lib/node-esm/hooks/index.mjs +0 -14
  307. package/dist/lib/node-esm/index.mjs +0 -131
  308. package/dist/lib/node-esm/index.mjs.map +0 -7
  309. package/dist/lib/node-esm/intent-resolver-KDRYB5BC.mjs +0 -78
  310. package/dist/lib/node-esm/intent-resolver-KDRYB5BC.mjs.map +0 -7
  311. package/dist/lib/node-esm/meta.json +0 -1
  312. package/dist/lib/node-esm/react-surface-NNHYNBO6.mjs +0 -65
  313. package/dist/lib/node-esm/react-surface-NNHYNBO6.mjs.map +0 -7
  314. package/dist/lib/node-esm/types/index.mjs +0 -9
  315. package/dist/types/src/capabilities/capabilities.d.ts +0 -20
  316. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  317. package/dist/types/src/capabilities/compute-runtime.d.ts +0 -5
  318. package/dist/types/src/capabilities/compute-runtime.d.ts.map +0 -1
  319. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  320. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  321. package/dist/types/src/components/AutomationSettings.d.ts +0 -5
  322. package/dist/types/src/components/AutomationSettings.d.ts.map +0 -1
  323. package/dist/types/src/components/FunctionsContainer.d.ts +0 -7
  324. package/dist/types/src/components/FunctionsContainer.d.ts.map +0 -1
  325. package/dist/types/src/components/TriggerSettings.d.ts.map +0 -1
  326. package/dist/types/src/events.d.ts +0 -4
  327. package/dist/types/src/events.d.ts.map +0 -1
  328. package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts +0 -12
  329. package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts.map +0 -1
  330. package/src/capabilities/capabilities.ts +0 -41
  331. package/src/capabilities/compute-runtime.ts +0 -127
  332. package/src/capabilities/intent-resolver.ts +0 -72
  333. package/src/components/AutomationSettings.tsx +0 -30
  334. package/src/components/FunctionsContainer.tsx +0 -36
  335. package/src/components/TriggerSettings.tsx +0 -25
  336. package/src/events.ts +0 -11
  337. package/src/hooks/useComputeRuntimeCallback.ts +0 -68
  338. /package/dist/lib/{browser/AutomationPanel-7OECLR5N.mjs.map → neutral/AutomationPanel-OS3ZWYJK.mjs.map} +0 -0
  339. /package/dist/lib/{browser/FunctionsPanel-CRW6SJUN.mjs.map → neutral/AutomationPlugin.mjs.map} +0 -0
  340. /package/dist/lib/{browser/hooks/index.mjs.map → neutral/TriggerSettings-XCHIZPOR.mjs.map} +0 -0
  341. /package/dist/lib/{browser/types/index.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
  342. /package/dist/lib/{node-esm/hooks → neutral/components}/index.mjs.map +0 -0
  343. /package/dist/lib/{node-esm/types → neutral/hooks}/index.mjs.map +0 -0
  344. /package/dist/lib/{node-esm/AutomationPanel-HCVFNHGQ.mjs.map → neutral/index.mjs.map} +0 -0
  345. /package/dist/lib/{node-esm/FunctionsPanel-RVVCS6VH.mjs.map → neutral/meta.mjs.map} +0 -0
  346. /package/dist/types/src/{components → containers/TriggerSettings}/TriggerSettings.d.ts +0 -0
@@ -0,0 +1,1118 @@
1
+ import "./chunk-J5LGTIGS.mjs";
2
+
3
+ // src/AutomationPlugin.node.ts
4
+ import { ActivationEvent, ActivationEvents, Plugin } from "@dxos/app-framework";
5
+ import { AppPlugin } from "@dxos/app-toolkit";
6
+ import { Operation as Operation8, Trace, Trigger as Trigger10 } from "@dxos/compute";
7
+ import { ClientEvents } from "@dxos/plugin-client";
8
+ import { AppGraphBuilder, LayerSpecs, OperationHandler, TriggerRuntimeController } from "#capabilities";
9
+ import { meta } from "#meta";
10
+
11
+ // src/commands/trigger/index.ts
12
+ import * as Command11 from "@effect/cli/Command";
13
+
14
+ // src/commands/trigger/create/index.ts
15
+ import * as Command4 from "@effect/cli/Command";
16
+
17
+ // src/commands/trigger/create/queue.ts
18
+ import * as Command from "@effect/cli/Command";
19
+ import * as Options2 from "@effect/cli/Options";
20
+ import * as Prompt2 from "@effect/cli/Prompt";
21
+ import * as Console2 from "effect/Console";
22
+ import * as Effect2 from "effect/Effect";
23
+ import * as HashMap from "effect/HashMap";
24
+ import * as Option2 from "effect/Option";
25
+ import { CommandConfig } from "@dxos/cli-util";
26
+ import { flushAndSync, print, spaceLayer, withTypes } from "@dxos/cli-util";
27
+ import { Common } from "@dxos/cli-util";
28
+ import { Operation as Operation2, Trigger as Trigger2 } from "@dxos/compute";
29
+ import { Database as Database2, Feed as FeedNs, Filter as Filter2, JsonSchema, Ref as Ref2 } from "@dxos/echo";
30
+ import { EchoURI } from "@dxos/keys";
31
+
32
+ // src/commands/trigger/options.ts
33
+ import * as Options from "@effect/cli/Options";
34
+ var TriggerId = Options.text("id").pipe(Options.withDescription("The id of the trigger."));
35
+ var Enabled = Options.boolean("enabled", {
36
+ ifPresent: true
37
+ }).pipe(Options.withDescription("Whether the trigger is enabled."));
38
+ var Input = Options.keyValueMap("input").pipe(Options.withDescription("Input data to pass to the function. Must match the function's input schema."));
39
+ var Typename = Options.text("typename").pipe(Options.withDescription("The type name to query for the subscription trigger."));
40
+ var Deep = Options.boolean("deep", {
41
+ ifPresent: true
42
+ }).pipe(Options.withDescription("Watch changes to nested properties (not just creation)."));
43
+ var Delay = Options.integer("delay").pipe(Options.withDescription("Debounce changes with a delay in milliseconds."));
44
+ var Cron = Options.text("cron").pipe(Options.withDescription("The cron expression to use for the timer trigger."));
45
+ var Feed = Options.text("feed").pipe(Options.withDescription("The EchoURI of the feed for the feed trigger (echo://<spaceId>/<objectId>)."));
46
+
47
+ // src/commands/trigger/util.ts
48
+ import * as Prompt from "@effect/cli/Prompt";
49
+ import * as Ansi from "@effect/printer-ansi/Ansi";
50
+ import * as Console from "effect/Console";
51
+ import * as Effect from "effect/Effect";
52
+ import * as Match from "effect/Match";
53
+ import * as Option from "effect/Option";
54
+ import * as SchemaAST from "effect/SchemaAST";
55
+ import { FormBuilder } from "@dxos/cli-util";
56
+ import { Operation, Trigger } from "@dxos/compute";
57
+ import { Annotation, Database, Entity, Feed as Feed2, Filter, Obj, Query, Ref, Type } from "@dxos/echo";
58
+ import { getProperties } from "@dxos/effect";
59
+ import { FeedAnnotation } from "@dxos/schema";
60
+ var getTriggerRemoteStatus = (trigger2, remoteCronIds) => {
61
+ if (trigger2.spec?.kind !== "timer") {
62
+ return "n/a";
63
+ }
64
+ return remoteCronIds.includes(trigger2.id) ? "available" : "not available";
65
+ };
66
+ var printTrigger = Effect.fn(function* (trigger2, remoteStatus) {
67
+ const fn6 = trigger2.function && (yield* Database.load(trigger2.function));
68
+ return FormBuilder.make({
69
+ title: trigger2.id
70
+ }).pipe(FormBuilder.set("status", trigger2.enabled ? "enabled" : "disabled", trigger2.enabled ? Ansi.green : Ansi.blackBright), FormBuilder.option("kind", Option.fromNullable(trigger2.spec?.kind)), FormBuilder.option("remote", Option.fromNullable(remoteStatus), Match.type().pipe(Match.withReturnType(), Match.when("available", () => Ansi.green), Match.when("not available", () => Ansi.yellow), Match.when("n/a", () => Ansi.blackBright), Match.exhaustive)), FormBuilder.when(fn6, FormBuilder.nest("function", FormBuilder.make().pipe(FormBuilder.set("key", Obj.getMeta(fn6).key), FormBuilder.set("dxn", Obj.getURI(fn6))))), FormBuilder.nestedOption("spec", Option.fromNullable(trigger2.spec).pipe(Option.map(printSpec))), FormBuilder.build);
71
+ });
72
+ var printSpec = (spec) => {
73
+ switch (spec.kind) {
74
+ case "timer":
75
+ return printTimer(spec);
76
+ case "subscription":
77
+ return printSubscription(spec);
78
+ case "webhook":
79
+ return printWebhook(spec);
80
+ case "feed":
81
+ return printFeed(spec);
82
+ default:
83
+ return FormBuilder.make({}).pipe(FormBuilder.set("unknown", "Unknown spec type"));
84
+ }
85
+ };
86
+ var printTimer = (spec) => FormBuilder.make({}).pipe(FormBuilder.set("cron", spec.cron));
87
+ var printSubscription = (spec) => FormBuilder.make({}).pipe(FormBuilder.set("query", spec.query?.raw ?? "[Query AST]"));
88
+ var printWebhook = (spec) => FormBuilder.make({}).pipe(FormBuilder.set("method", spec.method), FormBuilder.set("port", spec.port));
89
+ var printFeed = (spec) => FormBuilder.make({}).pipe(FormBuilder.set("feed", spec.feed ? spec.feed.uri.toString() : "(none)"));
90
+ var promptForSchemaInput = Effect.fn(function* (schema, defaults) {
91
+ if (!schema) {
92
+ return {};
93
+ }
94
+ const ast = schema.ast;
95
+ if (!SchemaAST.isTypeLiteral(ast)) {
96
+ return {};
97
+ }
98
+ const properties = getProperties(ast);
99
+ if (properties.length === 0) {
100
+ return {};
101
+ }
102
+ const requiredProperties = [];
103
+ const optionalProperties = [];
104
+ for (const prop of properties) {
105
+ if (prop.isOptional) {
106
+ optionalProperties.push(prop);
107
+ } else {
108
+ requiredProperties.push(prop);
109
+ }
110
+ }
111
+ const propertyInfo = properties.map((prop) => {
112
+ const key = prop.name.toString();
113
+ return {
114
+ prop,
115
+ key,
116
+ isRequired: !prop.isOptional
117
+ };
118
+ });
119
+ const selectedKeys = /* @__PURE__ */ new Set();
120
+ for (const info of propertyInfo) {
121
+ if (info.isRequired) {
122
+ selectedKeys.add(info.key);
123
+ }
124
+ }
125
+ if (requiredProperties.length > 0) {
126
+ const requiredNames = requiredProperties.map((p) => {
127
+ const info = propertyInfo.find((i) => i.prop === p);
128
+ return info?.key ?? p.name.toString();
129
+ });
130
+ yield* Console.log(`Required properties (will be included): ${requiredNames.join(", ")}`);
131
+ }
132
+ if (optionalProperties.length > 0) {
133
+ const optionalInfo = propertyInfo.filter((info) => !info.isRequired);
134
+ const choices = optionalInfo.map((info) => {
135
+ const hasDefault = defaults?.[info.key] !== void 0;
136
+ const defaultText = hasDefault ? ` (current: ${JSON.stringify(defaults[info.key])})` : "";
137
+ return {
138
+ title: `${info.key}${defaultText}`,
139
+ value: info.key,
140
+ description: hasDefault ? "Has default value" : void 0
141
+ };
142
+ });
143
+ const selected = yield* Prompt.multiSelect({
144
+ message: "Select optional properties to include:",
145
+ choices
146
+ });
147
+ for (const key of selected) {
148
+ selectedKeys.add(String(key));
149
+ }
150
+ }
151
+ if (selectedKeys.size === 0) {
152
+ return {};
153
+ }
154
+ const inputObj = {};
155
+ for (const info of propertyInfo) {
156
+ if (!selectedKeys.has(info.key)) {
157
+ continue;
158
+ }
159
+ const key = info.key;
160
+ const propType = info.prop.type;
161
+ const schemaDefault = Option.getOrUndefined(SchemaAST.getDefaultAnnotation(propType));
162
+ const defaultValue = defaults?.[key] ?? schemaDefault;
163
+ if (SchemaAST.isBooleanKeyword(propType)) {
164
+ const initialValue = typeof defaultValue === "boolean" ? defaultValue : typeof schemaDefault === "boolean" ? schemaDefault : false;
165
+ const value2 = yield* Prompt.confirm({
166
+ message: `${info.key}${defaults?.[key] !== void 0 ? ` (current: ${defaults[key]})` : ""}:`,
167
+ initial: initialValue
168
+ });
169
+ inputObj[key] = value2;
170
+ } else if (SchemaAST.isNumberKeyword(propType)) {
171
+ const currentValue = typeof defaultValue === "number" ? String(defaultValue) : "";
172
+ const valueStr = yield* Prompt.text({
173
+ message: `${info.key}${currentValue ? ` (current: ${currentValue}, press Enter to keep)` : ""}:`
174
+ }).pipe(Prompt.run);
175
+ inputObj[key] = valueStr === "" && defaultValue !== void 0 ? defaultValue : parseFloat(valueStr) || 0;
176
+ } else if (SchemaAST.isStringKeyword(propType)) {
177
+ const currentValue = typeof defaultValue === "string" ? defaultValue : "";
178
+ const valueStr = yield* Prompt.text({
179
+ message: `${info.key}${currentValue ? ` (current: ${currentValue}, press Enter to keep)` : ""}:`
180
+ }).pipe(Prompt.run);
181
+ inputObj[key] = valueStr === "" && defaultValue !== void 0 ? defaultValue : valueStr;
182
+ } else if (Ref.isRefType(propType)) {
183
+ const isDefaultTemplate = typeof defaultValue === "string" && defaultValue.startsWith("{{") && defaultValue.endsWith("}}");
184
+ const useTemplate = yield* Prompt.confirm({
185
+ message: `Use a template to specify ${info.key}?${isDefaultTemplate ? " (current: template)" : ""}`,
186
+ initial: isDefaultTemplate
187
+ });
188
+ if (useTemplate) {
189
+ const currentValue = typeof defaultValue === "string" ? defaultValue : "";
190
+ const templateStr = yield* Prompt.text({
191
+ message: `${info.key} template${currentValue ? ` (current: ${currentValue}, press Enter to keep)` : ""}:`
192
+ }).pipe(Prompt.run);
193
+ inputObj[key] = templateStr === "" && defaultValue !== void 0 ? defaultValue : templateStr;
194
+ } else {
195
+ const annotation = Annotation.ReferenceAnnotation.getFromAst(propType).pipe(Option.getOrThrow);
196
+ const objects = yield* Database.runQuery(Filter.typename(annotation.typename));
197
+ if (objects.length === 0) {
198
+ inputObj[key] = void 0;
199
+ } else {
200
+ const selected = yield* Prompt.select({
201
+ message: `Select ${info.key}:`,
202
+ choices: objects.map((obj) => ({
203
+ title: Entity.getLabel(obj) ?? obj.id,
204
+ value: Ref.make(obj),
205
+ description: Entity.getDescription(obj)
206
+ }))
207
+ });
208
+ inputObj[key] = selected;
209
+ }
210
+ }
211
+ } else {
212
+ const currentValue = defaultValue !== void 0 ? String(defaultValue) : "";
213
+ const valueStr = yield* Prompt.text({
214
+ message: `${info.key}${currentValue ? ` (current: ${currentValue}, press Enter to keep)` : ""}:`
215
+ }).pipe(Prompt.run);
216
+ inputObj[key] = valueStr === "" && defaultValue !== void 0 ? defaultValue : valueStr;
217
+ }
218
+ }
219
+ return inputObj;
220
+ });
221
+ var selectFunction = Effect.fn(function* () {
222
+ const functions = yield* Database.runQuery(Filter.type(Operation.PersistentOperation));
223
+ if (functions.length === 0) {
224
+ return yield* Effect.fail(new Error("No functions available"));
225
+ }
226
+ const selected = yield* Prompt.select({
227
+ message: "Select a function:",
228
+ choices: functions.map((fn6) => ({
229
+ title: fn6.name ?? fn6.id,
230
+ value: fn6.id,
231
+ description: fn6.description
232
+ }))
233
+ });
234
+ return String(selected);
235
+ });
236
+ var selectTrigger = Effect.fn(function* (kind) {
237
+ const triggers = yield* Database.runQuery(Query.select(Filter.type(Trigger.Trigger)).debugLabel("cli.trigger.selectTrigger"));
238
+ const filteredTriggers = kind ? triggers.filter((trigger2) => trigger2.spec?.kind === kind) : triggers;
239
+ if (filteredTriggers.length === 0) {
240
+ return yield* Effect.fail(new Error(kind ? `No ${kind} triggers available` : "No triggers available"));
241
+ }
242
+ const choices = yield* Effect.all(filteredTriggers.map((trigger2) => Effect.gen(function* () {
243
+ const fn6 = trigger2.function ? yield* Database.load(trigger2.function) : void 0;
244
+ const functionName = fn6 && Obj.instanceOf(Operation.PersistentOperation, fn6) ? fn6.name ?? Obj.getMeta(fn6).key ?? fn6.id : void 0;
245
+ const title = functionName ?? trigger2.id;
246
+ const description = `${trigger2.enabled ? "enabled" : "disabled"} - ${trigger2.spec?.kind ?? "unknown"}`;
247
+ return {
248
+ title,
249
+ value: trigger2.id,
250
+ description
251
+ };
252
+ })));
253
+ const selected = yield* Prompt.select({
254
+ message: kind ? `Select a ${kind} trigger:` : "Select a trigger:",
255
+ choices
256
+ });
257
+ return String(selected);
258
+ });
259
+ var selectFeed = Effect.fn(function* () {
260
+ const schemas = yield* Database.runSchemaQuery({
261
+ location: [
262
+ "database",
263
+ "runtime"
264
+ ]
265
+ });
266
+ const feedSchemas = schemas.filter((type2) => {
267
+ const schema = Type.getSchema(type2);
268
+ const annotation = FeedAnnotation.get(schema);
269
+ return Option.isSome(annotation) && annotation.value === true;
270
+ });
271
+ if (feedSchemas.length === 0) {
272
+ return yield* Effect.fail(new Error("No schemas with Feed annotation found"));
273
+ }
274
+ const feedChoices = [];
275
+ for (const schema of feedSchemas) {
276
+ yield* Effect.gen(function* () {
277
+ const typename = Type.getTypename(schema);
278
+ const objects = yield* Database.runQuery(Filter.type(typename));
279
+ for (const obj of objects) {
280
+ const feedRef = obj.feed;
281
+ if (!feedRef) {
282
+ continue;
283
+ }
284
+ const feedObj = yield* Effect.promise(() => feedRef.tryLoad());
285
+ if (!feedObj || !Obj.instanceOf(Feed2.Feed, feedObj)) {
286
+ continue;
287
+ }
288
+ const label = Obj.getLabel(obj) ?? obj.id;
289
+ const description = Obj.getTypename(obj);
290
+ feedChoices.push({
291
+ title: label,
292
+ value: feedObj,
293
+ description
294
+ });
295
+ }
296
+ }).pipe(Effect.catchAll(() => Effect.void));
297
+ }
298
+ if (feedChoices.length === 0) {
299
+ return yield* Effect.fail(new Error("No objects with feed properties found"));
300
+ }
301
+ const selected = yield* Prompt.select({
302
+ message: "Select a feed:",
303
+ choices: feedChoices
304
+ });
305
+ return selected;
306
+ });
307
+ var printTriggerRemoved = (id) => FormBuilder.make({
308
+ title: "Trigger removed"
309
+ }).pipe(FormBuilder.set("id", id), FormBuilder.build);
310
+
311
+ // src/commands/trigger/create/queue.ts
312
+ var queue = Command.make("feed", {
313
+ spaceId: Common.spaceId.pipe(Options2.optional),
314
+ enabled: Enabled,
315
+ functionId: Common.functionId.pipe(Options2.optional),
316
+ feed: Feed.pipe(Options2.optional),
317
+ input: Input.pipe(Options2.optional)
318
+ }, (options) => Effect2.gen(function* () {
319
+ const { json } = yield* CommandConfig;
320
+ const functionId = yield* Option2.match(options.functionId, {
321
+ onNone: () => selectFunction(),
322
+ onSome: (id) => Effect2.succeed(id)
323
+ });
324
+ const functions = yield* Database2.runQuery(Filter2.type(Operation2.PersistentOperation));
325
+ const fn6 = functions.find((fn7) => fn7.id === functionId);
326
+ if (!fn6) {
327
+ return yield* Effect2.fail(new Error(`Function not found: ${functionId}`));
328
+ }
329
+ const feed = yield* Option2.match(options.feed, {
330
+ onNone: () => selectFeed(),
331
+ onSome: (uri) => Database2.resolve(EchoURI.parse(uri), FeedNs.Feed)
332
+ });
333
+ const input = yield* Option2.match(options.input, {
334
+ onNone: () => promptForSchemaInput(fn6.inputSchema ? JsonSchema.toEffectSchema(fn6.inputSchema) : void 0),
335
+ onSome: (value2) => Effect2.succeed(Object.fromEntries(HashMap.toEntries(value2)))
336
+ });
337
+ const enabled = yield* Option2.match(options.functionId, {
338
+ onNone: () => Prompt2.confirm({
339
+ message: "Enable the trigger?",
340
+ initial: true
341
+ }).pipe(Prompt2.run),
342
+ onSome: () => Effect2.succeed(options.enabled)
343
+ });
344
+ const trigger2 = Trigger2.make({
345
+ function: Ref2.make(fn6),
346
+ enabled,
347
+ spec: Trigger2.specFeed(feed),
348
+ input
349
+ });
350
+ yield* Database2.add(trigger2);
351
+ if (json) {
352
+ yield* Console2.log(JSON.stringify(trigger2, null, 2));
353
+ } else {
354
+ yield* Console2.log(print(yield* printTrigger(trigger2)));
355
+ }
356
+ yield* flushAndSync({
357
+ indexes: true
358
+ });
359
+ })).pipe(Command.withDescription("Create a feed trigger."), Command.provide(({ spaceId }) => spaceLayer(spaceId, true)), Command.provideEffectDiscard(() => withTypes(Operation2.PersistentOperation, Trigger2.Trigger)));
360
+
361
+ // src/commands/trigger/create/subscription.ts
362
+ import * as Command2 from "@effect/cli/Command";
363
+ import * as Options3 from "@effect/cli/Options";
364
+ import * as Prompt3 from "@effect/cli/Prompt";
365
+ import * as Console3 from "effect/Console";
366
+ import * as Effect3 from "effect/Effect";
367
+ import * as HashMap2 from "effect/HashMap";
368
+ import * as Option3 from "effect/Option";
369
+ import { CommandConfig as CommandConfig2 } from "@dxos/cli-util";
370
+ import { flushAndSync as flushAndSync2, print as print2, spaceLayer as spaceLayer2, withTypes as withTypes2 } from "@dxos/cli-util";
371
+ import { Common as Common2 } from "@dxos/cli-util";
372
+ import { Operation as Operation3, Trigger as Trigger3 } from "@dxos/compute";
373
+ import { Database as Database3, Filter as Filter3, JsonSchema as JsonSchema2, Query as Query2, Ref as Ref3 } from "@dxos/echo";
374
+ var subscription = Command2.make("subscription", {
375
+ spaceId: Common2.spaceId.pipe(Options3.optional),
376
+ enabled: Enabled,
377
+ functionId: Common2.functionId.pipe(Options3.optional),
378
+ typename: Typename.pipe(Options3.optional),
379
+ deep: Deep.pipe(Options3.optional),
380
+ delay: Delay.pipe(Options3.optional),
381
+ input: Input.pipe(Options3.optional)
382
+ }, (options) => Effect3.gen(function* () {
383
+ const { json } = yield* CommandConfig2;
384
+ const functionId = yield* Option3.match(options.functionId, {
385
+ onNone: () => selectFunction(),
386
+ onSome: (id) => Effect3.succeed(id)
387
+ });
388
+ const functions = yield* Database3.runQuery(Filter3.type(Operation3.PersistentOperation));
389
+ const fn6 = functions.find((fn7) => fn7.id === functionId);
390
+ if (!fn6) {
391
+ return yield* Effect3.fail(new Error(`Function not found: ${functionId}`));
392
+ }
393
+ const typename = yield* Option3.match(options.typename, {
394
+ onNone: () => Prompt3.text({
395
+ message: "Enter type name:"
396
+ }).pipe(Prompt3.run),
397
+ onSome: (value2) => Effect3.succeed(value2)
398
+ });
399
+ const subscriptionQuery = Query2.select(Filter3.type(typename));
400
+ const deepOption = yield* Option3.match(options.deep, {
401
+ onNone: () => Prompt3.confirm({
402
+ message: "Watch changes to nested properties (deep)?",
403
+ initial: false
404
+ }).pipe(Prompt3.run, Effect3.map((value2) => value2 ? Option3.some(value2) : Option3.none())),
405
+ onSome: () => Effect3.succeed(Option3.some(true))
406
+ });
407
+ const delayOption = yield* Option3.match(options.delay, {
408
+ onNone: () => Effect3.gen(function* () {
409
+ const delayStr = yield* Prompt3.text({
410
+ message: "Debounce delay in milliseconds (optional, press Enter to skip):"
411
+ }).pipe(Prompt3.run);
412
+ return delayStr === "" ? Option3.none() : Option3.some(parseInt(delayStr, 10));
413
+ }),
414
+ onSome: (value2) => Effect3.succeed(Option3.some(value2))
415
+ });
416
+ const subscriptionOptions = {};
417
+ if (Option3.isSome(deepOption)) {
418
+ subscriptionOptions.deep = deepOption.value;
419
+ }
420
+ if (Option3.isSome(delayOption)) {
421
+ subscriptionOptions.delay = delayOption.value;
422
+ }
423
+ const input = yield* Option3.match(options.input, {
424
+ onNone: () => promptForSchemaInput(fn6.inputSchema ? JsonSchema2.toEffectSchema(fn6.inputSchema) : void 0),
425
+ onSome: (value2) => Effect3.succeed(Object.fromEntries(HashMap2.toEntries(value2)))
426
+ });
427
+ const enabled = yield* Option3.match(options.functionId, {
428
+ onNone: () => Prompt3.confirm({
429
+ message: "Enable the trigger?",
430
+ initial: true
431
+ }).pipe(Prompt3.run),
432
+ onSome: () => Effect3.succeed(options.enabled)
433
+ });
434
+ const trigger2 = Trigger3.make({
435
+ function: Ref3.make(fn6),
436
+ enabled,
437
+ spec: Trigger3.specSubscription(subscriptionQuery, Object.keys(subscriptionOptions).length > 0 ? subscriptionOptions : void 0),
438
+ input
439
+ });
440
+ yield* Database3.add(trigger2);
441
+ if (json) {
442
+ yield* Console3.log(JSON.stringify(trigger2, null, 2));
443
+ } else {
444
+ yield* Console3.log(print2(yield* printTrigger(trigger2)));
445
+ }
446
+ yield* flushAndSync2({
447
+ indexes: true
448
+ });
449
+ })).pipe(Command2.withDescription("Create a subscription trigger."), Command2.provide(({ spaceId }) => spaceLayer2(spaceId, true)), Command2.provideEffectDiscard(() => withTypes2(Operation3.PersistentOperation, Trigger3.Trigger)));
450
+
451
+ // src/commands/trigger/create/timer.ts
452
+ import * as Command3 from "@effect/cli/Command";
453
+ import * as Options4 from "@effect/cli/Options";
454
+ import * as Prompt4 from "@effect/cli/Prompt";
455
+ import * as Console4 from "effect/Console";
456
+ import * as Effect4 from "effect/Effect";
457
+ import * as HashMap3 from "effect/HashMap";
458
+ import * as Option4 from "effect/Option";
459
+ import { CommandConfig as CommandConfig3 } from "@dxos/cli-util";
460
+ import { flushAndSync as flushAndSync3, print as print3, spaceLayer as spaceLayer3, withTypes as withTypes3 } from "@dxos/cli-util";
461
+ import { Common as Common3 } from "@dxos/cli-util";
462
+ import { Operation as Operation4, Trigger as Trigger4 } from "@dxos/compute";
463
+ import { Database as Database4, Filter as Filter4, JsonSchema as JsonSchema3, Ref as Ref4 } from "@dxos/echo";
464
+ var timer = Command3.make("timer", {
465
+ spaceId: Common3.spaceId.pipe(Options4.optional),
466
+ enabled: Enabled,
467
+ functionId: Common3.functionId.pipe(Options4.optional),
468
+ cron: Cron.pipe(Options4.optional),
469
+ input: Input.pipe(Options4.optional)
470
+ }, (options) => Effect4.gen(function* () {
471
+ const { json } = yield* CommandConfig3;
472
+ const functionId = yield* Option4.match(options.functionId, {
473
+ onNone: () => selectFunction(),
474
+ onSome: (id) => Effect4.succeed(id)
475
+ });
476
+ const functions = yield* Database4.runQuery(Filter4.type(Operation4.PersistentOperation));
477
+ const fn6 = functions.find((fn7) => fn7.id === functionId);
478
+ if (!fn6) {
479
+ return yield* Effect4.fail(new Error(`Function not found: ${functionId}`));
480
+ }
481
+ const cron = yield* Option4.match(options.cron, {
482
+ onNone: () => Prompt4.text({
483
+ message: "Enter cron expression:"
484
+ }).pipe(Prompt4.run),
485
+ onSome: (value2) => Effect4.succeed(value2)
486
+ });
487
+ const input = yield* Option4.match(options.input, {
488
+ onNone: () => promptForSchemaInput(fn6.inputSchema ? JsonSchema3.toEffectSchema(fn6.inputSchema) : void 0),
489
+ onSome: (value2) => Effect4.succeed(Object.fromEntries(HashMap3.toEntries(value2)))
490
+ });
491
+ const enabled = yield* Option4.match(options.functionId, {
492
+ onNone: () => Prompt4.confirm({
493
+ message: "Enable the trigger?",
494
+ initial: true
495
+ }).pipe(Prompt4.run),
496
+ onSome: () => Effect4.succeed(options.enabled)
497
+ });
498
+ const trigger2 = Trigger4.make({
499
+ function: Ref4.make(fn6),
500
+ enabled,
501
+ spec: Trigger4.specTimer(cron),
502
+ input
503
+ });
504
+ yield* Database4.add(trigger2);
505
+ if (json) {
506
+ yield* Console4.log(JSON.stringify(trigger2, null, 2));
507
+ } else {
508
+ yield* Console4.log(print3(yield* printTrigger(trigger2)));
509
+ }
510
+ yield* flushAndSync3({
511
+ indexes: true
512
+ });
513
+ })).pipe(Command3.withDescription("Create a timer trigger."), Command3.provide(({ spaceId }) => spaceLayer3(spaceId, true)), Command3.provideEffectDiscard(() => withTypes3(Operation4.PersistentOperation, Trigger4.Trigger)));
514
+
515
+ // src/commands/trigger/create/index.ts
516
+ var create = Command4.make("create").pipe(Command4.withDescription("Create a trigger."), Command4.withSubcommands([
517
+ subscription,
518
+ timer,
519
+ queue
520
+ ]));
521
+
522
+ // src/commands/trigger/list.ts
523
+ import * as Command5 from "@effect/cli/Command";
524
+ import * as Options5 from "@effect/cli/Options";
525
+ import * as Console5 from "effect/Console";
526
+ import * as Effect5 from "effect/Effect";
527
+ import { CommandConfig as CommandConfig4, Common as Common4, printList, spaceIdWithDefault, spaceLayer as spaceLayer4 } from "@dxos/cli-util";
528
+ import { ClientService } from "@dxos/client";
529
+ import { Trigger as Trigger5 } from "@dxos/compute";
530
+ import { Context } from "@dxos/context";
531
+ import { Database as Database5, Filter as Filter5, Query as Query3 } from "@dxos/echo";
532
+ var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-automation/src/commands/trigger/list.ts";
533
+ var list = Command5.make("list", {
534
+ spaceId: Common4.spaceId.pipe(Options5.optional)
535
+ }, Effect5.fn(function* ({ spaceId: spaceIdOption }) {
536
+ const { json } = yield* CommandConfig4;
537
+ const triggers = yield* Database5.runQuery(Query3.select(Filter5.type(Trigger5.Trigger)).debugLabel("cli.trigger.list"));
538
+ const remoteCronIds = yield* Effect5.gen(function* () {
539
+ const client = yield* ClientService;
540
+ const spaceId = yield* spaceIdWithDefault(spaceIdOption);
541
+ const result = yield* Effect5.promise(() => client.edge.http.getCronTriggers(Context.default(void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 24 }), spaceId)).pipe(Effect5.catchAll(() => Effect5.succeed({
542
+ cronIds: []
543
+ })));
544
+ return result.cronIds;
545
+ });
546
+ const triggersWithStatus = triggers.map((trigger2) => ({
547
+ trigger: trigger2,
548
+ remoteStatus: getTriggerRemoteStatus(trigger2, remoteCronIds)
549
+ }));
550
+ if (json) {
551
+ yield* Console5.log(JSON.stringify(triggersWithStatus.map(({ trigger: trigger2, remoteStatus }) => ({
552
+ ...trigger2,
553
+ remoteStatus
554
+ })), null, 2));
555
+ } else {
556
+ if (triggersWithStatus.length === 0) {
557
+ yield* Console5.log("No triggers found.");
558
+ } else {
559
+ const items = yield* Effect5.all(triggersWithStatus.map(({ trigger: trigger2, remoteStatus }) => printTrigger(trigger2, remoteStatus)));
560
+ yield* Console5.log(printList(items));
561
+ }
562
+ }
563
+ })).pipe(Command5.withDescription("List triggers configured on EDGE."), Command5.provide(({ spaceId }) => spaceLayer4(spaceId, true)));
564
+
565
+ // src/commands/trigger/remove.ts
566
+ import * as Command6 from "@effect/cli/Command";
567
+ import * as Options6 from "@effect/cli/Options";
568
+ import * as Console6 from "effect/Console";
569
+ import * as Effect6 from "effect/Effect";
570
+ import * as Option5 from "effect/Option";
571
+ import { CommandConfig as CommandConfig5, Common as Common5, print as print4, spaceLayer as spaceLayer5, withTypes as withTypes4 } from "@dxos/cli-util";
572
+ import { Trigger as Trigger6 } from "@dxos/compute";
573
+ import { Database as Database6, Ref as Ref5 } from "@dxos/echo";
574
+ import { EchoURI as EchoURI2 } from "@dxos/keys";
575
+ var remove = Command6.make("remove", {
576
+ spaceId: Common5.spaceId.pipe(Options6.optional),
577
+ id: TriggerId.pipe(Options6.optional)
578
+ }, (options) => Effect6.gen(function* () {
579
+ const { json } = yield* CommandConfig5;
580
+ const triggerId = yield* Option5.match(options.id, {
581
+ onNone: () => selectTrigger(),
582
+ onSome: (id) => Effect6.succeed(id)
583
+ });
584
+ const dxn = EchoURI2.make({
585
+ objectId: triggerId
586
+ });
587
+ const trigger2 = yield* Database6.resolve(Ref5.fromURI(dxn), Trigger6.Trigger);
588
+ yield* Database6.remove(trigger2);
589
+ if (json) {
590
+ yield* Console6.log(JSON.stringify({
591
+ id: trigger2.id,
592
+ removed: true
593
+ }, null, 2));
594
+ } else {
595
+ yield* Console6.log(print4(printTriggerRemoved(trigger2.id)));
596
+ }
597
+ })).pipe(Command6.withDescription("Remove a trigger."), Command6.provide(({ spaceId }) => spaceLayer5(spaceId, true)), Command6.provideEffectDiscard(() => withTypes4(Trigger6.Trigger)));
598
+
599
+ // src/commands/trigger/update/index.ts
600
+ import * as Command10 from "@effect/cli/Command";
601
+
602
+ // src/commands/trigger/update/queue.ts
603
+ import * as Command7 from "@effect/cli/Command";
604
+ import * as Options7 from "@effect/cli/Options";
605
+ import * as Prompt5 from "@effect/cli/Prompt";
606
+ import * as Console7 from "effect/Console";
607
+ import * as Effect7 from "effect/Effect";
608
+ import * as Option6 from "effect/Option";
609
+ import { CommandConfig as CommandConfig6 } from "@dxos/cli-util";
610
+ import { flushAndSync as flushAndSync4, print as print5, spaceLayer as spaceLayer6, withTypes as withTypes5 } from "@dxos/cli-util";
611
+ import { Common as Common6 } from "@dxos/cli-util";
612
+ import { Operation as Operation5, Trigger as Trigger7 } from "@dxos/compute";
613
+ import { Database as Database7, Feed as FeedNs2, Filter as Filter6, JsonSchema as JsonSchema4, Obj as Obj2, Ref as Ref6 } from "@dxos/echo";
614
+ import { EchoURI as EchoURI3 } from "@dxos/keys";
615
+ var queue2 = Command7.make("feed", {
616
+ spaceId: Common6.spaceId.pipe(Options7.optional),
617
+ id: TriggerId.pipe(Options7.optional),
618
+ enabled: Enabled,
619
+ functionId: Common6.functionId.pipe(Options7.optional),
620
+ feed: Feed.pipe(Options7.optional),
621
+ input: Input.pipe(Options7.optional)
622
+ }, (options) => Effect7.gen(function* () {
623
+ const { json } = yield* CommandConfig6;
624
+ const triggerId = yield* Option6.match(options.id, {
625
+ onNone: () => selectTrigger("feed"),
626
+ onSome: (id) => Effect7.succeed(id)
627
+ });
628
+ const dxn = EchoURI3.make({
629
+ objectId: triggerId
630
+ });
631
+ const trigger2 = yield* Database7.resolve(dxn, Trigger7.Trigger);
632
+ if (trigger2.spec?.kind !== "feed") {
633
+ return yield* Effect7.fail(new Error(`Invalid trigger type: ${trigger2.spec?.kind}`));
634
+ }
635
+ const currentFn = yield* updateFunction(trigger2, options.functionId);
636
+ yield* updateFeed(trigger2, options.feed);
637
+ yield* updateInput(trigger2, currentFn, options.input);
638
+ yield* updateEnabled(trigger2, options.id, options.enabled);
639
+ if (json) {
640
+ yield* Console7.log(JSON.stringify(trigger2, null, 2));
641
+ } else {
642
+ yield* Console7.log(print5(yield* printTrigger(trigger2)));
643
+ }
644
+ yield* flushAndSync4({
645
+ indexes: true
646
+ });
647
+ })).pipe(Command7.withDescription("Update a feed trigger."), Command7.provide(({ spaceId }) => spaceLayer6(spaceId, true)), Command7.provideEffectDiscard(() => withTypes5(Operation5.PersistentOperation, Trigger7.Trigger)));
648
+ var updateFunction = Effect7.fn(function* (trigger2, functionIdOption) {
649
+ let currentFn = trigger2.function ? yield* Database7.load(trigger2.function) : void 0;
650
+ if (currentFn && !Obj2.instanceOf(Operation5.PersistentOperation, currentFn)) {
651
+ currentFn = void 0;
652
+ }
653
+ const currentFunctionName = currentFn ? currentFn.name ?? currentFn.id : void 0;
654
+ const shouldChangeFunction = yield* Option6.match(functionIdOption, {
655
+ onNone: () => Prompt5.confirm({
656
+ message: `Change the function${currentFunctionName ? ` (current: ${currentFunctionName})` : ""}?`,
657
+ initial: false
658
+ }).pipe(Prompt5.run),
659
+ onSome: () => Effect7.succeed(true)
660
+ });
661
+ if (shouldChangeFunction) {
662
+ const functionId = yield* Option6.match(functionIdOption, {
663
+ onNone: () => selectFunction(),
664
+ onSome: (id) => Effect7.succeed(id)
665
+ });
666
+ const functions = yield* Database7.runQuery(Filter6.type(Operation5.PersistentOperation));
667
+ const foundFn = functions.find((fn6) => fn6.id === functionId);
668
+ if (!foundFn || !Obj2.instanceOf(Operation5.PersistentOperation, foundFn)) {
669
+ return yield* Effect7.fail(new Error(`Function not found: ${functionId}`));
670
+ }
671
+ Obj2.update(trigger2, (trigger3) => {
672
+ trigger3.function = Ref6.make(foundFn);
673
+ });
674
+ currentFn = foundFn;
675
+ }
676
+ if (!currentFn) {
677
+ const functionId = (trigger2.function ? trigger2.function.uri.toString() : void 0) ?? "unknown";
678
+ return yield* Effect7.fail(new Error(`Invalid reference for ${functionId}`));
679
+ }
680
+ return currentFn;
681
+ });
682
+ var updateFeed = Effect7.fn(function* (trigger2, feedOption) {
683
+ const currentFeed = trigger2.spec?.kind === "feed" ? trigger2.spec.feed : void 0;
684
+ const currentFeedStr = currentFeed ? currentFeed.uri.toString() : void 0;
685
+ const shouldChangeFeed = yield* Option6.match(feedOption, {
686
+ onNone: () => Prompt5.confirm({
687
+ message: `Change the feed${currentFeedStr ? ` (current: ${currentFeedStr})` : ""}?`,
688
+ initial: false
689
+ }).pipe(Prompt5.run),
690
+ onSome: () => Effect7.succeed(true)
691
+ });
692
+ if (shouldChangeFeed) {
693
+ const feed = yield* Option6.match(feedOption, {
694
+ onNone: () => selectFeed(),
695
+ onSome: (uri) => Database7.resolve(EchoURI3.parse(uri), FeedNs2.Feed)
696
+ });
697
+ Obj2.update(trigger2, (trigger3) => {
698
+ if (trigger3.spec?.kind === "feed") {
699
+ trigger3.spec.feed = Ref6.make(feed);
700
+ }
701
+ });
702
+ }
703
+ });
704
+ var updateInput = Effect7.fn(function* (trigger2, fn6, inputOption) {
705
+ const currentInput = trigger2.input;
706
+ const currentInputStr = currentInput ? JSON.stringify(currentInput) : "none";
707
+ const shouldChangeInput = yield* Option6.match(inputOption, {
708
+ onNone: () => Effect7.gen(function* () {
709
+ yield* Console7.log(`Current input: ${currentInputStr}`);
710
+ return yield* Prompt5.confirm({
711
+ message: "Change input?",
712
+ initial: false
713
+ }).pipe(Prompt5.run);
714
+ }),
715
+ onSome: () => Effect7.succeed(true)
716
+ });
717
+ if (shouldChangeInput) {
718
+ const inputObj = yield* Option6.match(inputOption, {
719
+ onNone: () => promptForSchemaInput(fn6.inputSchema ? JsonSchema4.toEffectSchema(fn6.inputSchema) : void 0, currentInput),
720
+ onSome: (value2) => Effect7.succeed(value2)
721
+ });
722
+ Obj2.update(trigger2, (trigger3) => {
723
+ trigger3.input = inputObj;
724
+ });
725
+ }
726
+ });
727
+ var updateEnabled = Effect7.fn(function* (trigger2, idOption, enabled) {
728
+ const enabledValue = yield* Option6.match(idOption, {
729
+ onNone: () => Prompt5.confirm({
730
+ message: "Enable the trigger?",
731
+ initial: trigger2.enabled
732
+ }).pipe(Prompt5.run),
733
+ onSome: () => Effect7.succeed(enabled)
734
+ });
735
+ Obj2.update(trigger2, (trigger3) => {
736
+ trigger3.enabled = enabledValue;
737
+ });
738
+ });
739
+
740
+ // src/commands/trigger/update/subscription.ts
741
+ import * as Command8 from "@effect/cli/Command";
742
+ import * as Options8 from "@effect/cli/Options";
743
+ import * as Prompt6 from "@effect/cli/Prompt";
744
+ import * as Console8 from "effect/Console";
745
+ import * as Effect8 from "effect/Effect";
746
+ import * as Match2 from "effect/Match";
747
+ import * as Option7 from "effect/Option";
748
+ import { CommandConfig as CommandConfig7 } from "@dxos/cli-util";
749
+ import { flushAndSync as flushAndSync5, print as print6, spaceLayer as spaceLayer7, withTypes as withTypes6 } from "@dxos/cli-util";
750
+ import { Common as Common7 } from "@dxos/cli-util";
751
+ import { Operation as Operation6, Trigger as Trigger8 } from "@dxos/compute";
752
+ import { Database as Database8, Filter as Filter7, JsonSchema as JsonSchema5, Obj as Obj3, Query as Query4, Ref as Ref7 } from "@dxos/echo";
753
+ import { DXN, EchoURI as EchoURI4 } from "@dxos/keys";
754
+ var subscription2 = Command8.make("subscription", {
755
+ spaceId: Common7.spaceId.pipe(Options8.optional),
756
+ id: TriggerId.pipe(Options8.optional),
757
+ enabled: Enabled,
758
+ functionId: Common7.functionId.pipe(Options8.optional),
759
+ typename: Typename.pipe(Options8.optional),
760
+ deep: Deep.pipe(Options8.optional),
761
+ delay: Delay.pipe(Options8.optional),
762
+ input: Input.pipe(Options8.optional)
763
+ }, (options) => Effect8.gen(function* () {
764
+ const { json } = yield* CommandConfig7;
765
+ const triggerId = yield* Option7.match(options.id, {
766
+ onNone: () => selectTrigger("subscription"),
767
+ onSome: (id) => Effect8.succeed(id)
768
+ });
769
+ const dxn = EchoURI4.make({
770
+ objectId: triggerId
771
+ });
772
+ const trigger2 = yield* Database8.resolve(Ref7.fromURI(dxn), Trigger8.Trigger);
773
+ if (trigger2.spec?.kind !== "subscription") {
774
+ return yield* Effect8.fail(new Error(`Invalid trigger type: ${trigger2.spec?.kind}`));
775
+ }
776
+ const currentFn = yield* updateFunction2(trigger2, options.functionId);
777
+ yield* updateSpec(trigger2, options.typename, options.deep, options.delay);
778
+ yield* updateInput2(trigger2, currentFn, options.input);
779
+ yield* updateEnabled2(trigger2, options.id, options.enabled);
780
+ if (json) {
781
+ yield* Console8.log(JSON.stringify(trigger2, null, 2));
782
+ } else {
783
+ yield* Console8.log(print6(yield* printTrigger(trigger2)));
784
+ }
785
+ yield* flushAndSync5({
786
+ indexes: true
787
+ });
788
+ })).pipe(Command8.withDescription("Update a subscription trigger."), Command8.provide(({ spaceId }) => spaceLayer7(spaceId, true)), Command8.provideEffectDiscard(() => withTypes6(Operation6.PersistentOperation, Trigger8.Trigger)));
789
+ var extractCurrentTypename = (spec) => {
790
+ if (!spec?.query?.ast) {
791
+ return Option7.none();
792
+ }
793
+ return Match2.value(spec.query.ast).pipe(Match2.withReturnType(), Match2.when({
794
+ type: "select"
795
+ }, (q) => Match2.value(q.filter).pipe(Match2.withReturnType(), Match2.when({
796
+ type: "object"
797
+ }, (f) => Option7.fromNullable(f.typename).pipe(Option7.flatMap((dxn) => Option7.fromNullable(DXN.isDXN(dxn) ? DXN.getName(dxn) : void 0)))), Match2.orElse(() => Option7.none()))), Match2.orElse(() => Option7.none()));
798
+ };
799
+ var updateFunction2 = Effect8.fn(function* (trigger2, functionIdOption) {
800
+ let currentFn = trigger2.function ? yield* Database8.load(trigger2.function) : void 0;
801
+ if (currentFn && !Obj3.instanceOf(Operation6.PersistentOperation, currentFn)) {
802
+ currentFn = void 0;
803
+ }
804
+ const currentFunctionName = currentFn ? currentFn.name ?? currentFn.id : void 0;
805
+ const shouldChangeFunction = yield* Option7.match(functionIdOption, {
806
+ onNone: () => Prompt6.confirm({
807
+ message: `Change the function${currentFunctionName ? ` (current: ${currentFunctionName})` : ""}?`,
808
+ initial: false
809
+ }).pipe(Prompt6.run),
810
+ onSome: () => Effect8.succeed(true)
811
+ });
812
+ if (shouldChangeFunction) {
813
+ const functionId = yield* Option7.match(functionIdOption, {
814
+ onNone: () => selectFunction(),
815
+ onSome: (id) => Effect8.succeed(id)
816
+ });
817
+ const functions = yield* Database8.runQuery(Filter7.type(Operation6.PersistentOperation));
818
+ const foundFn = functions.find((fn6) => fn6.id === functionId);
819
+ if (!foundFn || !Obj3.instanceOf(Operation6.PersistentOperation, foundFn)) {
820
+ return yield* Effect8.fail(new Error(`Function not found: ${functionId}`));
821
+ }
822
+ Obj3.update(trigger2, (trigger3) => {
823
+ trigger3.function = Ref7.make(foundFn);
824
+ });
825
+ currentFn = foundFn;
826
+ }
827
+ if (!currentFn) {
828
+ const functionId = (trigger2.function ? EchoURI4.getObjectId(EchoURI4.tryParse(trigger2.function.uri)) : void 0) ?? "unknown";
829
+ return yield* Effect8.fail(new Error(`Invalid reference for ${functionId}`));
830
+ }
831
+ return currentFn;
832
+ });
833
+ var updateSpec = Effect8.fn(function* (trigger2, typenameOption, deepOption, delayOption) {
834
+ const currentSpec = trigger2.spec?.kind === "subscription" ? trigger2.spec : void 0;
835
+ const currentTypename = extractCurrentTypename(currentSpec);
836
+ const currentTypenameStr = Option7.getOrUndefined(currentTypename);
837
+ const currentDeep = currentSpec?.options?.deep;
838
+ const currentDelay = currentSpec?.options?.delay;
839
+ const specParts = [];
840
+ if (currentTypenameStr) {
841
+ specParts.push(`typename: ${currentTypenameStr}`);
842
+ }
843
+ if (currentDeep !== void 0) {
844
+ specParts.push(`deep: ${currentDeep}`);
845
+ }
846
+ if (currentDelay !== void 0) {
847
+ specParts.push(`delay: ${currentDelay}`);
848
+ }
849
+ const currentSpecStr = specParts.length > 0 ? specParts.join(", ") : "none";
850
+ const hasSpecOption = Option7.isSome(typenameOption) || Option7.isSome(deepOption) || Option7.isSome(delayOption);
851
+ const shouldChangeSpec = yield* hasSpecOption ? Effect8.succeed(true) : Prompt6.confirm({
852
+ message: `Change the trigger spec (current: ${currentSpecStr})?`,
853
+ initial: false
854
+ }).pipe(Prompt6.run);
855
+ if (shouldChangeSpec) {
856
+ const typename = yield* Option7.match(typenameOption, {
857
+ onNone: () => Prompt6.text({
858
+ message: `Enter type name${currentTypenameStr ? ` (current: ${currentTypenameStr})` : ""}:`
859
+ }).pipe(Prompt6.run),
860
+ onSome: (value2) => Effect8.succeed(value2)
861
+ });
862
+ const queryAst = Query4.select(Filter7.type(typename)).ast;
863
+ const deepOptionValue = yield* Option7.match(deepOption, {
864
+ onNone: () => Prompt6.confirm({
865
+ message: "Watch changes to nested properties (deep)?",
866
+ initial: currentSpec?.options?.deep ?? false
867
+ }).pipe(Prompt6.run, Effect8.map((value2) => value2 ? Option7.some(value2) : Option7.none())),
868
+ onSome: () => Effect8.succeed(Option7.some(true))
869
+ });
870
+ const delayOptionValue = yield* Option7.match(delayOption, {
871
+ onNone: () => Effect8.gen(function* () {
872
+ const currentDelay2 = currentSpec?.options?.delay;
873
+ const delayStr = yield* Prompt6.text({
874
+ message: `Debounce delay in milliseconds (optional, press Enter to skip)${currentDelay2 ? ` (current: ${currentDelay2})` : ""}:`
875
+ }).pipe(Prompt6.run);
876
+ return delayStr === "" ? Option7.none() : Option7.some(parseInt(delayStr, 10));
877
+ }),
878
+ onSome: (value2) => Effect8.succeed(Option7.some(value2))
879
+ });
880
+ const subscriptionOptions = {};
881
+ if (Option7.isSome(deepOptionValue)) {
882
+ subscriptionOptions.deep = deepOptionValue.value;
883
+ }
884
+ if (Option7.isSome(delayOptionValue)) {
885
+ subscriptionOptions.delay = delayOptionValue.value;
886
+ }
887
+ Obj3.update(trigger2, (trigger3) => {
888
+ const spec = trigger3.spec;
889
+ if (spec?.kind === "subscription") {
890
+ spec.query = {
891
+ ast: queryAst
892
+ };
893
+ spec.options = Object.keys(subscriptionOptions).length > 0 ? subscriptionOptions : void 0;
894
+ }
895
+ });
896
+ }
897
+ });
898
+ var updateInput2 = Effect8.fn(function* (trigger2, fn6, inputOption) {
899
+ const currentInput = trigger2.input;
900
+ const currentInputStr = currentInput ? JSON.stringify(currentInput) : "none";
901
+ const shouldChangeInput = yield* Option7.match(inputOption, {
902
+ onNone: () => Effect8.gen(function* () {
903
+ yield* Console8.log(`Current input: ${currentInputStr}`);
904
+ return yield* Prompt6.confirm({
905
+ message: "Change input?",
906
+ initial: false
907
+ }).pipe(Prompt6.run);
908
+ }),
909
+ onSome: () => Effect8.succeed(true)
910
+ });
911
+ if (shouldChangeInput) {
912
+ const inputObj = yield* Option7.match(inputOption, {
913
+ onNone: () => promptForSchemaInput(fn6.inputSchema ? JsonSchema5.toEffectSchema(fn6.inputSchema) : void 0, currentInput),
914
+ onSome: (value2) => Effect8.succeed(value2)
915
+ });
916
+ Obj3.update(trigger2, (trigger3) => {
917
+ trigger3.input = inputObj;
918
+ });
919
+ }
920
+ });
921
+ var updateEnabled2 = Effect8.fn(function* (trigger2, idOption, enabled) {
922
+ const enabledValue = yield* Option7.match(idOption, {
923
+ onNone: () => Prompt6.confirm({
924
+ message: "Enable the trigger?",
925
+ initial: trigger2.enabled
926
+ }).pipe(Prompt6.run),
927
+ onSome: () => Effect8.succeed(enabled)
928
+ });
929
+ Obj3.update(trigger2, (trigger3) => {
930
+ trigger3.enabled = enabledValue;
931
+ });
932
+ });
933
+
934
+ // src/commands/trigger/update/timer.ts
935
+ import * as Command9 from "@effect/cli/Command";
936
+ import * as Options9 from "@effect/cli/Options";
937
+ import * as Prompt7 from "@effect/cli/Prompt";
938
+ import * as Console9 from "effect/Console";
939
+ import * as Effect9 from "effect/Effect";
940
+ import * as Option8 from "effect/Option";
941
+ import { CommandConfig as CommandConfig8 } from "@dxos/cli-util";
942
+ import { flushAndSync as flushAndSync6, print as print7, spaceLayer as spaceLayer8, withTypes as withTypes7 } from "@dxos/cli-util";
943
+ import { Common as Common8 } from "@dxos/cli-util";
944
+ import { Operation as Operation7, Trigger as Trigger9 } from "@dxos/compute";
945
+ import { Database as Database9, Filter as Filter8, JsonSchema as JsonSchema6, Obj as Obj4, Ref as Ref8 } from "@dxos/echo";
946
+ import { EchoURI as EchoURI5 } from "@dxos/keys";
947
+ var timer2 = Command9.make("timer", {
948
+ spaceId: Common8.spaceId.pipe(Options9.optional),
949
+ id: TriggerId.pipe(Options9.optional),
950
+ enabled: Enabled,
951
+ functionId: Common8.functionId.pipe(Options9.optional),
952
+ cron: Cron.pipe(Options9.optional),
953
+ input: Input.pipe(Options9.optional)
954
+ }, (options) => Effect9.gen(function* () {
955
+ const { json } = yield* CommandConfig8;
956
+ const triggerId = yield* Option8.match(options.id, {
957
+ onNone: () => selectTrigger("timer"),
958
+ onSome: (id) => Effect9.succeed(id)
959
+ });
960
+ const dxn = EchoURI5.make({
961
+ objectId: triggerId
962
+ });
963
+ const trigger2 = yield* Database9.resolve(Ref8.fromURI(dxn), Trigger9.Trigger);
964
+ if (!trigger2.spec || trigger2.spec?.kind !== "timer") {
965
+ return yield* Effect9.fail(new Error(`Invalid trigger type: ${trigger2.spec?.kind}`));
966
+ }
967
+ const currentFn = yield* updateFunction3(trigger2, options.functionId);
968
+ yield* updateCron(trigger2, options.cron);
969
+ yield* updateInput3(trigger2, currentFn, options.input);
970
+ yield* updateEnabled3(trigger2, options.id, options.enabled);
971
+ if (json) {
972
+ yield* Console9.log(JSON.stringify(trigger2, null, 2));
973
+ } else {
974
+ yield* Console9.log(print7(yield* printTrigger(trigger2)));
975
+ }
976
+ yield* flushAndSync6({
977
+ indexes: true
978
+ });
979
+ })).pipe(Command9.withDescription("Update a timer trigger."), Command9.provide(({ spaceId }) => spaceLayer8(spaceId, true)), Command9.provideEffectDiscard(() => withTypes7(Operation7.PersistentOperation, Trigger9.Trigger)));
980
+ var updateFunction3 = Effect9.fn(function* (trigger2, functionIdOption) {
981
+ let currentFn = trigger2.function ? yield* Database9.load(trigger2.function) : void 0;
982
+ if (currentFn && !Obj4.instanceOf(Operation7.PersistentOperation, currentFn)) {
983
+ currentFn = void 0;
984
+ }
985
+ const currentFunctionName = currentFn ? currentFn.name ?? currentFn.id : void 0;
986
+ const shouldChangeFunction = yield* Option8.match(functionIdOption, {
987
+ onNone: () => Prompt7.confirm({
988
+ message: `Change the function${currentFunctionName ? ` (current: ${currentFunctionName})` : ""}?`,
989
+ initial: false
990
+ }).pipe(Prompt7.run),
991
+ onSome: () => Effect9.succeed(true)
992
+ });
993
+ if (shouldChangeFunction) {
994
+ const functionId = yield* Option8.match(functionIdOption, {
995
+ onNone: () => selectFunction(),
996
+ onSome: (id) => Effect9.succeed(id)
997
+ });
998
+ const functions = yield* Database9.runQuery(Filter8.type(Operation7.PersistentOperation));
999
+ const foundFn = functions.find((fn6) => fn6.id === functionId);
1000
+ if (!foundFn || !Obj4.instanceOf(Operation7.PersistentOperation, foundFn)) {
1001
+ return yield* Effect9.fail(new Error(`Function not found: ${functionId}`));
1002
+ }
1003
+ Obj4.update(trigger2, (trigger3) => {
1004
+ trigger3.function = Ref8.make(foundFn);
1005
+ });
1006
+ currentFn = foundFn;
1007
+ }
1008
+ if (!currentFn) {
1009
+ const functionId = (trigger2.function ? EchoURI5.getObjectId(EchoURI5.tryParse(trigger2.function.uri)) : void 0) ?? "unknown";
1010
+ return yield* Effect9.fail(new Error(`Invalid reference for ${functionId}`));
1011
+ }
1012
+ return currentFn;
1013
+ });
1014
+ var updateCron = Effect9.fn(function* (trigger2, cronOption) {
1015
+ const currentCron = trigger2.spec?.kind === "timer" ? trigger2.spec.cron : void 0;
1016
+ const shouldChangeCron = yield* Option8.match(cronOption, {
1017
+ onNone: () => Prompt7.confirm({
1018
+ message: `Change the cron expression${currentCron ? ` (current: ${currentCron})` : ""}?`,
1019
+ initial: false
1020
+ }).pipe(Prompt7.run),
1021
+ onSome: () => Effect9.succeed(true)
1022
+ });
1023
+ if (shouldChangeCron) {
1024
+ const cron = yield* Option8.match(cronOption, {
1025
+ onNone: () => Prompt7.text({
1026
+ message: `Enter cron expression${currentCron ? ` (current: ${currentCron})` : ""}:`
1027
+ }).pipe(Prompt7.run),
1028
+ onSome: (value2) => Effect9.succeed(value2)
1029
+ });
1030
+ Obj4.update(trigger2, (trigger3) => {
1031
+ if (trigger3.spec?.kind === "timer") {
1032
+ trigger3.spec.cron = cron;
1033
+ }
1034
+ });
1035
+ }
1036
+ });
1037
+ var updateInput3 = Effect9.fn(function* (trigger2, fn6, inputOption) {
1038
+ const currentInput = trigger2.input;
1039
+ const currentInputStr = currentInput ? JSON.stringify(currentInput) : "none";
1040
+ const shouldChangeInput = yield* Option8.match(inputOption, {
1041
+ onNone: () => Effect9.gen(function* () {
1042
+ yield* Console9.log(`Current input: ${currentInputStr}`);
1043
+ return yield* Prompt7.confirm({
1044
+ message: "Change input?",
1045
+ initial: false
1046
+ }).pipe(Prompt7.run);
1047
+ }),
1048
+ onSome: () => Effect9.succeed(true)
1049
+ });
1050
+ if (shouldChangeInput) {
1051
+ const inputObj = yield* Option8.match(inputOption, {
1052
+ onNone: () => promptForSchemaInput(fn6.inputSchema ? JsonSchema6.toEffectSchema(fn6.inputSchema) : void 0, currentInput),
1053
+ onSome: (value2) => Effect9.succeed(value2)
1054
+ });
1055
+ Obj4.update(trigger2, (trigger3) => {
1056
+ trigger3.input = inputObj;
1057
+ });
1058
+ }
1059
+ });
1060
+ var updateEnabled3 = Effect9.fn(function* (trigger2, idOption, enabled) {
1061
+ const enabledValue = yield* Option8.match(idOption, {
1062
+ onNone: () => Prompt7.confirm({
1063
+ message: "Enable the trigger?",
1064
+ initial: trigger2.enabled
1065
+ }).pipe(Prompt7.run),
1066
+ onSome: () => Effect9.succeed(enabled)
1067
+ });
1068
+ Obj4.update(trigger2, (trigger3) => {
1069
+ trigger3.enabled = enabledValue;
1070
+ });
1071
+ });
1072
+
1073
+ // src/commands/trigger/update/index.ts
1074
+ var update = Command10.make("update").pipe(Command10.withDescription("Update a trigger."), Command10.withSubcommands([
1075
+ subscription2,
1076
+ timer2,
1077
+ queue2
1078
+ ]));
1079
+
1080
+ // src/commands/trigger/index.ts
1081
+ var trigger = Command11.make("trigger").pipe(Command11.withDescription("Manage EDGE triggers."), Command11.withSubcommands([
1082
+ create,
1083
+ list,
1084
+ remove,
1085
+ update
1086
+ ]));
1087
+
1088
+ // src/AutomationPlugin.node.ts
1089
+ var AutomationPlugin = Plugin.define(meta).pipe(AppPlugin.addAppGraphModule({
1090
+ activate: AppGraphBuilder
1091
+ }), AppPlugin.addCommandModule({
1092
+ commands: [
1093
+ trigger
1094
+ ]
1095
+ }), AppPlugin.addOperationHandlerModule({
1096
+ activate: OperationHandler
1097
+ }), AppPlugin.addSchemaModule({
1098
+ schema: [
1099
+ Operation8.PersistentOperation,
1100
+ Trigger10.Trigger,
1101
+ Trace.Message
1102
+ ]
1103
+ }), Plugin.addModule({
1104
+ activatesOn: ClientEvents.ClientReady,
1105
+ firesBeforeActivation: [
1106
+ ActivationEvents.SetupProcessManager
1107
+ ],
1108
+ activate: LayerSpecs
1109
+ }), Plugin.addModule({
1110
+ activatesOn: ActivationEvent.allOf(ActivationEvents.ProcessManagerReady, ClientEvents.SpacesReady),
1111
+ activate: TriggerRuntimeController
1112
+ }), Plugin.make);
1113
+ var AutomationPlugin_node_default = AutomationPlugin;
1114
+ export {
1115
+ AutomationPlugin,
1116
+ AutomationPlugin_node_default as default
1117
+ };
1118
+ //# sourceMappingURL=AutomationPlugin.node.mjs.map