@dxos/plugin-automation 0.8.4-main.bc674ce → 0.8.4-main.c351d160a8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/AutomationPanel-IGLIQY2N.mjs +11 -0
- package/dist/lib/browser/AutomationSettings-XGJGVBDD.mjs +37 -0
- package/dist/lib/browser/AutomationSettings-XGJGVBDD.mjs.map +7 -0
- package/dist/lib/browser/FunctionsContainer-R4ZMYSFJ.mjs +43 -0
- package/dist/lib/browser/FunctionsContainer-R4ZMYSFJ.mjs.map +7 -0
- package/dist/lib/browser/{FunctionsPanel-ZX4J75UM.mjs → FunctionsPanel-NMA4RYJL.mjs} +3 -3
- package/dist/lib/browser/FunctionsRegistry-TMKAEG5E.mjs +10 -0
- package/dist/lib/browser/TriggerSettings-GW5OEM2G.mjs +11 -0
- package/dist/lib/browser/{app-graph-builder-LAQMEBMH.mjs → app-graph-builder-74ILZP25.mjs} +19 -20
- package/dist/lib/browser/app-graph-builder-74ILZP25.mjs.map +7 -0
- package/dist/lib/browser/{chunk-JOXPQ27I.mjs → chunk-5WMYSXEH.mjs} +7 -7
- package/dist/lib/browser/chunk-5WMYSXEH.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BFUIVUQH.mjs → chunk-75XLBFAG.mjs} +11 -16
- package/dist/lib/browser/chunk-75XLBFAG.mjs.map +7 -0
- package/dist/lib/browser/{chunk-QW3EM35H.mjs → chunk-BWEKRPFJ.mjs} +62 -16
- package/dist/lib/browser/chunk-BWEKRPFJ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-PZNBEKO5.mjs → chunk-EL64ZPPN.mjs} +2 -2
- package/dist/lib/browser/{chunk-PZNBEKO5.mjs.map → chunk-EL64ZPPN.mjs.map} +1 -1
- package/dist/lib/browser/{FunctionsContainer-6QLC7JP4.mjs → chunk-FUVAC5EC.mjs} +15 -48
- package/dist/lib/browser/chunk-FUVAC5EC.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BKFQBKYO.mjs → chunk-LHJEQVX5.mjs} +2 -2
- package/dist/lib/browser/{chunk-YWLEY2FD.mjs → chunk-O23LHDEX.mjs} +119 -50
- package/dist/lib/browser/chunk-O23LHDEX.mjs.map +7 -0
- package/dist/lib/browser/chunk-PUYY7B5F.mjs +31 -0
- package/dist/lib/browser/chunk-PUYY7B5F.mjs.map +7 -0
- package/dist/lib/browser/{chunk-RAF2FJST.mjs → chunk-ZBEMNWNY.mjs} +19 -12
- package/dist/lib/browser/chunk-ZBEMNWNY.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +62 -54
- package/dist/lib/browser/cli/index.mjs.map +3 -3
- package/dist/lib/browser/{compute-runtime-WTWLQ67J.mjs → compute-runtime-I3I2BIRE.mjs} +36 -20
- package/dist/lib/browser/compute-runtime-I3I2BIRE.mjs.map +7 -0
- package/dist/lib/browser/hooks/index.mjs +3 -3
- package/dist/lib/browser/index.mjs +26 -25
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{operation-resolver-Q3MWOR7K.mjs → operation-resolver-NGN4BEWN.mjs} +11 -9
- package/dist/lib/browser/operation-resolver-NGN4BEWN.mjs.map +7 -0
- package/dist/lib/browser/react-surface-SXDIM3RM.mjs +65 -0
- package/dist/lib/browser/react-surface-SXDIM3RM.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +2 -2
- package/dist/lib/node-esm/{AutomationPanel-B7NAGDFA.mjs → AutomationPanel-O2BCQA7P.mjs} +4 -4
- package/dist/lib/node-esm/AutomationPanel-O2BCQA7P.mjs.map +7 -0
- package/dist/lib/node-esm/AutomationSettings-W52ZO2XI.mjs +38 -0
- package/dist/lib/node-esm/AutomationSettings-W52ZO2XI.mjs.map +7 -0
- package/dist/lib/node-esm/FunctionsContainer-GYRPQZM7.mjs +44 -0
- package/dist/lib/node-esm/FunctionsContainer-GYRPQZM7.mjs.map +7 -0
- package/dist/lib/node-esm/{FunctionsPanel-SS6GIVNU.mjs → FunctionsPanel-DCXXLSVP.mjs} +3 -3
- package/dist/lib/node-esm/FunctionsPanel-DCXXLSVP.mjs.map +7 -0
- package/dist/lib/node-esm/FunctionsRegistry-7WCHC64E.mjs +11 -0
- package/dist/lib/node-esm/FunctionsRegistry-7WCHC64E.mjs.map +7 -0
- package/dist/lib/node-esm/TriggerSettings-2GKFPECW.mjs +12 -0
- package/dist/lib/node-esm/TriggerSettings-2GKFPECW.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-4UCMXHYY.mjs → app-graph-builder-VDXPOWCH.mjs} +19 -20
- package/dist/lib/node-esm/app-graph-builder-VDXPOWCH.mjs.map +7 -0
- package/dist/lib/node-esm/{FunctionsContainer-J4O2ULWR.mjs → chunk-6JVB3IHW.mjs} +15 -48
- package/dist/lib/node-esm/chunk-6JVB3IHW.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-BNWZ2NNI.mjs +32 -0
- package/dist/lib/node-esm/chunk-BNWZ2NNI.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-2CKVH7JC.mjs → chunk-FPXVLTEY.mjs} +119 -50
- package/dist/lib/node-esm/chunk-FPXVLTEY.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-KWKWOGS5.mjs → chunk-K7T2MVB7.mjs} +11 -16
- package/dist/lib/node-esm/chunk-K7T2MVB7.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-LJAXQ6CX.mjs → chunk-Q5JSKD6Z.mjs} +62 -16
- package/dist/lib/node-esm/chunk-Q5JSKD6Z.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-K7GCM342.mjs → chunk-V3VUE2NR.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-5FXNN3MV.mjs → chunk-WC5AT7B3.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-5FXNN3MV.mjs.map → chunk-WC5AT7B3.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-RX52VKI2.mjs → chunk-XCFO2IXT.mjs} +7 -7
- package/dist/lib/node-esm/chunk-XCFO2IXT.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-HQLVREIX.mjs → chunk-XQO3HK62.mjs} +19 -12
- package/dist/lib/node-esm/chunk-XQO3HK62.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +62 -54
- package/dist/lib/node-esm/cli/index.mjs.map +3 -3
- package/dist/lib/node-esm/{compute-runtime-ZHROOBLY.mjs → compute-runtime-7HCSIYFG.mjs} +36 -20
- package/dist/lib/node-esm/compute-runtime-7HCSIYFG.mjs.map +7 -0
- package/dist/lib/node-esm/hooks/index.mjs +3 -3
- package/dist/lib/node-esm/index.mjs +26 -25
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{operation-resolver-R5GA4YNO.mjs → operation-resolver-ANGACQZG.mjs} +11 -9
- package/dist/lib/node-esm/operation-resolver-ANGACQZG.mjs.map +7 -0
- package/dist/lib/node-esm/{react-surface-S6VZJCEZ.mjs → react-surface-QVLVDEVW.mjs} +25 -25
- package/dist/lib/node-esm/react-surface-QVLVDEVW.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +2 -2
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +1 -1
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/compute-runtime/compute-runtime.d.ts +1 -1
- package/dist/types/src/capabilities/compute-runtime/compute-runtime.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +2 -2
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +2 -2
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -1
- package/dist/types/src/cli/commands/trigger/update/queue.d.ts.map +1 -1
- package/dist/types/src/cli/commands/trigger/util.d.ts +2 -2
- package/dist/types/src/cli/commands/trigger/util.d.ts.map +1 -1
- package/dist/types/src/cli/plugin.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +3 -4
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts +1 -0
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsRegistry/FunctionsRegistry.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsRegistry/index.d.ts +3 -1
- package/dist/types/src/components/FunctionsRegistry/index.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +2 -0
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +3 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/AutomationSettings/AutomationSettings.d.ts +4 -0
- package/dist/types/src/containers/AutomationSettings/AutomationSettings.d.ts.map +1 -0
- package/dist/types/src/containers/AutomationSettings/index.d.ts +3 -0
- package/dist/types/src/containers/AutomationSettings/index.d.ts.map +1 -0
- package/dist/types/src/{components → containers/FunctionsContainer}/FunctionsContainer.d.ts +0 -1
- package/dist/types/src/containers/FunctionsContainer/FunctionsContainer.d.ts.map +1 -0
- package/dist/types/src/containers/FunctionsContainer/index.d.ts +3 -0
- package/dist/types/src/containers/FunctionsContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/TriggerSettings/TriggerSettings.d.ts.map +1 -0
- package/dist/types/src/containers/TriggerSettings/index.d.ts +3 -0
- package/dist/types/src/containers/TriggerSettings/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +5 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts +2 -1
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +3 -2
- package/dist/types/src/types/capabilities.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +3 -3
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +51 -46
- package/src/AutomationPlugin.tsx +7 -6
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +17 -15
- package/src/capabilities/compute-runtime/compute-runtime.ts +36 -14
- package/src/capabilities/operation-resolver/operation-resolver.ts +7 -6
- package/src/capabilities/react-surface/react-surface.tsx +16 -19
- package/src/cli/commands/trigger/create/queue.ts +4 -4
- package/src/cli/commands/trigger/create/subscription.ts +4 -4
- package/src/cli/commands/trigger/create/timer.ts +4 -4
- package/src/cli/commands/trigger/list.ts +2 -2
- package/src/cli/commands/trigger/remove.ts +2 -2
- package/src/cli/commands/trigger/update/queue.ts +5 -5
- package/src/cli/commands/trigger/update/subscription.ts +5 -5
- package/src/cli/commands/trigger/update/timer.ts +5 -5
- package/src/cli/commands/trigger/util.ts +34 -25
- package/src/cli/plugin.ts +3 -2
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +3 -3
- package/src/components/AutomationPanel/AutomationPanel.tsx +137 -69
- package/src/components/FunctionsPanel/FunctionsPanel.tsx +9 -11
- package/src/components/FunctionsRegistry/FunctionsRegistry.tsx +9 -10
- package/src/components/FunctionsRegistry/index.ts +4 -1
- package/src/components/TriggerEditor/FunctionInputEditor.tsx +13 -4
- package/src/components/TriggerEditor/SpecSelector.tsx +1 -1
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +46 -4
- package/src/components/TriggerEditor/TriggerEditor.tsx +39 -7
- package/src/components/index.ts +1 -2
- package/src/{components → containers/AutomationSettings}/AutomationSettings.tsx +8 -11
- package/src/containers/AutomationSettings/index.ts +7 -0
- package/src/{components → containers/FunctionsContainer}/FunctionsContainer.tsx +10 -13
- package/src/containers/FunctionsContainer/index.ts +7 -0
- package/src/containers/TriggerSettings/TriggerSettings.tsx +26 -0
- package/src/containers/TriggerSettings/index.ts +6 -0
- package/src/containers/index.ts +9 -0
- package/src/hooks/useComputeRuntimeCallback.ts +1 -1
- package/src/hooks/useTriggerRuntimeControls.ts +22 -8
- package/src/meta.ts +1 -1
- package/src/testing/test-functions.ts +5 -5
- package/src/translations.ts +2 -0
- package/src/types/capabilities.ts +5 -2
- package/src/types/events.ts +1 -1
- package/src/types/schema.ts +3 -3
- package/dist/lib/browser/AutomationPanel-FAS6ADCW.mjs +0 -11
- package/dist/lib/browser/AutomationSettings-XN2OIYWL.mjs +0 -56
- package/dist/lib/browser/AutomationSettings-XN2OIYWL.mjs.map +0 -7
- package/dist/lib/browser/FunctionsContainer-6QLC7JP4.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-LAQMEBMH.mjs.map +0 -7
- package/dist/lib/browser/chunk-54PANILA.mjs +0 -14
- package/dist/lib/browser/chunk-54PANILA.mjs.map +0 -7
- package/dist/lib/browser/chunk-BFUIVUQH.mjs.map +0 -7
- package/dist/lib/browser/chunk-JOXPQ27I.mjs.map +0 -7
- package/dist/lib/browser/chunk-QW3EM35H.mjs.map +0 -7
- package/dist/lib/browser/chunk-RAF2FJST.mjs.map +0 -7
- package/dist/lib/browser/chunk-YWLEY2FD.mjs.map +0 -7
- package/dist/lib/browser/compute-runtime-WTWLQ67J.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-Q3MWOR7K.mjs.map +0 -7
- package/dist/lib/browser/react-surface-EV3AC62F.mjs +0 -65
- package/dist/lib/browser/react-surface-EV3AC62F.mjs.map +0 -7
- package/dist/lib/node-esm/AutomationSettings-M5PMZJ6P.mjs +0 -57
- package/dist/lib/node-esm/AutomationSettings-M5PMZJ6P.mjs.map +0 -7
- package/dist/lib/node-esm/FunctionsContainer-J4O2ULWR.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-4UCMXHYY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2CKVH7JC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7QRUPEHH.mjs +0 -16
- package/dist/lib/node-esm/chunk-7QRUPEHH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HQLVREIX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-KWKWOGS5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LJAXQ6CX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RX52VKI2.mjs.map +0 -7
- package/dist/lib/node-esm/compute-runtime-ZHROOBLY.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-R5GA4YNO.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-S6VZJCEZ.mjs.map +0 -7
- package/dist/types/src/components/AutomationSettings.d.ts +0 -5
- package/dist/types/src/components/AutomationSettings.d.ts.map +0 -1
- package/dist/types/src/components/FunctionsContainer.d.ts.map +0 -1
- package/dist/types/src/components/TriggerSettings.d.ts.map +0 -1
- package/src/components/TriggerSettings.tsx +0 -25
- /package/dist/lib/browser/{AutomationPanel-FAS6ADCW.mjs.map → AutomationPanel-IGLIQY2N.mjs.map} +0 -0
- /package/dist/lib/browser/{FunctionsPanel-ZX4J75UM.mjs.map → FunctionsPanel-NMA4RYJL.mjs.map} +0 -0
- /package/dist/lib/{node-esm/AutomationPanel-B7NAGDFA.mjs.map → browser/FunctionsRegistry-TMKAEG5E.mjs.map} +0 -0
- /package/dist/lib/{node-esm/FunctionsPanel-SS6GIVNU.mjs.map → browser/TriggerSettings-GW5OEM2G.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-BKFQBKYO.mjs.map → chunk-LHJEQVX5.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-K7GCM342.mjs.map → chunk-V3VUE2NR.mjs.map} +0 -0
- /package/dist/types/src/{components → containers/TriggerSettings}/TriggerSettings.d.ts +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/useComputeRuntimeCallback.ts", "../../../src/hooks/useTriggerRuntimeControls.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Cause from 'effect/Cause';\nimport * as Effect from 'effect/Effect';\nimport * as Exit from 'effect/Exit';\nimport { type DependencyList, useCallback } from 'react';\n\nimport { useCapability } from '@dxos/app-framework/ui';\nimport { type Key } from '@dxos/echo';\nimport { type FunctionDefinition, FunctionInvocationService, TracingService } from '@dxos/functions';\nimport { log } from '@dxos/log';\n\nimport { AutomationCapabilities } from '../types';\n\n/**\n * Create an effectful function that has access to compute services\n */\n// TODO(burdon): Factor out (figure out cross-plugin capabilities dependencies).\nexport const useComputeRuntimeCallback = <T>(\n id: Key.SpaceId | undefined,\n fn: () => Effect.Effect<T, any, AutomationCapabilities.ComputeServices>,\n deps?: DependencyList,\n): (() => Promise<T>) => {\n const computeRuntime = useCapability(AutomationCapabilities.ComputeRuntime);\n const runtime = id !== undefined ? computeRuntime.getRuntime(id) : undefined;\n\n return useCallback(() => {\n if (!runtime) {\n throw new TypeError('Space not provided to useComputeRuntimeCallback');\n }\n\n return runtime.runPromise(fn());\n }, [runtime, ...(deps ?? [])]);\n};\n\n// TODO(wittjosiah): Function invoking should automatically be traced (DX-647).\nexport const invokeFunctionWithTracing = <I, O>(functionDef: FunctionDefinition<I, O>, inputData: I) =>\n Effect.gen(function* () {\n const tracer = yield* TracingService;\n const trace = yield* tracer.traceInvocationStart({\n target: undefined,\n payload: {\n data: {},\n },\n });\n\n // Invoke the function.\n const result = yield* FunctionInvocationService.invokeFunction(functionDef, inputData).pipe(\n Effect.provide(trace.invocationTraceQueue ? TracingService.layerInvocation(trace) : TracingService.layerNoop),\n Effect.exit,\n );\n\n if (Exit.isFailure(result)) {\n const error = Cause.prettyErrors(result.cause)[0];\n log.error(error.message, error.cause ?? error.stack);\n }\n\n yield* tracer.traceInvocationEnd({\n trace,\n // TODO(dmaretskyi): Might miss errors.\n exception: Exit.isFailure(result) ? Cause.prettyErrors(result.cause)[0] : undefined,\n });\n\n return result;\n });\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Atom, useAtomValue } from '@effect-atom/atom-react';\nimport type * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport { useEffect, useState } from 'react';\n\nimport { type Database, Filter } from '@dxos/echo';\nimport { Trigger } from '@dxos/functions';\nimport { TriggerDispatcher, type TriggerDispatcherState } from '@dxos/functions-runtime';\nimport { useQuery } from '@dxos/react-client/echo';\n\nimport { useComputeRuntimeCallback } from './useComputeRuntimeCallback';\n\ninterface TriggerRuntimeControls {\n triggers: Trigger.Trigger[];\n\n state: TriggerDispatcherState | undefined;\n\n start: () => void;\n stop: () => void;\n}\n\nexport const useTriggerRuntimeControls = (db: Database.Database | undefined): TriggerRuntimeControls => {\n const triggers = useQuery(db, Filter.type(Trigger.Trigger));\n\n const [dispatcher, setDispatcher] = useState<Context.Tag.Service<TriggerDispatcher> | undefined>(undefined);\n\n const init = useComputeRuntimeCallback(\n db?.spaceId,\n Effect.fnUntraced(function* () {\n const dispatcher = yield* TriggerDispatcher;\n setDispatcher(dispatcher);\n }),\n );\n\n useEffect(() => {\n void init();\n }, []);\n\n const state = useAtomValue(dispatcher?.state ?? Atom.make(undefined));\n\n const start = useComputeRuntimeCallback(\n db?.spaceId,\n Effect.fnUntraced(function* () {\n const dispatcher = yield* TriggerDispatcher;\n yield* dispatcher.start();\n }),\n );\n\n const stop = useComputeRuntimeCallback(\n db?.spaceId,\n Effect.fnUntraced(function* () {\n const dispatcher = yield* TriggerDispatcher;\n yield* dispatcher.stop();\n }),\n );\n\n return {\n triggers,\n state,\n start: () => void start(),\n stop: () => void stop(),\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;AAIA,YAAYA,WAAW;AACvB,YAAYC,YAAY;AACxB,YAAYC,UAAU;AACtB,SAA8BC,mBAAmB;AAEjD,SAASC,qBAAqB;AAE9B,SAAkCC,2BAA2BC,sBAAsB;AACnF,SAASC,WAAW;;AAQb,IAAMC,4BAA4B,CACvCC,IACAC,IACAC,SAAAA;AAEA,QAAMC,iBAAiBC,cAAcC,uBAAuBC,cAAc;AAC1E,QAAMC,UAAUP,OAAOQ,SAAYL,eAAeM,WAAWT,EAAAA,IAAMQ;AAEnE,SAAOE,YAAY,MAAA;AACjB,QAAI,CAACH,SAAS;AACZ,YAAM,IAAII,UAAU,iDAAA;IACtB;AAEA,WAAOJ,QAAQK,WAAWX,GAAAA,CAAAA;EAC5B,GAAG;IAACM;OAAaL,QAAQ,CAAA;GAAI;AAC/B;AAGO,IAAMW,4BAA4B,CAAOC,aAAuCC,cAC9EC,WAAI,aAAA;AACT,QAAMC,SAAS,OAAOC;AACtB,QAAMC,QAAQ,OAAOF,OAAOG,qBAAqB;IAC/CC,QAAQb;IACRc,SAAS;MACPC,MAAM,CAAC;IACT;EACF,CAAA;AAGA,QAAMC,SAAS,OAAOC,0BAA0BC,eAAeZ,aAAaC,SAAAA,EAAWY,KAC9EC,eAAQT,MAAMU,uBAAuBX,eAAeY,gBAAgBX,KAAAA,IAASD,eAAea,SAAS,GACrGC,WAAI;AAGb,MAASC,eAAUT,MAAAA,GAAS;AAC1B,UAAMU,QAAcC,mBAAaX,OAAOY,KAAK,EAAE,CAAA;AAC/CC,QAAIH,MAAMA,MAAMI,SAASJ,MAAME,SAASF,MAAMK,OAAK;;;;;;EACrD;AAEA,SAAOtB,OAAOuB,mBAAmB;IAC/BrB;;IAEAsB,WAAgBR,eAAUT,MAAAA,IAAgBW,mBAAaX,OAAOY,KAAK,EAAE,CAAA,IAAK5B;EAC5E,CAAA;AAEA,SAAOgB;AACT,CAAA;;;AC9DF,SAASkB,MAAMC,oBAAoB;AAEnC,YAAYC,aAAY;AACxB,SAASC,WAAWC,gBAAgB;AAEpC,SAAwBC,cAAc;AACtC,SAASC,eAAe;AACxB,SAASC,yBAAsD;AAC/D,SAASC,gBAAgB;AAalB,IAAMC,4BAA4B,CAACC,OAAAA;AACxC,QAAMC,WAAWC,SAASF,IAAIG,OAAOC,KAAKC,QAAQA,OAAO,CAAA;AAEzD,QAAM,CAACC,YAAYC,aAAAA,IAAiBC,SAA6DC,MAAAA;AAEjG,QAAMC,OAAOC,0BACXX,IAAIY,SACGC,mBAAW,aAAA;AAChB,UAAMP,cAAa,OAAOQ;AAC1BP,kBAAcD,WAAAA;EAChB,CAAA,CAAA;AAGFS,YAAU,MAAA;AACR,SAAKL,KAAAA;EACP,GAAG,CAAA,CAAE;AAEL,QAAMM,QAAQC,aAAaX,YAAYU,SAASE,KAAKC,KAAKV,MAAAA,CAAAA;AAE1D,QAAMW,QAAQT,0BACZX,IAAIY,SACGC,mBAAW,aAAA;AAChB,UAAMP,cAAa,OAAOQ;AAC1B,WAAOR,YAAWc,MAAK;EACzB,CAAA,CAAA;AAGF,QAAMC,OAAOV,0BACXX,IAAIY,SACGC,mBAAW,aAAA;AAChB,UAAMP,cAAa,OAAOQ;AAC1B,WAAOR,YAAWe,KAAI;EACxB,CAAA,CAAA;AAGF,SAAO;IACLpB;IACAe;IACAI,OAAO,MAAM,KAAKA,MAAAA;IAClBC,MAAM,MAAM,KAAKA,KAAAA;EACnB;AACF;",
|
|
6
|
+
"names": ["Cause", "Effect", "Exit", "useCallback", "useCapability", "FunctionInvocationService", "TracingService", "log", "useComputeRuntimeCallback", "id", "fn", "deps", "computeRuntime", "useCapability", "AutomationCapabilities", "ComputeRuntime", "runtime", "undefined", "getRuntime", "useCallback", "TypeError", "runPromise", "invokeFunctionWithTracing", "functionDef", "inputData", "gen", "tracer", "TracingService", "trace", "traceInvocationStart", "target", "payload", "data", "result", "FunctionInvocationService", "invokeFunction", "pipe", "provide", "invocationTraceQueue", "layerInvocation", "layerNoop", "exit", "isFailure", "error", "prettyErrors", "cause", "log", "message", "stack", "traceInvocationEnd", "exception", "Atom", "useAtomValue", "Effect", "useEffect", "useState", "Filter", "Trigger", "TriggerDispatcher", "useQuery", "useTriggerRuntimeControls", "db", "triggers", "useQuery", "Filter", "type", "Trigger", "dispatcher", "setDispatcher", "useState", "undefined", "init", "useComputeRuntimeCallback", "spaceId", "fnUntraced", "TriggerDispatcher", "useEffect", "state", "useAtomValue", "Atom", "make", "start", "stop"]
|
|
7
|
+
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ComputeRuntime
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-LHJEQVX5.mjs";
|
|
4
4
|
import {
|
|
5
5
|
AutomationEvents
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-5WMYSXEH.mjs";
|
|
7
7
|
import {
|
|
8
8
|
meta
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-EL64ZPPN.mjs";
|
|
10
10
|
|
|
11
11
|
// src/cli/plugin.ts
|
|
12
|
-
import {
|
|
12
|
+
import { Plugin } from "@dxos/app-framework";
|
|
13
|
+
import { AppPlugin } from "@dxos/app-toolkit";
|
|
13
14
|
import { ClientEvents } from "@dxos/plugin-client/types";
|
|
14
15
|
|
|
15
16
|
// src/cli/commands/trigger/index.ts
|
|
@@ -29,7 +30,7 @@ import * as Option2 from "effect/Option";
|
|
|
29
30
|
import { CommandConfig } from "@dxos/cli-util";
|
|
30
31
|
import { flushAndSync, print, spaceLayer, withTypes } from "@dxos/cli-util";
|
|
31
32
|
import { Common } from "@dxos/cli-util";
|
|
32
|
-
import { Database as Database2, Filter as Filter2, Ref as Ref2
|
|
33
|
+
import { Database as Database2, Filter as Filter2, JsonSchema, Ref as Ref2 } from "@dxos/echo";
|
|
33
34
|
import { Function as Function2, Trigger as Trigger2 } from "@dxos/functions";
|
|
34
35
|
|
|
35
36
|
// src/cli/commands/trigger/options.ts
|
|
@@ -62,10 +63,10 @@ import * as Match from "effect/Match";
|
|
|
62
63
|
import * as Option from "effect/Option";
|
|
63
64
|
import * as SchemaAST from "effect/SchemaAST";
|
|
64
65
|
import { FormBuilder } from "@dxos/cli-util";
|
|
65
|
-
import { Annotation, Database, Entity, Filter, Obj, Ref, Type } from "@dxos/echo";
|
|
66
|
+
import { Annotation, Database, Entity, Feed, Filter, Obj, Ref, Type } from "@dxos/echo";
|
|
66
67
|
import { getProperties } from "@dxos/effect";
|
|
67
68
|
import { Function, Trigger } from "@dxos/functions";
|
|
68
|
-
import {
|
|
69
|
+
import { FeedAnnotation } from "@dxos/schema";
|
|
69
70
|
var getTriggerRemoteStatus = (trigger2, remoteCronIds) => {
|
|
70
71
|
if (trigger2.spec?.kind !== "timer") {
|
|
71
72
|
return "n/a";
|
|
@@ -73,7 +74,7 @@ var getTriggerRemoteStatus = (trigger2, remoteCronIds) => {
|
|
|
73
74
|
return remoteCronIds.includes(trigger2.id) ? "available" : "not available";
|
|
74
75
|
};
|
|
75
76
|
var printTrigger = Effect.fn(function* (trigger2, remoteStatus) {
|
|
76
|
-
const fn6 = trigger2.function && (yield* Database.
|
|
77
|
+
const fn6 = trigger2.function && (yield* Database.load(trigger2.function));
|
|
77
78
|
return FormBuilder.make({
|
|
78
79
|
title: trigger2.id
|
|
79
80
|
}).pipe(FormBuilder.set("status", trigger2.enabled ? "enabled" : "disabled", trigger2.enabled ? Ansi.green : Ansi.blackBright), FormBuilder.option("kind", Option.fromNullable(trigger2.spec?.kind)), FormBuilder.option("remote", Option.fromNullable(remoteStatus), Match.type().pipe(Match.withReturnType(), Match.when("available", () => Ansi.green), Match.when("not available", () => Ansi.yellow), Match.when("n/a", () => Ansi.blackBright), Match.exhaustive)), FormBuilder.when(fn6, FormBuilder.nest("function", FormBuilder.make().pipe(FormBuilder.set("key", fn6.key), FormBuilder.set("dxn", fn6.dxn?.toString())))), FormBuilder.nestedOption("spec", Option.fromNullable(trigger2.spec).pipe(Option.map(printSpec))), FormBuilder.build);
|
|
@@ -202,7 +203,7 @@ var promptForSchemaInput = Effect.fn(function* (schema, defaults) {
|
|
|
202
203
|
inputObj[key] = templateStr === "" && defaultValue !== void 0 ? defaultValue : templateStr;
|
|
203
204
|
} else {
|
|
204
205
|
const annotation = Annotation.ReferenceAnnotation.getFromAst(propType).pipe(Option.getOrThrow);
|
|
205
|
-
const objects = yield* Database.
|
|
206
|
+
const objects = yield* Database.runQuery(Filter.typename(annotation.typename));
|
|
206
207
|
if (objects.length === 0) {
|
|
207
208
|
inputObj[key] = void 0;
|
|
208
209
|
} else {
|
|
@@ -228,7 +229,7 @@ var promptForSchemaInput = Effect.fn(function* (schema, defaults) {
|
|
|
228
229
|
return inputObj;
|
|
229
230
|
});
|
|
230
231
|
var selectFunction = Effect.fn(function* () {
|
|
231
|
-
const functions = yield* Database.
|
|
232
|
+
const functions = yield* Database.runQuery(Filter.type(Function.Function));
|
|
232
233
|
if (functions.length === 0) {
|
|
233
234
|
return yield* Effect.fail(new Error("No functions available"));
|
|
234
235
|
}
|
|
@@ -243,13 +244,13 @@ var selectFunction = Effect.fn(function* () {
|
|
|
243
244
|
return String(selected);
|
|
244
245
|
});
|
|
245
246
|
var selectTrigger = Effect.fn(function* (kind) {
|
|
246
|
-
const triggers = yield* Database.
|
|
247
|
+
const triggers = yield* Database.runQuery(Filter.type(Trigger.Trigger));
|
|
247
248
|
const filteredTriggers = kind ? triggers.filter((trigger2) => trigger2.spec?.kind === kind) : triggers;
|
|
248
249
|
if (filteredTriggers.length === 0) {
|
|
249
250
|
return yield* Effect.fail(new Error(kind ? `No ${kind} triggers available` : "No triggers available"));
|
|
250
251
|
}
|
|
251
252
|
const choices = yield* Effect.all(filteredTriggers.map((trigger2) => Effect.gen(function* () {
|
|
252
|
-
const fn6 = trigger2.function ? yield* Database.
|
|
253
|
+
const fn6 = trigger2.function ? yield* Database.load(trigger2.function) : void 0;
|
|
253
254
|
const functionName = fn6 && Obj.instanceOf(Function.Function, fn6) ? fn6.name ?? fn6.key ?? fn6.id : void 0;
|
|
254
255
|
const title = functionName ?? trigger2.id;
|
|
255
256
|
const description = `${trigger2.enabled ? "enabled" : "disabled"} - ${trigger2.spec?.kind ?? "unknown"}`;
|
|
@@ -266,35 +267,42 @@ var selectTrigger = Effect.fn(function* (kind) {
|
|
|
266
267
|
return String(selected);
|
|
267
268
|
});
|
|
268
269
|
var selectQueue = Effect.fn(function* () {
|
|
269
|
-
const schemas = yield* Database.
|
|
270
|
+
const schemas = yield* Database.runSchemaQuery({
|
|
270
271
|
location: [
|
|
271
272
|
"database",
|
|
272
273
|
"runtime"
|
|
273
274
|
]
|
|
274
275
|
});
|
|
275
|
-
const
|
|
276
|
-
const annotation =
|
|
276
|
+
const feedSchemas = schemas.filter((schema) => {
|
|
277
|
+
const annotation = FeedAnnotation.get(schema);
|
|
277
278
|
return Option.isSome(annotation) && annotation.value === true;
|
|
278
279
|
});
|
|
279
|
-
if (
|
|
280
|
-
return yield* Effect.fail(new Error("No schemas with
|
|
280
|
+
if (feedSchemas.length === 0) {
|
|
281
|
+
return yield* Effect.fail(new Error("No schemas with Feed annotation found"));
|
|
281
282
|
}
|
|
282
283
|
const queueChoices = [];
|
|
283
|
-
for (const schema of
|
|
284
|
+
for (const schema of feedSchemas) {
|
|
284
285
|
yield* Effect.gen(function* () {
|
|
285
286
|
const typename = Type.getTypename(schema);
|
|
286
|
-
const objects = yield* Database.
|
|
287
|
+
const objects = yield* Database.runQuery(Filter.type(typename));
|
|
287
288
|
for (const obj of objects) {
|
|
288
|
-
const
|
|
289
|
-
if (!
|
|
289
|
+
const feedRef = obj.feed;
|
|
290
|
+
if (!feedRef) {
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
const feedObj = yield* Effect.promise(() => feedRef.tryLoad());
|
|
294
|
+
if (!feedObj || !Obj.instanceOf(Feed.Feed, feedObj)) {
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
const queueDxn = Feed.getQueueDxn(feedObj);
|
|
298
|
+
if (!queueDxn) {
|
|
290
299
|
continue;
|
|
291
300
|
}
|
|
292
|
-
const queueDxn = queueRef.dxn.toString();
|
|
293
301
|
const label = Obj.getLabel(obj) ?? obj.id;
|
|
294
302
|
const description = Obj.getTypename(obj);
|
|
295
303
|
queueChoices.push({
|
|
296
304
|
title: label,
|
|
297
|
-
value: queueDxn,
|
|
305
|
+
value: queueDxn.toString(),
|
|
298
306
|
description
|
|
299
307
|
});
|
|
300
308
|
}
|
|
@@ -326,7 +334,7 @@ var queue = Command.make("queue", {
|
|
|
326
334
|
onNone: () => selectFunction(),
|
|
327
335
|
onSome: (id) => Effect2.succeed(id)
|
|
328
336
|
});
|
|
329
|
-
const functions = yield* Database2.
|
|
337
|
+
const functions = yield* Database2.runQuery(Filter2.type(Function2.Function));
|
|
330
338
|
const fn6 = functions.find((fn7) => fn7.id === functionId);
|
|
331
339
|
if (!fn6) {
|
|
332
340
|
return yield* Effect2.fail(new Error(`Function not found: ${functionId}`));
|
|
@@ -336,7 +344,7 @@ var queue = Command.make("queue", {
|
|
|
336
344
|
onSome: (dxn) => Effect2.succeed(dxn.toString())
|
|
337
345
|
});
|
|
338
346
|
const input = yield* Option2.match(options.input, {
|
|
339
|
-
onNone: () => promptForSchemaInput(fn6.inputSchema ?
|
|
347
|
+
onNone: () => promptForSchemaInput(fn6.inputSchema ? JsonSchema.toEffectSchema(fn6.inputSchema) : void 0),
|
|
340
348
|
onSome: (value2) => Effect2.succeed(Object.fromEntries(HashMap.toEntries(value2)))
|
|
341
349
|
});
|
|
342
350
|
const enabled = yield* Option2.match(options.functionId, {
|
|
@@ -355,7 +363,7 @@ var queue = Command.make("queue", {
|
|
|
355
363
|
},
|
|
356
364
|
input
|
|
357
365
|
});
|
|
358
|
-
yield* Database2.
|
|
366
|
+
yield* Database2.add(trigger2);
|
|
359
367
|
if (json) {
|
|
360
368
|
yield* Console2.log(JSON.stringify(trigger2, null, 2));
|
|
361
369
|
} else {
|
|
@@ -377,7 +385,7 @@ import * as Option3 from "effect/Option";
|
|
|
377
385
|
import { CommandConfig as CommandConfig2 } from "@dxos/cli-util";
|
|
378
386
|
import { flushAndSync as flushAndSync2, print as print2, spaceLayer as spaceLayer2, withTypes as withTypes2 } from "@dxos/cli-util";
|
|
379
387
|
import { Common as Common2 } from "@dxos/cli-util";
|
|
380
|
-
import { Database as Database3, Filter as Filter3, Query, Ref as Ref3
|
|
388
|
+
import { Database as Database3, Filter as Filter3, JsonSchema as JsonSchema2, Query, Ref as Ref3 } from "@dxos/echo";
|
|
381
389
|
import { Function as Function3, Trigger as Trigger3 } from "@dxos/functions";
|
|
382
390
|
var subscription = Command2.make("subscription", {
|
|
383
391
|
spaceId: Common2.spaceId.pipe(Options3.optional),
|
|
@@ -393,7 +401,7 @@ var subscription = Command2.make("subscription", {
|
|
|
393
401
|
onNone: () => selectFunction(),
|
|
394
402
|
onSome: (id) => Effect3.succeed(id)
|
|
395
403
|
});
|
|
396
|
-
const functions = yield* Database3.
|
|
404
|
+
const functions = yield* Database3.runQuery(Filter3.type(Function3.Function));
|
|
397
405
|
const fn6 = functions.find((fn7) => fn7.id === functionId);
|
|
398
406
|
if (!fn6) {
|
|
399
407
|
return yield* Effect3.fail(new Error(`Function not found: ${functionId}`));
|
|
@@ -429,7 +437,7 @@ var subscription = Command2.make("subscription", {
|
|
|
429
437
|
subscriptionOptions.delay = delayOption.value;
|
|
430
438
|
}
|
|
431
439
|
const input = yield* Option3.match(options.input, {
|
|
432
|
-
onNone: () => promptForSchemaInput(fn6.inputSchema ?
|
|
440
|
+
onNone: () => promptForSchemaInput(fn6.inputSchema ? JsonSchema2.toEffectSchema(fn6.inputSchema) : void 0),
|
|
433
441
|
onSome: (value2) => Effect3.succeed(Object.fromEntries(HashMap2.toEntries(value2)))
|
|
434
442
|
});
|
|
435
443
|
const enabled = yield* Option3.match(options.functionId, {
|
|
@@ -451,7 +459,7 @@ var subscription = Command2.make("subscription", {
|
|
|
451
459
|
},
|
|
452
460
|
input
|
|
453
461
|
});
|
|
454
|
-
yield* Database3.
|
|
462
|
+
yield* Database3.add(trigger2);
|
|
455
463
|
if (json) {
|
|
456
464
|
yield* Console3.log(JSON.stringify(trigger2, null, 2));
|
|
457
465
|
} else {
|
|
@@ -473,7 +481,7 @@ import * as Option4 from "effect/Option";
|
|
|
473
481
|
import { CommandConfig as CommandConfig3 } from "@dxos/cli-util";
|
|
474
482
|
import { flushAndSync as flushAndSync3, print as print3, spaceLayer as spaceLayer3, withTypes as withTypes3 } from "@dxos/cli-util";
|
|
475
483
|
import { Common as Common3 } from "@dxos/cli-util";
|
|
476
|
-
import { Database as Database4, Filter as Filter4,
|
|
484
|
+
import { Database as Database4, Filter as Filter4, JsonSchema as JsonSchema3, Ref as Ref4 } from "@dxos/echo";
|
|
477
485
|
import { Function as Function4, Trigger as Trigger4 } from "@dxos/functions";
|
|
478
486
|
var timer = Command3.make("timer", {
|
|
479
487
|
spaceId: Common3.spaceId.pipe(Options4.optional),
|
|
@@ -487,7 +495,7 @@ var timer = Command3.make("timer", {
|
|
|
487
495
|
onNone: () => selectFunction(),
|
|
488
496
|
onSome: (id) => Effect4.succeed(id)
|
|
489
497
|
});
|
|
490
|
-
const functions = yield* Database4.
|
|
498
|
+
const functions = yield* Database4.runQuery(Filter4.type(Function4.Function));
|
|
491
499
|
const fn6 = functions.find((fn7) => fn7.id === functionId);
|
|
492
500
|
if (!fn6) {
|
|
493
501
|
return yield* Effect4.fail(new Error(`Function not found: ${functionId}`));
|
|
@@ -499,7 +507,7 @@ var timer = Command3.make("timer", {
|
|
|
499
507
|
onSome: (value2) => Effect4.succeed(value2)
|
|
500
508
|
});
|
|
501
509
|
const input = yield* Option4.match(options.input, {
|
|
502
|
-
onNone: () => promptForSchemaInput(fn6.inputSchema ?
|
|
510
|
+
onNone: () => promptForSchemaInput(fn6.inputSchema ? JsonSchema3.toEffectSchema(fn6.inputSchema) : void 0),
|
|
503
511
|
onSome: (value2) => Effect4.succeed(Object.fromEntries(HashMap3.toEntries(value2)))
|
|
504
512
|
});
|
|
505
513
|
const enabled = yield* Option4.match(options.functionId, {
|
|
@@ -518,7 +526,7 @@ var timer = Command3.make("timer", {
|
|
|
518
526
|
},
|
|
519
527
|
input
|
|
520
528
|
});
|
|
521
|
-
yield* Database4.
|
|
529
|
+
yield* Database4.add(trigger2);
|
|
522
530
|
if (json) {
|
|
523
531
|
yield* Console4.log(JSON.stringify(trigger2, null, 2));
|
|
524
532
|
} else {
|
|
@@ -549,11 +557,11 @@ var list = Command5.make("list", {
|
|
|
549
557
|
spaceId: Common4.spaceId.pipe(Options5.optional)
|
|
550
558
|
}, Effect5.fn(function* ({ spaceId: spaceIdOption }) {
|
|
551
559
|
const { json } = yield* CommandConfig4;
|
|
552
|
-
const triggers = yield* Database5.
|
|
560
|
+
const triggers = yield* Database5.runQuery(Filter5.type(Trigger5.Trigger));
|
|
553
561
|
const remoteCronIds = yield* Effect5.gen(function* () {
|
|
554
562
|
const client = yield* ClientService;
|
|
555
563
|
const spaceId = yield* spaceIdWithDefault(spaceIdOption);
|
|
556
|
-
const result = yield* Effect5.promise(() => client.edge.getCronTriggers(spaceId)).pipe(Effect5.catchAll(() => Effect5.succeed({
|
|
564
|
+
const result = yield* Effect5.promise(() => client.edge.http.getCronTriggers(spaceId)).pipe(Effect5.catchAll(() => Effect5.succeed({
|
|
557
565
|
cronIds: []
|
|
558
566
|
})));
|
|
559
567
|
return result.cronIds;
|
|
@@ -597,8 +605,8 @@ var remove = Command6.make("remove", {
|
|
|
597
605
|
onSome: (id) => Effect6.succeed(id)
|
|
598
606
|
});
|
|
599
607
|
const dxn = DXN2.fromLocalObjectId(triggerId);
|
|
600
|
-
const trigger2 = yield* Database6.
|
|
601
|
-
yield* Database6.
|
|
608
|
+
const trigger2 = yield* Database6.resolve(dxn, Trigger6.Trigger);
|
|
609
|
+
yield* Database6.remove(trigger2);
|
|
602
610
|
if (json) {
|
|
603
611
|
yield* Console6.log(JSON.stringify({
|
|
604
612
|
id: trigger2.id,
|
|
@@ -622,7 +630,7 @@ import * as Option6 from "effect/Option";
|
|
|
622
630
|
import { CommandConfig as CommandConfig6 } from "@dxos/cli-util";
|
|
623
631
|
import { flushAndSync as flushAndSync4, print as print5, spaceLayer as spaceLayer6, withTypes as withTypes5 } from "@dxos/cli-util";
|
|
624
632
|
import { Common as Common6 } from "@dxos/cli-util";
|
|
625
|
-
import { DXN as DXN3, Database as Database7, Filter as Filter6,
|
|
633
|
+
import { DXN as DXN3, Database as Database7, Filter as Filter6, JsonSchema as JsonSchema4, Obj as Obj2, Ref as Ref5 } from "@dxos/echo";
|
|
626
634
|
import { Function as Function5, Trigger as Trigger7 } from "@dxos/functions";
|
|
627
635
|
var queue2 = Command7.make("queue", {
|
|
628
636
|
spaceId: Common6.spaceId.pipe(Options7.optional),
|
|
@@ -638,7 +646,7 @@ var queue2 = Command7.make("queue", {
|
|
|
638
646
|
onSome: (id) => Effect7.succeed(id)
|
|
639
647
|
});
|
|
640
648
|
const dxn = DXN3.fromLocalObjectId(triggerId);
|
|
641
|
-
const trigger2 = yield* Database7.
|
|
649
|
+
const trigger2 = yield* Database7.resolve(dxn, Trigger7.Trigger);
|
|
642
650
|
if (trigger2.spec?.kind !== "queue") {
|
|
643
651
|
return yield* Effect7.fail(new Error(`Invalid trigger type: ${trigger2.spec?.kind}`));
|
|
644
652
|
}
|
|
@@ -656,7 +664,7 @@ var queue2 = Command7.make("queue", {
|
|
|
656
664
|
});
|
|
657
665
|
})).pipe(Command7.withDescription("Update a queue trigger."), Command7.provide(({ spaceId }) => spaceLayer6(spaceId, true)), Command7.provideEffectDiscard(() => withTypes5(Function5.Function, Trigger7.Trigger)));
|
|
658
666
|
var updateFunction = Effect7.fn(function* (trigger2, functionIdOption) {
|
|
659
|
-
let currentFn = trigger2.function ? yield* Database7.
|
|
667
|
+
let currentFn = trigger2.function ? yield* Database7.load(trigger2.function) : void 0;
|
|
660
668
|
if (currentFn && !Obj2.instanceOf(Function5.Function, currentFn)) {
|
|
661
669
|
currentFn = void 0;
|
|
662
670
|
}
|
|
@@ -673,7 +681,7 @@ var updateFunction = Effect7.fn(function* (trigger2, functionIdOption) {
|
|
|
673
681
|
onNone: () => selectFunction(),
|
|
674
682
|
onSome: (id) => Effect7.succeed(id)
|
|
675
683
|
});
|
|
676
|
-
const functions = yield* Database7.
|
|
684
|
+
const functions = yield* Database7.runQuery(Filter6.type(Function5.Function));
|
|
677
685
|
const foundFn = functions.find((fn6) => fn6.id === functionId);
|
|
678
686
|
if (!foundFn || !Obj2.instanceOf(Function5.Function, foundFn)) {
|
|
679
687
|
return yield* Effect7.fail(new Error(`Function not found: ${functionId}`));
|
|
@@ -726,7 +734,7 @@ var updateInput = Effect7.fn(function* (trigger2, fn6, inputOption) {
|
|
|
726
734
|
});
|
|
727
735
|
if (shouldChangeInput) {
|
|
728
736
|
const inputObj = yield* Option6.match(inputOption, {
|
|
729
|
-
onNone: () => promptForSchemaInput(fn6.inputSchema ?
|
|
737
|
+
onNone: () => promptForSchemaInput(fn6.inputSchema ? JsonSchema4.toEffectSchema(fn6.inputSchema) : void 0, currentInput),
|
|
730
738
|
onSome: (value2) => Effect7.succeed(value2)
|
|
731
739
|
});
|
|
732
740
|
Obj2.change(trigger2, (mutableTrigger) => {
|
|
@@ -758,7 +766,7 @@ import * as Option7 from "effect/Option";
|
|
|
758
766
|
import { CommandConfig as CommandConfig7 } from "@dxos/cli-util";
|
|
759
767
|
import { flushAndSync as flushAndSync5, print as print6, spaceLayer as spaceLayer7, withTypes as withTypes6 } from "@dxos/cli-util";
|
|
760
768
|
import { Common as Common7 } from "@dxos/cli-util";
|
|
761
|
-
import { DXN as DXN4, Database as Database8, Filter as Filter7, Obj as Obj3, Query as Query2, Ref as Ref6
|
|
769
|
+
import { DXN as DXN4, Database as Database8, Filter as Filter7, JsonSchema as JsonSchema5, Obj as Obj3, Query as Query2, Ref as Ref6 } from "@dxos/echo";
|
|
762
770
|
import { Function as Function6, Trigger as Trigger8 } from "@dxos/functions";
|
|
763
771
|
var subscription2 = Command8.make("subscription", {
|
|
764
772
|
spaceId: Common7.spaceId.pipe(Options8.optional),
|
|
@@ -776,7 +784,7 @@ var subscription2 = Command8.make("subscription", {
|
|
|
776
784
|
onSome: (id) => Effect8.succeed(id)
|
|
777
785
|
});
|
|
778
786
|
const dxn = DXN4.fromLocalObjectId(triggerId);
|
|
779
|
-
const trigger2 = yield* Database8.
|
|
787
|
+
const trigger2 = yield* Database8.resolve(dxn, Trigger8.Trigger);
|
|
780
788
|
if (trigger2.spec?.kind !== "subscription") {
|
|
781
789
|
return yield* Effect8.fail(new Error(`Invalid trigger type: ${trigger2.spec?.kind}`));
|
|
782
790
|
}
|
|
@@ -804,7 +812,7 @@ var extractCurrentTypename = (spec) => {
|
|
|
804
812
|
}, (f) => Option7.fromNullable(f.typename).pipe(Option7.flatMap((dxn) => Option7.fromNullable(DXN4.tryParse(dxn))), Option7.flatMap((dxn) => Option7.fromNullable(dxn.asTypeDXN()?.type)))), Match2.orElse(() => Option7.none()))), Match2.orElse(() => Option7.none()));
|
|
805
813
|
};
|
|
806
814
|
var updateFunction2 = Effect8.fn(function* (trigger2, functionIdOption) {
|
|
807
|
-
let currentFn = trigger2.function ? yield* Database8.
|
|
815
|
+
let currentFn = trigger2.function ? yield* Database8.load(trigger2.function) : void 0;
|
|
808
816
|
if (currentFn && !Obj3.instanceOf(Function6.Function, currentFn)) {
|
|
809
817
|
currentFn = void 0;
|
|
810
818
|
}
|
|
@@ -821,7 +829,7 @@ var updateFunction2 = Effect8.fn(function* (trigger2, functionIdOption) {
|
|
|
821
829
|
onNone: () => selectFunction(),
|
|
822
830
|
onSome: (id) => Effect8.succeed(id)
|
|
823
831
|
});
|
|
824
|
-
const functions = yield* Database8.
|
|
832
|
+
const functions = yield* Database8.runQuery(Filter7.type(Function6.Function));
|
|
825
833
|
const foundFn = functions.find((fn6) => fn6.id === functionId);
|
|
826
834
|
if (!foundFn || !Obj3.instanceOf(Function6.Function, foundFn)) {
|
|
827
835
|
return yield* Effect8.fail(new Error(`Function not found: ${functionId}`));
|
|
@@ -917,7 +925,7 @@ var updateInput2 = Effect8.fn(function* (trigger2, fn6, inputOption) {
|
|
|
917
925
|
});
|
|
918
926
|
if (shouldChangeInput) {
|
|
919
927
|
const inputObj = yield* Option7.match(inputOption, {
|
|
920
|
-
onNone: () => promptForSchemaInput(fn6.inputSchema ?
|
|
928
|
+
onNone: () => promptForSchemaInput(fn6.inputSchema ? JsonSchema5.toEffectSchema(fn6.inputSchema) : void 0, currentInput),
|
|
921
929
|
onSome: (value2) => Effect8.succeed(value2)
|
|
922
930
|
});
|
|
923
931
|
Obj3.change(trigger2, (mutableTrigger) => {
|
|
@@ -948,7 +956,7 @@ import * as Option8 from "effect/Option";
|
|
|
948
956
|
import { CommandConfig as CommandConfig8 } from "@dxos/cli-util";
|
|
949
957
|
import { flushAndSync as flushAndSync6, print as print7, spaceLayer as spaceLayer8, withTypes as withTypes7 } from "@dxos/cli-util";
|
|
950
958
|
import { Common as Common8 } from "@dxos/cli-util";
|
|
951
|
-
import { DXN as DXN5, Database as Database9, Filter as Filter8,
|
|
959
|
+
import { DXN as DXN5, Database as Database9, Filter as Filter8, JsonSchema as JsonSchema6, Obj as Obj4, Ref as Ref7 } from "@dxos/echo";
|
|
952
960
|
import { Function as Function7, Trigger as Trigger9 } from "@dxos/functions";
|
|
953
961
|
var timer2 = Command9.make("timer", {
|
|
954
962
|
spaceId: Common8.spaceId.pipe(Options9.optional),
|
|
@@ -964,7 +972,7 @@ var timer2 = Command9.make("timer", {
|
|
|
964
972
|
onSome: (id) => Effect9.succeed(id)
|
|
965
973
|
});
|
|
966
974
|
const dxn = DXN5.fromLocalObjectId(triggerId);
|
|
967
|
-
const trigger2 = yield* Database9.
|
|
975
|
+
const trigger2 = yield* Database9.resolve(dxn, Trigger9.Trigger);
|
|
968
976
|
if (!trigger2.spec || trigger2.spec?.kind !== "timer") {
|
|
969
977
|
return yield* Effect9.fail(new Error(`Invalid trigger type: ${trigger2.spec?.kind}`));
|
|
970
978
|
}
|
|
@@ -982,7 +990,7 @@ var timer2 = Command9.make("timer", {
|
|
|
982
990
|
});
|
|
983
991
|
})).pipe(Command9.withDescription("Update a timer trigger."), Command9.provide(({ spaceId }) => spaceLayer8(spaceId, true)), Command9.provideEffectDiscard(() => withTypes7(Function7.Function, Trigger9.Trigger)));
|
|
984
992
|
var updateFunction3 = Effect9.fn(function* (trigger2, functionIdOption) {
|
|
985
|
-
let currentFn = trigger2.function ? yield* Database9.
|
|
993
|
+
let currentFn = trigger2.function ? yield* Database9.load(trigger2.function) : void 0;
|
|
986
994
|
if (currentFn && !Obj4.instanceOf(Function7.Function, currentFn)) {
|
|
987
995
|
currentFn = void 0;
|
|
988
996
|
}
|
|
@@ -999,7 +1007,7 @@ var updateFunction3 = Effect9.fn(function* (trigger2, functionIdOption) {
|
|
|
999
1007
|
onNone: () => selectFunction(),
|
|
1000
1008
|
onSome: (id) => Effect9.succeed(id)
|
|
1001
1009
|
});
|
|
1002
|
-
const functions = yield* Database9.
|
|
1010
|
+
const functions = yield* Database9.runQuery(Filter8.type(Function7.Function));
|
|
1003
1011
|
const foundFn = functions.find((fn6) => fn6.id === functionId);
|
|
1004
1012
|
if (!foundFn || !Obj4.instanceOf(Function7.Function, foundFn)) {
|
|
1005
1013
|
return yield* Effect9.fail(new Error(`Function not found: ${functionId}`));
|
|
@@ -1053,7 +1061,7 @@ var updateInput3 = Effect9.fn(function* (trigger2, fn6, inputOption) {
|
|
|
1053
1061
|
});
|
|
1054
1062
|
if (shouldChangeInput) {
|
|
1055
1063
|
const inputObj = yield* Option8.match(inputOption, {
|
|
1056
|
-
onNone: () => promptForSchemaInput(fn6.inputSchema ?
|
|
1064
|
+
onNone: () => promptForSchemaInput(fn6.inputSchema ? JsonSchema6.toEffectSchema(fn6.inputSchema) : void 0, currentInput),
|
|
1057
1065
|
onSome: (value2) => Effect9.succeed(value2)
|
|
1058
1066
|
});
|
|
1059
1067
|
Obj4.change(trigger2, (mutableTrigger) => {
|
|
@@ -1090,7 +1098,7 @@ var trigger = Command11.make("trigger").pipe(Command11.withDescription("Manage E
|
|
|
1090
1098
|
]));
|
|
1091
1099
|
|
|
1092
1100
|
// src/cli/plugin.ts
|
|
1093
|
-
var AutomationPlugin = Plugin.define(meta).pipe(
|
|
1101
|
+
var AutomationPlugin = Plugin.define(meta).pipe(AppPlugin.addCommandModule({
|
|
1094
1102
|
commands: [
|
|
1095
1103
|
trigger
|
|
1096
1104
|
]
|