@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,1921 @@
|
|
|
1
|
+
import "../chunk-J5LGTIGS.mjs";
|
|
2
|
+
|
|
3
|
+
// src/components/RoutineForm/RoutineForm.tsx
|
|
4
|
+
import * as Schema3 from "effect/Schema";
|
|
5
|
+
import React5, { useCallback as useCallback5, useMemo as useMemo3 } from "react";
|
|
6
|
+
import { Instructions as Instructions2, Operation, Trigger as Trigger2 } from "@dxos/compute";
|
|
7
|
+
import { DXN as DXN2, Entity as Entity2, Filter as Filter2, Obj as Obj3, Query as Query2, Ref as Ref2, Scope as Scope2, Type as Type3 } from "@dxos/echo";
|
|
8
|
+
import { useObject, useQuery as useQuery2 } from "@dxos/react-client/echo";
|
|
9
|
+
import { ToggleGroup as ToggleGroup2, ToggleGroupItem as ToggleGroupItem2, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
10
|
+
import { Form as Form3, RefField } from "@dxos/react-ui-form";
|
|
11
|
+
import { meta as meta4 } from "#meta";
|
|
12
|
+
import { Routine as Routine2 } from "#types";
|
|
13
|
+
|
|
14
|
+
// src/components/InstructionsEditor/InstructionsEditor.tsx
|
|
15
|
+
import * as Option from "effect/Option";
|
|
16
|
+
import React, { useCallback, useMemo } from "react";
|
|
17
|
+
import { Instructions, Skill } from "@dxos/compute";
|
|
18
|
+
import { Entity, Obj, Type } from "@dxos/echo";
|
|
19
|
+
import { HiddenAnnotation } from "@dxos/echo/Annotation";
|
|
20
|
+
import { Form } from "@dxos/react-ui-form";
|
|
21
|
+
var INSTRUCTIONS_SCHEMA = Type.getSchema(Instructions.Instructions);
|
|
22
|
+
var INSTRUCTIONS_FIELDS = /* @__PURE__ */ new Set([
|
|
23
|
+
"text",
|
|
24
|
+
"skills",
|
|
25
|
+
"objects"
|
|
26
|
+
]);
|
|
27
|
+
var InstructionsEditor = ({ db: dbProp, instructions, readonly }) => {
|
|
28
|
+
const db = dbProp ?? Obj.getDatabase(instructions);
|
|
29
|
+
const defaultValues = useMemo(() => ({
|
|
30
|
+
...Obj.getSnapshot(instructions),
|
|
31
|
+
objects: instructions.objects ? [
|
|
32
|
+
...instructions.objects
|
|
33
|
+
] : []
|
|
34
|
+
}), [
|
|
35
|
+
instructions
|
|
36
|
+
]);
|
|
37
|
+
const handleValuesChanged = useCallback((values, { isValid }) => {
|
|
38
|
+
if (!isValid) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
Obj.update(instructions, (instructions2) => {
|
|
42
|
+
if (values.text) {
|
|
43
|
+
instructions2.text = values.text;
|
|
44
|
+
}
|
|
45
|
+
instructions2.skills = [
|
|
46
|
+
...values.skills ?? []
|
|
47
|
+
];
|
|
48
|
+
instructions2.objects = [
|
|
49
|
+
...values.objects ?? []
|
|
50
|
+
];
|
|
51
|
+
});
|
|
52
|
+
}, [
|
|
53
|
+
instructions
|
|
54
|
+
]);
|
|
55
|
+
return /* @__PURE__ */ React.createElement(Form.Root, {
|
|
56
|
+
key: instructions.id,
|
|
57
|
+
schema: INSTRUCTIONS_SCHEMA,
|
|
58
|
+
db,
|
|
59
|
+
readonly,
|
|
60
|
+
defaultValues,
|
|
61
|
+
getOptions: getRefOptions,
|
|
62
|
+
onValuesChanged: handleValuesChanged
|
|
63
|
+
}, /* @__PURE__ */ React.createElement(Form.FieldSet, {
|
|
64
|
+
filter: (props) => props.filter((prop) => INSTRUCTIONS_FIELDS.has(prop.name.toString()))
|
|
65
|
+
}));
|
|
66
|
+
};
|
|
67
|
+
var isSystemObject = (object) => {
|
|
68
|
+
if (!Obj.isObject(object)) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
const typeEntity = Obj.getType(object);
|
|
72
|
+
if (!typeEntity) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
return HiddenAnnotation.get(Type.getSchema(typeEntity)).pipe(Option.getOrElse(() => false));
|
|
76
|
+
};
|
|
77
|
+
var getRefOptions = (results, { getTypePlaceholder } = {}) => results.filter((entity) => !isSystemObject(entity)).map((entity) => {
|
|
78
|
+
const id = Entity.getURI(entity, {
|
|
79
|
+
prefer: "named"
|
|
80
|
+
});
|
|
81
|
+
const typename = Entity.getTypename(entity);
|
|
82
|
+
const label = Entity.getLabel(entity) ?? (typename ? getTypePlaceholder?.(typename) : void 0) ?? id;
|
|
83
|
+
const description = Obj.instanceOf(Skill.Skill, entity) ? Obj.getMeta(entity).key : typename;
|
|
84
|
+
return {
|
|
85
|
+
id,
|
|
86
|
+
label,
|
|
87
|
+
description
|
|
88
|
+
};
|
|
89
|
+
}).sort((left, right) => left.label.localeCompare(right.label));
|
|
90
|
+
|
|
91
|
+
// src/components/TriggerEditor/TriggerEditor.tsx
|
|
92
|
+
import * as Schema2 from "effect/Schema";
|
|
93
|
+
import React4, { useCallback as useCallback4, useMemo as useMemo2, useState as useState2 } from "react";
|
|
94
|
+
import { Trigger } from "@dxos/compute";
|
|
95
|
+
import { DXN, Feed, Filter, Obj as Obj2, Query, Ref, Scope, Type as Type2 } from "@dxos/echo";
|
|
96
|
+
import { useQuery } from "@dxos/react-client/echo";
|
|
97
|
+
import { IconButton, Input as Input2, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
98
|
+
import { Form as Form2, SelectField } from "@dxos/react-ui-form";
|
|
99
|
+
import { ParentLabelAnnotation } from "@dxos/schema";
|
|
100
|
+
import { mx as mx2 } from "@dxos/ui-theme";
|
|
101
|
+
import { meta as meta3 } from "#meta";
|
|
102
|
+
import { Routine } from "#types";
|
|
103
|
+
|
|
104
|
+
// src/components/Schedule/cron.ts
|
|
105
|
+
import cronstrue from "cronstrue";
|
|
106
|
+
var DOW_MAP = {
|
|
107
|
+
sun: 0,
|
|
108
|
+
mon: 1,
|
|
109
|
+
tue: 2,
|
|
110
|
+
wed: 3,
|
|
111
|
+
thu: 4,
|
|
112
|
+
fri: 5,
|
|
113
|
+
sat: 6
|
|
114
|
+
};
|
|
115
|
+
var toCron = (value) => {
|
|
116
|
+
switch (value.frequency) {
|
|
117
|
+
case "minutely":
|
|
118
|
+
return `*/${value.interval} * * * *`;
|
|
119
|
+
case "hourly":
|
|
120
|
+
return `${value.minute} */${value.interval} * * *`;
|
|
121
|
+
case "daily":
|
|
122
|
+
return `${value.minute} ${value.hour} * * *`;
|
|
123
|
+
case "weekly": {
|
|
124
|
+
const dow = value.daysOfWeek.length > 0 ? value.daysOfWeek.map((d) => DOW_MAP[d]).join(",") : "*";
|
|
125
|
+
return `${value.minute} ${value.hour} * * ${dow}`;
|
|
126
|
+
}
|
|
127
|
+
case "monthly": {
|
|
128
|
+
const dom = value.daysOfMonth.length > 0 ? value.daysOfMonth.join(",") : "*";
|
|
129
|
+
return `${value.minute} ${value.hour} ${dom} * *`;
|
|
130
|
+
}
|
|
131
|
+
case "custom":
|
|
132
|
+
return value.cronExpression || "* * * * *";
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
var DOW_REVERSE = {
|
|
136
|
+
"0": "sun",
|
|
137
|
+
"1": "mon",
|
|
138
|
+
"2": "tue",
|
|
139
|
+
"3": "wed",
|
|
140
|
+
"4": "thu",
|
|
141
|
+
"5": "fri",
|
|
142
|
+
"6": "sat",
|
|
143
|
+
// Both 0 and 7 represent Sunday in standard cron.
|
|
144
|
+
"7": "sun"
|
|
145
|
+
};
|
|
146
|
+
var parseUInt = (token) => /^\d+$/.test(token) ? Number(token) : void 0;
|
|
147
|
+
var parseBoundedUInt = (token, min, max) => {
|
|
148
|
+
const value = parseUInt(token);
|
|
149
|
+
return value !== void 0 && value >= min && value <= max ? value : void 0;
|
|
150
|
+
};
|
|
151
|
+
var fromCron = (cron) => {
|
|
152
|
+
const parts = cron.trim().split(/\s+/);
|
|
153
|
+
if (parts.length !== 5) {
|
|
154
|
+
return {
|
|
155
|
+
frequency: "custom",
|
|
156
|
+
cronExpression: cron
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
const [minute, hour, dom, month, dow] = parts;
|
|
160
|
+
const minutelyMatch = minute.match(/^\*\/(\d+)$/);
|
|
161
|
+
if (minutelyMatch && hour === "*" && dom === "*" && month === "*" && dow === "*") {
|
|
162
|
+
return {
|
|
163
|
+
frequency: "minutely",
|
|
164
|
+
interval: parseInt(minutelyMatch[1])
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
const hourlyMatch = hour.match(/^\*\/(\d+)$/);
|
|
168
|
+
const minuteNum = parseBoundedUInt(minute, 0, 59);
|
|
169
|
+
if (hourlyMatch && dom === "*" && month === "*" && dow === "*" && minuteNum !== void 0) {
|
|
170
|
+
return {
|
|
171
|
+
frequency: "hourly",
|
|
172
|
+
interval: parseInt(hourlyMatch[1]),
|
|
173
|
+
minute: minuteNum
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
const hourNum = parseBoundedUInt(hour, 0, 23);
|
|
177
|
+
if (minuteNum === void 0 || hourNum === void 0) {
|
|
178
|
+
return {
|
|
179
|
+
frequency: "custom",
|
|
180
|
+
cronExpression: cron
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
if (dom === "*" && month === "*" && dow !== "*") {
|
|
184
|
+
const tokens = dow.split(",");
|
|
185
|
+
const days = tokens.map((d) => DOW_REVERSE[d]).filter((d) => d != null);
|
|
186
|
+
if (days.length === tokens.length && days.length > 0) {
|
|
187
|
+
return {
|
|
188
|
+
frequency: "weekly",
|
|
189
|
+
daysOfWeek: days,
|
|
190
|
+
hour: hourNum,
|
|
191
|
+
minute: minuteNum
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
frequency: "custom",
|
|
196
|
+
cronExpression: cron
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
if (dom !== "*" && month === "*" && dow === "*") {
|
|
200
|
+
const tokens = dom.split(",");
|
|
201
|
+
const days = tokens.map((d) => parseBoundedUInt(d, 1, 31)).filter((d) => d !== void 0);
|
|
202
|
+
if (days.length === tokens.length && days.length > 0) {
|
|
203
|
+
return {
|
|
204
|
+
frequency: "monthly",
|
|
205
|
+
daysOfMonth: days,
|
|
206
|
+
hour: hourNum,
|
|
207
|
+
minute: minuteNum
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
frequency: "custom",
|
|
212
|
+
cronExpression: cron
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
if (dom === "*" && month === "*" && dow === "*") {
|
|
216
|
+
return {
|
|
217
|
+
frequency: "daily",
|
|
218
|
+
hour: hourNum,
|
|
219
|
+
minute: minuteNum
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
return {
|
|
223
|
+
frequency: "custom",
|
|
224
|
+
cronExpression: cron
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
var describeCron = (cron) => {
|
|
228
|
+
try {
|
|
229
|
+
return cronstrue.toString(cron, {
|
|
230
|
+
throwExceptionOnParseError: true
|
|
231
|
+
});
|
|
232
|
+
} catch {
|
|
233
|
+
return cron;
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
var pad = (value) => String(value).padStart(2, "0");
|
|
237
|
+
var splitTime = (time) => {
|
|
238
|
+
const [hour, minute] = time.split(":").map(Number);
|
|
239
|
+
return {
|
|
240
|
+
hour: Number.isFinite(hour) ? hour : 0,
|
|
241
|
+
minute: Number.isFinite(minute) ? minute : 0
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
var joinTime = (hour, minute) => `${pad(hour)}:${pad(minute)}`;
|
|
245
|
+
var scheduleToCron = (value) => {
|
|
246
|
+
switch (value.kind) {
|
|
247
|
+
case "hourly":
|
|
248
|
+
return toCron({
|
|
249
|
+
frequency: "hourly",
|
|
250
|
+
interval: 1,
|
|
251
|
+
minute: value.minute
|
|
252
|
+
});
|
|
253
|
+
case "daily": {
|
|
254
|
+
const { hour, minute } = splitTime(value.time);
|
|
255
|
+
return toCron({
|
|
256
|
+
frequency: "daily",
|
|
257
|
+
hour,
|
|
258
|
+
minute
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
case "weekly": {
|
|
262
|
+
const { hour, minute } = splitTime(value.time);
|
|
263
|
+
return toCron({
|
|
264
|
+
frequency: "weekly",
|
|
265
|
+
daysOfWeek: value.days,
|
|
266
|
+
hour,
|
|
267
|
+
minute
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
case "monthly": {
|
|
271
|
+
const { hour, minute } = splitTime(value.time);
|
|
272
|
+
return toCron({
|
|
273
|
+
frequency: "monthly",
|
|
274
|
+
daysOfMonth: [
|
|
275
|
+
value.day
|
|
276
|
+
],
|
|
277
|
+
hour,
|
|
278
|
+
minute
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
case "custom":
|
|
282
|
+
return toCron({
|
|
283
|
+
frequency: "custom",
|
|
284
|
+
cronExpression: value.cron
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
var MINUTE_SECONDS = 60;
|
|
289
|
+
var HOUR_SECONDS = 60 * 60;
|
|
290
|
+
var DAY_SECONDS = 24 * HOUR_SECONDS;
|
|
291
|
+
var MAX_MIN_INTERVAL_SECONDS = HOUR_SECONDS;
|
|
292
|
+
var parseList = (field, min, max) => {
|
|
293
|
+
const tokens = field.split(",");
|
|
294
|
+
const values = tokens.map((token) => parseBoundedUInt(token, min, max)).filter((value) => value !== void 0);
|
|
295
|
+
return values.length === tokens.length && values.length > 0 ? values : void 0;
|
|
296
|
+
};
|
|
297
|
+
var minGap = (values, span) => {
|
|
298
|
+
const sorted = [
|
|
299
|
+
...new Set(values)
|
|
300
|
+
].sort((lhs, rhs) => lhs - rhs);
|
|
301
|
+
if (sorted.length <= 1) {
|
|
302
|
+
return Number.POSITIVE_INFINITY;
|
|
303
|
+
}
|
|
304
|
+
let gap = Number.POSITIVE_INFINITY;
|
|
305
|
+
for (let index = 0; index < sorted.length; index++) {
|
|
306
|
+
const next = index === sorted.length - 1 ? sorted[0] + span : sorted[index + 1];
|
|
307
|
+
gap = Math.min(gap, next - sorted[index]);
|
|
308
|
+
}
|
|
309
|
+
return gap;
|
|
310
|
+
};
|
|
311
|
+
var parseStep = (field, max) => {
|
|
312
|
+
const match = field.match(/^(?:\*|\d+(?:-\d+)?)\/(\d+)$/);
|
|
313
|
+
return match ? parseBoundedUInt(match[1], 1, max) : void 0;
|
|
314
|
+
};
|
|
315
|
+
var hourIntervalSeconds = (hour) => {
|
|
316
|
+
const step = parseStep(hour, 23);
|
|
317
|
+
if (step !== void 0) {
|
|
318
|
+
return step * HOUR_SECONDS;
|
|
319
|
+
}
|
|
320
|
+
if (hour === "*") {
|
|
321
|
+
return HOUR_SECONDS;
|
|
322
|
+
}
|
|
323
|
+
const hours = parseList(hour, 0, 23);
|
|
324
|
+
if (hours) {
|
|
325
|
+
return hours.length > 1 ? minGap(hours, 24) * HOUR_SECONDS : DAY_SECONDS;
|
|
326
|
+
}
|
|
327
|
+
return Number.POSITIVE_INFINITY;
|
|
328
|
+
};
|
|
329
|
+
var cronIntervalSeconds = (cron) => {
|
|
330
|
+
const parts = cron.trim().split(/\s+/);
|
|
331
|
+
if (parts.length !== 5) {
|
|
332
|
+
return Number.POSITIVE_INFINITY;
|
|
333
|
+
}
|
|
334
|
+
const [minute, hour] = parts;
|
|
335
|
+
const minuteStep = parseStep(minute, 59);
|
|
336
|
+
if (minuteStep !== void 0) {
|
|
337
|
+
return minuteStep * MINUTE_SECONDS;
|
|
338
|
+
}
|
|
339
|
+
if (minute === "*") {
|
|
340
|
+
return MINUTE_SECONDS;
|
|
341
|
+
}
|
|
342
|
+
const minutes = parseList(minute, 0, 59);
|
|
343
|
+
if (minutes) {
|
|
344
|
+
const minuteGap = minutes.length > 1 ? minGap(minutes, 60) * MINUTE_SECONDS : Number.POSITIVE_INFINITY;
|
|
345
|
+
return Math.min(minuteGap, hourIntervalSeconds(hour));
|
|
346
|
+
}
|
|
347
|
+
return Number.POSITIVE_INFINITY;
|
|
348
|
+
};
|
|
349
|
+
var clampCronMinute = (cron, minIntervalSeconds) => {
|
|
350
|
+
const parts = cron.trim().split(/\s+/);
|
|
351
|
+
if (parts.length !== 5) {
|
|
352
|
+
return cron;
|
|
353
|
+
}
|
|
354
|
+
const stepMinutes = Math.ceil(minIntervalSeconds / MINUTE_SECONDS);
|
|
355
|
+
parts[0] = stepMinutes >= 60 ? "0" : `*/${stepMinutes}`;
|
|
356
|
+
return parts.join(" ");
|
|
357
|
+
};
|
|
358
|
+
var scheduleIntervalSeconds = (value) => {
|
|
359
|
+
switch (value.kind) {
|
|
360
|
+
case "hourly":
|
|
361
|
+
return HOUR_SECONDS;
|
|
362
|
+
case "daily":
|
|
363
|
+
return DAY_SECONDS;
|
|
364
|
+
// Consecutive selected weekdays sit one day apart at closest.
|
|
365
|
+
case "weekly":
|
|
366
|
+
return DAY_SECONDS;
|
|
367
|
+
// Approximate the shortest month to stay conservative.
|
|
368
|
+
case "monthly":
|
|
369
|
+
return 28 * DAY_SECONDS;
|
|
370
|
+
case "custom":
|
|
371
|
+
return cronIntervalSeconds(value.cron);
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
var clampSchedule = (value, minIntervalSeconds) => {
|
|
375
|
+
if (value.kind !== "custom" || cronIntervalSeconds(value.cron) >= minIntervalSeconds) {
|
|
376
|
+
return value;
|
|
377
|
+
}
|
|
378
|
+
return {
|
|
379
|
+
kind: "custom",
|
|
380
|
+
cron: clampCronMinute(value.cron, minIntervalSeconds)
|
|
381
|
+
};
|
|
382
|
+
};
|
|
383
|
+
var cronToSchedule = (cron) => {
|
|
384
|
+
const spec = fromCron(cron);
|
|
385
|
+
switch (spec.frequency) {
|
|
386
|
+
case "hourly":
|
|
387
|
+
return spec.interval === 1 ? {
|
|
388
|
+
kind: "hourly",
|
|
389
|
+
minute: spec.minute
|
|
390
|
+
} : {
|
|
391
|
+
kind: "custom",
|
|
392
|
+
cron
|
|
393
|
+
};
|
|
394
|
+
case "daily":
|
|
395
|
+
return {
|
|
396
|
+
kind: "daily",
|
|
397
|
+
time: joinTime(spec.hour, spec.minute)
|
|
398
|
+
};
|
|
399
|
+
case "weekly":
|
|
400
|
+
return {
|
|
401
|
+
kind: "weekly",
|
|
402
|
+
time: joinTime(spec.hour, spec.minute),
|
|
403
|
+
days: [
|
|
404
|
+
...spec.daysOfWeek
|
|
405
|
+
]
|
|
406
|
+
};
|
|
407
|
+
case "monthly":
|
|
408
|
+
return spec.daysOfMonth.length === 1 ? {
|
|
409
|
+
kind: "monthly",
|
|
410
|
+
day: spec.daysOfMonth[0],
|
|
411
|
+
time: joinTime(spec.hour, spec.minute)
|
|
412
|
+
} : {
|
|
413
|
+
kind: "custom",
|
|
414
|
+
cron
|
|
415
|
+
};
|
|
416
|
+
case "minutely":
|
|
417
|
+
case "custom":
|
|
418
|
+
default:
|
|
419
|
+
return {
|
|
420
|
+
kind: "custom",
|
|
421
|
+
cron
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
// src/components/Schedule/types.ts
|
|
427
|
+
import * as Schema from "effect/Schema";
|
|
428
|
+
var MinutelySpec = Schema.Struct({
|
|
429
|
+
frequency: Schema.Literal("minutely").annotations({
|
|
430
|
+
title: "Frequency"
|
|
431
|
+
}),
|
|
432
|
+
interval: Schema.Number.pipe(Schema.int(), Schema.between(1, 59)).annotations({
|
|
433
|
+
title: "Every (minutes)",
|
|
434
|
+
description: "1\u201359"
|
|
435
|
+
})
|
|
436
|
+
});
|
|
437
|
+
var HourlySpec = Schema.Struct({
|
|
438
|
+
frequency: Schema.Literal("hourly").annotations({
|
|
439
|
+
title: "Frequency"
|
|
440
|
+
}),
|
|
441
|
+
interval: Schema.Number.pipe(Schema.int(), Schema.between(1, 23)).annotations({
|
|
442
|
+
title: "Every (hours)",
|
|
443
|
+
description: "1\u201323"
|
|
444
|
+
}),
|
|
445
|
+
minute: Schema.Number.pipe(Schema.int(), Schema.between(0, 59)).annotations({
|
|
446
|
+
title: "At minute",
|
|
447
|
+
description: "0\u201359"
|
|
448
|
+
})
|
|
449
|
+
});
|
|
450
|
+
var DailySpec = Schema.Struct({
|
|
451
|
+
frequency: Schema.Literal("daily").annotations({
|
|
452
|
+
title: "Frequency"
|
|
453
|
+
}),
|
|
454
|
+
hour: Schema.Number.pipe(Schema.int(), Schema.between(0, 23)).annotations({
|
|
455
|
+
title: "Hour",
|
|
456
|
+
description: "0\u201323"
|
|
457
|
+
}),
|
|
458
|
+
minute: Schema.Number.pipe(Schema.int(), Schema.between(0, 59)).annotations({
|
|
459
|
+
title: "Minute",
|
|
460
|
+
description: "0\u201359"
|
|
461
|
+
})
|
|
462
|
+
});
|
|
463
|
+
var DayOfWeek = Schema.Literal("sun", "mon", "tue", "wed", "thu", "fri", "sat");
|
|
464
|
+
var WeeklySpec = Schema.Struct({
|
|
465
|
+
frequency: Schema.Literal("weekly").annotations({
|
|
466
|
+
title: "Frequency"
|
|
467
|
+
}),
|
|
468
|
+
daysOfWeek: Schema.Array(DayOfWeek.annotations({
|
|
469
|
+
title: "Day"
|
|
470
|
+
})).annotations({
|
|
471
|
+
title: "Days of week"
|
|
472
|
+
}),
|
|
473
|
+
hour: Schema.Number.pipe(Schema.int(), Schema.between(0, 23)).annotations({
|
|
474
|
+
title: "Hour",
|
|
475
|
+
description: "0\u201323"
|
|
476
|
+
}),
|
|
477
|
+
minute: Schema.Number.pipe(Schema.int(), Schema.between(0, 59)).annotations({
|
|
478
|
+
title: "Minute",
|
|
479
|
+
description: "0\u201359"
|
|
480
|
+
})
|
|
481
|
+
});
|
|
482
|
+
var MonthlySpec = Schema.Struct({
|
|
483
|
+
frequency: Schema.Literal("monthly").annotations({
|
|
484
|
+
title: "Frequency"
|
|
485
|
+
}),
|
|
486
|
+
daysOfMonth: Schema.Array(Schema.Number.pipe(Schema.int(), Schema.between(1, 31)).annotations({
|
|
487
|
+
title: "Day"
|
|
488
|
+
})).annotations({
|
|
489
|
+
title: "Days of month"
|
|
490
|
+
}),
|
|
491
|
+
hour: Schema.Number.pipe(Schema.int(), Schema.between(0, 23)).annotations({
|
|
492
|
+
title: "Hour",
|
|
493
|
+
description: "0\u201323"
|
|
494
|
+
}),
|
|
495
|
+
minute: Schema.Number.pipe(Schema.int(), Schema.between(0, 59)).annotations({
|
|
496
|
+
title: "Minute",
|
|
497
|
+
description: "0\u201359"
|
|
498
|
+
})
|
|
499
|
+
});
|
|
500
|
+
var CustomSpec = Schema.Struct({
|
|
501
|
+
frequency: Schema.Literal("custom").annotations({
|
|
502
|
+
title: "Frequency"
|
|
503
|
+
}),
|
|
504
|
+
cronExpression: Schema.String.annotations({
|
|
505
|
+
title: "Cron expression",
|
|
506
|
+
description: "e.g. 0 9 * * MON-FRI"
|
|
507
|
+
})
|
|
508
|
+
});
|
|
509
|
+
var CronSpec = Schema.Union(MinutelySpec, HourlySpec, DailySpec, WeeklySpec, MonthlySpec, CustomSpec).annotations({
|
|
510
|
+
title: ""
|
|
511
|
+
});
|
|
512
|
+
var FrequencyDefaults = {
|
|
513
|
+
minutely: {
|
|
514
|
+
frequency: "minutely",
|
|
515
|
+
interval: 15
|
|
516
|
+
},
|
|
517
|
+
hourly: {
|
|
518
|
+
frequency: "hourly",
|
|
519
|
+
interval: 1,
|
|
520
|
+
minute: 0
|
|
521
|
+
},
|
|
522
|
+
daily: {
|
|
523
|
+
frequency: "daily",
|
|
524
|
+
hour: 9,
|
|
525
|
+
minute: 0
|
|
526
|
+
},
|
|
527
|
+
weekly: {
|
|
528
|
+
frequency: "weekly",
|
|
529
|
+
daysOfWeek: [
|
|
530
|
+
"mon"
|
|
531
|
+
],
|
|
532
|
+
hour: 9,
|
|
533
|
+
minute: 0
|
|
534
|
+
},
|
|
535
|
+
monthly: {
|
|
536
|
+
frequency: "monthly",
|
|
537
|
+
daysOfMonth: [
|
|
538
|
+
1
|
|
539
|
+
],
|
|
540
|
+
hour: 9,
|
|
541
|
+
minute: 0
|
|
542
|
+
},
|
|
543
|
+
custom: {
|
|
544
|
+
frequency: "custom",
|
|
545
|
+
cronExpression: "* * * * *"
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
// src/components/Schedule/Schedule.tsx
|
|
550
|
+
import React2, { createContext, forwardRef, useCallback as useCallback2, useContext, useState } from "react";
|
|
551
|
+
import { invariant } from "@dxos/invariant";
|
|
552
|
+
import { Input, ToggleGroup, ToggleGroupItem, composable, composableProps, useTranslation } from "@dxos/react-ui";
|
|
553
|
+
import { mx } from "@dxos/ui-theme";
|
|
554
|
+
import { meta } from "#meta";
|
|
555
|
+
var __dxlog_file = "/Users/jdw/Code/dxos/packages/plugins/plugin-routine/src/components/Schedule/Schedule.tsx";
|
|
556
|
+
var ScheduleKinds = [
|
|
557
|
+
// TODO(burdon): Once cannot be converted to a cron expression.
|
|
558
|
+
// 'once',
|
|
559
|
+
"hourly",
|
|
560
|
+
"daily",
|
|
561
|
+
"weekly",
|
|
562
|
+
"monthly",
|
|
563
|
+
"custom"
|
|
564
|
+
];
|
|
565
|
+
var isScheduleKind = (value) => ScheduleKinds.includes(value);
|
|
566
|
+
var Days = [
|
|
567
|
+
{
|
|
568
|
+
value: "mon",
|
|
569
|
+
label: "Mon"
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
value: "tue",
|
|
573
|
+
label: "Tue"
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
value: "wed",
|
|
577
|
+
label: "Wed"
|
|
578
|
+
},
|
|
579
|
+
{
|
|
580
|
+
value: "thu",
|
|
581
|
+
label: "Thu"
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
value: "fri",
|
|
585
|
+
label: "Fri"
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
value: "sat",
|
|
589
|
+
label: "Sat"
|
|
590
|
+
},
|
|
591
|
+
{
|
|
592
|
+
value: "sun",
|
|
593
|
+
label: "Sun"
|
|
594
|
+
}
|
|
595
|
+
];
|
|
596
|
+
var DEFAULT_TIME = "08:00";
|
|
597
|
+
var DEFAULT_MIN_INTERVAL_SECONDS = 60;
|
|
598
|
+
var normalizeMinInterval = (minInterval) => {
|
|
599
|
+
const finite = Number.isFinite(minInterval) ? minInterval : DEFAULT_MIN_INTERVAL_SECONDS;
|
|
600
|
+
return Math.min(MAX_MIN_INTERVAL_SECONDS, Math.max(DEFAULT_MIN_INTERVAL_SECONDS, Math.round(finite)));
|
|
601
|
+
};
|
|
602
|
+
var KIND_LABEL_KEYS = {
|
|
603
|
+
// once: 'schedule.kind.once.label',
|
|
604
|
+
hourly: "schedule.kind.hourly.label",
|
|
605
|
+
daily: "schedule.kind.daily.label",
|
|
606
|
+
weekly: "schedule.kind.weekly.label",
|
|
607
|
+
monthly: "schedule.kind.monthly.label",
|
|
608
|
+
custom: "schedule.kind.custom.label"
|
|
609
|
+
};
|
|
610
|
+
var DEFAULTS = {
|
|
611
|
+
// once: {
|
|
612
|
+
// kind: 'once',
|
|
613
|
+
// },
|
|
614
|
+
hourly: {
|
|
615
|
+
kind: "hourly",
|
|
616
|
+
minute: 0
|
|
617
|
+
},
|
|
618
|
+
daily: {
|
|
619
|
+
kind: "daily",
|
|
620
|
+
time: DEFAULT_TIME
|
|
621
|
+
},
|
|
622
|
+
weekly: {
|
|
623
|
+
kind: "weekly",
|
|
624
|
+
time: DEFAULT_TIME,
|
|
625
|
+
days: [
|
|
626
|
+
"mon"
|
|
627
|
+
]
|
|
628
|
+
},
|
|
629
|
+
monthly: {
|
|
630
|
+
kind: "monthly",
|
|
631
|
+
day: 1,
|
|
632
|
+
time: DEFAULT_TIME
|
|
633
|
+
},
|
|
634
|
+
custom: {
|
|
635
|
+
kind: "custom",
|
|
636
|
+
cron: "0 9 * * 1"
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
var pad2 = (value) => String(value).padStart(2, "0");
|
|
640
|
+
var switchKind = (current, kind) => {
|
|
641
|
+
const cron = scheduleToCron(current);
|
|
642
|
+
const spec = cron ? fromCron(cron) : void 0;
|
|
643
|
+
const [defaultHour, defaultMinute] = DEFAULT_TIME.split(":").map(Number);
|
|
644
|
+
const minute = spec && "minute" in spec ? spec.minute : defaultMinute;
|
|
645
|
+
const hour = spec && "hour" in spec ? spec.hour : defaultHour;
|
|
646
|
+
const time = `${pad2(hour)}:${pad2(minute)}`;
|
|
647
|
+
switch (kind) {
|
|
648
|
+
case "hourly":
|
|
649
|
+
return {
|
|
650
|
+
kind: "hourly",
|
|
651
|
+
minute
|
|
652
|
+
};
|
|
653
|
+
case "daily":
|
|
654
|
+
return {
|
|
655
|
+
kind: "daily",
|
|
656
|
+
time
|
|
657
|
+
};
|
|
658
|
+
case "weekly":
|
|
659
|
+
return {
|
|
660
|
+
kind: "weekly",
|
|
661
|
+
time,
|
|
662
|
+
days: spec?.frequency === "weekly" ? [
|
|
663
|
+
...spec.daysOfWeek
|
|
664
|
+
] : DEFAULTS.weekly.days
|
|
665
|
+
};
|
|
666
|
+
case "monthly":
|
|
667
|
+
return {
|
|
668
|
+
kind: "monthly",
|
|
669
|
+
time,
|
|
670
|
+
day: spec?.frequency === "monthly" ? spec.daysOfMonth[0] : DEFAULTS.monthly.day
|
|
671
|
+
};
|
|
672
|
+
case "custom":
|
|
673
|
+
return {
|
|
674
|
+
kind: "custom",
|
|
675
|
+
cron: cron ?? DEFAULTS.custom.cron
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
var ScheduleContext = /* @__PURE__ */ createContext(null);
|
|
680
|
+
var useScheduleContext = (consumer) => {
|
|
681
|
+
const context = useContext(ScheduleContext);
|
|
682
|
+
invariant(context, `${consumer} must be used within Schedule.Root`, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 146, S: void 0, A: ["context", "`${consumer} must be used within Schedule.Root`"] });
|
|
683
|
+
return context;
|
|
684
|
+
};
|
|
685
|
+
var ScheduleRoot = composable(({ children, value: valueProp, defaultValue, onValueChange, kinds = ScheduleKinds, minInterval: minIntervalProp = DEFAULT_MIN_INTERVAL_SECONDS, timezone, ...props }, forwardedRef) => {
|
|
686
|
+
const minInterval = normalizeMinInterval(minIntervalProp);
|
|
687
|
+
const [value, setValue] = useState(() => clampSchedule(valueProp ?? defaultValue ?? DEFAULTS.weekly, minInterval));
|
|
688
|
+
const handleValueChange = useCallback2((next) => {
|
|
689
|
+
const clamped = clampSchedule(next, minInterval);
|
|
690
|
+
setValue(clamped);
|
|
691
|
+
onValueChange?.(clamped);
|
|
692
|
+
}, [
|
|
693
|
+
onValueChange,
|
|
694
|
+
minInterval
|
|
695
|
+
]);
|
|
696
|
+
const allowedKinds = kinds.filter((kind) => kind === "custom" || scheduleIntervalSeconds(DEFAULTS[kind]) >= minInterval);
|
|
697
|
+
return /* @__PURE__ */ React2.createElement(ScheduleContext.Provider, {
|
|
698
|
+
value: {
|
|
699
|
+
value: clampSchedule(valueProp ?? value, minInterval),
|
|
700
|
+
onValueChange: handleValueChange,
|
|
701
|
+
kinds: allowedKinds,
|
|
702
|
+
minInterval,
|
|
703
|
+
timezone
|
|
704
|
+
}
|
|
705
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
706
|
+
...composableProps(props, {
|
|
707
|
+
classNames: "flex flex-col gap-y-3"
|
|
708
|
+
}),
|
|
709
|
+
ref: forwardedRef
|
|
710
|
+
}, children));
|
|
711
|
+
});
|
|
712
|
+
ScheduleRoot.displayName = "Schedule.Root";
|
|
713
|
+
var ScheduleHeader = /* @__PURE__ */ forwardRef(({ classNames }, forwardedRef) => {
|
|
714
|
+
const { t } = useTranslation(meta.profile.key);
|
|
715
|
+
const { value, timezone } = useScheduleContext("Schedule.Header");
|
|
716
|
+
return /* @__PURE__ */ React2.createElement("p", {
|
|
717
|
+
className: mx("grow truncate text-description", classNames)
|
|
718
|
+
}, describeSchedule(value, timezone));
|
|
719
|
+
});
|
|
720
|
+
ScheduleHeader.displayName = "Schedule.Header";
|
|
721
|
+
var ScheduleKindRow = /* @__PURE__ */ forwardRef(({ classNames }, forwardedRef) => {
|
|
722
|
+
const { t } = useTranslation(meta.profile.key);
|
|
723
|
+
const { value, onValueChange, kinds } = useScheduleContext("Schedule.Kind");
|
|
724
|
+
const handleKindChange = useCallback2((kind) => {
|
|
725
|
+
if (isScheduleKind(kind)) {
|
|
726
|
+
onValueChange(switchKind(value, kind));
|
|
727
|
+
}
|
|
728
|
+
}, [
|
|
729
|
+
value,
|
|
730
|
+
onValueChange
|
|
731
|
+
]);
|
|
732
|
+
return /* @__PURE__ */ React2.createElement(ToggleGroup, {
|
|
733
|
+
classNames: "overflow-x-auto scrollbar-none",
|
|
734
|
+
type: "single",
|
|
735
|
+
value: value.kind,
|
|
736
|
+
onValueChange: handleKindChange
|
|
737
|
+
}, kinds.map((kind) => /* @__PURE__ */ React2.createElement(ToggleGroupItem, {
|
|
738
|
+
key: kind,
|
|
739
|
+
value: kind
|
|
740
|
+
}, t(KIND_LABEL_KEYS[kind]))));
|
|
741
|
+
});
|
|
742
|
+
ScheduleKindRow.displayName = "Schedule.Kind";
|
|
743
|
+
var ScheduleBody = /* @__PURE__ */ forwardRef(({ classNames }, forwardedRef) => {
|
|
744
|
+
const { value, onValueChange } = useScheduleContext("Schedule.Body");
|
|
745
|
+
return /* @__PURE__ */ React2.createElement(ScheduleEditor, {
|
|
746
|
+
value,
|
|
747
|
+
onChange: onValueChange
|
|
748
|
+
});
|
|
749
|
+
});
|
|
750
|
+
ScheduleBody.displayName = "Schedule.Body";
|
|
751
|
+
var Schedule = {
|
|
752
|
+
Root: ScheduleRoot,
|
|
753
|
+
Header: ScheduleHeader,
|
|
754
|
+
Kind: ScheduleKindRow,
|
|
755
|
+
Body: ScheduleBody
|
|
756
|
+
};
|
|
757
|
+
var Field = ({ label, children, classNames }) => /* @__PURE__ */ React2.createElement("label", {
|
|
758
|
+
className: mx("flex items-center gap-2 shrink-0", classNames)
|
|
759
|
+
}, /* @__PURE__ */ React2.createElement("span", {
|
|
760
|
+
className: "text-sm"
|
|
761
|
+
}, label), children);
|
|
762
|
+
var ScheduleEditor = ({ value, onChange }) => {
|
|
763
|
+
const { t } = useTranslation(meta.profile.key);
|
|
764
|
+
switch (value.kind) {
|
|
765
|
+
// case 'once':
|
|
766
|
+
// `Input.Root` renders no DOM, so the trigger (column 1) and the field (center) become direct children
|
|
767
|
+
// of `Schedule.Body`'s row while still sharing the input context that wires the picker to the field.
|
|
768
|
+
// return (
|
|
769
|
+
// <Input.Root>
|
|
770
|
+
// <div>
|
|
771
|
+
// <Field label={t('schedule.at.label')}>
|
|
772
|
+
// <Input.DateTime
|
|
773
|
+
// classNames='min-w-0 overflow-hidden'
|
|
774
|
+
// hourCycle={12}
|
|
775
|
+
// value={value.date ?? ''}
|
|
776
|
+
// onValueChange={(date) => onChange({ kind: 'once', date: date || undefined })}
|
|
777
|
+
// />
|
|
778
|
+
// <Input.TriggerIcon />
|
|
779
|
+
// </Field>
|
|
780
|
+
// </div>
|
|
781
|
+
// </Input.Root>
|
|
782
|
+
// );
|
|
783
|
+
case "hourly":
|
|
784
|
+
return /* @__PURE__ */ React2.createElement(Field, {
|
|
785
|
+
label: t("schedule.minute.label")
|
|
786
|
+
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
787
|
+
type: "number",
|
|
788
|
+
min: 0,
|
|
789
|
+
max: 59,
|
|
790
|
+
step: 1,
|
|
791
|
+
classNames: "w-15",
|
|
792
|
+
value: String(value.minute),
|
|
793
|
+
onChange: (event) => {
|
|
794
|
+
const minute = Math.min(59, Math.max(0, Math.round(Number(event.target.value) || 0)));
|
|
795
|
+
onChange({
|
|
796
|
+
kind: "hourly",
|
|
797
|
+
minute
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
})));
|
|
801
|
+
case "daily":
|
|
802
|
+
return /* @__PURE__ */ React2.createElement(Field, {
|
|
803
|
+
label: t("schedule.at.label")
|
|
804
|
+
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Time, {
|
|
805
|
+
hourCycle: 12,
|
|
806
|
+
value: value.time,
|
|
807
|
+
onValueChange: (time) => onChange({
|
|
808
|
+
kind: "daily",
|
|
809
|
+
time
|
|
810
|
+
})
|
|
811
|
+
})));
|
|
812
|
+
case "weekly":
|
|
813
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
814
|
+
className: "@container dx-inline-size-container min-w-0 flex justify-between items-center gap-2 overflow-x-auto scrollbar-none"
|
|
815
|
+
}, /* @__PURE__ */ React2.createElement(Field, {
|
|
816
|
+
label: t("schedule.at.label")
|
|
817
|
+
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Time, {
|
|
818
|
+
hourCycle: 12,
|
|
819
|
+
value: value.time,
|
|
820
|
+
onValueChange: (time) => onChange({
|
|
821
|
+
...value,
|
|
822
|
+
time
|
|
823
|
+
})
|
|
824
|
+
}))), /* @__PURE__ */ React2.createElement("div", {
|
|
825
|
+
className: "flex shrink-0 items-center gap-2"
|
|
826
|
+
}, /* @__PURE__ */ React2.createElement("span", {
|
|
827
|
+
className: "shrink-0 text-sm"
|
|
828
|
+
}, t("schedule.on.label")), /* @__PURE__ */ React2.createElement("div", {
|
|
829
|
+
className: "grid w-max shrink-0 grid-cols-7 gap-x-2"
|
|
830
|
+
}, Days.map(({ value: day, label }) => {
|
|
831
|
+
const checked = value.days.includes(day);
|
|
832
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
833
|
+
key: day,
|
|
834
|
+
className: "flex shrink-0 items-center gap-1"
|
|
835
|
+
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Checkbox, {
|
|
836
|
+
checked,
|
|
837
|
+
onCheckedChange: (next) => {
|
|
838
|
+
const nextDays = next ? Days.map((d) => d.value).filter((d) => d === day || value.days.includes(d)) : value.days.filter((d) => d !== day);
|
|
839
|
+
onChange({
|
|
840
|
+
...value,
|
|
841
|
+
days: nextDays.length > 0 ? nextDays : value.days
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
}), /* @__PURE__ */ React2.createElement(Input.Label, {
|
|
845
|
+
classNames: "hidden @min-[32rem]:inline-block text-xs uppercase"
|
|
846
|
+
}, label), /* @__PURE__ */ React2.createElement(Input.Label, {
|
|
847
|
+
classNames: "inline-block @min-[32rem]:hidden text-xs"
|
|
848
|
+
}, label.charAt(0))));
|
|
849
|
+
}))));
|
|
850
|
+
case "monthly":
|
|
851
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
852
|
+
className: "flex items-center gap-3"
|
|
853
|
+
}, /* @__PURE__ */ React2.createElement(Field, {
|
|
854
|
+
label: t("schedule.day.label")
|
|
855
|
+
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
856
|
+
type: "number",
|
|
857
|
+
min: 1,
|
|
858
|
+
max: 31,
|
|
859
|
+
step: 1,
|
|
860
|
+
classNames: "w-15",
|
|
861
|
+
value: String(value.day),
|
|
862
|
+
onChange: (event) => {
|
|
863
|
+
const day = Math.min(31, Math.max(1, Math.round(Number(event.target.value) || 1)));
|
|
864
|
+
onChange({
|
|
865
|
+
...value,
|
|
866
|
+
day
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
}))), /* @__PURE__ */ React2.createElement(Field, {
|
|
870
|
+
label: t("schedule.at.label")
|
|
871
|
+
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.Time, {
|
|
872
|
+
hourCycle: 12,
|
|
873
|
+
value: value.time,
|
|
874
|
+
onValueChange: (time) => onChange({
|
|
875
|
+
...value,
|
|
876
|
+
time
|
|
877
|
+
})
|
|
878
|
+
}))));
|
|
879
|
+
case "custom":
|
|
880
|
+
return /* @__PURE__ */ React2.createElement(Field, {
|
|
881
|
+
label: t("schedule.cron.label")
|
|
882
|
+
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
883
|
+
classNames: "w-50 tabular-nums",
|
|
884
|
+
placeholder: "0 9 * * MON-FRI",
|
|
885
|
+
value: value.cron,
|
|
886
|
+
onChange: (event) => onChange({
|
|
887
|
+
kind: "custom",
|
|
888
|
+
cron: event.target.value
|
|
889
|
+
})
|
|
890
|
+
})));
|
|
891
|
+
}
|
|
892
|
+
};
|
|
893
|
+
var DAY_NAMES = {
|
|
894
|
+
mon: "Monday",
|
|
895
|
+
tue: "Tuesday",
|
|
896
|
+
wed: "Wednesday",
|
|
897
|
+
thu: "Thursday",
|
|
898
|
+
fri: "Friday",
|
|
899
|
+
sat: "Saturday",
|
|
900
|
+
sun: "Sunday"
|
|
901
|
+
};
|
|
902
|
+
var formatTime = (time) => {
|
|
903
|
+
const [h, m] = time.split(":").map(Number);
|
|
904
|
+
if (Number.isNaN(h) || Number.isNaN(m)) {
|
|
905
|
+
return time;
|
|
906
|
+
}
|
|
907
|
+
const period = h < 12 ? "AM" : "PM";
|
|
908
|
+
const hour = h % 12 === 0 ? 12 : h % 12;
|
|
909
|
+
return `${hour}:${String(m).padStart(2, "0")} ${period}`;
|
|
910
|
+
};
|
|
911
|
+
var withZone = (text, timezone) => timezone ? `${text} ${timezone}` : text;
|
|
912
|
+
var describeSchedule = (value, timezone) => {
|
|
913
|
+
switch (value.kind) {
|
|
914
|
+
// case 'once':
|
|
915
|
+
// return value.date
|
|
916
|
+
// ? `Runs once at ${formatTime(value.date.slice(11))} on ${value.date.slice(0, 10)}`
|
|
917
|
+
// : 'Runs once';
|
|
918
|
+
case "hourly":
|
|
919
|
+
return `Runs every hour at minute ${value.minute}`;
|
|
920
|
+
case "daily":
|
|
921
|
+
return withZone(`Runs every day at ${formatTime(value.time)}`, timezone);
|
|
922
|
+
case "weekly": {
|
|
923
|
+
const days = value.days.length === 0 ? "no days" : value.days.length === 1 ? DAY_NAMES[value.days[0]] : Days.filter((d) => value.days.includes(d.value)).map((d) => d.label).join(", ");
|
|
924
|
+
return withZone(`Runs every ${days} at ${formatTime(value.time)}`, timezone);
|
|
925
|
+
}
|
|
926
|
+
case "monthly":
|
|
927
|
+
return withZone(`Runs monthly on day ${value.day} at ${formatTime(value.time)}`, timezone);
|
|
928
|
+
case "custom":
|
|
929
|
+
return withZone(describeCron(value.cron), timezone);
|
|
930
|
+
}
|
|
931
|
+
};
|
|
932
|
+
|
|
933
|
+
// src/components/TriggerEditor/TriggerKindSelector.tsx
|
|
934
|
+
import React3, { useCallback as useCallback3 } from "react";
|
|
935
|
+
import { Icon, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
936
|
+
import { Listbox } from "@dxos/react-ui-list";
|
|
937
|
+
import { meta as meta2 } from "#meta";
|
|
938
|
+
var OPTIONS = [
|
|
939
|
+
{
|
|
940
|
+
kind: "timer",
|
|
941
|
+
icon: "ph--clock-countdown--regular"
|
|
942
|
+
},
|
|
943
|
+
{
|
|
944
|
+
kind: "feed",
|
|
945
|
+
icon: "ph--cards-three--regular"
|
|
946
|
+
},
|
|
947
|
+
{
|
|
948
|
+
kind: "subscription",
|
|
949
|
+
icon: "ph--funnel--regular"
|
|
950
|
+
},
|
|
951
|
+
{
|
|
952
|
+
kind: "webhook",
|
|
953
|
+
icon: "ph--webhooks-logo--regular",
|
|
954
|
+
disabled: true
|
|
955
|
+
},
|
|
956
|
+
{
|
|
957
|
+
kind: "email",
|
|
958
|
+
icon: "ph--envelope--regular",
|
|
959
|
+
disabled: true
|
|
960
|
+
}
|
|
961
|
+
];
|
|
962
|
+
var TriggerKindSelector = ({ onChange }) => {
|
|
963
|
+
const { t } = useTranslation2(meta2.profile.key);
|
|
964
|
+
const handleValueChange = useCallback3((id) => {
|
|
965
|
+
const option = OPTIONS.find((option2) => option2.kind === id);
|
|
966
|
+
if (option) {
|
|
967
|
+
onChange(option.kind);
|
|
968
|
+
}
|
|
969
|
+
}, [
|
|
970
|
+
onChange
|
|
971
|
+
]);
|
|
972
|
+
return /* @__PURE__ */ React3.createElement(Listbox.Root, {
|
|
973
|
+
onValueChange: handleValueChange
|
|
974
|
+
}, /* @__PURE__ */ React3.createElement(Listbox.Content, {
|
|
975
|
+
classNames: "gap-1",
|
|
976
|
+
"aria-label": t("trigger-kind.placeholder")
|
|
977
|
+
}, OPTIONS.map(({ kind, icon, disabled }) => /* @__PURE__ */ React3.createElement(Listbox.Item, {
|
|
978
|
+
key: kind,
|
|
979
|
+
id: kind,
|
|
980
|
+
disabled,
|
|
981
|
+
classNames: "bg-input-surface rounded-sm"
|
|
982
|
+
}, /* @__PURE__ */ React3.createElement(Listbox.ItemContent, {
|
|
983
|
+
icon: /* @__PURE__ */ React3.createElement(Icon, {
|
|
984
|
+
icon,
|
|
985
|
+
size: 5,
|
|
986
|
+
classNames: "text-description"
|
|
987
|
+
}),
|
|
988
|
+
title: /* @__PURE__ */ React3.createElement("span", {
|
|
989
|
+
className: "font-medium"
|
|
990
|
+
}, t(`trigger-kind.${kind}.label`)),
|
|
991
|
+
description: t(`trigger-kind.${kind}.description`)
|
|
992
|
+
})))));
|
|
993
|
+
};
|
|
994
|
+
|
|
995
|
+
// src/components/TriggerEditor/TriggerEditor.tsx
|
|
996
|
+
var RECURRING_KINDS = [
|
|
997
|
+
"hourly",
|
|
998
|
+
"daily",
|
|
999
|
+
"weekly",
|
|
1000
|
+
"monthly",
|
|
1001
|
+
"custom"
|
|
1002
|
+
];
|
|
1003
|
+
var EnabledForm = Type2.getSchema(Trigger.Trigger).pipe(Schema2.pick("enabled"));
|
|
1004
|
+
var TimerSpecForm = Schema2.extend(Schema2.Struct({
|
|
1005
|
+
kind: Schema2.Literal("timer"),
|
|
1006
|
+
cron: Schema2.String.pipe(Schema2.annotations({
|
|
1007
|
+
title: "Schedule (cron)"
|
|
1008
|
+
}), Schema2.optional)
|
|
1009
|
+
}), EnabledForm);
|
|
1010
|
+
var SubscriptionSpecForm = Schema2.extend(Schema2.Struct({
|
|
1011
|
+
kind: Schema2.Literal("subscription"),
|
|
1012
|
+
// The object type to watch; converted to a `Filter.type` query. `typename` renders via a custom select of
|
|
1013
|
+
// the space/registry types (see `TypeSelectField`); `deep`/`delay` map to the subscription's options.
|
|
1014
|
+
typename: Schema2.String.pipe(Schema2.annotations({
|
|
1015
|
+
title: "Type"
|
|
1016
|
+
}), Schema2.optional),
|
|
1017
|
+
deep: Schema2.Boolean.pipe(Schema2.annotations({
|
|
1018
|
+
title: "Nested"
|
|
1019
|
+
}), Schema2.optional),
|
|
1020
|
+
delay: Schema2.Number.pipe(Schema2.annotations({
|
|
1021
|
+
title: "Delay (ms)"
|
|
1022
|
+
}), Schema2.optional)
|
|
1023
|
+
}), EnabledForm);
|
|
1024
|
+
var WebhookSpecForm = Schema2.extend(Schema2.Struct({
|
|
1025
|
+
kind: Schema2.Literal("webhook"),
|
|
1026
|
+
method: Schema2.String.pipe(Schema2.annotations({
|
|
1027
|
+
title: "Method"
|
|
1028
|
+
}), Schema2.optional),
|
|
1029
|
+
port: Schema2.Number.pipe(Schema2.annotations({
|
|
1030
|
+
title: "Port"
|
|
1031
|
+
}), Schema2.optional)
|
|
1032
|
+
}), EnabledForm);
|
|
1033
|
+
var FeedSpecForm = Schema2.extend(Schema2.Struct({
|
|
1034
|
+
kind: Schema2.Literal("feed"),
|
|
1035
|
+
feed: Ref.Ref(Feed.Feed).pipe(ParentLabelAnnotation.set(true), Schema2.annotations({
|
|
1036
|
+
title: "Feed"
|
|
1037
|
+
}), Schema2.optional)
|
|
1038
|
+
}), EnabledForm);
|
|
1039
|
+
var EmailSpecForm = Schema2.extend(Schema2.Struct({
|
|
1040
|
+
kind: Schema2.Literal("email")
|
|
1041
|
+
}), EnabledForm);
|
|
1042
|
+
var TriggerForm = Schema2.Union(TimerSpecForm, SubscriptionSpecForm, WebhookSpecForm, FeedSpecForm, EmailSpecForm);
|
|
1043
|
+
var triggerFormValues = (spec) => {
|
|
1044
|
+
switch (spec?.kind) {
|
|
1045
|
+
case "subscription":
|
|
1046
|
+
return {
|
|
1047
|
+
kind: "subscription",
|
|
1048
|
+
typename: spec.query?.raw,
|
|
1049
|
+
deep: spec.options?.deep,
|
|
1050
|
+
delay: spec.options?.delay
|
|
1051
|
+
};
|
|
1052
|
+
case "feed":
|
|
1053
|
+
return {
|
|
1054
|
+
kind: "feed",
|
|
1055
|
+
feed: spec.feed
|
|
1056
|
+
};
|
|
1057
|
+
case "webhook":
|
|
1058
|
+
return {
|
|
1059
|
+
kind: "webhook",
|
|
1060
|
+
method: spec.method,
|
|
1061
|
+
port: spec.port
|
|
1062
|
+
};
|
|
1063
|
+
case "email":
|
|
1064
|
+
return {
|
|
1065
|
+
kind: "email"
|
|
1066
|
+
};
|
|
1067
|
+
case "timer":
|
|
1068
|
+
return {
|
|
1069
|
+
kind: "timer",
|
|
1070
|
+
cron: spec.cron
|
|
1071
|
+
};
|
|
1072
|
+
default:
|
|
1073
|
+
return {};
|
|
1074
|
+
}
|
|
1075
|
+
};
|
|
1076
|
+
var DEFAULT_TIMER_CRON = toCron(FrequencyDefaults.daily);
|
|
1077
|
+
var subscriptionQuery = (typename) => typename ? Query.select(Filter.type(DXN.make(typename))) : Query.select(Filter.everything());
|
|
1078
|
+
var triggerFormSpec = (values) => {
|
|
1079
|
+
switch (values.kind) {
|
|
1080
|
+
case "subscription": {
|
|
1081
|
+
const hasOptions = values.deep != null || values.delay != null;
|
|
1082
|
+
return {
|
|
1083
|
+
kind: "subscription",
|
|
1084
|
+
// Carry the typename in `raw` so the editor can recover the Type selection on reopen.
|
|
1085
|
+
query: {
|
|
1086
|
+
raw: values.typename,
|
|
1087
|
+
ast: subscriptionQuery(values.typename).ast
|
|
1088
|
+
},
|
|
1089
|
+
options: hasOptions ? {
|
|
1090
|
+
deep: values.deep,
|
|
1091
|
+
delay: values.delay
|
|
1092
|
+
} : void 0
|
|
1093
|
+
};
|
|
1094
|
+
}
|
|
1095
|
+
case "feed":
|
|
1096
|
+
return {
|
|
1097
|
+
kind: "feed",
|
|
1098
|
+
feed: values.feed
|
|
1099
|
+
};
|
|
1100
|
+
case "webhook":
|
|
1101
|
+
return Trigger.specWebhook({
|
|
1102
|
+
method: values.method,
|
|
1103
|
+
port: values.port
|
|
1104
|
+
});
|
|
1105
|
+
case "email":
|
|
1106
|
+
return Trigger.specEmail();
|
|
1107
|
+
case "timer":
|
|
1108
|
+
default:
|
|
1109
|
+
return Trigger.specTimer(values.cron || DEFAULT_TIMER_CRON);
|
|
1110
|
+
}
|
|
1111
|
+
};
|
|
1112
|
+
var TriggerEditor = ({ classNames, db, routine, trigger, readonly }) => {
|
|
1113
|
+
const { t } = useTranslation3(meta3.profile.key);
|
|
1114
|
+
const { defaultValues, fieldMap, kind, resetNonce, handleClose, handleValuesChanged } = useTriggerForm(routine, trigger);
|
|
1115
|
+
return /* @__PURE__ */ React4.createElement(Form2.Root, {
|
|
1116
|
+
// Remount when the bound trigger changes (picks up its spec) or on reset (reverts to the picker).
|
|
1117
|
+
key: `${trigger?.id ?? "new"}:${resetNonce}`,
|
|
1118
|
+
schema: TriggerForm,
|
|
1119
|
+
db,
|
|
1120
|
+
readonly,
|
|
1121
|
+
fieldMap,
|
|
1122
|
+
defaultValues,
|
|
1123
|
+
onValuesChanged: handleValuesChanged
|
|
1124
|
+
}, /* @__PURE__ */ React4.createElement(Form2.Content, {
|
|
1125
|
+
classNames: mx2(kind && "pb-2 bg-card-surface border border-separator rounded-xs", classNames)
|
|
1126
|
+
}, kind && /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("div", {
|
|
1127
|
+
className: "flex items-center"
|
|
1128
|
+
}, /* @__PURE__ */ React4.createElement(Input2.Root, null, /* @__PURE__ */ React4.createElement(Input2.Label, {
|
|
1129
|
+
classNames: "pl-2 grow truncate"
|
|
1130
|
+
}, t(`trigger-kind.${kind}.label`))), !readonly && /* @__PURE__ */ React4.createElement(IconButton, {
|
|
1131
|
+
iconOnly: true,
|
|
1132
|
+
variant: "ghost",
|
|
1133
|
+
square: true,
|
|
1134
|
+
icon: "ph--x--regular",
|
|
1135
|
+
label: t("trigger-kind.clear.label"),
|
|
1136
|
+
onClick: handleClose
|
|
1137
|
+
})), /* @__PURE__ */ React4.createElement(Form2.FieldSet, {
|
|
1138
|
+
classNames: "px-2"
|
|
1139
|
+
})) || /* @__PURE__ */ React4.createElement(Form2.FieldSet, null), kind === "email" && /* @__PURE__ */ React4.createElement("p", {
|
|
1140
|
+
className: "px-2 text-sm text-description"
|
|
1141
|
+
}, t("trigger-kind.email-note.message"))));
|
|
1142
|
+
};
|
|
1143
|
+
var TypeSelectField = (props) => {
|
|
1144
|
+
const types = useQuery(props.db, Query.select(Filter.type(Type2.Type)).from(Scope.space(), Scope.registry()));
|
|
1145
|
+
const options = useMemo2(() => types.filter((type) => !Type2.isTypeKind(type)).map((type) => Type2.getTypename(type)).filter((typename) => !!typename).map((typename) => ({
|
|
1146
|
+
value: typename,
|
|
1147
|
+
label: typename
|
|
1148
|
+
})), [
|
|
1149
|
+
types
|
|
1150
|
+
]);
|
|
1151
|
+
return /* @__PURE__ */ React4.createElement(SelectField, {
|
|
1152
|
+
...props,
|
|
1153
|
+
options
|
|
1154
|
+
});
|
|
1155
|
+
};
|
|
1156
|
+
TypeSelectField.displayName = "TriggerEditor.TypeSelectField";
|
|
1157
|
+
var CronField = (props) => {
|
|
1158
|
+
const cron = props.getValue() || DEFAULT_TIMER_CRON;
|
|
1159
|
+
const initial = useMemo2(() => cronToSchedule(cron), []);
|
|
1160
|
+
const handleChange = useCallback4((value) => {
|
|
1161
|
+
const next = scheduleToCron(value);
|
|
1162
|
+
if (next) {
|
|
1163
|
+
props.onValueChange(props.type, next);
|
|
1164
|
+
}
|
|
1165
|
+
}, [
|
|
1166
|
+
props.type,
|
|
1167
|
+
props.onValueChange
|
|
1168
|
+
]);
|
|
1169
|
+
return /* @__PURE__ */ React4.createElement(Schedule.Root, {
|
|
1170
|
+
kinds: RECURRING_KINDS,
|
|
1171
|
+
defaultValue: initial,
|
|
1172
|
+
onValueChange: handleChange
|
|
1173
|
+
}, /* @__PURE__ */ React4.createElement(Schedule.Header, null), /* @__PURE__ */ React4.createElement(Schedule.Kind, null), /* @__PURE__ */ React4.createElement(Schedule.Body, null));
|
|
1174
|
+
};
|
|
1175
|
+
CronField.displayName = "TriggerEditor.CronField";
|
|
1176
|
+
var useTriggerForm = (routine, trigger) => {
|
|
1177
|
+
const methodOptions = useMemo2(() => [
|
|
1178
|
+
{
|
|
1179
|
+
value: "GET",
|
|
1180
|
+
label: "GET"
|
|
1181
|
+
},
|
|
1182
|
+
{
|
|
1183
|
+
value: "POST",
|
|
1184
|
+
label: "POST"
|
|
1185
|
+
}
|
|
1186
|
+
], []);
|
|
1187
|
+
const fieldMap = useMemo2(() => ({
|
|
1188
|
+
// Show the variant picker only until a kind is chosen; once selected the row is replaced by that
|
|
1189
|
+
// variant's editor (the kind field renders nothing).
|
|
1190
|
+
kind: (props) => props.getValue() ? null : /* @__PURE__ */ React4.createElement(TriggerKindSelector, {
|
|
1191
|
+
onChange: (next) => props.onValueChange(props.type, next)
|
|
1192
|
+
}),
|
|
1193
|
+
cron: (props) => /* @__PURE__ */ React4.createElement(CronField, props),
|
|
1194
|
+
method: (props) => /* @__PURE__ */ React4.createElement(SelectField, {
|
|
1195
|
+
...props,
|
|
1196
|
+
options: methodOptions
|
|
1197
|
+
}),
|
|
1198
|
+
typename: (props) => /* @__PURE__ */ React4.createElement(TypeSelectField, props)
|
|
1199
|
+
}), [
|
|
1200
|
+
methodOptions
|
|
1201
|
+
]);
|
|
1202
|
+
const [resetNonce, setResetNonce] = useState2(0);
|
|
1203
|
+
const defaultValues = useMemo2(() => ({
|
|
1204
|
+
...triggerFormValues(trigger?.spec),
|
|
1205
|
+
enabled: trigger?.enabled
|
|
1206
|
+
}), [
|
|
1207
|
+
trigger,
|
|
1208
|
+
resetNonce
|
|
1209
|
+
]);
|
|
1210
|
+
const [kind, setKind] = useState2(() => triggerFormValues(trigger?.spec).kind);
|
|
1211
|
+
const handleClose = useCallback4(() => {
|
|
1212
|
+
setKind(void 0);
|
|
1213
|
+
setResetNonce((nonce) => nonce + 1);
|
|
1214
|
+
if (trigger) {
|
|
1215
|
+
Obj2.update(trigger, (trigger2) => {
|
|
1216
|
+
trigger2.spec = void 0;
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1219
|
+
}, [
|
|
1220
|
+
trigger
|
|
1221
|
+
]);
|
|
1222
|
+
const handleValuesChanged = useCallback4((values) => {
|
|
1223
|
+
if (!values.kind) {
|
|
1224
|
+
return;
|
|
1225
|
+
}
|
|
1226
|
+
const spec = triggerFormSpec(values);
|
|
1227
|
+
setKind(spec.kind);
|
|
1228
|
+
const enabled = values.enabled === true;
|
|
1229
|
+
if (trigger) {
|
|
1230
|
+
Obj2.update(trigger, (trigger2) => {
|
|
1231
|
+
trigger2.spec = spec;
|
|
1232
|
+
trigger2.enabled = enabled;
|
|
1233
|
+
});
|
|
1234
|
+
} else {
|
|
1235
|
+
const created = Trigger.make({
|
|
1236
|
+
spec,
|
|
1237
|
+
enabled
|
|
1238
|
+
});
|
|
1239
|
+
Obj2.setParent(created, routine);
|
|
1240
|
+
Obj2.update(routine, (routine2) => {
|
|
1241
|
+
routine2.triggers.push(Ref.make(created));
|
|
1242
|
+
});
|
|
1243
|
+
Routine.wireTriggers(routine);
|
|
1244
|
+
}
|
|
1245
|
+
}, [
|
|
1246
|
+
routine,
|
|
1247
|
+
trigger
|
|
1248
|
+
]);
|
|
1249
|
+
return {
|
|
1250
|
+
defaultValues,
|
|
1251
|
+
fieldMap,
|
|
1252
|
+
kind,
|
|
1253
|
+
resetNonce,
|
|
1254
|
+
handleClose,
|
|
1255
|
+
handleValuesChanged
|
|
1256
|
+
};
|
|
1257
|
+
};
|
|
1258
|
+
|
|
1259
|
+
// src/components/RoutineForm/RoutineForm.tsx
|
|
1260
|
+
var GeneralForm = Type3.getSchema(Routine2.Routine).pipe(Schema3.pick("name", "description"));
|
|
1261
|
+
var RoutineForm = ({ db, routine, readonly = false, onSave, onCancel }) => {
|
|
1262
|
+
const { t } = useTranslation4(meta4.profile.key);
|
|
1263
|
+
const [auto, updateAuto] = useObject(routine);
|
|
1264
|
+
const trigger = usePrimaryTrigger(routine);
|
|
1265
|
+
const defaultValues = useMemo3(() => ({
|
|
1266
|
+
name: auto.name,
|
|
1267
|
+
description: auto.description
|
|
1268
|
+
}), [
|
|
1269
|
+
routine
|
|
1270
|
+
]);
|
|
1271
|
+
const handleValuesChanged = useCallback5((values) => {
|
|
1272
|
+
updateAuto((routine2) => {
|
|
1273
|
+
routine2.name = values.name;
|
|
1274
|
+
routine2.description = values.description;
|
|
1275
|
+
});
|
|
1276
|
+
}, [
|
|
1277
|
+
updateAuto
|
|
1278
|
+
]);
|
|
1279
|
+
return /* @__PURE__ */ React5.createElement(Form3.Root, {
|
|
1280
|
+
schema: GeneralForm,
|
|
1281
|
+
readonly,
|
|
1282
|
+
defaultValues,
|
|
1283
|
+
onValuesChanged: handleValuesChanged,
|
|
1284
|
+
onSave,
|
|
1285
|
+
onCancel
|
|
1286
|
+
}, /* @__PURE__ */ React5.createElement(Form3.Viewport, {
|
|
1287
|
+
scroll: true
|
|
1288
|
+
}, /* @__PURE__ */ React5.createElement(Form3.Content, null, /* @__PURE__ */ React5.createElement(Form3.FieldSet, null), /* @__PURE__ */ React5.createElement(Section, {
|
|
1289
|
+
title: t("actions.title")
|
|
1290
|
+
}, /* @__PURE__ */ React5.createElement(ActionEditor, {
|
|
1291
|
+
db,
|
|
1292
|
+
routine,
|
|
1293
|
+
readonly
|
|
1294
|
+
})), /* @__PURE__ */ React5.createElement(Section, {
|
|
1295
|
+
title: t("triggers.title")
|
|
1296
|
+
}, /* @__PURE__ */ React5.createElement(TriggerEditor, {
|
|
1297
|
+
db,
|
|
1298
|
+
routine,
|
|
1299
|
+
trigger,
|
|
1300
|
+
readonly
|
|
1301
|
+
})), onSave && /* @__PURE__ */ React5.createElement(Form3.Actions, null))));
|
|
1302
|
+
};
|
|
1303
|
+
var Section = ({ title, children }) => /* @__PURE__ */ React5.createElement("div", {
|
|
1304
|
+
role: "none",
|
|
1305
|
+
className: "flex flex-col mbs-4"
|
|
1306
|
+
}, /* @__PURE__ */ React5.createElement(Form3.Label, {
|
|
1307
|
+
standalone: true,
|
|
1308
|
+
label: title
|
|
1309
|
+
}), children);
|
|
1310
|
+
var ActionEditor = ({ db, routine: routineProp, readonly }) => {
|
|
1311
|
+
const operations = useOperations(db);
|
|
1312
|
+
const [routine, updateRoutine] = useObject(routineProp);
|
|
1313
|
+
const kind = routine.spec?.kind ?? "runnable";
|
|
1314
|
+
const operationRef = Routine2.runnableRef(routine);
|
|
1315
|
+
const instructions = Routine2.instructionsRef(routine)?.target;
|
|
1316
|
+
const handleOperationChange = useCallback5((operation) => {
|
|
1317
|
+
updateRoutine((routine2) => {
|
|
1318
|
+
routine2.spec = operation ? {
|
|
1319
|
+
kind: "runnable",
|
|
1320
|
+
runnable: operation
|
|
1321
|
+
} : void 0;
|
|
1322
|
+
});
|
|
1323
|
+
Routine2.wireTriggers(routineProp);
|
|
1324
|
+
}, [
|
|
1325
|
+
updateRoutine,
|
|
1326
|
+
routineProp
|
|
1327
|
+
]);
|
|
1328
|
+
const handleKindChange = useCallback5((next) => {
|
|
1329
|
+
updateRoutine((routine2) => {
|
|
1330
|
+
if (next === "runnable") {
|
|
1331
|
+
routine2.spec = void 0;
|
|
1332
|
+
} else if (routine2.spec?.kind !== "instructions") {
|
|
1333
|
+
const instructions2 = Instructions2.make({});
|
|
1334
|
+
Obj3.setParent(instructions2, routine2);
|
|
1335
|
+
routine2.spec = {
|
|
1336
|
+
kind: "instructions",
|
|
1337
|
+
instructions: Ref2.make(instructions2)
|
|
1338
|
+
};
|
|
1339
|
+
}
|
|
1340
|
+
});
|
|
1341
|
+
Routine2.wireTriggers(routineProp);
|
|
1342
|
+
}, [
|
|
1343
|
+
updateRoutine,
|
|
1344
|
+
routineProp
|
|
1345
|
+
]);
|
|
1346
|
+
return /* @__PURE__ */ React5.createElement("div", {
|
|
1347
|
+
role: "none",
|
|
1348
|
+
className: "flex flex-col"
|
|
1349
|
+
}, !readonly && /* @__PURE__ */ React5.createElement(ActionKindToggle, {
|
|
1350
|
+
value: kind,
|
|
1351
|
+
onChange: handleKindChange
|
|
1352
|
+
}), kind === "runnable" ? /* @__PURE__ */ React5.createElement(OperationEditor, {
|
|
1353
|
+
db,
|
|
1354
|
+
operations,
|
|
1355
|
+
operation: operationRef,
|
|
1356
|
+
onChange: handleOperationChange,
|
|
1357
|
+
readonly
|
|
1358
|
+
}) : instructions ? /* @__PURE__ */ React5.createElement(InstructionsEditor, {
|
|
1359
|
+
db,
|
|
1360
|
+
instructions,
|
|
1361
|
+
readonly
|
|
1362
|
+
}) : null);
|
|
1363
|
+
};
|
|
1364
|
+
var ActionKindToggle = ({ value, onChange }) => {
|
|
1365
|
+
const { t } = useTranslation4(meta4.profile.key);
|
|
1366
|
+
return (
|
|
1367
|
+
// `type='single'` emits `''` when the selected item is clicked again (toggled off); ignore that and any
|
|
1368
|
+
// other non-kind value so it can't fall through and overwrite the current action.
|
|
1369
|
+
/* @__PURE__ */ React5.createElement(ToggleGroup2, {
|
|
1370
|
+
type: "single",
|
|
1371
|
+
value,
|
|
1372
|
+
onValueChange: (next) => {
|
|
1373
|
+
if (next === "instructions" || next === "runnable") {
|
|
1374
|
+
onChange(next);
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
}, /* @__PURE__ */ React5.createElement(ToggleGroupItem2, {
|
|
1378
|
+
value: "instructions"
|
|
1379
|
+
}, t("action-kind.instructions.label")), /* @__PURE__ */ React5.createElement(ToggleGroupItem2, {
|
|
1380
|
+
value: "runnable"
|
|
1381
|
+
}, t("action-kind.operation.label")))
|
|
1382
|
+
);
|
|
1383
|
+
};
|
|
1384
|
+
var OperationActionForm = Schema3.Struct({
|
|
1385
|
+
operation: Ref2.Ref(Operation.PersistentOperation).pipe(Schema3.annotations({
|
|
1386
|
+
title: "Operation"
|
|
1387
|
+
}), Schema3.optional)
|
|
1388
|
+
});
|
|
1389
|
+
var getOperationOptions = (results) => results.filter((operation) => !Obj3.instanceOf(Operation.PersistentOperation, operation) || Operation.isVisible(operation)).map((operation) => {
|
|
1390
|
+
const id = Entity2.getURI(operation, {
|
|
1391
|
+
prefer: "named"
|
|
1392
|
+
});
|
|
1393
|
+
const name = Entity2.getLabel(operation) ?? id;
|
|
1394
|
+
const key = Obj3.instanceOf(Operation.PersistentOperation, operation) ? Operation.getKey(operation) : void 0;
|
|
1395
|
+
return {
|
|
1396
|
+
id,
|
|
1397
|
+
label: name,
|
|
1398
|
+
description: key
|
|
1399
|
+
};
|
|
1400
|
+
}).sort((left, right) => left.label.localeCompare(right.label));
|
|
1401
|
+
var OperationEditor = ({ db, operations, operation, onChange, readonly }) => {
|
|
1402
|
+
const fieldMap = useMemo3(() => ({
|
|
1403
|
+
operation: (props) => /* @__PURE__ */ React5.createElement(RefField, {
|
|
1404
|
+
...props,
|
|
1405
|
+
db,
|
|
1406
|
+
useResults: () => operations,
|
|
1407
|
+
getOptions: getOperationOptions
|
|
1408
|
+
})
|
|
1409
|
+
}), [
|
|
1410
|
+
db,
|
|
1411
|
+
operations
|
|
1412
|
+
]);
|
|
1413
|
+
const defaultValues = useMemo3(() => ({
|
|
1414
|
+
operation
|
|
1415
|
+
}), [
|
|
1416
|
+
operation
|
|
1417
|
+
]);
|
|
1418
|
+
const handleValuesChanged = useCallback5((values) => onChange?.(values.operation), [
|
|
1419
|
+
onChange
|
|
1420
|
+
]);
|
|
1421
|
+
return /* @__PURE__ */ React5.createElement(Form3.Root, {
|
|
1422
|
+
schema: OperationActionForm,
|
|
1423
|
+
db,
|
|
1424
|
+
readonly,
|
|
1425
|
+
defaultValues,
|
|
1426
|
+
fieldMap,
|
|
1427
|
+
onValuesChanged: handleValuesChanged
|
|
1428
|
+
}, /* @__PURE__ */ React5.createElement(Form3.FieldSet, null));
|
|
1429
|
+
};
|
|
1430
|
+
var useOperations = (db) => useQuery2(db, Query2.select(Filter2.type(DXN2.make(Type3.getTypename(Operation.PersistentOperation)))).from(Scope2.space(), Scope2.registry()));
|
|
1431
|
+
var usePrimaryTrigger = (routine) => {
|
|
1432
|
+
const [snapshot] = useObject(routine);
|
|
1433
|
+
return useMemo3(() => {
|
|
1434
|
+
for (const ref of snapshot.triggers) {
|
|
1435
|
+
const target = ref.target;
|
|
1436
|
+
if (Obj3.instanceOf(Trigger2.Trigger, target)) {
|
|
1437
|
+
return target;
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
return void 0;
|
|
1441
|
+
}, [
|
|
1442
|
+
snapshot.triggers
|
|
1443
|
+
]);
|
|
1444
|
+
};
|
|
1445
|
+
|
|
1446
|
+
// src/components/CreateRoutinePanel/CreateRoutinePanel.tsx
|
|
1447
|
+
import React6, { useCallback as useCallback6, useMemo as useMemo4 } from "react";
|
|
1448
|
+
import { useCapabilities } from "@dxos/app-framework/ui";
|
|
1449
|
+
import { useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
1450
|
+
import { SearchList, useSearchListResults } from "@dxos/react-ui-search";
|
|
1451
|
+
import { meta as meta5 } from "#meta";
|
|
1452
|
+
import { RoutineCapabilities } from "#types";
|
|
1453
|
+
var CreateRoutinePanel = ({ onCreateObject, templates: templatesProp }) => {
|
|
1454
|
+
const { t } = useTranslation5(meta5.profile.key);
|
|
1455
|
+
const capabilityTemplates = useCapabilities(RoutineCapabilities.Template);
|
|
1456
|
+
const templates = templatesProp ?? capabilityTemplates;
|
|
1457
|
+
const sorted = useMemo4(() => [
|
|
1458
|
+
...templates
|
|
1459
|
+
].filter((template) => template.appliesTo?.(void 0) ?? true).sort((a, b) => a.label.localeCompare(b.label)), [
|
|
1460
|
+
templates
|
|
1461
|
+
]);
|
|
1462
|
+
const { results, handleSearch } = useSearchListResults({
|
|
1463
|
+
items: sorted,
|
|
1464
|
+
extract: (template) => template.label
|
|
1465
|
+
});
|
|
1466
|
+
const handleSelect = useCallback6((templateId) => {
|
|
1467
|
+
void onCreateObject({
|
|
1468
|
+
templateId
|
|
1469
|
+
});
|
|
1470
|
+
}, [
|
|
1471
|
+
onCreateObject
|
|
1472
|
+
]);
|
|
1473
|
+
return /* @__PURE__ */ React6.createElement(SearchList.Root, {
|
|
1474
|
+
onSearch: handleSearch
|
|
1475
|
+
}, /* @__PURE__ */ React6.createElement(SearchList.Input, {
|
|
1476
|
+
classNames: "mb-form-gap",
|
|
1477
|
+
autoFocus: true,
|
|
1478
|
+
"data-testid": "create-automation-panel.template-input",
|
|
1479
|
+
placeholder: t("create-panel.template.placeholder")
|
|
1480
|
+
}), /* @__PURE__ */ React6.createElement(SearchList.Viewport, null, results.map((template) => /* @__PURE__ */ React6.createElement(SearchList.Item, {
|
|
1481
|
+
key: template.id,
|
|
1482
|
+
value: template.id,
|
|
1483
|
+
label: template.label,
|
|
1484
|
+
icon: template.icon ?? "ph--lightning--regular",
|
|
1485
|
+
onSelect: () => handleSelect(template.id)
|
|
1486
|
+
}))));
|
|
1487
|
+
};
|
|
1488
|
+
|
|
1489
|
+
// src/components/MasterDetail/MasterDetail.tsx
|
|
1490
|
+
import { Atom, useAtomValue } from "@effect-atom/atom-react";
|
|
1491
|
+
import React7, { useMemo as useMemo5 } from "react";
|
|
1492
|
+
import { Column, Icon as Icon2, IconBlock, IconButton as IconButton2, Tooltip, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
1493
|
+
import { Empty, OrderedList } from "@dxos/react-ui-list";
|
|
1494
|
+
import { Menu, useMenuBuilder } from "@dxos/react-ui-menu";
|
|
1495
|
+
import { getStyles } from "@dxos/ui-theme";
|
|
1496
|
+
import { meta as meta6 } from "#meta";
|
|
1497
|
+
var EMPTY_MENU = {
|
|
1498
|
+
nodes: [],
|
|
1499
|
+
edges: []
|
|
1500
|
+
};
|
|
1501
|
+
var MasterDetail = ({ classNames, items, selectedId, onSelect, getLabel, getIcon, getAdornment, getMenu, emptyLabel, detail }) => {
|
|
1502
|
+
return /* @__PURE__ */ React7.createElement(Column.Root, {
|
|
1503
|
+
gutter: "sm",
|
|
1504
|
+
classNames
|
|
1505
|
+
}, /* @__PURE__ */ React7.createElement(Column.Center, null, items.length === 0 && /* @__PURE__ */ React7.createElement(Empty, {
|
|
1506
|
+
label: emptyLabel
|
|
1507
|
+
}) || /* @__PURE__ */ React7.createElement(OrderedList.Root, {
|
|
1508
|
+
items
|
|
1509
|
+
}, ({ items: items2 }) => /* @__PURE__ */ React7.createElement(OrderedList.Content, null, items2.map((item) => /* @__PURE__ */ React7.createElement(MasterDetailRow, {
|
|
1510
|
+
key: item.id,
|
|
1511
|
+
item,
|
|
1512
|
+
selected: item.id === selectedId,
|
|
1513
|
+
getLabel,
|
|
1514
|
+
getIcon,
|
|
1515
|
+
getAdornment,
|
|
1516
|
+
getMenu,
|
|
1517
|
+
onSelect
|
|
1518
|
+
}))))), /* @__PURE__ */ React7.createElement("div", {
|
|
1519
|
+
className: "col-span-full pt-trim-md"
|
|
1520
|
+
}, detail));
|
|
1521
|
+
};
|
|
1522
|
+
var MasterDetailRow = ({ item, selected, getLabel, getIcon, getAdornment, getMenu, onSelect }) => {
|
|
1523
|
+
const { t } = useTranslation6(meta6.profile.key);
|
|
1524
|
+
const label = useAtomValue(useMemo5(() => Atom.make((get) => getLabel(get, item)), [
|
|
1525
|
+
getLabel,
|
|
1526
|
+
item
|
|
1527
|
+
]));
|
|
1528
|
+
const icon = useAtomValue(useMemo5(() => Atom.make((get) => getIcon?.(get, item)), [
|
|
1529
|
+
getIcon,
|
|
1530
|
+
item
|
|
1531
|
+
]));
|
|
1532
|
+
const adornment = useAtomValue(useMemo5(() => Atom.make((get) => getAdornment?.(get, item)), [
|
|
1533
|
+
getAdornment,
|
|
1534
|
+
item
|
|
1535
|
+
]));
|
|
1536
|
+
const menu = useMenuBuilder((get) => getMenu?.(get, item) ?? EMPTY_MENU, [
|
|
1537
|
+
getMenu,
|
|
1538
|
+
item
|
|
1539
|
+
]);
|
|
1540
|
+
return /* @__PURE__ */ React7.createElement(OrderedList.Item, {
|
|
1541
|
+
id: item.id,
|
|
1542
|
+
item,
|
|
1543
|
+
canDrag: false,
|
|
1544
|
+
hover: true,
|
|
1545
|
+
selected,
|
|
1546
|
+
classNames: "flex items-center cursor-pointer p-1",
|
|
1547
|
+
onClick: () => onSelect?.(selected ? void 0 : item.id)
|
|
1548
|
+
}, icon && /* @__PURE__ */ React7.createElement(IconBlock, null, /* @__PURE__ */ React7.createElement(Icon2, {
|
|
1549
|
+
icon: icon.icon,
|
|
1550
|
+
classNames: icon.hue ? getStyles(icon.hue).text : void 0
|
|
1551
|
+
})), /* @__PURE__ */ React7.createElement("span", {
|
|
1552
|
+
className: "grow truncate"
|
|
1553
|
+
}, label), adornment && /* @__PURE__ */ React7.createElement(Tooltip.Provider, null, /* @__PURE__ */ React7.createElement(Tooltip.Trigger, {
|
|
1554
|
+
asChild: true,
|
|
1555
|
+
side: "bottom",
|
|
1556
|
+
content: adornment.label
|
|
1557
|
+
}, /* @__PURE__ */ React7.createElement(Icon2, {
|
|
1558
|
+
icon: adornment.icon
|
|
1559
|
+
}))), getMenu && /* @__PURE__ */ React7.createElement(Menu.Root, menu, /* @__PURE__ */ React7.createElement(Menu.Trigger, {
|
|
1560
|
+
asChild: true
|
|
1561
|
+
}, /* @__PURE__ */ React7.createElement(IconButton2, {
|
|
1562
|
+
iconOnly: true,
|
|
1563
|
+
variant: "ghost",
|
|
1564
|
+
icon: "ph--dots-three-vertical--regular",
|
|
1565
|
+
label: t("routine-actions.label"),
|
|
1566
|
+
// Open the menu without toggling row selection.
|
|
1567
|
+
onClick: (event) => event.stopPropagation()
|
|
1568
|
+
})), /* @__PURE__ */ React7.createElement(Menu.Content, null)));
|
|
1569
|
+
};
|
|
1570
|
+
|
|
1571
|
+
// src/components/TemplateEditor/TemplateEditor.tsx
|
|
1572
|
+
import { defaultHighlightStyle, syntaxHighlighting } from "@codemirror/language";
|
|
1573
|
+
import { composeRefs } from "@radix-ui/react-compose-refs";
|
|
1574
|
+
import React8 from "react";
|
|
1575
|
+
import { Doc } from "@dxos/echo-doc";
|
|
1576
|
+
import { useThemeContext, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
1577
|
+
import { composable as composable2, composableProps as composableProps2 } from "@dxos/react-ui";
|
|
1578
|
+
import { useTextEditor } from "@dxos/react-ui-editor";
|
|
1579
|
+
import { createBasicExtensions, createDataExtensions, createMarkdownExtensions, createThemeExtensions, decorateMarkdown } from "@dxos/ui-editor";
|
|
1580
|
+
import { isNonNullable } from "@dxos/util";
|
|
1581
|
+
import { meta as meta7 } from "#meta";
|
|
1582
|
+
|
|
1583
|
+
// src/components/TemplateEditor/extensions/handlebars-extension.ts
|
|
1584
|
+
import { autocompletion, completionKeymap } from "@codemirror/autocomplete";
|
|
1585
|
+
import { RangeSetBuilder } from "@codemirror/state";
|
|
1586
|
+
import { Decoration, ViewPlugin, WidgetType, keymap } from "@codemirror/view";
|
|
1587
|
+
import { Domino, mx as mx3 } from "@dxos/ui";
|
|
1588
|
+
var handlebars = (_ = {}) => {
|
|
1589
|
+
return [
|
|
1590
|
+
handlebarsHighlightPlugin,
|
|
1591
|
+
autocompletion({
|
|
1592
|
+
activateOnTyping: true,
|
|
1593
|
+
aboveCursor: true,
|
|
1594
|
+
closeOnBlur: true,
|
|
1595
|
+
override: [
|
|
1596
|
+
handlebarsCompletions
|
|
1597
|
+
]
|
|
1598
|
+
}),
|
|
1599
|
+
keymap.of(completionKeymap)
|
|
1600
|
+
];
|
|
1601
|
+
};
|
|
1602
|
+
var regex = {
|
|
1603
|
+
// {{! comment }}
|
|
1604
|
+
comment: /\{\{!\s*[^}]*\}\}/g,
|
|
1605
|
+
// {{var}}
|
|
1606
|
+
brackets: /\{\{[^}]*\}\}/g,
|
|
1607
|
+
// {{#command}} {{/command}}
|
|
1608
|
+
command: /\{\{[#/]([^}]+)\}\}/g,
|
|
1609
|
+
// {{var}}
|
|
1610
|
+
var: /\{\{(?!\s*!)(\w[^}]*)\}\}/g,
|
|
1611
|
+
// @echo://space/id or @dxn:nsid
|
|
1612
|
+
dxn: /@?(?:echo:\/{1,3}[\w/]+|dxn:[\w.-]+)/g,
|
|
1613
|
+
// example.com/path/xxx
|
|
1614
|
+
url: /[\w.-]+\.[\w.-]+\/[\w/]+/g
|
|
1615
|
+
};
|
|
1616
|
+
var tagPadding = "mx-0.5 px-1 rounded-xs";
|
|
1617
|
+
var handlebarsHighlightPlugin = ViewPlugin.fromClass(class {
|
|
1618
|
+
decorations;
|
|
1619
|
+
constructor(view) {
|
|
1620
|
+
this.decorations = this.buildDecorations(view);
|
|
1621
|
+
}
|
|
1622
|
+
update(update) {
|
|
1623
|
+
if (update.docChanged || update.viewportChanged || update.selectionSet) {
|
|
1624
|
+
this.decorations = this.buildDecorations(update.view);
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
// NOTE: Decorations may clash with other extensions (e.g., markdown).
|
|
1628
|
+
buildDecorations(view) {
|
|
1629
|
+
const selection = view.state.selection.main;
|
|
1630
|
+
const decorations = [];
|
|
1631
|
+
for (const { from, to } of view.visibleRanges) {
|
|
1632
|
+
const text = view.state.doc.sliceString(from, to);
|
|
1633
|
+
{
|
|
1634
|
+
let match;
|
|
1635
|
+
while ((match = regex.dxn.exec(text)) !== null) {
|
|
1636
|
+
const start = from + match.index;
|
|
1637
|
+
const end = start + match[0].length;
|
|
1638
|
+
const overlaps = selection.to > start && selection.from <= end;
|
|
1639
|
+
if (!overlaps) {
|
|
1640
|
+
decorations.push({
|
|
1641
|
+
from: start,
|
|
1642
|
+
to: end,
|
|
1643
|
+
decoration: Decoration.widget({
|
|
1644
|
+
widget: new DXNWidget(match[0])
|
|
1645
|
+
})
|
|
1646
|
+
});
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
{
|
|
1651
|
+
let match;
|
|
1652
|
+
while ((match = regex.url.exec(text)) !== null) {
|
|
1653
|
+
const start = from + match.index;
|
|
1654
|
+
const end = start + match[0].length;
|
|
1655
|
+
decorations.push({
|
|
1656
|
+
from: start,
|
|
1657
|
+
to: end,
|
|
1658
|
+
decoration: Decoration.mark({
|
|
1659
|
+
class: mx3("dx-tag--blue", tagPadding)
|
|
1660
|
+
})
|
|
1661
|
+
});
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
{
|
|
1665
|
+
let match;
|
|
1666
|
+
while ((match = regex.brackets.exec(text)) !== null) {
|
|
1667
|
+
const start = from + match.index;
|
|
1668
|
+
const end = start + match[0].length;
|
|
1669
|
+
decorations.push({
|
|
1670
|
+
from: start,
|
|
1671
|
+
to: end,
|
|
1672
|
+
decoration: Decoration.mark({
|
|
1673
|
+
class: "text-subdued"
|
|
1674
|
+
})
|
|
1675
|
+
});
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
{
|
|
1679
|
+
let match;
|
|
1680
|
+
while ((match = regex.command.exec(text)) !== null) {
|
|
1681
|
+
const start = from + match.index + 2;
|
|
1682
|
+
let end = start + match[0].length - 4;
|
|
1683
|
+
const text2 = view.state.doc.sliceString(start, end);
|
|
1684
|
+
const parts = text2.split(/\s+/);
|
|
1685
|
+
if (parts.length > 1) {
|
|
1686
|
+
const idx = start + parts[0].length;
|
|
1687
|
+
decorations.push({
|
|
1688
|
+
from: idx,
|
|
1689
|
+
to: end,
|
|
1690
|
+
decoration: Decoration.mark({
|
|
1691
|
+
class: "text-green-text"
|
|
1692
|
+
})
|
|
1693
|
+
});
|
|
1694
|
+
end = idx;
|
|
1695
|
+
}
|
|
1696
|
+
decorations.push({
|
|
1697
|
+
from: start,
|
|
1698
|
+
to: end,
|
|
1699
|
+
decoration: Decoration.mark({
|
|
1700
|
+
class: "text-blue-text"
|
|
1701
|
+
})
|
|
1702
|
+
});
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
{
|
|
1706
|
+
let match;
|
|
1707
|
+
while ((match = regex.var.exec(text)) !== null) {
|
|
1708
|
+
const start = from + match.index + 2;
|
|
1709
|
+
const end = start + match[0].length - 4;
|
|
1710
|
+
decorations.push({
|
|
1711
|
+
from: start,
|
|
1712
|
+
to: end,
|
|
1713
|
+
decoration: Decoration.mark({
|
|
1714
|
+
class: "text-green-text"
|
|
1715
|
+
})
|
|
1716
|
+
});
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
decorations.sort((a, b) => a.from - b.from || a.to - b.to);
|
|
1721
|
+
const builder = new RangeSetBuilder();
|
|
1722
|
+
for (const { from, to, decoration } of decorations) {
|
|
1723
|
+
builder.add(from, to, decoration);
|
|
1724
|
+
}
|
|
1725
|
+
return builder.finish();
|
|
1726
|
+
}
|
|
1727
|
+
}, {
|
|
1728
|
+
decorations: (v) => v.decorations
|
|
1729
|
+
});
|
|
1730
|
+
var DXNWidget = class extends WidgetType {
|
|
1731
|
+
_identifier;
|
|
1732
|
+
constructor(_identifier) {
|
|
1733
|
+
super(), this._identifier = _identifier;
|
|
1734
|
+
}
|
|
1735
|
+
ignoreEvent() {
|
|
1736
|
+
return false;
|
|
1737
|
+
}
|
|
1738
|
+
eq(other) {
|
|
1739
|
+
return this._identifier === other._identifier;
|
|
1740
|
+
}
|
|
1741
|
+
toDOM() {
|
|
1742
|
+
const text = this._identifier.split(":").map((part) => {
|
|
1743
|
+
const len = 16;
|
|
1744
|
+
const plen = 4;
|
|
1745
|
+
if (part.length > len) {
|
|
1746
|
+
return `[${part.slice(0, plen)}\u2026${part.slice(-plen)}]`;
|
|
1747
|
+
}
|
|
1748
|
+
return part;
|
|
1749
|
+
}).join(":");
|
|
1750
|
+
return Domino.of("span").classNames(mx3("font-mono dx-tag--blue", tagPadding)).text(text).root;
|
|
1751
|
+
}
|
|
1752
|
+
};
|
|
1753
|
+
var variables = [
|
|
1754
|
+
"this"
|
|
1755
|
+
];
|
|
1756
|
+
var commands = [
|
|
1757
|
+
"this",
|
|
1758
|
+
"each",
|
|
1759
|
+
"if",
|
|
1760
|
+
"unless",
|
|
1761
|
+
"with"
|
|
1762
|
+
];
|
|
1763
|
+
function handlebarsCompletions(context) {
|
|
1764
|
+
const match = context.matchBefore(/\{\{[^}]*/);
|
|
1765
|
+
if (!match || match.from === match.to) {
|
|
1766
|
+
return null;
|
|
1767
|
+
}
|
|
1768
|
+
let type = "variable";
|
|
1769
|
+
let text = match.text.slice(2);
|
|
1770
|
+
let from = match.from + 2;
|
|
1771
|
+
let matches = [];
|
|
1772
|
+
if (text.startsWith("#") || text.startsWith("/")) {
|
|
1773
|
+
const idx = text.lastIndexOf(" ");
|
|
1774
|
+
if (idx !== -1) {
|
|
1775
|
+
type = "variable";
|
|
1776
|
+
matches = variables;
|
|
1777
|
+
text = text.slice(idx + 1);
|
|
1778
|
+
from += idx + 1;
|
|
1779
|
+
} else {
|
|
1780
|
+
type = "command";
|
|
1781
|
+
text = text.slice(1);
|
|
1782
|
+
matches = commands;
|
|
1783
|
+
from += 1;
|
|
1784
|
+
}
|
|
1785
|
+
} else {
|
|
1786
|
+
type = "variable";
|
|
1787
|
+
matches = variables;
|
|
1788
|
+
}
|
|
1789
|
+
const options = matches.filter((name) => name.startsWith(text)).map((name) => ({
|
|
1790
|
+
type,
|
|
1791
|
+
label: name
|
|
1792
|
+
}));
|
|
1793
|
+
return {
|
|
1794
|
+
from,
|
|
1795
|
+
options
|
|
1796
|
+
};
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
// src/components/TemplateEditor/extensions/xml-extension.ts
|
|
1800
|
+
import { syntaxTree } from "@codemirror/language";
|
|
1801
|
+
import { RangeSetBuilder as RangeSetBuilder2 } from "@codemirror/state";
|
|
1802
|
+
import { Decoration as Decoration2, ViewPlugin as ViewPlugin2 } from "@codemirror/view";
|
|
1803
|
+
var xmlDecorator = (_ = {}) => {
|
|
1804
|
+
return [
|
|
1805
|
+
xmlDecoratorPlugin
|
|
1806
|
+
];
|
|
1807
|
+
};
|
|
1808
|
+
var xmlDecoratorPlugin = ViewPlugin2.fromClass(class {
|
|
1809
|
+
decorations;
|
|
1810
|
+
constructor(view) {
|
|
1811
|
+
this.decorations = this.buildDecorations(view);
|
|
1812
|
+
}
|
|
1813
|
+
update(update) {
|
|
1814
|
+
if (update.docChanged || update.viewportChanged) {
|
|
1815
|
+
this.decorations = this.buildDecorations(update.view);
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
buildDecorations(view) {
|
|
1819
|
+
const builder = new RangeSetBuilder2();
|
|
1820
|
+
for (const { from, to } of view.visibleRanges) {
|
|
1821
|
+
syntaxTree(view.state).iterate({
|
|
1822
|
+
from,
|
|
1823
|
+
to,
|
|
1824
|
+
enter: (node) => {
|
|
1825
|
+
if (node.name === "HTMLTag" || node.name === "OpenTag" || node.name === "CloseTag" || node.name === "SelfClosingTag" || node.name === "Element") {
|
|
1826
|
+
builder.add(node.from, node.to, Decoration2.mark({
|
|
1827
|
+
class: "font-mono text-subdued"
|
|
1828
|
+
}));
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1831
|
+
});
|
|
1832
|
+
}
|
|
1833
|
+
return builder.finish();
|
|
1834
|
+
}
|
|
1835
|
+
}, {
|
|
1836
|
+
decorations: (v) => v.decorations
|
|
1837
|
+
});
|
|
1838
|
+
|
|
1839
|
+
// src/components/TemplateEditor/TemplateEditor.tsx
|
|
1840
|
+
var TemplateEditor = composable2(({ classNames, id, source, lineNumbers = true, ...props }, forwardedRef) => {
|
|
1841
|
+
const { t } = useTranslation7(meta7.profile.key);
|
|
1842
|
+
const { themeMode } = useThemeContext();
|
|
1843
|
+
const { parentRef } = useTextEditor(() => {
|
|
1844
|
+
const target = source?.target;
|
|
1845
|
+
if (!target) {
|
|
1846
|
+
return {};
|
|
1847
|
+
}
|
|
1848
|
+
return {
|
|
1849
|
+
initialValue: target.content ?? "",
|
|
1850
|
+
extensions: [
|
|
1851
|
+
createDataExtensions({
|
|
1852
|
+
id,
|
|
1853
|
+
text: Doc.createAccessor(target, [
|
|
1854
|
+
"content"
|
|
1855
|
+
])
|
|
1856
|
+
}),
|
|
1857
|
+
createBasicExtensions({
|
|
1858
|
+
bracketMatching: false,
|
|
1859
|
+
lineNumbers,
|
|
1860
|
+
lineWrapping: true,
|
|
1861
|
+
placeholder: t("template.placeholder")
|
|
1862
|
+
}),
|
|
1863
|
+
createThemeExtensions({
|
|
1864
|
+
themeMode
|
|
1865
|
+
}),
|
|
1866
|
+
createMarkdownExtensions(),
|
|
1867
|
+
decorateMarkdown(),
|
|
1868
|
+
handlebars(),
|
|
1869
|
+
// xml(),
|
|
1870
|
+
// NOTE: Since we're using markdown only HTML nodes are parsed.
|
|
1871
|
+
xmlDecorator(),
|
|
1872
|
+
syntaxHighlighting(defaultHighlightStyle)
|
|
1873
|
+
].filter(isNonNullable)
|
|
1874
|
+
};
|
|
1875
|
+
}, [
|
|
1876
|
+
themeMode,
|
|
1877
|
+
source?.target,
|
|
1878
|
+
lineNumbers
|
|
1879
|
+
]);
|
|
1880
|
+
return /* @__PURE__ */ React8.createElement("div", {
|
|
1881
|
+
...composableProps2(props, {
|
|
1882
|
+
role: "none",
|
|
1883
|
+
classNames: [
|
|
1884
|
+
"h-full overflow-hidden",
|
|
1885
|
+
classNames
|
|
1886
|
+
]
|
|
1887
|
+
}),
|
|
1888
|
+
ref: composeRefs(parentRef, forwardedRef)
|
|
1889
|
+
});
|
|
1890
|
+
});
|
|
1891
|
+
export {
|
|
1892
|
+
CreateRoutinePanel,
|
|
1893
|
+
CronSpec,
|
|
1894
|
+
CustomSpec,
|
|
1895
|
+
DailySpec,
|
|
1896
|
+
DayOfWeek,
|
|
1897
|
+
Days,
|
|
1898
|
+
FrequencyDefaults,
|
|
1899
|
+
HourlySpec,
|
|
1900
|
+
InstructionsEditor,
|
|
1901
|
+
MAX_MIN_INTERVAL_SECONDS,
|
|
1902
|
+
MasterDetail,
|
|
1903
|
+
MinutelySpec,
|
|
1904
|
+
MonthlySpec,
|
|
1905
|
+
RoutineForm,
|
|
1906
|
+
Schedule,
|
|
1907
|
+
ScheduleKinds,
|
|
1908
|
+
TemplateEditor,
|
|
1909
|
+
TriggerEditor,
|
|
1910
|
+
WeeklySpec,
|
|
1911
|
+
clampSchedule,
|
|
1912
|
+
cronIntervalSeconds,
|
|
1913
|
+
cronToSchedule,
|
|
1914
|
+
describeCron,
|
|
1915
|
+
describeSchedule,
|
|
1916
|
+
fromCron,
|
|
1917
|
+
scheduleIntervalSeconds,
|
|
1918
|
+
scheduleToCron,
|
|
1919
|
+
toCron
|
|
1920
|
+
};
|
|
1921
|
+
//# sourceMappingURL=index.mjs.map
|