@dxos/plugin-automation 0.8.4-main.c4373fc → 0.8.4-main.c85a9c8dae
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/AutomationPanel-EHRSV2DL.mjs +11 -0
- package/dist/lib/browser/AutomationSettings-TJYG77L6.mjs +37 -0
- package/dist/lib/browser/AutomationSettings-TJYG77L6.mjs.map +7 -0
- package/dist/lib/browser/FunctionsContainer-XHEQSNNO.mjs +43 -0
- package/dist/lib/browser/FunctionsContainer-XHEQSNNO.mjs.map +7 -0
- package/dist/lib/browser/{FunctionsPanel-NRIKAPQV.mjs → FunctionsPanel-5WPUZGRB.mjs} +3 -3
- package/dist/lib/browser/FunctionsRegistry-XRXIZRLL.mjs +10 -0
- package/dist/lib/browser/TriggerSettings-HUQT53SV.mjs +13 -0
- package/dist/lib/browser/TriggerSettings-HUQT53SV.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-HLARI3VW.mjs +85 -0
- package/dist/lib/browser/app-graph-builder-HLARI3VW.mjs.map +7 -0
- package/dist/lib/browser/chunk-3P4R5WNC.mjs +8 -0
- package/dist/lib/browser/chunk-3P4R5WNC.mjs.map +7 -0
- package/dist/lib/browser/chunk-4EY2KMCM.mjs +272 -0
- package/dist/lib/browser/chunk-4EY2KMCM.mjs.map +7 -0
- package/dist/lib/browser/chunk-PZNBEKO5.mjs +17 -0
- package/dist/lib/browser/chunk-PZNBEKO5.mjs.map +7 -0
- package/dist/lib/browser/chunk-QPG3AKFX.mjs +93 -0
- package/dist/lib/browser/chunk-QPG3AKFX.mjs.map +7 -0
- package/dist/lib/browser/chunk-SEG5OCGB.mjs +31 -0
- package/dist/lib/browser/chunk-SEG5OCGB.mjs.map +7 -0
- package/dist/lib/browser/chunk-U55ZXRYM.mjs +98 -0
- package/dist/lib/browser/chunk-U55ZXRYM.mjs.map +7 -0
- package/dist/lib/browser/chunk-WOBCY2FQ.mjs +83 -0
- package/dist/lib/browser/chunk-WOBCY2FQ.mjs.map +7 -0
- package/dist/lib/browser/chunk-XFXYU645.mjs +96 -0
- package/dist/lib/browser/chunk-XFXYU645.mjs.map +7 -0
- package/dist/lib/browser/chunk-ZNI2CGQP.mjs +270 -0
- package/dist/lib/browser/chunk-ZNI2CGQP.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +1108 -0
- package/dist/lib/browser/cli/index.mjs.map +7 -0
- package/dist/lib/browser/compute-runtime-L2RVWXY2.mjs +124 -0
- package/dist/lib/browser/compute-runtime-L2RVWXY2.mjs.map +7 -0
- package/dist/lib/browser/hooks/index.mjs +5 -4
- package/dist/lib/browser/index.mjs +66 -64
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-2U6ZQVXR.mjs +83 -0
- package/dist/lib/browser/operation-resolver-2U6ZQVXR.mjs.map +7 -0
- package/dist/lib/browser/{react-surface-JXFO46V4.mjs → react-surface-U6FAYV42.mjs} +20 -14
- package/dist/lib/browser/react-surface-U6FAYV42.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +10 -4
- package/dist/lib/node-esm/{AutomationPanel-GHK5UG4K.mjs → AutomationPanel-F7MPUR7U.mjs} +4 -4
- package/dist/lib/node-esm/AutomationSettings-5AHJMILI.mjs +38 -0
- package/dist/lib/node-esm/AutomationSettings-5AHJMILI.mjs.map +7 -0
- package/dist/lib/node-esm/FunctionsContainer-U5UVRKVT.mjs +44 -0
- package/dist/lib/node-esm/FunctionsContainer-U5UVRKVT.mjs.map +7 -0
- package/dist/lib/node-esm/{FunctionsPanel-SAMRTELO.mjs → FunctionsPanel-UFL5LT2R.mjs} +3 -3
- package/dist/lib/node-esm/FunctionsPanel-UFL5LT2R.mjs.map +7 -0
- package/dist/lib/node-esm/FunctionsRegistry-574OBZ5T.mjs +11 -0
- package/dist/lib/node-esm/FunctionsRegistry-574OBZ5T.mjs.map +7 -0
- package/dist/lib/node-esm/TriggerSettings-RDIJHUKK.mjs +14 -0
- package/dist/lib/node-esm/TriggerSettings-RDIJHUKK.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-builder-Z2TMQHVX.mjs +86 -0
- package/dist/lib/node-esm/app-graph-builder-Z2TMQHVX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-2X564LII.mjs +10 -0
- package/dist/lib/node-esm/chunk-2X564LII.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-34HGM46Z.mjs +32 -0
- package/dist/lib/node-esm/chunk-34HGM46Z.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-4DK33JDH.mjs +84 -0
- package/dist/lib/node-esm/chunk-4DK33JDH.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-5MQJPJR2.mjs → chunk-5FXNN3MV.mjs} +6 -2
- package/dist/lib/node-esm/chunk-5FXNN3MV.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-7AIKTEAX.mjs +273 -0
- package/dist/lib/node-esm/chunk-7AIKTEAX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-CMZ4NKSK.mjs +271 -0
- package/dist/lib/node-esm/chunk-CMZ4NKSK.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-GXFQR3KI.mjs +99 -0
- package/dist/lib/node-esm/chunk-GXFQR3KI.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-QNPYY3XZ.mjs +94 -0
- package/dist/lib/node-esm/chunk-QNPYY3XZ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-RTEXGGBX.mjs +97 -0
- package/dist/lib/node-esm/chunk-RTEXGGBX.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +1109 -0
- package/dist/lib/node-esm/cli/index.mjs.map +7 -0
- package/dist/lib/node-esm/compute-runtime-XD6A5Q7Q.mjs +125 -0
- package/dist/lib/node-esm/compute-runtime-XD6A5Q7Q.mjs.map +7 -0
- package/dist/lib/node-esm/hooks/index.mjs +5 -4
- package/dist/lib/node-esm/index.mjs +66 -64
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operation-resolver-XWJGBHJZ.mjs +84 -0
- package/dist/lib/node-esm/operation-resolver-XWJGBHJZ.mjs.map +7 -0
- package/dist/lib/node-esm/{react-surface-YDJ43B3N.mjs → react-surface-BVNHCWQ7.mjs} +20 -14
- package/dist/lib/node-esm/react-surface-BVNHCWQ7.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +10 -4
- package/dist/types/src/AutomationPlugin.d.ts +2 -1
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/compute-runtime/compute-runtime.d.ts +6 -0
- package/dist/types/src/capabilities/compute-runtime/compute-runtime.d.ts.map +1 -0
- package/dist/types/src/capabilities/compute-runtime/index.d.ts +3 -0
- package/dist/types/src/capabilities/compute-runtime/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +4 -5
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/cli/commands/index.d.ts +2 -0
- package/dist/types/src/cli/commands/index.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/create/index.d.ts +25 -0
- package/dist/types/src/cli/commands/trigger/create/index.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/create/queue.d.ts +13 -0
- package/dist/types/src/cli/commands/trigger/create/queue.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/create/subscription.d.ts +15 -0
- package/dist/types/src/cli/commands/trigger/create/subscription.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/create/timer.d.ts +13 -0
- package/dist/types/src/cli/commands/trigger/create/timer.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/index.d.ts +57 -0
- package/dist/types/src/cli/commands/trigger/index.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/list.d.ts +7 -0
- package/dist/types/src/cli/commands/trigger/list.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/options.d.ts +11 -0
- package/dist/types/src/cli/commands/trigger/options.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/remove.d.ts +8 -0
- package/dist/types/src/cli/commands/trigger/remove.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/update/index.d.ts +28 -0
- package/dist/types/src/cli/commands/trigger/update/index.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/update/queue.d.ts +12 -0
- package/dist/types/src/cli/commands/trigger/update/queue.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/update/subscription.d.ts +13 -0
- package/dist/types/src/cli/commands/trigger/update/subscription.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/update/timer.d.ts +11 -0
- package/dist/types/src/cli/commands/trigger/update/timer.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/util.d.ts +46 -0
- package/dist/types/src/cli/commands/trigger/util.d.ts.map +1 -0
- package/dist/types/src/cli/index.d.ts +2 -0
- package/dist/types/src/cli/index.d.ts.map +1 -0
- package/dist/types/src/cli/plugin.d.ts +3 -0
- package/dist/types/src/cli/plugin.d.ts.map +1 -0
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +6 -7
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts +5 -0
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsRegistry/FunctionsRegistry.d.ts +8 -0
- package/dist/types/src/components/FunctionsRegistry/FunctionsRegistry.d.ts.map +1 -0
- package/dist/types/src/components/FunctionsRegistry/index.d.ts +4 -0
- package/dist/types/src/components/FunctionsRegistry/index.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts +12 -9
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts +6 -3
- package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +10 -8
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +74 -2
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +3 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/AutomationSettings/AutomationSettings.d.ts +4 -0
- package/dist/types/src/containers/AutomationSettings/AutomationSettings.d.ts.map +1 -0
- package/dist/types/src/containers/AutomationSettings/index.d.ts +3 -0
- package/dist/types/src/containers/AutomationSettings/index.d.ts.map +1 -0
- package/dist/types/src/{components → containers/FunctionsContainer}/FunctionsContainer.d.ts +0 -1
- package/dist/types/src/containers/FunctionsContainer/FunctionsContainer.d.ts.map +1 -0
- package/dist/types/src/containers/FunctionsContainer/index.d.ts +3 -0
- package/dist/types/src/containers/FunctionsContainer/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 +5 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts +8 -4
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts.map +1 -1
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts +6 -5
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/testing/test-functions.d.ts +202 -3
- package/dist/types/src/testing/test-functions.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +5 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +22 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/events.d.ts +5 -0
- package/dist/types/src/types/events.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +30 -1
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +66 -47
- package/src/AutomationPlugin.tsx +15 -34
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +72 -0
- package/src/capabilities/app-graph-builder/index.ts +7 -0
- package/src/capabilities/compute-runtime/compute-runtime.ts +146 -0
- package/src/capabilities/compute-runtime/index.ts +7 -0
- package/src/capabilities/index.ts +4 -8
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +80 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +61 -0
- package/src/cli/commands/index.ts +5 -0
- package/src/cli/commands/trigger/create/index.ts +14 -0
- package/src/cli/commands/trigger/create/queue.ts +89 -0
- package/src/cli/commands/trigger/create/subscription.ts +128 -0
- package/src/cli/commands/trigger/create/timer.ts +93 -0
- package/src/cli/commands/trigger/index.ts +16 -0
- package/src/cli/commands/trigger/list.ts +67 -0
- package/src/cli/commands/trigger/options.ts +59 -0
- package/src/cli/commands/trigger/remove.ts +45 -0
- package/src/cli/commands/trigger/update/index.ts +14 -0
- package/src/cli/commands/trigger/update/queue.ts +195 -0
- package/src/cli/commands/trigger/update/subscription.ts +278 -0
- package/src/cli/commands/trigger/update/timer.ts +193 -0
- package/src/cli/commands/trigger/util.ts +395 -0
- package/src/cli/index.ts +5 -0
- package/src/cli/plugin.ts +24 -0
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +5 -6
- package/src/components/AutomationPanel/AutomationPanel.tsx +189 -86
- package/src/components/FunctionsPanel/FunctionsPanel.tsx +34 -22
- package/src/components/FunctionsRegistry/FunctionsRegistry.tsx +110 -0
- package/src/components/FunctionsRegistry/index.ts +8 -0
- package/src/components/TriggerEditor/FunctionInputEditor.tsx +34 -33
- package/src/components/TriggerEditor/SpecSelector.tsx +12 -11
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +89 -23
- package/src/components/TriggerEditor/TriggerEditor.tsx +83 -85
- package/src/components/index.ts +1 -2
- package/src/{components → containers/AutomationSettings}/AutomationSettings.tsx +9 -12
- package/src/containers/AutomationSettings/index.ts +7 -0
- package/src/containers/FunctionsContainer/FunctionsContainer.tsx +33 -0
- package/src/containers/FunctionsContainer/index.ts +7 -0
- package/src/containers/TriggerSettings/TriggerSettings.tsx +26 -0
- package/src/containers/TriggerSettings/index.ts +7 -0
- package/src/containers/index.ts +9 -0
- package/src/hooks/useComputeRuntimeCallback.ts +45 -8
- package/src/hooks/useTriggerRuntimeControls.ts +30 -15
- package/src/index.ts +2 -2
- package/src/meta.ts +7 -4
- package/src/testing/test-functions.ts +6 -6
- package/src/translations.ts +7 -0
- package/src/{capabilities → types}/capabilities.ts +9 -14
- package/src/types/events.ts +11 -0
- package/src/types/index.ts +2 -0
- package/src/types/schema.ts +23 -2
- package/dist/lib/browser/AutomationPanel-PNBH5L5C.mjs +0 -11
- package/dist/lib/browser/AutomationSettings-3LABN6ER.mjs +0 -69
- package/dist/lib/browser/AutomationSettings-3LABN6ER.mjs.map +0 -7
- package/dist/lib/browser/FunctionsContainer-HHBMPUOD.mjs +0 -36
- package/dist/lib/browser/FunctionsContainer-HHBMPUOD.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-DV5HMFX4.mjs +0 -81
- package/dist/lib/browser/app-graph-builder-DV5HMFX4.mjs.map +0 -7
- package/dist/lib/browser/chunk-5ARH77PV.mjs +0 -15
- package/dist/lib/browser/chunk-5ARH77PV.mjs.map +0 -7
- package/dist/lib/browser/chunk-AY67OUDA.mjs +0 -14
- package/dist/lib/browser/chunk-AY67OUDA.mjs.map +0 -7
- package/dist/lib/browser/chunk-DLLE4FKP.mjs +0 -94
- package/dist/lib/browser/chunk-DLLE4FKP.mjs.map +0 -7
- package/dist/lib/browser/chunk-LC3QQU47.mjs +0 -171
- package/dist/lib/browser/chunk-LC3QQU47.mjs.map +0 -7
- package/dist/lib/browser/chunk-MVPRI3DB.mjs +0 -53
- package/dist/lib/browser/chunk-MVPRI3DB.mjs.map +0 -7
- package/dist/lib/browser/chunk-NIJWEQRD.mjs +0 -283
- package/dist/lib/browser/chunk-NIJWEQRD.mjs.map +0 -7
- package/dist/lib/browser/chunk-QT3YWUOT.mjs +0 -14
- package/dist/lib/browser/chunk-QT3YWUOT.mjs.map +0 -7
- package/dist/lib/browser/chunk-VGBZKM3O.mjs +0 -38
- package/dist/lib/browser/chunk-VGBZKM3O.mjs.map +0 -7
- package/dist/lib/browser/chunk-WWURMV25.mjs +0 -13
- package/dist/lib/browser/chunk-WWURMV25.mjs.map +0 -7
- package/dist/lib/browser/compute-runtime-YJREH6WP.mjs +0 -160
- package/dist/lib/browser/compute-runtime-YJREH6WP.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-D2OHKQRR.mjs +0 -77
- package/dist/lib/browser/intent-resolver-D2OHKQRR.mjs.map +0 -7
- package/dist/lib/browser/react-surface-JXFO46V4.mjs.map +0 -7
- package/dist/lib/node-esm/AutomationSettings-XENNIIZM.mjs +0 -70
- package/dist/lib/node-esm/AutomationSettings-XENNIIZM.mjs.map +0 -7
- package/dist/lib/node-esm/FunctionsContainer-ZKVOBUHV.mjs +0 -37
- package/dist/lib/node-esm/FunctionsContainer-ZKVOBUHV.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-TR2WXPX2.mjs +0 -82
- package/dist/lib/node-esm/app-graph-builder-TR2WXPX2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3EWMZAU6.mjs +0 -172
- package/dist/lib/node-esm/chunk-3EWMZAU6.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5MQJPJR2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CJUI6AKX.mjs +0 -39
- package/dist/lib/node-esm/chunk-CJUI6AKX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-EX74SIDO.mjs +0 -284
- package/dist/lib/node-esm/chunk-EX74SIDO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LWASMQIF.mjs +0 -16
- package/dist/lib/node-esm/chunk-LWASMQIF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QCA543ZR.mjs +0 -54
- package/dist/lib/node-esm/chunk-QCA543ZR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-U7LJXQS4.mjs +0 -16
- package/dist/lib/node-esm/chunk-U7LJXQS4.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WHCSOUNN.mjs +0 -16
- package/dist/lib/node-esm/chunk-WHCSOUNN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YQXW3JXD.mjs +0 -95
- package/dist/lib/node-esm/chunk-YQXW3JXD.mjs.map +0 -7
- package/dist/lib/node-esm/compute-runtime-CMEPAYND.mjs +0 -161
- package/dist/lib/node-esm/compute-runtime-CMEPAYND.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-2LGBVXT5.mjs +0 -78
- package/dist/lib/node-esm/intent-resolver-2LGBVXT5.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-YDJ43B3N.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -19
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/compute-runtime.d.ts +0 -5
- package/dist/types/src/capabilities/compute-runtime.d.ts.map +0 -1
- 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/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/AutomationSettings.d.ts +0 -5
- package/dist/types/src/components/AutomationSettings.d.ts.map +0 -1
- package/dist/types/src/components/FunctionsContainer.d.ts.map +0 -1
- package/dist/types/src/components/TriggerSettings.d.ts +0 -6
- package/dist/types/src/components/TriggerSettings.d.ts.map +0 -1
- package/dist/types/src/events.d.ts +0 -4
- package/dist/types/src/events.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder.ts +0 -87
- package/src/capabilities/compute-runtime.ts +0 -138
- package/src/capabilities/intent-resolver.ts +0 -72
- package/src/capabilities/react-surface.tsx +0 -55
- package/src/components/FunctionsContainer.tsx +0 -29
- package/src/components/TriggerSettings.tsx +0 -25
- package/src/events.ts +0 -11
- /package/dist/lib/browser/{AutomationPanel-PNBH5L5C.mjs.map → AutomationPanel-EHRSV2DL.mjs.map} +0 -0
- /package/dist/lib/browser/{FunctionsPanel-NRIKAPQV.mjs.map → FunctionsPanel-5WPUZGRB.mjs.map} +0 -0
- /package/dist/lib/{node-esm/AutomationPanel-GHK5UG4K.mjs.map → browser/FunctionsRegistry-XRXIZRLL.mjs.map} +0 -0
- /package/dist/lib/node-esm/{FunctionsPanel-SAMRTELO.mjs.map → AutomationPanel-F7MPUR7U.mjs.map} +0 -0
|
@@ -0,0 +1,195 @@
|
|
|
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 Option from 'effect/Option';
|
|
11
|
+
|
|
12
|
+
import { CommandConfig } from '@dxos/cli-util';
|
|
13
|
+
import { flushAndSync, print, spaceLayer, withTypes } from '@dxos/cli-util';
|
|
14
|
+
import { Common } from '@dxos/cli-util';
|
|
15
|
+
import { DXN, Database, Filter, JsonSchema, Obj, Ref } from '@dxos/echo';
|
|
16
|
+
import { Function, Trigger } from '@dxos/functions';
|
|
17
|
+
|
|
18
|
+
import { Enabled, Input, Queue, TriggerId } from '../options';
|
|
19
|
+
import { printTrigger, promptForSchemaInput, selectFunction, selectQueue, selectTrigger } from '../util';
|
|
20
|
+
|
|
21
|
+
export const queue = Command.make(
|
|
22
|
+
'queue',
|
|
23
|
+
{
|
|
24
|
+
spaceId: Common.spaceId.pipe(Options.optional),
|
|
25
|
+
id: TriggerId.pipe(Options.optional),
|
|
26
|
+
enabled: Enabled,
|
|
27
|
+
functionId: Common.functionId.pipe(Options.optional),
|
|
28
|
+
queue: Queue.pipe(Options.optional),
|
|
29
|
+
input: Input.pipe(Options.optional),
|
|
30
|
+
},
|
|
31
|
+
(options) =>
|
|
32
|
+
Effect.gen(function* () {
|
|
33
|
+
const { json } = yield* CommandConfig;
|
|
34
|
+
|
|
35
|
+
const triggerId = yield* Option.match(options.id, {
|
|
36
|
+
onNone: () => selectTrigger('queue'),
|
|
37
|
+
onSome: (id) => Effect.succeed(id),
|
|
38
|
+
});
|
|
39
|
+
const dxn = DXN.fromLocalObjectId(triggerId);
|
|
40
|
+
const trigger = yield* Database.resolve(dxn, Trigger.Trigger);
|
|
41
|
+
if (trigger.spec?.kind !== 'queue') {
|
|
42
|
+
return yield* Effect.fail(new Error(`Invalid trigger type: ${trigger.spec?.kind}`));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const currentFn = yield* updateFunction(trigger, options.functionId);
|
|
46
|
+
yield* updateQueue(trigger, options.queue);
|
|
47
|
+
yield* updateInput(trigger, currentFn, options.input);
|
|
48
|
+
yield* updateEnabled(trigger, options.id, options.enabled);
|
|
49
|
+
|
|
50
|
+
if (json) {
|
|
51
|
+
yield* Console.log(JSON.stringify(trigger, null, 2));
|
|
52
|
+
} else {
|
|
53
|
+
yield* Console.log(print(yield* printTrigger(trigger)));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
yield* flushAndSync({ indexes: true });
|
|
57
|
+
}),
|
|
58
|
+
).pipe(
|
|
59
|
+
Command.withDescription('Update a queue trigger.'),
|
|
60
|
+
Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
|
|
61
|
+
Command.provideEffectDiscard(() => withTypes(Function.Function, Trigger.Trigger)),
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Handles updating the function for a trigger.
|
|
66
|
+
* Prompts for confirmation if functionId is not provided, then updates the function if confirmed.
|
|
67
|
+
* @returns The current function (either original or newly assigned)
|
|
68
|
+
*/
|
|
69
|
+
const updateFunction = Effect.fn(function* (trigger: Trigger.Trigger, functionIdOption: Option.Option<string>) {
|
|
70
|
+
let currentFn: Function.Function | undefined = trigger.function
|
|
71
|
+
? yield* Database.load(trigger.function) as any
|
|
72
|
+
: undefined;
|
|
73
|
+
if (currentFn && !Obj.instanceOf(Function.Function, currentFn)) {
|
|
74
|
+
currentFn = undefined;
|
|
75
|
+
}
|
|
76
|
+
const currentFunctionName = currentFn ? (currentFn.name ?? currentFn.id) : undefined;
|
|
77
|
+
const shouldChangeFunction = yield* Option.match(functionIdOption, {
|
|
78
|
+
onNone: () =>
|
|
79
|
+
Prompt.confirm({
|
|
80
|
+
message: `Change the function${currentFunctionName ? ` (current: ${currentFunctionName})` : ''}?`,
|
|
81
|
+
initial: false,
|
|
82
|
+
}).pipe(Prompt.run),
|
|
83
|
+
onSome: () => Effect.succeed(true),
|
|
84
|
+
});
|
|
85
|
+
if (shouldChangeFunction) {
|
|
86
|
+
const functionId = yield* Option.match(functionIdOption, {
|
|
87
|
+
onNone: () => selectFunction(),
|
|
88
|
+
onSome: (id) => Effect.succeed(id),
|
|
89
|
+
});
|
|
90
|
+
const functions = yield* Database.runQuery(Filter.type(Function.Function));
|
|
91
|
+
const foundFn = functions.find((fn) => fn.id === functionId);
|
|
92
|
+
if (!foundFn || !Obj.instanceOf(Function.Function, foundFn)) {
|
|
93
|
+
return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
|
|
94
|
+
}
|
|
95
|
+
Obj.change(trigger, (mutableTrigger) => {
|
|
96
|
+
mutableTrigger.function = Ref.make(foundFn);
|
|
97
|
+
});
|
|
98
|
+
currentFn = foundFn;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (!currentFn) {
|
|
102
|
+
const functionId = trigger.function?.dxn.asEchoDXN()?.echoId ?? 'unknown';
|
|
103
|
+
return yield* Effect.fail(new Error(`Invalid reference for ${functionId}`));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return currentFn;
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Handles updating the queue DXN for a queue trigger.
|
|
111
|
+
* Prompts for confirmation if queue is not provided, then updates the queue if confirmed.
|
|
112
|
+
*/
|
|
113
|
+
const updateQueue = Effect.fn(function* (trigger: Trigger.Trigger, queueOption: Option.Option<DXN>) {
|
|
114
|
+
const currentQueue = trigger.spec?.kind === 'queue' ? trigger.spec.queue : undefined;
|
|
115
|
+
const currentQueueStr = currentQueue
|
|
116
|
+
? typeof currentQueue === 'string'
|
|
117
|
+
? currentQueue
|
|
118
|
+
: String(currentQueue)
|
|
119
|
+
: undefined;
|
|
120
|
+
const shouldChangeQueue = yield* Option.match(queueOption, {
|
|
121
|
+
onNone: () =>
|
|
122
|
+
Prompt.confirm({
|
|
123
|
+
message: `Change the queue${currentQueueStr ? ` (current: ${currentQueueStr})` : ''}?`,
|
|
124
|
+
initial: false,
|
|
125
|
+
}).pipe(Prompt.run),
|
|
126
|
+
onSome: () => Effect.succeed(true),
|
|
127
|
+
});
|
|
128
|
+
if (shouldChangeQueue) {
|
|
129
|
+
const queueDxn = yield* Option.match(queueOption, {
|
|
130
|
+
onNone: () => selectQueue(),
|
|
131
|
+
onSome: (dxn) => Effect.succeed(dxn.toString()),
|
|
132
|
+
});
|
|
133
|
+
Obj.change(trigger, (mutableTrigger) => {
|
|
134
|
+
if (mutableTrigger.spec?.kind === 'queue') {
|
|
135
|
+
mutableTrigger.spec.queue = queueDxn;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Handles updating the input for a trigger.
|
|
143
|
+
* Prompts for confirmation if input is not provided, then updates the input if confirmed.
|
|
144
|
+
*/
|
|
145
|
+
const updateInput = Effect.fn(function* (
|
|
146
|
+
trigger: Trigger.Trigger,
|
|
147
|
+
fn: Function.Function,
|
|
148
|
+
inputOption: Option.Option<Record<string, any>>,
|
|
149
|
+
) {
|
|
150
|
+
const currentInput = trigger.input as Record<string, any> | undefined;
|
|
151
|
+
const currentInputStr = currentInput ? JSON.stringify(currentInput) : 'none';
|
|
152
|
+
const shouldChangeInput = yield* Option.match(inputOption, {
|
|
153
|
+
onNone: () =>
|
|
154
|
+
Effect.gen(function* () {
|
|
155
|
+
yield* Console.log(`Current input: ${currentInputStr}`);
|
|
156
|
+
return yield* Prompt.confirm({
|
|
157
|
+
message: 'Change input?',
|
|
158
|
+
initial: false,
|
|
159
|
+
}).pipe(Prompt.run);
|
|
160
|
+
}),
|
|
161
|
+
onSome: () => Effect.succeed(true),
|
|
162
|
+
});
|
|
163
|
+
if (shouldChangeInput) {
|
|
164
|
+
const inputObj = yield* Option.match(inputOption, {
|
|
165
|
+
onNone: () =>
|
|
166
|
+
promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined, currentInput),
|
|
167
|
+
onSome: (value) => Effect.succeed(value as Record<string, any>),
|
|
168
|
+
});
|
|
169
|
+
Obj.change(trigger, (mutableTrigger) => {
|
|
170
|
+
mutableTrigger.input = inputObj;
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Handles updating the enabled status for a trigger.
|
|
177
|
+
* Prompts for enabled if id is not provided.
|
|
178
|
+
*/
|
|
179
|
+
const updateEnabled = Effect.fn(function* (
|
|
180
|
+
trigger: Trigger.Trigger,
|
|
181
|
+
idOption: Option.Option<string>,
|
|
182
|
+
enabled: boolean,
|
|
183
|
+
) {
|
|
184
|
+
const enabledValue = yield* Option.match(idOption, {
|
|
185
|
+
onNone: () =>
|
|
186
|
+
Prompt.confirm({
|
|
187
|
+
message: 'Enable the trigger?',
|
|
188
|
+
initial: trigger.enabled,
|
|
189
|
+
}).pipe(Prompt.run),
|
|
190
|
+
onSome: () => Effect.succeed(enabled),
|
|
191
|
+
});
|
|
192
|
+
Obj.change(trigger, (mutableTrigger) => {
|
|
193
|
+
mutableTrigger.enabled = enabledValue;
|
|
194
|
+
});
|
|
195
|
+
});
|
|
@@ -0,0 +1,278 @@
|
|
|
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 Match from 'effect/Match';
|
|
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 { DXN, Database, Filter, JsonSchema, Obj, Query, Ref } from '@dxos/echo';
|
|
17
|
+
import { Function, Trigger } from '@dxos/functions';
|
|
18
|
+
|
|
19
|
+
import { Deep, Delay, Enabled, Input, TriggerId, Typename } from '../options';
|
|
20
|
+
import { printTrigger, promptForSchemaInput, selectFunction, selectTrigger } from '../util';
|
|
21
|
+
|
|
22
|
+
export const subscription = Command.make(
|
|
23
|
+
'subscription',
|
|
24
|
+
{
|
|
25
|
+
spaceId: Common.spaceId.pipe(Options.optional),
|
|
26
|
+
id: TriggerId.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 triggerId = yield* Option.match(options.id, {
|
|
39
|
+
onNone: () => selectTrigger('subscription'),
|
|
40
|
+
onSome: (id) => Effect.succeed(id),
|
|
41
|
+
});
|
|
42
|
+
const dxn = DXN.fromLocalObjectId(triggerId);
|
|
43
|
+
const trigger = yield* Database.resolve(dxn, Trigger.Trigger);
|
|
44
|
+
if (trigger.spec?.kind !== 'subscription') {
|
|
45
|
+
return yield* Effect.fail(new Error(`Invalid trigger type: ${trigger.spec?.kind}`));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const currentFn = yield* updateFunction(trigger, options.functionId);
|
|
49
|
+
yield* updateSpec(trigger, options.typename, options.deep, options.delay);
|
|
50
|
+
yield* updateInput(trigger, currentFn, options.input);
|
|
51
|
+
yield* updateEnabled(trigger, options.id, options.enabled);
|
|
52
|
+
|
|
53
|
+
if (json) {
|
|
54
|
+
yield* Console.log(JSON.stringify(trigger, null, 2));
|
|
55
|
+
} else {
|
|
56
|
+
yield* Console.log(print(yield* printTrigger(trigger)));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
yield* flushAndSync({ indexes: true });
|
|
60
|
+
}),
|
|
61
|
+
).pipe(
|
|
62
|
+
Command.withDescription('Update a subscription trigger.'),
|
|
63
|
+
Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
|
|
64
|
+
Command.provideEffectDiscard(() => withTypes(Function.Function, Trigger.Trigger)),
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Extracts the current typename from a subscription trigger's query AST.
|
|
69
|
+
*/
|
|
70
|
+
const extractCurrentTypename = (spec: Trigger.SubscriptionSpec | undefined): Option.Option<string> => {
|
|
71
|
+
if (!spec?.query?.ast) {
|
|
72
|
+
return Option.none();
|
|
73
|
+
}
|
|
74
|
+
return Match.value(spec.query.ast).pipe(
|
|
75
|
+
Match.withReturnType<Option.Option<string>>(),
|
|
76
|
+
Match.when({ type: 'select' }, (q) =>
|
|
77
|
+
Match.value(q.filter).pipe(
|
|
78
|
+
Match.withReturnType<Option.Option<string>>(),
|
|
79
|
+
Match.when({ type: 'object' }, (f) =>
|
|
80
|
+
Option.fromNullable(f.typename).pipe(
|
|
81
|
+
Option.flatMap((dxn) => Option.fromNullable(DXN.tryParse(dxn))),
|
|
82
|
+
Option.flatMap((dxn) => Option.fromNullable(dxn.asTypeDXN()?.type)),
|
|
83
|
+
),
|
|
84
|
+
),
|
|
85
|
+
Match.orElse(() => Option.none()),
|
|
86
|
+
),
|
|
87
|
+
),
|
|
88
|
+
Match.orElse(() => Option.none()),
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Handles updating the function for a trigger.
|
|
94
|
+
* Prompts for confirmation if functionId is not provided, then updates the function if confirmed.
|
|
95
|
+
* @returns The current function (either original or newly assigned)
|
|
96
|
+
*/
|
|
97
|
+
const updateFunction = Effect.fn(function* (trigger: Trigger.Trigger, functionIdOption: Option.Option<string>) {
|
|
98
|
+
let currentFn: Function.Function | undefined = trigger.function
|
|
99
|
+
? yield* Database.load(trigger.function) as any
|
|
100
|
+
: undefined;
|
|
101
|
+
if (currentFn && !Obj.instanceOf(Function.Function, currentFn)) {
|
|
102
|
+
currentFn = undefined;
|
|
103
|
+
}
|
|
104
|
+
const currentFunctionName = currentFn ? (currentFn.name ?? currentFn.id) : undefined;
|
|
105
|
+
const shouldChangeFunction = yield* Option.match(functionIdOption, {
|
|
106
|
+
onNone: () =>
|
|
107
|
+
Prompt.confirm({
|
|
108
|
+
message: `Change the function${currentFunctionName ? ` (current: ${currentFunctionName})` : ''}?`,
|
|
109
|
+
initial: false,
|
|
110
|
+
}).pipe(Prompt.run),
|
|
111
|
+
onSome: () => Effect.succeed(true),
|
|
112
|
+
});
|
|
113
|
+
if (shouldChangeFunction) {
|
|
114
|
+
const functionId = yield* Option.match(functionIdOption, {
|
|
115
|
+
onNone: () => selectFunction(),
|
|
116
|
+
onSome: (id) => Effect.succeed(id),
|
|
117
|
+
});
|
|
118
|
+
const functions = yield* Database.runQuery(Filter.type(Function.Function));
|
|
119
|
+
const foundFn = functions.find((fn) => fn.id === functionId);
|
|
120
|
+
if (!foundFn || !Obj.instanceOf(Function.Function, foundFn)) {
|
|
121
|
+
return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
|
|
122
|
+
}
|
|
123
|
+
Obj.change(trigger, (mutableTrigger) => {
|
|
124
|
+
mutableTrigger.function = Ref.make(foundFn);
|
|
125
|
+
});
|
|
126
|
+
currentFn = foundFn;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (!currentFn) {
|
|
130
|
+
const functionId = trigger.function?.dxn.asEchoDXN()?.echoId ?? 'unknown';
|
|
131
|
+
return yield* Effect.fail(new Error(`Invalid reference for ${functionId}`));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return currentFn;
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Handles updating the subscription trigger spec (typename, deep, delay).
|
|
139
|
+
* Prompts for confirmation if no spec options are provided, then updates the spec if confirmed.
|
|
140
|
+
*/
|
|
141
|
+
const updateSpec = Effect.fn(function* (
|
|
142
|
+
trigger: Trigger.Trigger,
|
|
143
|
+
typenameOption: Option.Option<string>,
|
|
144
|
+
deepOption: Option.Option<boolean>,
|
|
145
|
+
delayOption: Option.Option<number>,
|
|
146
|
+
) {
|
|
147
|
+
const currentSpec = trigger.spec?.kind === 'subscription' ? trigger.spec : undefined;
|
|
148
|
+
const currentTypename = extractCurrentTypename(currentSpec);
|
|
149
|
+
const currentTypenameStr = Option.getOrUndefined(currentTypename);
|
|
150
|
+
const currentDeep = currentSpec?.options?.deep;
|
|
151
|
+
const currentDelay = currentSpec?.options?.delay;
|
|
152
|
+
const specParts: string[] = [];
|
|
153
|
+
if (currentTypenameStr) {
|
|
154
|
+
specParts.push(`typename: ${currentTypenameStr}`);
|
|
155
|
+
}
|
|
156
|
+
if (currentDeep !== undefined) {
|
|
157
|
+
specParts.push(`deep: ${currentDeep}`);
|
|
158
|
+
}
|
|
159
|
+
if (currentDelay !== undefined) {
|
|
160
|
+
specParts.push(`delay: ${currentDelay}`);
|
|
161
|
+
}
|
|
162
|
+
const currentSpecStr = specParts.length > 0 ? specParts.join(', ') : 'none';
|
|
163
|
+
|
|
164
|
+
const hasSpecOption = Option.isSome(typenameOption) || Option.isSome(deepOption) || Option.isSome(delayOption);
|
|
165
|
+
const shouldChangeSpec = yield* hasSpecOption
|
|
166
|
+
? Effect.succeed(true)
|
|
167
|
+
: Prompt.confirm({
|
|
168
|
+
message: `Change the trigger spec (current: ${currentSpecStr})?`,
|
|
169
|
+
initial: false,
|
|
170
|
+
}).pipe(Prompt.run);
|
|
171
|
+
if (shouldChangeSpec) {
|
|
172
|
+
const typename = yield* Option.match(typenameOption, {
|
|
173
|
+
onNone: () =>
|
|
174
|
+
Prompt.text({
|
|
175
|
+
message: `Enter type name${currentTypenameStr ? ` (current: ${currentTypenameStr})` : ''}:`,
|
|
176
|
+
}).pipe(Prompt.run),
|
|
177
|
+
onSome: (value) => Effect.succeed(value),
|
|
178
|
+
});
|
|
179
|
+
const queryAst = Query.select(Filter.type(typename)).ast;
|
|
180
|
+
|
|
181
|
+
const deepOptionValue = yield* Option.match(deepOption, {
|
|
182
|
+
onNone: () =>
|
|
183
|
+
Prompt.confirm({
|
|
184
|
+
message: 'Watch changes to nested properties (deep)?',
|
|
185
|
+
initial: currentSpec?.options?.deep ?? false,
|
|
186
|
+
}).pipe(
|
|
187
|
+
Prompt.run,
|
|
188
|
+
Effect.map((value) => (value ? Option.some(value) : Option.none())),
|
|
189
|
+
),
|
|
190
|
+
onSome: () => Effect.succeed(Option.some(true)),
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
const delayOptionValue = yield* Option.match(delayOption, {
|
|
194
|
+
onNone: () =>
|
|
195
|
+
Effect.gen(function* () {
|
|
196
|
+
const currentDelay = currentSpec?.options?.delay;
|
|
197
|
+
const delayStr = yield* Prompt.text({
|
|
198
|
+
message: `Debounce delay in milliseconds (optional, press Enter to skip)${currentDelay ? ` (current: ${currentDelay})` : ''}:`,
|
|
199
|
+
}).pipe(Prompt.run);
|
|
200
|
+
return delayStr === '' ? Option.none<number>() : Option.some(parseInt(delayStr, 10));
|
|
201
|
+
}),
|
|
202
|
+
onSome: (value) => Effect.succeed(Option.some(value)),
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
const subscriptionOptions: { deep?: boolean; delay?: number } = {};
|
|
206
|
+
if (Option.isSome(deepOptionValue)) {
|
|
207
|
+
subscriptionOptions.deep = deepOptionValue.value;
|
|
208
|
+
}
|
|
209
|
+
if (Option.isSome(delayOptionValue)) {
|
|
210
|
+
subscriptionOptions.delay = delayOptionValue.value;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
Obj.change(trigger, (mutableTrigger) => {
|
|
214
|
+
const spec = mutableTrigger.spec;
|
|
215
|
+
if (spec?.kind === 'subscription') {
|
|
216
|
+
// Cast needed because QueryAST types are deeply readonly but spec.query expects mutable.
|
|
217
|
+
spec.query = { ast: queryAst } as NonNullable<typeof spec.query>;
|
|
218
|
+
spec.options = Object.keys(subscriptionOptions).length > 0 ? subscriptionOptions : undefined;
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Handles updating the input for a trigger.
|
|
226
|
+
* Prompts for confirmation if input is not provided, then updates the input if confirmed.
|
|
227
|
+
*/
|
|
228
|
+
const updateInput = Effect.fn(function* (
|
|
229
|
+
trigger: Trigger.Trigger,
|
|
230
|
+
fn: Function.Function,
|
|
231
|
+
inputOption: Option.Option<Record<string, any>>,
|
|
232
|
+
) {
|
|
233
|
+
const currentInput = trigger.input as Record<string, any> | undefined;
|
|
234
|
+
const currentInputStr = currentInput ? JSON.stringify(currentInput) : 'none';
|
|
235
|
+
const shouldChangeInput = yield* Option.match(inputOption, {
|
|
236
|
+
onNone: () =>
|
|
237
|
+
Effect.gen(function* () {
|
|
238
|
+
yield* Console.log(`Current input: ${currentInputStr}`);
|
|
239
|
+
return yield* Prompt.confirm({
|
|
240
|
+
message: 'Change input?',
|
|
241
|
+
initial: false,
|
|
242
|
+
}).pipe(Prompt.run);
|
|
243
|
+
}),
|
|
244
|
+
onSome: () => Effect.succeed(true),
|
|
245
|
+
});
|
|
246
|
+
if (shouldChangeInput) {
|
|
247
|
+
const inputObj = yield* Option.match(inputOption, {
|
|
248
|
+
onNone: () =>
|
|
249
|
+
promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined, currentInput),
|
|
250
|
+
onSome: (value) => Effect.succeed(value as Record<string, any>),
|
|
251
|
+
});
|
|
252
|
+
Obj.change(trigger, (mutableTrigger) => {
|
|
253
|
+
mutableTrigger.input = inputObj;
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Handles updating the enabled status for a trigger.
|
|
260
|
+
* Prompts for enabled if id is not provided.
|
|
261
|
+
*/
|
|
262
|
+
const updateEnabled = Effect.fn(function* (
|
|
263
|
+
trigger: Trigger.Trigger,
|
|
264
|
+
idOption: Option.Option<string>,
|
|
265
|
+
enabled: boolean,
|
|
266
|
+
) {
|
|
267
|
+
const enabledValue = yield* Option.match(idOption, {
|
|
268
|
+
onNone: () =>
|
|
269
|
+
Prompt.confirm({
|
|
270
|
+
message: 'Enable the trigger?',
|
|
271
|
+
initial: trigger.enabled,
|
|
272
|
+
}).pipe(Prompt.run),
|
|
273
|
+
onSome: () => Effect.succeed(enabled),
|
|
274
|
+
});
|
|
275
|
+
Obj.change(trigger, (mutableTrigger) => {
|
|
276
|
+
mutableTrigger.enabled = enabledValue;
|
|
277
|
+
});
|
|
278
|
+
});
|
|
@@ -0,0 +1,193 @@
|
|
|
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 Option from 'effect/Option';
|
|
11
|
+
|
|
12
|
+
import { CommandConfig } from '@dxos/cli-util';
|
|
13
|
+
import { flushAndSync, print, spaceLayer, withTypes } from '@dxos/cli-util';
|
|
14
|
+
import { Common } from '@dxos/cli-util';
|
|
15
|
+
import { DXN, Database, Filter, JsonSchema, Obj, Ref } from '@dxos/echo';
|
|
16
|
+
import { Function, Trigger } from '@dxos/functions';
|
|
17
|
+
|
|
18
|
+
import { Cron, Enabled, Input, TriggerId } from '../options';
|
|
19
|
+
import { printTrigger, promptForSchemaInput, selectFunction, selectTrigger } from '../util';
|
|
20
|
+
|
|
21
|
+
export const timer = Command.make(
|
|
22
|
+
'timer',
|
|
23
|
+
{
|
|
24
|
+
spaceId: Common.spaceId.pipe(Options.optional),
|
|
25
|
+
id: TriggerId.pipe(Options.optional),
|
|
26
|
+
enabled: Enabled,
|
|
27
|
+
functionId: Common.functionId.pipe(Options.optional),
|
|
28
|
+
cron: Cron.pipe(Options.optional),
|
|
29
|
+
input: Input.pipe(Options.optional),
|
|
30
|
+
},
|
|
31
|
+
(options) =>
|
|
32
|
+
Effect.gen(function* () {
|
|
33
|
+
const { json } = yield* CommandConfig;
|
|
34
|
+
|
|
35
|
+
const triggerId = yield* Option.match(options.id, {
|
|
36
|
+
onNone: () => selectTrigger('timer'),
|
|
37
|
+
onSome: (id) => Effect.succeed(id),
|
|
38
|
+
});
|
|
39
|
+
const dxn = DXN.fromLocalObjectId(triggerId);
|
|
40
|
+
const trigger = yield* Database.resolve(dxn, Trigger.Trigger);
|
|
41
|
+
if (!trigger.spec || trigger.spec?.kind !== 'timer') {
|
|
42
|
+
return yield* Effect.fail(new Error(`Invalid trigger type: ${trigger.spec?.kind}`));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const currentFn = yield* updateFunction(trigger, options.functionId);
|
|
46
|
+
yield* updateCron(trigger, options.cron);
|
|
47
|
+
yield* updateInput(trigger, currentFn, options.input);
|
|
48
|
+
yield* updateEnabled(trigger, options.id, options.enabled);
|
|
49
|
+
|
|
50
|
+
if (json) {
|
|
51
|
+
yield* Console.log(JSON.stringify(trigger, null, 2));
|
|
52
|
+
} else {
|
|
53
|
+
yield* Console.log(print(yield* printTrigger(trigger)));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
yield* flushAndSync({ indexes: true });
|
|
57
|
+
}),
|
|
58
|
+
).pipe(
|
|
59
|
+
Command.withDescription('Update a timer trigger.'),
|
|
60
|
+
Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
|
|
61
|
+
Command.provideEffectDiscard(() => withTypes(Function.Function, Trigger.Trigger)),
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Handles updating the function for a trigger.
|
|
66
|
+
* Prompts for confirmation if functionId is not provided, then updates the function if confirmed.
|
|
67
|
+
* @returns The current function (either original or newly assigned)
|
|
68
|
+
*/
|
|
69
|
+
const updateFunction = Effect.fn(function* (trigger: Trigger.Trigger, functionIdOption: Option.Option<string>) {
|
|
70
|
+
let currentFn: Function.Function | undefined = trigger.function
|
|
71
|
+
? yield* Database.load(trigger.function) as any
|
|
72
|
+
: undefined;
|
|
73
|
+
if (currentFn && !Obj.instanceOf(Function.Function, currentFn)) {
|
|
74
|
+
currentFn = undefined;
|
|
75
|
+
}
|
|
76
|
+
const currentFunctionName = currentFn ? (currentFn.name ?? currentFn.id) : undefined;
|
|
77
|
+
const shouldChangeFunction = yield* Option.match(functionIdOption, {
|
|
78
|
+
onNone: () =>
|
|
79
|
+
Prompt.confirm({
|
|
80
|
+
message: `Change the function${currentFunctionName ? ` (current: ${currentFunctionName})` : ''}?`,
|
|
81
|
+
initial: false,
|
|
82
|
+
}).pipe(Prompt.run),
|
|
83
|
+
onSome: () => Effect.succeed(true),
|
|
84
|
+
});
|
|
85
|
+
if (shouldChangeFunction) {
|
|
86
|
+
const functionId = yield* Option.match(functionIdOption, {
|
|
87
|
+
onNone: () => selectFunction(),
|
|
88
|
+
onSome: (id) => Effect.succeed(id),
|
|
89
|
+
});
|
|
90
|
+
const functions = yield* Database.runQuery(Filter.type(Function.Function));
|
|
91
|
+
const foundFn = functions.find((fn) => fn.id === functionId);
|
|
92
|
+
if (!foundFn || !Obj.instanceOf(Function.Function, foundFn)) {
|
|
93
|
+
return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
|
|
94
|
+
}
|
|
95
|
+
Obj.change(trigger, (mutableTrigger) => {
|
|
96
|
+
mutableTrigger.function = Ref.make(foundFn);
|
|
97
|
+
});
|
|
98
|
+
currentFn = foundFn;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (!currentFn) {
|
|
102
|
+
const functionId = trigger.function?.dxn.asEchoDXN()?.echoId ?? 'unknown';
|
|
103
|
+
return yield* Effect.fail(new Error(`Invalid reference for ${functionId}`));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return currentFn;
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Handles updating the cron expression for a timer trigger.
|
|
111
|
+
* Prompts for confirmation if cron is not provided, then updates the cron if confirmed.
|
|
112
|
+
*/
|
|
113
|
+
const updateCron = Effect.fn(function* (trigger: Trigger.Trigger, cronOption: Option.Option<string>) {
|
|
114
|
+
const currentCron = trigger.spec?.kind === 'timer' ? trigger.spec.cron : undefined;
|
|
115
|
+
const shouldChangeCron = yield* Option.match(cronOption, {
|
|
116
|
+
onNone: () =>
|
|
117
|
+
Prompt.confirm({
|
|
118
|
+
message: `Change the cron expression${currentCron ? ` (current: ${currentCron})` : ''}?`,
|
|
119
|
+
initial: false,
|
|
120
|
+
}).pipe(Prompt.run),
|
|
121
|
+
onSome: () => Effect.succeed(true),
|
|
122
|
+
});
|
|
123
|
+
if (shouldChangeCron) {
|
|
124
|
+
const cron = yield* Option.match(cronOption, {
|
|
125
|
+
onNone: () =>
|
|
126
|
+
Prompt.text({
|
|
127
|
+
message: `Enter cron expression${currentCron ? ` (current: ${currentCron})` : ''}:`,
|
|
128
|
+
}).pipe(Prompt.run),
|
|
129
|
+
onSome: (value) => Effect.succeed(value),
|
|
130
|
+
});
|
|
131
|
+
Obj.change(trigger, (mutableTrigger) => {
|
|
132
|
+
if (mutableTrigger.spec?.kind === 'timer') {
|
|
133
|
+
mutableTrigger.spec.cron = cron;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Handles updating the input for a trigger.
|
|
141
|
+
* Prompts for confirmation if input is not provided, then updates the input if confirmed.
|
|
142
|
+
*/
|
|
143
|
+
const updateInput = Effect.fn(function* (
|
|
144
|
+
trigger: Trigger.Trigger,
|
|
145
|
+
fn: Function.Function,
|
|
146
|
+
inputOption: Option.Option<Record<string, any>>,
|
|
147
|
+
) {
|
|
148
|
+
const currentInput = trigger.input as Record<string, any> | undefined;
|
|
149
|
+
const currentInputStr = currentInput ? JSON.stringify(currentInput) : 'none';
|
|
150
|
+
const shouldChangeInput = yield* Option.match(inputOption, {
|
|
151
|
+
onNone: () =>
|
|
152
|
+
Effect.gen(function* () {
|
|
153
|
+
yield* Console.log(`Current input: ${currentInputStr}`);
|
|
154
|
+
return yield* Prompt.confirm({
|
|
155
|
+
message: 'Change input?',
|
|
156
|
+
initial: false,
|
|
157
|
+
}).pipe(Prompt.run);
|
|
158
|
+
}),
|
|
159
|
+
onSome: () => Effect.succeed(true),
|
|
160
|
+
});
|
|
161
|
+
if (shouldChangeInput) {
|
|
162
|
+
const inputObj = yield* Option.match(inputOption, {
|
|
163
|
+
onNone: () =>
|
|
164
|
+
promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined, currentInput),
|
|
165
|
+
onSome: (value) => Effect.succeed(value as Record<string, any>),
|
|
166
|
+
});
|
|
167
|
+
Obj.change(trigger, (mutableTrigger) => {
|
|
168
|
+
mutableTrigger.input = inputObj;
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Handles updating the enabled status for a trigger.
|
|
175
|
+
* Prompts for enabled if id is not provided.
|
|
176
|
+
*/
|
|
177
|
+
const updateEnabled = Effect.fn(function* (
|
|
178
|
+
trigger: Trigger.Trigger,
|
|
179
|
+
idOption: Option.Option<string>,
|
|
180
|
+
enabled: boolean,
|
|
181
|
+
) {
|
|
182
|
+
const enabledValue = yield* Option.match(idOption, {
|
|
183
|
+
onNone: () =>
|
|
184
|
+
Prompt.confirm({
|
|
185
|
+
message: 'Enable the trigger?',
|
|
186
|
+
initial: trigger.enabled,
|
|
187
|
+
}).pipe(Prompt.run),
|
|
188
|
+
onSome: () => Effect.succeed(enabled),
|
|
189
|
+
});
|
|
190
|
+
Obj.change(trigger, (mutableTrigger) => {
|
|
191
|
+
mutableTrigger.enabled = enabledValue;
|
|
192
|
+
});
|
|
193
|
+
});
|