@dxos/plugin-script 0.8.2-main.fbd8ed0 → 0.8.2-staging.7ac8446
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/DeploymentDialog-AEPYJKPO.mjs +12 -0
- package/dist/lib/browser/{ScriptContainer-6DYV7D65.mjs → ScriptContainer-R25PRK2D.mjs} +19 -31
- package/dist/lib/browser/ScriptContainer-R25PRK2D.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-BFBTQPSP.mjs → app-graph-builder-RRLY67QC.mjs} +10 -10
- package/dist/lib/browser/app-graph-builder-RRLY67QC.mjs.map +7 -0
- package/dist/lib/browser/{artifact-definition-PD4UAAQZ.mjs → artifact-definition-WXFYD2V5.mjs} +38 -44
- package/dist/lib/browser/artifact-definition-WXFYD2V5.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BONEXAIK.mjs → chunk-2CGZFDCR.mjs} +10 -10
- package/dist/lib/browser/chunk-2CGZFDCR.mjs.map +7 -0
- package/dist/lib/browser/{chunk-A4VOGQ2P.mjs → chunk-4VD3K3PY.mjs} +2 -2
- package/dist/lib/browser/{chunk-YNOCAJYT.mjs → chunk-CSZXPLYY.mjs} +3 -3
- package/dist/lib/browser/chunk-CSZXPLYY.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FFDJENAN.mjs → chunk-KLEOGVXY.mjs} +156 -87
- package/dist/lib/browser/chunk-KLEOGVXY.mjs.map +7 -0
- package/dist/lib/browser/{chunk-INL55MFV.mjs → chunk-MQZQB5VD.mjs} +10 -10
- package/dist/lib/browser/chunk-MQZQB5VD.mjs.map +7 -0
- package/dist/lib/browser/chunk-R2CHVWJ2.mjs +41 -0
- package/dist/lib/browser/chunk-R2CHVWJ2.mjs.map +7 -0
- package/dist/lib/browser/chunk-SUCBNCEQ.mjs +87 -0
- package/dist/lib/browser/chunk-SUCBNCEQ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-KJMVDGRB.mjs → chunk-WSK3YQXI.mjs} +1 -2
- package/dist/lib/browser/{chunk-KJMVDGRB.mjs.map → chunk-WSK3YQXI.mjs.map} +2 -2
- package/dist/lib/browser/{compiler-O4FJK7RR.mjs → compiler-56LTBEQB.mjs} +3 -3
- package/dist/lib/browser/index.mjs +15 -16
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-SXO6X6XQ.mjs → intent-resolver-WCVXKRBR.mjs} +14 -14
- package/dist/lib/browser/intent-resolver-WCVXKRBR.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-TZGE7EGC.mjs → react-surface-WXZVPNGI.mjs} +12 -12
- package/dist/lib/browser/react-surface-WXZVPNGI.mjs.map +7 -0
- package/dist/lib/browser/{settings-EOKSUGB6.mjs → settings-Z7B37V2I.mjs} +5 -5
- package/dist/lib/browser/settings-Z7B37V2I.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +2 -2
- package/dist/lib/node/{DeploymentDialog-43SI7XFL.cjs → DeploymentDialog-O4MU4OMF.cjs} +10 -10
- package/dist/lib/node/DeploymentDialog-O4MU4OMF.cjs.map +7 -0
- package/dist/lib/node/{ScriptContainer-H56OW5FC.cjs → ScriptContainer-5KY6ZOQD.cjs} +22 -32
- package/dist/lib/node/ScriptContainer-5KY6ZOQD.cjs.map +7 -0
- package/dist/lib/node/{app-graph-builder-IKOX7GHW.cjs → app-graph-builder-6I2BWD46.cjs} +17 -17
- package/dist/lib/node/app-graph-builder-6I2BWD46.cjs.map +7 -0
- package/dist/lib/node/{artifact-definition-C644EAYM.cjs → artifact-definition-6NVXEHJD.cjs} +47 -53
- package/dist/lib/node/artifact-definition-6NVXEHJD.cjs.map +7 -0
- package/dist/lib/node/{chunk-VHSIOCS5.cjs → chunk-65MIJR3Q.cjs} +17 -17
- package/dist/lib/node/chunk-65MIJR3Q.cjs.map +7 -0
- package/dist/lib/node/{chunk-7NNN3IUQ.cjs → chunk-F4DP7WON.cjs} +160 -93
- package/dist/lib/node/chunk-F4DP7WON.cjs.map +7 -0
- package/dist/lib/node/{chunk-KFJQVOGS.cjs → chunk-JICWAOWZ.cjs} +6 -6
- package/dist/lib/node/{chunk-HPBQHRM3.cjs → chunk-SLDJM45C.cjs} +18 -18
- package/dist/lib/node/chunk-SLDJM45C.cjs.map +7 -0
- package/dist/lib/node/{chunk-K7PPLRVQ.cjs → chunk-VYBEBLDO.cjs} +14 -14
- package/dist/lib/node/chunk-VYBEBLDO.cjs.map +7 -0
- package/dist/lib/node/chunk-X7MHLHHS.cjs +91 -0
- package/dist/lib/node/chunk-X7MHLHHS.cjs.map +7 -0
- package/dist/lib/node/{chunk-SXJGHLK6.cjs → chunk-XFZPWFEG.cjs} +19 -18
- package/dist/lib/node/chunk-XFZPWFEG.cjs.map +7 -0
- package/dist/lib/node/{chunk-NO5Y74F3.cjs → chunk-YJQZHKKA.cjs} +4 -5
- package/dist/lib/node/{chunk-NO5Y74F3.cjs.map → chunk-YJQZHKKA.cjs.map} +2 -2
- package/dist/lib/node/{compiler-FBC6ELQN.cjs → compiler-W2RU3M7U.cjs} +7 -7
- package/dist/lib/node/index.cjs +44 -45
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/{intent-resolver-PDSMZM2T.cjs → intent-resolver-J4NBDNFH.cjs} +21 -21
- package/dist/lib/node/intent-resolver-J4NBDNFH.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-BHHJQZ7P.cjs → react-surface-27KTUBIZ.cjs} +38 -38
- package/dist/lib/node/react-surface-27KTUBIZ.cjs.map +7 -0
- package/dist/lib/node/{settings-425QHVGC.cjs → settings-EI6VPNKN.cjs} +9 -9
- package/dist/lib/node/settings-EI6VPNKN.cjs.map +7 -0
- package/dist/lib/node/types.cjs +5 -5
- package/dist/lib/node/types.cjs.map +1 -1
- package/dist/lib/node-esm/{DeploymentDialog-2RRUJEBC.mjs → DeploymentDialog-SSQSWLHX.mjs} +5 -5
- package/dist/lib/node-esm/{ScriptContainer-762FHDZ4.mjs → ScriptContainer-W2F4FGDV.mjs} +19 -31
- package/dist/lib/node-esm/ScriptContainer-W2F4FGDV.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-KZGKGSP6.mjs → app-graph-builder-H5XLRVX3.mjs} +10 -10
- package/dist/lib/node-esm/app-graph-builder-H5XLRVX3.mjs.map +7 -0
- package/dist/lib/node-esm/{artifact-definition-J6UM6BQF.mjs → artifact-definition-KQ64AYBP.mjs} +38 -44
- package/dist/lib/node-esm/artifact-definition-KQ64AYBP.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-A3TXZHGD.mjs → chunk-4MTPYMV2.mjs} +10 -10
- package/dist/lib/node-esm/chunk-4MTPYMV2.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-HKJUN636.mjs → chunk-EB5DSAD4.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-F47OE6ZM.mjs → chunk-F4HA5C34.mjs} +10 -10
- package/dist/lib/node-esm/chunk-F4HA5C34.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-H7FRB3M7.mjs → chunk-FDEAVT67.mjs} +1 -2
- package/dist/lib/node-esm/{chunk-H7FRB3M7.mjs.map → chunk-FDEAVT67.mjs.map} +2 -2
- package/dist/lib/node-esm/{chunk-V733VFCJ.mjs → chunk-MU3JKVL2.mjs} +3 -3
- package/dist/lib/node-esm/chunk-MU3JKVL2.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-NYA7KDN6.mjs → chunk-PBGVTGL2.mjs} +156 -87
- package/dist/lib/node-esm/chunk-PBGVTGL2.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-QDYGTY4L.mjs +89 -0
- package/dist/lib/node-esm/chunk-QDYGTY4L.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-VMQPOPKV.mjs → chunk-RW2APVMV.mjs} +14 -13
- package/dist/lib/node-esm/chunk-RW2APVMV.mjs.map +7 -0
- package/dist/lib/node-esm/{compiler-3NG4T5LH.mjs → compiler-VT5C2Z3T.mjs} +3 -3
- package/dist/lib/node-esm/index.mjs +15 -16
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-WSAVLQY5.mjs → intent-resolver-PDZ2A26X.mjs} +14 -14
- package/dist/lib/node-esm/intent-resolver-PDZ2A26X.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-W7BM4PDK.mjs → react-surface-UCUVDVSH.mjs} +12 -12
- package/dist/lib/node-esm/react-surface-UCUVDVSH.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-BWSKKIVQ.mjs → settings-HU5UEFRF.mjs} +5 -5
- package/dist/lib/node-esm/settings-HU5UEFRF.mjs.map +7 -0
- package/dist/lib/node-esm/types.mjs +2 -2
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +179 -2
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +177 -1
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts +2 -2
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptContainer.d.ts +1 -1
- package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
- package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts +1 -1
- package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts.map +1 -1
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/TestPanel.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/hooks/deploy.d.ts +19 -22
- package/dist/types/src/hooks/deploy.d.ts.map +1 -1
- package/dist/types/src/hooks/format.d.ts +5 -2
- package/dist/types/src/hooks/format.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/template.d.ts +5 -2
- package/dist/types/src/hooks/template.d.ts.map +1 -1
- package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts.map +1 -1
- package/dist/types/src/hooks/useToolbarAction.d.ts +13 -0
- package/dist/types/src/hooks/useToolbarAction.d.ts.map +1 -0
- package/dist/types/src/hooks/useToolbarState.d.ts +1 -1
- package/dist/types/src/hooks/useToolbarState.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/templates/chat.d.ts +1 -1
- package/dist/types/src/templates/chat.d.ts.map +1 -1
- package/dist/types/src/templates/chess.d.ts.map +1 -1
- package/dist/types/src/templates/data-generator.d.ts +7 -0
- package/dist/types/src/templates/data-generator.d.ts.map +1 -1
- package/dist/types/src/templates/discord.d.ts.map +1 -1
- package/dist/types/src/templates/echo.d.ts +1 -1
- package/dist/types/src/templates/echo.d.ts.map +1 -1
- package/dist/types/src/templates/email.d.ts +1 -1
- package/dist/types/src/templates/email.d.ts.map +1 -1
- package/dist/types/src/templates/forex-effect.d.ts.map +1 -1
- package/dist/types/src/templates/forex.d.ts.map +1 -1
- package/dist/types/src/templates/gmail.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +110 -2
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +26 -27
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/src/util/deploy.d.ts.map +1 -1
- package/dist/types/src/util/functions.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +50 -56
- package/src/ScriptPlugin.tsx +2 -4
- package/src/capabilities/app-graph-builder.ts +29 -46
- package/src/capabilities/artifact-definition.ts +32 -35
- package/src/capabilities/intent-resolver.ts +7 -7
- package/src/capabilities/react-surface.tsx +5 -5
- package/src/capabilities/settings.ts +2 -2
- package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +1 -1
- package/src/components/DeploymentDialog/DeploymentDialog.tsx +2 -2
- package/src/components/ScriptContainer.tsx +2 -2
- package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +1 -1
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +10 -16
- package/src/components/Settings/ScriptObjectSettings.tsx +5 -5
- package/src/hooks/deploy.ts +55 -61
- package/src/hooks/format.ts +26 -26
- package/src/hooks/index.ts +1 -0
- package/src/hooks/template.ts +32 -24
- package/src/hooks/useToolbarAction.ts +50 -0
- package/src/hooks/useToolbarState.ts +2 -2
- package/src/meta.ts +0 -1
- package/src/templates/chat.ts +9 -3
- package/src/templates/chess.ts +6 -1
- package/src/templates/data-generator.ts +45 -20
- package/src/templates/discord.ts +10 -10
- package/src/templates/echo.ts +12 -1
- package/src/templates/email.ts +14 -8
- package/src/templates/forex-effect.ts +6 -2
- package/src/templates/forex.ts +5 -1
- package/src/templates/gmail.ts +26 -33
- package/src/translations.ts +1 -1
- package/src/types.ts +14 -13
- package/src/util/deploy.ts +10 -6
- package/dist/lib/browser/DeploymentDialog-W7PY33VN.mjs +0 -12
- package/dist/lib/browser/ScriptContainer-6DYV7D65.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-BFBTQPSP.mjs.map +0 -7
- package/dist/lib/browser/artifact-definition-PD4UAAQZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-6MLJJI73.mjs +0 -40
- package/dist/lib/browser/chunk-6MLJJI73.mjs.map +0 -7
- package/dist/lib/browser/chunk-BONEXAIK.mjs.map +0 -7
- package/dist/lib/browser/chunk-FFDJENAN.mjs.map +0 -7
- package/dist/lib/browser/chunk-INL55MFV.mjs.map +0 -7
- package/dist/lib/browser/chunk-RTVU4RZW.mjs +0 -87
- package/dist/lib/browser/chunk-RTVU4RZW.mjs.map +0 -7
- package/dist/lib/browser/chunk-YNOCAJYT.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-SXO6X6XQ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-TZGE7EGC.mjs.map +0 -7
- package/dist/lib/browser/settings-EOKSUGB6.mjs.map +0 -7
- package/dist/lib/node/DeploymentDialog-43SI7XFL.cjs.map +0 -7
- package/dist/lib/node/ScriptContainer-H56OW5FC.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-IKOX7GHW.cjs.map +0 -7
- package/dist/lib/node/artifact-definition-C644EAYM.cjs.map +0 -7
- package/dist/lib/node/chunk-7NNN3IUQ.cjs.map +0 -7
- package/dist/lib/node/chunk-HPBQHRM3.cjs.map +0 -7
- package/dist/lib/node/chunk-K7PPLRVQ.cjs.map +0 -7
- package/dist/lib/node/chunk-SXJGHLK6.cjs.map +0 -7
- package/dist/lib/node/chunk-VHSIOCS5.cjs.map +0 -7
- package/dist/lib/node/chunk-VNSZBEJW.cjs +0 -91
- package/dist/lib/node/chunk-VNSZBEJW.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-PDSMZM2T.cjs.map +0 -7
- package/dist/lib/node/react-surface-BHHJQZ7P.cjs.map +0 -7
- package/dist/lib/node/settings-425QHVGC.cjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-762FHDZ4.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-KZGKGSP6.mjs.map +0 -7
- package/dist/lib/node-esm/artifact-definition-J6UM6BQF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-A3TXZHGD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-F47OE6ZM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NYA7KDN6.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-V733VFCJ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VMQPOPKV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YCTECQLY.mjs +0 -89
- package/dist/lib/node-esm/chunk-YCTECQLY.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-WSAVLQY5.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-W7BM4PDK.mjs.map +0 -7
- package/dist/lib/node-esm/settings-BWSKKIVQ.mjs.map +0 -7
- /package/dist/lib/browser/{DeploymentDialog-W7PY33VN.mjs.map → DeploymentDialog-AEPYJKPO.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-A4VOGQ2P.mjs.map → chunk-4VD3K3PY.mjs.map} +0 -0
- /package/dist/lib/browser/{compiler-O4FJK7RR.mjs.map → compiler-56LTBEQB.mjs.map} +0 -0
- /package/dist/lib/node/{chunk-KFJQVOGS.cjs.map → chunk-JICWAOWZ.cjs.map} +0 -0
- /package/dist/lib/node/{compiler-FBC6ELQN.cjs.map → compiler-W2RU3M7U.cjs.map} +0 -0
- /package/dist/lib/node-esm/{DeploymentDialog-2RRUJEBC.mjs.map → DeploymentDialog-SSQSWLHX.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-HKJUN636.mjs.map → chunk-EB5DSAD4.mjs.map} +0 -0
- /package/dist/lib/node-esm/{compiler-3NG4T5LH.mjs.map → compiler-VT5C2Z3T.mjs.map} +0 -0
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Schema } from 'effect';
|
|
6
|
-
|
|
7
5
|
import { Capabilities, contributes, createIntent, type PromiseIntentDispatcher } from '@dxos/app-framework';
|
|
8
6
|
import { defineArtifact, defineTool, ToolResult } from '@dxos/artifact';
|
|
9
7
|
import { createArtifactElement } from '@dxos/assistant';
|
|
10
|
-
import {
|
|
8
|
+
import { ObjectId, S } from '@dxos/echo-schema';
|
|
9
|
+
import { ScriptType } from '@dxos/functions/types';
|
|
11
10
|
import { invariant } from '@dxos/invariant';
|
|
12
11
|
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
12
|
+
import { create, makeRef, type Space } from '@dxos/react-client/echo';
|
|
13
|
+
import { TextType } from '@dxos/schema';
|
|
15
14
|
|
|
16
15
|
import { meta } from '../meta';
|
|
17
16
|
// TODO(burdon): Factor out.
|
|
@@ -72,28 +71,28 @@ export default () => {
|
|
|
72
71
|
<apis>
|
|
73
72
|
export function defineFunction(params: {
|
|
74
73
|
description: string,
|
|
75
|
-
inputSchema:
|
|
76
|
-
outputSchema:
|
|
74
|
+
inputSchema: S.Schema,
|
|
75
|
+
outputSchema: S.Schema,
|
|
77
76
|
handler: (params: { event: { data: TInput } }) => Promise<TOutput>
|
|
78
77
|
}): FunctionDefinition
|
|
79
78
|
/**
|
|
80
79
|
* Effect Schema
|
|
81
80
|
*/
|
|
82
|
-
export const
|
|
81
|
+
export const S;
|
|
83
82
|
|
|
84
83
|
// Examples:
|
|
85
84
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
from:
|
|
91
|
-
to:
|
|
85
|
+
S.String
|
|
86
|
+
S.Number
|
|
87
|
+
S.Boolean
|
|
88
|
+
S.Struct({
|
|
89
|
+
from: S.String.annotations({ description: 'The source currency' }),
|
|
90
|
+
to: S.String.annotations({ description: 'The target currency' }),
|
|
92
91
|
})
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
S.Array(S.String)
|
|
93
|
+
S.Union(S.String, S.Number)
|
|
94
|
+
S.optional(S.String)
|
|
95
|
+
S.String.annotations({ description: 'The source currency' })
|
|
97
96
|
</apis>
|
|
98
97
|
|
|
99
98
|
<handler_function>
|
|
@@ -114,13 +113,13 @@ export default () => {
|
|
|
114
113
|
export default defineFunction({
|
|
115
114
|
description: 'Returns the exchange rate between two currencies.',
|
|
116
115
|
|
|
117
|
-
inputSchema:
|
|
118
|
-
from:
|
|
119
|
-
to:
|
|
116
|
+
inputSchema: S.Struct({
|
|
117
|
+
from: S.String.annotations({ description: 'The source currency' }),
|
|
118
|
+
to: S.String.annotations({ description: 'The target currency' }),
|
|
120
119
|
}),
|
|
121
120
|
|
|
122
|
-
outputSchema:
|
|
123
|
-
rate:
|
|
121
|
+
outputSchema: S.Struct({
|
|
122
|
+
rate: S.String.annotations({ description: 'The exchange rate' }),
|
|
124
123
|
}),
|
|
125
124
|
|
|
126
125
|
handler: async ({
|
|
@@ -144,19 +143,19 @@ export default () => {
|
|
|
144
143
|
name: 'create',
|
|
145
144
|
description: 'Create a new script. Returns the artifact definition for the script',
|
|
146
145
|
caption: 'Creating script...',
|
|
147
|
-
schema:
|
|
148
|
-
name:
|
|
149
|
-
code:
|
|
146
|
+
schema: S.Struct({
|
|
147
|
+
name: S.String.annotations({ description: 'The name of the script' }),
|
|
148
|
+
code: S.String.annotations({
|
|
150
149
|
description: 'The full code of the script in JavaScript or TypeScript. Must be valid executable code.',
|
|
151
150
|
}),
|
|
152
151
|
}),
|
|
153
152
|
execute: async ({ name, code }, { extensions }) => {
|
|
154
153
|
invariant(extensions?.space, 'No space');
|
|
155
154
|
invariant(extensions?.dispatch, 'No intent dispatcher');
|
|
156
|
-
const script =
|
|
155
|
+
const script = create(ScriptType, {
|
|
157
156
|
name,
|
|
158
157
|
source: makeRef(
|
|
159
|
-
|
|
158
|
+
create(TextType, {
|
|
160
159
|
content: code,
|
|
161
160
|
}),
|
|
162
161
|
),
|
|
@@ -177,9 +176,8 @@ export default () => {
|
|
|
177
176
|
name: 'inspect',
|
|
178
177
|
description: 'Inspect a script. Returns the artifact definition for the script',
|
|
179
178
|
caption: 'Inspecting script...',
|
|
180
|
-
schema:
|
|
181
|
-
|
|
182
|
-
id: Schema.String.annotations({ description: 'The ID of the script' }),
|
|
179
|
+
schema: S.Struct({
|
|
180
|
+
id: ObjectId,
|
|
183
181
|
}),
|
|
184
182
|
execute: async ({ id }, { extensions }) => {
|
|
185
183
|
invariant(extensions?.space, 'No space');
|
|
@@ -197,10 +195,9 @@ export default () => {
|
|
|
197
195
|
name: 'update',
|
|
198
196
|
description: 'Update a script. Returns the artifact definition for the script',
|
|
199
197
|
caption: 'Updating script...',
|
|
200
|
-
schema:
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
code: Schema.String.annotations({
|
|
198
|
+
schema: S.Struct({
|
|
199
|
+
id: ObjectId,
|
|
200
|
+
code: S.String.annotations({
|
|
204
201
|
description: 'The full code of the script in JavaScript or TypeScript. Must be valid executable code.',
|
|
205
202
|
}),
|
|
206
203
|
}),
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Octokit } from '@octokit/core';
|
|
6
|
-
import {
|
|
6
|
+
import { isNotNullable } from 'effect/Predicate';
|
|
7
7
|
|
|
8
8
|
import { contributes, Capabilities, createResolver, createIntent, LayoutAction } from '@dxos/app-framework';
|
|
9
|
-
import { ScriptType } from '@dxos/functions';
|
|
10
|
-
import {
|
|
9
|
+
import { ScriptType } from '@dxos/functions/types';
|
|
10
|
+
import { create, makeRef } from '@dxos/live-object';
|
|
11
11
|
import { TokenManagerAction } from '@dxos/plugin-token-manager/types';
|
|
12
|
-
import {
|
|
12
|
+
import { TextType } from '@dxos/schema';
|
|
13
13
|
|
|
14
14
|
import { DEPLOYMENT_DIALOG } from '../components';
|
|
15
15
|
import { defaultScriptsForIntegration } from '../meta';
|
|
@@ -47,9 +47,9 @@ export default () =>
|
|
|
47
47
|
|
|
48
48
|
return {
|
|
49
49
|
data: {
|
|
50
|
-
object:
|
|
50
|
+
object: create(ScriptType, {
|
|
51
51
|
name,
|
|
52
|
-
source: makeRef(
|
|
52
|
+
source: makeRef(create(TextType, { content })),
|
|
53
53
|
}),
|
|
54
54
|
},
|
|
55
55
|
};
|
|
@@ -60,7 +60,7 @@ export default () =>
|
|
|
60
60
|
resolve: async ({ accessToken }) => {
|
|
61
61
|
const scriptTemplates = (defaultScriptsForIntegration[accessToken.source] ?? [])
|
|
62
62
|
.map((id) => templates.find((t) => t.id === id))
|
|
63
|
-
.filter(
|
|
63
|
+
.filter(isNotNullable);
|
|
64
64
|
|
|
65
65
|
if (scriptTemplates.length > 0) {
|
|
66
66
|
return {
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
7
|
import { Capabilities, contributes, createSurface, useCapability } from '@dxos/app-framework';
|
|
8
|
-
import {
|
|
8
|
+
import { InvocationTracePanel } from '@dxos/devtools';
|
|
9
9
|
import { isInstanceOf } from '@dxos/echo-schema';
|
|
10
|
-
import { ScriptType } from '@dxos/functions';
|
|
10
|
+
import { ScriptType } from '@dxos/functions/types';
|
|
11
11
|
import { SettingsStore } from '@dxos/local-storage';
|
|
12
12
|
import { getSpace } from '@dxos/react-client/echo';
|
|
13
13
|
import { StackItem } from '@dxos/react-ui-stack';
|
|
14
|
-
import { type
|
|
14
|
+
import { type AccessTokenType } from '@dxos/schema';
|
|
15
15
|
|
|
16
16
|
import { ScriptCapabilities } from './capabilities';
|
|
17
17
|
import {
|
|
@@ -84,7 +84,7 @@ export default () =>
|
|
|
84
84
|
const space = getSpace(data.companionTo);
|
|
85
85
|
return (
|
|
86
86
|
<StackItem.Content role={role}>
|
|
87
|
-
<
|
|
87
|
+
<InvocationTracePanel space={space} script={data.companionTo} detailAxis='block' />
|
|
88
88
|
</StackItem.Content>
|
|
89
89
|
);
|
|
90
90
|
},
|
|
@@ -92,7 +92,7 @@ export default () =>
|
|
|
92
92
|
createSurface({
|
|
93
93
|
id: DEPLOYMENT_DIALOG,
|
|
94
94
|
role: 'dialog',
|
|
95
|
-
filter: (data): data is { props: { accessToken:
|
|
95
|
+
filter: (data): data is { props: { accessToken: AccessTokenType; scriptTemplates: any } } =>
|
|
96
96
|
data.component === DEPLOYMENT_DIALOG,
|
|
97
97
|
component: ({ data }) => <DeploymentDialog {...data.props} />,
|
|
98
98
|
}),
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Capabilities, contributes } from '@dxos/app-framework';
|
|
6
|
-
import {
|
|
6
|
+
import { create } from '@dxos/live-object';
|
|
7
7
|
|
|
8
8
|
import { meta } from '../meta';
|
|
9
9
|
import { ScriptSettingsSchema } from '../types';
|
|
10
10
|
|
|
11
11
|
export default () => {
|
|
12
|
-
const settings =
|
|
12
|
+
const settings = create(ScriptSettingsSchema, { editorInputMode: 'vscode' });
|
|
13
13
|
return contributes(Capabilities.Settings, { schema: ScriptSettingsSchema, prefix: meta.id, value: settings });
|
|
14
14
|
};
|
|
@@ -33,7 +33,7 @@ const meta: Meta = {
|
|
|
33
33
|
title: 'plugins/plugin-script/DeploymentDialog',
|
|
34
34
|
component: DeploymentDialog,
|
|
35
35
|
parameters: { translations },
|
|
36
|
-
decorators: [withTheme, withLayout()],
|
|
36
|
+
decorators: [withTheme, withLayout({ tooltips: true })],
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
export default meta;
|
|
@@ -7,7 +7,7 @@ import React, { useEffect, useMemo } from 'react';
|
|
|
7
7
|
import { createIntent, LayoutAction, useIntentDispatcher } from '@dxos/app-framework';
|
|
8
8
|
import { getSpace } from '@dxos/react-client/echo';
|
|
9
9
|
import { Button, Dialog, Icon, useTranslation } from '@dxos/react-ui';
|
|
10
|
-
import { type
|
|
10
|
+
import { type AccessTokenType } from '@dxos/schema';
|
|
11
11
|
|
|
12
12
|
import { useCreateAndDeployScriptTemplates } from '../../hooks/useCreateAndDeployScriptTemplates';
|
|
13
13
|
import { SCRIPT_PLUGIN } from '../../meta';
|
|
@@ -21,7 +21,7 @@ export const DEPLOYMENT_DIALOG = `${SCRIPT_PLUGIN}/deployment/dialog`;
|
|
|
21
21
|
// - Pending / onError states.
|
|
22
22
|
|
|
23
23
|
type DeploymentDialogProps = {
|
|
24
|
-
accessToken:
|
|
24
|
+
accessToken: AccessTokenType;
|
|
25
25
|
scriptTemplates: Template[];
|
|
26
26
|
};
|
|
27
27
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type ScriptType } from '@dxos/functions';
|
|
7
|
+
import { type ScriptType } from '@dxos/functions/types';
|
|
8
8
|
import { createDocAccessor, getSpace } from '@dxos/react-client/echo';
|
|
9
9
|
import { useIdentity } from '@dxos/react-client/halo';
|
|
10
10
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
@@ -57,7 +57,7 @@ export const ScriptContainer = ({
|
|
|
57
57
|
);
|
|
58
58
|
|
|
59
59
|
return (
|
|
60
|
-
<StackItem.Content toolbar>
|
|
60
|
+
<StackItem.Content toolbar classNames='divide-y divide-separator'>
|
|
61
61
|
<ScriptToolbar state={state} role={role} script={script} />
|
|
62
62
|
<TypescriptEditor
|
|
63
63
|
id={script.id}
|
|
@@ -4,21 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type ScriptType } from '@dxos/functions';
|
|
7
|
+
import { type ScriptType } from '@dxos/functions/types';
|
|
8
8
|
import { fullyQualifiedId } from '@dxos/react-client/echo';
|
|
9
|
-
import { ElevationProvider,
|
|
9
|
+
import { ElevationProvider, type ThemedClassName } from '@dxos/react-ui';
|
|
10
10
|
import { stackItemContentToolbarClassNames } from '@dxos/react-ui-editor';
|
|
11
11
|
import { createGapSeparator, MenuProvider, ToolbarMenu, useMenuActions } from '@dxos/react-ui-menu';
|
|
12
12
|
|
|
13
13
|
import {
|
|
14
|
-
type CreateDeployOptions,
|
|
15
14
|
type ScriptToolbarState,
|
|
16
15
|
createDeploy,
|
|
17
16
|
createFormat,
|
|
18
17
|
createTemplateSelect,
|
|
19
|
-
|
|
18
|
+
useToolbarAction,
|
|
20
19
|
} from '../../hooks';
|
|
21
|
-
import { SCRIPT_PLUGIN } from '../../meta';
|
|
22
20
|
|
|
23
21
|
export type ScriptToolbarProps = ThemedClassName<{
|
|
24
22
|
role?: string;
|
|
@@ -26,11 +24,11 @@ export type ScriptToolbarProps = ThemedClassName<{
|
|
|
26
24
|
state: ScriptToolbarState;
|
|
27
25
|
}>;
|
|
28
26
|
|
|
29
|
-
const createToolbar = (
|
|
30
|
-
const templateSelect = createTemplateSelect(
|
|
31
|
-
const format = createFormat(
|
|
27
|
+
const createToolbar = (state: ScriptToolbarState) => {
|
|
28
|
+
const templateSelect = createTemplateSelect();
|
|
29
|
+
const format = createFormat();
|
|
32
30
|
const gap = createGapSeparator();
|
|
33
|
-
const deploy = createDeploy(
|
|
31
|
+
const deploy = createDeploy(state);
|
|
34
32
|
return {
|
|
35
33
|
nodes: [...templateSelect.nodes, ...format.nodes, ...gap.nodes, ...deploy.nodes],
|
|
36
34
|
edges: [...templateSelect.edges, ...format.edges, ...gap.edges, ...deploy.edges],
|
|
@@ -38,18 +36,14 @@ const createToolbar = ({ state, script, ...options }: CreateDeployOptions) => {
|
|
|
38
36
|
};
|
|
39
37
|
|
|
40
38
|
export const ScriptToolbar = ({ script, role, state, classNames }: ScriptToolbarProps) => {
|
|
41
|
-
const {
|
|
42
|
-
const
|
|
43
|
-
const toolbarCreator = useCallback(
|
|
44
|
-
() => createToolbar({ state, script, t, ...options }),
|
|
45
|
-
[state, script, options, t],
|
|
46
|
-
);
|
|
39
|
+
const handleAction = useToolbarAction({ state, script });
|
|
40
|
+
const toolbarCreator = useCallback(() => createToolbar(state), [state]);
|
|
47
41
|
const menu = useMenuActions(toolbarCreator);
|
|
48
42
|
|
|
49
43
|
return (
|
|
50
44
|
<div role='none' className={stackItemContentToolbarClassNames(role)}>
|
|
51
45
|
<ElevationProvider elevation={role === 'section' ? 'positioned' : 'base'}>
|
|
52
|
-
<MenuProvider {...menu} attendableId={fullyQualifiedId(script)}>
|
|
46
|
+
<MenuProvider {...menu} onAction={handleAction} attendableId={fullyQualifiedId(script)}>
|
|
53
47
|
<ToolbarMenu classNames={classNames} />
|
|
54
48
|
</MenuProvider>
|
|
55
49
|
</ElevationProvider>
|
|
@@ -6,12 +6,12 @@ import { Octokit } from '@octokit/core';
|
|
|
6
6
|
import React, { type ChangeEvent, useCallback, useEffect, useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import { createIntent, SettingsAction, useIntentDispatcher } from '@dxos/app-framework';
|
|
9
|
-
import { FunctionType, type ScriptType, getInvocationUrl, getUserFunctionUrlInMetadata } from '@dxos/functions';
|
|
9
|
+
import { FunctionType, type ScriptType, getInvocationUrl, getUserFunctionUrlInMetadata } from '@dxos/functions/types';
|
|
10
10
|
import { log } from '@dxos/log';
|
|
11
11
|
import { useClient } from '@dxos/react-client';
|
|
12
|
-
import { Filter, getMeta, getSpace,
|
|
12
|
+
import { Filter, getMeta, getSpace, useQuery } from '@dxos/react-client/echo';
|
|
13
13
|
import { Button, Clipboard, Input, useControlledState, useTranslation } from '@dxos/react-ui';
|
|
14
|
-
import {
|
|
14
|
+
import { AccessTokenType } from '@dxos/schema';
|
|
15
15
|
|
|
16
16
|
import { SCRIPT_PLUGIN } from '../../meta';
|
|
17
17
|
|
|
@@ -48,7 +48,7 @@ const Binding = ({ object }: ScriptObjectSettingsProps) => {
|
|
|
48
48
|
const { t } = useTranslation(SCRIPT_PLUGIN);
|
|
49
49
|
const client = useClient();
|
|
50
50
|
const space = getSpace(object);
|
|
51
|
-
const [fn] = useQuery(space, Filter.
|
|
51
|
+
const [fn] = useQuery(space, Filter.schema(FunctionType, { source: object }));
|
|
52
52
|
|
|
53
53
|
const functionPath = fn && getUserFunctionUrlInMetadata(getMeta(fn));
|
|
54
54
|
const functionUrl =
|
|
@@ -112,7 +112,7 @@ const Publishing = ({ object }: ScriptObjectSettingsProps) => {
|
|
|
112
112
|
const { t } = useTranslation(SCRIPT_PLUGIN);
|
|
113
113
|
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
114
114
|
const space = getSpace(object);
|
|
115
|
-
const [githubToken] = useQuery(space, Filter.
|
|
115
|
+
const [githubToken] = useQuery(space, Filter.schema(AccessTokenType, { source: 'github.com' }));
|
|
116
116
|
const gistKey = getMeta(object).keys.find(({ source }) => source === 'github.com');
|
|
117
117
|
const [gistUrl, setGistUrl] = useState<string | undefined>();
|
|
118
118
|
|
package/src/hooks/deploy.ts
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { useEffect, useMemo } from 'react';
|
|
5
|
+
import { useCallback, useEffect, useMemo } from 'react';
|
|
6
6
|
|
|
7
7
|
import { FunctionType, type ScriptType, getUserFunctionUrlInMetadata } from '@dxos/functions';
|
|
8
8
|
import { log } from '@dxos/log';
|
|
9
|
-
import {
|
|
10
|
-
import { getMeta, getSpace,
|
|
11
|
-
import {
|
|
9
|
+
import { useClient } from '@dxos/react-client';
|
|
10
|
+
import { Filter, getMeta, getSpace, useQuery } from '@dxos/react-client/echo';
|
|
11
|
+
import { useTranslation } from '@dxos/react-ui';
|
|
12
12
|
import { createMenuAction } from '@dxos/react-ui-menu';
|
|
13
13
|
import { errorMessageColors } from '@dxos/react-ui-theme';
|
|
14
14
|
|
|
@@ -24,68 +24,28 @@ export type DeployState = {
|
|
|
24
24
|
error: string;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
export
|
|
28
|
-
|
|
29
|
-
script: ScriptType;
|
|
30
|
-
fn: FunctionType;
|
|
31
|
-
space?: Space;
|
|
32
|
-
existingFunctionUrl?: string;
|
|
33
|
-
client: Client;
|
|
34
|
-
t: TFunction;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const createDeploy = ({ state, script, space, fn, client, existingFunctionUrl, t }: CreateDeployOptions) => {
|
|
38
|
-
// TODO(wittjosiah): Should this be an action?
|
|
39
|
-
const errorItem = createMenuAction('error', () => {}, {
|
|
27
|
+
export const createDeploy = (state: Partial<DeployState>) => {
|
|
28
|
+
const errorItem = createMenuAction('error', {
|
|
40
29
|
label: state.error ?? ['no error label', { ns: SCRIPT_PLUGIN }],
|
|
41
30
|
icon: 'ph--warning-circle--regular',
|
|
42
31
|
hidden: !state.error,
|
|
43
32
|
classNames: state.error && errorMessageColors,
|
|
44
33
|
});
|
|
45
34
|
|
|
46
|
-
const deployAction = createMenuAction<DeployActionProperties>(
|
|
47
|
-
'deploy',
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
state.error = t('upload failed label');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
state.deploying = false;
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
type: 'deploy',
|
|
67
|
-
label: [state.deploying ? 'pending label' : 'deploy label', { ns: SCRIPT_PLUGIN }],
|
|
68
|
-
icon: state.deploying ? 'ph--spinner-gap--regular' : 'ph--cloud-arrow-up--regular',
|
|
69
|
-
disabled: state.deploying,
|
|
70
|
-
classNames: state.deploying ? '[&_svg]:animate-spin' : '',
|
|
71
|
-
},
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
const copyAction = createMenuAction<DeployActionProperties>(
|
|
75
|
-
'copy',
|
|
76
|
-
async () => {
|
|
77
|
-
if (!state.functionUrl) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
await navigator.clipboard.writeText(state.functionUrl);
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
type: 'copy',
|
|
84
|
-
label: ['copy link label', { ns: SCRIPT_PLUGIN }],
|
|
85
|
-
icon: 'ph--link--regular',
|
|
86
|
-
disabled: !state.functionUrl,
|
|
87
|
-
},
|
|
88
|
-
);
|
|
35
|
+
const deployAction = createMenuAction<DeployActionProperties>('deploy', {
|
|
36
|
+
type: 'deploy',
|
|
37
|
+
label: [state.deploying ? 'pending label' : 'deploy label', { ns: SCRIPT_PLUGIN }],
|
|
38
|
+
icon: state.deploying ? 'ph--spinner-gap--regular' : 'ph--cloud-arrow-up--regular',
|
|
39
|
+
disabled: state.deploying,
|
|
40
|
+
classNames: state.deploying ? '[&_svg]:animate-spin' : '',
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const copyAction = createMenuAction<DeployActionProperties>('copy', {
|
|
44
|
+
type: 'copy',
|
|
45
|
+
label: ['copy link label', { ns: SCRIPT_PLUGIN }],
|
|
46
|
+
icon: 'ph--link--regular',
|
|
47
|
+
disabled: !state.functionUrl,
|
|
48
|
+
});
|
|
89
49
|
|
|
90
50
|
return {
|
|
91
51
|
nodes: [errorItem, deployAction, copyAction],
|
|
@@ -118,8 +78,42 @@ export const useDeployState = ({ state, script }: { state: Partial<DeployState>;
|
|
|
118
78
|
|
|
119
79
|
export const useDeployDeps = ({ script }: { script: ScriptType }) => {
|
|
120
80
|
const space = getSpace(script);
|
|
121
|
-
const [fn] = useQuery(space,
|
|
81
|
+
const [fn] = useQuery(space, Filter.schema(FunctionType, { source: script }));
|
|
122
82
|
const client = useClient();
|
|
123
83
|
const existingFunctionUrl = useMemo(() => fn && getUserFunctionUrlInMetadata(getMeta(fn)), [fn]);
|
|
124
84
|
return { space, fn, client, existingFunctionUrl };
|
|
125
85
|
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Manage EDGE function deployment.
|
|
89
|
+
*/
|
|
90
|
+
export const useDeployHandler = ({ state, script }: { state: Partial<DeployState>; script: ScriptType }) => {
|
|
91
|
+
const { space, fn, client, existingFunctionUrl } = useDeployDeps({ script });
|
|
92
|
+
const { t } = useTranslation(SCRIPT_PLUGIN);
|
|
93
|
+
|
|
94
|
+
return useCallback(async () => {
|
|
95
|
+
if (!script.source || !space) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
state.error = undefined;
|
|
100
|
+
state.deploying = true;
|
|
101
|
+
|
|
102
|
+
const result = await deployScript({ script, client, space, fn, existingFunctionUrl });
|
|
103
|
+
|
|
104
|
+
if (!result.success) {
|
|
105
|
+
log.catch(result.error);
|
|
106
|
+
state.error = t('upload failed label');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
state.deploying = false;
|
|
110
|
+
}, [fn, client, t, existingFunctionUrl, script, space]);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const useCopyHandler = ({ state }: { state: Partial<DeployState> }) =>
|
|
114
|
+
useCallback(async () => {
|
|
115
|
+
if (!state.functionUrl) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
await navigator.clipboard.writeText(state.functionUrl);
|
|
119
|
+
}, [state.functionUrl]);
|
package/src/hooks/format.ts
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
import { format } from 'prettier';
|
|
6
6
|
import prettierPluginEstree from 'prettier/plugins/estree';
|
|
7
7
|
import prettierPluginTypescript from 'prettier/plugins/typescript';
|
|
8
|
+
import { useCallback } from 'react';
|
|
8
9
|
|
|
9
|
-
import { type ScriptType } from '@dxos/functions';
|
|
10
|
+
import { type ScriptType } from '@dxos/functions/types';
|
|
10
11
|
import { log } from '@dxos/log';
|
|
11
12
|
import { createMenuAction } from '@dxos/react-ui-menu';
|
|
12
13
|
|
|
@@ -14,34 +15,33 @@ import { SCRIPT_PLUGIN } from '../meta';
|
|
|
14
15
|
|
|
15
16
|
export type FormatActionProperties = { type: 'format' };
|
|
16
17
|
|
|
17
|
-
export const createFormat = (
|
|
18
|
-
const formatAction = createMenuAction(
|
|
19
|
-
'format',
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
try {
|
|
26
|
-
script.source.target!.content = await format(script.source.target!.content, {
|
|
27
|
-
parser: 'typescript',
|
|
28
|
-
plugins: [prettierPluginEstree, prettierPluginTypescript],
|
|
29
|
-
semi: true,
|
|
30
|
-
singleQuote: true,
|
|
31
|
-
});
|
|
32
|
-
} catch (err: any) {
|
|
33
|
-
// TODO(wittjosiah): Show error in UI.
|
|
34
|
-
log.catch(err);
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
label: ['format label', { ns: SCRIPT_PLUGIN }],
|
|
39
|
-
icon: 'ph--magic-wand--regular',
|
|
40
|
-
},
|
|
41
|
-
);
|
|
18
|
+
export const createFormat = () => {
|
|
19
|
+
const formatAction = createMenuAction('format', {
|
|
20
|
+
label: ['format label', { ns: SCRIPT_PLUGIN }],
|
|
21
|
+
icon: 'ph--magic-wand--regular',
|
|
22
|
+
});
|
|
42
23
|
|
|
43
24
|
return {
|
|
44
25
|
nodes: [formatAction],
|
|
45
26
|
edges: [{ source: 'root', target: 'format' }],
|
|
46
27
|
};
|
|
47
28
|
};
|
|
29
|
+
|
|
30
|
+
export const useFormatHandler = ({ script }: { script: ScriptType }) =>
|
|
31
|
+
useCallback(async () => {
|
|
32
|
+
if (!script.source) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
script.source.target!.content = await format(script.source.target!.content, {
|
|
38
|
+
parser: 'typescript',
|
|
39
|
+
plugins: [prettierPluginEstree, prettierPluginTypescript],
|
|
40
|
+
semi: true,
|
|
41
|
+
singleQuote: true,
|
|
42
|
+
});
|
|
43
|
+
} catch (err: any) {
|
|
44
|
+
// TODO(wittjosiah): Show error in UI.
|
|
45
|
+
log.catch(err);
|
|
46
|
+
}
|
|
47
|
+
}, [script.source]);
|