@dxos/plugin-automation 0.8.4-main.dedc0f3 → 0.8.4-main.dfabb4ec29

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