@dxos/plugin-automation 0.8.4-main.c4373fc → 0.8.4-main.c85a9c8dae

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