@dxos/plugin-automation 0.8.4-main.ae835ea → 0.8.4-main.bc674ce
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 +11 -0
- package/dist/lib/browser/AutomationSettings-XN2OIYWL.mjs +56 -0
- package/dist/lib/browser/AutomationSettings-XN2OIYWL.mjs.map +7 -0
- package/dist/lib/browser/FunctionsContainer-6QLC7JP4.mjs +129 -0
- package/dist/lib/browser/FunctionsContainer-6QLC7JP4.mjs.map +7 -0
- package/dist/lib/browser/{FunctionsPanel-HFCK3JRB.mjs → FunctionsPanel-ZX4J75UM.mjs} +3 -3
- package/dist/lib/browser/app-graph-builder-LAQMEBMH.mjs +84 -0
- package/dist/lib/browser/app-graph-builder-LAQMEBMH.mjs.map +7 -0
- package/dist/lib/browser/{chunk-XXZNGORC.mjs → chunk-54PANILA.mjs} +5 -5
- package/dist/lib/browser/chunk-BFUIVUQH.mjs +102 -0
- package/dist/lib/browser/chunk-BFUIVUQH.mjs.map +7 -0
- package/dist/lib/browser/chunk-BKFQBKYO.mjs +8 -0
- package/dist/lib/browser/chunk-BKFQBKYO.mjs.map +7 -0
- package/dist/lib/browser/chunk-JOXPQ27I.mjs +83 -0
- package/dist/lib/browser/chunk-JOXPQ27I.mjs.map +7 -0
- package/dist/lib/browser/{chunk-LZQFZO3B.mjs → chunk-PZNBEKO5.mjs} +1 -1
- package/dist/lib/browser/chunk-PZNBEKO5.mjs.map +7 -0
- package/dist/lib/browser/chunk-QW3EM35H.mjs +248 -0
- package/dist/lib/browser/chunk-QW3EM35H.mjs.map +7 -0
- package/dist/lib/browser/chunk-RAF2FJST.mjs +86 -0
- package/dist/lib/browser/chunk-RAF2FJST.mjs.map +7 -0
- package/dist/lib/browser/chunk-YWLEY2FD.mjs +200 -0
- package/dist/lib/browser/chunk-YWLEY2FD.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +1107 -0
- package/dist/lib/browser/cli/index.mjs.map +7 -0
- package/dist/lib/browser/compute-runtime-WTWLQ67J.mjs +114 -0
- package/dist/lib/browser/compute-runtime-WTWLQ67J.mjs.map +7 -0
- package/dist/lib/browser/hooks/index.mjs +5 -3
- package/dist/lib/browser/index.mjs +53 -57
- 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 +82 -0
- package/dist/lib/browser/operation-resolver-Q3MWOR7K.mjs.map +7 -0
- package/dist/lib/browser/{react-surface-WPMY3EX2.mjs → react-surface-EV3AC62F.mjs} +13 -11
- package/dist/lib/browser/react-surface-EV3AC62F.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +10 -4
- package/dist/lib/node-esm/{AutomationPanel-NVEIUIZP.mjs → AutomationPanel-B7NAGDFA.mjs} +4 -4
- package/dist/lib/node-esm/AutomationSettings-M5PMZJ6P.mjs +57 -0
- package/dist/lib/node-esm/AutomationSettings-M5PMZJ6P.mjs.map +7 -0
- package/dist/lib/node-esm/FunctionsContainer-J4O2ULWR.mjs +130 -0
- package/dist/lib/node-esm/FunctionsContainer-J4O2ULWR.mjs.map +7 -0
- package/dist/lib/node-esm/{FunctionsPanel-74ELGR7P.mjs → FunctionsPanel-SS6GIVNU.mjs} +3 -3
- package/dist/lib/node-esm/app-graph-builder-4UCMXHYY.mjs +85 -0
- package/dist/lib/node-esm/app-graph-builder-4UCMXHYY.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-2CKVH7JC.mjs +201 -0
- package/dist/lib/node-esm/chunk-2CKVH7JC.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-CEVIVRTY.mjs → chunk-5FXNN3MV.mjs} +1 -1
- package/dist/lib/node-esm/chunk-5FXNN3MV.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-U5Q2NI7H.mjs → chunk-7QRUPEHH.mjs} +5 -5
- package/dist/lib/node-esm/chunk-HQLVREIX.mjs +87 -0
- package/dist/lib/node-esm/chunk-HQLVREIX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-K7GCM342.mjs +10 -0
- package/dist/lib/node-esm/chunk-K7GCM342.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-KWKWOGS5.mjs +103 -0
- package/dist/lib/node-esm/chunk-KWKWOGS5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-LJAXQ6CX.mjs +249 -0
- package/dist/lib/node-esm/chunk-LJAXQ6CX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-RX52VKI2.mjs +84 -0
- package/dist/lib/node-esm/chunk-RX52VKI2.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +1108 -0
- package/dist/lib/node-esm/cli/index.mjs.map +7 -0
- package/dist/lib/node-esm/compute-runtime-ZHROOBLY.mjs +115 -0
- package/dist/lib/node-esm/compute-runtime-ZHROOBLY.mjs.map +7 -0
- package/dist/lib/node-esm/hooks/index.mjs +5 -3
- package/dist/lib/node-esm/index.mjs +53 -57
- 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 +83 -0
- package/dist/lib/node-esm/operation-resolver-R5GA4YNO.mjs.map +7 -0
- package/dist/lib/node-esm/{react-surface-Y2BBJV2I.mjs → react-surface-S6VZJCEZ.mjs} +13 -11
- package/dist/lib/node-esm/react-surface-S6VZJCEZ.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +10 -4
- package/dist/types/src/AutomationPlugin.d.ts +2 -1
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/compute-runtime/compute-runtime.d.ts +6 -0
- package/dist/types/src/capabilities/compute-runtime/compute-runtime.d.ts.map +1 -0
- package/dist/types/src/capabilities/compute-runtime/index.d.ts +3 -0
- package/dist/types/src/capabilities/compute-runtime/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +4 -5
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/cli/commands/index.d.ts +2 -0
- package/dist/types/src/cli/commands/index.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/create/index.d.ts +25 -0
- package/dist/types/src/cli/commands/trigger/create/index.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/create/queue.d.ts +13 -0
- package/dist/types/src/cli/commands/trigger/create/queue.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/create/subscription.d.ts +15 -0
- package/dist/types/src/cli/commands/trigger/create/subscription.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/create/timer.d.ts +13 -0
- package/dist/types/src/cli/commands/trigger/create/timer.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/index.d.ts +57 -0
- package/dist/types/src/cli/commands/trigger/index.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/list.d.ts +7 -0
- package/dist/types/src/cli/commands/trigger/list.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/options.d.ts +11 -0
- package/dist/types/src/cli/commands/trigger/options.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/remove.d.ts +8 -0
- package/dist/types/src/cli/commands/trigger/remove.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/update/index.d.ts +28 -0
- package/dist/types/src/cli/commands/trigger/update/index.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/update/queue.d.ts +12 -0
- package/dist/types/src/cli/commands/trigger/update/queue.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/update/subscription.d.ts +13 -0
- package/dist/types/src/cli/commands/trigger/update/subscription.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/update/timer.d.ts +11 -0
- package/dist/types/src/cli/commands/trigger/update/timer.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/util.d.ts +46 -0
- package/dist/types/src/cli/commands/trigger/util.d.ts.map +1 -0
- package/dist/types/src/cli/index.d.ts +2 -0
- package/dist/types/src/cli/index.d.ts.map +1 -0
- package/dist/types/src/cli/plugin.d.ts +3 -0
- package/dist/types/src/cli/plugin.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 +3 -0
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsContainer.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 +8 -0
- package/dist/types/src/components/FunctionsRegistry/FunctionsRegistry.d.ts.map +1 -0
- package/dist/types/src/components/FunctionsRegistry/index.d.ts +2 -0
- package/dist/types/src/components/FunctionsRegistry/index.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts +10 -7
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts +6 -3
- package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +7 -6
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +72 -2
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TriggerSettings.d.ts +3 -3
- package/dist/types/src/components/TriggerSettings.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts +8 -4
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts.map +1 -1
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts +2 -2
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/testing/test-functions.d.ts +202 -3
- package/dist/types/src/testing/test-functions.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +3 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +22 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/events.d.ts +5 -0
- package/dist/types/src/types/events.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +30 -1
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +61 -47
- package/src/AutomationPlugin.tsx +13 -33
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +71 -0
- package/src/capabilities/app-graph-builder/index.ts +7 -0
- package/src/capabilities/compute-runtime/compute-runtime.ts +133 -0
- package/src/capabilities/compute-runtime/index.ts +7 -0
- package/src/capabilities/index.ts +4 -8
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +79 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +60 -0
- package/src/cli/commands/index.ts +5 -0
- package/src/cli/commands/trigger/create/index.ts +14 -0
- package/src/cli/commands/trigger/create/queue.ts +89 -0
- package/src/cli/commands/trigger/create/subscription.ts +128 -0
- package/src/cli/commands/trigger/create/timer.ts +93 -0
- package/src/cli/commands/trigger/index.ts +16 -0
- package/src/cli/commands/trigger/list.ts +67 -0
- package/src/cli/commands/trigger/options.ts +59 -0
- package/src/cli/commands/trigger/remove.ts +45 -0
- package/src/cli/commands/trigger/update/index.ts +14 -0
- package/src/cli/commands/trigger/update/queue.ts +195 -0
- package/src/cli/commands/trigger/update/subscription.ts +278 -0
- package/src/cli/commands/trigger/update/timer.ts +193 -0
- package/src/cli/commands/trigger/util.ts +395 -0
- package/src/cli/index.ts +5 -0
- package/src/cli/plugin.ts +23 -0
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +1 -1
- package/src/components/AutomationPanel/AutomationPanel.tsx +51 -22
- package/src/components/AutomationSettings.tsx +1 -1
- package/src/components/FunctionsContainer.tsx +7 -0
- package/src/components/FunctionsPanel/FunctionsPanel.tsx +14 -12
- package/src/components/FunctionsRegistry/FunctionsRegistry.tsx +111 -0
- package/src/components/FunctionsRegistry/index.ts +5 -0
- package/src/components/TriggerEditor/FunctionInputEditor.tsx +23 -31
- package/src/components/TriggerEditor/SpecSelector.tsx +8 -6
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +33 -29
- package/src/components/TriggerEditor/TriggerEditor.tsx +56 -43
- package/src/components/TriggerSettings.tsx +3 -3
- package/src/hooks/useComputeRuntimeCallback.ts +43 -8
- package/src/hooks/useTriggerRuntimeControls.ts +9 -8
- package/src/index.ts +1 -2
- package/src/meta.ts +2 -2
- package/src/testing/test-functions.ts +2 -2
- package/src/translations.ts +4 -0
- package/src/{capabilities → types}/capabilities.ts +8 -14
- package/src/types/events.ts +11 -0
- package/src/types/index.ts +2 -0
- package/src/types/schema.ts +23 -2
- package/dist/lib/browser/AutomationPanel-LBXJDM6Z.mjs +0 -11
- package/dist/lib/browser/AutomationSettings-IIEI5D2K.mjs +0 -68
- package/dist/lib/browser/AutomationSettings-IIEI5D2K.mjs.map +0 -7
- package/dist/lib/browser/FunctionsContainer-IZTCGNJZ.mjs +0 -36
- package/dist/lib/browser/FunctionsContainer-IZTCGNJZ.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-7VKA2GS3.mjs +0 -81
- package/dist/lib/browser/app-graph-builder-7VKA2GS3.mjs.map +0 -7
- package/dist/lib/browser/chunk-CVYJM6OO.mjs +0 -66
- package/dist/lib/browser/chunk-CVYJM6OO.mjs.map +0 -7
- package/dist/lib/browser/chunk-FHSN7G4H.mjs +0 -107
- package/dist/lib/browser/chunk-FHSN7G4H.mjs.map +0 -7
- package/dist/lib/browser/chunk-GCGHLQM2.mjs +0 -15
- package/dist/lib/browser/chunk-GCGHLQM2.mjs.map +0 -7
- package/dist/lib/browser/chunk-JW7XSPYW.mjs +0 -267
- package/dist/lib/browser/chunk-JW7XSPYW.mjs.map +0 -7
- package/dist/lib/browser/chunk-K5YNWESC.mjs +0 -183
- package/dist/lib/browser/chunk-K5YNWESC.mjs.map +0 -7
- package/dist/lib/browser/chunk-LZQFZO3B.mjs.map +0 -7
- package/dist/lib/browser/chunk-YBPJCY3F.mjs +0 -38
- package/dist/lib/browser/chunk-YBPJCY3F.mjs.map +0 -7
- package/dist/lib/browser/compute-runtime-PFYRMGN2.mjs +0 -114
- package/dist/lib/browser/compute-runtime-PFYRMGN2.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-5HR7M7T6.mjs +0 -77
- package/dist/lib/browser/intent-resolver-5HR7M7T6.mjs.map +0 -7
- package/dist/lib/browser/react-surface-WPMY3EX2.mjs.map +0 -7
- package/dist/lib/node-esm/AutomationSettings-VIIEPI2P.mjs +0 -69
- package/dist/lib/node-esm/AutomationSettings-VIIEPI2P.mjs.map +0 -7
- package/dist/lib/node-esm/FunctionsContainer-KKRCIXGB.mjs +0 -37
- package/dist/lib/node-esm/FunctionsContainer-KKRCIXGB.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-RTOFJNFV.mjs +0 -82
- package/dist/lib/node-esm/app-graph-builder-RTOFJNFV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3BJ6BR3E.mjs +0 -67
- package/dist/lib/node-esm/chunk-3BJ6BR3E.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CEVIVRTY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ECJKIUBO.mjs +0 -39
- package/dist/lib/node-esm/chunk-ECJKIUBO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JOCKHLFT.mjs +0 -108
- package/dist/lib/node-esm/chunk-JOCKHLFT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MRYKW5TM.mjs +0 -16
- package/dist/lib/node-esm/chunk-MRYKW5TM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-W76WUTZY.mjs +0 -268
- package/dist/lib/node-esm/chunk-W76WUTZY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Y7PJXFCJ.mjs +0 -184
- package/dist/lib/node-esm/chunk-Y7PJXFCJ.mjs.map +0 -7
- package/dist/lib/node-esm/compute-runtime-IXCSD3W7.mjs +0 -115
- package/dist/lib/node-esm/compute-runtime-IXCSD3W7.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-KDRYB5BC.mjs +0 -78
- package/dist/lib/node-esm/intent-resolver-KDRYB5BC.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-Y2BBJV2I.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -19
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/compute-runtime.d.ts +0 -5
- package/dist/types/src/capabilities/compute-runtime.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/events.d.ts +0 -4
- package/dist/types/src/events.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder.ts +0 -87
- package/src/capabilities/compute-runtime.ts +0 -138
- package/src/capabilities/intent-resolver.ts +0 -72
- package/src/capabilities/react-surface.tsx +0 -55
- package/src/events.ts +0 -11
- /package/dist/lib/browser/{AutomationPanel-LBXJDM6Z.mjs.map → AutomationPanel-FAS6ADCW.mjs.map} +0 -0
- /package/dist/lib/browser/{FunctionsPanel-HFCK3JRB.mjs.map → FunctionsPanel-ZX4J75UM.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-XXZNGORC.mjs.map → chunk-54PANILA.mjs.map} +0 -0
- /package/dist/lib/node-esm/{AutomationPanel-NVEIUIZP.mjs.map → AutomationPanel-B7NAGDFA.mjs.map} +0 -0
- /package/dist/lib/node-esm/{FunctionsPanel-74ELGR7P.mjs.map → FunctionsPanel-SS6GIVNU.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-U5Q2NI7H.mjs.map → chunk-7QRUPEHH.mjs.map} +0 -0
|
@@ -5,14 +5,16 @@
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { useCallback, useMemo } from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { Common } from '@dxos/app-framework';
|
|
9
|
+
import { useOperationInvoker } from '@dxos/app-framework/react';
|
|
10
|
+
import { Obj } from '@dxos/echo';
|
|
9
11
|
import { Function, Script } from '@dxos/functions';
|
|
10
|
-
import {
|
|
11
|
-
import { Filter, type Space,
|
|
12
|
+
import { SpaceOperation } from '@dxos/plugin-space/types';
|
|
13
|
+
import { Filter, type Space, useQuery } from '@dxos/react-client/echo';
|
|
12
14
|
import { Button, IconButton, useTranslation } from '@dxos/react-ui';
|
|
13
15
|
import { controlItemClasses } from '@dxos/react-ui-form';
|
|
14
16
|
import { List } from '@dxos/react-ui-list';
|
|
15
|
-
import { ghostHover, mx } from '@dxos/
|
|
17
|
+
import { ghostHover, mx } from '@dxos/ui-theme';
|
|
16
18
|
|
|
17
19
|
import { meta } from '../../meta';
|
|
18
20
|
|
|
@@ -24,9 +26,9 @@ export type FunctionsPanelProps = {
|
|
|
24
26
|
|
|
25
27
|
export const FunctionsPanel = ({ space }: FunctionsPanelProps) => {
|
|
26
28
|
const { t } = useTranslation(meta.id);
|
|
27
|
-
const functions = useQuery(space, Filter.type(Function.Function));
|
|
28
|
-
const scripts = useQuery(space, Filter.type(Script.Script));
|
|
29
|
-
const {
|
|
29
|
+
const functions = useQuery(space.db, Filter.type(Function.Function));
|
|
30
|
+
const scripts = useQuery(space.db, Filter.type(Script.Script));
|
|
31
|
+
const { invokePromise } = useOperationInvoker();
|
|
30
32
|
|
|
31
33
|
const functionToScriptMap = useMemo(
|
|
32
34
|
() =>
|
|
@@ -58,15 +60,15 @@ export const FunctionsPanel = ({ space }: FunctionsPanelProps) => {
|
|
|
58
60
|
(func: Function.Function) => {
|
|
59
61
|
const script = functionToScriptMap[func.id];
|
|
60
62
|
if (script) {
|
|
61
|
-
void
|
|
63
|
+
void invokePromise(Common.LayoutOperation.Open, { subject: [Obj.getDXN(script).toString()] });
|
|
62
64
|
}
|
|
63
65
|
},
|
|
64
|
-
[functionToScriptMap,
|
|
66
|
+
[functionToScriptMap, invokePromise],
|
|
65
67
|
);
|
|
66
68
|
|
|
67
69
|
const handleDelete = useCallback(
|
|
68
|
-
(func: Function.Function) =>
|
|
69
|
-
[
|
|
70
|
+
(func: Function.Function) => invokePromise(SpaceOperation.RemoveObjects, { objects: [func] }),
|
|
71
|
+
[invokePromise],
|
|
70
72
|
);
|
|
71
73
|
|
|
72
74
|
return (
|
|
@@ -74,7 +76,7 @@ export const FunctionsPanel = ({ space }: FunctionsPanelProps) => {
|
|
|
74
76
|
{functions.length > 0 && (
|
|
75
77
|
<List.Root<Function.Function> items={functions} isItem={Schema.is(Function.Function)} getId={(func) => func.id}>
|
|
76
78
|
{({ items }) => (
|
|
77
|
-
<div role='list' className='flex flex-col
|
|
79
|
+
<div role='list' className='flex flex-col is-full'>
|
|
78
80
|
{items?.map((func) => (
|
|
79
81
|
<List.Item<Function.Function>
|
|
80
82
|
key={func.id}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import { useState } from 'react';
|
|
7
|
+
import React, { useCallback } from 'react';
|
|
8
|
+
|
|
9
|
+
import { Function } from '@dxos/functions';
|
|
10
|
+
import { getDeployedFunctions } from '@dxos/functions-runtime/edge';
|
|
11
|
+
import { useClient } from '@dxos/react-client';
|
|
12
|
+
import { Filter, Query, type Space, useQuery } from '@dxos/react-client/echo';
|
|
13
|
+
import { useAsyncEffect } from '@dxos/react-ui';
|
|
14
|
+
import { IconButton, useTranslation } from '@dxos/react-ui';
|
|
15
|
+
import { controlItemClasses } from '@dxos/react-ui-form';
|
|
16
|
+
import { List } from '@dxos/react-ui-list';
|
|
17
|
+
import { ghostHover, mx } from '@dxos/ui-theme';
|
|
18
|
+
|
|
19
|
+
import { meta } from '../../meta';
|
|
20
|
+
|
|
21
|
+
const grid = 'grid grid-cols-[1fr_1fr_auto] min-bs-[2.5rem]';
|
|
22
|
+
|
|
23
|
+
type FunctionsRegistryProps = {
|
|
24
|
+
space: Space;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const FunctionsRegistry = ({ space }: FunctionsRegistryProps) => {
|
|
28
|
+
const client = useClient();
|
|
29
|
+
const [loading, setLoading] = useState(true);
|
|
30
|
+
const [functions, setFunctions] = useState<Function.Function[]>([]);
|
|
31
|
+
const { t } = useTranslation(meta.id);
|
|
32
|
+
|
|
33
|
+
const dbFunctions = useQuery(space.db, Filter.type(Function.Function));
|
|
34
|
+
|
|
35
|
+
const state = (func: Function.Function) => {
|
|
36
|
+
const dbFunction = dbFunctions.find((f) => f.key === func.key);
|
|
37
|
+
if (!dbFunction) {
|
|
38
|
+
return 'import';
|
|
39
|
+
}
|
|
40
|
+
if (dbFunction.version === func.version && dbFunction.updated === func.updated) {
|
|
41
|
+
return 'none';
|
|
42
|
+
}
|
|
43
|
+
return 'update';
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
useAsyncEffect(async () => {
|
|
47
|
+
setLoading(true);
|
|
48
|
+
const functions = await getDeployedFunctions(client, true);
|
|
49
|
+
setFunctions(functions);
|
|
50
|
+
setLoading(false);
|
|
51
|
+
}, []);
|
|
52
|
+
|
|
53
|
+
const hanleImportOrUpdate = useCallback(
|
|
54
|
+
async (func: Function.Function) => {
|
|
55
|
+
const functions = await space.db.query(Query.type(Function.Function, { key: func.key })).run();
|
|
56
|
+
const [existingFunc] = functions;
|
|
57
|
+
if (!existingFunc) {
|
|
58
|
+
space.db.add(func);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
Function.setFrom(existingFunc, func);
|
|
62
|
+
},
|
|
63
|
+
[space],
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<div role='none' className={mx(controlItemClasses)}>
|
|
68
|
+
{functions.length > 0 && (
|
|
69
|
+
<List.Root<Function.Function> items={functions} isItem={Schema.is(Function.Function)} getId={(func) => func.id}>
|
|
70
|
+
{({ items }) => (
|
|
71
|
+
<div role='list' className='flex flex-col is-full'>
|
|
72
|
+
{items?.map((func) => (
|
|
73
|
+
<List.Item<Function.Function>
|
|
74
|
+
key={func.id}
|
|
75
|
+
item={func}
|
|
76
|
+
classNames={mx(grid, ghostHover, 'items-center', 'pli-2', 'min-bs-[3rem]')}
|
|
77
|
+
>
|
|
78
|
+
<div className='flex flex-col truncate'>
|
|
79
|
+
<List.ItemTitle classNames='truncate'>{func.name}</List.ItemTitle>
|
|
80
|
+
<div className='text-xs text-description truncate'>{func.key}</div>
|
|
81
|
+
</div>
|
|
82
|
+
<div className='flex flex-col truncate'>
|
|
83
|
+
<div className='text-xs text-description truncate'>{func.version}</div>
|
|
84
|
+
<div className='text-xs text-description truncate'>
|
|
85
|
+
{func.updated ? `Uploaded ${new Date(func.updated).toLocaleString()}` : ''}
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
|
|
89
|
+
<IconButton
|
|
90
|
+
iconOnly
|
|
91
|
+
icon={state(func) === 'update' ? 'ph--arrows-clockwise--regular' : 'ph--download--regular'}
|
|
92
|
+
label={
|
|
93
|
+
state(func) === 'update' ? t('update function button label') : t('import function button label')
|
|
94
|
+
}
|
|
95
|
+
disabled={state(func) === 'none'}
|
|
96
|
+
onClick={() => hanleImportOrUpdate(func)}
|
|
97
|
+
/>
|
|
98
|
+
</List.Item>
|
|
99
|
+
))}
|
|
100
|
+
</div>
|
|
101
|
+
)}
|
|
102
|
+
</List.Root>
|
|
103
|
+
)}
|
|
104
|
+
|
|
105
|
+
{functions.length === 0 && !loading && (
|
|
106
|
+
<div className='text-center plb-4 text-gray-500'>{t('no functions found')}</div>
|
|
107
|
+
)}
|
|
108
|
+
{loading && <div className='text-center plb-4 text-gray-500'>{t('loading functions')}</div>}
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
};
|
|
@@ -2,29 +2,26 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import type * as SchemaAST from 'effect/SchemaAST';
|
|
5
6
|
import React, { useCallback, useMemo } from 'react';
|
|
6
7
|
|
|
7
|
-
import { Ref, Type } from '@dxos/echo';
|
|
8
|
+
import { type Database, Ref, Type } from '@dxos/echo';
|
|
8
9
|
import { type JsonPath } from '@dxos/echo/internal';
|
|
9
10
|
import { type Function } from '@dxos/functions';
|
|
10
|
-
import { useOnTransition } from '@dxos/react-ui';
|
|
11
|
-
import { Form, type
|
|
11
|
+
import { useOnTransition, useTranslation } from '@dxos/react-ui';
|
|
12
|
+
import { Form, type FormFieldStateProps, type FormRootProps, useFormValues } from '@dxos/react-ui-form';
|
|
13
|
+
|
|
14
|
+
import { meta } from '../../meta';
|
|
12
15
|
|
|
13
16
|
export type FunctionInputEditorProps = {
|
|
17
|
+
type: SchemaAST.AST;
|
|
14
18
|
functions: Function.Function[];
|
|
15
|
-
|
|
16
|
-
} &
|
|
19
|
+
db?: Database.Database;
|
|
20
|
+
} & FormFieldStateProps;
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export const FunctionInputEditor = ({
|
|
22
|
-
functions,
|
|
23
|
-
getValue,
|
|
24
|
-
onValueChange,
|
|
25
|
-
onQueryRefOptions,
|
|
26
|
-
}: FunctionInputEditorProps) => {
|
|
27
|
-
const selectedFunctionValue = useFormValues(['function' as JsonPath]);
|
|
22
|
+
export const FunctionInputEditor = ({ type, functions, db, getValue, onValueChange }: FunctionInputEditorProps) => {
|
|
23
|
+
const { t } = useTranslation(meta.id);
|
|
24
|
+
const selectedFunctionValue = useFormValues(FunctionInputEditor.displayName, ['function' as JsonPath]);
|
|
28
25
|
const selectedFunctionId = useMemo(() => {
|
|
29
26
|
if (Ref.isRef(selectedFunctionValue)) {
|
|
30
27
|
return selectedFunctionValue.dxn.toString().split('dxn:echo:@:').at(1);
|
|
@@ -47,20 +44,19 @@ export const FunctionInputEditor = ({
|
|
|
47
44
|
return prevValue.dxn.toString() !== selectedFunctionValue.dxn.toString();
|
|
48
45
|
},
|
|
49
46
|
(currValue) => currValue !== undefined,
|
|
50
|
-
() => onValueChange(
|
|
47
|
+
() => onValueChange(type, {}),
|
|
51
48
|
);
|
|
52
49
|
|
|
53
50
|
const inputSchema = useMemo(() => selectedFunction?.inputSchema, [selectedFunction]);
|
|
54
51
|
const effectSchema = useMemo(() => (inputSchema ? Type.toEffectSchema(inputSchema) : undefined), [inputSchema]);
|
|
55
52
|
const propertyCount = inputSchema?.properties ? Object.keys(inputSchema.properties).length : 0;
|
|
56
|
-
|
|
57
53
|
const values = useMemo(() => getValue() ?? {}, [getValue]);
|
|
58
54
|
|
|
59
|
-
const handleValuesChanged = useCallback(
|
|
60
|
-
(values
|
|
61
|
-
onValueChange(
|
|
55
|
+
const handleValuesChanged = useCallback<NonNullable<FormRootProps['onValuesChanged']>>(
|
|
56
|
+
(values) => {
|
|
57
|
+
onValueChange(type, values);
|
|
62
58
|
},
|
|
63
|
-
[onValueChange],
|
|
59
|
+
[type, onValueChange],
|
|
64
60
|
);
|
|
65
61
|
|
|
66
62
|
if (selectedFunction === undefined || effectSchema === undefined || propertyCount === 0) {
|
|
@@ -69,16 +65,12 @@ export const FunctionInputEditor = ({
|
|
|
69
65
|
|
|
70
66
|
return (
|
|
71
67
|
<>
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
schema={effectSchema}
|
|
77
|
-
values={values}
|
|
78
|
-
onValuesChanged={handleValuesChanged}
|
|
79
|
-
onQueryRefOptions={onQueryRefOptions}
|
|
80
|
-
outerSpacing={false}
|
|
81
|
-
/>
|
|
68
|
+
<Form.Label label={t('function parameters label')} asChild />
|
|
69
|
+
<Form.Root schema={effectSchema} values={values} db={db} onValuesChanged={handleValuesChanged}>
|
|
70
|
+
<Form.FieldSet />
|
|
71
|
+
</Form.Root>
|
|
82
72
|
</>
|
|
83
73
|
);
|
|
84
74
|
};
|
|
75
|
+
|
|
76
|
+
FunctionInputEditor.displayName = 'AutomationTrigger.FunctionInputEditor';
|
|
@@ -7,15 +7,15 @@ import React, { useCallback, useMemo } from 'react';
|
|
|
7
7
|
import { Filter, Query } from '@dxos/echo';
|
|
8
8
|
import { Trigger } from '@dxos/functions';
|
|
9
9
|
import { useTranslation } from '@dxos/react-ui';
|
|
10
|
-
import { type
|
|
10
|
+
import { type FormFieldComponentProps, SelectField, useFormFieldState } from '@dxos/react-ui-form';
|
|
11
11
|
|
|
12
12
|
import { meta } from '../../meta';
|
|
13
13
|
|
|
14
|
-
export type SpecSelectorProps =
|
|
14
|
+
export type SpecSelectorProps = FormFieldComponentProps;
|
|
15
15
|
|
|
16
16
|
export const SpecSelector = (props: SpecSelectorProps) => {
|
|
17
17
|
const { t } = useTranslation(meta.id);
|
|
18
|
-
const specProps =
|
|
18
|
+
const specProps = useFormFieldState(SpecSelector.displayName, ['spec' satisfies keyof Trigger.Trigger]);
|
|
19
19
|
|
|
20
20
|
const handleTypeChange = useCallback(
|
|
21
21
|
(_type: any, value: string): Trigger.Spec | undefined => {
|
|
@@ -47,9 +47,9 @@ export const SpecSelector = (props: SpecSelectorProps) => {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
// Update the entire spec object, not just the `spec.kind`.
|
|
50
|
-
specProps.onValueChange(
|
|
50
|
+
specProps.onValueChange(props.type, defaultSpec);
|
|
51
51
|
},
|
|
52
|
-
[specProps],
|
|
52
|
+
[props.type, specProps],
|
|
53
53
|
);
|
|
54
54
|
|
|
55
55
|
const options = useMemo(
|
|
@@ -61,5 +61,7 @@ export const SpecSelector = (props: SpecSelectorProps) => {
|
|
|
61
61
|
[t],
|
|
62
62
|
);
|
|
63
63
|
|
|
64
|
-
return <
|
|
64
|
+
return <SelectField {...props} options={options} onValueChange={handleTypeChange} />;
|
|
65
65
|
};
|
|
66
|
+
|
|
67
|
+
SpecSelector.displayName = 'Form.SpecSelector';
|
|
@@ -10,10 +10,11 @@ import { Function, Trigger } from '@dxos/functions';
|
|
|
10
10
|
import { invariant } from '@dxos/invariant';
|
|
11
11
|
import { faker } from '@dxos/random';
|
|
12
12
|
import { useQuery } from '@dxos/react-client/echo';
|
|
13
|
-
import {
|
|
13
|
+
import { TestSchema, useClientStory, withClientProvider } from '@dxos/react-client/testing';
|
|
14
14
|
import { useAsyncEffect } from '@dxos/react-ui';
|
|
15
15
|
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
16
|
-
import {
|
|
16
|
+
import { translations as formTranslations } from '@dxos/react-ui-form';
|
|
17
|
+
import { Employer, Organization, Person, Project } from '@dxos/types';
|
|
17
18
|
|
|
18
19
|
import { functions } from '../../testing';
|
|
19
20
|
import { translations } from '../../translations';
|
|
@@ -22,24 +23,24 @@ import { TriggerEditor, type TriggerEditorProps } from './TriggerEditor';
|
|
|
22
23
|
|
|
23
24
|
const types = [
|
|
24
25
|
// TODO(burdon): Get label from annotation.
|
|
25
|
-
{ value:
|
|
26
|
-
{ value:
|
|
27
|
-
{ value: Type.getTypename(
|
|
28
|
-
{ value:
|
|
26
|
+
{ value: Organization.Organization.typename, label: 'Organization' },
|
|
27
|
+
{ value: Person.Person.typename, label: 'Person' },
|
|
28
|
+
{ value: Type.getTypename(Project.Project), label: 'Project' },
|
|
29
|
+
{ value: Employer.Employer.typename, label: 'Employer' },
|
|
29
30
|
];
|
|
30
31
|
|
|
31
32
|
const DefaultStory = (props: Partial<TriggerEditorProps>) => {
|
|
32
|
-
const { space } =
|
|
33
|
+
const { space } = useClientStory();
|
|
33
34
|
const [trigger, setTrigger] = useState<Trigger.Trigger>();
|
|
34
|
-
const tags = useQuery(space, Filter.type(Tag.Tag));
|
|
35
|
+
const tags = useQuery(space?.db, Filter.type(Tag.Tag));
|
|
35
36
|
|
|
36
37
|
useAsyncEffect(async () => {
|
|
37
38
|
if (!space) {
|
|
38
39
|
return;
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
const
|
|
42
|
-
const fn =
|
|
42
|
+
const functions = await space.db.query(Filter.type(Function.Function)).run();
|
|
43
|
+
const fn = functions.find((fn) => fn.name === 'example.com/function/forex');
|
|
43
44
|
invariant(fn);
|
|
44
45
|
const trigger = space.db.add(
|
|
45
46
|
Trigger.make({
|
|
@@ -59,16 +60,14 @@ const DefaultStory = (props: Partial<TriggerEditorProps>) => {
|
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
return (
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
/>
|
|
71
|
-
</div>
|
|
63
|
+
<TriggerEditor
|
|
64
|
+
db={space.db}
|
|
65
|
+
trigger={trigger}
|
|
66
|
+
types={types}
|
|
67
|
+
tags={tags}
|
|
68
|
+
onSave={(values) => console.log('on save', values)}
|
|
69
|
+
{...props}
|
|
70
|
+
/>
|
|
72
71
|
);
|
|
73
72
|
};
|
|
74
73
|
|
|
@@ -78,22 +77,26 @@ const meta = {
|
|
|
78
77
|
render: DefaultStory,
|
|
79
78
|
decorators: [
|
|
80
79
|
withTheme,
|
|
81
|
-
withLayout({
|
|
80
|
+
withLayout({ layout: 'column' }),
|
|
82
81
|
withClientProvider({
|
|
83
82
|
createIdentity: true,
|
|
84
83
|
createSpace: true,
|
|
85
|
-
types: [Tag.Tag, Function.Function, Trigger.Trigger, ContactType],
|
|
84
|
+
types: [Tag.Tag, Function.Function, Trigger.Trigger, TestSchema.ContactType],
|
|
86
85
|
onCreateSpace: ({ space }) => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
// Tags.
|
|
87
|
+
['Important', 'Investor', 'New'].forEach((label) => {
|
|
88
|
+
space.db.add(Tag.make({ label }));
|
|
89
|
+
});
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
// Functions.
|
|
92
|
+
functions.forEach((fn) => {
|
|
92
93
|
space.db.add(Function.make(fn));
|
|
93
|
-
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Objects.
|
|
94
97
|
Array.from({ length: 10 }).map(() => {
|
|
95
98
|
return space.db.add(
|
|
96
|
-
Obj.make(ContactType, {
|
|
99
|
+
Obj.make(TestSchema.ContactType, {
|
|
97
100
|
name: faker.person.fullName(),
|
|
98
101
|
identifiers: [],
|
|
99
102
|
}),
|
|
@@ -103,7 +106,8 @@ const meta = {
|
|
|
103
106
|
}),
|
|
104
107
|
],
|
|
105
108
|
parameters: {
|
|
106
|
-
|
|
109
|
+
layout: 'fullscreen',
|
|
110
|
+
translations: [...formTranslations, ...translations],
|
|
107
111
|
},
|
|
108
112
|
} satisfies Meta<typeof DefaultStory>;
|
|
109
113
|
|
|
@@ -5,59 +5,74 @@
|
|
|
5
5
|
import React, { useCallback, useMemo } from 'react';
|
|
6
6
|
|
|
7
7
|
import { ComputeGraph } from '@dxos/conductor';
|
|
8
|
-
import { type
|
|
8
|
+
import { DXN, type Database, type Query } from '@dxos/echo';
|
|
9
9
|
import { Function, Script, Trigger } from '@dxos/functions';
|
|
10
|
-
import { Filter, Ref,
|
|
10
|
+
import { Filter, Ref, useQuery } from '@dxos/react-client/echo';
|
|
11
11
|
import { Input } from '@dxos/react-ui';
|
|
12
12
|
import { QueryForm, type QueryFormProps } from '@dxos/react-ui-components';
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
import {
|
|
14
|
+
type ExcludeId,
|
|
15
|
+
Form,
|
|
16
|
+
FormFieldLabel,
|
|
17
|
+
type FormFieldMap,
|
|
18
|
+
type FormRootProps,
|
|
19
|
+
SelectField,
|
|
20
|
+
omitId,
|
|
21
|
+
} from '@dxos/react-ui-form';
|
|
22
|
+
|
|
23
|
+
import { FunctionInputEditor } from './FunctionInputEditor';
|
|
16
24
|
import { SpecSelector } from './SpecSelector';
|
|
17
25
|
|
|
26
|
+
type TriggerFormSchema = ExcludeId<typeof Trigger.Trigger>;
|
|
27
|
+
|
|
18
28
|
export type TriggerEditorProps = {
|
|
19
|
-
|
|
29
|
+
db: Database.Database;
|
|
20
30
|
trigger: Trigger.Trigger;
|
|
21
31
|
// TODO(wittjosiah): This needs to apply to whole spec but currently only applies to spec.kind & spec.query.
|
|
22
32
|
readonlySpec?: boolean;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
} &
|
|
34
|
+
// prettier-ignore
|
|
35
|
+
Pick<QueryFormProps, 'types' | 'tags'> &
|
|
36
|
+
Pick<FormRootProps<TriggerFormSchema>, 'onSave' | 'onCancel'>;
|
|
37
|
+
|
|
38
|
+
export const TriggerEditor = ({ db, types, tags, readonlySpec, trigger, ...formProps }: TriggerEditorProps) => {
|
|
39
|
+
const fieldMap = useCustomInputs({
|
|
40
|
+
db,
|
|
41
|
+
types,
|
|
42
|
+
tags,
|
|
43
|
+
readonlySpec,
|
|
44
|
+
});
|
|
34
45
|
|
|
35
46
|
return (
|
|
36
|
-
<Form
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
schema={Trigger.Trigger}
|
|
47
|
+
<Form.Root<TriggerFormSchema>
|
|
48
|
+
{...formProps}
|
|
49
|
+
schema={omitId(Trigger.Trigger)}
|
|
40
50
|
values={trigger}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
51
|
+
db={db}
|
|
52
|
+
fieldMap={fieldMap}
|
|
53
|
+
>
|
|
54
|
+
<Form.Viewport>
|
|
55
|
+
<Form.Content>
|
|
56
|
+
<Form.FieldSet />
|
|
57
|
+
<Form.Actions />
|
|
58
|
+
</Form.Content>
|
|
59
|
+
</Form.Viewport>
|
|
60
|
+
</Form.Root>
|
|
45
61
|
);
|
|
46
62
|
};
|
|
47
63
|
|
|
48
64
|
type UseCustomInputsProps = {
|
|
49
|
-
|
|
65
|
+
db: Database.Database;
|
|
50
66
|
readonlySpec?: boolean;
|
|
51
|
-
onQueryRefOptions: FunctionInputEditorProps['onQueryRefOptions'];
|
|
52
67
|
} & Pick<QueryFormProps, 'types' | 'tags'>;
|
|
53
68
|
|
|
54
|
-
const useCustomInputs = ({
|
|
55
|
-
const functions = useQuery(
|
|
56
|
-
const workflows = useQuery(
|
|
57
|
-
const scripts = useQuery(
|
|
69
|
+
const useCustomInputs = ({ db, readonlySpec, types, tags }: UseCustomInputsProps): FormFieldMap => {
|
|
70
|
+
const functions = useQuery(db, Filter.type(Function.Function));
|
|
71
|
+
const workflows = useQuery(db, Filter.type(ComputeGraph));
|
|
72
|
+
const scripts = useQuery(db, Filter.type(Script.Script));
|
|
58
73
|
|
|
59
74
|
return useMemo(
|
|
60
|
-
():
|
|
75
|
+
(): FormFieldMap => ({
|
|
61
76
|
// Function selector.
|
|
62
77
|
['function' satisfies keyof Trigger.Trigger]: (props) => {
|
|
63
78
|
const getValue = useCallback(() => {
|
|
@@ -70,17 +85,17 @@ const useCustomInputs = ({ space, readonlySpec, types, tags, onQueryRefOptions }
|
|
|
70
85
|
|
|
71
86
|
const handleOnValueChange = useCallback(
|
|
72
87
|
(_type: any, dxnString: string) => {
|
|
73
|
-
const dxn =
|
|
88
|
+
const dxn = DXN.parse(dxnString);
|
|
74
89
|
if (dxn) {
|
|
75
90
|
const ref = Ref.fromDXN(dxn);
|
|
76
|
-
props.onValueChange(
|
|
91
|
+
props.onValueChange(props.type, ref);
|
|
77
92
|
}
|
|
78
93
|
},
|
|
79
|
-
[props.onValueChange],
|
|
94
|
+
[props.type, props.onValueChange],
|
|
80
95
|
);
|
|
81
96
|
|
|
82
97
|
return (
|
|
83
|
-
<
|
|
98
|
+
<SelectField
|
|
84
99
|
{...props}
|
|
85
100
|
getValue={getValue as any}
|
|
86
101
|
onValueChange={handleOnValueChange}
|
|
@@ -90,28 +105,26 @@ const useCustomInputs = ({ space, readonlySpec, types, tags, onQueryRefOptions }
|
|
|
90
105
|
},
|
|
91
106
|
|
|
92
107
|
// Spec selector.
|
|
93
|
-
['spec.kind' as const]: (props) => <SpecSelector {...props} readonly={readonlySpec
|
|
108
|
+
['spec.kind' as const]: (props) => <SpecSelector {...props} readonly={readonlySpec} />,
|
|
94
109
|
|
|
95
110
|
// TODO(wittjosiah): Copied from ViewEditor.
|
|
96
111
|
// Query input editor.
|
|
97
112
|
['spec.query' as const]: (props) => {
|
|
98
113
|
const handleChange = useCallback(
|
|
99
|
-
(query: Query.Any) => props.onValueChange(
|
|
100
|
-
[props.onValueChange],
|
|
114
|
+
(query: Query.Any) => props.onValueChange(props.type, { ast: query.ast }),
|
|
115
|
+
[props.type, props.onValueChange],
|
|
101
116
|
);
|
|
102
117
|
|
|
103
118
|
return (
|
|
104
119
|
<Input.Root>
|
|
105
|
-
<
|
|
120
|
+
<FormFieldLabel label={props.label} asChild />
|
|
106
121
|
<QueryForm initialQuery={(props.getValue() as any).ast} types={types} tags={tags} onChange={handleChange} />
|
|
107
122
|
</Input.Root>
|
|
108
123
|
);
|
|
109
124
|
},
|
|
110
125
|
|
|
111
126
|
// Function input editor.
|
|
112
|
-
['input' as const]: (props) =>
|
|
113
|
-
<FunctionInputEditor {...props} functions={functions} onQueryRefOptions={onQueryRefOptions} />
|
|
114
|
-
),
|
|
127
|
+
['input' as const]: (props) => <FunctionInputEditor {...props} functions={functions} db={db} />,
|
|
115
128
|
}),
|
|
116
129
|
[workflows, scripts, functions, readonlySpec],
|
|
117
130
|
);
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type Database } from '@dxos/echo';
|
|
8
8
|
import { Input, useTranslation } from '@dxos/react-ui';
|
|
9
9
|
import { ControlItemInput } from '@dxos/react-ui-form';
|
|
10
10
|
|
|
11
11
|
import { useTriggerRuntimeControls } from '../hooks';
|
|
12
12
|
import { meta } from '../meta';
|
|
13
13
|
|
|
14
|
-
export const TriggersSettings = ({
|
|
15
|
-
const { triggers, isRunning, start, stop } = useTriggerRuntimeControls(
|
|
14
|
+
export const TriggersSettings = ({ db }: { db: Database.Database }) => {
|
|
15
|
+
const { triggers, isRunning, start, stop } = useTriggerRuntimeControls(db);
|
|
16
16
|
const { t } = useTranslation(meta.id);
|
|
17
17
|
|
|
18
18
|
return (
|