@dxos/plugin-automation 0.8.4-main.9be5663bfe → 0.8.4-main.abd8ff62ef
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/{chunk-WQLEMRPU.mjs → chunk-CHUTFU3D.mjs} +1 -1
- package/dist/lib/browser/chunk-CHUTFU3D.mjs.map +7 -0
- package/dist/lib/browser/{chunk-POEIL4RN.mjs → chunk-RE64VLSV.mjs} +3 -3
- package/dist/lib/browser/{chunk-POEIL4RN.mjs.map → chunk-RE64VLSV.mjs.map} +3 -3
- package/dist/lib/browser/{create-trigger-from-template-JZ62EZTB.mjs → create-trigger-from-template-JLBSJRVB.mjs} +9 -16
- package/dist/lib/browser/create-trigger-from-template-JLBSJRVB.mjs.map +7 -0
- package/dist/lib/browser/hooks/index.mjs +61 -17
- package/dist/lib/browser/hooks/index.mjs.map +3 -3
- package/dist/lib/browser/index.mjs +6 -71
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operations/index.mjs +4 -4
- package/dist/lib/browser/operations/index.mjs.map +3 -3
- package/dist/lib/browser/translations.mjs +47 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/{chunk-SP3P4OUI.mjs → chunk-HHIHREME.mjs} +3 -3
- package/dist/lib/node-esm/{chunk-SP3P4OUI.mjs.map → chunk-HHIHREME.mjs.map} +3 -3
- package/dist/lib/node-esm/{chunk-JWZAVQLF.mjs → chunk-NWQMBY32.mjs} +1 -1
- package/dist/lib/node-esm/chunk-NWQMBY32.mjs.map +7 -0
- package/dist/lib/node-esm/{create-trigger-from-template-224Z7WJI.mjs → create-trigger-from-template-FUQ3LUIF.mjs} +9 -16
- package/dist/lib/node-esm/create-trigger-from-template-FUQ3LUIF.mjs.map +7 -0
- package/dist/lib/node-esm/hooks/index.mjs +61 -17
- package/dist/lib/node-esm/hooks/index.mjs.map +3 -3
- package/dist/lib/node-esm/index.mjs +6 -71
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operations/index.mjs +4 -4
- package/dist/lib/node-esm/operations/index.mjs.map +3 -3
- package/dist/lib/node-esm/translations.mjs +48 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +1 -1
- package/dist/types/src/AutomationPlugin.d.ts +1 -0
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- package/dist/types/src/{cli/plugin.d.ts → AutomationPlugin.node.d.ts} +2 -1
- package/dist/types/src/AutomationPlugin.node.d.ts.map +1 -0
- package/dist/types/src/AutomationPlugin.test.d.ts +2 -0
- package/dist/types/src/AutomationPlugin.test.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/compute-runtime.d.ts +8 -0
- package/dist/types/src/capabilities/compute-runtime.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +1 -1
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/node.d.ts +3 -0
- package/dist/types/src/capabilities/node.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/commands/index.d.ts.map +1 -0
- package/dist/types/src/{cli/commands → commands}/trigger/create/index.d.ts +6 -6
- package/dist/types/src/commands/trigger/create/index.d.ts.map +1 -0
- package/dist/types/src/{cli/commands → commands}/trigger/create/queue.d.ts +1 -1
- package/dist/types/src/commands/trigger/create/queue.d.ts.map +1 -0
- package/dist/types/src/{cli/commands → commands}/trigger/create/subscription.d.ts +1 -1
- package/dist/types/src/commands/trigger/create/subscription.d.ts.map +1 -0
- package/dist/types/src/{cli/commands → commands}/trigger/create/timer.d.ts +1 -1
- package/dist/types/src/commands/trigger/create/timer.d.ts.map +1 -0
- package/dist/types/src/{cli/commands → commands}/trigger/index.d.ts +7 -7
- package/dist/types/src/commands/trigger/index.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/list.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/options.d.ts.map +1 -0
- package/dist/types/src/{cli/commands → commands}/trigger/remove.d.ts +1 -1
- package/dist/types/src/commands/trigger/remove.d.ts.map +1 -0
- package/dist/types/src/{cli/commands → commands}/trigger/update/index.d.ts +5 -5
- package/dist/types/src/commands/trigger/update/index.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/update/queue.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/update/subscription.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/update/timer.d.ts.map +1 -0
- package/dist/types/src/{cli/commands → commands}/trigger/util.d.ts +2 -2
- package/dist/types/src/commands/trigger/util.d.ts.map +1 -0
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts +32 -29
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/index.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsPanel/index.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.map +1 -1
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts +5 -5
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts +4 -4
- package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +95 -91
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
- package/dist/types/src/containers/AutomationSettings/AutomationSettings.d.ts +3 -1
- package/dist/types/src/containers/AutomationSettings/AutomationSettings.d.ts.map +1 -1
- package/dist/types/src/containers/FunctionsContainer/FunctionsContainer.d.ts +2 -4
- package/dist/types/src/containers/FunctionsContainer/FunctionsContainer.d.ts.map +1 -1
- package/dist/types/src/containers/TriggerSettings/TriggerSettings.d.ts +3 -3
- package/dist/types/src/containers/TriggerSettings/TriggerSettings.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeRuntime.d.ts +1 -0
- package/dist/types/src/hooks/useComputeRuntime.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeRuntimeService.d.ts +14 -2
- package/dist/types/src/hooks/useComputeRuntimeService.d.ts.map +1 -1
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts +1 -1
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/operations/create-trigger-from-template.d.ts +1 -1
- package/dist/types/src/operations/create-trigger-from-template.d.ts.map +1 -1
- package/dist/types/src/operations/definitions.d.ts +4 -4
- package/dist/types/src/operations/definitions.d.ts.map +1 -1
- package/dist/types/src/operations/index.d.ts +1 -1
- package/dist/types/src/operations/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-functions.d.ts +77 -77
- package/dist/types/src/translations.d.ts +32 -30
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +6 -7
- package/dist/types/src/types/capabilities.d.ts.map +1 -1
- package/dist/types/src/types/events.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +60 -60
- package/src/{cli/plugin.ts → AutomationPlugin.node.ts} +8 -2
- package/src/AutomationPlugin.test.ts +27 -0
- package/src/AutomationPlugin.tsx +6 -6
- package/src/capabilities/app-graph-builder.ts +10 -6
- package/src/capabilities/compute-runtime.ts +216 -139
- package/src/capabilities/index.ts +1 -1
- package/src/capabilities/node.ts +6 -0
- package/src/capabilities/operation-handler.ts +1 -1
- package/src/capabilities/react-surface.tsx +6 -6
- package/src/{cli/commands → commands}/trigger/create/queue.ts +2 -6
- package/src/{cli/commands → commands}/trigger/create/subscription.ts +6 -10
- package/src/{cli/commands → commands}/trigger/create/timer.ts +2 -6
- package/src/{cli/commands → commands}/trigger/list.ts +5 -3
- package/src/{cli/commands → commands}/trigger/remove.ts +1 -1
- package/src/{cli/commands → commands}/trigger/update/queue.ts +5 -6
- package/src/{cli/commands → commands}/trigger/update/subscription.ts +5 -6
- package/src/{cli/commands → commands}/trigger/update/timer.ts +5 -6
- package/src/{cli/commands → commands}/trigger/util.ts +5 -4
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +2 -3
- package/src/components/AutomationPanel/AutomationPanel.tsx +9 -6
- package/src/components/FunctionsPanel/FunctionsPanel.tsx +1 -2
- package/src/components/FunctionsRegistry/FunctionsRegistry.tsx +1 -1
- package/src/components/TriggerEditor/FunctionInputEditor.tsx +1 -1
- package/src/components/TriggerEditor/SpecSelector.tsx +6 -11
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +4 -5
- package/src/components/TriggerEditor/TriggerEditor.tsx +2 -3
- package/src/containers/AutomationSettings/AutomationSettings.tsx +5 -2
- package/src/containers/FunctionsContainer/FunctionsContainer.tsx +3 -4
- package/src/containers/TriggerSettings/TriggerSettings.tsx +29 -7
- package/src/hooks/useComputeRuntime.ts +17 -3
- package/src/hooks/useComputeRuntimeService.ts +49 -9
- package/src/hooks/useTriggerRuntimeControls.ts +6 -3
- package/src/index.ts +5 -1
- package/src/operations/create-trigger-from-template.ts +6 -10
- package/src/operations/definitions.ts +1 -1
- package/src/operations/index.ts +1 -1
- package/src/translations.ts +8 -6
- package/src/types/capabilities.ts +9 -18
- package/dist/lib/browser/chunk-WQLEMRPU.mjs.map +0 -7
- package/dist/lib/browser/cli/index.mjs +0 -1122
- package/dist/lib/browser/cli/index.mjs.map +0 -7
- package/dist/lib/browser/create-trigger-from-template-JZ62EZTB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JWZAVQLF.mjs.map +0 -7
- package/dist/lib/node-esm/cli/index.mjs +0 -1123
- package/dist/lib/node-esm/cli/index.mjs.map +0 -7
- package/dist/lib/node-esm/create-trigger-from-template-224Z7WJI.mjs.map +0 -7
- package/dist/types/src/cli/commands/index.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/create/index.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/create/queue.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/create/subscription.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/create/timer.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/index.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/list.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/options.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/remove.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/update/index.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/update/queue.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/update/subscription.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/update/timer.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/util.d.ts.map +0 -1
- package/dist/types/src/cli/index.d.ts +0 -2
- package/dist/types/src/cli/index.d.ts.map +0 -1
- package/dist/types/src/cli/plugin.d.ts.map +0 -1
- package/src/cli/index.ts +0 -5
- /package/dist/types/src/{cli/commands → commands}/index.d.ts +0 -0
- /package/dist/types/src/{cli/commands → commands}/trigger/list.d.ts +0 -0
- /package/dist/types/src/{cli/commands → commands}/trigger/options.d.ts +0 -0
- /package/dist/types/src/{cli/commands → commands}/trigger/update/queue.d.ts +0 -0
- /package/dist/types/src/{cli/commands → commands}/trigger/update/subscription.d.ts +0 -0
- /package/dist/types/src/{cli/commands → commands}/trigger/update/timer.d.ts +0 -0
- /package/src/{cli/commands → commands}/index.ts +0 -0
- /package/src/{cli/commands → commands}/trigger/create/index.ts +0 -0
- /package/src/{cli/commands → commands}/trigger/index.ts +0 -0
- /package/src/{cli/commands → commands}/trigger/options.ts +0 -0
- /package/src/{cli/commands → commands}/trigger/update/index.ts +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/types/capabilities.ts", "../../../src/types/events.ts", "../../../src/types/schema.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as ManagedRuntime from 'effect/ManagedRuntime';\n\nimport { type AiService, type OpaqueToolkit } from '@dxos/ai';\nimport { Capability } from '@dxos/app-framework';\nimport type { Blueprint, Credential, Operation, OperationRegistry, Process } from '@dxos/compute';\nimport { type Database, type Feed } from '@dxos/echo';\nimport type { QueueService } from '@dxos/functions';\nimport { AgentService } from '@dxos/functions-runtime';\nimport type { ProcessManager, TriggerDispatcher, TriggerStateStore } from '@dxos/functions-runtime';\nimport type { SpaceId } from '@dxos/keys';\n\nimport { meta } from '#meta';\n\nexport namespace AutomationCapabilities {\n /**\n * Service stack for executing agents, functions, and triggers.\n */\n export type ComputeServices =\n | TriggerDispatcher\n | TriggerStateStore\n | AiService.AiService\n | Database.Service\n | Feed.FeedService\n | QueueService\n | Credential.CredentialsService\n | Blueprint.RegistryService\n | AgentService.AgentService\n | Process.ProcessMonitorService\n | ProcessManager.Service\n | Operation.Service\n | OperationRegistry.Service\n | OpaqueToolkit.OpaqueToolkitProvider;\n\n export type ComputeRuntime = ManagedRuntime.ManagedRuntime<AutomationCapabilities.ComputeServices, never>;\n export interface ComputeRuntimeProvider {\n getRuntime(spaceId: SpaceId): ComputeRuntime;\n }\n\n /**\n * Runtime for executing agents, functions, and triggers.\n */\n export const ComputeRuntime = Capability.make<ComputeRuntimeProvider>(`${meta.id}.capability.compute-runtime`);\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { ActivationEvent } from '@dxos/app-framework';\n\nimport { meta } from '#meta';\n\nexport namespace AutomationEvents {\n export const ComputeRuntimeReady = ActivationEvent.make(`${meta.id}.event.compute-runtime-ready`);\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Database } from '@dxos/echo';\n\nimport { meta } from '#meta';\n\nexport const TriggerTemplate = Schema.Union(\n Schema.Struct({ type: Schema.Literal('timer'), cron: Schema.String }),\n Schema.Struct({ type: Schema.Literal('queue'), queueDXN: Schema.Any }),\n);\n\nexport namespace AutomationAction {\n export class CreateTriggerFromTemplate extends Schema.TaggedClass<CreateTriggerFromTemplate>()(\n `${meta.id}.action.create-trigger-from-template`,\n {\n input: Schema.Struct({\n db: Database.Database,\n template: TriggerTemplate,\n enabled: Schema.optional(Schema.Boolean),\n // TODO(wittjosiah): Improve how this lookup is done.\n scriptName: Schema.optional(Schema.String),\n input: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),\n }),\n output: Schema.Void,\n },\n ) {}\n}\n"],
|
|
5
|
+
"mappings": ";AAOA,SAASA,kBAAkB;AAQ3B,SAASC,YAAY;UAEJC,yBAAAA;0BA4BFC,iBAAiBH,WAAWI,KAA6B,GAAGH,KAAKI,EAAE,6BAA6B;AAC/G,GA7BiBH,2BAAAA,yBAAAA,CAAAA,EAAAA;;;;ACbjB,SAASI,uBAAuB;AAEhC,SAASC,QAAAA,aAAY;UAEJC,mBAAAA;oBACFC,sBAAsBH,gBAAgBI,KAAK,GAAGH,MAAKI,EAAE,8BAA8B;AAClG,GAFiBH,qBAAAA,mBAAAA,CAAAA,EAAAA;;;;ACJjB,YAAYI,YAAY;AAExB,SAASC,gBAAgB;AAEzB,SAASC,QAAAA,aAAY;AAEd,IAAMC,kBAAyBC,aAC7BC,cAAO;EAAEC,MAAaC,eAAQ,OAAA;EAAUC,MAAaC;AAAO,CAAA,GAC5DJ,cAAO;EAAEC,MAAaC,eAAQ,OAAA;EAAUG,UAAiBC;AAAI,CAAA,CAAA;UAGrDC,mBAAAA;EACR,MAAMC,kCAAyCC,mBAAW,EAC/D,GAAGZ,MAAKa,EAAE,wCACV;IACEC,OAAcX,cAAO;MACnBY,IAAIhB,SAASA;MACbiB,UAAUf;MACVgB,SAAgBC,gBAAgBC,cAAO;;MAEvCC,YAAmBF,gBAAgBX,aAAM;MACzCO,OAAcI,gBAAgBG,cAAO;QAAEC,KAAYf;QAAQgB,OAAcd;MAAI,CAAA,CAAA;IAC/E,CAAA;IACAe,QAAeC;EACjB,CAAA,EAAA;EACC;oBAbUd,4BAAAA;AAcf,GAfiBD,qBAAAA,mBAAAA,CAAAA,EAAAA;;",
|
|
6
|
+
"names": ["Capability", "meta", "AutomationCapabilities", "ComputeRuntime", "make", "id", "ActivationEvent", "meta", "AutomationEvents", "ComputeRuntimeReady", "make", "id", "Schema", "Database", "meta", "TriggerTemplate", "Union", "Struct", "type", "Literal", "cron", "String", "queueDXN", "Any", "AutomationAction", "CreateTriggerFromTemplate", "TaggedClass", "id", "input", "db", "template", "enabled", "optional", "Boolean", "scriptName", "Record", "key", "value", "output", "Void"]
|
|
7
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TriggerTemplate
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CHUTFU3D.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__export
|
|
6
6
|
} from "./chunk-J5LGTIGS.mjs";
|
|
@@ -12,8 +12,8 @@ __export(definitions_exports, {
|
|
|
12
12
|
});
|
|
13
13
|
import * as Schema from "effect/Schema";
|
|
14
14
|
import { Capability } from "@dxos/app-framework";
|
|
15
|
+
import { Operation } from "@dxos/compute";
|
|
15
16
|
import { Database } from "@dxos/echo";
|
|
16
|
-
import { Operation } from "@dxos/operation";
|
|
17
17
|
import { meta } from "#meta";
|
|
18
18
|
var AUTOMATION_OPERATION = `${meta.id}.operation`;
|
|
19
19
|
var CreateTriggerFromTemplate = Operation.make({
|
|
@@ -41,4 +41,4 @@ export {
|
|
|
41
41
|
CreateTriggerFromTemplate,
|
|
42
42
|
definitions_exports
|
|
43
43
|
};
|
|
44
|
-
//# sourceMappingURL=chunk-
|
|
44
|
+
//# sourceMappingURL=chunk-RE64VLSV.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/operations/definitions.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Capability } from '@dxos/app-framework';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;AAAA;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,kBAAkB;AAC3B,SAASC,
|
|
6
|
-
"names": ["Schema", "Capability", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Capability } from '@dxos/app-framework';\nimport { Operation } from '@dxos/compute';\nimport { Database } from '@dxos/echo';\n\nimport { meta } from '#meta';\n\nimport { TriggerTemplate } from '../types';\n\nconst AUTOMATION_OPERATION = `${meta.id}.operation`;\n\nexport const CreateTriggerFromTemplate = Operation.make({\n meta: { key: `${AUTOMATION_OPERATION}.create-trigger-from-template`, name: 'Create Trigger From Template' },\n services: [Capability.Service],\n input: Schema.Struct({\n db: Database.Database,\n template: TriggerTemplate,\n enabled: Schema.optional(Schema.Boolean),\n scriptName: Schema.optional(Schema.String),\n input: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),\n }),\n output: Schema.Void,\n});\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAAA;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,kBAAkB;AAC3B,SAASC,iBAAiB;AAC1B,SAASC,gBAAgB;AAEzB,SAASC,YAAY;AAIrB,IAAMC,uBAAuB,GAAGC,KAAKC,EAAE;AAEhC,IAAMC,4BAA4BC,UAAUC,KAAK;EACtDJ,MAAM;IAAEK,KAAK,GAAGN,oBAAAA;IAAqDO,MAAM;EAA+B;EAC1GC,UAAU;IAACC,WAAWC;;EACtBC,OAAcC,cAAO;IACnBC,IAAIC,SAASA;IACbC,UAAUC;IACVC,SAAgBC,gBAAgBC,cAAO;IACvCC,YAAmBF,gBAAgBG,aAAM;IACzCV,OAAcO,gBAAgBI,cAAO;MAAEhB,KAAYe;MAAQE,OAAcC;IAAI,CAAA,CAAA;EAC/E,CAAA;EACAC,QAAeC;AACjB,CAAA;",
|
|
6
|
+
"names": ["Schema", "Capability", "Operation", "Database", "meta", "AUTOMATION_OPERATION", "meta", "id", "CreateTriggerFromTemplate", "Operation", "make", "key", "name", "services", "Capability", "Service", "input", "Struct", "db", "Database", "template", "TriggerTemplate", "enabled", "optional", "Boolean", "scriptName", "String", "Record", "value", "Any", "output", "Void"]
|
|
7
7
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CreateTriggerFromTemplate
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-RE64VLSV.mjs";
|
|
4
|
+
import "./chunk-CHUTFU3D.mjs";
|
|
5
5
|
import "./chunk-J5LGTIGS.mjs";
|
|
6
6
|
|
|
7
7
|
// src/operations/create-trigger-from-template.ts
|
|
8
8
|
import * as Effect from "effect/Effect";
|
|
9
9
|
import { LayoutOperation, getSpacePath } from "@dxos/app-toolkit";
|
|
10
|
+
import { Operation, Script, Trigger } from "@dxos/compute";
|
|
10
11
|
import { Obj, Ref } from "@dxos/echo";
|
|
11
|
-
import { Script, Trigger } from "@dxos/functions";
|
|
12
|
-
import { Operation } from "@dxos/operation";
|
|
13
12
|
import { SpaceOperation } from "@dxos/plugin-space/operations";
|
|
14
13
|
import { Filter } from "@dxos/react-client/echo";
|
|
15
14
|
import { meta } from "#meta";
|
|
@@ -29,7 +28,7 @@ var handler = CreateTriggerFromTemplate.pipe(Operation.withHandler(Effect.fnUntr
|
|
|
29
28
|
})).run());
|
|
30
29
|
const [fn] = functions;
|
|
31
30
|
if (fn) {
|
|
32
|
-
Obj.
|
|
31
|
+
Obj.update(trigger, (trigger2) => {
|
|
33
32
|
trigger2.function = Ref.make(fn);
|
|
34
33
|
});
|
|
35
34
|
}
|
|
@@ -37,20 +36,14 @@ var handler = CreateTriggerFromTemplate.pipe(Operation.withHandler(Effect.fnUntr
|
|
|
37
36
|
}
|
|
38
37
|
switch (template.type) {
|
|
39
38
|
case "timer": {
|
|
40
|
-
Obj.
|
|
41
|
-
trigger2.spec =
|
|
42
|
-
kind: "timer",
|
|
43
|
-
cron: template.cron
|
|
44
|
-
};
|
|
39
|
+
Obj.update(trigger, (trigger2) => {
|
|
40
|
+
trigger2.spec = Trigger.specTimer(template.cron);
|
|
45
41
|
});
|
|
46
42
|
break;
|
|
47
43
|
}
|
|
48
44
|
case "queue": {
|
|
49
|
-
Obj.
|
|
50
|
-
trigger2.spec =
|
|
51
|
-
kind: "queue",
|
|
52
|
-
queue: template.queueDXN.toString()
|
|
53
|
-
};
|
|
45
|
+
Obj.update(trigger, (trigger2) => {
|
|
46
|
+
trigger2.spec = Trigger.specQueue(template.queueDXN.toString());
|
|
54
47
|
});
|
|
55
48
|
break;
|
|
56
49
|
}
|
|
@@ -74,4 +67,4 @@ var create_trigger_from_template_default = handler;
|
|
|
74
67
|
export {
|
|
75
68
|
create_trigger_from_template_default as default
|
|
76
69
|
};
|
|
77
|
-
//# sourceMappingURL=create-trigger-from-template-
|
|
70
|
+
//# sourceMappingURL=create-trigger-from-template-JLBSJRVB.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/operations/create-trigger-from-template.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { LayoutOperation, getSpacePath } from '@dxos/app-toolkit';\nimport { Operation, Script, Trigger } from '@dxos/compute';\nimport { Obj, Ref } from '@dxos/echo';\nimport { type DXN } from '@dxos/keys';\nimport { SpaceOperation } from '@dxos/plugin-space/operations';\nimport { Filter } from '@dxos/react-client/echo';\n\nimport { meta } from '#meta';\n\nimport { CreateTriggerFromTemplate } from './definitions';\n\nconst handler: Operation.WithHandler<typeof CreateTriggerFromTemplate> = CreateTriggerFromTemplate.pipe(\n Operation.withHandler(\n Effect.fnUntraced(function* ({ db, template, enabled = false, scriptName, input }) {\n const trigger = Trigger.make({ enabled, input });\n\n // TODO(wittjosiah): Factor out function lookup by script name?\n if (scriptName) {\n const scripts = yield* Effect.promise(() => db.query(Filter.type(Script.Script, { name: scriptName })).run());\n const [script] = scripts;\n if (script) {\n const functions = yield* Effect.promise(() =>\n db.query(Filter.type(Operation.PersistentOperation, { source: Ref.make(script) })).run(),\n );\n const [fn] = functions;\n if (fn) {\n Obj.update(trigger, (trigger) => {\n trigger.function = Ref.make(fn);\n });\n }\n }\n }\n\n switch (template.type) {\n case 'timer': {\n Obj.update(trigger, (trigger) => {\n trigger.spec = Trigger.specTimer(template.cron);\n });\n break;\n }\n case 'queue': {\n Obj.update(trigger, (trigger) => {\n trigger.spec = Trigger.specQueue((template.queueDXN as DXN).toString());\n });\n break;\n }\n default: {\n break;\n }\n }\n\n yield* Operation.invoke(SpaceOperation.AddObject, {\n object: trigger,\n target: db,\n hidden: true,\n });\n yield* Operation.invoke(LayoutOperation.Open, {\n subject: [`${getSpacePath(db.spaceId)}/settings/${meta.id}.automations`],\n workspace: getSpacePath(db.spaceId),\n });\n }),\n ),\n);\n\nexport default handler;\n"],
|
|
5
|
+
"mappings": ";;;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,iBAAiBC,oBAAoB;AAC9C,SAASC,WAAWC,QAAQC,eAAe;AAC3C,SAASC,KAAKC,WAAW;AAEzB,SAASC,sBAAsB;AAC/B,SAASC,cAAc;AAEvB,SAASC,YAAY;AAIrB,IAAMC,UAAmEC,0BAA0BC,KACjGC,UAAUC,YACDC,kBAAW,WAAW,EAAEC,IAAIC,UAAUC,UAAU,OAAOC,YAAYC,MAAK,GAAE;AAC/E,QAAMC,UAAUC,QAAQC,KAAK;IAAEL;IAASE;EAAM,CAAA;AAG9C,MAAID,YAAY;AACd,UAAMK,UAAU,OAAcC,eAAQ,MAAMT,GAAGU,MAAMC,OAAOC,KAAKC,OAAOA,QAAQ;MAAEC,MAAMX;IAAW,CAAA,CAAA,EAAIY,IAAG,CAAA;AAC1G,UAAM,CAACC,MAAAA,IAAUR;AACjB,QAAIQ,QAAQ;AACV,YAAMC,YAAY,OAAcR,eAAQ,MACtCT,GAAGU,MAAMC,OAAOC,KAAKf,UAAUqB,qBAAqB;QAAEC,QAAQC,IAAIb,KAAKS,MAAAA;MAAQ,CAAA,CAAA,EAAID,IAAG,CAAA;AAExF,YAAM,CAACM,EAAAA,IAAMJ;AACb,UAAII,IAAI;AACNC,YAAIC,OAAOlB,SAAS,CAACA,aAAAA;AACnBA,UAAAA,SAAQmB,WAAWJ,IAAIb,KAAKc,EAAAA;QAC9B,CAAA;MACF;IACF;EACF;AAEA,UAAQpB,SAASW,MAAI;IACnB,KAAK,SAAS;AACZU,UAAIC,OAAOlB,SAAS,CAACA,aAAAA;AACnBA,QAAAA,SAAQoB,OAAOnB,QAAQoB,UAAUzB,SAAS0B,IAAI;MAChD,CAAA;AACA;IACF;IACA,KAAK,SAAS;AACZL,UAAIC,OAAOlB,SAAS,CAACA,aAAAA;AACnBA,QAAAA,SAAQoB,OAAOnB,QAAQsB,UAAW3B,SAAS4B,SAAiBC,SAAQ,CAAA;MACtE,CAAA;AACA;IACF;IACA,SAAS;AACP;IACF;EACF;AAEA,SAAOjC,UAAUkC,OAAOC,eAAeC,WAAW;IAChDC,QAAQ7B;IACR8B,QAAQnC;IACRoC,QAAQ;EACV,CAAA;AACA,SAAOvC,UAAUkC,OAAOM,gBAAgBC,MAAM;IAC5CC,SAAS;MAAC,GAAGC,aAAaxC,GAAGyC,OAAO,CAAA,aAAcC,KAAKC,EAAE;;IACzDC,WAAWJ,aAAaxC,GAAGyC,OAAO;EACpC,CAAA;AACF,CAAA,CAAA,CAAA;AAIJ,IAAA,uCAAe/C;",
|
|
6
|
+
"names": ["Effect", "LayoutOperation", "getSpacePath", "Operation", "Script", "Trigger", "Obj", "Ref", "SpaceOperation", "Filter", "meta", "handler", "CreateTriggerFromTemplate", "pipe", "Operation", "withHandler", "fnUntraced", "db", "template", "enabled", "scriptName", "input", "trigger", "Trigger", "make", "scripts", "promise", "query", "Filter", "type", "Script", "name", "run", "script", "functions", "PersistentOperation", "source", "Ref", "fn", "Obj", "update", "function", "spec", "specTimer", "cron", "specQueue", "queueDXN", "toString", "invoke", "SpaceOperation", "AddObject", "object", "target", "hidden", "LayoutOperation", "Open", "subject", "getSpacePath", "spaceId", "meta", "id", "workspace"]
|
|
7
|
+
}
|
|
@@ -1,16 +1,31 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AutomationCapabilities
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-CHUTFU3D.mjs";
|
|
4
4
|
import "../chunk-J5LGTIGS.mjs";
|
|
5
5
|
|
|
6
6
|
// src/hooks/useComputeRuntimeCallback.ts
|
|
7
7
|
import { useCallback } from "react";
|
|
8
8
|
|
|
9
9
|
// src/hooks/useComputeRuntime.ts
|
|
10
|
-
import {
|
|
10
|
+
import { useEffect } from "react";
|
|
11
|
+
import { useCapabilities } from "@dxos/app-framework/ui";
|
|
12
|
+
import { log } from "@dxos/log";
|
|
13
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-automation/src/hooks/useComputeRuntime.ts";
|
|
11
14
|
var useComputeRuntime = (id) => {
|
|
12
|
-
const computeRuntime =
|
|
13
|
-
|
|
15
|
+
const [computeRuntime] = useCapabilities(AutomationCapabilities.ComputeRuntime);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
log("useComputeRuntime", {
|
|
18
|
+
hasCapability: !!computeRuntime,
|
|
19
|
+
spaceId: id
|
|
20
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 16, S: void 0 });
|
|
21
|
+
}, [
|
|
22
|
+
!!computeRuntime,
|
|
23
|
+
id
|
|
24
|
+
]);
|
|
25
|
+
if (!computeRuntime || id === void 0) {
|
|
26
|
+
return void 0;
|
|
27
|
+
}
|
|
28
|
+
return computeRuntime.getRuntime(id);
|
|
14
29
|
};
|
|
15
30
|
|
|
16
31
|
// src/hooks/useComputeRuntimeCallback.ts
|
|
@@ -30,19 +45,19 @@ var useComputeRuntimeCallback = (id, fn, deps) => {
|
|
|
30
45
|
// src/hooks/useTriggerRuntimeControls.ts
|
|
31
46
|
import { Atom, useAtomValue } from "@effect-atom/atom-react";
|
|
32
47
|
import * as Effect from "effect/Effect";
|
|
33
|
-
import { useEffect, useState } from "react";
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
48
|
+
import { useEffect as useEffect2, useState } from "react";
|
|
49
|
+
import { Trigger } from "@dxos/compute";
|
|
50
|
+
import { Filter, Query } from "@dxos/echo";
|
|
36
51
|
import { TriggerDispatcher } from "@dxos/functions-runtime";
|
|
37
52
|
import { useQuery } from "@dxos/react-client/echo";
|
|
38
53
|
var useTriggerRuntimeControls = (db) => {
|
|
39
|
-
const triggers = useQuery(db, Filter.type(Trigger.Trigger));
|
|
54
|
+
const triggers = useQuery(db, Query.select(Filter.type(Trigger.Trigger)).debugLabel("plugin-automation.useTriggerRuntimeControls"));
|
|
40
55
|
const [dispatcher, setDispatcher] = useState(void 0);
|
|
41
56
|
const init = useComputeRuntimeCallback(db?.spaceId, Effect.fnUntraced(function* () {
|
|
42
57
|
const dispatcher2 = yield* TriggerDispatcher;
|
|
43
58
|
setDispatcher(dispatcher2);
|
|
44
59
|
}));
|
|
45
|
-
|
|
60
|
+
useEffect2(() => {
|
|
46
61
|
void init();
|
|
47
62
|
}, []);
|
|
48
63
|
const state = useAtomValue(dispatcher?.state ?? Atom.make(void 0));
|
|
@@ -63,18 +78,47 @@ var useTriggerRuntimeControls = (db) => {
|
|
|
63
78
|
};
|
|
64
79
|
|
|
65
80
|
// src/hooks/useComputeRuntimeService.ts
|
|
66
|
-
import
|
|
67
|
-
import
|
|
68
|
-
import {
|
|
81
|
+
import * as Effect2 from "effect/Effect";
|
|
82
|
+
import * as Exit from "effect/Exit";
|
|
83
|
+
import { useEffect as useEffect3, useState as useState2 } from "react";
|
|
84
|
+
import { log as log2 } from "@dxos/log";
|
|
85
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/plugins/plugin-automation/src/hooks/useComputeRuntimeService.ts";
|
|
69
86
|
var useComputeRuntimeService = (tag, spaceId) => {
|
|
70
87
|
const runtime = useComputeRuntime(spaceId);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
88
|
+
const [service, setService] = useState2(void 0);
|
|
89
|
+
useEffect3(() => {
|
|
90
|
+
setService(void 0);
|
|
91
|
+
if (!runtime) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
let cancelled = false;
|
|
95
|
+
void (async () => {
|
|
96
|
+
try {
|
|
97
|
+
const exit = await runtime.runPromiseExit(tag.pipe(Effect2.timeout("30 seconds")));
|
|
98
|
+
if (cancelled) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (Exit.isSuccess(exit)) {
|
|
102
|
+
setService(exit.value);
|
|
103
|
+
} else {
|
|
104
|
+
log2.warn("useComputeRuntimeService: failed to acquire service", {
|
|
105
|
+
cause: exit.cause
|
|
106
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 37, S: void 0 });
|
|
107
|
+
}
|
|
108
|
+
} catch (error) {
|
|
109
|
+
if (!cancelled) {
|
|
110
|
+
log2.catch(error, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 43, S: void 0 });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
})();
|
|
114
|
+
return () => {
|
|
115
|
+
cancelled = true;
|
|
116
|
+
};
|
|
117
|
+
}, [
|
|
75
118
|
runtime,
|
|
76
119
|
tag
|
|
77
|
-
])
|
|
120
|
+
]);
|
|
121
|
+
return service;
|
|
78
122
|
};
|
|
79
123
|
export {
|
|
80
124
|
useComputeRuntime,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/hooks/useComputeRuntimeCallback.ts", "../../../../src/hooks/useComputeRuntime.ts", "../../../../src/hooks/useTriggerRuntimeControls.ts", "../../../../src/hooks/useComputeRuntimeService.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport { type DependencyList, useCallback } from 'react';\n\nimport { type Key } from '@dxos/echo';\n\nimport { AutomationCapabilities } from '#types';\n\nimport { useComputeRuntime } from './useComputeRuntime';\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 runtime = useComputeRuntime(id);\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// Copyright 2025 DXOS.org\n//\n\nimport {
|
|
5
|
-
"mappings": ";;;;;;AAKA,SAA8BA,mBAAmB;;;ACDjD,SAASC,
|
|
6
|
-
"names": ["useCallback", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport { type DependencyList, useCallback } from 'react';\n\nimport { type Key } from '@dxos/echo';\n\nimport { AutomationCapabilities } from '#types';\n\nimport { useComputeRuntime } from './useComputeRuntime';\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 runtime = useComputeRuntime(id);\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// Copyright 2025 DXOS.org\n//\n\nimport { useEffect } from 'react';\n\nimport { useCapabilities } from '@dxos/app-framework/ui';\nimport { SpaceId } from '@dxos/keys';\nimport { log } from '@dxos/log';\n\nimport { AutomationCapabilities } from '../types';\n\n/**\n * Resolves the compute runtime for a space.\n * Returns undefined if the AutomationPlugin is not loaded or spaceId is not provided.\n */\nexport const useComputeRuntime = (id: SpaceId | undefined): AutomationCapabilities.ComputeRuntime | undefined => {\n const [computeRuntime] = useCapabilities(AutomationCapabilities.ComputeRuntime);\n // One log per change of (capability availability, spaceId) so we can see when\n // the React subscription actually observes the contributed runtime.\n useEffect(() => {\n log('useComputeRuntime', { hasCapability: !!computeRuntime, spaceId: id });\n }, [!!computeRuntime, id]);\n\n if (!computeRuntime || id === undefined) {\n return undefined;\n }\n\n return computeRuntime.getRuntime(id);\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 { Trigger } from '@dxos/compute';\nimport { type Database, Filter, Query } from '@dxos/echo';\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(\n db,\n Query.select(Filter.type(Trigger.Trigger)).debugLabel('plugin-automation.useTriggerRuntimeControls'),\n );\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", "//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport * as Exit from 'effect/Exit';\nimport { useEffect, useState } from 'react';\n\nimport { SpaceId } from '@dxos/keys';\nimport { log } from '@dxos/log';\n\nimport { useComputeRuntime } from './useComputeRuntime';\n\ntype ResolvedService<T extends Context.Tag<any, any>> = Context.Tag.Service<T> | undefined;\n\n/**\n * Resolves a service from the compute runtime for a given space.\n *\n * NOTE: Previously implemented via `use(useMemo(() => runtime.runPromiseExit(...)))`.\n * React's `use()` is weird and unreliable in production builds — the Suspense\n * boundary can stay pending indefinitely without the promise ever resolving\n * from React's perspective (the runtime is built lazily on first invocation\n * and one of its `acquire` steps can block). This `useState` + `useEffect`\n * flavour avoids suspension entirely: the hook returns `undefined` while the\n * service is being acquired or if acquisition fails / times out.\n */\nexport const useComputeRuntimeService = <T extends Context.Tag<any, any>>(\n tag: T,\n spaceId?: SpaceId,\n): ResolvedService<T> => {\n const runtime = useComputeRuntime(spaceId);\n const [service, setService] = useState<ResolvedService<T>>(undefined);\n\n useEffect(() => {\n setService(undefined);\n if (!runtime) {\n return;\n }\n let cancelled = false;\n void (async () => {\n try {\n const exit = await runtime.runPromiseExit(tag.pipe(Effect.timeout('30 seconds')));\n if (cancelled) {\n return;\n }\n if (Exit.isSuccess(exit)) {\n setService(exit.value);\n } else {\n log.warn('useComputeRuntimeService: failed to acquire service', { cause: exit.cause });\n }\n } catch (error) {\n if (!cancelled) {\n log.catch(error);\n }\n }\n })();\n return () => {\n cancelled = true;\n };\n }, [runtime, tag]);\n\n return service;\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["useCallback", "useEffect", "useCapabilities", "log", "hasCapability", "spaceId", "id", "computeRuntime", "useComputeRuntimeCallback", "id", "fn", "deps", "runtime", "useComputeRuntime", "useCallback", "TypeError", "runPromise", "Atom", "useAtomValue", "Effect", "useEffect", "useState", "Trigger", "Filter", "Query", "TriggerDispatcher", "useQuery", "useTriggerRuntimeControls", "db", "triggers", "useQuery", "Query", "select", "Filter", "type", "Trigger", "debugLabel", "dispatcher", "setDispatcher", "useState", "undefined", "init", "useComputeRuntimeCallback", "spaceId", "fnUntraced", "TriggerDispatcher", "useEffect", "state", "useAtomValue", "Atom", "make", "start", "stop", "Effect", "Exit", "useEffect", "useState", "log", "__dxlog_file", "service", "undefined", "useEffect", "setService", "runtime", "cancelled", "exit", "Exit", "log", "error", "catch"]
|
|
7
7
|
}
|
|
@@ -1,79 +1,11 @@
|
|
|
1
1
|
import "./chunk-J5LGTIGS.mjs";
|
|
2
2
|
|
|
3
|
-
// src/
|
|
3
|
+
// src/index.ts
|
|
4
4
|
import { Plugin } from "@dxos/app-framework";
|
|
5
|
-
import { AppPlugin } from "@dxos/app-toolkit";
|
|
6
|
-
import { Trigger } from "@dxos/functions";
|
|
7
|
-
import { Operation } from "@dxos/operation";
|
|
8
|
-
import { ClientEvents } from "@dxos/plugin-client/types";
|
|
9
|
-
import { AppGraphBuilder, ComputeRuntime, OperationHandler, ReactSurface } from "#capabilities";
|
|
10
|
-
import { meta as meta2 } from "#meta";
|
|
11
|
-
import { AutomationEvents } from "#types";
|
|
12
|
-
|
|
13
|
-
// src/translations.ts
|
|
14
|
-
import { meta } from "#meta";
|
|
15
|
-
var translations = [
|
|
16
|
-
{
|
|
17
|
-
"en-US": {
|
|
18
|
-
[meta.id]: {
|
|
19
|
-
"plugin.name": "Automation",
|
|
20
|
-
"automation-panel.label": "Automations",
|
|
21
|
-
"script-automation.label": "Automation",
|
|
22
|
-
"automation-verbose.label": "Manage automations",
|
|
23
|
-
"automation.description": "You can manage all the triggers which automate your space here.",
|
|
24
|
-
"runtime.label": "Enable Local Runtime",
|
|
25
|
-
"runtime.description": "This will start a trigger dispatcher locally for this space to run triggers on your device while Composer is running.",
|
|
26
|
-
"functions-panel.label": "Functions",
|
|
27
|
-
"functions-verbose.label": "Manage deployed functions",
|
|
28
|
-
"functions-registry-verbose.label": "Functions registry",
|
|
29
|
-
"functions-registry.description": "Import functions from the registry",
|
|
30
|
-
"functions.description": "You can manage all the functions deployed from your space on EDGE here.",
|
|
31
|
-
"show-source-button.label": "Show source",
|
|
32
|
-
"delete-function-button.label": "Delete function",
|
|
33
|
-
"function-parameters.label": "Function parameters",
|
|
34
|
-
"trigger-editor.title": "Configure Trigger",
|
|
35
|
-
"trigger-editor.description": "Triggers are used to run functions at specific times or when specific events occur.",
|
|
36
|
-
"new-trigger.label": "Add Trigger",
|
|
37
|
-
"trigger-type.timer.label": "Timer",
|
|
38
|
-
"trigger-type.webhook.label": "Webhook",
|
|
39
|
-
"trigger-type.websocket.label": "Websocket",
|
|
40
|
-
"trigger-type.subscription.label": "Subscription",
|
|
41
|
-
"trigger-type.email.label": "Email",
|
|
42
|
-
"trigger-type.queue.label": "Feed",
|
|
43
|
-
"trigger-payload-prop-name.placeholder": "New payload property name",
|
|
44
|
-
"import-function-button.label": "Loading...",
|
|
45
|
-
"loading-functions.message": "Loading functions...",
|
|
46
|
-
"update-function-button.label": "Update"
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
];
|
|
51
|
-
|
|
52
|
-
// src/AutomationPlugin.tsx
|
|
53
|
-
var AutomationPlugin = Plugin.define(meta2).pipe(AppPlugin.addAppGraphModule({
|
|
54
|
-
activate: AppGraphBuilder
|
|
55
|
-
}), AppPlugin.addOperationHandlerModule({
|
|
56
|
-
activate: OperationHandler
|
|
57
|
-
}), AppPlugin.addSchemaModule({
|
|
58
|
-
schema: [
|
|
59
|
-
Operation.PersistentOperation,
|
|
60
|
-
Trigger.Trigger
|
|
61
|
-
]
|
|
62
|
-
}), AppPlugin.addSurfaceModule({
|
|
63
|
-
activate: ReactSurface
|
|
64
|
-
}), AppPlugin.addTranslationsModule({
|
|
65
|
-
translations
|
|
66
|
-
}), Plugin.addModule({
|
|
67
|
-
activatesOn: ClientEvents.ClientReady,
|
|
68
|
-
activatesAfter: [
|
|
69
|
-
AutomationEvents.ComputeRuntimeReady
|
|
70
|
-
],
|
|
71
|
-
activate: ComputeRuntime
|
|
72
|
-
}), Plugin.make);
|
|
73
5
|
|
|
74
6
|
// src/meta.ts
|
|
75
7
|
import { trim } from "@dxos/util";
|
|
76
|
-
var
|
|
8
|
+
var meta = {
|
|
77
9
|
id: "org.dxos.plugin.automation",
|
|
78
10
|
name: "Automation",
|
|
79
11
|
description: trim`
|
|
@@ -83,8 +15,11 @@ var meta3 = {
|
|
|
83
15
|
icon: "ph--atom--regular",
|
|
84
16
|
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-automation"
|
|
85
17
|
};
|
|
18
|
+
|
|
19
|
+
// src/index.ts
|
|
20
|
+
var AutomationPlugin = Plugin.lazy(meta, () => import("#plugin"));
|
|
86
21
|
export {
|
|
87
22
|
AutomationPlugin,
|
|
88
|
-
|
|
23
|
+
meta
|
|
89
24
|
};
|
|
90
25
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../src/
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Plugin } from '@dxos/app-framework';\
|
|
5
|
-
"mappings": ";;;AAIA,SAASA,cAAc
|
|
6
|
-
"names": ["Plugin", "
|
|
3
|
+
"sources": ["../../../src/index.ts", "../../../src/meta.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Plugin } from '@dxos/app-framework';\n\nimport { meta } from './meta';\n\nexport const AutomationPlugin = Plugin.lazy(meta, () => import('#plugin'));\nexport { meta } from './meta';\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Plugin } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: Plugin.Meta = {\n id: 'org.dxos.plugin.automation',\n name: 'Automation',\n description: trim`\n Workflow automation engine that triggers custom actions based on object events and conditions.\n Create automated pipelines that respond to changes and streamline repetitive tasks.\n `,\n icon: 'ph--atom--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-automation',\n};\n"],
|
|
5
|
+
"mappings": ";;;AAIA,SAASA,cAAc;;;ACCvB,SAASC,YAAY;AAEd,IAAMC,OAAoB;EAC/BC,IAAI;EACJC,MAAM;EACNC,aAAaJ;;;;EAIbK,MAAM;EACNC,QAAQ;AACV;;;ADRO,IAAMC,mBAAmBC,OAAOC,KAAKC,MAAM,MAAM,OAAO,SAAA,CAAA;",
|
|
6
|
+
"names": ["Plugin", "trim", "meta", "id", "name", "description", "icon", "source", "AutomationPlugin", "Plugin", "lazy", "meta"]
|
|
7
7
|
}
|