@dxos/plugin-routine 0.0.0
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 +105 -0
- package/PLUGIN.mdl +475 -0
- package/README.md +15 -0
- package/dist/lib/neutral/RoutineArticle-UNTMV4CC.mjs +95 -0
- package/dist/lib/neutral/RoutineArticle-UNTMV4CC.mjs.map +7 -0
- package/dist/lib/neutral/RoutineCompanion-ZZ6WMY7I.mjs +249 -0
- package/dist/lib/neutral/RoutineCompanion-ZZ6WMY7I.mjs.map +7 -0
- package/dist/lib/neutral/RoutinePlugin.mjs +10 -0
- package/dist/lib/neutral/RoutinePlugin.mjs.map +7 -0
- package/dist/lib/neutral/RoutinePlugin.node.mjs +1133 -0
- package/dist/lib/neutral/RoutinePlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/RoutinePlugin.workerd.mjs +36 -0
- package/dist/lib/neutral/RoutinePlugin.workerd.mjs.map +7 -0
- package/dist/lib/neutral/RoutineSettings-ZJOM4F3S.mjs +48 -0
- package/dist/lib/neutral/RoutineSettings-ZJOM4F3S.mjs.map +7 -0
- package/dist/lib/neutral/RoutineTraceCompanion-5U6R7LJE.mjs +236 -0
- package/dist/lib/neutral/RoutineTraceCompanion-5U6R7LJE.mjs.map +7 -0
- package/dist/lib/neutral/SkillArticle-WWDNKW2Z.mjs +27 -0
- package/dist/lib/neutral/SkillArticle-WWDNKW2Z.mjs.map +7 -0
- package/dist/lib/neutral/app-graph-builder-FALWLZTI.mjs +90 -0
- package/dist/lib/neutral/app-graph-builder-FALWLZTI.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-674LDIUJ.mjs +9 -0
- package/dist/lib/neutral/chunk-674LDIUJ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-CNYAPXUW.mjs +65 -0
- package/dist/lib/neutral/chunk-CNYAPXUW.mjs.map +7 -0
- package/dist/lib/neutral/chunk-HLO4LYXT.mjs +44 -0
- package/dist/lib/neutral/chunk-HLO4LYXT.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ODQDVFMZ.mjs +8 -0
- package/dist/lib/neutral/chunk-ODQDVFMZ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-R7J2MU2M.mjs +263 -0
- package/dist/lib/neutral/chunk-R7J2MU2M.mjs.map +7 -0
- package/dist/lib/neutral/chunk-WLNL77C7.mjs +14 -0
- package/dist/lib/neutral/chunk-WLNL77C7.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +1921 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +17 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/create-object-V23KVDMJ.mjs +25 -0
- package/dist/lib/neutral/create-object-V23KVDMJ.mjs.map +7 -0
- package/dist/lib/neutral/create-routine-I67BYJA2.mjs +38 -0
- package/dist/lib/neutral/create-routine-I67BYJA2.mjs.map +7 -0
- package/dist/lib/neutral/create-trigger-from-template-U3KNS77V.mjs +70 -0
- package/dist/lib/neutral/create-trigger-from-template-U3KNS77V.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 +27 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/layer-specs-ADQCTTRT.mjs +135 -0
- package/dist/lib/neutral/layer-specs-ADQCTTRT.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +8 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/neutral/navigation-resolver-KQIWUH6F.mjs +18 -0
- package/dist/lib/neutral/navigation-resolver-KQIWUH6F.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-QKLJSDCQ.mjs +13 -0
- package/dist/lib/neutral/operation-handler-QKLJSDCQ.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-GMO7I7YE.mjs +67 -0
- package/dist/lib/neutral/react-surface-GMO7I7YE.mjs.map +7 -0
- package/dist/lib/neutral/registry-sync-PHBU6CH2.mjs +86 -0
- package/dist/lib/neutral/registry-sync-PHBU6CH2.mjs.map +7 -0
- package/dist/lib/neutral/run-routine-HJWXIWLJ.mjs +37 -0
- package/dist/lib/neutral/run-routine-HJWXIWLJ.mjs.map +7 -0
- package/dist/lib/neutral/templates-IIUCEBAX.mjs +49 -0
- package/dist/lib/neutral/templates-IIUCEBAX.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 +115 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/trigger-runtime-controller-7FOTH2NP.mjs +77 -0
- package/dist/lib/neutral/trigger-runtime-controller-7FOTH2NP.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +17 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/types/dx.config.d.ts +28 -0
- package/dist/types/dx.config.d.ts.map +1 -0
- package/dist/types/src/RoutinePlugin.d.ts +4 -0
- package/dist/types/src/RoutinePlugin.d.ts.map +1 -0
- package/dist/types/src/RoutinePlugin.node.d.ts +4 -0
- package/dist/types/src/RoutinePlugin.node.d.ts.map +1 -0
- package/dist/types/src/RoutinePlugin.test.d.ts +2 -0
- package/dist/types/src/RoutinePlugin.test.d.ts.map +1 -0
- package/dist/types/src/RoutinePlugin.workerd.d.ts +4 -0
- package/dist/types/src/RoutinePlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +5 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/create-object.d.ts +5 -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 +12 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/layer-specs.d.ts +5 -0
- package/dist/types/src/capabilities/layer-specs.d.ts.map +1 -0
- package/dist/types/src/capabilities/navigation-resolver.d.ts +5 -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 +5 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- 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 +5 -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 +13 -0
- package/dist/types/src/commands/trigger/update/queue.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/update/subscription.d.ts +15 -0
- package/dist/types/src/commands/trigger/update/subscription.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/update/timer.d.ts +13 -0
- package/dist/types/src/commands/trigger/update/timer.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/util.d.ts +46 -0
- package/dist/types/src/commands/trigger/util.d.ts.map +1 -0
- package/dist/types/src/components/CreateRoutinePanel/CreateRoutinePanel.d.ts +14 -0
- package/dist/types/src/components/CreateRoutinePanel/CreateRoutinePanel.d.ts.map +1 -0
- package/dist/types/src/components/CreateRoutinePanel/index.d.ts +2 -0
- package/dist/types/src/components/CreateRoutinePanel/index.d.ts.map +1 -0
- package/dist/types/src/components/InstructionsEditor/InstructionsEditor.d.ts +16 -0
- package/dist/types/src/components/InstructionsEditor/InstructionsEditor.d.ts.map +1 -0
- package/dist/types/src/components/InstructionsEditor/InstructionsEditor.stories.d.ts +17 -0
- package/dist/types/src/components/InstructionsEditor/InstructionsEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/InstructionsEditor/index.d.ts +2 -0
- package/dist/types/src/components/InstructionsEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/MasterDetail/MasterDetail.d.ts +51 -0
- package/dist/types/src/components/MasterDetail/MasterDetail.d.ts.map +1 -0
- package/dist/types/src/components/MasterDetail/MasterDetail.stories.d.ts +16 -0
- package/dist/types/src/components/MasterDetail/MasterDetail.stories.d.ts.map +1 -0
- package/dist/types/src/components/MasterDetail/index.d.ts +2 -0
- package/dist/types/src/components/MasterDetail/index.d.ts.map +1 -0
- package/dist/types/src/components/RoutineForm/RoutineForm.d.ts +25 -0
- package/dist/types/src/components/RoutineForm/RoutineForm.d.ts.map +1 -0
- package/dist/types/src/components/RoutineForm/index.d.ts +2 -0
- package/dist/types/src/components/RoutineForm/index.d.ts.map +1 -0
- package/dist/types/src/components/Schedule/Schedule.d.ts +80 -0
- package/dist/types/src/components/Schedule/Schedule.d.ts.map +1 -0
- package/dist/types/src/components/Schedule/Schedule.stories.d.ts +23 -0
- package/dist/types/src/components/Schedule/Schedule.stories.d.ts.map +1 -0
- package/dist/types/src/components/Schedule/cron.d.ts +44 -0
- package/dist/types/src/components/Schedule/cron.d.ts.map +1 -0
- package/dist/types/src/components/Schedule/cron.test.d.ts +2 -0
- package/dist/types/src/components/Schedule/cron.test.d.ts.map +1 -0
- package/dist/types/src/components/Schedule/index.d.ts +4 -0
- package/dist/types/src/components/Schedule/index.d.ts.map +1 -0
- package/dist/types/src/components/Schedule/types.d.ts +66 -0
- package/dist/types/src/components/Schedule/types.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +13 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +19 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +21 -0
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +16 -0
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts +12 -0
- package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/extensions/index.d.ts +3 -0
- package/dist/types/src/components/TemplateEditor/extensions/index.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts +8 -0
- package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/index.d.ts +2 -0
- package/dist/types/src/components/TemplateEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/types.d.ts +18 -0
- package/dist/types/src/components/TemplateEditor/types.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +24 -0
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +25 -0
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/TriggerKindSelector.d.ts +15 -0
- package/dist/types/src/components/TriggerEditor/TriggerKindSelector.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/TriggerKindSelector.stories.d.ts +15 -0
- package/dist/types/src/components/TriggerEditor/TriggerKindSelector.stories.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/index.d.ts +2 -0
- package/dist/types/src/components/TriggerEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +8 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineArticle/RoutineArticle.d.ts +14 -0
- package/dist/types/src/containers/RoutineArticle/RoutineArticle.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineArticle/RoutineArticle.stories.d.ts +20 -0
- package/dist/types/src/containers/RoutineArticle/RoutineArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineArticle/index.d.ts +2 -0
- package/dist/types/src/containers/RoutineArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineCompanion/RoutineCompanion.d.ts +17 -0
- package/dist/types/src/containers/RoutineCompanion/RoutineCompanion.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineCompanion/RoutineCompanion.stories.d.ts +15 -0
- package/dist/types/src/containers/RoutineCompanion/RoutineCompanion.stories.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineCompanion/index.d.ts +3 -0
- package/dist/types/src/containers/RoutineCompanion/index.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineSettings/RoutineSettings.d.ts +10 -0
- package/dist/types/src/containers/RoutineSettings/RoutineSettings.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineSettings/index.d.ts +2 -0
- package/dist/types/src/containers/RoutineSettings/index.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineTraceCompanion/RoutineTraceCompanion.d.ts +9 -0
- package/dist/types/src/containers/RoutineTraceCompanion/RoutineTraceCompanion.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineTraceCompanion/RoutineTraceCompanion.stories.d.ts +15 -0
- package/dist/types/src/containers/RoutineTraceCompanion/RoutineTraceCompanion.stories.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineTraceCompanion/index.d.ts +2 -0
- package/dist/types/src/containers/RoutineTraceCompanion/index.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineTraceCompanion/runs.d.ts +34 -0
- package/dist/types/src/containers/RoutineTraceCompanion/runs.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineTraceCompanion/runs.test.d.ts +2 -0
- package/dist/types/src/containers/RoutineTraceCompanion/runs.test.d.ts.map +1 -0
- package/dist/types/src/containers/RoutineTraceCompanion/useRoutineRuns.d.ts +11 -0
- package/dist/types/src/containers/RoutineTraceCompanion/useRoutineRuns.d.ts.map +1 -0
- package/dist/types/src/containers/SkillArticle/SkillArticle.d.ts +6 -0
- package/dist/types/src/containers/SkillArticle/SkillArticle.d.ts.map +1 -0
- package/dist/types/src/containers/SkillArticle/index.d.ts +2 -0
- package/dist/types/src/containers/SkillArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +7 -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 +4 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +33 -0
- package/dist/types/src/meta.d.ts.map +1 -0
- package/dist/types/src/operations/create-routine.d.ts +5 -0
- package/dist/types/src/operations/create-routine.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/operations/run-routine.d.ts +5 -0
- package/dist/types/src/operations/run-routine.d.ts.map +1 -0
- package/dist/types/src/paths.d.ts +5 -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 +11 -0
- package/dist/types/src/templates/index.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/test-functions.d.ts +328 -0
- package/dist/types/src/testing/test-functions.d.ts.map +1 -0
- 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 +3 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/dist/types/src/types/Routine.d.ts +55 -0
- package/dist/types/src/types/Routine.d.ts.map +1 -0
- package/dist/types/src/types/Routine.test.d.ts +2 -0
- package/dist/types/src/types/Routine.test.d.ts.map +1 -0
- package/dist/types/src/types/RoutineCapabilities.d.ts +44 -0
- package/dist/types/src/types/RoutineCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/RoutineOperation.d.ts +45 -0
- package/dist/types/src/types/RoutineOperation.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +5 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/types/schema.d.ts +33 -0
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/src/util/index.d.ts +3 -0
- package/dist/types/src/util/index.d.ts.map +1 -0
- package/dist/types/src/util/routines-for-object.d.ts +22 -0
- package/dist/types/src/util/routines-for-object.d.ts.map +1 -0
- package/dist/types/src/util/routines-for-object.test.d.ts +2 -0
- package/dist/types/src/util/routines-for-object.test.d.ts.map +1 -0
- package/dist/types/src/util/run-instructions.d.ts +5 -0
- package/dist/types/src/util/run-instructions.d.ts.map +1 -0
- package/dist/types/src/util/run-instructions.test.d.ts +2 -0
- package/dist/types/src/util/run-instructions.test.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/dx.config.ts +33 -0
- package/package.json +196 -0
- package/src/RoutinePlugin.node.ts +48 -0
- package/src/RoutinePlugin.test.ts +27 -0
- package/src/RoutinePlugin.tsx +58 -0
- package/src/RoutinePlugin.workerd.ts +24 -0
- package/src/capabilities/app-graph-builder.ts +80 -0
- package/src/capabilities/create-object.test.ts +18 -0
- package/src/capabilities/create-object.ts +26 -0
- package/src/capabilities/index.ts +22 -0
- package/src/capabilities/layer-specs.ts +190 -0
- package/src/capabilities/navigation-resolver.ts +21 -0
- package/src/capabilities/node.ts +19 -0
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +66 -0
- 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 +278 -0
- package/src/commands/trigger/update/timer.ts +194 -0
- package/src/commands/trigger/util.ts +412 -0
- package/src/components/CreateRoutinePanel/CreateRoutinePanel.tsx +68 -0
- package/src/components/CreateRoutinePanel/index.ts +5 -0
- package/src/components/InstructionsEditor/InstructionsEditor.stories.tsx +69 -0
- package/src/components/InstructionsEditor/InstructionsEditor.tsx +107 -0
- package/src/components/InstructionsEditor/index.ts +5 -0
- package/src/components/MasterDetail/MasterDetail.stories.tsx +100 -0
- package/src/components/MasterDetail/MasterDetail.tsx +175 -0
- package/src/components/MasterDetail/index.ts +5 -0
- package/src/components/RoutineForm/RoutineForm.tsx +293 -0
- package/src/components/RoutineForm/index.ts +5 -0
- package/src/components/Schedule/Schedule.stories.tsx +73 -0
- package/src/components/Schedule/Schedule.tsx +527 -0
- package/src/components/Schedule/cron.test.ts +230 -0
- package/src/components/Schedule/cron.ts +337 -0
- package/src/components/Schedule/index.ts +8 -0
- package/src/components/Schedule/types.ts +124 -0
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +93 -0
- package/src/components/TemplateEditor/TemplateEditor.tsx +77 -0
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +76 -0
- package/src/components/TemplateEditor/TemplateForm.tsx +204 -0
- package/src/components/TemplateEditor/extensions/handlebars-extension.ts +274 -0
- package/src/components/TemplateEditor/extensions/index.ts +6 -0
- package/src/components/TemplateEditor/extensions/xml-extension.ts +64 -0
- package/src/components/TemplateEditor/index.ts +5 -0
- package/src/components/TemplateEditor/types.tsx +28 -0
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +122 -0
- package/src/components/TriggerEditor/TriggerEditor.tsx +365 -0
- package/src/components/TriggerEditor/TriggerKindSelector.stories.tsx +42 -0
- package/src/components/TriggerEditor/TriggerKindSelector.tsx +87 -0
- package/src/components/TriggerEditor/index.ts +5 -0
- package/src/components/index.ts +11 -0
- package/src/containers/RoutineArticle/RoutineArticle.stories.tsx +146 -0
- package/src/containers/RoutineArticle/RoutineArticle.tsx +109 -0
- package/src/containers/RoutineArticle/index.ts +5 -0
- package/src/containers/RoutineCompanion/RoutineCompanion.stories.tsx +82 -0
- package/src/containers/RoutineCompanion/RoutineCompanion.tsx +342 -0
- package/src/containers/RoutineCompanion/index.ts +6 -0
- package/src/containers/RoutineSettings/RoutineSettings.tsx +65 -0
- package/src/containers/RoutineSettings/index.ts +5 -0
- package/src/containers/RoutineTraceCompanion/RoutineTraceCompanion.stories.tsx +133 -0
- package/src/containers/RoutineTraceCompanion/RoutineTraceCompanion.tsx +125 -0
- package/src/containers/RoutineTraceCompanion/index.ts +5 -0
- package/src/containers/RoutineTraceCompanion/runs.test.ts +140 -0
- package/src/containers/RoutineTraceCompanion/runs.ts +135 -0
- package/src/containers/RoutineTraceCompanion/useRoutineRuns.ts +50 -0
- package/src/containers/SkillArticle/SkillArticle.tsx +29 -0
- package/src/containers/SkillArticle/index.ts +5 -0
- package/src/containers/index.ts +11 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/useTriggerRuntimeControls.ts +70 -0
- package/src/index.ts +7 -0
- package/src/meta.ts +9 -0
- package/src/operations/create-routine.ts +39 -0
- package/src/operations/create-trigger-from-template.ts +68 -0
- package/src/operations/index.ts +11 -0
- package/src/operations/run-routine.ts +45 -0
- package/src/paths.ts +18 -0
- package/src/plugin.ts +11 -0
- package/src/templates/index.ts +48 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/test-functions.ts +76 -0
- package/src/testing.ts +7 -0
- package/src/translations.ts +125 -0
- package/src/types/Routine.test.ts +51 -0
- package/src/types/Routine.ts +144 -0
- package/src/types/RoutineCapabilities.ts +51 -0
- package/src/types/RoutineOperation.ts +104 -0
- package/src/types/index.ts +9 -0
- package/src/types/schema.ts +31 -0
- package/src/util/index.ts +6 -0
- package/src/util/routines-for-object.test.ts +109 -0
- package/src/util/routines-for-object.ts +89 -0
- package/src/util/run-instructions.test.ts +23 -0
- package/src/util/run-instructions.ts +12 -0
- package/src/vite-env.d.ts +10 -0
|
@@ -0,0 +1,191 @@
|
|
|
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 { Operation, Trigger } from '@dxos/compute';
|
|
16
|
+
import { Database, Filter, JsonSchema, Obj, Ref, Feed as Feed$ } from '@dxos/echo';
|
|
17
|
+
import { EID, type EntityId } from '@dxos/keys';
|
|
18
|
+
|
|
19
|
+
import { Enabled, Feed, Input, TriggerId } from '../options';
|
|
20
|
+
import { printTrigger, promptForSchemaInput, selectFeed, selectFunction, selectTrigger } from '../util';
|
|
21
|
+
|
|
22
|
+
export const queue = Command.make(
|
|
23
|
+
'feed',
|
|
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
|
+
feed: Feed.pipe(Options.optional),
|
|
30
|
+
input: Input.pipe(Options.optional),
|
|
31
|
+
},
|
|
32
|
+
(options) =>
|
|
33
|
+
Effect.gen(function* () {
|
|
34
|
+
const { json } = yield* CommandConfig;
|
|
35
|
+
const triggerId = yield* Option.match(options.id, {
|
|
36
|
+
onNone: () => selectTrigger('feed'),
|
|
37
|
+
onSome: (id) => Effect.succeed(id),
|
|
38
|
+
});
|
|
39
|
+
const dxn = EID.make({ entityId: triggerId as EntityId });
|
|
40
|
+
const trigger = yield* Database.resolve(dxn, Trigger.Trigger);
|
|
41
|
+
if (trigger.spec?.kind !== 'feed') {
|
|
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* updateFeed(trigger, options.feed);
|
|
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 feed trigger.'),
|
|
60
|
+
Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
|
|
61
|
+
Command.provideEffectDiscard(() => withTypes(Operation.PersistentOperation, 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: Operation.PersistentOperation | undefined = trigger.runnable
|
|
71
|
+
? yield* Database.load(trigger.runnable)
|
|
72
|
+
: undefined;
|
|
73
|
+
if (currentFn && !Obj.instanceOf(Operation.PersistentOperation, 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.query(Filter.type(Operation.PersistentOperation)).run;
|
|
91
|
+
const foundFn = functions.find((fn) => fn.id === functionId);
|
|
92
|
+
if (!foundFn || !Obj.instanceOf(Operation.PersistentOperation, foundFn)) {
|
|
93
|
+
return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
|
|
94
|
+
}
|
|
95
|
+
Obj.update(trigger, (trigger) => {
|
|
96
|
+
trigger.runnable = Ref.make(foundFn);
|
|
97
|
+
});
|
|
98
|
+
currentFn = foundFn;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (!currentFn) {
|
|
102
|
+
const runnableId = (trigger.runnable ? trigger.runnable.uri.toString() : undefined) ?? 'unknown';
|
|
103
|
+
return yield* Effect.fail(new Error(`Invalid reference for ${runnableId}`));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return currentFn;
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Handles updating the feed reference for a feed trigger.
|
|
111
|
+
* Prompts for confirmation if feed is not provided, then updates the feed if confirmed.
|
|
112
|
+
*/
|
|
113
|
+
const updateFeed = Effect.fn(function* (trigger: Trigger.Trigger, feedOption: Option.Option<string>) {
|
|
114
|
+
const currentFeed = trigger.spec?.kind === 'feed' ? trigger.spec.feed : undefined;
|
|
115
|
+
const currentFeedStr = currentFeed ? currentFeed.uri.toString() : undefined;
|
|
116
|
+
const shouldChangeFeed = yield* Option.match(feedOption, {
|
|
117
|
+
onNone: () =>
|
|
118
|
+
Prompt.confirm({
|
|
119
|
+
message: `Change the feed${currentFeedStr ? ` (current: ${currentFeedStr})` : ''}?`,
|
|
120
|
+
initial: false,
|
|
121
|
+
}).pipe(Prompt.run),
|
|
122
|
+
onSome: () => Effect.succeed(true),
|
|
123
|
+
});
|
|
124
|
+
if (shouldChangeFeed) {
|
|
125
|
+
const feed = yield* Option.match(feedOption, {
|
|
126
|
+
onNone: () => selectFeed(),
|
|
127
|
+
onSome: (uri) => Database.resolve(EID.parse(uri), Feed$.Feed),
|
|
128
|
+
});
|
|
129
|
+
Obj.update(trigger, (trigger) => {
|
|
130
|
+
if (trigger.spec?.kind === 'feed') {
|
|
131
|
+
trigger.spec.feed = Ref.make(feed);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Handles updating the input for a trigger.
|
|
139
|
+
* Prompts for confirmation if input is not provided, then updates the input if confirmed.
|
|
140
|
+
*/
|
|
141
|
+
const updateInput = Effect.fn(function* (
|
|
142
|
+
trigger: Trigger.Trigger,
|
|
143
|
+
fn: Operation.PersistentOperation,
|
|
144
|
+
inputOption: Option.Option<Record<string, any>>,
|
|
145
|
+
) {
|
|
146
|
+
const currentInput = trigger.input as Record<string, any> | undefined;
|
|
147
|
+
const currentInputStr = currentInput ? JSON.stringify(currentInput) : 'none';
|
|
148
|
+
const shouldChangeInput = yield* Option.match(inputOption, {
|
|
149
|
+
onNone: () =>
|
|
150
|
+
Effect.gen(function* () {
|
|
151
|
+
yield* Console.log(`Current input: ${currentInputStr}`);
|
|
152
|
+
return yield* Prompt.confirm({
|
|
153
|
+
message: 'Change input?',
|
|
154
|
+
initial: false,
|
|
155
|
+
}).pipe(Prompt.run);
|
|
156
|
+
}),
|
|
157
|
+
onSome: () => Effect.succeed(true),
|
|
158
|
+
});
|
|
159
|
+
if (shouldChangeInput) {
|
|
160
|
+
const inputObj = yield* Option.match(inputOption, {
|
|
161
|
+
onNone: () =>
|
|
162
|
+
promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined, currentInput),
|
|
163
|
+
onSome: (value) => Effect.succeed(value as Record<string, any>),
|
|
164
|
+
});
|
|
165
|
+
Obj.update(trigger, (trigger) => {
|
|
166
|
+
trigger.input = inputObj;
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Handles updating the enabled status for a trigger.
|
|
173
|
+
* Prompts for enabled if id is not provided.
|
|
174
|
+
*/
|
|
175
|
+
const updateEnabled = Effect.fn(function* (
|
|
176
|
+
trigger: Trigger.Trigger,
|
|
177
|
+
idOption: Option.Option<string>,
|
|
178
|
+
enabled: boolean,
|
|
179
|
+
) {
|
|
180
|
+
const enabledValue = yield* Option.match(idOption, {
|
|
181
|
+
onNone: () =>
|
|
182
|
+
Prompt.confirm({
|
|
183
|
+
message: 'Enable the trigger?',
|
|
184
|
+
initial: trigger.enabled,
|
|
185
|
+
}).pipe(Prompt.run),
|
|
186
|
+
onSome: () => Effect.succeed(enabled),
|
|
187
|
+
});
|
|
188
|
+
Obj.update(trigger, (trigger) => {
|
|
189
|
+
trigger.enabled = enabledValue;
|
|
190
|
+
});
|
|
191
|
+
});
|
|
@@ -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 { Operation, Trigger } from '@dxos/compute';
|
|
17
|
+
import { Database, Filter, JsonSchema, Obj, Query, Ref } from '@dxos/echo';
|
|
18
|
+
import { DXN, EID } from '@dxos/keys';
|
|
19
|
+
|
|
20
|
+
import { Deep, Delay, Enabled, Input, TriggerId, Typename } from '../options';
|
|
21
|
+
import { printTrigger, promptForSchemaInput, selectFunction, selectTrigger } from '../util';
|
|
22
|
+
|
|
23
|
+
export const subscription = Command.make(
|
|
24
|
+
'subscription',
|
|
25
|
+
{
|
|
26
|
+
spaceId: Common.spaceId.pipe(Options.optional),
|
|
27
|
+
id: TriggerId.pipe(Options.optional),
|
|
28
|
+
enabled: Enabled,
|
|
29
|
+
functionId: Common.functionId.pipe(Options.optional),
|
|
30
|
+
typename: Typename.pipe(Options.optional),
|
|
31
|
+
deep: Deep.pipe(Options.optional),
|
|
32
|
+
delay: Delay.pipe(Options.optional),
|
|
33
|
+
input: Input.pipe(Options.optional),
|
|
34
|
+
},
|
|
35
|
+
(options) =>
|
|
36
|
+
Effect.gen(function* () {
|
|
37
|
+
const { json } = yield* CommandConfig;
|
|
38
|
+
|
|
39
|
+
const triggerId = yield* Option.match(options.id, {
|
|
40
|
+
onNone: () => selectTrigger('subscription'),
|
|
41
|
+
onSome: (id) => Effect.succeed(id),
|
|
42
|
+
});
|
|
43
|
+
const dxn = EID.make({ entityId: triggerId });
|
|
44
|
+
const trigger = yield* Database.resolve(Ref.fromURI(dxn), Trigger.Trigger);
|
|
45
|
+
if (trigger.spec?.kind !== 'subscription') {
|
|
46
|
+
return yield* Effect.fail(new Error(`Invalid trigger type: ${trigger.spec?.kind}`));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const currentFn = yield* updateFunction(trigger, options.functionId);
|
|
50
|
+
yield* updateSpec(trigger, options.typename, options.deep, options.delay);
|
|
51
|
+
yield* updateInput(trigger, currentFn, options.input);
|
|
52
|
+
yield* updateEnabled(trigger, options.id, options.enabled);
|
|
53
|
+
|
|
54
|
+
if (json) {
|
|
55
|
+
yield* Console.log(JSON.stringify(trigger, null, 2));
|
|
56
|
+
} else {
|
|
57
|
+
yield* Console.log(print(yield* printTrigger(trigger)));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
yield* flushAndSync({ indexes: true });
|
|
61
|
+
}),
|
|
62
|
+
).pipe(
|
|
63
|
+
Command.withDescription('Update a subscription trigger.'),
|
|
64
|
+
Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
|
|
65
|
+
Command.provideEffectDiscard(() => withTypes(Operation.PersistentOperation, Trigger.Trigger)),
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Extracts the current typename from a subscription trigger's query AST.
|
|
70
|
+
*/
|
|
71
|
+
const extractCurrentTypename = (spec: Trigger.SubscriptionSpec | undefined): Option.Option<string> => {
|
|
72
|
+
if (!spec?.query?.ast) {
|
|
73
|
+
return Option.none();
|
|
74
|
+
}
|
|
75
|
+
return Match.value(spec.query.ast).pipe(
|
|
76
|
+
Match.withReturnType<Option.Option<string>>(),
|
|
77
|
+
Match.when({ type: 'select' }, (q) =>
|
|
78
|
+
Match.value(q.filter).pipe(
|
|
79
|
+
Match.withReturnType<Option.Option<string>>(),
|
|
80
|
+
Match.when({ type: 'object' }, (f) =>
|
|
81
|
+
Option.fromNullable(f.typename).pipe(
|
|
82
|
+
Option.flatMap((dxn) => Option.fromNullable(DXN.isDXN(dxn) ? DXN.getName(dxn) : undefined)),
|
|
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: Operation.PersistentOperation | undefined = trigger.runnable
|
|
99
|
+
? yield* Database.load(trigger.runnable)
|
|
100
|
+
: undefined;
|
|
101
|
+
if (currentFn && !Obj.instanceOf(Operation.PersistentOperation, 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.query(Filter.type(Operation.PersistentOperation)).run;
|
|
119
|
+
const foundFn = functions.find((fn) => fn.id === functionId);
|
|
120
|
+
if (!foundFn || !Obj.instanceOf(Operation.PersistentOperation, foundFn)) {
|
|
121
|
+
return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
|
|
122
|
+
}
|
|
123
|
+
Obj.update(trigger, (trigger) => {
|
|
124
|
+
trigger.runnable = Ref.make(foundFn);
|
|
125
|
+
});
|
|
126
|
+
currentFn = foundFn;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (!currentFn) {
|
|
130
|
+
const runnableId = trigger.runnable?.uri.toString() ?? 'unknown';
|
|
131
|
+
return yield* Effect.fail(new Error(`Invalid reference for ${runnableId}`));
|
|
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(DXN.make(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.update(trigger, (trigger) => {
|
|
214
|
+
const spec = trigger.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: Operation.PersistentOperation,
|
|
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.update(trigger, (trigger) => {
|
|
253
|
+
trigger.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.update(trigger, (trigger) => {
|
|
276
|
+
trigger.enabled = enabledValue;
|
|
277
|
+
});
|
|
278
|
+
});
|
|
@@ -0,0 +1,194 @@
|
|
|
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 { Operation, Trigger } from '@dxos/compute';
|
|
16
|
+
import { Database, Filter, JsonSchema, Obj, Ref } from '@dxos/echo';
|
|
17
|
+
import { EID } from '@dxos/keys';
|
|
18
|
+
|
|
19
|
+
import { Cron, Enabled, Input, TriggerId } from '../options';
|
|
20
|
+
import { printTrigger, promptForSchemaInput, selectFunction, selectTrigger } from '../util';
|
|
21
|
+
|
|
22
|
+
export const timer = Command.make(
|
|
23
|
+
'timer',
|
|
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
|
+
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 triggerId = yield* Option.match(options.id, {
|
|
37
|
+
onNone: () => selectTrigger('timer'),
|
|
38
|
+
onSome: (id) => Effect.succeed(id),
|
|
39
|
+
});
|
|
40
|
+
const dxn = EID.make({ entityId: triggerId });
|
|
41
|
+
const trigger = yield* Database.resolve(Ref.fromURI(dxn), Trigger.Trigger);
|
|
42
|
+
if (!trigger.spec || trigger.spec?.kind !== 'timer') {
|
|
43
|
+
return yield* Effect.fail(new Error(`Invalid trigger type: ${trigger.spec?.kind}`));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const currentFn = yield* updateFunction(trigger, options.functionId);
|
|
47
|
+
yield* updateCron(trigger, options.cron);
|
|
48
|
+
yield* updateInput(trigger, currentFn, options.input);
|
|
49
|
+
yield* updateEnabled(trigger, options.id, options.enabled);
|
|
50
|
+
|
|
51
|
+
if (json) {
|
|
52
|
+
yield* Console.log(JSON.stringify(trigger, null, 2));
|
|
53
|
+
} else {
|
|
54
|
+
yield* Console.log(print(yield* printTrigger(trigger)));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
yield* flushAndSync({ indexes: true });
|
|
58
|
+
}),
|
|
59
|
+
).pipe(
|
|
60
|
+
Command.withDescription('Update a timer trigger.'),
|
|
61
|
+
Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
|
|
62
|
+
Command.provideEffectDiscard(() => withTypes(Operation.PersistentOperation, Trigger.Trigger)),
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Handles updating the function for a trigger.
|
|
67
|
+
* Prompts for confirmation if functionId is not provided, then updates the function if confirmed.
|
|
68
|
+
* @returns The current function (either original or newly assigned)
|
|
69
|
+
*/
|
|
70
|
+
const updateFunction = Effect.fn(function* (trigger: Trigger.Trigger, functionIdOption: Option.Option<string>) {
|
|
71
|
+
let currentFn: Operation.PersistentOperation | undefined = trigger.runnable
|
|
72
|
+
? yield* Database.load(trigger.runnable)
|
|
73
|
+
: undefined;
|
|
74
|
+
if (currentFn && !Obj.instanceOf(Operation.PersistentOperation, currentFn)) {
|
|
75
|
+
currentFn = undefined;
|
|
76
|
+
}
|
|
77
|
+
const currentFunctionName = currentFn ? (currentFn.name ?? currentFn.id) : undefined;
|
|
78
|
+
const shouldChangeFunction = yield* Option.match(functionIdOption, {
|
|
79
|
+
onNone: () =>
|
|
80
|
+
Prompt.confirm({
|
|
81
|
+
message: `Change the function${currentFunctionName ? ` (current: ${currentFunctionName})` : ''}?`,
|
|
82
|
+
initial: false,
|
|
83
|
+
}).pipe(Prompt.run),
|
|
84
|
+
onSome: () => Effect.succeed(true),
|
|
85
|
+
});
|
|
86
|
+
if (shouldChangeFunction) {
|
|
87
|
+
const functionId = yield* Option.match(functionIdOption, {
|
|
88
|
+
onNone: () => selectFunction(),
|
|
89
|
+
onSome: (id) => Effect.succeed(id),
|
|
90
|
+
});
|
|
91
|
+
const functions = yield* Database.query(Filter.type(Operation.PersistentOperation)).run;
|
|
92
|
+
const foundFn = functions.find((fn) => fn.id === functionId);
|
|
93
|
+
if (!foundFn || !Obj.instanceOf(Operation.PersistentOperation, foundFn)) {
|
|
94
|
+
return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
|
|
95
|
+
}
|
|
96
|
+
Obj.update(trigger, (trigger) => {
|
|
97
|
+
trigger.runnable = Ref.make(foundFn);
|
|
98
|
+
});
|
|
99
|
+
currentFn = foundFn;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (!currentFn) {
|
|
103
|
+
const runnableId = trigger.runnable?.uri.toString() ?? 'unknown';
|
|
104
|
+
return yield* Effect.fail(new Error(`Invalid reference for ${runnableId}`));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return currentFn;
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Handles updating the cron expression for a timer trigger.
|
|
112
|
+
* Prompts for confirmation if cron is not provided, then updates the cron if confirmed.
|
|
113
|
+
*/
|
|
114
|
+
const updateCron = Effect.fn(function* (trigger: Trigger.Trigger, cronOption: Option.Option<string>) {
|
|
115
|
+
const currentCron = trigger.spec?.kind === 'timer' ? trigger.spec.cron : undefined;
|
|
116
|
+
const shouldChangeCron = yield* Option.match(cronOption, {
|
|
117
|
+
onNone: () =>
|
|
118
|
+
Prompt.confirm({
|
|
119
|
+
message: `Change the cron expression${currentCron ? ` (current: ${currentCron})` : ''}?`,
|
|
120
|
+
initial: false,
|
|
121
|
+
}).pipe(Prompt.run),
|
|
122
|
+
onSome: () => Effect.succeed(true),
|
|
123
|
+
});
|
|
124
|
+
if (shouldChangeCron) {
|
|
125
|
+
const cron = yield* Option.match(cronOption, {
|
|
126
|
+
onNone: () =>
|
|
127
|
+
Prompt.text({
|
|
128
|
+
message: `Enter cron expression${currentCron ? ` (current: ${currentCron})` : ''}:`,
|
|
129
|
+
}).pipe(Prompt.run),
|
|
130
|
+
onSome: (value) => Effect.succeed(value),
|
|
131
|
+
});
|
|
132
|
+
Obj.update(trigger, (trigger) => {
|
|
133
|
+
if (trigger.spec?.kind === 'timer') {
|
|
134
|
+
trigger.spec.cron = cron;
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Handles updating the input for a trigger.
|
|
142
|
+
* Prompts for confirmation if input is not provided, then updates the input if confirmed.
|
|
143
|
+
*/
|
|
144
|
+
const updateInput = Effect.fn(function* (
|
|
145
|
+
trigger: Trigger.Trigger,
|
|
146
|
+
fn: Operation.PersistentOperation,
|
|
147
|
+
inputOption: Option.Option<Record<string, any>>,
|
|
148
|
+
) {
|
|
149
|
+
const currentInput = trigger.input as Record<string, any> | undefined;
|
|
150
|
+
const currentInputStr = currentInput ? JSON.stringify(currentInput) : 'none';
|
|
151
|
+
const shouldChangeInput = yield* Option.match(inputOption, {
|
|
152
|
+
onNone: () =>
|
|
153
|
+
Effect.gen(function* () {
|
|
154
|
+
yield* Console.log(`Current input: ${currentInputStr}`);
|
|
155
|
+
return yield* Prompt.confirm({
|
|
156
|
+
message: 'Change input?',
|
|
157
|
+
initial: false,
|
|
158
|
+
}).pipe(Prompt.run);
|
|
159
|
+
}),
|
|
160
|
+
onSome: () => Effect.succeed(true),
|
|
161
|
+
});
|
|
162
|
+
if (shouldChangeInput) {
|
|
163
|
+
const inputObj = yield* Option.match(inputOption, {
|
|
164
|
+
onNone: () =>
|
|
165
|
+
promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined, currentInput),
|
|
166
|
+
onSome: (value) => Effect.succeed(value as Record<string, any>),
|
|
167
|
+
});
|
|
168
|
+
Obj.update(trigger, (trigger) => {
|
|
169
|
+
trigger.input = inputObj;
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Handles updating the enabled status for a trigger.
|
|
176
|
+
* Prompts for enabled if id is not provided.
|
|
177
|
+
*/
|
|
178
|
+
const updateEnabled = Effect.fn(function* (
|
|
179
|
+
trigger: Trigger.Trigger,
|
|
180
|
+
idOption: Option.Option<string>,
|
|
181
|
+
enabled: boolean,
|
|
182
|
+
) {
|
|
183
|
+
const enabledValue = yield* Option.match(idOption, {
|
|
184
|
+
onNone: () =>
|
|
185
|
+
Prompt.confirm({
|
|
186
|
+
message: 'Enable the trigger?',
|
|
187
|
+
initial: trigger.enabled,
|
|
188
|
+
}).pipe(Prompt.run),
|
|
189
|
+
onSome: () => Effect.succeed(enabled),
|
|
190
|
+
});
|
|
191
|
+
Obj.update(trigger, (trigger) => {
|
|
192
|
+
trigger.enabled = enabledValue;
|
|
193
|
+
});
|
|
194
|
+
});
|