@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
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/meta.ts"],
|
|
4
|
+
"sourcesContent": ["//\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: 'dxos.org/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--robot--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-automation',\n};\n"],
|
|
5
|
+
"mappings": ";;;AAKA,SAASA,YAAY;AAEd,IAAMC,OAAoB;EAC/BC,IAAI;EACJC,MAAM;EACNC,aAAaC;;;;EAIbC,MAAM;EACNC,QAAQ;AACV;",
|
|
6
|
+
"names": ["trim", "meta", "id", "name", "description", "trim", "icon", "source"]
|
|
7
|
+
}
|
|
@@ -2,10 +2,10 @@ import { createRequire } from 'node:module';const require = createRequire(import
|
|
|
2
2
|
|
|
3
3
|
// src/components/index.ts
|
|
4
4
|
import { lazy } from "react";
|
|
5
|
-
var AutomationPanel = lazy(() => import("./AutomationPanel-
|
|
6
|
-
var AutomationSettings = lazy(() => import("./AutomationSettings-
|
|
7
|
-
var FunctionsContainer = lazy(() => import("./FunctionsContainer-
|
|
8
|
-
var FunctionsPanel = lazy(() => import("./FunctionsPanel-
|
|
5
|
+
var AutomationPanel = lazy(() => import("./AutomationPanel-B7NAGDFA.mjs"));
|
|
6
|
+
var AutomationSettings = lazy(() => import("./AutomationSettings-M5PMZJ6P.mjs"));
|
|
7
|
+
var FunctionsContainer = lazy(() => import("./FunctionsContainer-J4O2ULWR.mjs"));
|
|
8
|
+
var FunctionsPanel = lazy(() => import("./FunctionsPanel-SS6GIVNU.mjs"));
|
|
9
9
|
|
|
10
10
|
export {
|
|
11
11
|
AutomationPanel,
|
|
@@ -13,4 +13,4 @@ export {
|
|
|
13
13
|
FunctionsContainer,
|
|
14
14
|
FunctionsPanel
|
|
15
15
|
};
|
|
16
|
-
//# sourceMappingURL=chunk-
|
|
16
|
+
//# sourceMappingURL=chunk-7QRUPEHH.mjs.map
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
AutomationCapabilities
|
|
4
|
+
} from "./chunk-RX52VKI2.mjs";
|
|
5
|
+
|
|
6
|
+
// src/hooks/useComputeRuntimeCallback.ts
|
|
7
|
+
import * as Cause from "effect/Cause";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import * as Exit from "effect/Exit";
|
|
10
|
+
import { useCallback } from "react";
|
|
11
|
+
import { useCapability } from "@dxos/app-framework/react";
|
|
12
|
+
import { FunctionInvocationService, TracingService } from "@dxos/functions";
|
|
13
|
+
import { log } from "@dxos/log";
|
|
14
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-automation/src/hooks/useComputeRuntimeCallback.ts";
|
|
15
|
+
var useComputeRuntimeCallback = (id, fn, deps) => {
|
|
16
|
+
const computeRuntime = useCapability(AutomationCapabilities.ComputeRuntime);
|
|
17
|
+
const runtime = id !== void 0 ? computeRuntime.getRuntime(id) : void 0;
|
|
18
|
+
return useCallback(() => {
|
|
19
|
+
if (!runtime) {
|
|
20
|
+
throw new TypeError("Space not provided to useComputeRuntimeCallback");
|
|
21
|
+
}
|
|
22
|
+
return runtime.runPromise(fn());
|
|
23
|
+
}, [
|
|
24
|
+
runtime,
|
|
25
|
+
...deps ?? []
|
|
26
|
+
]);
|
|
27
|
+
};
|
|
28
|
+
var invokeFunctionWithTracing = (functionDef, inputData) => Effect.gen(function* () {
|
|
29
|
+
const tracer = yield* TracingService;
|
|
30
|
+
const trace = yield* tracer.traceInvocationStart({
|
|
31
|
+
target: void 0,
|
|
32
|
+
payload: {
|
|
33
|
+
data: {}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
const result = yield* FunctionInvocationService.invokeFunction(functionDef, inputData).pipe(Effect.provide(trace.invocationTraceQueue ? TracingService.layerInvocation(trace) : TracingService.layerNoop), Effect.exit);
|
|
37
|
+
if (Exit.isFailure(result)) {
|
|
38
|
+
const error = Cause.prettyErrors(result.cause)[0];
|
|
39
|
+
log.error(error.message, error.cause ?? error.stack, {
|
|
40
|
+
F: __dxlog_file,
|
|
41
|
+
L: 57,
|
|
42
|
+
S: this,
|
|
43
|
+
C: (f, a) => f(...a)
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
yield* tracer.traceInvocationEnd({
|
|
47
|
+
trace,
|
|
48
|
+
// TODO(dmaretskyi): Might miss errors.
|
|
49
|
+
exception: Exit.isFailure(result) ? Cause.prettyErrors(result.cause)[0] : void 0
|
|
50
|
+
});
|
|
51
|
+
return result;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// src/hooks/useTriggerRuntimeControls.ts
|
|
55
|
+
import * as Effect2 from "effect/Effect";
|
|
56
|
+
import { Filter } from "@dxos/echo";
|
|
57
|
+
import { Trigger } from "@dxos/functions";
|
|
58
|
+
import { TriggerDispatcher } from "@dxos/functions-runtime";
|
|
59
|
+
import { useQuery } from "@dxos/react-client/echo";
|
|
60
|
+
import { useAsyncState } from "@dxos/react-ui";
|
|
61
|
+
var useTriggerRuntimeControls = (db) => {
|
|
62
|
+
const triggers = useQuery(db, Filter.type(Trigger.Trigger));
|
|
63
|
+
const [isRunningState, setIsRunningState] = useAsyncState(useComputeRuntimeCallback(db?.spaceId, () => TriggerDispatcher.pipe(Effect2.map((t) => t.running))));
|
|
64
|
+
const start = useComputeRuntimeCallback(db?.spaceId, Effect2.fnUntraced(function* () {
|
|
65
|
+
const dispatcher = yield* TriggerDispatcher;
|
|
66
|
+
yield* dispatcher.start();
|
|
67
|
+
setIsRunningState(true);
|
|
68
|
+
}));
|
|
69
|
+
const stop = useComputeRuntimeCallback(db?.spaceId, Effect2.fnUntraced(function* () {
|
|
70
|
+
const dispatcher = yield* TriggerDispatcher;
|
|
71
|
+
yield* dispatcher.stop();
|
|
72
|
+
setIsRunningState(false);
|
|
73
|
+
}));
|
|
74
|
+
return {
|
|
75
|
+
triggers,
|
|
76
|
+
isRunning: isRunningState ?? false,
|
|
77
|
+
start: () => void start(),
|
|
78
|
+
stop: () => void stop()
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export {
|
|
83
|
+
useComputeRuntimeCallback,
|
|
84
|
+
invokeFunctionWithTracing,
|
|
85
|
+
useTriggerRuntimeControls
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=chunk-HQLVREIX.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/react';\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 * as Effect from 'effect/Effect';\n\nimport { type Database, Filter } from '@dxos/echo';\nimport { Trigger } from '@dxos/functions';\nimport { TriggerDispatcher } from '@dxos/functions-runtime';\nimport { useQuery } from '@dxos/react-client/echo';\nimport { useAsyncState } from '@dxos/react-ui';\n\nimport { useComputeRuntimeCallback } from './useComputeRuntimeCallback';\n\ninterface TriggerRuntimeControls {\n triggers: Trigger.Trigger[];\n isRunning: boolean;\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 [isRunningState, setIsRunningState] = useAsyncState(\n useComputeRuntimeCallback(db?.spaceId, () => TriggerDispatcher.pipe(Effect.map((t) => t.running))),\n );\n\n const start = useComputeRuntimeCallback(\n db?.spaceId,\n Effect.fnUntraced(function* () {\n const dispatcher = yield* TriggerDispatcher;\n yield* dispatcher.start();\n setIsRunningState(true);\n }),\n );\n\n const stop = useComputeRuntimeCallback(\n db?.spaceId,\n Effect.fnUntraced(function* () {\n const dispatcher = yield* TriggerDispatcher;\n yield* dispatcher.stop();\n setIsRunningState(false);\n }),\n );\n\n return {\n triggers,\n isRunning: isRunningState ?? false,\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,q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AACxC,QAAMC,WAAWC,SAASF,IAAIG,OAAOC,KAAKC,QAAQA,OAAO,CAAA;AAEzD,QAAM,CAACC,gBAAgBC,iBAAAA,IAAqBC,cAC1CC,0BAA0BT,IAAIU,SAAS,MAAMC,kBAAkBC,KAAYC,YAAI,CAACC,MAAMA,EAAEC,OAAO,CAAA,CAAA,CAAA;AAGjG,QAAMC,QAAQP,0BACZT,IAAIU,SACGO,mBAAW,aAAA;AAChB,UAAMC,aAAa,OAAOP;AAC1B,WAAOO,WAAWF,MAAK;AACvBT,sBAAkB,IAAA;EACpB,CAAA,CAAA;AAGF,QAAMY,OAAOV,0BACXT,IAAIU,SACGO,mBAAW,aAAA;AAChB,UAAMC,aAAa,OAAOP;AAC1B,WAAOO,WAAWC,KAAI;AACtBZ,sBAAkB,KAAA;EACpB,CAAA,CAAA;AAGF,SAAO;IACLN;IACAmB,WAAWd,kBAAkB;IAC7BU,OAAO,MAAM,KAAKA,MAAAA;IAClBG,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", "Effect", "Filter", "Trigger", "TriggerDispatcher", "useQuery", "useAsyncState", "useTriggerRuntimeControls", "db", "triggers", "useQuery", "Filter", "type", "Trigger", "isRunningState", "setIsRunningState", "useAsyncState", "useComputeRuntimeCallback", "spaceId", "TriggerDispatcher", "pipe", "map", "t", "running", "start", "fnUntraced", "dispatcher", "stop", "isRunning"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/capabilities/compute-runtime/index.ts
|
|
4
|
+
import { Capability } from "@dxos/app-framework";
|
|
5
|
+
var ComputeRuntime = Capability.lazy("ComputeRuntime", () => import("./compute-runtime-ZHROOBLY.mjs"));
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
ComputeRuntime
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=chunk-K7GCM342.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/compute-runtime/index.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capability } from '@dxos/app-framework';\n\nexport const ComputeRuntime = Capability.lazy('ComputeRuntime', () => import('./compute-runtime'));\n"],
|
|
5
|
+
"mappings": ";;;AAIA,SAASA,kBAAkB;AAEpB,IAAMC,iBAAiBC,WAAWC,KAAK,kBAAkB,MAAM,OAAO,gCAAA,CAAA;",
|
|
6
|
+
"names": ["Capability", "ComputeRuntime", "Capability", "lazy"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
meta
|
|
4
|
+
} from "./chunk-5FXNN3MV.mjs";
|
|
5
|
+
|
|
6
|
+
// src/components/FunctionsPanel/FunctionsPanel.tsx
|
|
7
|
+
import * as Schema from "effect/Schema";
|
|
8
|
+
import React, { useCallback, useMemo } from "react";
|
|
9
|
+
import { Common } from "@dxos/app-framework";
|
|
10
|
+
import { useOperationInvoker } from "@dxos/app-framework/react";
|
|
11
|
+
import { Obj } from "@dxos/echo";
|
|
12
|
+
import { Function, Script } from "@dxos/functions";
|
|
13
|
+
import { SpaceOperation } from "@dxos/plugin-space/types";
|
|
14
|
+
import { Filter, useQuery } from "@dxos/react-client/echo";
|
|
15
|
+
import { Button, IconButton, useTranslation } from "@dxos/react-ui";
|
|
16
|
+
import { controlItemClasses } from "@dxos/react-ui-form";
|
|
17
|
+
import { List } from "@dxos/react-ui-list";
|
|
18
|
+
import { ghostHover, mx } from "@dxos/ui-theme";
|
|
19
|
+
var grid = "grid grid-cols-[1fr_auto] min-bs-[2.5rem]";
|
|
20
|
+
var FunctionsPanel = ({ space }) => {
|
|
21
|
+
const { t } = useTranslation(meta.id);
|
|
22
|
+
const functions = useQuery(space.db, Filter.type(Function.Function));
|
|
23
|
+
const scripts = useQuery(space.db, Filter.type(Script.Script));
|
|
24
|
+
const { invokePromise } = useOperationInvoker();
|
|
25
|
+
const functionToScriptMap = useMemo(() => functions.reduce((map, func) => {
|
|
26
|
+
const scriptId = func.source?.target?.id;
|
|
27
|
+
if (scriptId) {
|
|
28
|
+
const script = scripts.find((s) => s.id === scriptId);
|
|
29
|
+
if (script) {
|
|
30
|
+
map[func.id] = script;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return map;
|
|
34
|
+
}, {}), [
|
|
35
|
+
functions,
|
|
36
|
+
scripts
|
|
37
|
+
]);
|
|
38
|
+
const getScriptName = useCallback((func) => {
|
|
39
|
+
const script = functionToScriptMap[func.id];
|
|
40
|
+
return script?.name;
|
|
41
|
+
}, [
|
|
42
|
+
functionToScriptMap
|
|
43
|
+
]);
|
|
44
|
+
const handleGoToScript = useCallback((func) => {
|
|
45
|
+
const script = functionToScriptMap[func.id];
|
|
46
|
+
if (script) {
|
|
47
|
+
void invokePromise(Common.LayoutOperation.Open, {
|
|
48
|
+
subject: [
|
|
49
|
+
Obj.getDXN(script).toString()
|
|
50
|
+
]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}, [
|
|
54
|
+
functionToScriptMap,
|
|
55
|
+
invokePromise
|
|
56
|
+
]);
|
|
57
|
+
const handleDelete = useCallback((func) => invokePromise(SpaceOperation.RemoveObjects, {
|
|
58
|
+
objects: [
|
|
59
|
+
func
|
|
60
|
+
]
|
|
61
|
+
}), [
|
|
62
|
+
invokePromise
|
|
63
|
+
]);
|
|
64
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
65
|
+
role: "none",
|
|
66
|
+
className: mx(controlItemClasses)
|
|
67
|
+
}, functions.length > 0 && /* @__PURE__ */ React.createElement(List.Root, {
|
|
68
|
+
items: functions,
|
|
69
|
+
isItem: Schema.is(Function.Function),
|
|
70
|
+
getId: (func) => func.id
|
|
71
|
+
}, ({ items }) => /* @__PURE__ */ React.createElement("div", {
|
|
72
|
+
role: "list",
|
|
73
|
+
className: "flex flex-col is-full"
|
|
74
|
+
}, items?.map((func) => /* @__PURE__ */ React.createElement(List.Item, {
|
|
75
|
+
key: func.id,
|
|
76
|
+
item: func,
|
|
77
|
+
classNames: mx(grid, ghostHover, "items-center", "pli-2", "min-bs-[3rem]")
|
|
78
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
79
|
+
className: "flex flex-col truncate"
|
|
80
|
+
}, /* @__PURE__ */ React.createElement(List.ItemTitle, {
|
|
81
|
+
classNames: "truncate"
|
|
82
|
+
}, func.name), getScriptName(func) && /* @__PURE__ */ React.createElement("div", {
|
|
83
|
+
className: "text-xs text-description truncate"
|
|
84
|
+
}, getScriptName(func))), functionToScriptMap[func.id] && /* @__PURE__ */ React.createElement(Button, {
|
|
85
|
+
onClick: () => handleGoToScript(func)
|
|
86
|
+
}, t("go to function source button label")), /* @__PURE__ */ React.createElement(IconButton, {
|
|
87
|
+
iconOnly: true,
|
|
88
|
+
icon: "ph--trash--regular",
|
|
89
|
+
label: t("delete function button label"),
|
|
90
|
+
onClick: () => handleDelete(func)
|
|
91
|
+
}))))), functions.length === 0 && /* @__PURE__ */ React.createElement("div", {
|
|
92
|
+
className: "text-center plb-4 text-gray-500"
|
|
93
|
+
}, t("no functions found")));
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// src/components/FunctionsPanel/index.ts
|
|
97
|
+
var FunctionsPanel_default = FunctionsPanel;
|
|
98
|
+
|
|
99
|
+
export {
|
|
100
|
+
FunctionsPanel,
|
|
101
|
+
FunctionsPanel_default
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=chunk-KWKWOGS5.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 { Common } from '@dxos/app-framework';\nimport { useOperationInvoker } from '@dxos/app-framework/react';\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 { controlItemClasses } 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\nconst grid = 'grid grid-cols-[1fr_auto] min-bs-[2.5rem]';\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(Common.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 <div role='none' className={mx(controlItemClasses)}>\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(grid, ghostHover, 'items-center', 'pli-2', 'min-bs-[3rem]')}\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-gray-500'>{t('no functions found')}</div>}\n </div>\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { FunctionsPanel } from './FunctionsPanel';\n\nexport * from './FunctionsPanel';\nexport default FunctionsPanel;\n"],
|
|
5
|
+
"mappings": ";;;;;;AAIA,YAAYA,YAAY;AACxB,OAAOC,SAASC,aAAaC,eAAe;AAE5C,SAASC,cAAc;AACvB,SAASC,2BAA2B;AACpC,SAASC,WAAW;AACpB,SAASC,UAAUC,cAAc;AACjC,SAAS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AAe;IAAEC,SAAS;MAACrB;;EAAM,CAAA,GAC3F;IAACN;GAAc;AAGjB,SACE,sBAAA,cAAC4B,OAAAA;IAAIC,MAAK;IAAOC,WAAWC,GAAGC,kBAAAA;KAC5BxC,UAAUyC,SAAS,KAClB,sBAAA,cAACC,KAAKC,MAAI;IAAoBC,OAAO5C;IAAW6C,QAAeC,UAAGzC,SAASA,QAAQ;IAAG0C,OAAO,CAACjC,SAASA,KAAKf;KACzG,CAAC,EAAE6C,MAAK,MACP,sBAAA,cAACR,OAAAA;IAAIC,MAAK;IAAOC,WAAU;KACxBM,OAAO/B,IAAI,CAACC,SACX,sBAAA,cAAC4B,KAAKM,MAAI;IACRC,KAAKnC,KAAKf;IACVmD,MAAMpC;IACNqC,YAAYZ,GAAG9C,MAAM2D,YAAY,gBAAgB,SAAS,eAAA;KAE1D,sBAAA,cAAChB,OAAAA;IAAIE,WAAU;KACb,sBAAA,cAACI,KAAKW,WAAS;IAACF,YAAW;KAAYrC,KAAKS,IAAI,GAC/CF,cAAcP,IAAAA,KACb,sBAAA,cAACsB,OAAAA;IAAIE,WAAU;KAAqCjB,cAAcP,IAAAA,CAAAA,CAAAA,GAGrEJ,oBAAoBI,KAAKf,EAAE,KAC1B,sBAAA,cAACuD,QAAAA;IAAOC,SAAS,MAAM/B,iBAAiBV,IAAAA;KAAQlB,EAAE,oCAAA,CAAA,GAEpD,sBAAA,cAAC4D,YAAAA;IACCC,UAAAA;IACAC,MAAK;IACLC,OAAO/D,EAAE,8BAAA;IACT2D,SAAS,MAAMvB,aAAalB,IAAAA;UASzCd,UAAUyC,WAAW,KAAK,sBAAA,cAACL,OAAAA;IAAIE,WAAU;KAAmC1C,EAAE,oBAAA,CAAA,CAAA;AAGrF;;;ACvGA,IAAA,yBAAegE;",
|
|
6
|
+
"names": ["Schema", "React", "useCallback", "useMemo", "Common", "useOperationInvoker", "Obj", "Function", "Script", "SpaceOperation", "Filter", "useQuery", "Button", "IconButton", "useTranslation", "controlItemClasses", "List", "ghostHover", "mx", "grid", "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", "Common", "LayoutOperation", "Open", "subject", "Obj", "getDXN", "toString", "handleDelete", "SpaceOperation", "RemoveObjects", "objects", "div", "role", "className", "mx", "controlItemClasses", "length", "List", "Root", "items", "isItem", "is", "getId", "Item", "key", "item", "classNames", "ghostHover", "ItemTitle", "Button", "onClick", "IconButton", "iconOnly", "icon", "label", "FunctionsPanel"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
meta
|
|
4
|
+
} from "./chunk-5FXNN3MV.mjs";
|
|
5
|
+
|
|
6
|
+
// src/components/TriggerEditor/TriggerEditor.tsx
|
|
7
|
+
import React3, { useCallback as useCallback3, useMemo as useMemo3 } from "react";
|
|
8
|
+
import { ComputeGraph } from "@dxos/conductor";
|
|
9
|
+
import { DXN } from "@dxos/echo";
|
|
10
|
+
import { Function, Script, Trigger as Trigger2 } from "@dxos/functions";
|
|
11
|
+
import { Filter as Filter2, Ref as Ref2, useQuery } from "@dxos/react-client/echo";
|
|
12
|
+
import { Input } from "@dxos/react-ui";
|
|
13
|
+
import { QueryForm } from "@dxos/react-ui-components";
|
|
14
|
+
import { Form as Form2, FormFieldLabel, SelectField as SelectField2, omitId } from "@dxos/react-ui-form";
|
|
15
|
+
|
|
16
|
+
// src/components/TriggerEditor/FunctionInputEditor.tsx
|
|
17
|
+
import React, { useCallback, useMemo } from "react";
|
|
18
|
+
import { Ref, Type } from "@dxos/echo";
|
|
19
|
+
import { useOnTransition, useTranslation } from "@dxos/react-ui";
|
|
20
|
+
import { Form, useFormValues } from "@dxos/react-ui-form";
|
|
21
|
+
var FunctionInputEditor = ({ type, functions, db, getValue, onValueChange }) => {
|
|
22
|
+
const { t } = useTranslation(meta.id);
|
|
23
|
+
const selectedFunctionValue = useFormValues(FunctionInputEditor.displayName, [
|
|
24
|
+
"function"
|
|
25
|
+
]);
|
|
26
|
+
const selectedFunctionId = useMemo(() => {
|
|
27
|
+
if (Ref.isRef(selectedFunctionValue)) {
|
|
28
|
+
return selectedFunctionValue.dxn.toString().split("dxn:echo:@:").at(1);
|
|
29
|
+
}
|
|
30
|
+
}, [
|
|
31
|
+
selectedFunctionValue
|
|
32
|
+
]);
|
|
33
|
+
const selectedFunction = useMemo(() => functions.find((fn) => fn.id === selectedFunctionId), [
|
|
34
|
+
functions,
|
|
35
|
+
selectedFunctionId
|
|
36
|
+
]);
|
|
37
|
+
useOnTransition(
|
|
38
|
+
// Clear function parameter input when the function changes.
|
|
39
|
+
selectedFunctionValue,
|
|
40
|
+
(prevValue) => {
|
|
41
|
+
if (!Ref.isRef(prevValue) || !Ref.isRef(selectedFunctionValue)) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
return prevValue.dxn.toString() !== selectedFunctionValue.dxn.toString();
|
|
45
|
+
},
|
|
46
|
+
(currValue) => currValue !== void 0,
|
|
47
|
+
() => onValueChange(type, {})
|
|
48
|
+
);
|
|
49
|
+
const inputSchema = useMemo(() => selectedFunction?.inputSchema, [
|
|
50
|
+
selectedFunction
|
|
51
|
+
]);
|
|
52
|
+
const effectSchema = useMemo(() => inputSchema ? Type.toEffectSchema(inputSchema) : void 0, [
|
|
53
|
+
inputSchema
|
|
54
|
+
]);
|
|
55
|
+
const propertyCount = inputSchema?.properties ? Object.keys(inputSchema.properties).length : 0;
|
|
56
|
+
const values = useMemo(() => getValue() ?? {}, [
|
|
57
|
+
getValue
|
|
58
|
+
]);
|
|
59
|
+
const handleValuesChanged = useCallback((values2) => {
|
|
60
|
+
onValueChange(type, values2);
|
|
61
|
+
}, [
|
|
62
|
+
type,
|
|
63
|
+
onValueChange
|
|
64
|
+
]);
|
|
65
|
+
if (selectedFunction === void 0 || effectSchema === void 0 || propertyCount === 0) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Form.Label, {
|
|
69
|
+
label: t("function parameters label"),
|
|
70
|
+
asChild: true
|
|
71
|
+
}), /* @__PURE__ */ React.createElement(Form.Root, {
|
|
72
|
+
schema: effectSchema,
|
|
73
|
+
values,
|
|
74
|
+
db,
|
|
75
|
+
onValuesChanged: handleValuesChanged
|
|
76
|
+
}, /* @__PURE__ */ React.createElement(Form.FieldSet, null)));
|
|
77
|
+
};
|
|
78
|
+
FunctionInputEditor.displayName = "AutomationTrigger.FunctionInputEditor";
|
|
79
|
+
|
|
80
|
+
// src/components/TriggerEditor/SpecSelector.tsx
|
|
81
|
+
import React2, { useCallback as useCallback2, useMemo as useMemo2 } from "react";
|
|
82
|
+
import { Filter, Query } from "@dxos/echo";
|
|
83
|
+
import { Trigger } from "@dxos/functions";
|
|
84
|
+
import { useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
85
|
+
import { SelectField, useFormFieldState } from "@dxos/react-ui-form";
|
|
86
|
+
var SpecSelector = (props) => {
|
|
87
|
+
const { t } = useTranslation2(meta.id);
|
|
88
|
+
const specProps = useFormFieldState(SpecSelector.displayName, [
|
|
89
|
+
"spec"
|
|
90
|
+
]);
|
|
91
|
+
const handleTypeChange = useCallback2((_type, value) => {
|
|
92
|
+
const getDefaultTriggerSpec = (kind) => {
|
|
93
|
+
switch (kind) {
|
|
94
|
+
case "timer":
|
|
95
|
+
return {
|
|
96
|
+
kind: "timer",
|
|
97
|
+
cron: ""
|
|
98
|
+
};
|
|
99
|
+
case "subscription":
|
|
100
|
+
return {
|
|
101
|
+
kind: "subscription",
|
|
102
|
+
query: {
|
|
103
|
+
ast: Query.select(Filter.nothing()).ast
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
case "queue":
|
|
107
|
+
return {
|
|
108
|
+
kind: "queue",
|
|
109
|
+
queue: "dxn:"
|
|
110
|
+
};
|
|
111
|
+
case "email":
|
|
112
|
+
return {
|
|
113
|
+
kind: "email"
|
|
114
|
+
};
|
|
115
|
+
case "webhook":
|
|
116
|
+
return {
|
|
117
|
+
kind: "webhook"
|
|
118
|
+
};
|
|
119
|
+
default:
|
|
120
|
+
return void 0;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
const defaultSpec = getDefaultTriggerSpec(value);
|
|
124
|
+
if (!defaultSpec) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
specProps.onValueChange(props.type, defaultSpec);
|
|
128
|
+
}, [
|
|
129
|
+
props.type,
|
|
130
|
+
specProps
|
|
131
|
+
]);
|
|
132
|
+
const options = useMemo2(() => Trigger.Kinds.map((kind) => ({
|
|
133
|
+
value: kind,
|
|
134
|
+
label: t(`trigger type ${kind}`)
|
|
135
|
+
})), [
|
|
136
|
+
t
|
|
137
|
+
]);
|
|
138
|
+
return /* @__PURE__ */ React2.createElement(SelectField, {
|
|
139
|
+
...props,
|
|
140
|
+
options,
|
|
141
|
+
onValueChange: handleTypeChange
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
SpecSelector.displayName = "Form.SpecSelector";
|
|
145
|
+
|
|
146
|
+
// src/components/TriggerEditor/TriggerEditor.tsx
|
|
147
|
+
var TriggerEditor = ({ db, types, tags, readonlySpec, trigger, ...formProps }) => {
|
|
148
|
+
const fieldMap = useCustomInputs({
|
|
149
|
+
db,
|
|
150
|
+
types,
|
|
151
|
+
tags,
|
|
152
|
+
readonlySpec
|
|
153
|
+
});
|
|
154
|
+
return /* @__PURE__ */ React3.createElement(Form2.Root, {
|
|
155
|
+
...formProps,
|
|
156
|
+
schema: omitId(Trigger2.Trigger),
|
|
157
|
+
values: trigger,
|
|
158
|
+
db,
|
|
159
|
+
fieldMap
|
|
160
|
+
}, /* @__PURE__ */ React3.createElement(Form2.Viewport, null, /* @__PURE__ */ React3.createElement(Form2.Content, null, /* @__PURE__ */ React3.createElement(Form2.FieldSet, null), /* @__PURE__ */ React3.createElement(Form2.Actions, null))));
|
|
161
|
+
};
|
|
162
|
+
var useCustomInputs = ({ db, readonlySpec, types, tags }) => {
|
|
163
|
+
const functions = useQuery(db, Filter2.type(Function.Function));
|
|
164
|
+
const workflows = useQuery(db, Filter2.type(ComputeGraph));
|
|
165
|
+
const scripts = useQuery(db, Filter2.type(Script.Script));
|
|
166
|
+
return useMemo3(() => ({
|
|
167
|
+
// Function selector.
|
|
168
|
+
["function"]: (props) => {
|
|
169
|
+
const getValue = useCallback3(() => {
|
|
170
|
+
const formValue = props.getValue();
|
|
171
|
+
if (Ref2.isRef(formValue)) {
|
|
172
|
+
return formValue.dxn.toString();
|
|
173
|
+
}
|
|
174
|
+
return void 0;
|
|
175
|
+
}, [
|
|
176
|
+
props
|
|
177
|
+
]);
|
|
178
|
+
const handleOnValueChange = useCallback3((_type, dxnString) => {
|
|
179
|
+
const dxn = DXN.parse(dxnString);
|
|
180
|
+
if (dxn) {
|
|
181
|
+
const ref = Ref2.fromDXN(dxn);
|
|
182
|
+
props.onValueChange(props.type, ref);
|
|
183
|
+
}
|
|
184
|
+
}, [
|
|
185
|
+
props.type,
|
|
186
|
+
props.onValueChange
|
|
187
|
+
]);
|
|
188
|
+
return /* @__PURE__ */ React3.createElement(SelectField2, {
|
|
189
|
+
...props,
|
|
190
|
+
getValue,
|
|
191
|
+
onValueChange: handleOnValueChange,
|
|
192
|
+
options: getWorkflowOptions(workflows).concat(getFunctionOptions(scripts, functions))
|
|
193
|
+
});
|
|
194
|
+
},
|
|
195
|
+
// Spec selector.
|
|
196
|
+
["spec.kind"]: (props) => /* @__PURE__ */ React3.createElement(SpecSelector, {
|
|
197
|
+
...props,
|
|
198
|
+
readonly: readonlySpec
|
|
199
|
+
}),
|
|
200
|
+
// TODO(wittjosiah): Copied from ViewEditor.
|
|
201
|
+
// Query input editor.
|
|
202
|
+
["spec.query"]: (props) => {
|
|
203
|
+
const handleChange = useCallback3((query) => props.onValueChange(props.type, {
|
|
204
|
+
ast: query.ast
|
|
205
|
+
}), [
|
|
206
|
+
props.type,
|
|
207
|
+
props.onValueChange
|
|
208
|
+
]);
|
|
209
|
+
return /* @__PURE__ */ React3.createElement(Input.Root, null, /* @__PURE__ */ React3.createElement(FormFieldLabel, {
|
|
210
|
+
label: props.label,
|
|
211
|
+
asChild: true
|
|
212
|
+
}), /* @__PURE__ */ React3.createElement(QueryForm, {
|
|
213
|
+
initialQuery: props.getValue().ast,
|
|
214
|
+
types,
|
|
215
|
+
tags,
|
|
216
|
+
onChange: handleChange
|
|
217
|
+
}));
|
|
218
|
+
},
|
|
219
|
+
// Function input editor.
|
|
220
|
+
["input"]: (props) => /* @__PURE__ */ React3.createElement(FunctionInputEditor, {
|
|
221
|
+
...props,
|
|
222
|
+
functions,
|
|
223
|
+
db
|
|
224
|
+
})
|
|
225
|
+
}), [
|
|
226
|
+
workflows,
|
|
227
|
+
scripts,
|
|
228
|
+
functions,
|
|
229
|
+
readonlySpec
|
|
230
|
+
]);
|
|
231
|
+
};
|
|
232
|
+
var getWorkflowOptions = (graphs) => {
|
|
233
|
+
return graphs.map((graph) => ({
|
|
234
|
+
label: `compute-${graph.id}`,
|
|
235
|
+
value: `dxn:echo:@:${graph.id}`
|
|
236
|
+
}));
|
|
237
|
+
};
|
|
238
|
+
var getFunctionOptions = (scripts, functions) => {
|
|
239
|
+
const getLabel = (fn) => scripts.find((s) => fn.source?.target?.id === s.id)?.name ?? fn.name;
|
|
240
|
+
return functions.map((fn) => ({
|
|
241
|
+
label: getLabel(fn),
|
|
242
|
+
value: `dxn:echo:@:${fn.id}`
|
|
243
|
+
}));
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
export {
|
|
247
|
+
TriggerEditor
|
|
248
|
+
};
|
|
249
|
+
//# sourceMappingURL=chunk-LJAXQ6CX.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/TriggerEditor/TriggerEditor.tsx", "../../../src/components/TriggerEditor/FunctionInputEditor.tsx", "../../../src/components/TriggerEditor/SpecSelector.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { useCallback, useMemo } from 'react';\n\nimport { ComputeGraph } from '@dxos/conductor';\nimport { DXN, type Database, type Query } from '@dxos/echo';\nimport { Function, Script, Trigger } from '@dxos/functions';\nimport { Filter, Ref, useQuery } from '@dxos/react-client/echo';\nimport { Input } from '@dxos/react-ui';\nimport { QueryForm, type QueryFormProps } from '@dxos/react-ui-components';\nimport {\n type ExcludeId,\n Form,\n FormFieldLabel,\n type FormFieldMap,\n type FormRootProps,\n SelectField,\n omitId,\n} from '@dxos/react-ui-form';\n\nimport { FunctionInputEditor } from './FunctionInputEditor';\nimport { SpecSelector } from './SpecSelector';\n\ntype TriggerFormSchema = ExcludeId<typeof Trigger.Trigger>;\n\nexport type TriggerEditorProps = {\n db: Database.Database;\n trigger: Trigger.Trigger;\n // TODO(wittjosiah): This needs to apply to whole spec but currently only applies to spec.kind & spec.query.\n readonlySpec?: boolean;\n} &\n // prettier-ignore\n Pick<QueryFormProps, 'types' | 'tags'> &\n Pick<FormRootProps<TriggerFormSchema>, 'onSave' | 'onCancel'>;\n\nexport const TriggerEditor = ({ db, types, tags, readonlySpec, trigger, ...formProps }: TriggerEditorProps) => {\n const fieldMap = useCustomInputs({\n db,\n types,\n tags,\n readonlySpec,\n });\n\n return (\n <Form.Root<TriggerFormSchema>\n {...formProps}\n schema={omitId(Trigger.Trigger)}\n values={trigger}\n db={db}\n fieldMap={fieldMap}\n >\n <Form.Viewport>\n <Form.Content>\n <Form.FieldSet />\n <Form.Actions />\n </Form.Content>\n </Form.Viewport>\n </Form.Root>\n );\n};\n\ntype UseCustomInputsProps = {\n db: Database.Database;\n readonlySpec?: boolean;\n} & Pick<QueryFormProps, 'types' | 'tags'>;\n\nconst useCustomInputs = ({ db, readonlySpec, types, tags }: UseCustomInputsProps): FormFieldMap => {\n const functions = useQuery(db, Filter.type(Function.Function));\n const workflows = useQuery(db, Filter.type(ComputeGraph));\n const scripts = useQuery(db, Filter.type(Script.Script));\n\n return useMemo(\n (): FormFieldMap => ({\n // Function selector.\n ['function' satisfies keyof Trigger.Trigger]: (props) => {\n const getValue = useCallback(() => {\n const formValue = props.getValue();\n if (Ref.isRef(formValue)) {\n return formValue.dxn.toString() as string;\n }\n return undefined;\n }, [props]);\n\n const handleOnValueChange = useCallback(\n (_type: any, dxnString: string) => {\n const dxn = DXN.parse(dxnString);\n if (dxn) {\n const ref = Ref.fromDXN(dxn);\n props.onValueChange(props.type, ref);\n }\n },\n [props.type, props.onValueChange],\n );\n\n return (\n <SelectField\n {...props}\n getValue={getValue as any}\n onValueChange={handleOnValueChange}\n options={getWorkflowOptions(workflows).concat(getFunctionOptions(scripts, functions))}\n />\n );\n },\n\n // Spec selector.\n ['spec.kind' as const]: (props) => <SpecSelector {...props} readonly={readonlySpec} />,\n\n // TODO(wittjosiah): Copied from ViewEditor.\n // Query input editor.\n ['spec.query' as const]: (props) => {\n const handleChange = useCallback(\n (query: Query.Any) => props.onValueChange(props.type, { ast: query.ast }),\n [props.type, props.onValueChange],\n );\n\n return (\n <Input.Root>\n <FormFieldLabel label={props.label} asChild />\n <QueryForm initialQuery={(props.getValue() as any).ast} types={types} tags={tags} onChange={handleChange} />\n </Input.Root>\n );\n },\n\n // Function input editor.\n ['input' as const]: (props) => <FunctionInputEditor {...props} functions={functions} db={db} />,\n }),\n [workflows, scripts, functions, readonlySpec],\n );\n};\n\nconst getWorkflowOptions = (graphs: ComputeGraph[]) => {\n return graphs.map((graph) => ({ label: `compute-${graph.id}`, value: `dxn:echo:@:${graph.id}` }));\n};\n\nconst getFunctionOptions = (scripts: Script.Script[], functions: Function.Function[]) => {\n const getLabel = (fn: Function.Function) => scripts.find((s) => fn.source?.target?.id === s.id)?.name ?? fn.name;\n return functions.map((fn) => ({ label: getLabel(fn), value: `dxn:echo:@:${fn.id}` }));\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as SchemaAST from 'effect/SchemaAST';\nimport React, { useCallback, useMemo } from 'react';\n\nimport { type Database, Ref, Type } from '@dxos/echo';\nimport { type JsonPath } from '@dxos/echo/internal';\nimport { type Function } from '@dxos/functions';\nimport { useOnTransition, useTranslation } from '@dxos/react-ui';\nimport { Form, type FormFieldStateProps, type FormRootProps, useFormValues } from '@dxos/react-ui-form';\n\nimport { meta } from '../../meta';\n\nexport type FunctionInputEditorProps = {\n type: SchemaAST.AST;\n functions: Function.Function[];\n db?: Database.Database;\n} & FormFieldStateProps;\n\nexport const FunctionInputEditor = ({ type, functions, db, getValue, onValueChange }: FunctionInputEditorProps) => {\n const { t } = useTranslation(meta.id);\n const selectedFunctionValue = useFormValues(FunctionInputEditor.displayName, ['function' as JsonPath]);\n const selectedFunctionId = useMemo(() => {\n if (Ref.isRef(selectedFunctionValue)) {\n return selectedFunctionValue.dxn.toString().split('dxn:echo:@:').at(1);\n }\n }, [selectedFunctionValue]);\n\n const selectedFunction = useMemo(\n () => functions.find((fn) => fn.id === selectedFunctionId),\n [functions, selectedFunctionId],\n );\n\n useOnTransition(\n // Clear function parameter input when the function changes.\n selectedFunctionValue,\n (prevValue) => {\n if (!Ref.isRef(prevValue) || !Ref.isRef(selectedFunctionValue)) {\n return false;\n }\n\n return prevValue.dxn.toString() !== selectedFunctionValue.dxn.toString();\n },\n (currValue) => currValue !== undefined,\n () => onValueChange(type, {}),\n );\n\n const inputSchema = useMemo(() => selectedFunction?.inputSchema, [selectedFunction]);\n const effectSchema = useMemo(() => (inputSchema ? Type.toEffectSchema(inputSchema) : undefined), [inputSchema]);\n const propertyCount = inputSchema?.properties ? Object.keys(inputSchema.properties).length : 0;\n const values = useMemo(() => getValue() ?? {}, [getValue]);\n\n const handleValuesChanged = useCallback<NonNullable<FormRootProps['onValuesChanged']>>(\n (values) => {\n onValueChange(type, values);\n },\n [type, onValueChange],\n );\n\n if (selectedFunction === undefined || effectSchema === undefined || propertyCount === 0) {\n return null;\n }\n\n return (\n <>\n <Form.Label label={t('function parameters label')} asChild />\n <Form.Root schema={effectSchema} values={values} db={db} onValuesChanged={handleValuesChanged}>\n <Form.FieldSet />\n </Form.Root>\n </>\n );\n};\n\nFunctionInputEditor.displayName = 'AutomationTrigger.FunctionInputEditor';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { useCallback, useMemo } from 'react';\n\nimport { Filter, Query } from '@dxos/echo';\nimport { Trigger } from '@dxos/functions';\nimport { useTranslation } from '@dxos/react-ui';\nimport { type FormFieldComponentProps, SelectField, useFormFieldState } from '@dxos/react-ui-form';\n\nimport { meta } from '../../meta';\n\nexport type SpecSelectorProps = FormFieldComponentProps;\n\nexport const SpecSelector = (props: SpecSelectorProps) => {\n const { t } = useTranslation(meta.id);\n const specProps = useFormFieldState(SpecSelector.displayName, ['spec' satisfies keyof Trigger.Trigger]);\n\n const handleTypeChange = useCallback(\n (_type: any, value: string): Trigger.Spec | undefined => {\n const getDefaultTriggerSpec = (kind: string) => {\n switch (kind) {\n case 'timer':\n return { kind: 'timer', cron: '' };\n case 'subscription':\n return {\n kind: 'subscription',\n query: {\n ast: Query.select(Filter.nothing()).ast,\n },\n };\n case 'queue':\n return { kind: 'queue', queue: 'dxn:' };\n case 'email':\n return { kind: 'email' };\n case 'webhook':\n return { kind: 'webhook' };\n default:\n return undefined;\n }\n };\n\n const defaultSpec = getDefaultTriggerSpec(value);\n if (!defaultSpec) {\n return;\n }\n\n // Update the entire spec object, not just the `spec.kind`.\n specProps.onValueChange(props.type, defaultSpec);\n },\n [props.type, specProps],\n );\n\n const options = useMemo(\n () =>\n Trigger.Kinds.map((kind) => ({\n value: kind,\n label: t(`trigger type ${kind}`),\n })),\n [t],\n );\n\n return <SelectField {...props} options={options} onValueChange={handleTypeChange} />;\n};\n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BAAArC,OAAA,cAACgD,MAAM9C,MAAI,MACT,gBAAAF,OAAA,cAACiD,gBAAAA;QAAeC,OAAO7B,MAAM6B;QAAOC,SAAAA;UACpC,gBAAAnD,OAAA,cAACoD,WAAAA;QAAUC,cAAehC,MAAMC,SAAQ,EAAWyB;QAAKtD;QAAcC;QAAY4D,UAAUT;;IAGlG;;IAGA,CAAC,OAAA,GAAmB,CAACxB,UAAU,gBAAArB,OAAA,cAACuD,qBAAAA;MAAqB,GAAGlC;MAAOV;MAAsBnB;;EACvF,IACA;IAACwB;IAAWE;IAASP;IAAWhB;GAAa;AAEjD;AAEA,IAAM6C,qBAAqB,CAACgB,WAAAA;AAC1B,SAAOA,OAAOC,IAAI,CAACC,WAAW;IAAER,OAAO,WAAWQ,MAAMC,EAAE;IAAIC,OAAO,cAAcF,MAAMC,EAAE;EAAG,EAAA;AAChG;AAEA,IAAMjB,qBAAqB,CAACxB,SAA0BP,cAAAA;AACpD,QAAMkD,WAAW,CAACC,OAA0B5C,QAAQ6C,KAAK,CAACC,MAAMF,GAAGG,QAAQC,QAAQP,OAAOK,EAAEL,EAAE,GAAGQ,QAAQL,GAAGK;AAC5G,SAAOxD,UAAU8C,IAAI,CAACK,QAAQ;IAAEZ,OAAOW,SAASC,EAAAA;IAAKF,OAAO,cAAcE,GAAGH,EAAE;EAAG,EAAA;AACpF;",
|
|
6
|
+
"names": ["React", "useCallback", "useMemo", "ComputeGraph", "DXN", "Function", "Script", "Trigger", "Filter", "Ref", "useQuery", "Input", "QueryForm", "Form", "FormFieldLabel", "SelectField", "omitId", "React", "useCallback", "useMemo", "Ref", "Type", "useOnTransition", "useTranslation", "Form", "useFormValues", "FunctionInputEditor", "type", "functions", "db", "getValue", "onValueChange", "t", "useTranslation", "meta", "id", "selectedFunctionValue", "useFormValues", "displayName", "selectedFunctionId", "useMemo", "Ref", "isRef", "dxn", "toString", "split", "at", "selectedFunction", "find", "fn", "useOnTransition", "prevValue", "currValue", "undefined", "inputSchema", "effectSchema", "Type", "toEffectSchema", "propertyCount", "properties", "Object", "keys", "length", "values", "handleValuesChanged", "useCallback", "Form", "Label", "label", "asChild", "Root", "schema", "onValuesChanged", "FieldSet", "React", "useCallback", "useMemo", "Filter", "Query", "Trigger", "useTranslation", "SelectField", "useFormFieldState", "SpecSelector", "props", "t", "useTranslation", "meta", "id", "specProps", "useFormFieldState", "displayName", "handleTypeChange", "useCallback", "_type", "value", "getDefaultTriggerSpec", "kind", "cron", "query", "ast", "Query", "select", "Filter", "nothing", "queue", "undefined", "defaultSpec", "onValueChange", "type", "options", "useMemo", "Trigger", "Kinds", "map", "label", "React", "SelectField", "TriggerEditor", "db", "types", "tags", "readonlySpec", "trigger", "formProps", "fieldMap", "useCustomInputs", "React", "Form", "Root", "schema", "omitId", "Trigger", "values", "Viewport", "Content", "FieldSet", "Actions", "functions", "useQuery", "Filter", "type", "Function", "workflows", "ComputeGraph", "scripts", "Script", "useMemo", "props", "getValue", "useCallback", "formValue", "Ref", "isRef", "dxn", "toString", "undefined", "handleOnValueChange", "_type", "dxnString", "DXN", "parse", "ref", "fromDXN", "onValueChange", "SelectField", "options", "getWorkflowOptions", "concat", "getFunctionOptions", "SpecSelector", "readonly", "handleChange", "query", "ast", "Input", "FormFieldLabel", "label", "asChild", "QueryForm", "initialQuery", "onChange", "FunctionInputEditor", "graphs", "map", "graph", "id", "value", "getLabel", "fn", "find", "s", "source", "target", "name"]
|
|
7
|
+
}
|