@dxos/plugin-automation 0.8.4-main.fffef41 → 0.9.0

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