@dxos/plugin-automation 0.8.4-main.9735255 → 0.8.4-main.9be5663bfe

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 (261) hide show
  1. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  2. package/dist/lib/browser/chunk-POEIL4RN.mjs +44 -0
  3. package/dist/lib/browser/chunk-POEIL4RN.mjs.map +7 -0
  4. package/dist/lib/browser/{chunk-JOXPQ27I.mjs → chunk-WQLEMRPU.mjs} +9 -38
  5. package/dist/lib/browser/chunk-WQLEMRPU.mjs.map +7 -0
  6. package/dist/lib/browser/cli/index.mjs +122 -107
  7. package/dist/lib/browser/cli/index.mjs.map +3 -3
  8. package/dist/lib/browser/create-trigger-from-template-JZ62EZTB.mjs +77 -0
  9. package/dist/lib/browser/create-trigger-from-template-JZ62EZTB.mjs.map +7 -0
  10. package/dist/lib/browser/hooks/index.mjs +79 -7
  11. package/dist/lib/browser/hooks/index.mjs.map +4 -4
  12. package/dist/lib/browser/index.mjs +60 -92
  13. package/dist/lib/browser/index.mjs.map +4 -4
  14. package/dist/lib/browser/meta.json +1 -1
  15. package/dist/lib/browser/operations/index.mjs +14 -0
  16. package/dist/lib/browser/operations/index.mjs.map +7 -0
  17. package/dist/lib/browser/types/index.mjs +4 -4
  18. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  19. package/dist/lib/node-esm/{chunk-RX52VKI2.mjs → chunk-JWZAVQLF.mjs} +9 -37
  20. package/dist/lib/node-esm/chunk-JWZAVQLF.mjs.map +7 -0
  21. package/dist/lib/node-esm/chunk-SP3P4OUI.mjs +45 -0
  22. package/dist/lib/node-esm/chunk-SP3P4OUI.mjs.map +7 -0
  23. package/dist/lib/node-esm/cli/index.mjs +122 -107
  24. package/dist/lib/node-esm/cli/index.mjs.map +3 -3
  25. package/dist/lib/node-esm/create-trigger-from-template-224Z7WJI.mjs +78 -0
  26. package/dist/lib/node-esm/create-trigger-from-template-224Z7WJI.mjs.map +7 -0
  27. package/dist/lib/node-esm/hooks/index.mjs +79 -7
  28. package/dist/lib/node-esm/hooks/index.mjs.map +4 -4
  29. package/dist/lib/node-esm/index.mjs +60 -92
  30. package/dist/lib/node-esm/index.mjs.map +4 -4
  31. package/dist/lib/node-esm/meta.json +1 -1
  32. package/dist/lib/node-esm/operations/index.mjs +15 -0
  33. package/dist/lib/node-esm/operations/index.mjs.map +7 -0
  34. package/dist/lib/node-esm/types/index.mjs +4 -4
  35. package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
  36. package/dist/types/src/capabilities/app-graph-builder.d.ts +6 -0
  37. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
  38. package/dist/types/src/capabilities/compute-runtime.d.ts +6 -0
  39. package/dist/types/src/capabilities/compute-runtime.d.ts.map +1 -0
  40. package/dist/types/src/capabilities/index.d.ts +6 -4
  41. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  42. package/dist/types/src/capabilities/node.d.ts +3 -0
  43. package/dist/types/src/capabilities/node.d.ts.map +1 -0
  44. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  45. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  46. package/dist/types/src/capabilities/react-surface.d.ts +5 -0
  47. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  48. package/dist/types/src/cli/commands/trigger/create/index.d.ts +1 -1
  49. package/dist/types/src/cli/commands/trigger/create/queue.d.ts +1 -1
  50. package/dist/types/src/cli/commands/trigger/create/queue.d.ts.map +1 -1
  51. package/dist/types/src/cli/commands/trigger/create/subscription.d.ts +1 -1
  52. package/dist/types/src/cli/commands/trigger/create/subscription.d.ts.map +1 -1
  53. package/dist/types/src/cli/commands/trigger/create/timer.d.ts +1 -1
  54. package/dist/types/src/cli/commands/trigger/create/timer.d.ts.map +1 -1
  55. package/dist/types/src/cli/commands/trigger/list.d.ts +1 -1
  56. package/dist/types/src/cli/commands/trigger/list.d.ts.map +1 -1
  57. package/dist/types/src/cli/commands/trigger/remove.d.ts +1 -1
  58. package/dist/types/src/cli/commands/trigger/update/queue.d.ts.map +1 -1
  59. package/dist/types/src/cli/commands/trigger/update/subscription.d.ts.map +1 -1
  60. package/dist/types/src/cli/commands/trigger/update/timer.d.ts.map +1 -1
  61. package/dist/types/src/cli/commands/trigger/util.d.ts +2 -2
  62. package/dist/types/src/cli/commands/trigger/util.d.ts.map +1 -1
  63. package/dist/types/src/cli/plugin.d.ts.map +1 -1
  64. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +3 -4
  65. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
  66. package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts +28 -30
  67. package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
  68. package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts.map +1 -1
  69. package/dist/types/src/components/FunctionsRegistry/FunctionsRegistry.d.ts.map +1 -1
  70. package/dist/types/src/components/FunctionsRegistry/index.d.ts +3 -1
  71. package/dist/types/src/components/FunctionsRegistry/index.d.ts.map +1 -1
  72. package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts +2 -2
  73. package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts.map +1 -1
  74. package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts.map +1 -1
  75. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
  76. package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +91 -91
  77. package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
  78. package/dist/types/src/components/index.d.ts +3 -4
  79. package/dist/types/src/components/index.d.ts.map +1 -1
  80. package/dist/types/src/containers/AutomationSettings/AutomationSettings.d.ts +4 -0
  81. package/dist/types/src/containers/AutomationSettings/AutomationSettings.d.ts.map +1 -0
  82. package/dist/types/src/containers/AutomationSettings/index.d.ts +2 -0
  83. package/dist/types/src/containers/AutomationSettings/index.d.ts.map +1 -0
  84. package/dist/types/src/{components → containers/FunctionsContainer}/FunctionsContainer.d.ts +0 -1
  85. package/dist/types/src/containers/FunctionsContainer/FunctionsContainer.d.ts.map +1 -0
  86. package/dist/types/src/containers/FunctionsContainer/index.d.ts +2 -0
  87. package/dist/types/src/containers/FunctionsContainer/index.d.ts.map +1 -0
  88. package/dist/types/src/containers/TriggerSettings/TriggerSettings.d.ts.map +1 -0
  89. package/dist/types/src/containers/TriggerSettings/index.d.ts +3 -0
  90. package/dist/types/src/containers/TriggerSettings/index.d.ts.map +1 -0
  91. package/dist/types/src/containers/index.d.ts +5 -0
  92. package/dist/types/src/containers/index.d.ts.map +1 -0
  93. package/dist/types/src/hooks/index.d.ts +2 -0
  94. package/dist/types/src/hooks/index.d.ts.map +1 -1
  95. package/dist/types/src/hooks/useComputeRuntime.d.ts +7 -0
  96. package/dist/types/src/hooks/useComputeRuntime.d.ts.map +1 -0
  97. package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts +1 -4
  98. package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts.map +1 -1
  99. package/dist/types/src/hooks/useComputeRuntimeService.d.ts +5 -0
  100. package/dist/types/src/hooks/useComputeRuntimeService.d.ts.map +1 -0
  101. package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts +2 -1
  102. package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts.map +1 -1
  103. package/dist/types/src/index.d.ts +2 -5
  104. package/dist/types/src/index.d.ts.map +1 -1
  105. package/dist/types/src/operations/create-trigger-from-template.d.ts +5 -0
  106. package/dist/types/src/operations/create-trigger-from-template.d.ts.map +1 -0
  107. package/dist/types/src/operations/definitions.d.ts +19 -0
  108. package/dist/types/src/operations/definitions.d.ts.map +1 -0
  109. package/dist/types/src/operations/index.d.ts +4 -0
  110. package/dist/types/src/operations/index.d.ts.map +1 -0
  111. package/dist/types/src/testing/test-functions.d.ts +2 -0
  112. package/dist/types/src/testing/test-functions.d.ts.map +1 -1
  113. package/dist/types/src/translations.d.ts +29 -31
  114. package/dist/types/src/translations.d.ts.map +1 -1
  115. package/dist/types/src/types/capabilities.d.ts +6 -3
  116. package/dist/types/src/types/capabilities.d.ts.map +1 -1
  117. package/dist/types/src/types/schema.d.ts +9 -30
  118. package/dist/types/src/types/schema.d.ts.map +1 -1
  119. package/dist/types/tsconfig.tsbuildinfo +1 -1
  120. package/package.json +73 -46
  121. package/src/AutomationPlugin.tsx +13 -10
  122. package/src/capabilities/app-graph-builder.ts +62 -0
  123. package/src/capabilities/compute-runtime.ts +248 -0
  124. package/src/capabilities/index.ts +10 -4
  125. package/src/capabilities/operation-handler.ts +16 -0
  126. package/src/capabilities/react-surface.tsx +59 -0
  127. package/src/cli/commands/trigger/create/queue.ts +7 -6
  128. package/src/cli/commands/trigger/create/subscription.ts +7 -6
  129. package/src/cli/commands/trigger/create/timer.ts +7 -6
  130. package/src/cli/commands/trigger/list.ts +3 -2
  131. package/src/cli/commands/trigger/remove.ts +2 -2
  132. package/src/cli/commands/trigger/update/queue.ts +21 -21
  133. package/src/cli/commands/trigger/update/subscription.ts +20 -19
  134. package/src/cli/commands/trigger/update/timer.ts +21 -20
  135. package/src/cli/commands/trigger/util.ts +43 -29
  136. package/src/cli/plugin.ts +6 -6
  137. package/src/components/AutomationPanel/AutomationPanel.stories.tsx +10 -8
  138. package/src/components/AutomationPanel/AutomationPanel.tsx +160 -87
  139. package/src/components/FunctionsPanel/FunctionsPanel.tsx +37 -31
  140. package/src/components/FunctionsRegistry/FunctionsRegistry.tsx +27 -24
  141. package/src/components/FunctionsRegistry/index.ts +4 -1
  142. package/src/components/TriggerEditor/FunctionInputEditor.tsx +17 -8
  143. package/src/components/TriggerEditor/SpecSelector.tsx +12 -3
  144. package/src/components/TriggerEditor/TriggerEditor.stories.tsx +56 -13
  145. package/src/components/TriggerEditor/TriggerEditor.tsx +46 -17
  146. package/src/components/index.ts +1 -2
  147. package/src/containers/AutomationSettings/AutomationSettings.tsx +28 -0
  148. package/src/containers/AutomationSettings/index.ts +5 -0
  149. package/src/containers/FunctionsContainer/FunctionsContainer.tsx +34 -0
  150. package/src/containers/FunctionsContainer/index.ts +5 -0
  151. package/src/{components → containers/TriggerSettings}/TriggerSettings.tsx +8 -7
  152. package/src/containers/TriggerSettings/index.ts +6 -0
  153. package/src/containers/index.ts +9 -0
  154. package/src/hooks/index.ts +3 -0
  155. package/src/hooks/useComputeRuntime.ts +16 -0
  156. package/src/hooks/useComputeRuntimeCallback.ts +4 -39
  157. package/src/hooks/useComputeRuntimeService.ts +24 -0
  158. package/src/hooks/useTriggerRuntimeControls.ts +22 -8
  159. package/src/index.ts +2 -6
  160. package/src/meta.ts +2 -2
  161. package/src/operations/create-trigger-from-template.ts +75 -0
  162. package/src/operations/definitions.ts +28 -0
  163. package/src/operations/index.ts +9 -0
  164. package/src/testing/test-functions.ts +8 -5
  165. package/src/translations.ts +35 -36
  166. package/src/types/capabilities.ts +20 -6
  167. package/src/types/events.ts +2 -2
  168. package/src/types/schema.ts +3 -24
  169. package/dist/lib/browser/AutomationPanel-FAS6ADCW.mjs +0 -11
  170. package/dist/lib/browser/AutomationSettings-XN2OIYWL.mjs +0 -56
  171. package/dist/lib/browser/AutomationSettings-XN2OIYWL.mjs.map +0 -7
  172. package/dist/lib/browser/FunctionsContainer-6QLC7JP4.mjs +0 -129
  173. package/dist/lib/browser/FunctionsContainer-6QLC7JP4.mjs.map +0 -7
  174. package/dist/lib/browser/FunctionsPanel-ZX4J75UM.mjs +0 -10
  175. package/dist/lib/browser/app-graph-builder-LAQMEBMH.mjs +0 -84
  176. package/dist/lib/browser/app-graph-builder-LAQMEBMH.mjs.map +0 -7
  177. package/dist/lib/browser/chunk-54PANILA.mjs +0 -14
  178. package/dist/lib/browser/chunk-54PANILA.mjs.map +0 -7
  179. package/dist/lib/browser/chunk-BFUIVUQH.mjs +0 -102
  180. package/dist/lib/browser/chunk-BFUIVUQH.mjs.map +0 -7
  181. package/dist/lib/browser/chunk-BKFQBKYO.mjs +0 -8
  182. package/dist/lib/browser/chunk-BKFQBKYO.mjs.map +0 -7
  183. package/dist/lib/browser/chunk-JOXPQ27I.mjs.map +0 -7
  184. package/dist/lib/browser/chunk-PZNBEKO5.mjs +0 -17
  185. package/dist/lib/browser/chunk-PZNBEKO5.mjs.map +0 -7
  186. package/dist/lib/browser/chunk-QW3EM35H.mjs +0 -248
  187. package/dist/lib/browser/chunk-QW3EM35H.mjs.map +0 -7
  188. package/dist/lib/browser/chunk-RAF2FJST.mjs +0 -86
  189. package/dist/lib/browser/chunk-RAF2FJST.mjs.map +0 -7
  190. package/dist/lib/browser/chunk-YWLEY2FD.mjs +0 -200
  191. package/dist/lib/browser/chunk-YWLEY2FD.mjs.map +0 -7
  192. package/dist/lib/browser/compute-runtime-WTWLQ67J.mjs +0 -114
  193. package/dist/lib/browser/compute-runtime-WTWLQ67J.mjs.map +0 -7
  194. package/dist/lib/browser/operation-resolver-Q3MWOR7K.mjs +0 -82
  195. package/dist/lib/browser/operation-resolver-Q3MWOR7K.mjs.map +0 -7
  196. package/dist/lib/browser/react-surface-EV3AC62F.mjs +0 -65
  197. package/dist/lib/browser/react-surface-EV3AC62F.mjs.map +0 -7
  198. package/dist/lib/node-esm/AutomationPanel-B7NAGDFA.mjs +0 -12
  199. package/dist/lib/node-esm/AutomationPanel-B7NAGDFA.mjs.map +0 -7
  200. package/dist/lib/node-esm/AutomationSettings-M5PMZJ6P.mjs +0 -57
  201. package/dist/lib/node-esm/AutomationSettings-M5PMZJ6P.mjs.map +0 -7
  202. package/dist/lib/node-esm/FunctionsContainer-J4O2ULWR.mjs +0 -130
  203. package/dist/lib/node-esm/FunctionsContainer-J4O2ULWR.mjs.map +0 -7
  204. package/dist/lib/node-esm/FunctionsPanel-SS6GIVNU.mjs +0 -11
  205. package/dist/lib/node-esm/FunctionsPanel-SS6GIVNU.mjs.map +0 -7
  206. package/dist/lib/node-esm/app-graph-builder-4UCMXHYY.mjs +0 -85
  207. package/dist/lib/node-esm/app-graph-builder-4UCMXHYY.mjs.map +0 -7
  208. package/dist/lib/node-esm/chunk-2CKVH7JC.mjs +0 -201
  209. package/dist/lib/node-esm/chunk-2CKVH7JC.mjs.map +0 -7
  210. package/dist/lib/node-esm/chunk-5FXNN3MV.mjs +0 -19
  211. package/dist/lib/node-esm/chunk-5FXNN3MV.mjs.map +0 -7
  212. package/dist/lib/node-esm/chunk-7QRUPEHH.mjs +0 -16
  213. package/dist/lib/node-esm/chunk-7QRUPEHH.mjs.map +0 -7
  214. package/dist/lib/node-esm/chunk-HQLVREIX.mjs +0 -87
  215. package/dist/lib/node-esm/chunk-HQLVREIX.mjs.map +0 -7
  216. package/dist/lib/node-esm/chunk-K7GCM342.mjs +0 -10
  217. package/dist/lib/node-esm/chunk-K7GCM342.mjs.map +0 -7
  218. package/dist/lib/node-esm/chunk-KWKWOGS5.mjs +0 -103
  219. package/dist/lib/node-esm/chunk-KWKWOGS5.mjs.map +0 -7
  220. package/dist/lib/node-esm/chunk-LJAXQ6CX.mjs +0 -249
  221. package/dist/lib/node-esm/chunk-LJAXQ6CX.mjs.map +0 -7
  222. package/dist/lib/node-esm/chunk-RX52VKI2.mjs.map +0 -7
  223. package/dist/lib/node-esm/compute-runtime-ZHROOBLY.mjs +0 -115
  224. package/dist/lib/node-esm/compute-runtime-ZHROOBLY.mjs.map +0 -7
  225. package/dist/lib/node-esm/operation-resolver-R5GA4YNO.mjs +0 -83
  226. package/dist/lib/node-esm/operation-resolver-R5GA4YNO.mjs.map +0 -7
  227. package/dist/lib/node-esm/react-surface-S6VZJCEZ.mjs +0 -66
  228. package/dist/lib/node-esm/react-surface-S6VZJCEZ.mjs.map +0 -7
  229. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +0 -6
  230. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +0 -1
  231. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +0 -3
  232. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +0 -1
  233. package/dist/types/src/capabilities/compute-runtime/compute-runtime.d.ts +0 -6
  234. package/dist/types/src/capabilities/compute-runtime/compute-runtime.d.ts.map +0 -1
  235. package/dist/types/src/capabilities/compute-runtime/index.d.ts +0 -3
  236. package/dist/types/src/capabilities/compute-runtime/index.d.ts.map +0 -1
  237. package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
  238. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
  239. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
  240. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
  241. package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
  242. package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
  243. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
  244. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
  245. package/dist/types/src/components/AutomationSettings.d.ts +0 -5
  246. package/dist/types/src/components/AutomationSettings.d.ts.map +0 -1
  247. package/dist/types/src/components/FunctionsContainer.d.ts.map +0 -1
  248. package/dist/types/src/components/TriggerSettings.d.ts.map +0 -1
  249. package/src/capabilities/app-graph-builder/app-graph-builder.ts +0 -71
  250. package/src/capabilities/app-graph-builder/index.ts +0 -7
  251. package/src/capabilities/compute-runtime/compute-runtime.ts +0 -133
  252. package/src/capabilities/operation-resolver/index.ts +0 -7
  253. package/src/capabilities/operation-resolver/operation-resolver.ts +0 -79
  254. package/src/capabilities/react-surface/index.ts +0 -7
  255. package/src/capabilities/react-surface/react-surface.tsx +0 -60
  256. package/src/components/AutomationSettings.tsx +0 -30
  257. package/src/components/FunctionsContainer.tsx +0 -36
  258. /package/dist/lib/browser/{AutomationPanel-FAS6ADCW.mjs.map → chunk-J5LGTIGS.mjs.map} +0 -0
  259. /package/dist/lib/{browser/FunctionsPanel-ZX4J75UM.mjs.map → node-esm/chunk-HSLMI22Q.mjs.map} +0 -0
  260. /package/dist/types/src/{components → containers/TriggerSettings}/TriggerSettings.d.ts +0 -0
  261. /package/src/capabilities/{compute-runtime/index.ts → node.ts} +0 -0
@@ -13,8 +13,9 @@ import * as Option from 'effect/Option';
13
13
  import { CommandConfig } from '@dxos/cli-util';
14
14
  import { flushAndSync, print, spaceLayer, withTypes } from '@dxos/cli-util';
15
15
  import { Common } from '@dxos/cli-util';
16
- import { Database, Filter, Query, Ref, Type } from '@dxos/echo';
17
- import { Function, Trigger } from '@dxos/functions';
16
+ import { Database, Filter, JsonSchema, Query, Ref } from '@dxos/echo';
17
+ import { Trigger } from '@dxos/functions';
18
+ import { Operation } from '@dxos/operation';
18
19
 
19
20
  import { Deep, Delay, Enabled, Input, Typename } from '../options';
20
21
  import { printTrigger, promptForSchemaInput, selectFunction } from '../util';
@@ -38,7 +39,7 @@ export const subscription = Command.make(
38
39
  onNone: () => selectFunction(),
39
40
  onSome: (id) => Effect.succeed(id),
40
41
  });
41
- const functions = yield* Database.Service.runQuery(Filter.type(Function.Function));
42
+ const functions = yield* Database.runQuery(Filter.type(Operation.PersistentOperation));
42
43
  const fn = functions.find((fn) => fn.id === functionId);
43
44
  if (!fn) {
44
45
  return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
@@ -85,7 +86,7 @@ export const subscription = Command.make(
85
86
  }
86
87
 
87
88
  const input = yield* Option.match(options.input, {
88
- onNone: () => promptForSchemaInput(fn.inputSchema ? Type.toEffectSchema(fn.inputSchema) : undefined),
89
+ onNone: () => promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined),
89
90
  onSome: (value) => Effect.succeed(Object.fromEntries(HashMap.toEntries(value))),
90
91
  });
91
92
 
@@ -111,7 +112,7 @@ export const subscription = Command.make(
111
112
  },
112
113
  input,
113
114
  });
114
- yield* Database.Service.add(trigger);
115
+ yield* Database.add(trigger);
115
116
 
116
117
  if (json) {
117
118
  yield* Console.log(JSON.stringify(trigger, null, 2));
@@ -124,5 +125,5 @@ export const subscription = Command.make(
124
125
  ).pipe(
125
126
  Command.withDescription('Create a subscription trigger.'),
126
127
  Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
127
- Command.provideEffectDiscard(() => withTypes(Function.Function, Trigger.Trigger)),
128
+ Command.provideEffectDiscard(() => withTypes(Operation.PersistentOperation, Trigger.Trigger)),
128
129
  );
@@ -13,8 +13,9 @@ import * as Option from 'effect/Option';
13
13
  import { CommandConfig } from '@dxos/cli-util';
14
14
  import { flushAndSync, print, spaceLayer, withTypes } from '@dxos/cli-util';
15
15
  import { Common } from '@dxos/cli-util';
16
- import { Database, Filter, Ref, Type } from '@dxos/echo';
17
- import { Function, Trigger } from '@dxos/functions';
16
+ import { Database, Filter, JsonSchema, Ref } from '@dxos/echo';
17
+ import { Trigger } from '@dxos/functions';
18
+ import { Operation } from '@dxos/operation';
18
19
 
19
20
  import { Cron, Enabled, Input } from '../options';
20
21
  import { printTrigger, promptForSchemaInput, selectFunction } from '../util';
@@ -37,7 +38,7 @@ export const timer = Command.make(
37
38
  onNone: () => selectFunction(),
38
39
  onSome: (id) => Effect.succeed(id),
39
40
  });
40
- const functions = yield* Database.Service.runQuery(Filter.type(Function.Function));
41
+ const functions = yield* Database.runQuery(Filter.type(Operation.PersistentOperation));
41
42
  const fn = functions.find((fn) => fn.id === functionId);
42
43
  if (!fn) {
43
44
  return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
@@ -52,7 +53,7 @@ export const timer = Command.make(
52
53
  });
53
54
 
54
55
  const input = yield* Option.match(options.input, {
55
- onNone: () => promptForSchemaInput(fn.inputSchema ? Type.toEffectSchema(fn.inputSchema) : undefined),
56
+ onNone: () => promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined),
56
57
  onSome: (value) => Effect.succeed(Object.fromEntries(HashMap.toEntries(value))),
57
58
  });
58
59
 
@@ -76,7 +77,7 @@ export const timer = Command.make(
76
77
  input,
77
78
  });
78
79
 
79
- yield* Database.Service.add(trigger);
80
+ yield* Database.add(trigger);
80
81
 
81
82
  if (json) {
82
83
  yield* Console.log(JSON.stringify(trigger, null, 2));
@@ -89,5 +90,5 @@ export const timer = Command.make(
89
90
  ).pipe(
90
91
  Command.withDescription('Create a timer trigger.'),
91
92
  Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
92
- Command.provideEffectDiscard(() => withTypes(Function.Function, Trigger.Trigger)),
93
+ Command.provideEffectDiscard(() => withTypes(Operation.PersistentOperation, Trigger.Trigger)),
93
94
  );
@@ -9,6 +9,7 @@ import * as Effect from 'effect/Effect';
9
9
 
10
10
  import { CommandConfig, Common, printList, spaceIdWithDefault, spaceLayer } from '@dxos/cli-util';
11
11
  import { ClientService } from '@dxos/client';
12
+ import { Context } from '@dxos/context';
12
13
  import { Database, Filter } from '@dxos/echo';
13
14
  import { Trigger } from '@dxos/functions';
14
15
 
@@ -23,13 +24,13 @@ export const list = Command.make(
23
24
  const { json } = yield* CommandConfig;
24
25
 
25
26
  // Fetch local triggers
26
- const triggers = yield* Database.Service.runQuery(Filter.type(Trigger.Trigger));
27
+ const triggers = yield* Database.runQuery(Filter.type(Trigger.Trigger));
27
28
 
28
29
  // Fetch remote cron triggers to check availability
29
30
  const remoteCronIds = yield* Effect.gen(function* () {
30
31
  const client = yield* ClientService;
31
32
  const spaceId = yield* spaceIdWithDefault(spaceIdOption);
32
- const result = yield* Effect.promise(() => client.edge.getCronTriggers(spaceId)).pipe(
33
+ const result = yield* Effect.promise(() => client.edge.http.getCronTriggers(Context.default(), spaceId)).pipe(
33
34
  Effect.catchAll(() => Effect.succeed({ cronIds: [] })),
34
35
  );
35
36
  return result.cronIds;
@@ -30,8 +30,8 @@ export const remove = Command.make(
30
30
  onSome: (id) => Effect.succeed(id),
31
31
  });
32
32
  const dxn = DXN.fromLocalObjectId(triggerId);
33
- const trigger = yield* Database.Service.resolve(dxn, Trigger.Trigger);
34
- yield* Database.Service.remove(trigger);
33
+ const trigger = yield* Database.resolve(dxn, Trigger.Trigger);
34
+ yield* Database.remove(trigger);
35
35
  if (json) {
36
36
  yield* Console.log(JSON.stringify({ id: trigger.id, removed: true }, null, 2));
37
37
  } else {
@@ -12,8 +12,9 @@ import * as Option from 'effect/Option';
12
12
  import { CommandConfig } from '@dxos/cli-util';
13
13
  import { flushAndSync, print, spaceLayer, withTypes } from '@dxos/cli-util';
14
14
  import { Common } from '@dxos/cli-util';
15
- import { DXN, Database, Filter, Obj, Ref, Type } from '@dxos/echo';
16
- import { Function, Trigger } from '@dxos/functions';
15
+ import { DXN, Database, Filter, JsonSchema, Obj, Ref } from '@dxos/echo';
16
+ import { Trigger } from '@dxos/functions';
17
+ import { Operation } from '@dxos/operation';
17
18
 
18
19
  import { Enabled, Input, Queue, TriggerId } from '../options';
19
20
  import { printTrigger, promptForSchemaInput, selectFunction, selectQueue, selectTrigger } from '../util';
@@ -31,13 +32,12 @@ export const queue = Command.make(
31
32
  (options) =>
32
33
  Effect.gen(function* () {
33
34
  const { json } = yield* CommandConfig;
34
-
35
35
  const triggerId = yield* Option.match(options.id, {
36
36
  onNone: () => selectTrigger('queue'),
37
37
  onSome: (id) => Effect.succeed(id),
38
38
  });
39
39
  const dxn = DXN.fromLocalObjectId(triggerId);
40
- const trigger = yield* Database.Service.resolve(dxn, Trigger.Trigger);
40
+ const trigger = yield* Database.resolve(dxn, Trigger.Trigger);
41
41
  if (trigger.spec?.kind !== 'queue') {
42
42
  return yield* Effect.fail(new Error(`Invalid trigger type: ${trigger.spec?.kind}`));
43
43
  }
@@ -58,7 +58,7 @@ export const queue = Command.make(
58
58
  ).pipe(
59
59
  Command.withDescription('Update a queue trigger.'),
60
60
  Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
61
- Command.provideEffectDiscard(() => withTypes(Function.Function, Trigger.Trigger)),
61
+ Command.provideEffectDiscard(() => withTypes(Operation.PersistentOperation, Trigger.Trigger)),
62
62
  );
63
63
 
64
64
  /**
@@ -67,10 +67,10 @@ export const queue = Command.make(
67
67
  * @returns The current function (either original or newly assigned)
68
68
  */
69
69
  const updateFunction = Effect.fn(function* (trigger: Trigger.Trigger, functionIdOption: Option.Option<string>) {
70
- let currentFn: Function.Function | undefined = trigger.function
71
- ? yield* Database.Service.load(trigger.function) as any
70
+ let currentFn: Operation.PersistentOperation | undefined = trigger.function
71
+ ? yield* Database.load(trigger.function) as any
72
72
  : undefined;
73
- if (currentFn && !Obj.instanceOf(Function.Function, currentFn)) {
73
+ if (currentFn && !Obj.instanceOf(Operation.PersistentOperation, currentFn)) {
74
74
  currentFn = undefined;
75
75
  }
76
76
  const currentFunctionName = currentFn ? (currentFn.name ?? currentFn.id) : undefined;
@@ -87,13 +87,13 @@ const updateFunction = Effect.fn(function* (trigger: Trigger.Trigger, functionId
87
87
  onNone: () => selectFunction(),
88
88
  onSome: (id) => Effect.succeed(id),
89
89
  });
90
- const functions = yield* Database.Service.runQuery(Filter.type(Function.Function));
90
+ const functions = yield* Database.runQuery(Filter.type(Operation.PersistentOperation));
91
91
  const foundFn = functions.find((fn) => fn.id === functionId);
92
- if (!foundFn || !Obj.instanceOf(Function.Function, foundFn)) {
92
+ if (!foundFn || !Obj.instanceOf(Operation.PersistentOperation, foundFn)) {
93
93
  return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
94
94
  }
95
- Obj.change(trigger, (mutableTrigger) => {
96
- mutableTrigger.function = Ref.make(foundFn);
95
+ Obj.change(trigger, (trigger) => {
96
+ trigger.function = Ref.make(foundFn);
97
97
  });
98
98
  currentFn = foundFn;
99
99
  }
@@ -130,9 +130,9 @@ const updateQueue = Effect.fn(function* (trigger: Trigger.Trigger, queueOption:
130
130
  onNone: () => selectQueue(),
131
131
  onSome: (dxn) => Effect.succeed(dxn.toString()),
132
132
  });
133
- Obj.change(trigger, (mutableTrigger) => {
134
- if (mutableTrigger.spec?.kind === 'queue') {
135
- mutableTrigger.spec.queue = queueDxn;
133
+ Obj.change(trigger, (trigger) => {
134
+ if (trigger.spec?.kind === 'queue') {
135
+ trigger.spec.queue = queueDxn;
136
136
  }
137
137
  });
138
138
  }
@@ -144,7 +144,7 @@ const updateQueue = Effect.fn(function* (trigger: Trigger.Trigger, queueOption:
144
144
  */
145
145
  const updateInput = Effect.fn(function* (
146
146
  trigger: Trigger.Trigger,
147
- fn: Function.Function,
147
+ fn: Operation.PersistentOperation,
148
148
  inputOption: Option.Option<Record<string, any>>,
149
149
  ) {
150
150
  const currentInput = trigger.input as Record<string, any> | undefined;
@@ -163,11 +163,11 @@ const updateInput = Effect.fn(function* (
163
163
  if (shouldChangeInput) {
164
164
  const inputObj = yield* Option.match(inputOption, {
165
165
  onNone: () =>
166
- promptForSchemaInput(fn.inputSchema ? Type.toEffectSchema(fn.inputSchema) : undefined, currentInput),
166
+ promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined, currentInput),
167
167
  onSome: (value) => Effect.succeed(value as Record<string, any>),
168
168
  });
169
- Obj.change(trigger, (mutableTrigger) => {
170
- mutableTrigger.input = inputObj;
169
+ Obj.change(trigger, (trigger) => {
170
+ trigger.input = inputObj;
171
171
  });
172
172
  }
173
173
  });
@@ -189,7 +189,7 @@ const updateEnabled = Effect.fn(function* (
189
189
  }).pipe(Prompt.run),
190
190
  onSome: () => Effect.succeed(enabled),
191
191
  });
192
- Obj.change(trigger, (mutableTrigger) => {
193
- mutableTrigger.enabled = enabledValue;
192
+ Obj.change(trigger, (trigger) => {
193
+ trigger.enabled = enabledValue;
194
194
  });
195
195
  });
@@ -13,8 +13,9 @@ import * as Option from 'effect/Option';
13
13
  import { CommandConfig } from '@dxos/cli-util';
14
14
  import { flushAndSync, print, spaceLayer, withTypes } from '@dxos/cli-util';
15
15
  import { Common } from '@dxos/cli-util';
16
- import { DXN, Database, Filter, Obj, Query, Ref, Type } from '@dxos/echo';
17
- import { Function, Trigger } from '@dxos/functions';
16
+ import { DXN, Database, Filter, JsonSchema, Obj, Query, Ref } from '@dxos/echo';
17
+ import { Trigger } from '@dxos/functions';
18
+ import { Operation } from '@dxos/operation';
18
19
 
19
20
  import { Deep, Delay, Enabled, Input, TriggerId, Typename } from '../options';
20
21
  import { printTrigger, promptForSchemaInput, selectFunction, selectTrigger } from '../util';
@@ -40,7 +41,7 @@ export const subscription = Command.make(
40
41
  onSome: (id) => Effect.succeed(id),
41
42
  });
42
43
  const dxn = DXN.fromLocalObjectId(triggerId);
43
- const trigger = yield* Database.Service.resolve(dxn, Trigger.Trigger);
44
+ const trigger = yield* Database.resolve(dxn, Trigger.Trigger);
44
45
  if (trigger.spec?.kind !== 'subscription') {
45
46
  return yield* Effect.fail(new Error(`Invalid trigger type: ${trigger.spec?.kind}`));
46
47
  }
@@ -61,7 +62,7 @@ export const subscription = Command.make(
61
62
  ).pipe(
62
63
  Command.withDescription('Update a subscription trigger.'),
63
64
  Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
64
- Command.provideEffectDiscard(() => withTypes(Function.Function, Trigger.Trigger)),
65
+ Command.provideEffectDiscard(() => withTypes(Operation.PersistentOperation, Trigger.Trigger)),
65
66
  );
66
67
 
67
68
  /**
@@ -95,10 +96,10 @@ const extractCurrentTypename = (spec: Trigger.SubscriptionSpec | undefined): Opt
95
96
  * @returns The current function (either original or newly assigned)
96
97
  */
97
98
  const updateFunction = Effect.fn(function* (trigger: Trigger.Trigger, functionIdOption: Option.Option<string>) {
98
- let currentFn: Function.Function | undefined = trigger.function
99
- ? yield* Database.Service.load(trigger.function) as any
99
+ let currentFn: Operation.PersistentOperation | undefined = trigger.function
100
+ ? yield* Database.load(trigger.function) as any
100
101
  : undefined;
101
- if (currentFn && !Obj.instanceOf(Function.Function, currentFn)) {
102
+ if (currentFn && !Obj.instanceOf(Operation.PersistentOperation, currentFn)) {
102
103
  currentFn = undefined;
103
104
  }
104
105
  const currentFunctionName = currentFn ? (currentFn.name ?? currentFn.id) : undefined;
@@ -115,13 +116,13 @@ const updateFunction = Effect.fn(function* (trigger: Trigger.Trigger, functionId
115
116
  onNone: () => selectFunction(),
116
117
  onSome: (id) => Effect.succeed(id),
117
118
  });
118
- const functions = yield* Database.Service.runQuery(Filter.type(Function.Function));
119
+ const functions = yield* Database.runQuery(Filter.type(Operation.PersistentOperation));
119
120
  const foundFn = functions.find((fn) => fn.id === functionId);
120
- if (!foundFn || !Obj.instanceOf(Function.Function, foundFn)) {
121
+ if (!foundFn || !Obj.instanceOf(Operation.PersistentOperation, foundFn)) {
121
122
  return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
122
123
  }
123
- Obj.change(trigger, (mutableTrigger) => {
124
- mutableTrigger.function = Ref.make(foundFn);
124
+ Obj.change(trigger, (trigger) => {
125
+ trigger.function = Ref.make(foundFn);
125
126
  });
126
127
  currentFn = foundFn;
127
128
  }
@@ -210,8 +211,8 @@ const updateSpec = Effect.fn(function* (
210
211
  subscriptionOptions.delay = delayOptionValue.value;
211
212
  }
212
213
 
213
- Obj.change(trigger, (mutableTrigger) => {
214
- const spec = mutableTrigger.spec;
214
+ Obj.change(trigger, (trigger) => {
215
+ const spec = trigger.spec;
215
216
  if (spec?.kind === 'subscription') {
216
217
  // Cast needed because QueryAST types are deeply readonly but spec.query expects mutable.
217
218
  spec.query = { ast: queryAst } as NonNullable<typeof spec.query>;
@@ -227,7 +228,7 @@ const updateSpec = Effect.fn(function* (
227
228
  */
228
229
  const updateInput = Effect.fn(function* (
229
230
  trigger: Trigger.Trigger,
230
- fn: Function.Function,
231
+ fn: Operation.PersistentOperation,
231
232
  inputOption: Option.Option<Record<string, any>>,
232
233
  ) {
233
234
  const currentInput = trigger.input as Record<string, any> | undefined;
@@ -246,11 +247,11 @@ const updateInput = Effect.fn(function* (
246
247
  if (shouldChangeInput) {
247
248
  const inputObj = yield* Option.match(inputOption, {
248
249
  onNone: () =>
249
- promptForSchemaInput(fn.inputSchema ? Type.toEffectSchema(fn.inputSchema) : undefined, currentInput),
250
+ promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined, currentInput),
250
251
  onSome: (value) => Effect.succeed(value as Record<string, any>),
251
252
  });
252
- Obj.change(trigger, (mutableTrigger) => {
253
- mutableTrigger.input = inputObj;
253
+ Obj.change(trigger, (trigger) => {
254
+ trigger.input = inputObj;
254
255
  });
255
256
  }
256
257
  });
@@ -272,7 +273,7 @@ const updateEnabled = Effect.fn(function* (
272
273
  }).pipe(Prompt.run),
273
274
  onSome: () => Effect.succeed(enabled),
274
275
  });
275
- Obj.change(trigger, (mutableTrigger) => {
276
- mutableTrigger.enabled = enabledValue;
276
+ Obj.change(trigger, (trigger) => {
277
+ trigger.enabled = enabledValue;
277
278
  });
278
279
  });
@@ -12,8 +12,9 @@ import * as Option from 'effect/Option';
12
12
  import { CommandConfig } from '@dxos/cli-util';
13
13
  import { flushAndSync, print, spaceLayer, withTypes } from '@dxos/cli-util';
14
14
  import { Common } from '@dxos/cli-util';
15
- import { DXN, Database, Filter, Obj, Ref, Type } from '@dxos/echo';
16
- import { Function, Trigger } from '@dxos/functions';
15
+ import { DXN, Database, Filter, JsonSchema, Obj, Ref } from '@dxos/echo';
16
+ import { Trigger } from '@dxos/functions';
17
+ import { Operation } from '@dxos/operation';
17
18
 
18
19
  import { Cron, Enabled, Input, TriggerId } from '../options';
19
20
  import { printTrigger, promptForSchemaInput, selectFunction, selectTrigger } from '../util';
@@ -37,7 +38,7 @@ export const timer = Command.make(
37
38
  onSome: (id) => Effect.succeed(id),
38
39
  });
39
40
  const dxn = DXN.fromLocalObjectId(triggerId);
40
- const trigger = yield* Database.Service.resolve(dxn, Trigger.Trigger);
41
+ const trigger = yield* Database.resolve(dxn, Trigger.Trigger);
41
42
  if (!trigger.spec || trigger.spec?.kind !== 'timer') {
42
43
  return yield* Effect.fail(new Error(`Invalid trigger type: ${trigger.spec?.kind}`));
43
44
  }
@@ -58,7 +59,7 @@ export const timer = Command.make(
58
59
  ).pipe(
59
60
  Command.withDescription('Update a timer trigger.'),
60
61
  Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
61
- Command.provideEffectDiscard(() => withTypes(Function.Function, Trigger.Trigger)),
62
+ Command.provideEffectDiscard(() => withTypes(Operation.PersistentOperation, Trigger.Trigger)),
62
63
  );
63
64
 
64
65
  /**
@@ -67,10 +68,10 @@ export const timer = Command.make(
67
68
  * @returns The current function (either original or newly assigned)
68
69
  */
69
70
  const updateFunction = Effect.fn(function* (trigger: Trigger.Trigger, functionIdOption: Option.Option<string>) {
70
- let currentFn: Function.Function | undefined = trigger.function
71
- ? yield* Database.Service.load(trigger.function) as any
71
+ let currentFn: Operation.PersistentOperation | undefined = trigger.function
72
+ ? yield* Database.load(trigger.function) as any
72
73
  : undefined;
73
- if (currentFn && !Obj.instanceOf(Function.Function, currentFn)) {
74
+ if (currentFn && !Obj.instanceOf(Operation.PersistentOperation, currentFn)) {
74
75
  currentFn = undefined;
75
76
  }
76
77
  const currentFunctionName = currentFn ? (currentFn.name ?? currentFn.id) : undefined;
@@ -87,13 +88,13 @@ const updateFunction = Effect.fn(function* (trigger: Trigger.Trigger, functionId
87
88
  onNone: () => selectFunction(),
88
89
  onSome: (id) => Effect.succeed(id),
89
90
  });
90
- const functions = yield* Database.Service.runQuery(Filter.type(Function.Function));
91
+ const functions = yield* Database.runQuery(Filter.type(Operation.PersistentOperation));
91
92
  const foundFn = functions.find((fn) => fn.id === functionId);
92
- if (!foundFn || !Obj.instanceOf(Function.Function, foundFn)) {
93
+ if (!foundFn || !Obj.instanceOf(Operation.PersistentOperation, foundFn)) {
93
94
  return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
94
95
  }
95
- Obj.change(trigger, (mutableTrigger) => {
96
- mutableTrigger.function = Ref.make(foundFn);
96
+ Obj.change(trigger, (trigger) => {
97
+ trigger.function = Ref.make(foundFn);
97
98
  });
98
99
  currentFn = foundFn;
99
100
  }
@@ -128,9 +129,9 @@ const updateCron = Effect.fn(function* (trigger: Trigger.Trigger, cronOption: Op
128
129
  }).pipe(Prompt.run),
129
130
  onSome: (value) => Effect.succeed(value),
130
131
  });
131
- Obj.change(trigger, (mutableTrigger) => {
132
- if (mutableTrigger.spec?.kind === 'timer') {
133
- mutableTrigger.spec.cron = cron;
132
+ Obj.change(trigger, (trigger) => {
133
+ if (trigger.spec?.kind === 'timer') {
134
+ trigger.spec.cron = cron;
134
135
  }
135
136
  });
136
137
  }
@@ -142,7 +143,7 @@ const updateCron = Effect.fn(function* (trigger: Trigger.Trigger, cronOption: Op
142
143
  */
143
144
  const updateInput = Effect.fn(function* (
144
145
  trigger: Trigger.Trigger,
145
- fn: Function.Function,
146
+ fn: Operation.PersistentOperation,
146
147
  inputOption: Option.Option<Record<string, any>>,
147
148
  ) {
148
149
  const currentInput = trigger.input as Record<string, any> | undefined;
@@ -161,11 +162,11 @@ const updateInput = Effect.fn(function* (
161
162
  if (shouldChangeInput) {
162
163
  const inputObj = yield* Option.match(inputOption, {
163
164
  onNone: () =>
164
- promptForSchemaInput(fn.inputSchema ? Type.toEffectSchema(fn.inputSchema) : undefined, currentInput),
165
+ promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined, currentInput),
165
166
  onSome: (value) => Effect.succeed(value as Record<string, any>),
166
167
  });
167
- Obj.change(trigger, (mutableTrigger) => {
168
- mutableTrigger.input = inputObj;
168
+ Obj.change(trigger, (trigger) => {
169
+ trigger.input = inputObj;
169
170
  });
170
171
  }
171
172
  });
@@ -187,7 +188,7 @@ const updateEnabled = Effect.fn(function* (
187
188
  }).pipe(Prompt.run),
188
189
  onSome: () => Effect.succeed(enabled),
189
190
  });
190
- Obj.change(trigger, (mutableTrigger) => {
191
- mutableTrigger.enabled = enabledValue;
191
+ Obj.change(trigger, (trigger) => {
192
+ trigger.enabled = enabledValue;
192
193
  });
193
194
  });
@@ -12,10 +12,11 @@ import type * as Schema from 'effect/Schema';
12
12
  import * as SchemaAST from 'effect/SchemaAST';
13
13
 
14
14
  import { FormBuilder } from '@dxos/cli-util';
15
- import { Annotation, Database, Entity, Filter, Obj, Ref, Type } from '@dxos/echo';
15
+ import { Annotation, Database, Entity, Feed, Filter, Obj, Ref, Type } from '@dxos/echo';
16
16
  import { getProperties } from '@dxos/effect';
17
- import { Function, Trigger } from '@dxos/functions';
18
- import { QueueAnnotation } from '@dxos/schema';
17
+ import { Trigger } from '@dxos/functions';
18
+ import { Operation } from '@dxos/operation';
19
+ import { FeedAnnotation } from '@dxos/schema';
19
20
 
20
21
  export type TriggerRemoteStatus = 'available' | 'not available' | 'n/a';
21
22
 
@@ -34,7 +35,7 @@ export const getTriggerRemoteStatus = (trigger: Trigger.Trigger, remoteCronIds:
34
35
  * Pretty prints a trigger with ANSI colors.
35
36
  */
36
37
  export const printTrigger = Effect.fn(function* (trigger: Trigger.Trigger, remoteStatus?: TriggerRemoteStatus) {
37
- const fn = trigger.function && (yield* Database.Service.load(trigger.function));
38
+ const fn = trigger.function && (yield* Database.load(trigger.function));
38
39
 
39
40
  return FormBuilder.make({
40
41
  title: trigger.id,
@@ -60,7 +61,10 @@ export const printTrigger = Effect.fn(function* (trigger: Trigger.Trigger, remot
60
61
  fn,
61
62
  FormBuilder.nest(
62
63
  'function',
63
- FormBuilder.make().pipe(FormBuilder.set('key', fn!.key), FormBuilder.set('dxn', fn!.dxn?.toString())),
64
+ FormBuilder.make().pipe(
65
+ FormBuilder.set('key', (fn as Operation.PersistentOperation).key),
66
+ FormBuilder.set('dxn', Obj.getDXN(fn as Obj.Unknown).toString()),
67
+ ),
64
68
  ),
65
69
  ),
66
70
  FormBuilder.nestedOption('spec', Option.fromNullable(trigger.spec).pipe(Option.map(printSpec))),
@@ -239,7 +243,7 @@ export const promptForSchemaInput = Effect.fn(function* (
239
243
  inputObj[key] = templateStr === '' && defaultValue !== undefined ? defaultValue : templateStr;
240
244
  } else {
241
245
  const annotation = Annotation.ReferenceAnnotation.getFromAst(propType).pipe(Option.getOrThrow);
242
- const objects = yield* Database.Service.runQuery(Filter.typename(annotation.typename));
246
+ const objects = yield* Database.runQuery(Filter.typename(annotation.typename));
243
247
  if (objects.length === 0) {
244
248
  inputObj[key] = undefined;
245
249
  } else {
@@ -272,7 +276,7 @@ export const promptForSchemaInput = Effect.fn(function* (
272
276
  * Queries the database for functions and prompts the user to select one.
273
277
  */
274
278
  export const selectFunction = Effect.fn(function* () {
275
- const functions = yield* Database.Service.runQuery(Filter.type(Function.Function));
279
+ const functions = yield* Database.runQuery(Filter.type(Operation.PersistentOperation));
276
280
 
277
281
  if (functions.length === 0) {
278
282
  return yield* Effect.fail(new Error('No functions available'));
@@ -280,7 +284,7 @@ export const selectFunction = Effect.fn(function* () {
280
284
 
281
285
  const selected = yield* Prompt.select({
282
286
  message: 'Select a function:',
283
- choices: functions.map((fn: Function.Function) => ({
287
+ choices: functions.map((fn: Operation.PersistentOperation) => ({
284
288
  title: fn.name ?? fn.id,
285
289
  value: fn.id,
286
290
  description: fn.description,
@@ -296,7 +300,7 @@ export const selectFunction = Effect.fn(function* () {
296
300
  * Queries the database for triggers and prompts the user to select one.
297
301
  */
298
302
  export const selectTrigger = Effect.fn(function* (kind?: Trigger.Kind) {
299
- const triggers = yield* Database.Service.runQuery(Filter.type(Trigger.Trigger));
303
+ const triggers = yield* Database.runQuery(Filter.type(Trigger.Trigger));
300
304
  const filteredTriggers = kind ? triggers.filter((trigger) => trigger.spec?.kind === kind) : triggers;
301
305
 
302
306
  if (filteredTriggers.length === 0) {
@@ -306,8 +310,9 @@ export const selectTrigger = Effect.fn(function* (kind?: Trigger.Kind) {
306
310
  const choices = yield* Effect.all(
307
311
  filteredTriggers.map((trigger) =>
308
312
  Effect.gen(function* () {
309
- const fn = trigger.function ? yield* Database.Service.load(trigger.function) : undefined;
310
- const functionName = fn && Obj.instanceOf(Function.Function, fn) ? (fn.name ?? fn.key ?? fn.id) : undefined;
313
+ const fn = trigger.function ? yield* Database.load(trigger.function) : undefined;
314
+ const functionName =
315
+ fn && Obj.instanceOf(Operation.PersistentOperation, fn) ? (fn.name ?? fn.key ?? fn.id) : undefined;
311
316
  const title = functionName ?? trigger.id;
312
317
  const description = `${trigger.enabled ? 'enabled' : 'disabled'} - ${trigger.spec?.kind ?? 'unknown'}`;
313
318
 
@@ -330,46 +335,55 @@ export const selectTrigger = Effect.fn(function* (kind?: Trigger.Kind) {
330
335
 
331
336
  /**
332
337
  * Selects a queue interactively from available queues in the database.
333
- * Queries schemas with QueueAnnotation, then queries objects of those types,
334
- * and extracts queue DXNs from the objects' queue properties.
338
+ * Queries schemas with FeedAnnotation, then queries objects of those types,
339
+ * and extracts queue DXNs from the objects' feed properties.
335
340
  */
336
341
  export const selectQueue = Effect.fn(function* () {
337
- // Query schema registry for schemas with QueueAnnotation
338
- const schemas = yield* Database.Service.runSchemaQuery({ location: ['database', 'runtime'] });
342
+ // Query schema registry for schemas with FeedAnnotation.
343
+ const schemas = yield* Database.runSchemaQuery({ location: ['database', 'runtime'] });
339
344
 
340
- // Filter schemas that have QueueAnnotation
341
- const queueSchemas = schemas.filter((schema) => {
342
- const annotation = QueueAnnotation.get(schema);
345
+ // Filter schemas that have FeedAnnotation.
346
+ const feedSchemas = schemas.filter((schema) => {
347
+ const annotation = FeedAnnotation.get(schema);
343
348
  return Option.isSome(annotation) && annotation.value === true;
344
349
  });
345
350
 
346
- if (queueSchemas.length === 0) {
347
- return yield* Effect.fail(new Error('No schemas with Queue annotation found'));
351
+ if (feedSchemas.length === 0) {
352
+ return yield* Effect.fail(new Error('No schemas with Feed annotation found'));
348
353
  }
349
354
 
350
- // Collect all objects with queues
355
+ // Collect all objects with queues.
351
356
  const queueChoices: Array<{ title: string; value: string; description?: string }> = [];
352
357
 
353
- // Process each schema, skipping ones that fail
354
- for (const schema of queueSchemas) {
358
+ // Process each feed schema, loading the Feed object to extract queue DXN.
359
+ for (const schema of feedSchemas) {
355
360
  yield* Effect.gen(function* () {
356
361
  const typename = Type.getTypename(schema);
357
- const objects = yield* Database.Service.runQuery(Filter.type(typename));
362
+ const objects = yield* Database.runQuery(Filter.type(typename));
358
363
 
359
364
  for (const obj of objects) {
360
- // Access the queue property (which is a Ref<Queue>)
361
- const queueRef = (obj as any).queue as Ref.Ref<any> | undefined;
362
- if (!queueRef) {
365
+ // Access the feed property (which is a Ref<Feed>).
366
+ const feedRef = (obj as any).feed as Ref.Ref<any> | undefined;
367
+ if (!feedRef) {
368
+ continue;
369
+ }
370
+
371
+ const feedObj = yield* Effect.promise(() => feedRef.tryLoad());
372
+ if (!feedObj || !Obj.instanceOf(Feed.Feed, feedObj)) {
373
+ continue;
374
+ }
375
+
376
+ const queueDxn = Feed.getQueueDxn(feedObj);
377
+ if (!queueDxn) {
363
378
  continue;
364
379
  }
365
380
 
366
- const queueDxn = queueRef.dxn.toString();
367
381
  const label = Obj.getLabel(obj) ?? obj.id;
368
382
  const description = Obj.getTypename(obj);
369
383
 
370
384
  queueChoices.push({
371
385
  title: label,
372
- value: queueDxn,
386
+ value: queueDxn.toString(),
373
387
  description,
374
388
  });
375
389
  }
package/src/cli/plugin.ts CHANGED
@@ -2,18 +2,18 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Common, Plugin } from '@dxos/app-framework';
5
+ import { Plugin } from '@dxos/app-framework';
6
+ import { AppPlugin } from '@dxos/app-toolkit';
6
7
  import { ClientEvents } from '@dxos/plugin-client/types';
7
8
 
8
- // NOTE: Must not import from index to avoid pulling in react dependencies.
9
- import { ComputeRuntime } from '../capabilities/compute-runtime';
10
- import { meta } from '../meta';
11
- import { AutomationEvents } from '../types';
9
+ import { ComputeRuntime } from '#capabilities';
10
+ import { meta } from '#meta';
11
+ import { AutomationEvents } from '#types';
12
12
 
13
13
  import { trigger } from './commands';
14
14
 
15
15
  export const AutomationPlugin = Plugin.define(meta).pipe(
16
- Common.Plugin.addCommandModule({ commands: [trigger] }),
16
+ AppPlugin.addCommandModule({ commands: [trigger] }),
17
17
  Plugin.addModule({
18
18
  activatesOn: ClientEvents.ClientReady,
19
19
  activatesAfter: [AutomationEvents.ComputeRuntimeReady],