@dxos/plugin-automation 0.8.4-main.fd6878d → 0.8.4-staging.60fe92afc8
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.
- package/LICENSE +102 -5
- package/PLUGIN.mdl +428 -0
- package/README.md +1 -1
- package/dist/lib/neutral/AutomationArticle-GN36NUX2.mjs +17 -0
- package/dist/lib/neutral/AutomationCompanion-M26WR6VP.mjs +165 -0
- package/dist/lib/neutral/AutomationCompanion-M26WR6VP.mjs.map +7 -0
- package/dist/lib/neutral/AutomationPlugin.mjs +10 -0
- package/dist/lib/neutral/AutomationPlugin.node.mjs +1132 -0
- package/dist/lib/neutral/AutomationPlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/AutomationPlugin.workerd.mjs +36 -0
- package/dist/lib/neutral/AutomationPlugin.workerd.mjs.map +7 -0
- package/dist/lib/neutral/AutomationSettings-YXUJDRQA.mjs +27 -0
- package/dist/lib/neutral/AutomationSettings-YXUJDRQA.mjs.map +7 -0
- package/dist/lib/neutral/TriggerSettings-XCHIZPOR.mjs +9 -0
- package/dist/lib/neutral/app-graph-builder-BTTHS4VK.mjs +102 -0
- package/dist/lib/neutral/app-graph-builder-BTTHS4VK.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +25 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/node.mjs +19 -0
- package/dist/lib/neutral/capabilities/node.mjs.map +7 -0
- package/dist/lib/neutral/chunk-24JKY6NU.mjs +21 -0
- package/dist/lib/neutral/chunk-24JKY6NU.mjs.map +7 -0
- package/dist/lib/neutral/chunk-2JP77CMN.mjs +42 -0
- package/dist/lib/neutral/chunk-2JP77CMN.mjs.map +7 -0
- package/dist/lib/neutral/chunk-DUGOIM7G.mjs +36 -0
- package/dist/lib/neutral/chunk-DUGOIM7G.mjs.map +7 -0
- package/dist/lib/neutral/chunk-FE7YFBX7.mjs +486 -0
- package/dist/lib/neutral/chunk-FE7YFBX7.mjs.map +7 -0
- package/dist/lib/neutral/chunk-GARB7S5R.mjs +157 -0
- package/dist/lib/neutral/chunk-GARB7S5R.mjs.map +7 -0
- package/dist/lib/neutral/chunk-HPUHQ3L6.mjs +64 -0
- package/dist/lib/neutral/chunk-HPUHQ3L6.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-SONGOJRB.mjs +8 -0
- package/dist/lib/neutral/chunk-SONGOJRB.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +48 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +15 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/create-automation-OE3TNXYE.mjs +41 -0
- package/dist/lib/neutral/create-automation-OE3TNXYE.mjs.map +7 -0
- package/dist/lib/neutral/create-object-MEJOWGMH.mjs +25 -0
- package/dist/lib/neutral/create-object-MEJOWGMH.mjs.map +7 -0
- package/dist/lib/neutral/create-trigger-from-template-TERHKWJM.mjs +68 -0
- package/dist/lib/neutral/create-trigger-from-template-TERHKWJM.mjs.map +7 -0
- package/dist/lib/neutral/hooks/index.mjs +47 -0
- package/dist/lib/neutral/hooks/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +22 -0
- package/dist/lib/neutral/layer-specs-G6GCH7BE.mjs +137 -0
- package/dist/lib/neutral/layer-specs-G6GCH7BE.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +8 -0
- package/dist/lib/neutral/navigation-resolver-I3L5FHJO.mjs +14 -0
- package/dist/lib/neutral/navigation-resolver-I3L5FHJO.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-YXGYH5W5.mjs +13 -0
- package/dist/lib/neutral/operation-handler-YXGYH5W5.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/operations/index.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-IBRWUKPC.mjs +54 -0
- package/dist/lib/neutral/react-surface-IBRWUKPC.mjs.map +7 -0
- package/dist/lib/neutral/registry-sync-G6TKKZGK.mjs +86 -0
- package/dist/lib/neutral/registry-sync-G6TKKZGK.mjs.map +7 -0
- package/dist/lib/neutral/templates-ETXVD3VE.mjs +16 -0
- package/dist/lib/neutral/templates-ETXVD3VE.mjs.map +7 -0
- package/dist/lib/neutral/testing.mjs +8 -0
- package/dist/lib/neutral/testing.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +64 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/trigger-runtime-controller-BOEJYGWC.mjs +77 -0
- package/dist/lib/neutral/trigger-runtime-controller-BOEJYGWC.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +18 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/types/src/AutomationPlugin.d.ts +3 -1
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- package/dist/types/src/AutomationPlugin.node.d.ts +4 -0
- package/dist/types/src/AutomationPlugin.node.d.ts.map +1 -0
- package/dist/types/src/AutomationPlugin.test.d.ts +2 -0
- package/dist/types/src/AutomationPlugin.test.d.ts.map +1 -0
- package/dist/types/src/AutomationPlugin.workerd.d.ts +4 -0
- package/dist/types/src/AutomationPlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/create-object.d.ts +11 -0
- package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
- package/dist/types/src/capabilities/create-object.test.d.ts +2 -0
- package/dist/types/src/capabilities/create-object.test.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +16 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/layer-specs.d.ts +6 -0
- package/dist/types/src/capabilities/layer-specs.d.ts.map +1 -0
- package/dist/types/src/capabilities/navigation-resolver.d.ts +6 -0
- package/dist/types/src/capabilities/navigation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/node.d.ts +9 -0
- package/dist/types/src/capabilities/node.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/registry-sync.d.ts +21 -0
- package/dist/types/src/capabilities/registry-sync.d.ts.map +1 -0
- package/dist/types/src/capabilities/templates.d.ts +6 -0
- package/dist/types/src/capabilities/templates.d.ts.map +1 -0
- package/dist/types/src/capabilities/trigger-runtime-controller.d.ts +5 -0
- package/dist/types/src/capabilities/trigger-runtime-controller.d.ts.map +1 -0
- package/dist/types/src/capabilities/trigger-runtime-controller.test.d.ts +2 -0
- package/dist/types/src/capabilities/trigger-runtime-controller.test.d.ts.map +1 -0
- package/dist/types/src/commands/index.d.ts +2 -0
- package/dist/types/src/commands/index.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/create/index.d.ts +25 -0
- package/dist/types/src/commands/trigger/create/index.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/create/queue.d.ts +13 -0
- package/dist/types/src/commands/trigger/create/queue.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/create/subscription.d.ts +15 -0
- package/dist/types/src/commands/trigger/create/subscription.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/create/timer.d.ts +13 -0
- package/dist/types/src/commands/trigger/create/timer.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/index.d.ts +57 -0
- package/dist/types/src/commands/trigger/index.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/list.d.ts +7 -0
- package/dist/types/src/commands/trigger/list.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/options.d.ts +10 -0
- package/dist/types/src/commands/trigger/options.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/remove.d.ts +8 -0
- package/dist/types/src/commands/trigger/remove.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/update/index.d.ts +28 -0
- package/dist/types/src/commands/trigger/update/index.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/update/queue.d.ts +11 -0
- package/dist/types/src/commands/trigger/update/queue.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/update/subscription.d.ts +13 -0
- package/dist/types/src/commands/trigger/update/subscription.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/update/timer.d.ts +11 -0
- package/dist/types/src/commands/trigger/update/timer.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/util.d.ts +85 -0
- package/dist/types/src/commands/trigger/util.d.ts.map +1 -0
- package/dist/types/src/components/CreateAutomationPanel/CreateAutomationPanel.d.ts +14 -0
- package/dist/types/src/components/CreateAutomationPanel/CreateAutomationPanel.d.ts.map +1 -0
- package/dist/types/src/components/CreateAutomationPanel/index.d.ts +2 -0
- package/dist/types/src/components/CreateAutomationPanel/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +1 -7
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/AutomationArticle/AutomationArticle.d.ts +35 -0
- package/dist/types/src/containers/AutomationArticle/AutomationArticle.d.ts.map +1 -0
- package/dist/types/src/containers/AutomationArticle/index.d.ts +3 -0
- package/dist/types/src/containers/AutomationArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/AutomationCompanion/AutomationCompanion.d.ts +13 -0
- package/dist/types/src/containers/AutomationCompanion/AutomationCompanion.d.ts.map +1 -0
- package/dist/types/src/containers/AutomationCompanion/index.d.ts +3 -0
- package/dist/types/src/containers/AutomationCompanion/index.d.ts.map +1 -0
- package/dist/types/src/containers/AutomationSettings/AutomationSettings.d.ts +10 -0
- package/dist/types/src/containers/AutomationSettings/AutomationSettings.d.ts.map +1 -0
- package/dist/types/src/containers/AutomationSettings/index.d.ts +2 -0
- package/dist/types/src/containers/AutomationSettings/index.d.ts.map +1 -0
- package/dist/types/src/containers/TriggerSettings/TriggerSettings.d.ts +6 -0
- package/dist/types/src/containers/TriggerSettings/TriggerSettings.d.ts.map +1 -0
- package/dist/types/src/containers/TriggerSettings/index.d.ts +3 -0
- package/dist/types/src/containers/TriggerSettings/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +6 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +2 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts +12 -0
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/create-automation.d.ts +5 -0
- package/dist/types/src/operations/create-automation.d.ts.map +1 -0
- package/dist/types/src/operations/create-trigger-from-template.d.ts +5 -0
- package/dist/types/src/operations/create-trigger-from-template.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/paths.d.ts +3 -0
- package/dist/types/src/paths.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/templates/index.d.ts +10 -0
- package/dist/types/src/templates/index.d.ts.map +1 -0
- package/dist/types/src/testing/test-functions.d.ts +318 -3
- package/dist/types/src/testing/test-functions.d.ts.map +1 -1
- package/dist/types/src/testing.d.ts +2 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +90 -26
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Automation.d.ts +41 -0
- package/dist/types/src/types/Automation.d.ts.map +1 -0
- package/dist/types/src/types/Automation.test.d.ts +2 -0
- package/dist/types/src/types/Automation.test.d.ts.map +1 -0
- package/dist/types/src/types/AutomationCapabilities.d.ts +42 -0
- package/dist/types/src/types/AutomationCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/AutomationOperation.d.ts +31 -0
- package/dist/types/src/types/AutomationOperation.d.ts.map +1 -0
- package/dist/types/src/types/Runnable.d.ts +14 -0
- package/dist/types/src/types/Runnable.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +4 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +14 -6
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/util/automations-for-object.d.ts +20 -0
- package/dist/types/src/util/automations-for-object.d.ts.map +1 -0
- package/dist/types/src/util/automations-for-object.test.d.ts +2 -0
- package/dist/types/src/util/automations-for-object.test.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +140 -52
- package/src/AutomationPlugin.node.ts +48 -0
- package/src/AutomationPlugin.test.ts +27 -0
- package/src/AutomationPlugin.tsx +52 -34
- package/src/AutomationPlugin.workerd.ts +24 -0
- package/src/capabilities/app-graph-builder.ts +82 -78
- package/src/capabilities/create-object.test.ts +18 -0
- package/src/capabilities/create-object.ts +26 -0
- package/src/capabilities/index.ts +17 -4
- package/src/capabilities/layer-specs.ts +196 -0
- package/src/capabilities/navigation-resolver.ts +19 -0
- package/src/capabilities/node.ts +19 -0
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +45 -46
- package/src/capabilities/registry-sync.ts +114 -0
- package/src/capabilities/templates.ts +17 -0
- package/src/capabilities/trigger-runtime-controller.test.ts +107 -0
- package/src/capabilities/trigger-runtime-controller.ts +126 -0
- package/src/commands/index.ts +5 -0
- package/src/commands/trigger/create/index.ts +14 -0
- package/src/commands/trigger/create/queue.ts +87 -0
- package/src/commands/trigger/create/subscription.ts +126 -0
- package/src/commands/trigger/create/timer.ts +90 -0
- package/src/commands/trigger/index.ts +16 -0
- package/src/commands/trigger/list.ts +69 -0
- package/src/commands/trigger/options.ts +47 -0
- package/src/commands/trigger/remove.ts +45 -0
- package/src/commands/trigger/update/index.ts +14 -0
- package/src/commands/trigger/update/queue.ts +191 -0
- package/src/commands/trigger/update/subscription.ts +279 -0
- package/src/commands/trigger/update/timer.ts +195 -0
- package/src/commands/trigger/util.ts +410 -0
- package/src/components/CreateAutomationPanel/CreateAutomationPanel.tsx +68 -0
- package/src/components/CreateAutomationPanel/index.ts +5 -0
- package/src/components/index.ts +1 -8
- package/src/containers/AutomationArticle/AutomationArticle.tsx +586 -0
- package/src/containers/AutomationArticle/index.ts +6 -0
- package/src/containers/AutomationCompanion/AutomationCompanion.tsx +183 -0
- package/src/containers/AutomationCompanion/index.ts +6 -0
- package/src/containers/AutomationSettings/AutomationSettings.tsx +34 -0
- package/src/containers/AutomationSettings/index.ts +5 -0
- package/src/containers/TriggerSettings/TriggerSettings.tsx +48 -0
- package/src/containers/TriggerSettings/index.ts +6 -0
- package/src/containers/index.ts +10 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/useTriggerRuntimeControls.ts +72 -0
- package/src/index.ts +1 -3
- package/src/meta.ts +26 -9
- package/src/operations/create-automation.ts +38 -0
- package/src/operations/create-trigger-from-template.ts +70 -0
- package/src/operations/index.ts +10 -0
- package/src/paths.ts +13 -0
- package/src/plugin.ts +11 -0
- package/src/templates/index.ts +22 -0
- package/src/testing/test-functions.ts +44 -10
- package/src/testing.ts +7 -0
- package/src/translations.ts +49 -26
- package/src/types/Automation.test.ts +37 -0
- package/src/types/Automation.ts +45 -0
- package/src/types/AutomationCapabilities.ts +52 -0
- package/src/types/AutomationOperation.ts +61 -0
- package/src/types/Runnable.ts +14 -0
- package/src/types/index.ts +5 -0
- package/src/types/schema.ts +7 -7
- package/src/util/automations-for-object.test.ts +86 -0
- package/src/util/automations-for-object.ts +72 -0
- package/src/vite-env.d.ts +10 -0
- package/dist/lib/browser/AutomationContainer-5UYKI7EG.mjs +0 -38
- package/dist/lib/browser/AutomationContainer-5UYKI7EG.mjs.map +0 -7
- package/dist/lib/browser/AutomationPanel-YYERBNYJ.mjs +0 -11
- package/dist/lib/browser/FunctionsContainer-VOGKIPHA.mjs +0 -39
- package/dist/lib/browser/FunctionsContainer-VOGKIPHA.mjs.map +0 -7
- package/dist/lib/browser/FunctionsPanel-I443Y6KB.mjs +0 -10
- package/dist/lib/browser/app-graph-builder-4OFKIRAI.mjs +0 -80
- package/dist/lib/browser/app-graph-builder-4OFKIRAI.mjs.map +0 -7
- package/dist/lib/browser/chunk-7EE4SA6M.mjs +0 -230
- package/dist/lib/browser/chunk-7EE4SA6M.mjs.map +0 -7
- package/dist/lib/browser/chunk-CHENFUQ6.mjs +0 -14
- package/dist/lib/browser/chunk-CHENFUQ6.mjs.map +0 -7
- package/dist/lib/browser/chunk-GW5U2DGT.mjs +0 -15
- package/dist/lib/browser/chunk-GW5U2DGT.mjs.map +0 -7
- package/dist/lib/browser/chunk-HN7OHFCB.mjs +0 -38
- package/dist/lib/browser/chunk-HN7OHFCB.mjs.map +0 -7
- package/dist/lib/browser/chunk-OX6OW6XP.mjs +0 -147
- package/dist/lib/browser/chunk-OX6OW6XP.mjs.map +0 -7
- package/dist/lib/browser/chunk-Z5DT4MHW.mjs +0 -94
- package/dist/lib/browser/chunk-Z5DT4MHW.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -101
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-YZP6RKTR.mjs +0 -76
- package/dist/lib/browser/intent-resolver-YZP6RKTR.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-WNOIIT4O.mjs +0 -64
- package/dist/lib/browser/react-surface-WNOIIT4O.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -8
- package/dist/lib/node-esm/AutomationContainer-EZMY6DTD.mjs +0 -39
- package/dist/lib/node-esm/AutomationContainer-EZMY6DTD.mjs.map +0 -7
- package/dist/lib/node-esm/AutomationPanel-5EQQF5S2.mjs +0 -12
- package/dist/lib/node-esm/FunctionsContainer-IHLMLXHH.mjs +0 -40
- package/dist/lib/node-esm/FunctionsContainer-IHLMLXHH.mjs.map +0 -7
- package/dist/lib/node-esm/FunctionsPanel-ELINCXPW.mjs +0 -11
- package/dist/lib/node-esm/app-graph-builder-555IHYOB.mjs +0 -81
- package/dist/lib/node-esm/app-graph-builder-555IHYOB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CX2AILIS.mjs +0 -95
- package/dist/lib/node-esm/chunk-CX2AILIS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-D4VWZD53.mjs +0 -16
- package/dist/lib/node-esm/chunk-D4VWZD53.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GHRG4NQV.mjs +0 -148
- package/dist/lib/node-esm/chunk-GHRG4NQV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NK5N3QKD.mjs +0 -17
- package/dist/lib/node-esm/chunk-NK5N3QKD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OEZNHUL2.mjs +0 -39
- package/dist/lib/node-esm/chunk-OEZNHUL2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YPUO4IVX.mjs +0 -231
- package/dist/lib/node-esm/chunk-YPUO4IVX.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -102
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-TSLQE27W.mjs +0 -77
- package/dist/lib/node-esm/intent-resolver-TSLQE27W.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/react-surface-K6MQFIAS.mjs +0 -65
- package/dist/lib/node-esm/react-surface-K6MQFIAS.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -9
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/components/AutomationContainer.d.ts +0 -5
- package/dist/types/src/components/AutomationContainer.d.ts.map +0 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +0 -12
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +0 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts +0 -6
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +0 -1
- package/dist/types/src/components/AutomationPanel/index.d.ts +0 -4
- package/dist/types/src/components/AutomationPanel/index.d.ts.map +0 -1
- package/dist/types/src/components/FunctionsContainer.d.ts +0 -7
- package/dist/types/src/components/FunctionsContainer.d.ts.map +0 -1
- package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts +0 -7
- package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts.map +0 -1
- package/dist/types/src/components/FunctionsPanel/index.d.ts +0 -4
- package/dist/types/src/components/FunctionsPanel/index.d.ts.map +0 -1
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts +0 -12
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts.map +0 -1
- package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts +0 -5
- package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts.map +0 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +0 -11
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +0 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +0 -6
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +0 -1
- package/dist/types/src/components/TriggerEditor/index.d.ts +0 -2
- package/dist/types/src/components/TriggerEditor/index.d.ts.map +0 -1
- package/src/capabilities/intent-resolver.ts +0 -72
- package/src/components/AutomationContainer.tsx +0 -31
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +0 -58
- package/src/components/AutomationPanel/AutomationPanel.tsx +0 -171
- package/src/components/AutomationPanel/index.ts +0 -9
- package/src/components/FunctionsContainer.tsx +0 -32
- package/src/components/FunctionsPanel/FunctionsPanel.tsx +0 -97
- package/src/components/FunctionsPanel/index.ts +0 -8
- package/src/components/TriggerEditor/FunctionInputEditor.tsx +0 -78
- package/src/components/TriggerEditor/SpecSelector.tsx +0 -59
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +0 -79
- package/src/components/TriggerEditor/TriggerEditor.tsx +0 -107
- package/src/components/TriggerEditor/index.ts +0 -5
- /package/dist/lib/{browser/AutomationPanel-YYERBNYJ.mjs.map → neutral/AutomationArticle-GN36NUX2.mjs.map} +0 -0
- /package/dist/lib/{browser/FunctionsPanel-I443Y6KB.mjs.map → neutral/AutomationPlugin.mjs.map} +0 -0
- /package/dist/lib/{browser/types/index.mjs.map → neutral/TriggerSettings-XCHIZPOR.mjs.map} +0 -0
- /package/dist/lib/{node-esm/AutomationPanel-5EQQF5S2.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/{node-esm/types → neutral}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/FunctionsPanel-ELINCXPW.mjs.map → neutral/meta.mjs.map} +0 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
import * as Fiber from 'effect/Fiber';
|
|
7
|
+
|
|
8
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
9
|
+
import { type ComputeEnvironment } from '@dxos/client-protocol';
|
|
10
|
+
import { ServiceResolver } from '@dxos/compute';
|
|
11
|
+
import { Obj } from '@dxos/echo';
|
|
12
|
+
import { TriggerDispatcher } from '@dxos/functions-runtime';
|
|
13
|
+
import { type SpaceId } from '@dxos/keys';
|
|
14
|
+
import { log } from '@dxos/log';
|
|
15
|
+
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
16
|
+
import { type Space } from '@dxos/react-client/echo';
|
|
17
|
+
|
|
18
|
+
//
|
|
19
|
+
// Capability Module
|
|
20
|
+
//
|
|
21
|
+
// Watches `space.properties.computeEnvironment` for every space and toggles
|
|
22
|
+
// the per-space {@link TriggerDispatcher} accordingly:
|
|
23
|
+
//
|
|
24
|
+
// - `local` → `dispatcher.start()`
|
|
25
|
+
// - `edge` / `disabled` → `dispatcher.stop()`
|
|
26
|
+
//
|
|
27
|
+
// Replaces the in-line watcher that used to live inside the removed
|
|
28
|
+
// `compute-runtime.ts` per-space layer. The dispatcher itself is now
|
|
29
|
+
// contributed unconditionally via `TriggerDispatcherSpec` in `layer-specs.ts`,
|
|
30
|
+
// so this capability is only responsible for driving its lifecycle.
|
|
31
|
+
//
|
|
32
|
+
|
|
33
|
+
/** Trigger execution location the dispatcher should run locally. */
|
|
34
|
+
const LOCAL_ENVIRONMENT: ComputeEnvironment = 'local';
|
|
35
|
+
|
|
36
|
+
export default Capability.makeModule(
|
|
37
|
+
Effect.fnUntraced(function* () {
|
|
38
|
+
const client = yield* Capability.get(ClientCapabilities.Client);
|
|
39
|
+
const runtime = yield* Capability.get(Capabilities.ProcessManagerRuntime);
|
|
40
|
+
|
|
41
|
+
/** Per-space property-subscription unsubscribe, last-seen environment, and in-flight transition fiber. */
|
|
42
|
+
type Tracker = {
|
|
43
|
+
unsubscribe: () => void;
|
|
44
|
+
lastEnvironment?: ComputeEnvironment;
|
|
45
|
+
inFlight?: Fiber.RuntimeFiber<unknown, unknown>;
|
|
46
|
+
};
|
|
47
|
+
const trackers = new Map<SpaceId, Tracker>();
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Resolve the per-space `TriggerDispatcher` from the process-manager
|
|
51
|
+
* runtime and invoke `start()` / `stop()` according to the requested
|
|
52
|
+
* environment. Returns a fiber so the caller can cancel a pending
|
|
53
|
+
* transition when a new one supersedes it.
|
|
54
|
+
*/
|
|
55
|
+
const transition = (spaceId: SpaceId, environment: ComputeEnvironment) =>
|
|
56
|
+
runtime.runFork(
|
|
57
|
+
Effect.gen(function* () {
|
|
58
|
+
const dispatcher = yield* TriggerDispatcher;
|
|
59
|
+
yield* environment === LOCAL_ENVIRONMENT ? dispatcher.start() : dispatcher.stop();
|
|
60
|
+
}).pipe(
|
|
61
|
+
Effect.provide(ServiceResolver.provide({ space: spaceId }, TriggerDispatcher)),
|
|
62
|
+
Effect.tapErrorCause((cause) =>
|
|
63
|
+
Effect.sync(() => log.warn('trigger dispatcher transition failed', { spaceId, environment, cause })),
|
|
64
|
+
),
|
|
65
|
+
),
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const apply = (tracker: Tracker, spaceId: SpaceId, environment: ComputeEnvironment): void => {
|
|
69
|
+
if (tracker.lastEnvironment === environment) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
tracker.lastEnvironment = environment;
|
|
73
|
+
if (tracker.inFlight) {
|
|
74
|
+
runtime.runFork(Fiber.interrupt(tracker.inFlight));
|
|
75
|
+
}
|
|
76
|
+
tracker.inFlight = transition(spaceId, environment);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const install = (space: Space): void => {
|
|
80
|
+
if (trackers.has(space.id)) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
// Reserve the slot synchronously so concurrent `client.spaces.subscribe`
|
|
84
|
+
// notifications (e.g. spaces array churn while we await readiness) don't
|
|
85
|
+
// wire a second subscriber for the same space.
|
|
86
|
+
const tracker: Tracker = { unsubscribe: () => {} };
|
|
87
|
+
trackers.set(space.id, tracker);
|
|
88
|
+
|
|
89
|
+
void space
|
|
90
|
+
.waitUntilReady()
|
|
91
|
+
.then(() => {
|
|
92
|
+
// The capability could have been torn down between `set` and the
|
|
93
|
+
// promise resolving; bail out without subscribing in that case.
|
|
94
|
+
if (trackers.get(space.id) !== tracker) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const readEnvironment = (): ComputeEnvironment => space.properties.computeEnvironment ?? LOCAL_ENVIRONMENT;
|
|
98
|
+
tracker.unsubscribe = Obj.subscribe(space.properties, () => apply(tracker, space.id, readEnvironment()));
|
|
99
|
+
apply(tracker, space.id, readEnvironment());
|
|
100
|
+
})
|
|
101
|
+
.catch((err) => log.catch(err));
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const installAll = (spaces: readonly Space[]): void => {
|
|
105
|
+
for (const space of spaces) {
|
|
106
|
+
install(space);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const spacesSubscription = client.spaces.subscribe(installAll);
|
|
111
|
+
installAll(client.spaces.get());
|
|
112
|
+
|
|
113
|
+
return Capability.contributes(Capabilities.Null, null, () =>
|
|
114
|
+
Effect.sync(() => {
|
|
115
|
+
spacesSubscription.unsubscribe();
|
|
116
|
+
for (const tracker of trackers.values()) {
|
|
117
|
+
tracker.unsubscribe();
|
|
118
|
+
if (tracker.inFlight) {
|
|
119
|
+
runtime.runFork(Fiber.interrupt(tracker.inFlight));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
trackers.clear();
|
|
123
|
+
}),
|
|
124
|
+
);
|
|
125
|
+
}),
|
|
126
|
+
);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Command from '@effect/cli/Command';
|
|
6
|
+
|
|
7
|
+
import { queue } from './queue';
|
|
8
|
+
import { subscription } from './subscription';
|
|
9
|
+
import { timer } from './timer';
|
|
10
|
+
|
|
11
|
+
export const create = Command.make('create').pipe(
|
|
12
|
+
Command.withDescription('Create a trigger.'),
|
|
13
|
+
Command.withSubcommands([subscription, timer, queue]),
|
|
14
|
+
);
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Command from '@effect/cli/Command';
|
|
6
|
+
import * as Options from '@effect/cli/Options';
|
|
7
|
+
import * as Prompt from '@effect/cli/Prompt';
|
|
8
|
+
import * as Console from 'effect/Console';
|
|
9
|
+
import * as Effect from 'effect/Effect';
|
|
10
|
+
import * as HashMap from 'effect/HashMap';
|
|
11
|
+
import * as Option from 'effect/Option';
|
|
12
|
+
|
|
13
|
+
import { CommandConfig } from '@dxos/cli-util';
|
|
14
|
+
import { flushAndSync, print, spaceLayer, withTypes } from '@dxos/cli-util';
|
|
15
|
+
import { Common } from '@dxos/cli-util';
|
|
16
|
+
import { Operation, Trigger } from '@dxos/compute';
|
|
17
|
+
import { Database, Feed as FeedNs, Filter, JsonSchema, Ref } from '@dxos/echo';
|
|
18
|
+
import { EID } from '@dxos/keys';
|
|
19
|
+
|
|
20
|
+
import { Enabled, Feed, Input } from '../options';
|
|
21
|
+
import { printTrigger, promptForSchemaInput, selectFunction, selectFeed } from '../util';
|
|
22
|
+
|
|
23
|
+
export const queue = Command.make(
|
|
24
|
+
'feed',
|
|
25
|
+
{
|
|
26
|
+
spaceId: Common.spaceId.pipe(Options.optional),
|
|
27
|
+
enabled: Enabled,
|
|
28
|
+
functionId: Common.functionId.pipe(Options.optional),
|
|
29
|
+
feed: Feed.pipe(Options.optional),
|
|
30
|
+
input: Input.pipe(Options.optional),
|
|
31
|
+
},
|
|
32
|
+
(options) =>
|
|
33
|
+
Effect.gen(function* () {
|
|
34
|
+
const { json } = yield* CommandConfig;
|
|
35
|
+
|
|
36
|
+
const functionId = yield* Option.match(options.functionId, {
|
|
37
|
+
onNone: () => selectFunction(),
|
|
38
|
+
onSome: (id) => Effect.succeed(id),
|
|
39
|
+
});
|
|
40
|
+
const functions = yield* Database.query(Filter.type(Operation.PersistentOperation)).run;
|
|
41
|
+
const fn = functions.find((fn) => fn.id === functionId);
|
|
42
|
+
if (!fn) {
|
|
43
|
+
return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const feed = yield* Option.match(options.feed, {
|
|
47
|
+
onNone: () => selectFeed(),
|
|
48
|
+
onSome: (uri) => Database.resolve(EID.parse(uri), FeedNs.Feed),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const input = yield* Option.match(options.input, {
|
|
52
|
+
onNone: () => promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined),
|
|
53
|
+
onSome: (value) => Effect.succeed(Object.fromEntries(HashMap.toEntries(value))),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Always prompt for enabled if functionId is not provided.
|
|
57
|
+
const enabled = yield* Option.match(options.functionId, {
|
|
58
|
+
onNone: () =>
|
|
59
|
+
Prompt.confirm({
|
|
60
|
+
message: 'Enable the trigger?',
|
|
61
|
+
initial: true,
|
|
62
|
+
}).pipe(Prompt.run),
|
|
63
|
+
onSome: () => Effect.succeed(options.enabled),
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const trigger = Trigger.make({
|
|
67
|
+
function: Ref.make(fn),
|
|
68
|
+
enabled,
|
|
69
|
+
spec: Trigger.specFeed(feed),
|
|
70
|
+
input,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
yield* Database.add(trigger);
|
|
74
|
+
|
|
75
|
+
if (json) {
|
|
76
|
+
yield* Console.log(JSON.stringify(trigger, null, 2));
|
|
77
|
+
} else {
|
|
78
|
+
yield* Console.log(print(yield* printTrigger(trigger)));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
yield* flushAndSync({ indexes: true });
|
|
82
|
+
}),
|
|
83
|
+
).pipe(
|
|
84
|
+
Command.withDescription('Create a feed trigger.'),
|
|
85
|
+
Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
|
|
86
|
+
Command.provideEffectDiscard(() => withTypes(Operation.PersistentOperation, Trigger.Trigger)),
|
|
87
|
+
);
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Command from '@effect/cli/Command';
|
|
6
|
+
import * as Options from '@effect/cli/Options';
|
|
7
|
+
import * as Prompt from '@effect/cli/Prompt';
|
|
8
|
+
import * as Console from 'effect/Console';
|
|
9
|
+
import * as Effect from 'effect/Effect';
|
|
10
|
+
import * as HashMap from 'effect/HashMap';
|
|
11
|
+
import * as Option from 'effect/Option';
|
|
12
|
+
|
|
13
|
+
import { CommandConfig } from '@dxos/cli-util';
|
|
14
|
+
import { flushAndSync, print, spaceLayer, withTypes } from '@dxos/cli-util';
|
|
15
|
+
import { Common } from '@dxos/cli-util';
|
|
16
|
+
import { Operation, Trigger } from '@dxos/compute';
|
|
17
|
+
import { Database, Filter, JsonSchema, Query, Ref } from '@dxos/echo';
|
|
18
|
+
import { DXN } from '@dxos/keys';
|
|
19
|
+
|
|
20
|
+
import { Deep, Delay, Enabled, Input, Typename } from '../options';
|
|
21
|
+
import { printTrigger, promptForSchemaInput, selectFunction } from '../util';
|
|
22
|
+
|
|
23
|
+
export const subscription = Command.make(
|
|
24
|
+
'subscription',
|
|
25
|
+
{
|
|
26
|
+
spaceId: Common.spaceId.pipe(Options.optional),
|
|
27
|
+
enabled: Enabled,
|
|
28
|
+
functionId: Common.functionId.pipe(Options.optional),
|
|
29
|
+
typename: Typename.pipe(Options.optional),
|
|
30
|
+
deep: Deep.pipe(Options.optional),
|
|
31
|
+
delay: Delay.pipe(Options.optional),
|
|
32
|
+
input: Input.pipe(Options.optional),
|
|
33
|
+
},
|
|
34
|
+
(options) =>
|
|
35
|
+
Effect.gen(function* () {
|
|
36
|
+
const { json } = yield* CommandConfig;
|
|
37
|
+
|
|
38
|
+
const functionId = yield* Option.match(options.functionId, {
|
|
39
|
+
onNone: () => selectFunction(),
|
|
40
|
+
onSome: (id) => Effect.succeed(id),
|
|
41
|
+
});
|
|
42
|
+
const functions = yield* Database.query(Filter.type(Operation.PersistentOperation)).run;
|
|
43
|
+
const fn = functions.find((fn) => fn.id === functionId);
|
|
44
|
+
if (!fn) {
|
|
45
|
+
return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const typename = yield* Option.match(options.typename, {
|
|
49
|
+
onNone: () =>
|
|
50
|
+
Prompt.text({
|
|
51
|
+
message: 'Enter type name:',
|
|
52
|
+
}).pipe(Prompt.run),
|
|
53
|
+
onSome: (value) => Effect.succeed(value),
|
|
54
|
+
});
|
|
55
|
+
const subscriptionQuery = Query.select(Filter.type(DXN.make(typename)));
|
|
56
|
+
|
|
57
|
+
const deepOption = yield* Option.match(options.deep, {
|
|
58
|
+
onNone: () =>
|
|
59
|
+
Prompt.confirm({
|
|
60
|
+
message: 'Watch changes to nested properties (deep)?',
|
|
61
|
+
initial: false,
|
|
62
|
+
}).pipe(
|
|
63
|
+
Prompt.run,
|
|
64
|
+
Effect.map((value) => (value ? Option.some(value) : Option.none())),
|
|
65
|
+
),
|
|
66
|
+
onSome: () => Effect.succeed(Option.some(true)),
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const delayOption = yield* Option.match(options.delay, {
|
|
70
|
+
onNone: () =>
|
|
71
|
+
Effect.gen(function* () {
|
|
72
|
+
const delayStr = yield* Prompt.text({
|
|
73
|
+
message: 'Debounce delay in milliseconds (optional, press Enter to skip):',
|
|
74
|
+
}).pipe(Prompt.run);
|
|
75
|
+
return delayStr === '' ? Option.none<number>() : Option.some(parseInt(delayStr, 10));
|
|
76
|
+
}),
|
|
77
|
+
onSome: (value) => Effect.succeed(Option.some(value)),
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const subscriptionOptions: { deep?: boolean; delay?: number } = {};
|
|
81
|
+
if (Option.isSome(deepOption)) {
|
|
82
|
+
subscriptionOptions.deep = deepOption.value;
|
|
83
|
+
}
|
|
84
|
+
if (Option.isSome(delayOption)) {
|
|
85
|
+
subscriptionOptions.delay = delayOption.value;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const input = yield* Option.match(options.input, {
|
|
89
|
+
onNone: () => promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined),
|
|
90
|
+
onSome: (value) => Effect.succeed(Object.fromEntries(HashMap.toEntries(value))),
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Always prompt for enabled if functionId is not provided.
|
|
94
|
+
const enabled = yield* Option.match(options.functionId, {
|
|
95
|
+
onNone: () =>
|
|
96
|
+
Prompt.confirm({
|
|
97
|
+
message: 'Enable the trigger?',
|
|
98
|
+
initial: true,
|
|
99
|
+
}).pipe(Prompt.run),
|
|
100
|
+
onSome: () => Effect.succeed(options.enabled),
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const trigger = Trigger.make({
|
|
104
|
+
function: Ref.make(fn),
|
|
105
|
+
enabled,
|
|
106
|
+
spec: Trigger.specSubscription(
|
|
107
|
+
subscriptionQuery,
|
|
108
|
+
Object.keys(subscriptionOptions).length > 0 ? subscriptionOptions : undefined,
|
|
109
|
+
),
|
|
110
|
+
input,
|
|
111
|
+
});
|
|
112
|
+
yield* Database.add(trigger);
|
|
113
|
+
|
|
114
|
+
if (json) {
|
|
115
|
+
yield* Console.log(JSON.stringify(trigger, null, 2));
|
|
116
|
+
} else {
|
|
117
|
+
yield* Console.log(print(yield* printTrigger(trigger)));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
yield* flushAndSync({ indexes: true });
|
|
121
|
+
}),
|
|
122
|
+
).pipe(
|
|
123
|
+
Command.withDescription('Create a subscription trigger.'),
|
|
124
|
+
Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
|
|
125
|
+
Command.provideEffectDiscard(() => withTypes(Operation.PersistentOperation, Trigger.Trigger)),
|
|
126
|
+
);
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Command from '@effect/cli/Command';
|
|
6
|
+
import * as Options from '@effect/cli/Options';
|
|
7
|
+
import * as Prompt from '@effect/cli/Prompt';
|
|
8
|
+
import * as Console from 'effect/Console';
|
|
9
|
+
import * as Effect from 'effect/Effect';
|
|
10
|
+
import * as HashMap from 'effect/HashMap';
|
|
11
|
+
import * as Option from 'effect/Option';
|
|
12
|
+
|
|
13
|
+
import { CommandConfig } from '@dxos/cli-util';
|
|
14
|
+
import { flushAndSync, print, spaceLayer, withTypes } from '@dxos/cli-util';
|
|
15
|
+
import { Common } from '@dxos/cli-util';
|
|
16
|
+
import { Operation, Trigger } from '@dxos/compute';
|
|
17
|
+
import { Database, Filter, JsonSchema, Ref } from '@dxos/echo';
|
|
18
|
+
|
|
19
|
+
import { Cron, Enabled, Input } from '../options';
|
|
20
|
+
import { printTrigger, promptForSchemaInput, selectFunction } from '../util';
|
|
21
|
+
|
|
22
|
+
// trigger create timer --cron "0 0 * * *" --functionId <functionId>
|
|
23
|
+
export const timer = Command.make(
|
|
24
|
+
'timer',
|
|
25
|
+
{
|
|
26
|
+
spaceId: Common.spaceId.pipe(Options.optional),
|
|
27
|
+
enabled: Enabled,
|
|
28
|
+
functionId: Common.functionId.pipe(Options.optional),
|
|
29
|
+
cron: Cron.pipe(Options.optional),
|
|
30
|
+
input: Input.pipe(Options.optional),
|
|
31
|
+
},
|
|
32
|
+
(options) =>
|
|
33
|
+
Effect.gen(function* () {
|
|
34
|
+
const { json } = yield* CommandConfig;
|
|
35
|
+
|
|
36
|
+
const functionId = yield* Option.match(options.functionId, {
|
|
37
|
+
onNone: () => selectFunction(),
|
|
38
|
+
onSome: (id) => Effect.succeed(id),
|
|
39
|
+
});
|
|
40
|
+
const functions = yield* Database.query(Filter.type(Operation.PersistentOperation)).run;
|
|
41
|
+
const fn = functions.find((fn) => fn.id === functionId);
|
|
42
|
+
if (!fn) {
|
|
43
|
+
return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const cron = yield* Option.match(options.cron, {
|
|
47
|
+
onNone: () =>
|
|
48
|
+
Prompt.text({
|
|
49
|
+
message: 'Enter cron expression:',
|
|
50
|
+
}).pipe(Prompt.run),
|
|
51
|
+
onSome: (value) => Effect.succeed(value),
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const input = yield* Option.match(options.input, {
|
|
55
|
+
onNone: () => promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined),
|
|
56
|
+
onSome: (value) => Effect.succeed(Object.fromEntries(HashMap.toEntries(value))),
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// Always prompt for enabled if functionId is not provided.
|
|
60
|
+
const enabled = yield* Option.match(options.functionId, {
|
|
61
|
+
onNone: () =>
|
|
62
|
+
Prompt.confirm({
|
|
63
|
+
message: 'Enable the trigger?',
|
|
64
|
+
initial: true,
|
|
65
|
+
}).pipe(Prompt.run),
|
|
66
|
+
onSome: () => Effect.succeed(options.enabled),
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const trigger = Trigger.make({
|
|
70
|
+
function: Ref.make(fn),
|
|
71
|
+
enabled,
|
|
72
|
+
spec: Trigger.specTimer(cron),
|
|
73
|
+
input,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
yield* Database.add(trigger);
|
|
77
|
+
|
|
78
|
+
if (json) {
|
|
79
|
+
yield* Console.log(JSON.stringify(trigger, null, 2));
|
|
80
|
+
} else {
|
|
81
|
+
yield* Console.log(print(yield* printTrigger(trigger)));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
yield* flushAndSync({ indexes: true });
|
|
85
|
+
}),
|
|
86
|
+
).pipe(
|
|
87
|
+
Command.withDescription('Create a timer trigger.'),
|
|
88
|
+
Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
|
|
89
|
+
Command.provideEffectDiscard(() => withTypes(Operation.PersistentOperation, Trigger.Trigger)),
|
|
90
|
+
);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Command from '@effect/cli/Command';
|
|
6
|
+
|
|
7
|
+
import { create } from './create';
|
|
8
|
+
import { list } from './list';
|
|
9
|
+
import { remove } from './remove';
|
|
10
|
+
import { update } from './update';
|
|
11
|
+
|
|
12
|
+
// TODO(wittjosiah): Rename to automation to align with Composer?
|
|
13
|
+
export const trigger = Command.make('trigger').pipe(
|
|
14
|
+
Command.withDescription('Manage EDGE triggers.'),
|
|
15
|
+
Command.withSubcommands([create, list, remove, update]),
|
|
16
|
+
);
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Command from '@effect/cli/Command';
|
|
6
|
+
import * as Options from '@effect/cli/Options';
|
|
7
|
+
import * as Console from 'effect/Console';
|
|
8
|
+
import * as Effect from 'effect/Effect';
|
|
9
|
+
|
|
10
|
+
import { CommandConfig, Common, printList, spaceIdWithDefault, spaceLayer } from '@dxos/cli-util';
|
|
11
|
+
import { ClientService } from '@dxos/client';
|
|
12
|
+
import { Trigger } from '@dxos/compute';
|
|
13
|
+
import { Context } from '@dxos/context';
|
|
14
|
+
import { Database, Filter, Query } from '@dxos/echo';
|
|
15
|
+
|
|
16
|
+
import { getTriggerRemoteStatus, printTrigger } from './util';
|
|
17
|
+
|
|
18
|
+
export const list = Command.make(
|
|
19
|
+
'list',
|
|
20
|
+
{
|
|
21
|
+
spaceId: Common.spaceId.pipe(Options.optional),
|
|
22
|
+
},
|
|
23
|
+
Effect.fn(function* ({ spaceId: spaceIdOption }) {
|
|
24
|
+
const { json } = yield* CommandConfig;
|
|
25
|
+
|
|
26
|
+
// Fetch local triggers
|
|
27
|
+
const triggers = yield* Database.query(Query.select(Filter.type(Trigger.Trigger)).debugLabel('cli.trigger.list'))
|
|
28
|
+
.run;
|
|
29
|
+
|
|
30
|
+
// Fetch remote cron triggers to check availability
|
|
31
|
+
const remoteCronIds = yield* Effect.gen(function* () {
|
|
32
|
+
const client = yield* ClientService;
|
|
33
|
+
const spaceId = yield* spaceIdWithDefault(spaceIdOption);
|
|
34
|
+
const result = yield* Effect.promise(() => client.edge.http.getCronTriggers(Context.default(), spaceId)).pipe(
|
|
35
|
+
Effect.catchAll(() => Effect.succeed({ cronIds: [] })),
|
|
36
|
+
);
|
|
37
|
+
return result.cronIds;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Determine remote status for each trigger
|
|
41
|
+
const triggersWithStatus = triggers.map((trigger) => ({
|
|
42
|
+
trigger,
|
|
43
|
+
remoteStatus: getTriggerRemoteStatus(trigger, remoteCronIds),
|
|
44
|
+
}));
|
|
45
|
+
|
|
46
|
+
// Print triggers
|
|
47
|
+
if (json) {
|
|
48
|
+
yield* Console.log(
|
|
49
|
+
JSON.stringify(
|
|
50
|
+
triggersWithStatus.map(({ trigger, remoteStatus }) => ({ ...trigger, remoteStatus })),
|
|
51
|
+
null,
|
|
52
|
+
2,
|
|
53
|
+
),
|
|
54
|
+
);
|
|
55
|
+
} else {
|
|
56
|
+
if (triggersWithStatus.length === 0) {
|
|
57
|
+
yield* Console.log('No triggers found.');
|
|
58
|
+
} else {
|
|
59
|
+
const items = yield* Effect.all(
|
|
60
|
+
triggersWithStatus.map(({ trigger, remoteStatus }) => printTrigger(trigger, remoteStatus)),
|
|
61
|
+
);
|
|
62
|
+
yield* Console.log(printList(items));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}),
|
|
66
|
+
).pipe(
|
|
67
|
+
Command.withDescription('List triggers configured on EDGE.'),
|
|
68
|
+
Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
|
|
69
|
+
);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Options from '@effect/cli/Options';
|
|
6
|
+
|
|
7
|
+
export const TriggerId = Options.text('id').pipe(Options.withDescription('The id of the trigger.'));
|
|
8
|
+
|
|
9
|
+
export const Enabled = Options.boolean('enabled', { ifPresent: true }).pipe(
|
|
10
|
+
Options.withDescription('Whether the trigger is enabled.'),
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export const Input = Options.keyValueMap('input').pipe(
|
|
14
|
+
Options.withDescription("Input data to pass to the function. Must match the function's input schema."),
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
//
|
|
18
|
+
// Subscription
|
|
19
|
+
//
|
|
20
|
+
|
|
21
|
+
export const Typename = Options.text('typename').pipe(
|
|
22
|
+
Options.withDescription('The type name to query for the subscription trigger.'),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export const Deep = Options.boolean('deep', { ifPresent: true }).pipe(
|
|
26
|
+
Options.withDescription('Watch changes to nested properties (not just creation).'),
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
export const Delay = Options.integer('delay').pipe(
|
|
30
|
+
Options.withDescription('Debounce changes with a delay in milliseconds.'),
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
//
|
|
34
|
+
// Timer
|
|
35
|
+
//
|
|
36
|
+
|
|
37
|
+
export const Cron = Options.text('cron').pipe(
|
|
38
|
+
Options.withDescription('The cron expression to use for the timer trigger.'),
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
//
|
|
42
|
+
// Feed
|
|
43
|
+
//
|
|
44
|
+
|
|
45
|
+
export const Feed = Options.text('feed').pipe(
|
|
46
|
+
Options.withDescription('The EID of the feed for the feed trigger (echo://<spaceId>/<objectId>).'),
|
|
47
|
+
);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Command from '@effect/cli/Command';
|
|
6
|
+
import * as Options from '@effect/cli/Options';
|
|
7
|
+
import * as Console from 'effect/Console';
|
|
8
|
+
import * as Effect from 'effect/Effect';
|
|
9
|
+
import * as Option from 'effect/Option';
|
|
10
|
+
|
|
11
|
+
import { CommandConfig, Common, print, spaceLayer, withTypes } from '@dxos/cli-util';
|
|
12
|
+
import { Trigger } from '@dxos/compute';
|
|
13
|
+
import { Database, Ref } from '@dxos/echo';
|
|
14
|
+
import { EID } from '@dxos/keys';
|
|
15
|
+
|
|
16
|
+
import { TriggerId } from './options';
|
|
17
|
+
import { printTriggerRemoved, selectTrigger } from './util';
|
|
18
|
+
|
|
19
|
+
export const remove = Command.make(
|
|
20
|
+
'remove',
|
|
21
|
+
{
|
|
22
|
+
spaceId: Common.spaceId.pipe(Options.optional),
|
|
23
|
+
id: TriggerId.pipe(Options.optional),
|
|
24
|
+
},
|
|
25
|
+
(options) =>
|
|
26
|
+
Effect.gen(function* () {
|
|
27
|
+
const { json } = yield* CommandConfig;
|
|
28
|
+
const triggerId = yield* Option.match(options.id, {
|
|
29
|
+
onNone: () => selectTrigger(),
|
|
30
|
+
onSome: (id) => Effect.succeed(id),
|
|
31
|
+
});
|
|
32
|
+
const dxn = EID.make({ entityId: triggerId });
|
|
33
|
+
const trigger = yield* Database.resolve(Ref.fromURI(dxn), Trigger.Trigger);
|
|
34
|
+
yield* Database.remove(trigger);
|
|
35
|
+
if (json) {
|
|
36
|
+
yield* Console.log(JSON.stringify({ id: trigger.id, removed: true }, null, 2));
|
|
37
|
+
} else {
|
|
38
|
+
yield* Console.log(print(printTriggerRemoved(trigger.id)));
|
|
39
|
+
}
|
|
40
|
+
}),
|
|
41
|
+
).pipe(
|
|
42
|
+
Command.withDescription('Remove a trigger.'),
|
|
43
|
+
Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
|
|
44
|
+
Command.provideEffectDiscard(() => withTypes(Trigger.Trigger)),
|
|
45
|
+
);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Command from '@effect/cli/Command';
|
|
6
|
+
|
|
7
|
+
import { queue } from './queue';
|
|
8
|
+
import { subscription } from './subscription';
|
|
9
|
+
import { timer } from './timer';
|
|
10
|
+
|
|
11
|
+
export const update = Command.make('update').pipe(
|
|
12
|
+
Command.withDescription('Update a trigger.'),
|
|
13
|
+
Command.withSubcommands([subscription, timer, queue]),
|
|
14
|
+
);
|