@dxos/plugin-automation 0.8.4-main.21d9917 → 0.8.4-main.2244d791bb
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-FAS6ADCW.mjs → AutomationPanel-C6MZ22CB.mjs} +3 -3
- package/dist/lib/browser/{AutomationSettings-XN2OIYWL.mjs → AutomationSettings-D7UO5V3Q.mjs} +10 -9
- package/dist/lib/browser/AutomationSettings-D7UO5V3Q.mjs.map +7 -0
- package/dist/lib/browser/{FunctionsContainer-6QLC7JP4.mjs → FunctionsContainer-5NHAAP5H.mjs} +8 -12
- package/dist/lib/browser/FunctionsContainer-5NHAAP5H.mjs.map +7 -0
- package/dist/lib/browser/{FunctionsPanel-ZX4J75UM.mjs → FunctionsPanel-RD22LYMR.mjs} +2 -2
- package/dist/lib/browser/{app-graph-builder-LAQMEBMH.mjs → app-graph-builder-HLARI3VW.mjs} +4 -3
- package/dist/lib/browser/app-graph-builder-HLARI3VW.mjs.map +7 -0
- package/dist/lib/browser/{chunk-YWLEY2FD.mjs → chunk-C273ZYLE.mjs} +100 -42
- package/dist/lib/browser/chunk-C273ZYLE.mjs.map +7 -0
- package/dist/lib/browser/{chunk-54PANILA.mjs → chunk-JFBUK3WR.mjs} +5 -5
- package/dist/lib/browser/{chunk-QW3EM35H.mjs → chunk-JN7QRQQX.mjs} +14 -6
- package/dist/lib/browser/chunk-JN7QRQQX.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BKFQBKYO.mjs → chunk-O5Y2F33G.mjs} +2 -2
- package/dist/lib/browser/{chunk-RAF2FJST.mjs → chunk-P5AEO35Y.mjs} +18 -11
- package/dist/lib/browser/chunk-P5AEO35Y.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BFUIVUQH.mjs → chunk-QNEQ23BF.mjs} +8 -12
- package/dist/lib/browser/chunk-QNEQ23BF.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +29 -28
- package/dist/lib/browser/cli/index.mjs.map +3 -3
- package/dist/lib/browser/{compute-runtime-WTWLQ67J.mjs → compute-runtime-BUBHYS4Y.mjs} +20 -15
- package/dist/lib/browser/compute-runtime-BUBHYS4Y.mjs.map +7 -0
- package/dist/lib/browser/hooks/index.mjs +1 -1
- package/dist/lib/browser/index.mjs +17 -16
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{operation-resolver-Q3MWOR7K.mjs → operation-resolver-IN2FRGOT.mjs} +5 -4
- package/dist/lib/browser/operation-resolver-IN2FRGOT.mjs.map +7 -0
- package/dist/lib/browser/{react-surface-EV3AC62F.mjs → react-surface-246NXXJR.mjs} +10 -9
- package/dist/lib/browser/react-surface-246NXXJR.mjs.map +7 -0
- package/dist/lib/node-esm/{AutomationPanel-B7NAGDFA.mjs → AutomationPanel-RTBY7YFM.mjs} +3 -3
- package/dist/lib/node-esm/{AutomationSettings-M5PMZJ6P.mjs → AutomationSettings-GK4RLSDN.mjs} +10 -9
- package/dist/lib/node-esm/AutomationSettings-GK4RLSDN.mjs.map +7 -0
- package/dist/lib/node-esm/{FunctionsContainer-J4O2ULWR.mjs → FunctionsContainer-AHHZODM5.mjs} +8 -12
- package/dist/lib/node-esm/FunctionsContainer-AHHZODM5.mjs.map +7 -0
- package/dist/lib/node-esm/{FunctionsPanel-SS6GIVNU.mjs → FunctionsPanel-V2DKWYMU.mjs} +2 -2
- package/dist/lib/node-esm/{app-graph-builder-4UCMXHYY.mjs → app-graph-builder-Z2TMQHVX.mjs} +4 -3
- package/dist/lib/node-esm/app-graph-builder-Z2TMQHVX.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-KWKWOGS5.mjs → chunk-AENSLAVD.mjs} +8 -12
- package/dist/lib/node-esm/chunk-AENSLAVD.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-LJAXQ6CX.mjs → chunk-EJPZWAGR.mjs} +14 -6
- package/dist/lib/node-esm/chunk-EJPZWAGR.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-7QRUPEHH.mjs → chunk-K5Z4UGIO.mjs} +5 -5
- package/dist/lib/node-esm/{chunk-K7GCM342.mjs → chunk-M3UPTGXF.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-2CKVH7JC.mjs → chunk-OJEFRZEV.mjs} +100 -42
- package/dist/lib/node-esm/chunk-OJEFRZEV.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-HQLVREIX.mjs → chunk-Q7EMIPMW.mjs} +18 -11
- package/dist/lib/node-esm/chunk-Q7EMIPMW.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +29 -28
- package/dist/lib/node-esm/cli/index.mjs.map +3 -3
- package/dist/lib/node-esm/{compute-runtime-ZHROOBLY.mjs → compute-runtime-6UEDBN76.mjs} +20 -15
- package/dist/lib/node-esm/compute-runtime-6UEDBN76.mjs.map +7 -0
- package/dist/lib/node-esm/hooks/index.mjs +1 -1
- package/dist/lib/node-esm/index.mjs +17 -16
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{operation-resolver-R5GA4YNO.mjs → operation-resolver-67CEAKXP.mjs} +5 -4
- package/dist/lib/node-esm/operation-resolver-67CEAKXP.mjs.map +7 -0
- package/dist/lib/node-esm/{react-surface-S6VZJCEZ.mjs → react-surface-U6762KPI.mjs} +10 -9
- package/dist/lib/node-esm/react-surface-U6762KPI.mjs.map +7 -0
- package/dist/types/src/AutomationPlugin.d.ts.map +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.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/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/FunctionsPanel/FunctionsPanel.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsRegistry/FunctionsRegistry.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerSettings.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- 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/testing/test-functions.d.ts +202 -2
- package/dist/types/src/testing/test-functions.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +48 -45
- package/src/AutomationPlugin.tsx +7 -6
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +3 -2
- package/src/capabilities/compute-runtime/compute-runtime.ts +19 -12
- package/src/capabilities/operation-resolver/operation-resolver.ts +4 -3
- package/src/capabilities/react-surface/react-surface.tsx +7 -6
- package/src/cli/commands/trigger/create/queue.ts +2 -2
- package/src/cli/commands/trigger/create/subscription.ts +2 -2
- package/src/cli/commands/trigger/create/timer.ts +2 -2
- package/src/cli/commands/trigger/list.ts +1 -1
- package/src/cli/commands/trigger/remove.ts +2 -2
- package/src/cli/commands/trigger/update/queue.ts +3 -3
- package/src/cli/commands/trigger/update/subscription.ts +3 -3
- package/src/cli/commands/trigger/update/timer.ts +3 -3
- package/src/cli/commands/trigger/util.ts +7 -7
- package/src/cli/plugin.ts +3 -2
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +1 -1
- package/src/components/AutomationPanel/AutomationPanel.tsx +131 -65
- package/src/components/AutomationSettings.tsx +5 -5
- package/src/components/FunctionsContainer.tsx +7 -7
- package/src/components/FunctionsPanel/FunctionsPanel.tsx +11 -10
- package/src/components/FunctionsRegistry/FunctionsRegistry.tsx +4 -5
- package/src/components/TriggerEditor/FunctionInputEditor.tsx +12 -3
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +3 -3
- package/src/components/TriggerSettings.tsx +5 -4
- package/src/hooks/useComputeRuntimeCallback.ts +1 -1
- package/src/hooks/useTriggerRuntimeControls.ts +22 -8
- 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-BFUIVUQH.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.map +0 -7
- 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-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/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/lib/browser/{AutomationPanel-FAS6ADCW.mjs.map → AutomationPanel-C6MZ22CB.mjs.map} +0 -0
- /package/dist/lib/browser/{FunctionsPanel-ZX4J75UM.mjs.map → FunctionsPanel-RD22LYMR.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-54PANILA.mjs.map → chunk-JFBUK3WR.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-BKFQBKYO.mjs.map → chunk-O5Y2F33G.mjs.map} +0 -0
- /package/dist/lib/node-esm/{AutomationPanel-B7NAGDFA.mjs.map → AutomationPanel-RTBY7YFM.mjs.map} +0 -0
- /package/dist/lib/node-esm/{FunctionsPanel-SS6GIVNU.mjs.map → FunctionsPanel-V2DKWYMU.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-7QRUPEHH.mjs.map → chunk-K5Z4UGIO.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-K7GCM342.mjs.map → chunk-M3UPTGXF.mjs.map} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/capabilities/compute-runtime/index.ts
|
|
2
2
|
import { Capability } from "@dxos/app-framework";
|
|
3
|
-
var ComputeRuntime = Capability.lazy("ComputeRuntime", () => import("./compute-runtime-
|
|
3
|
+
var ComputeRuntime = Capability.lazy("ComputeRuntime", () => import("./compute-runtime-BUBHYS4Y.mjs"));
|
|
4
4
|
|
|
5
5
|
export {
|
|
6
6
|
ComputeRuntime
|
|
7
7
|
};
|
|
8
|
-
//# sourceMappingURL=chunk-
|
|
8
|
+
//# sourceMappingURL=chunk-O5Y2F33G.mjs.map
|
|
@@ -7,7 +7,7 @@ import * as Cause from "effect/Cause";
|
|
|
7
7
|
import * as Effect from "effect/Effect";
|
|
8
8
|
import * as Exit from "effect/Exit";
|
|
9
9
|
import { useCallback } from "react";
|
|
10
|
-
import { useCapability } from "@dxos/app-framework/
|
|
10
|
+
import { useCapability } from "@dxos/app-framework/ui";
|
|
11
11
|
import { FunctionInvocationService, TracingService } from "@dxos/functions";
|
|
12
12
|
import { log } from "@dxos/log";
|
|
13
13
|
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-automation/src/hooks/useComputeRuntimeCallback.ts";
|
|
@@ -51,28 +51,35 @@ var invokeFunctionWithTracing = (functionDef, inputData) => Effect.gen(function*
|
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
// src/hooks/useTriggerRuntimeControls.ts
|
|
54
|
+
import { Atom, useAtomValue } from "@effect-atom/atom-react";
|
|
54
55
|
import * as Effect2 from "effect/Effect";
|
|
56
|
+
import { useEffect, useState } from "react";
|
|
55
57
|
import { Filter } from "@dxos/echo";
|
|
56
58
|
import { Trigger } from "@dxos/functions";
|
|
57
59
|
import { TriggerDispatcher } from "@dxos/functions-runtime";
|
|
58
60
|
import { useQuery } from "@dxos/react-client/echo";
|
|
59
|
-
import { useAsyncState } from "@dxos/react-ui";
|
|
60
61
|
var useTriggerRuntimeControls = (db) => {
|
|
61
62
|
const triggers = useQuery(db, Filter.type(Trigger.Trigger));
|
|
62
|
-
const [
|
|
63
|
+
const [dispatcher, setDispatcher] = useState(void 0);
|
|
64
|
+
const init = useComputeRuntimeCallback(db?.spaceId, Effect2.fnUntraced(function* () {
|
|
65
|
+
const dispatcher2 = yield* TriggerDispatcher;
|
|
66
|
+
setDispatcher(dispatcher2);
|
|
67
|
+
}));
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
void init();
|
|
70
|
+
}, []);
|
|
71
|
+
const state = useAtomValue(dispatcher?.state ?? Atom.make(void 0));
|
|
63
72
|
const start = useComputeRuntimeCallback(db?.spaceId, Effect2.fnUntraced(function* () {
|
|
64
|
-
const
|
|
65
|
-
yield*
|
|
66
|
-
setIsRunningState(true);
|
|
73
|
+
const dispatcher2 = yield* TriggerDispatcher;
|
|
74
|
+
yield* dispatcher2.start();
|
|
67
75
|
}));
|
|
68
76
|
const stop = useComputeRuntimeCallback(db?.spaceId, Effect2.fnUntraced(function* () {
|
|
69
|
-
const
|
|
70
|
-
yield*
|
|
71
|
-
setIsRunningState(false);
|
|
77
|
+
const dispatcher2 = yield* TriggerDispatcher;
|
|
78
|
+
yield* dispatcher2.stop();
|
|
72
79
|
}));
|
|
73
80
|
return {
|
|
74
81
|
triggers,
|
|
75
|
-
|
|
82
|
+
state,
|
|
76
83
|
start: () => void start(),
|
|
77
84
|
stop: () => void stop()
|
|
78
85
|
};
|
|
@@ -83,4 +90,4 @@ export {
|
|
|
83
90
|
invokeFunctionWithTracing,
|
|
84
91
|
useTriggerRuntimeControls
|
|
85
92
|
};
|
|
86
|
-
//# sourceMappingURL=chunk-
|
|
93
|
+
//# sourceMappingURL=chunk-P5AEO35Y.mjs.map
|
|
@@ -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
|
+
}
|
|
@@ -5,17 +5,16 @@ import {
|
|
|
5
5
|
// src/components/FunctionsPanel/FunctionsPanel.tsx
|
|
6
6
|
import * as Schema from "effect/Schema";
|
|
7
7
|
import React, { useCallback, useMemo } from "react";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { useOperationInvoker } from "@dxos/app-framework/ui";
|
|
9
|
+
import { LayoutOperation } from "@dxos/app-toolkit";
|
|
10
10
|
import { Obj } from "@dxos/echo";
|
|
11
11
|
import { Function, Script } from "@dxos/functions";
|
|
12
12
|
import { SpaceOperation } from "@dxos/plugin-space/types";
|
|
13
13
|
import { Filter, useQuery } from "@dxos/react-client/echo";
|
|
14
14
|
import { Button, IconButton, useTranslation } from "@dxos/react-ui";
|
|
15
|
-
import {
|
|
15
|
+
import { Settings } from "@dxos/react-ui-form";
|
|
16
16
|
import { List } from "@dxos/react-ui-list";
|
|
17
17
|
import { ghostHover, mx } from "@dxos/ui-theme";
|
|
18
|
-
var grid = "grid grid-cols-[1fr_auto] min-bs-[2.5rem]";
|
|
19
18
|
var FunctionsPanel = ({ space }) => {
|
|
20
19
|
const { t } = useTranslation(meta.id);
|
|
21
20
|
const functions = useQuery(space.db, Filter.type(Function.Function));
|
|
@@ -43,7 +42,7 @@ var FunctionsPanel = ({ space }) => {
|
|
|
43
42
|
const handleGoToScript = useCallback((func) => {
|
|
44
43
|
const script = functionToScriptMap[func.id];
|
|
45
44
|
if (script) {
|
|
46
|
-
void invokePromise(
|
|
45
|
+
void invokePromise(LayoutOperation.Open, {
|
|
47
46
|
subject: [
|
|
48
47
|
Obj.getDXN(script).toString()
|
|
49
48
|
]
|
|
@@ -60,10 +59,7 @@ var FunctionsPanel = ({ space }) => {
|
|
|
60
59
|
}), [
|
|
61
60
|
invokePromise
|
|
62
61
|
]);
|
|
63
|
-
return /* @__PURE__ */ React.createElement(
|
|
64
|
-
role: "none",
|
|
65
|
-
className: mx(controlItemClasses)
|
|
66
|
-
}, functions.length > 0 && /* @__PURE__ */ React.createElement(List.Root, {
|
|
62
|
+
return /* @__PURE__ */ React.createElement(Settings.Container, null, functions.length > 0 && /* @__PURE__ */ React.createElement(List.Root, {
|
|
67
63
|
items: functions,
|
|
68
64
|
isItem: Schema.is(Function.Function),
|
|
69
65
|
getId: (func) => func.id
|
|
@@ -73,7 +69,7 @@ var FunctionsPanel = ({ space }) => {
|
|
|
73
69
|
}, items?.map((func) => /* @__PURE__ */ React.createElement(List.Item, {
|
|
74
70
|
key: func.id,
|
|
75
71
|
item: func,
|
|
76
|
-
classNames: mx(grid
|
|
72
|
+
classNames: mx("grid grid-cols-[1fr_auto] min-bs-[2.5rem] min-bs-[3rem] pli-2 items-center", ghostHover)
|
|
77
73
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
78
74
|
className: "flex flex-col truncate"
|
|
79
75
|
}, /* @__PURE__ */ React.createElement(List.ItemTitle, {
|
|
@@ -88,7 +84,7 @@ var FunctionsPanel = ({ space }) => {
|
|
|
88
84
|
label: t("delete function button label"),
|
|
89
85
|
onClick: () => handleDelete(func)
|
|
90
86
|
}))))), functions.length === 0 && /* @__PURE__ */ React.createElement("div", {
|
|
91
|
-
className: "text-center plb-4 text-
|
|
87
|
+
className: "text-center plb-4 text-description"
|
|
92
88
|
}, t("no functions found")));
|
|
93
89
|
};
|
|
94
90
|
|
|
@@ -99,4 +95,4 @@ export {
|
|
|
99
95
|
FunctionsPanel,
|
|
100
96
|
FunctionsPanel_default
|
|
101
97
|
};
|
|
102
|
-
//# sourceMappingURL=chunk-
|
|
98
|
+
//# sourceMappingURL=chunk-QNEQ23BF.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/FunctionsPanel/FunctionsPanel.tsx", "../../../src/components/FunctionsPanel/index.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport React, { useCallback, useMemo } from 'react';\n\nimport { useOperationInvoker } from '@dxos/app-framework/ui';\nimport { LayoutOperation } from '@dxos/app-toolkit';\nimport { Obj } from '@dxos/echo';\nimport { Function, Script } from '@dxos/functions';\nimport { SpaceOperation } from '@dxos/plugin-space/types';\nimport { Filter, type Space, useQuery } from '@dxos/react-client/echo';\nimport { Button, IconButton, useTranslation } from '@dxos/react-ui';\nimport { Settings } from '@dxos/react-ui-form';\nimport { List } from '@dxos/react-ui-list';\nimport { ghostHover, mx } from '@dxos/ui-theme';\n\nimport { meta } from '../../meta';\n\nexport type FunctionsPanelProps = {\n space: Space;\n};\n\nexport const FunctionsPanel = ({ space }: FunctionsPanelProps) => {\n const { t } = useTranslation(meta.id);\n const functions = useQuery(space.db, Filter.type(Function.Function));\n const scripts = useQuery(space.db, Filter.type(Script.Script));\n const { invokePromise } = useOperationInvoker();\n\n const functionToScriptMap = useMemo(\n () =>\n functions.reduce(\n (map, func) => {\n const scriptId = func.source?.target?.id;\n if (scriptId) {\n const script = scripts.find((s) => s.id === scriptId);\n if (script) {\n map[func.id] = script;\n }\n }\n return map;\n },\n {} as Record<string, Script.Script>,\n ),\n [functions, scripts],\n );\n\n const getScriptName = useCallback(\n (func: Function.Function) => {\n const script = functionToScriptMap[func.id];\n return script?.name;\n },\n [functionToScriptMap],\n );\n\n const handleGoToScript = useCallback(\n (func: Function.Function) => {\n const script = functionToScriptMap[func.id];\n if (script) {\n void invokePromise(LayoutOperation.Open, { subject: [Obj.getDXN(script).toString()] });\n }\n },\n [functionToScriptMap, invokePromise],\n );\n\n const handleDelete = useCallback(\n (func: Function.Function) => invokePromise(SpaceOperation.RemoveObjects, { objects: [func] }),\n [invokePromise],\n );\n\n return (\n <Settings.Container>\n {functions.length > 0 && (\n <List.Root<Function.Function> items={functions} isItem={Schema.is(Function.Function)} getId={(func) => func.id}>\n {({ items }) => (\n <div role='list' className='flex flex-col is-full'>\n {items?.map((func) => (\n <List.Item<Function.Function>\n key={func.id}\n item={func}\n classNames={mx(\n 'grid grid-cols-[1fr_auto] min-bs-[2.5rem] min-bs-[3rem] pli-2 items-center',\n ghostHover,\n )}\n >\n <div className='flex flex-col truncate'>\n <List.ItemTitle classNames='truncate'>{func.name}</List.ItemTitle>\n {getScriptName(func) && (\n <div className='text-xs text-description truncate'>{getScriptName(func)}</div>\n )}\n </div>\n {functionToScriptMap[func.id] && (\n <Button onClick={() => handleGoToScript(func)}>{t('go to function source button label')}</Button>\n )}\n <IconButton\n iconOnly\n icon='ph--trash--regular'\n label={t('delete function button label')}\n onClick={() => handleDelete(func)}\n />\n </List.Item>\n ))}\n </div>\n )}\n </List.Root>\n )}\n\n {functions.length === 0 && <div className='text-center plb-4 text-description'>{t('no functions found')}</div>}\n </Settings.Container>\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { FunctionsPanel } from './FunctionsPanel';\n\nexport * from './FunctionsPanel';\nexport default FunctionsPanel;\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["Schema", "React", "useCallback", "useMemo", "useOperationInvoker", "LayoutOperation", "Obj", "Function", "Script", "SpaceOperation", "Filter", "useQuery", "Button", "IconButton", "useTranslation", "Settings", "List", "ghostHover", "mx", "FunctionsPanel", "space", "t", "useTranslation", "meta", "id", "functions", "useQuery", "db", "Filter", "type", "Function", "scripts", "Script", "invokePromise", "useOperationInvoker", "functionToScriptMap", "useMemo", "reduce", "map", "func", "scriptId", "source", "target", "script", "find", "s", "getScriptName", "useCallback", "name", "handleGoToScript", "LayoutOperation", "Open", "subject", "Obj", "getDXN", "toString", "handleDelete", "SpaceOperation", "RemoveObjects", "objects", "Settings", "Container", "length", "List", "Root", "items", "isItem", "is", "getId", "div", "role", "className", "Item", "key", "item", "classNames", "mx", "ghostHover", "ItemTitle", "Button", "onClick", "IconButton", "iconOnly", "icon", "label", "FunctionsPanel"]
|
|
7
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ComputeRuntime
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-O5Y2F33G.mjs";
|
|
4
4
|
import {
|
|
5
5
|
AutomationEvents
|
|
6
6
|
} from "../chunk-JOXPQ27I.mjs";
|
|
@@ -9,7 +9,8 @@ import {
|
|
|
9
9
|
} from "../chunk-PZNBEKO5.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
|
|
@@ -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,7 +267,7 @@ 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"
|
|
@@ -283,7 +284,7 @@ var selectQueue = Effect.fn(function* () {
|
|
|
283
284
|
for (const schema of queueSchemas) {
|
|
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
289
|
const queueRef = obj.queue;
|
|
289
290
|
if (!queueRef) {
|
|
@@ -326,7 +327,7 @@ var queue = Command.make("queue", {
|
|
|
326
327
|
onNone: () => selectFunction(),
|
|
327
328
|
onSome: (id) => Effect2.succeed(id)
|
|
328
329
|
});
|
|
329
|
-
const functions = yield* Database2.
|
|
330
|
+
const functions = yield* Database2.runQuery(Filter2.type(Function2.Function));
|
|
330
331
|
const fn6 = functions.find((fn7) => fn7.id === functionId);
|
|
331
332
|
if (!fn6) {
|
|
332
333
|
return yield* Effect2.fail(new Error(`Function not found: ${functionId}`));
|
|
@@ -355,7 +356,7 @@ var queue = Command.make("queue", {
|
|
|
355
356
|
},
|
|
356
357
|
input
|
|
357
358
|
});
|
|
358
|
-
yield* Database2.
|
|
359
|
+
yield* Database2.add(trigger2);
|
|
359
360
|
if (json) {
|
|
360
361
|
yield* Console2.log(JSON.stringify(trigger2, null, 2));
|
|
361
362
|
} else {
|
|
@@ -393,7 +394,7 @@ var subscription = Command2.make("subscription", {
|
|
|
393
394
|
onNone: () => selectFunction(),
|
|
394
395
|
onSome: (id) => Effect3.succeed(id)
|
|
395
396
|
});
|
|
396
|
-
const functions = yield* Database3.
|
|
397
|
+
const functions = yield* Database3.runQuery(Filter3.type(Function3.Function));
|
|
397
398
|
const fn6 = functions.find((fn7) => fn7.id === functionId);
|
|
398
399
|
if (!fn6) {
|
|
399
400
|
return yield* Effect3.fail(new Error(`Function not found: ${functionId}`));
|
|
@@ -451,7 +452,7 @@ var subscription = Command2.make("subscription", {
|
|
|
451
452
|
},
|
|
452
453
|
input
|
|
453
454
|
});
|
|
454
|
-
yield* Database3.
|
|
455
|
+
yield* Database3.add(trigger2);
|
|
455
456
|
if (json) {
|
|
456
457
|
yield* Console3.log(JSON.stringify(trigger2, null, 2));
|
|
457
458
|
} else {
|
|
@@ -487,7 +488,7 @@ var timer = Command3.make("timer", {
|
|
|
487
488
|
onNone: () => selectFunction(),
|
|
488
489
|
onSome: (id) => Effect4.succeed(id)
|
|
489
490
|
});
|
|
490
|
-
const functions = yield* Database4.
|
|
491
|
+
const functions = yield* Database4.runQuery(Filter4.type(Function4.Function));
|
|
491
492
|
const fn6 = functions.find((fn7) => fn7.id === functionId);
|
|
492
493
|
if (!fn6) {
|
|
493
494
|
return yield* Effect4.fail(new Error(`Function not found: ${functionId}`));
|
|
@@ -518,7 +519,7 @@ var timer = Command3.make("timer", {
|
|
|
518
519
|
},
|
|
519
520
|
input
|
|
520
521
|
});
|
|
521
|
-
yield* Database4.
|
|
522
|
+
yield* Database4.add(trigger2);
|
|
522
523
|
if (json) {
|
|
523
524
|
yield* Console4.log(JSON.stringify(trigger2, null, 2));
|
|
524
525
|
} else {
|
|
@@ -549,7 +550,7 @@ var list = Command5.make("list", {
|
|
|
549
550
|
spaceId: Common4.spaceId.pipe(Options5.optional)
|
|
550
551
|
}, Effect5.fn(function* ({ spaceId: spaceIdOption }) {
|
|
551
552
|
const { json } = yield* CommandConfig4;
|
|
552
|
-
const triggers = yield* Database5.
|
|
553
|
+
const triggers = yield* Database5.runQuery(Filter5.type(Trigger5.Trigger));
|
|
553
554
|
const remoteCronIds = yield* Effect5.gen(function* () {
|
|
554
555
|
const client = yield* ClientService;
|
|
555
556
|
const spaceId = yield* spaceIdWithDefault(spaceIdOption);
|
|
@@ -597,8 +598,8 @@ var remove = Command6.make("remove", {
|
|
|
597
598
|
onSome: (id) => Effect6.succeed(id)
|
|
598
599
|
});
|
|
599
600
|
const dxn = DXN2.fromLocalObjectId(triggerId);
|
|
600
|
-
const trigger2 = yield* Database6.
|
|
601
|
-
yield* Database6.
|
|
601
|
+
const trigger2 = yield* Database6.resolve(dxn, Trigger6.Trigger);
|
|
602
|
+
yield* Database6.remove(trigger2);
|
|
602
603
|
if (json) {
|
|
603
604
|
yield* Console6.log(JSON.stringify({
|
|
604
605
|
id: trigger2.id,
|
|
@@ -638,7 +639,7 @@ var queue2 = Command7.make("queue", {
|
|
|
638
639
|
onSome: (id) => Effect7.succeed(id)
|
|
639
640
|
});
|
|
640
641
|
const dxn = DXN3.fromLocalObjectId(triggerId);
|
|
641
|
-
const trigger2 = yield* Database7.
|
|
642
|
+
const trigger2 = yield* Database7.resolve(dxn, Trigger7.Trigger);
|
|
642
643
|
if (trigger2.spec?.kind !== "queue") {
|
|
643
644
|
return yield* Effect7.fail(new Error(`Invalid trigger type: ${trigger2.spec?.kind}`));
|
|
644
645
|
}
|
|
@@ -656,7 +657,7 @@ var queue2 = Command7.make("queue", {
|
|
|
656
657
|
});
|
|
657
658
|
})).pipe(Command7.withDescription("Update a queue trigger."), Command7.provide(({ spaceId }) => spaceLayer6(spaceId, true)), Command7.provideEffectDiscard(() => withTypes5(Function5.Function, Trigger7.Trigger)));
|
|
658
659
|
var updateFunction = Effect7.fn(function* (trigger2, functionIdOption) {
|
|
659
|
-
let currentFn = trigger2.function ? yield* Database7.
|
|
660
|
+
let currentFn = trigger2.function ? yield* Database7.load(trigger2.function) : void 0;
|
|
660
661
|
if (currentFn && !Obj2.instanceOf(Function5.Function, currentFn)) {
|
|
661
662
|
currentFn = void 0;
|
|
662
663
|
}
|
|
@@ -673,7 +674,7 @@ var updateFunction = Effect7.fn(function* (trigger2, functionIdOption) {
|
|
|
673
674
|
onNone: () => selectFunction(),
|
|
674
675
|
onSome: (id) => Effect7.succeed(id)
|
|
675
676
|
});
|
|
676
|
-
const functions = yield* Database7.
|
|
677
|
+
const functions = yield* Database7.runQuery(Filter6.type(Function5.Function));
|
|
677
678
|
const foundFn = functions.find((fn6) => fn6.id === functionId);
|
|
678
679
|
if (!foundFn || !Obj2.instanceOf(Function5.Function, foundFn)) {
|
|
679
680
|
return yield* Effect7.fail(new Error(`Function not found: ${functionId}`));
|
|
@@ -776,7 +777,7 @@ var subscription2 = Command8.make("subscription", {
|
|
|
776
777
|
onSome: (id) => Effect8.succeed(id)
|
|
777
778
|
});
|
|
778
779
|
const dxn = DXN4.fromLocalObjectId(triggerId);
|
|
779
|
-
const trigger2 = yield* Database8.
|
|
780
|
+
const trigger2 = yield* Database8.resolve(dxn, Trigger8.Trigger);
|
|
780
781
|
if (trigger2.spec?.kind !== "subscription") {
|
|
781
782
|
return yield* Effect8.fail(new Error(`Invalid trigger type: ${trigger2.spec?.kind}`));
|
|
782
783
|
}
|
|
@@ -804,7 +805,7 @@ var extractCurrentTypename = (spec) => {
|
|
|
804
805
|
}, (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
806
|
};
|
|
806
807
|
var updateFunction2 = Effect8.fn(function* (trigger2, functionIdOption) {
|
|
807
|
-
let currentFn = trigger2.function ? yield* Database8.
|
|
808
|
+
let currentFn = trigger2.function ? yield* Database8.load(trigger2.function) : void 0;
|
|
808
809
|
if (currentFn && !Obj3.instanceOf(Function6.Function, currentFn)) {
|
|
809
810
|
currentFn = void 0;
|
|
810
811
|
}
|
|
@@ -821,7 +822,7 @@ var updateFunction2 = Effect8.fn(function* (trigger2, functionIdOption) {
|
|
|
821
822
|
onNone: () => selectFunction(),
|
|
822
823
|
onSome: (id) => Effect8.succeed(id)
|
|
823
824
|
});
|
|
824
|
-
const functions = yield* Database8.
|
|
825
|
+
const functions = yield* Database8.runQuery(Filter7.type(Function6.Function));
|
|
825
826
|
const foundFn = functions.find((fn6) => fn6.id === functionId);
|
|
826
827
|
if (!foundFn || !Obj3.instanceOf(Function6.Function, foundFn)) {
|
|
827
828
|
return yield* Effect8.fail(new Error(`Function not found: ${functionId}`));
|
|
@@ -964,7 +965,7 @@ var timer2 = Command9.make("timer", {
|
|
|
964
965
|
onSome: (id) => Effect9.succeed(id)
|
|
965
966
|
});
|
|
966
967
|
const dxn = DXN5.fromLocalObjectId(triggerId);
|
|
967
|
-
const trigger2 = yield* Database9.
|
|
968
|
+
const trigger2 = yield* Database9.resolve(dxn, Trigger9.Trigger);
|
|
968
969
|
if (!trigger2.spec || trigger2.spec?.kind !== "timer") {
|
|
969
970
|
return yield* Effect9.fail(new Error(`Invalid trigger type: ${trigger2.spec?.kind}`));
|
|
970
971
|
}
|
|
@@ -982,7 +983,7 @@ var timer2 = Command9.make("timer", {
|
|
|
982
983
|
});
|
|
983
984
|
})).pipe(Command9.withDescription("Update a timer trigger."), Command9.provide(({ spaceId }) => spaceLayer8(spaceId, true)), Command9.provideEffectDiscard(() => withTypes7(Function7.Function, Trigger9.Trigger)));
|
|
984
985
|
var updateFunction3 = Effect9.fn(function* (trigger2, functionIdOption) {
|
|
985
|
-
let currentFn = trigger2.function ? yield* Database9.
|
|
986
|
+
let currentFn = trigger2.function ? yield* Database9.load(trigger2.function) : void 0;
|
|
986
987
|
if (currentFn && !Obj4.instanceOf(Function7.Function, currentFn)) {
|
|
987
988
|
currentFn = void 0;
|
|
988
989
|
}
|
|
@@ -999,7 +1000,7 @@ var updateFunction3 = Effect9.fn(function* (trigger2, functionIdOption) {
|
|
|
999
1000
|
onNone: () => selectFunction(),
|
|
1000
1001
|
onSome: (id) => Effect9.succeed(id)
|
|
1001
1002
|
});
|
|
1002
|
-
const functions = yield* Database9.
|
|
1003
|
+
const functions = yield* Database9.runQuery(Filter8.type(Function7.Function));
|
|
1003
1004
|
const foundFn = functions.find((fn6) => fn6.id === functionId);
|
|
1004
1005
|
if (!foundFn || !Obj4.instanceOf(Function7.Function, foundFn)) {
|
|
1005
1006
|
return yield* Effect9.fail(new Error(`Function not found: ${functionId}`));
|
|
@@ -1090,7 +1091,7 @@ var trigger = Command11.make("trigger").pipe(Command11.withDescription("Manage E
|
|
|
1090
1091
|
]));
|
|
1091
1092
|
|
|
1092
1093
|
// src/cli/plugin.ts
|
|
1093
|
-
var AutomationPlugin = Plugin.define(meta).pipe(
|
|
1094
|
+
var AutomationPlugin = Plugin.define(meta).pipe(AppPlugin.addCommandModule({
|
|
1094
1095
|
commands: [
|
|
1095
1096
|
trigger
|
|
1096
1097
|
]
|