@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
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/AutomationPanel/AutomationPanel.tsx", "../../../src/components/AutomationPanel/index.ts"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Array from 'effect/Array';\nimport * as EFn from 'effect/Function';\nimport * as Match from 'effect/Match';\nimport * as Schema from 'effect/Schema';\nimport React, { useMemo, useState } from 'react';\n\nimport { Filter, Obj, Tag } from '@dxos/echo';\nimport { Function, Script, Trigger } from '@dxos/functions';\nimport { FunctionsServiceClient } from '@dxos/functions-runtime/edge';\nimport { useTypeOptions } from '@dxos/plugin-space';\nimport { type Client, useClient } from '@dxos/react-client';\nimport { type Space, useQuery } from '@dxos/react-client/echo';\nimport { Clipboard, IconButton, Input, Separator, type ThemedClassName, useTranslation } from '@dxos/react-ui';\nimport { ControlItem, controlItemClasses } from '@dxos/react-ui-form';\nimport { List } from '@dxos/react-ui-list';\nimport { Project } from '@dxos/types';\nimport { ghostHover, mx } from '@dxos/ui-theme';\nimport { isNonNullable } from '@dxos/util';\n\nimport { meta } from '../../meta';\nimport { TriggerEditor, type TriggerEditorProps } from '../TriggerEditor';\n\nconst grid = 'grid grid-cols-[40px_1fr_32px_32px] min-bs-[2.5rem]';\n\nexport type AutomationPanelProps = ThemedClassName<{\n space: Space;\n object?: Obj.Unknown;\n initialTrigger?: Trigger.Trigger;\n onDone?: () => void;\n}>;\n\n// TODO(burdon): Factor out common layout with ViewEditor.\nexport const AutomationPanel = ({ classNames, space, object, initialTrigger, onDone }: AutomationPanelProps) => {\n const { t } = useTranslation(meta.id);\n const client = useClient();\n const functionsServiceClient = useMemo(() => FunctionsServiceClient.fromClient(client), [client]);\n const functions = useQuery(space.db, Filter.type(Function.Function));\n const triggers = useQuery(space.db, Filter.type(Trigger.Trigger));\n const filteredTriggers = useMemo(() => {\n return object ? triggers.filter(triggerMatch(object)) : triggers;\n }, [object, triggers]);\n const tags = useQuery(space.db, Filter.type(Tag.Tag));\n const types = useTypeOptions({\n space,\n annotation: {\n location: ['database', 'runtime'],\n kind: ['user'],\n registered: ['registered'],\n },\n });\n\n const [trigger, setTrigger] = useState<Trigger.Trigger | undefined>(initialTrigger);\n const [selected, setSelected] = useState<Trigger.Trigger>();\n\n const handleSelect = (trigger: Trigger.Trigger) => {\n setTrigger(trigger);\n setSelected(trigger);\n };\n\n const handleAdd = () => {\n setTrigger(Trigger.make({}));\n setSelected(undefined);\n };\n\n const handleDelete = (trigger: Trigger.Trigger) => {\n space.db.remove(trigger);\n setTrigger(undefined);\n setSelected(undefined);\n };\n\n const handleSave: TriggerEditorProps['onSave'] = (trigger) => {\n if (selected) {\n Object.assign(selected, trigger);\n } else {\n space.db.add(Trigger.make(trigger));\n }\n\n setTrigger(undefined);\n setSelected(undefined);\n onDone?.();\n };\n\n const handleCancel: TriggerEditorProps['onCancel'] = () => {\n setTrigger(undefined);\n onDone?.();\n };\n\n const handleForceRunTrigger = async (trigger: Trigger.Trigger) => {\n await functionsServiceClient.forceRunCronTrigger(space.id, trigger.id);\n };\n\n if (trigger) {\n return (\n <ControlItem title={t('trigger editor title')}>\n <TriggerEditor\n db={space.db}\n trigger={trigger}\n readonlySpec={Boolean(object)}\n tags={tags}\n types={types}\n onSave={handleSave}\n onCancel={handleCancel}\n />\n </ControlItem>\n );\n }\n\n return (\n <div className={mx(controlItemClasses, classNames)}>\n {filteredTriggers.length > 0 && (\n <List.Root<Trigger.Trigger>\n items={filteredTriggers}\n isItem={Schema.is(Trigger.Trigger)}\n getId={(field) => field.id}\n >\n {({ items: filteredTriggers }) => (\n <div role='list' className='flex flex-col is-full'>\n {filteredTriggers?.map((trigger) => {\n const copyAction = getCopyAction(client, trigger);\n return (\n <List.Item<Trigger.Trigger>\n key={trigger.id}\n item={trigger}\n classNames={mx(grid, ghostHover, 'items-center', 'pli-2')}\n >\n <Input.Root>\n <Input.Switch\n checked={trigger.enabled}\n onCheckedChange={(checked) =>\n Obj.change(trigger, (t) => {\n t.enabled = checked;\n })\n }\n />\n </Input.Root>\n\n <div className={'flex'}>\n <List.ItemTitle\n classNames='pli-1 cursor-pointer is-0 shrink truncate'\n onClick={() => handleSelect(trigger)}\n >\n {getFunctionName(functions, trigger) ?? '∅'}\n </List.ItemTitle>\n\n {/* TODO: a better way to expose copy action */}\n {copyAction && (\n <Clipboard.IconButton\n label={t(copyAction.translationKey)}\n value={copyAction.contentProvider()}\n />\n )}\n </div>\n\n <List.ItemButton\n autoHide={false}\n disabled={!trigger.enabled || trigger.spec?.kind !== 'timer'}\n icon='ph--play--regular'\n label='Force run'\n onClick={() => handleForceRunTrigger(trigger)}\n />\n\n <List.ItemDeleteButton onClick={() => handleDelete(trigger)} />\n </List.Item>\n );\n })}\n </div>\n )}\n </List.Root>\n )}\n {filteredTriggers.length > 0 && <Separator classNames='mlb-4' />}\n <IconButton icon='ph--plus--regular' label={t('new trigger label')} onClick={handleAdd} />\n </div>\n );\n};\n\nconst getCopyAction = (client: Client, trigger: Trigger.Trigger | undefined) => {\n if (trigger?.spec?.kind === 'email') {\n return {\n translationKey: 'trigger copy email',\n contentProvider: () => `${Obj.getDatabase(trigger)!.spaceId}@dxos.network`,\n };\n }\n\n if (trigger?.spec?.kind === 'webhook') {\n return { translationKey: 'trigger copy url', contentProvider: () => getWebhookUrl(client, trigger) };\n }\n\n return undefined;\n};\n\nconst getWebhookUrl = (client: Client, trigger: Trigger.Trigger) => {\n const spaceId = Obj.getDatabase(trigger)!.spaceId;\n const edgeUrl = new URL(client.config.values.runtime!.services!.edge!.url!);\n const isSecure = edgeUrl.protocol.startsWith('https') || edgeUrl.protocol.startsWith('wss');\n edgeUrl.protocol = isSecure ? 'https' : 'http';\n return new URL(`/webhook/${spaceId}:${trigger.id}`, edgeUrl).toString();\n};\n\nconst getFunctionName = (functions: Function.Function[], trigger: Trigger.Trigger) => {\n // TODO(wittjosiah): Truncation should be done in the UI.\n // Warning that the List component is currently a can of worms.\n const shortId = trigger.function && `${trigger.function.dxn.toString().slice(0, 16)}…`;\n const functionObject = functions.find((fn) => fn === trigger.function?.target);\n return functionObject?.name ?? shortId;\n};\n\nconst scriptMatch = (script: Script.Script) => (trigger: Trigger.Trigger) => {\n const fn = trigger.function?.target;\n if (!Obj.instanceOf(Function.Function, fn)) {\n return false;\n }\n\n return fn.source?.target === script;\n};\n\nconst projectMatch = (project: Project.Project) => {\n const viewQueries = EFn.pipe(\n project.columns,\n Array.map((column) => column.view.target),\n Array.filter(isNonNullable),\n Array.map((view) => Obj.getSnapshot(view).query.ast),\n Array.map((ast) => JSON.stringify(ast)),\n );\n\n return (trigger: Trigger.Trigger) => {\n const spec = Obj.getSnapshot(trigger).spec;\n if (spec?.kind !== 'subscription') {\n return false;\n }\n\n // TODO(wittjosiah): Implement better way of comparing query ASTs.\n return viewQueries.some((query) => JSON.stringify(spec.query) === query);\n };\n};\n\nconst triggerMatch = Match.type<Obj.Unknown>().pipe(\n Match.withReturnType<(trigger: Trigger.Trigger) => boolean>(),\n Match.when(\n (obj) => Obj.instanceOf(Script.Script, obj),\n (obj) => scriptMatch(obj),\n ),\n Match.when(\n (obj) => Obj.instanceOf(Project.Project, obj),\n (obj) => projectMatch(obj),\n ),\n Match.orElse((_obj) => () => true),\n);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { AutomationPanel } from './AutomationPanel';\n\nexport * from './AutomationPanel';\n\nexport default AutomationPanel;\n"],
5
- "mappings": ";;;;;;;;;AAIA,YAAYA,WAAW;AACvB,YAAYC,SAAS;AACrB,YAAYC,WAAW;AACvB,YAAYC,YAAY;AACxB,OAAOC,SAASC,SAASC,gBAAgB;AAEzC,SAASC,QAAQC,KAAKC,WAAW;AACjC,SAASC,UAAUC,QAAQC,eAAe;AAC1C,SAASC,8BAA8B;AACvC,SAASC,sBAAsB;AAC/B,SAAsBC,iBAAiB;AACvC,SAAqBC,gB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O,CAAC1G,YAAAA;AACN,UAAMgE,OAAOd,IAAIsD,YAAYxG,OAAAA,EAASgE;AACtC,QAAIA,MAAMlE,SAAS,gBAAgB;AACjC,aAAO;IACT;AAGA,WAAOoG,YAAYW,KAAK,CAACJ,UAAUE,KAAKC,UAAU5C,KAAKyC,KAAK,MAAMA,KAAAA;EACpE;AACF;AAEA,IAAMlH,eAAqBN,WAAI,EAAgBkH,KACvCW,qBAAc,GACdC,WACJ,CAACC,QAAQ9D,IAAI4C,WAAWmB,OAAOA,QAAQD,GAAAA,GACvC,CAACA,QAAQpB,YAAYoB,GAAAA,CAAAA,GAEjBD,WACJ,CAACC,QAAQ9D,IAAI4C,WAAWoB,QAAQA,SAASF,GAAAA,GACzC,CAACA,QAAQhB,aAAagB,GAAAA,CAAAA,GAElBG,aAAO,CAACC,SAAS,MAAM,IAAA,CAAA;;;ACjP/B,IAAA,0BAAeC;",
6
- "names": ["Array", "EFn", "Match", "Schema", "React", "useMemo", "useState", "Filter", "Obj", "Tag", "Function", "Script", "Trigger", "FunctionsServiceClient", "useTypeOptions", "useClient", "useQuery", "Clipboard", "IconButton", "Input", "Separator", "useTranslation", "ControlItem", "controlItemClasses", "List", "Project", "ghostHover", "mx", "isNonNullable", "grid", "AutomationPanel", "classNames", "space", "object", "initialTrigger", "onDone", "t", "useTranslation", "meta", "id", "client", "useClient", "functionsServiceClient", "useMemo", "FunctionsServiceClient", "fromClient", "functions", "useQuery", "db", "Filter", "type", "Function", "triggers", "Trigger", "filteredTriggers", "filter", "triggerMatch", "tags", "Tag", "types", "useTypeOptions", "annotation", "location", "kind", "registered", "trigger", "setTrigger", "useState", "selected", "setSelected", "handleSelect", "handleAdd", "make", "undefined", "handleDelete", "remove", "handleSave", "Object", "assign", "add", "handleCancel", "handleForceRunTrigger", "forceRunCronTrigger", "ControlItem", "title", "TriggerEditor", "readonlySpec", "Boolean", "onSave", "onCancel", "div", "className", "mx", "controlItemClasses", "length", "List", "Root", "items", "isItem", "is", "getId", "field", "role", "map", "copyAction", "getCopyAction", "Item", "key", "item", "ghostHover", "Input", "Switch", "checked", "enabled", "onCheckedChange", "Obj", "change", "ItemTitle", "onClick", "getFunctionName", "Clipboard", "IconButton", "label", "translationKey", "value", "contentProvider", "ItemButton", "autoHide", "disabled", "spec", "icon", "ItemDeleteButton", "Separator", "getDatabase", "spaceId", "getWebhookUrl", "edgeUrl", "URL", "config", "values", "runtime", "services", "edge", "url", "isSecure", "protocol", "startsWith", "toString", "shortId", "function", "dxn", "slice", "functionObject", "find", "fn", "target", "name", "scriptMatch", "script", "instanceOf", "source", "projectMatch", "project", "viewQueries", "pipe", "columns", "column", "view", "isNonNullable", "getSnapshot", "query", "ast", "JSON", "stringify", "some", "withReturnType", "when", "obj", "Script", "Project", "orElse", "_obj", "AutomationPanel"]
7
- }
@@ -1,19 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
-
3
- // src/meta.ts
4
- import { trim } from "@dxos/util";
5
- var meta = {
6
- id: "dxos.org/plugin/automation",
7
- name: "Automation",
8
- description: trim`
9
- Workflow automation engine that triggers custom actions based on object events and conditions.
10
- Create automated pipelines that respond to changes and streamline repetitive tasks.
11
- `,
12
- icon: "ph--robot--regular",
13
- source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-automation"
14
- };
15
-
16
- export {
17
- meta
18
- };
19
- //# sourceMappingURL=chunk-5FXNN3MV.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Plugin } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: Plugin.Meta = {\n id: 'dxos.org/plugin/automation',\n name: 'Automation',\n description: trim`\n Workflow automation engine that triggers custom actions based on object events and conditions.\n Create automated pipelines that respond to changes and streamline repetitive tasks.\n `,\n icon: 'ph--robot--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-automation',\n};\n"],
5
- "mappings": ";;;AAKA,SAASA,YAAY;AAEd,IAAMC,OAAoB;EAC/BC,IAAI;EACJC,MAAM;EACNC,aAAaC;;;;EAIbC,MAAM;EACNC,QAAQ;AACV;",
6
- "names": ["trim", "meta", "id", "name", "description", "trim", "icon", "source"]
7
- }
@@ -1,16 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
-
3
- // src/components/index.ts
4
- import { lazy } from "react";
5
- var AutomationPanel = lazy(() => import("./AutomationPanel-B7NAGDFA.mjs"));
6
- var AutomationSettings = lazy(() => import("./AutomationSettings-M5PMZJ6P.mjs"));
7
- var FunctionsContainer = lazy(() => import("./FunctionsContainer-J4O2ULWR.mjs"));
8
- var FunctionsPanel = lazy(() => import("./FunctionsPanel-SS6GIVNU.mjs"));
9
-
10
- export {
11
- AutomationPanel,
12
- AutomationSettings,
13
- FunctionsContainer,
14
- FunctionsPanel
15
- };
16
- //# sourceMappingURL=chunk-7QRUPEHH.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/index.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { lazy } from 'react';\n\nexport * from './TriggerEditor';\n\nexport const AutomationPanel = lazy(() => import('./AutomationPanel'));\nexport const AutomationSettings = lazy(() => import('./AutomationSettings'));\nexport const FunctionsContainer = lazy(() => import('./FunctionsContainer'));\nexport const FunctionsPanel = lazy(() => import('./FunctionsPanel'));\n"],
5
- "mappings": ";;;AAIA,SAASA,YAAY;AAId,IAAMC,kBAAkBC,KAAK,MAAM,OAAO,gCAAA,CAAA;AAC1C,IAAMC,qBAAqBD,KAAK,MAAM,OAAO,mCAAA,CAAA;AAC7C,IAAME,qBAAqBF,KAAK,MAAM,OAAO,mCAAA,CAAA;AAC7C,IAAMG,iBAAiBH,KAAK,MAAM,OAAO,+BAAA,CAAA;",
6
- "names": ["lazy", "AutomationPanel", "lazy", "AutomationSettings", "FunctionsContainer", "FunctionsPanel"]
7
- }
@@ -1,87 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- import {
3
- AutomationCapabilities
4
- } from "./chunk-RX52VKI2.mjs";
5
-
6
- // src/hooks/useComputeRuntimeCallback.ts
7
- import * as Cause from "effect/Cause";
8
- import * as Effect from "effect/Effect";
9
- import * as Exit from "effect/Exit";
10
- import { useCallback } from "react";
11
- import { useCapability } from "@dxos/app-framework/react";
12
- import { FunctionInvocationService, TracingService } from "@dxos/functions";
13
- import { log } from "@dxos/log";
14
- var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-automation/src/hooks/useComputeRuntimeCallback.ts";
15
- var useComputeRuntimeCallback = (id, fn, deps) => {
16
- const computeRuntime = useCapability(AutomationCapabilities.ComputeRuntime);
17
- const runtime = id !== void 0 ? computeRuntime.getRuntime(id) : void 0;
18
- return useCallback(() => {
19
- if (!runtime) {
20
- throw new TypeError("Space not provided to useComputeRuntimeCallback");
21
- }
22
- return runtime.runPromise(fn());
23
- }, [
24
- runtime,
25
- ...deps ?? []
26
- ]);
27
- };
28
- var invokeFunctionWithTracing = (functionDef, inputData) => Effect.gen(function* () {
29
- const tracer = yield* TracingService;
30
- const trace = yield* tracer.traceInvocationStart({
31
- target: void 0,
32
- payload: {
33
- data: {}
34
- }
35
- });
36
- const result = yield* FunctionInvocationService.invokeFunction(functionDef, inputData).pipe(Effect.provide(trace.invocationTraceQueue ? TracingService.layerInvocation(trace) : TracingService.layerNoop), Effect.exit);
37
- if (Exit.isFailure(result)) {
38
- const error = Cause.prettyErrors(result.cause)[0];
39
- log.error(error.message, error.cause ?? error.stack, {
40
- F: __dxlog_file,
41
- L: 57,
42
- S: this,
43
- C: (f, a) => f(...a)
44
- });
45
- }
46
- yield* tracer.traceInvocationEnd({
47
- trace,
48
- // TODO(dmaretskyi): Might miss errors.
49
- exception: Exit.isFailure(result) ? Cause.prettyErrors(result.cause)[0] : void 0
50
- });
51
- return result;
52
- });
53
-
54
- // src/hooks/useTriggerRuntimeControls.ts
55
- import * as Effect2 from "effect/Effect";
56
- import { Filter } from "@dxos/echo";
57
- import { Trigger } from "@dxos/functions";
58
- import { TriggerDispatcher } from "@dxos/functions-runtime";
59
- import { useQuery } from "@dxos/react-client/echo";
60
- import { useAsyncState } from "@dxos/react-ui";
61
- var useTriggerRuntimeControls = (db) => {
62
- const triggers = useQuery(db, Filter.type(Trigger.Trigger));
63
- const [isRunningState, setIsRunningState] = useAsyncState(useComputeRuntimeCallback(db?.spaceId, () => TriggerDispatcher.pipe(Effect2.map((t) => t.running))));
64
- const start = useComputeRuntimeCallback(db?.spaceId, Effect2.fnUntraced(function* () {
65
- const dispatcher = yield* TriggerDispatcher;
66
- yield* dispatcher.start();
67
- setIsRunningState(true);
68
- }));
69
- const stop = useComputeRuntimeCallback(db?.spaceId, Effect2.fnUntraced(function* () {
70
- const dispatcher = yield* TriggerDispatcher;
71
- yield* dispatcher.stop();
72
- setIsRunningState(false);
73
- }));
74
- return {
75
- triggers,
76
- isRunning: isRunningState ?? false,
77
- start: () => void start(),
78
- stop: () => void stop()
79
- };
80
- };
81
-
82
- export {
83
- useComputeRuntimeCallback,
84
- invokeFunctionWithTracing,
85
- useTriggerRuntimeControls
86
- };
87
- //# sourceMappingURL=chunk-HQLVREIX.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/hooks/useComputeRuntimeCallback.ts", "../../../src/hooks/useTriggerRuntimeControls.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Cause from 'effect/Cause';\nimport * as Effect from 'effect/Effect';\nimport * as Exit from 'effect/Exit';\nimport { type DependencyList, useCallback } from 'react';\n\nimport { useCapability } from '@dxos/app-framework/react';\nimport { type Key } from '@dxos/echo';\nimport { type FunctionDefinition, FunctionInvocationService, TracingService } from '@dxos/functions';\nimport { log } from '@dxos/log';\n\nimport { AutomationCapabilities } from '../types';\n\n/**\n * Create an effectful function that has access to compute services\n */\n// TODO(burdon): Factor out (figure out cross-plugin capabilities dependencies).\nexport const useComputeRuntimeCallback = <T>(\n id: Key.SpaceId | undefined,\n fn: () => Effect.Effect<T, any, AutomationCapabilities.ComputeServices>,\n deps?: DependencyList,\n): (() => Promise<T>) => {\n const computeRuntime = useCapability(AutomationCapabilities.ComputeRuntime);\n const runtime = id !== undefined ? computeRuntime.getRuntime(id) : undefined;\n\n return useCallback(() => {\n if (!runtime) {\n throw new TypeError('Space not provided to useComputeRuntimeCallback');\n }\n\n return runtime.runPromise(fn());\n }, [runtime, ...(deps ?? [])]);\n};\n\n// TODO(wittjosiah): Function invoking should automatically be traced (DX-647).\nexport const invokeFunctionWithTracing = <I, O>(functionDef: FunctionDefinition<I, O>, inputData: I) =>\n Effect.gen(function* () {\n const tracer = yield* TracingService;\n const trace = yield* tracer.traceInvocationStart({\n target: undefined,\n payload: {\n data: {},\n },\n });\n\n // Invoke the function.\n const result = yield* FunctionInvocationService.invokeFunction(functionDef, inputData).pipe(\n Effect.provide(trace.invocationTraceQueue ? TracingService.layerInvocation(trace) : TracingService.layerNoop),\n Effect.exit,\n );\n\n if (Exit.isFailure(result)) {\n const error = Cause.prettyErrors(result.cause)[0];\n log.error(error.message, error.cause ?? error.stack);\n }\n\n yield* tracer.traceInvocationEnd({\n trace,\n // TODO(dmaretskyi): Might miss errors.\n exception: Exit.isFailure(result) ? Cause.prettyErrors(result.cause)[0] : undefined,\n });\n\n return result;\n });\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { type Database, Filter } from '@dxos/echo';\nimport { Trigger } from '@dxos/functions';\nimport { TriggerDispatcher } from '@dxos/functions-runtime';\nimport { useQuery } from '@dxos/react-client/echo';\nimport { useAsyncState } from '@dxos/react-ui';\n\nimport { useComputeRuntimeCallback } from './useComputeRuntimeCallback';\n\ninterface TriggerRuntimeControls {\n triggers: Trigger.Trigger[];\n isRunning: boolean;\n start: () => void;\n stop: () => void;\n}\n\nexport const useTriggerRuntimeControls = (db: Database.Database | undefined): TriggerRuntimeControls => {\n const triggers = useQuery(db, Filter.type(Trigger.Trigger));\n\n const [isRunningState, setIsRunningState] = useAsyncState(\n useComputeRuntimeCallback(db?.spaceId, () => TriggerDispatcher.pipe(Effect.map((t) => t.running))),\n );\n\n const start = useComputeRuntimeCallback(\n db?.spaceId,\n Effect.fnUntraced(function* () {\n const dispatcher = yield* TriggerDispatcher;\n yield* dispatcher.start();\n setIsRunningState(true);\n }),\n );\n\n const stop = useComputeRuntimeCallback(\n db?.spaceId,\n Effect.fnUntraced(function* () {\n const dispatcher = yield* TriggerDispatcher;\n yield* dispatcher.stop();\n setIsRunningState(false);\n }),\n );\n\n return {\n triggers,\n isRunning: isRunningState ?? false,\n start: () => void start(),\n stop: () => void stop(),\n };\n};\n"],
5
- "mappings": ";;;;;;AAIA,YAAYA,WAAW;AACvB,YAAYC,YAAY;AACxB,YAAYC,UAAU;AACtB,SAA8BC,mBAAmB;AAEjD,SAASC,qBAAqB;AAE9B,SAAkCC,2BAA2BC,sBAAsB;AACnF,SAASC,WAAW;;AAQb,IAAMC,4BAA4B,CACvCC,IACAC,IACAC,SAAAA;AAEA,QAAMC,iBAAiBC,cAAcC,uBAAuBC,cAAc;AAC1E,QAAMC,UAAUP,OAAOQ,SAAYL,eAAeM,WAAWT,EAAAA,IAAMQ;AAEnE,SAAOE,YAAY,MAAA;AACjB,QAAI,CAACH,SAAS;AACZ,YAAM,IAAII,UAAU,iDAAA;IACtB;AAEA,WAAOJ,QAAQK,WAAWX,GAAAA,CAAAA;EAC5B,GAAG;IAACM;OAAaL,QAAQ,CAAA;GAAI;AAC/B;AAGO,IAAMW,4BAA4B,CAAOC,aAAuCC,cAC9EC,WAAI,aAAA;AACT,QAAMC,SAAS,OAAOC;AACtB,QAAMC,QAAQ,OAAOF,OAAOG,qBAAqB;IAC/CC,QAAQb;IACRc,SAAS;MACPC,MAAM,CAAC;IACT;EACF,CAAA;AA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ClBG,MAAM,MAAM,KAAKA,KAAAA;EACnB;AACF;",
6
- "names": ["Cause", "Effect", "Exit", "useCallback", "useCapability", "FunctionInvocationService", "TracingService", "log", "useComputeRuntimeCallback", "id", "fn", "deps", "computeRuntime", "useCapability", "AutomationCapabilities", "ComputeRuntime", "runtime", "undefined", "getRuntime", "useCallback", "TypeError", "runPromise", "invokeFunctionWithTracing", "functionDef", "inputData", "gen", "tracer", "TracingService", "trace", "traceInvocationStart", "target", "payload", "data", "result", "FunctionInvocationService", "invokeFunction", "pipe", "provide", "invocationTraceQueue", "layerInvocation", "layerNoop", "exit", "isFailure", "error", "prettyErrors", "cause", "log", "message", "stack", "traceInvocationEnd", "exception", "Effect", "Filter", "Trigger", "TriggerDispatcher", "useQuery", "useAsyncState", "useTriggerRuntimeControls", "db", "triggers", "useQuery", "Filter", "type", "Trigger", "isRunningState", "setIsRunningState", "useAsyncState", "useComputeRuntimeCallback", "spaceId", "TriggerDispatcher", "pipe", "map", "t", "running", "start", "fnUntraced", "dispatcher", "stop", "isRunning"]
7
- }
@@ -1,10 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
-
3
- // src/capabilities/compute-runtime/index.ts
4
- import { Capability } from "@dxos/app-framework";
5
- var ComputeRuntime = Capability.lazy("ComputeRuntime", () => import("./compute-runtime-ZHROOBLY.mjs"));
6
-
7
- export {
8
- ComputeRuntime
9
- };
10
- //# sourceMappingURL=chunk-K7GCM342.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/compute-runtime/index.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capability } from '@dxos/app-framework';\n\nexport const ComputeRuntime = Capability.lazy('ComputeRuntime', () => import('./compute-runtime'));\n"],
5
- "mappings": ";;;AAIA,SAASA,kBAAkB;AAEpB,IAAMC,iBAAiBC,WAAWC,KAAK,kBAAkB,MAAM,OAAO,gCAAA,CAAA;",
6
- "names": ["Capability", "ComputeRuntime", "Capability", "lazy"]
7
- }
@@ -1,103 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- import {
3
- meta
4
- } from "./chunk-5FXNN3MV.mjs";
5
-
6
- // src/components/FunctionsPanel/FunctionsPanel.tsx
7
- import * as Schema from "effect/Schema";
8
- import React, { useCallback, useMemo } from "react";
9
- import { Common } from "@dxos/app-framework";
10
- import { useOperationInvoker } from "@dxos/app-framework/react";
11
- import { Obj } from "@dxos/echo";
12
- import { Function, Script } from "@dxos/functions";
13
- import { SpaceOperation } from "@dxos/plugin-space/types";
14
- import { Filter, useQuery } from "@dxos/react-client/echo";
15
- import { Button, IconButton, useTranslation } from "@dxos/react-ui";
16
- import { controlItemClasses } from "@dxos/react-ui-form";
17
- import { List } from "@dxos/react-ui-list";
18
- import { ghostHover, mx } from "@dxos/ui-theme";
19
- var grid = "grid grid-cols-[1fr_auto] min-bs-[2.5rem]";
20
- var FunctionsPanel = ({ space }) => {
21
- const { t } = useTranslation(meta.id);
22
- const functions = useQuery(space.db, Filter.type(Function.Function));
23
- const scripts = useQuery(space.db, Filter.type(Script.Script));
24
- const { invokePromise } = useOperationInvoker();
25
- const functionToScriptMap = useMemo(() => functions.reduce((map, func) => {
26
- const scriptId = func.source?.target?.id;
27
- if (scriptId) {
28
- const script = scripts.find((s) => s.id === scriptId);
29
- if (script) {
30
- map[func.id] = script;
31
- }
32
- }
33
- return map;
34
- }, {}), [
35
- functions,
36
- scripts
37
- ]);
38
- const getScriptName = useCallback((func) => {
39
- const script = functionToScriptMap[func.id];
40
- return script?.name;
41
- }, [
42
- functionToScriptMap
43
- ]);
44
- const handleGoToScript = useCallback((func) => {
45
- const script = functionToScriptMap[func.id];
46
- if (script) {
47
- void invokePromise(Common.LayoutOperation.Open, {
48
- subject: [
49
- Obj.getDXN(script).toString()
50
- ]
51
- });
52
- }
53
- }, [
54
- functionToScriptMap,
55
- invokePromise
56
- ]);
57
- const handleDelete = useCallback((func) => invokePromise(SpaceOperation.RemoveObjects, {
58
- objects: [
59
- func
60
- ]
61
- }), [
62
- invokePromise
63
- ]);
64
- return /* @__PURE__ */ React.createElement("div", {
65
- role: "none",
66
- className: mx(controlItemClasses)
67
- }, functions.length > 0 && /* @__PURE__ */ React.createElement(List.Root, {
68
- items: functions,
69
- isItem: Schema.is(Function.Function),
70
- getId: (func) => func.id
71
- }, ({ items }) => /* @__PURE__ */ React.createElement("div", {
72
- role: "list",
73
- className: "flex flex-col is-full"
74
- }, items?.map((func) => /* @__PURE__ */ React.createElement(List.Item, {
75
- key: func.id,
76
- item: func,
77
- classNames: mx(grid, ghostHover, "items-center", "pli-2", "min-bs-[3rem]")
78
- }, /* @__PURE__ */ React.createElement("div", {
79
- className: "flex flex-col truncate"
80
- }, /* @__PURE__ */ React.createElement(List.ItemTitle, {
81
- classNames: "truncate"
82
- }, func.name), getScriptName(func) && /* @__PURE__ */ React.createElement("div", {
83
- className: "text-xs text-description truncate"
84
- }, getScriptName(func))), functionToScriptMap[func.id] && /* @__PURE__ */ React.createElement(Button, {
85
- onClick: () => handleGoToScript(func)
86
- }, t("go to function source button label")), /* @__PURE__ */ React.createElement(IconButton, {
87
- iconOnly: true,
88
- icon: "ph--trash--regular",
89
- label: t("delete function button label"),
90
- onClick: () => handleDelete(func)
91
- }))))), functions.length === 0 && /* @__PURE__ */ React.createElement("div", {
92
- className: "text-center plb-4 text-gray-500"
93
- }, t("no functions found")));
94
- };
95
-
96
- // src/components/FunctionsPanel/index.ts
97
- var FunctionsPanel_default = FunctionsPanel;
98
-
99
- export {
100
- FunctionsPanel,
101
- FunctionsPanel_default
102
- };
103
- //# sourceMappingURL=chunk-KWKWOGS5.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/FunctionsPanel/FunctionsPanel.tsx", "../../../src/components/FunctionsPanel/index.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport React, { useCallback, useMemo } from 'react';\n\nimport { Common } from '@dxos/app-framework';\nimport { useOperationInvoker } from '@dxos/app-framework/react';\nimport { Obj } from '@dxos/echo';\nimport { Function, Script } from '@dxos/functions';\nimport { SpaceOperation } from '@dxos/plugin-space/types';\nimport { Filter, type Space, useQuery } from '@dxos/react-client/echo';\nimport { Button, IconButton, useTranslation } from '@dxos/react-ui';\nimport { controlItemClasses } from '@dxos/react-ui-form';\nimport { List } from '@dxos/react-ui-list';\nimport { ghostHover, mx } from '@dxos/ui-theme';\n\nimport { meta } from '../../meta';\n\nconst grid = 'grid grid-cols-[1fr_auto] min-bs-[2.5rem]';\n\nexport type FunctionsPanelProps = {\n space: Space;\n};\n\nexport const FunctionsPanel = ({ space }: FunctionsPanelProps) => {\n const { t } = useTranslation(meta.id);\n const functions = useQuery(space.db, Filter.type(Function.Function));\n const scripts = useQuery(space.db, Filter.type(Script.Script));\n const { invokePromise } = useOperationInvoker();\n\n const functionToScriptMap = useMemo(\n () =>\n functions.reduce(\n (map, func) => {\n const scriptId = func.source?.target?.id;\n if (scriptId) {\n const script = scripts.find((s) => s.id === scriptId);\n if (script) {\n map[func.id] = script;\n }\n }\n return map;\n },\n {} as Record<string, Script.Script>,\n ),\n [functions, scripts],\n );\n\n const getScriptName = useCallback(\n (func: Function.Function) => {\n const script = functionToScriptMap[func.id];\n return script?.name;\n },\n [functionToScriptMap],\n );\n\n const handleGoToScript = useCallback(\n (func: Function.Function) => {\n const script = functionToScriptMap[func.id];\n if (script) {\n void invokePromise(Common.LayoutOperation.Open, { subject: [Obj.getDXN(script).toString()] });\n }\n },\n [functionToScriptMap, invokePromise],\n );\n\n const handleDelete = useCallback(\n (func: Function.Function) => invokePromise(SpaceOperation.RemoveObjects, { objects: [func] }),\n [invokePromise],\n );\n\n return (\n <div role='none' className={mx(controlItemClasses)}>\n {functions.length > 0 && (\n <List.Root<Function.Function> items={functions} isItem={Schema.is(Function.Function)} getId={(func) => func.id}>\n {({ items }) => (\n <div role='list' className='flex flex-col is-full'>\n {items?.map((func) => (\n <List.Item<Function.Function>\n key={func.id}\n item={func}\n classNames={mx(grid, ghostHover, 'items-center', 'pli-2', 'min-bs-[3rem]')}\n >\n <div className='flex flex-col truncate'>\n <List.ItemTitle classNames='truncate'>{func.name}</List.ItemTitle>\n {getScriptName(func) && (\n <div className='text-xs text-description truncate'>{getScriptName(func)}</div>\n )}\n </div>\n {functionToScriptMap[func.id] && (\n <Button onClick={() => handleGoToScript(func)}>{t('go to function source button label')}</Button>\n )}\n <IconButton\n iconOnly\n icon='ph--trash--regular'\n label={t('delete function button label')}\n onClick={() => handleDelete(func)}\n />\n </List.Item>\n ))}\n </div>\n )}\n </List.Root>\n )}\n\n {functions.length === 0 && <div className='text-center plb-4 text-gray-500'>{t('no functions found')}</div>}\n </div>\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { FunctionsPanel } from './FunctionsPanel';\n\nexport * from './FunctionsPanel';\nexport default FunctionsPanel;\n"],
5
- "mappings": ";;;;;;AAIA,YAAYA,YAAY;AACxB,OAAOC,SAASC,aAAaC,eAAe;AAE5C,SAASC,cAAc;AACvB,SAASC,2BAA2B;AACpC,SAASC,WAAW;AACpB,SAASC,UAAUC,cAAc;AACjC,SAASC,sBAAsB;AAC/B,SAASC,QAAoBC,gBAAgB;AAC7C,SAASC,QAAQC,YAAYC,sBAAsB;AACnD,SAASC,0BAA0B;AACnC,SAASC,YAAY;AACrB,SAASC,YAAYC,UAAU;AAI/B,IAAMC,OAAO;AAMN,IAAMC,iBAAiB,CAAC,EAAEC,MAAK,MAAuB;AAC3D,QAAM,EAAEC,EAAC,IAAKC,eAAeC,KAAKC,EAAE;AACpC,QAAMC,YAAYC,SAASN,MAAMO,IAAIC,OAAOC,KAAKC,SAASA,QAAQ,CAAA;AAClE,QAAMC,UAAUL,SAASN,MAAMO,IAAIC,OAAOC,KAAKG,OAAOA,MAAM,CAAA;AAC5D,QAAM,EAAEC,cAAa,IAAKC,oB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,MAAMpC;IACNqC,YAAYZ,GAAG9C,MAAM2D,YAAY,gBAAgB,SAAS,eAAA;KAE1D,sBAAA,cAAChB,OAAAA;IAAIE,WAAU;KACb,sBAAA,cAACI,KAAKW,WAAS;IAACF,YAAW;KAAYrC,KAAKS,IAAI,GAC/CF,cAAcP,IAAAA,KACb,sBAAA,cAACsB,OAAAA;IAAIE,WAAU;KAAqCjB,cAAcP,IAAAA,CAAAA,CAAAA,GAGrEJ,oBAAoBI,KAAKf,EAAE,KAC1B,sBAAA,cAACuD,QAAAA;IAAOC,SAAS,MAAM/B,iBAAiBV,IAAAA;KAAQlB,EAAE,oCAAA,CAAA,GAEpD,sBAAA,cAAC4D,YAAAA;IACCC,UAAAA;IACAC,MAAK;IACLC,OAAO/D,EAAE,8BAAA;IACT2D,SAAS,MAAMvB,aAAalB,IAAAA;UASzCd,UAAUyC,WAAW,KAAK,sBAAA,cAACL,OAAAA;IAAIE,WAAU;KAAmC1C,EAAE,oBAAA,CAAA,CAAA;AAGrF;;;ACvGA,IAAA,yBAAegE;",
6
- "names": ["Schema", "React", "useCallback", "useMemo", "Common", "useOperationInvoker", "Obj", "Function", "Script", "SpaceOperation", "Filter", "useQuery", "Button", "IconButton", "useTranslation", "controlItemClasses", "List", "ghostHover", "mx", "grid", "FunctionsPanel", "space", "t", "useTranslation", "meta", "id", "functions", "useQuery", "db", "Filter", "type", "Function", "scripts", "Script", "invokePromise", "useOperationInvoker", "functionToScriptMap", "useMemo", "reduce", "map", "func", "scriptId", "source", "target", "script", "find", "s", "getScriptName", "useCallback", "name", "handleGoToScript", "Common", "LayoutOperation", "Open", "subject", "Obj", "getDXN", "toString", "handleDelete", "SpaceOperation", "RemoveObjects", "objects", "div", "role", "className", "mx", "controlItemClasses", "length", "List", "Root", "items", "isItem", "is", "getId", "Item", "key", "item", "classNames", "ghostHover", "ItemTitle", "Button", "onClick", "IconButton", "iconOnly", "icon", "label", "FunctionsPanel"]
7
- }
@@ -1,249 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- import {
3
- meta
4
- } from "./chunk-5FXNN3MV.mjs";
5
-
6
- // src/components/TriggerEditor/TriggerEditor.tsx
7
- import React3, { useCallback as useCallback3, useMemo as useMemo3 } from "react";
8
- import { ComputeGraph } from "@dxos/conductor";
9
- import { DXN } from "@dxos/echo";
10
- import { Function, Script, Trigger as Trigger2 } from "@dxos/functions";
11
- import { Filter as Filter2, Ref as Ref2, useQuery } from "@dxos/react-client/echo";
12
- import { Input } from "@dxos/react-ui";
13
- import { QueryForm } from "@dxos/react-ui-components";
14
- import { Form as Form2, FormFieldLabel, SelectField as SelectField2, omitId } from "@dxos/react-ui-form";
15
-
16
- // src/components/TriggerEditor/FunctionInputEditor.tsx
17
- import React, { useCallback, useMemo } from "react";
18
- import { Ref, Type } from "@dxos/echo";
19
- import { useOnTransition, useTranslation } from "@dxos/react-ui";
20
- import { Form, useFormValues } from "@dxos/react-ui-form";
21
- var FunctionInputEditor = ({ type, functions, db, getValue, onValueChange }) => {
22
- const { t } = useTranslation(meta.id);
23
- const selectedFunctionValue = useFormValues(FunctionInputEditor.displayName, [
24
- "function"
25
- ]);
26
- const selectedFunctionId = useMemo(() => {
27
- if (Ref.isRef(selectedFunctionValue)) {
28
- return selectedFunctionValue.dxn.toString().split("dxn:echo:@:").at(1);
29
- }
30
- }, [
31
- selectedFunctionValue
32
- ]);
33
- const selectedFunction = useMemo(() => functions.find((fn) => fn.id === selectedFunctionId), [
34
- functions,
35
- selectedFunctionId
36
- ]);
37
- useOnTransition(
38
- // Clear function parameter input when the function changes.
39
- selectedFunctionValue,
40
- (prevValue) => {
41
- if (!Ref.isRef(prevValue) || !Ref.isRef(selectedFunctionValue)) {
42
- return false;
43
- }
44
- return prevValue.dxn.toString() !== selectedFunctionValue.dxn.toString();
45
- },
46
- (currValue) => currValue !== void 0,
47
- () => onValueChange(type, {})
48
- );
49
- const inputSchema = useMemo(() => selectedFunction?.inputSchema, [
50
- selectedFunction
51
- ]);
52
- const effectSchema = useMemo(() => inputSchema ? Type.toEffectSchema(inputSchema) : void 0, [
53
- inputSchema
54
- ]);
55
- const propertyCount = inputSchema?.properties ? Object.keys(inputSchema.properties).length : 0;
56
- const values = useMemo(() => getValue() ?? {}, [
57
- getValue
58
- ]);
59
- const handleValuesChanged = useCallback((values2) => {
60
- onValueChange(type, values2);
61
- }, [
62
- type,
63
- onValueChange
64
- ]);
65
- if (selectedFunction === void 0 || effectSchema === void 0 || propertyCount === 0) {
66
- return null;
67
- }
68
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Form.Label, {
69
- label: t("function parameters label"),
70
- asChild: true
71
- }), /* @__PURE__ */ React.createElement(Form.Root, {
72
- schema: effectSchema,
73
- values,
74
- db,
75
- onValuesChanged: handleValuesChanged
76
- }, /* @__PURE__ */ React.createElement(Form.FieldSet, null)));
77
- };
78
- FunctionInputEditor.displayName = "AutomationTrigger.FunctionInputEditor";
79
-
80
- // src/components/TriggerEditor/SpecSelector.tsx
81
- import React2, { useCallback as useCallback2, useMemo as useMemo2 } from "react";
82
- import { Filter, Query } from "@dxos/echo";
83
- import { Trigger } from "@dxos/functions";
84
- import { useTranslation as useTranslation2 } from "@dxos/react-ui";
85
- import { SelectField, useFormFieldState } from "@dxos/react-ui-form";
86
- var SpecSelector = (props) => {
87
- const { t } = useTranslation2(meta.id);
88
- const specProps = useFormFieldState(SpecSelector.displayName, [
89
- "spec"
90
- ]);
91
- const handleTypeChange = useCallback2((_type, value) => {
92
- const getDefaultTriggerSpec = (kind) => {
93
- switch (kind) {
94
- case "timer":
95
- return {
96
- kind: "timer",
97
- cron: ""
98
- };
99
- case "subscription":
100
- return {
101
- kind: "subscription",
102
- query: {
103
- ast: Query.select(Filter.nothing()).ast
104
- }
105
- };
106
- case "queue":
107
- return {
108
- kind: "queue",
109
- queue: "dxn:"
110
- };
111
- case "email":
112
- return {
113
- kind: "email"
114
- };
115
- case "webhook":
116
- return {
117
- kind: "webhook"
118
- };
119
- default:
120
- return void 0;
121
- }
122
- };
123
- const defaultSpec = getDefaultTriggerSpec(value);
124
- if (!defaultSpec) {
125
- return;
126
- }
127
- specProps.onValueChange(props.type, defaultSpec);
128
- }, [
129
- props.type,
130
- specProps
131
- ]);
132
- const options = useMemo2(() => Trigger.Kinds.map((kind) => ({
133
- value: kind,
134
- label: t(`trigger type ${kind}`)
135
- })), [
136
- t
137
- ]);
138
- return /* @__PURE__ */ React2.createElement(SelectField, {
139
- ...props,
140
- options,
141
- onValueChange: handleTypeChange
142
- });
143
- };
144
- SpecSelector.displayName = "Form.SpecSelector";
145
-
146
- // src/components/TriggerEditor/TriggerEditor.tsx
147
- var TriggerEditor = ({ db, types, tags, readonlySpec, trigger, ...formProps }) => {
148
- const fieldMap = useCustomInputs({
149
- db,
150
- types,
151
- tags,
152
- readonlySpec
153
- });
154
- return /* @__PURE__ */ React3.createElement(Form2.Root, {
155
- ...formProps,
156
- schema: omitId(Trigger2.Trigger),
157
- values: trigger,
158
- db,
159
- fieldMap
160
- }, /* @__PURE__ */ React3.createElement(Form2.Viewport, null, /* @__PURE__ */ React3.createElement(Form2.Content, null, /* @__PURE__ */ React3.createElement(Form2.FieldSet, null), /* @__PURE__ */ React3.createElement(Form2.Actions, null))));
161
- };
162
- var useCustomInputs = ({ db, readonlySpec, types, tags }) => {
163
- const functions = useQuery(db, Filter2.type(Function.Function));
164
- const workflows = useQuery(db, Filter2.type(ComputeGraph));
165
- const scripts = useQuery(db, Filter2.type(Script.Script));
166
- return useMemo3(() => ({
167
- // Function selector.
168
- ["function"]: (props) => {
169
- const getValue = useCallback3(() => {
170
- const formValue = props.getValue();
171
- if (Ref2.isRef(formValue)) {
172
- return formValue.dxn.toString();
173
- }
174
- return void 0;
175
- }, [
176
- props
177
- ]);
178
- const handleOnValueChange = useCallback3((_type, dxnString) => {
179
- const dxn = DXN.parse(dxnString);
180
- if (dxn) {
181
- const ref = Ref2.fromDXN(dxn);
182
- props.onValueChange(props.type, ref);
183
- }
184
- }, [
185
- props.type,
186
- props.onValueChange
187
- ]);
188
- return /* @__PURE__ */ React3.createElement(SelectField2, {
189
- ...props,
190
- getValue,
191
- onValueChange: handleOnValueChange,
192
- options: getWorkflowOptions(workflows).concat(getFunctionOptions(scripts, functions))
193
- });
194
- },
195
- // Spec selector.
196
- ["spec.kind"]: (props) => /* @__PURE__ */ React3.createElement(SpecSelector, {
197
- ...props,
198
- readonly: readonlySpec
199
- }),
200
- // TODO(wittjosiah): Copied from ViewEditor.
201
- // Query input editor.
202
- ["spec.query"]: (props) => {
203
- const handleChange = useCallback3((query) => props.onValueChange(props.type, {
204
- ast: query.ast
205
- }), [
206
- props.type,
207
- props.onValueChange
208
- ]);
209
- return /* @__PURE__ */ React3.createElement(Input.Root, null, /* @__PURE__ */ React3.createElement(FormFieldLabel, {
210
- label: props.label,
211
- asChild: true
212
- }), /* @__PURE__ */ React3.createElement(QueryForm, {
213
- initialQuery: props.getValue().ast,
214
- types,
215
- tags,
216
- onChange: handleChange
217
- }));
218
- },
219
- // Function input editor.
220
- ["input"]: (props) => /* @__PURE__ */ React3.createElement(FunctionInputEditor, {
221
- ...props,
222
- functions,
223
- db
224
- })
225
- }), [
226
- workflows,
227
- scripts,
228
- functions,
229
- readonlySpec
230
- ]);
231
- };
232
- var getWorkflowOptions = (graphs) => {
233
- return graphs.map((graph) => ({
234
- label: `compute-${graph.id}`,
235
- value: `dxn:echo:@:${graph.id}`
236
- }));
237
- };
238
- var getFunctionOptions = (scripts, functions) => {
239
- const getLabel = (fn) => scripts.find((s) => fn.source?.target?.id === s.id)?.name ?? fn.name;
240
- return functions.map((fn) => ({
241
- label: getLabel(fn),
242
- value: `dxn:echo:@:${fn.id}`
243
- }));
244
- };
245
-
246
- export {
247
- TriggerEditor
248
- };
249
- //# sourceMappingURL=chunk-LJAXQ6CX.mjs.map