@dxos/plugin-script 0.8.2-main.12df754 → 0.8.2-main.2f9c567
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-QEKJ54ZB.mjs → DeploymentDialog-EMYG5BCD.mjs} +4 -4
- package/dist/lib/browser/{ScriptContainer-ATBYTIFH.mjs → ScriptContainer-YI4U25EM.mjs} +5 -5
- package/dist/lib/browser/ScriptContainer-YI4U25EM.mjs.map +7 -0
- package/dist/lib/browser/{artifact-definition-OEDM2SCN.mjs → artifact-definition-PD4UAAQZ.mjs} +41 -35
- package/dist/lib/browser/artifact-definition-PD4UAAQZ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-QNXJNXQZ.mjs → chunk-4EA5VWVM.mjs} +6 -6
- package/dist/lib/browser/chunk-4EA5VWVM.mjs.map +7 -0
- package/dist/lib/browser/chunk-6MLJJI73.mjs +40 -0
- package/dist/lib/browser/chunk-6MLJJI73.mjs.map +7 -0
- package/dist/lib/browser/{chunk-SXS6PUU5.mjs → chunk-AA3MEHWR.mjs} +5 -4
- package/dist/lib/browser/chunk-AA3MEHWR.mjs.map +7 -0
- package/dist/lib/browser/chunk-AIO76GTZ.mjs +87 -0
- package/dist/lib/browser/chunk-AIO76GTZ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-EGDYE5MW.mjs → chunk-FIWZUPMO.mjs} +4 -4
- package/dist/lib/browser/{chunk-EGDYE5MW.mjs.map → chunk-FIWZUPMO.mjs.map} +1 -1
- package/dist/lib/browser/{chunk-OZEMT3NO.mjs → chunk-RIKHDIEO.mjs} +2 -2
- package/dist/lib/browser/chunk-RIKHDIEO.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +12 -12
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-C5D6TNPC.mjs → intent-resolver-UCPY7F6I.mjs} +11 -11
- package/dist/lib/browser/intent-resolver-UCPY7F6I.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-XJCN7XXF.mjs → react-surface-M76DWUVT.mjs} +8 -8
- package/dist/lib/browser/react-surface-M76DWUVT.mjs.map +7 -0
- package/dist/lib/browser/{settings-NK4XVS2E.mjs → settings-EOKSUGB6.mjs} +2 -2
- package/dist/lib/browser/types.mjs +1 -1
- package/dist/lib/node/{DeploymentDialog-NUKZNILK.cjs → DeploymentDialog-VWKE3X2Y.cjs} +9 -9
- package/dist/lib/node/{DeploymentDialog-NUKZNILK.cjs.map → DeploymentDialog-VWKE3X2Y.cjs.map} +2 -2
- package/dist/lib/node/{ScriptContainer-OHHMLPUE.cjs → ScriptContainer-2MIDQAOV.cjs} +14 -14
- package/dist/lib/node/ScriptContainer-2MIDQAOV.cjs.map +7 -0
- package/dist/lib/node/{artifact-definition-SEGATFNH.cjs → artifact-definition-C644EAYM.cjs} +47 -41
- package/dist/lib/node/artifact-definition-C644EAYM.cjs.map +7 -0
- package/dist/lib/node/chunk-BWBZ22HH.cjs +91 -0
- package/dist/lib/node/chunk-BWBZ22HH.cjs.map +7 -0
- package/dist/lib/node/{chunk-UUGLBCMY.cjs → chunk-FVCSTJDX.cjs} +14 -14
- package/dist/lib/node/chunk-FVCSTJDX.cjs.map +7 -0
- package/dist/lib/node/{chunk-ZZ4HK5KM.cjs → chunk-I4U27VO6.cjs} +11 -11
- package/dist/lib/node/chunk-I4U27VO6.cjs.map +7 -0
- package/dist/lib/node/{chunk-PMGWL64F.cjs → chunk-NBOJUJSM.cjs} +6 -6
- package/dist/lib/node/chunk-NBOJUJSM.cjs.map +7 -0
- package/dist/lib/node/{chunk-PGEGRJP3.cjs → chunk-SXJGHLK6.cjs} +16 -17
- package/dist/lib/node/chunk-SXJGHLK6.cjs.map +7 -0
- package/dist/lib/node/{chunk-DSFCLQ5F.cjs → chunk-XT76CMHH.cjs} +10 -9
- package/dist/lib/node/chunk-XT76CMHH.cjs.map +7 -0
- package/dist/lib/node/index.cjs +24 -24
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/{intent-resolver-BQPBRVHM.cjs → intent-resolver-IO3FBKP2.cjs} +20 -20
- package/dist/lib/node/intent-resolver-IO3FBKP2.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-5XHS5WYW.cjs → react-surface-AIHO75E7.cjs} +26 -26
- package/dist/lib/node/react-surface-AIHO75E7.cjs.map +7 -0
- package/dist/lib/node/{settings-7PVJBWC4.cjs → settings-425QHVGC.cjs} +7 -7
- package/dist/lib/node/types.cjs +3 -3
- package/dist/lib/node/types.cjs.map +1 -1
- package/dist/lib/node-esm/{DeploymentDialog-BIXZ5Q57.mjs → DeploymentDialog-FGFA6MG2.mjs} +4 -4
- package/dist/lib/node-esm/{ScriptContainer-4YWGWPY7.mjs → ScriptContainer-GYTXNQMB.mjs} +5 -5
- package/dist/lib/node-esm/ScriptContainer-GYTXNQMB.mjs.map +7 -0
- package/dist/lib/node-esm/{artifact-definition-5UHIXXHW.mjs → artifact-definition-J6UM6BQF.mjs} +41 -35
- package/dist/lib/node-esm/artifact-definition-J6UM6BQF.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-NNQXJQBG.mjs → chunk-3FAUXSL4.mjs} +4 -4
- package/dist/lib/node-esm/{chunk-NNQXJQBG.mjs.map → chunk-3FAUXSL4.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-GR4VTXVM.mjs → chunk-NERLX6GG.mjs} +2 -2
- package/dist/lib/node-esm/chunk-NERLX6GG.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NMMN5ZIG.mjs +89 -0
- package/dist/lib/node-esm/chunk-NMMN5ZIG.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-4ISQLIIH.mjs → chunk-OSDNCSBE.mjs} +6 -6
- package/dist/lib/node-esm/chunk-OSDNCSBE.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-KGYTIL33.mjs → chunk-VMQPOPKV.mjs} +12 -13
- package/dist/lib/node-esm/chunk-VMQPOPKV.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-TN35DSTF.mjs → chunk-X27CHZ64.mjs} +5 -4
- package/dist/lib/node-esm/chunk-X27CHZ64.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +12 -12
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-PPJKPHUQ.mjs → intent-resolver-W3MJ427G.mjs} +11 -11
- package/dist/lib/node-esm/intent-resolver-W3MJ427G.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-7ELFL7IO.mjs → react-surface-IAUELUG6.mjs} +8 -8
- package/dist/lib/node-esm/react-surface-IAUELUG6.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-SJYC4JLT.mjs → settings-BWSKKIVQ.mjs} +2 -2
- package/dist/lib/node-esm/types.mjs +1 -1
- 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.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/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/index.d.ts +1 -1
- package/dist/types/src/hooks/deploy.d.ts +4 -3
- package/dist/types/src/hooks/deploy.d.ts.map +1 -1
- package/dist/types/src/hooks/format.d.ts +1 -1
- package/dist/types/src/hooks/format.d.ts.map +1 -1
- package/dist/types/src/hooks/template.d.ts +1 -1
- package/dist/types/src/hooks/template.d.ts.map +1 -1
- package/dist/types/src/hooks/useToolbarAction.d.ts +1 -1
- package/dist/types/src/hooks/useToolbarAction.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.map +1 -1
- package/dist/types/src/templates/discord.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/types.d.ts +27 -26
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/src/util/deploy.d.ts.map +1 -1
- package/package.json +51 -49
- package/src/ScriptPlugin.tsx +3 -3
- package/src/capabilities/artifact-definition.ts +33 -30
- package/src/capabilities/intent-resolver.ts +5 -5
- package/src/capabilities/react-surface.tsx +3 -3
- package/src/components/DeploymentDialog/DeploymentDialog.tsx +2 -2
- package/src/components/ScriptContainer.tsx +1 -1
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +1 -1
- package/src/components/Settings/ScriptObjectSettings.tsx +3 -3
- package/src/hooks/format.ts +1 -1
- package/src/hooks/template.ts +1 -1
- package/src/hooks/useToolbarAction.ts +1 -1
- package/src/templates/chess.ts +7 -6
- package/src/templates/data-generator.ts +6 -5
- package/src/templates/discord.ts +24 -16
- package/src/templates/forex-effect.ts +6 -5
- package/src/templates/forex.ts +5 -4
- package/src/templates/gmail.ts +96 -82
- package/src/translations.ts +1 -1
- package/src/types.ts +13 -14
- package/src/util/deploy.ts +1 -2
- package/dist/lib/browser/ScriptContainer-ATBYTIFH.mjs.map +0 -7
- package/dist/lib/browser/artifact-definition-OEDM2SCN.mjs.map +0 -7
- package/dist/lib/browser/chunk-OZEMT3NO.mjs.map +0 -7
- package/dist/lib/browser/chunk-QNXJNXQZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-SXS6PUU5.mjs.map +0 -7
- package/dist/lib/browser/chunk-XEPVXV72.mjs +0 -87
- package/dist/lib/browser/chunk-XEPVXV72.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZFTDU4WS.mjs +0 -41
- package/dist/lib/browser/chunk-ZFTDU4WS.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-C5D6TNPC.mjs.map +0 -7
- package/dist/lib/browser/react-surface-XJCN7XXF.mjs.map +0 -7
- package/dist/lib/node/ScriptContainer-OHHMLPUE.cjs.map +0 -7
- package/dist/lib/node/artifact-definition-SEGATFNH.cjs.map +0 -7
- package/dist/lib/node/chunk-4K23KEYT.cjs +0 -91
- package/dist/lib/node/chunk-4K23KEYT.cjs.map +0 -7
- package/dist/lib/node/chunk-DSFCLQ5F.cjs.map +0 -7
- package/dist/lib/node/chunk-PGEGRJP3.cjs.map +0 -7
- package/dist/lib/node/chunk-PMGWL64F.cjs.map +0 -7
- package/dist/lib/node/chunk-UUGLBCMY.cjs.map +0 -7
- package/dist/lib/node/chunk-ZZ4HK5KM.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-BQPBRVHM.cjs.map +0 -7
- package/dist/lib/node/react-surface-5XHS5WYW.cjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-4YWGWPY7.mjs.map +0 -7
- package/dist/lib/node-esm/artifact-definition-5UHIXXHW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4ISQLIIH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GR4VTXVM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-KGYTIL33.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-TN35DSTF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-X64SI6XO.mjs +0 -89
- package/dist/lib/node-esm/chunk-X64SI6XO.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-PPJKPHUQ.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-7ELFL7IO.mjs.map +0 -7
- /package/dist/lib/browser/{DeploymentDialog-QEKJ54ZB.mjs.map → DeploymentDialog-EMYG5BCD.mjs.map} +0 -0
- /package/dist/lib/browser/{settings-NK4XVS2E.mjs.map → settings-EOKSUGB6.mjs.map} +0 -0
- /package/dist/lib/node/{settings-7PVJBWC4.cjs.map → settings-425QHVGC.cjs.map} +0 -0
- /package/dist/lib/node-esm/{DeploymentDialog-BIXZ5Q57.mjs.map → DeploymentDialog-FGFA6MG2.mjs.map} +0 -0
- /package/dist/lib/node-esm/{settings-SJYC4JLT.mjs.map → settings-BWSKKIVQ.mjs.map} +0 -0
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Schema } from 'effect';
|
|
6
|
+
|
|
5
7
|
import { Capabilities, contributes, createIntent, type PromiseIntentDispatcher } from '@dxos/app-framework';
|
|
6
8
|
import { defineArtifact, defineTool, ToolResult } from '@dxos/artifact';
|
|
7
9
|
import { createArtifactElement } from '@dxos/assistant';
|
|
8
|
-
import {
|
|
9
|
-
import { ScriptType } from '@dxos/functions/types';
|
|
10
|
+
import { ScriptType } from '@dxos/functions';
|
|
10
11
|
import { invariant } from '@dxos/invariant';
|
|
11
12
|
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
12
13
|
import { live, makeRef, type Space } from '@dxos/react-client/echo';
|
|
13
|
-
import {
|
|
14
|
+
import { DataType } from '@dxos/schema';
|
|
14
15
|
|
|
15
16
|
import { meta } from '../meta';
|
|
16
17
|
// TODO(burdon): Factor out.
|
|
@@ -71,28 +72,28 @@ export default () => {
|
|
|
71
72
|
<apis>
|
|
72
73
|
export function defineFunction(params: {
|
|
73
74
|
description: string,
|
|
74
|
-
inputSchema:
|
|
75
|
-
outputSchema:
|
|
75
|
+
inputSchema: Schema.Schema,
|
|
76
|
+
outputSchema: Schema.Schema,
|
|
76
77
|
handler: (params: { event: { data: TInput } }) => Promise<TOutput>
|
|
77
78
|
}): FunctionDefinition
|
|
78
79
|
/**
|
|
79
80
|
* Effect Schema
|
|
80
81
|
*/
|
|
81
|
-
export const
|
|
82
|
+
export const Schema;
|
|
82
83
|
|
|
83
84
|
// Examples:
|
|
84
85
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
from:
|
|
90
|
-
to:
|
|
86
|
+
Schema.String
|
|
87
|
+
Schema.Number
|
|
88
|
+
Schema.Boolean
|
|
89
|
+
Schema.Struct({
|
|
90
|
+
from: Schema.String.annotations({ description: 'The source currency' }),
|
|
91
|
+
to: Schema.String.annotations({ description: 'The target currency' }),
|
|
91
92
|
})
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
Schema.Array(Schema.String)
|
|
94
|
+
Schema.Union(Schema.String, Schema.Number)
|
|
95
|
+
Schema.optional(Schema.String)
|
|
96
|
+
Schema.String.annotations({ description: 'The source currency' })
|
|
96
97
|
</apis>
|
|
97
98
|
|
|
98
99
|
<handler_function>
|
|
@@ -113,13 +114,13 @@ export default () => {
|
|
|
113
114
|
export default defineFunction({
|
|
114
115
|
description: 'Returns the exchange rate between two currencies.',
|
|
115
116
|
|
|
116
|
-
inputSchema:
|
|
117
|
-
from:
|
|
118
|
-
to:
|
|
117
|
+
inputSchema: Schema.Struct({
|
|
118
|
+
from: Schema.String.annotations({ description: 'The source currency' }),
|
|
119
|
+
to: Schema.String.annotations({ description: 'The target currency' }),
|
|
119
120
|
}),
|
|
120
121
|
|
|
121
|
-
outputSchema:
|
|
122
|
-
rate:
|
|
122
|
+
outputSchema: Schema.Struct({
|
|
123
|
+
rate: Schema.String.annotations({ description: 'The exchange rate' }),
|
|
123
124
|
}),
|
|
124
125
|
|
|
125
126
|
handler: async ({
|
|
@@ -143,9 +144,9 @@ export default () => {
|
|
|
143
144
|
name: 'create',
|
|
144
145
|
description: 'Create a new script. Returns the artifact definition for the script',
|
|
145
146
|
caption: 'Creating script...',
|
|
146
|
-
schema:
|
|
147
|
-
name:
|
|
148
|
-
code:
|
|
147
|
+
schema: Schema.Struct({
|
|
148
|
+
name: Schema.String.annotations({ description: 'The name of the script' }),
|
|
149
|
+
code: Schema.String.annotations({
|
|
149
150
|
description: 'The full code of the script in JavaScript or TypeScript. Must be valid executable code.',
|
|
150
151
|
}),
|
|
151
152
|
}),
|
|
@@ -155,7 +156,7 @@ export default () => {
|
|
|
155
156
|
const script = live(ScriptType, {
|
|
156
157
|
name,
|
|
157
158
|
source: makeRef(
|
|
158
|
-
live(
|
|
159
|
+
live(DataType.Text, {
|
|
159
160
|
content: code,
|
|
160
161
|
}),
|
|
161
162
|
),
|
|
@@ -176,8 +177,9 @@ export default () => {
|
|
|
176
177
|
name: 'inspect',
|
|
177
178
|
description: 'Inspect a script. Returns the artifact definition for the script',
|
|
178
179
|
caption: 'Inspecting script...',
|
|
179
|
-
schema:
|
|
180
|
-
|
|
180
|
+
schema: Schema.Struct({
|
|
181
|
+
// TODO(wittjosiah): ObjectId schema should be used here but it's not working.
|
|
182
|
+
id: Schema.String.annotations({ description: 'The ID of the script' }),
|
|
181
183
|
}),
|
|
182
184
|
execute: async ({ id }, { extensions }) => {
|
|
183
185
|
invariant(extensions?.space, 'No space');
|
|
@@ -195,9 +197,10 @@ export default () => {
|
|
|
195
197
|
name: 'update',
|
|
196
198
|
description: 'Update a script. Returns the artifact definition for the script',
|
|
197
199
|
caption: 'Updating script...',
|
|
198
|
-
schema:
|
|
199
|
-
|
|
200
|
-
|
|
200
|
+
schema: Schema.Struct({
|
|
201
|
+
// TODO(wittjosiah): ObjectId schema should be used here but it's not working.
|
|
202
|
+
id: Schema.String.annotations({ description: 'The ID of the script to update' }),
|
|
203
|
+
code: Schema.String.annotations({
|
|
201
204
|
description: 'The full code of the script in JavaScript or TypeScript. Must be valid executable code.',
|
|
202
205
|
}),
|
|
203
206
|
}),
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Octokit } from '@octokit/core';
|
|
6
|
-
import {
|
|
6
|
+
import { Predicate } from 'effect';
|
|
7
7
|
|
|
8
8
|
import { contributes, Capabilities, createResolver, createIntent, LayoutAction } from '@dxos/app-framework';
|
|
9
|
-
import { ScriptType } from '@dxos/functions
|
|
9
|
+
import { ScriptType } from '@dxos/functions';
|
|
10
10
|
import { live, makeRef } from '@dxos/live-object';
|
|
11
11
|
import { TokenManagerAction } from '@dxos/plugin-token-manager/types';
|
|
12
|
-
import {
|
|
12
|
+
import { DataType } from '@dxos/schema';
|
|
13
13
|
|
|
14
14
|
import { DEPLOYMENT_DIALOG } from '../components';
|
|
15
15
|
import { defaultScriptsForIntegration } from '../meta';
|
|
@@ -49,7 +49,7 @@ export default () =>
|
|
|
49
49
|
data: {
|
|
50
50
|
object: live(ScriptType, {
|
|
51
51
|
name,
|
|
52
|
-
source: makeRef(live(
|
|
52
|
+
source: makeRef(live(DataType.Text, { 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(isNotNullable);
|
|
63
|
+
.filter(Predicate.isNotNullable);
|
|
64
64
|
|
|
65
65
|
if (scriptTemplates.length > 0) {
|
|
66
66
|
return {
|
|
@@ -7,11 +7,11 @@ import React from 'react';
|
|
|
7
7
|
import { Capabilities, contributes, createSurface, useCapability } from '@dxos/app-framework';
|
|
8
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';
|
|
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 DataType } from '@dxos/schema';
|
|
15
15
|
|
|
16
16
|
import { ScriptCapabilities } from './capabilities';
|
|
17
17
|
import {
|
|
@@ -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: DataType.AccessToken; scriptTemplates: any } } =>
|
|
96
96
|
data.component === DEPLOYMENT_DIALOG,
|
|
97
97
|
component: ({ data }) => <DeploymentDialog {...data.props} />,
|
|
98
98
|
}),
|
|
@@ -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 DataType } 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: DataType.AccessToken;
|
|
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';
|
|
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';
|
|
@@ -4,7 +4,7 @@
|
|
|
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';
|
|
8
8
|
import { fullyQualifiedId } from '@dxos/react-client/echo';
|
|
9
9
|
import { ElevationProvider, type ThemedClassName } from '@dxos/react-ui';
|
|
10
10
|
import { stackItemContentToolbarClassNames } from '@dxos/react-ui-editor';
|
|
@@ -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';
|
|
10
10
|
import { log } from '@dxos/log';
|
|
11
11
|
import { useClient } from '@dxos/react-client';
|
|
12
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 { DataType } from '@dxos/schema';
|
|
15
15
|
|
|
16
16
|
import { SCRIPT_PLUGIN } from '../../meta';
|
|
17
17
|
|
|
@@ -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.schema(
|
|
115
|
+
const [githubToken] = useQuery(space, Filter.schema(DataType.AccessToken, { 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/format.ts
CHANGED
|
@@ -7,7 +7,7 @@ import prettierPluginEstree from 'prettier/plugins/estree';
|
|
|
7
7
|
import prettierPluginTypescript from 'prettier/plugins/typescript';
|
|
8
8
|
import { useCallback } from 'react';
|
|
9
9
|
|
|
10
|
-
import { type ScriptType } from '@dxos/functions
|
|
10
|
+
import { type ScriptType } from '@dxos/functions';
|
|
11
11
|
import { log } from '@dxos/log';
|
|
12
12
|
import { createMenuAction } from '@dxos/react-ui-menu';
|
|
13
13
|
|
package/src/hooks/template.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { useCallback } from 'react';
|
|
6
6
|
|
|
7
|
-
import { FUNCTIONS_PRESET_META_KEY, type ScriptType } from '@dxos/functions
|
|
7
|
+
import { FUNCTIONS_PRESET_META_KEY, type ScriptType } from '@dxos/functions';
|
|
8
8
|
import { getMeta } from '@dxos/live-object';
|
|
9
9
|
import { createMenuItemGroup, createMenuAction } from '@dxos/react-ui-menu';
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { useCallback } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type ScriptType } from '@dxos/functions
|
|
7
|
+
import { type ScriptType } from '@dxos/functions';
|
|
8
8
|
import { log } from '@dxos/log';
|
|
9
9
|
import { type MenuAction, type MenuActionHandler } from '@dxos/react-ui-menu';
|
|
10
10
|
|
package/src/templates/chess.ts
CHANGED
|
@@ -2,25 +2,26 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Schema } from 'effect';
|
|
5
6
|
// @ts-ignore
|
|
6
|
-
import { defineFunction
|
|
7
|
+
import { defineFunction } from 'dxos:functions';
|
|
7
8
|
// @ts-ignore
|
|
8
9
|
import { Chess } from 'https://esm.sh/chess.js@0.13.1';
|
|
9
10
|
|
|
10
11
|
export default defineFunction({
|
|
11
12
|
description: 'Plays a random move in a chess game.',
|
|
12
13
|
|
|
13
|
-
inputSchema:
|
|
14
|
-
changedObjectId:
|
|
14
|
+
inputSchema: Schema.Struct({
|
|
15
|
+
changedObjectId: Schema.String.annotations({
|
|
15
16
|
description: 'The objects to play the game on.',
|
|
16
17
|
}),
|
|
17
|
-
player:
|
|
18
|
+
player: Schema.optional(Schema.Literal('w', 'b')).annotations({
|
|
18
19
|
description: 'The player to play the game as.',
|
|
19
20
|
}),
|
|
20
21
|
}),
|
|
21
22
|
|
|
22
|
-
outputSchema:
|
|
23
|
-
state:
|
|
23
|
+
outputSchema: Schema.Struct({
|
|
24
|
+
state: Schema.String.annotations({
|
|
24
25
|
description: 'The state of the game as an ASCII art board.',
|
|
25
26
|
}),
|
|
26
27
|
}),
|
|
@@ -2,19 +2,20 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Schema } from 'effect';
|
|
5
6
|
// @ts-ignore
|
|
6
7
|
import { defineFunction, S, create, Expando } from 'dxos:functions';
|
|
7
8
|
// @ts-ignore
|
|
8
9
|
import { randText } from 'https://esm.sh/@ngneat/falso@7.1.1';
|
|
9
10
|
|
|
10
11
|
export default defineFunction({
|
|
11
|
-
inputSchema:
|
|
12
|
-
documentAmount:
|
|
13
|
-
textSize:
|
|
14
|
-
mutationAmount:
|
|
12
|
+
inputSchema: Schema.Struct({
|
|
13
|
+
documentAmount: Schema.optional(Schema.Number),
|
|
14
|
+
textSize: Schema.optional(Schema.Number),
|
|
15
|
+
mutationAmount: Schema.optional(Schema.Number),
|
|
15
16
|
}),
|
|
16
17
|
|
|
17
|
-
outputSchema:
|
|
18
|
+
outputSchema: Schema.Struct({}),
|
|
18
19
|
|
|
19
20
|
handler: async ({
|
|
20
21
|
event: {
|
package/src/templates/discord.ts
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Schema } from 'effect';
|
|
5
6
|
// @ts-ignore
|
|
6
|
-
import { create,
|
|
7
|
+
import { create, defineFunction, DXN, Filter, ObjectId, S } from 'dxos:functions';
|
|
7
8
|
import {
|
|
8
9
|
FetchHttpClient,
|
|
9
10
|
// @ts-ignore
|
|
@@ -13,13 +14,20 @@ import { DiscordConfig, DiscordREST, DiscordRESTMemoryLive } from 'https://esm.s
|
|
|
13
14
|
// @ts-ignore
|
|
14
15
|
import { Effect, Config, Redacted, Ref } from 'https://esm.sh/effect@3.13.3';
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
import { Type } from '@dxos/echo';
|
|
18
|
+
|
|
19
|
+
const MessageSchema = Schema.Struct({
|
|
20
|
+
id: ObjectId,
|
|
21
|
+
foreignId: Schema.Any, // bigint?
|
|
22
|
+
from: Schema.String,
|
|
23
|
+
created: Schema.String,
|
|
24
|
+
content: Schema.String,
|
|
25
|
+
}).pipe(
|
|
26
|
+
Type.def({
|
|
27
|
+
typename: 'example.com/type/Message',
|
|
28
|
+
version: '0.1.0',
|
|
29
|
+
}),
|
|
30
|
+
);
|
|
23
31
|
|
|
24
32
|
const DEFAULT_AFTER = 1704067200; // 2024-01-01
|
|
25
33
|
|
|
@@ -29,17 +37,17 @@ const generateSnowflake = (unixTimestamp: number): bigint => {
|
|
|
29
37
|
};
|
|
30
38
|
|
|
31
39
|
export default defineFunction({
|
|
32
|
-
inputSchema:
|
|
40
|
+
inputSchema: Schema.Struct({
|
|
33
41
|
// TODO(wittjosiah): Remove. This is used to provide a terminal for a cron trigger.
|
|
34
|
-
tick:
|
|
35
|
-
channelId:
|
|
36
|
-
after:
|
|
37
|
-
pageSize:
|
|
38
|
-
queueId:
|
|
42
|
+
tick: Schema.optional(Schema.String),
|
|
43
|
+
channelId: Schema.String,
|
|
44
|
+
after: Schema.optional(Schema.Number),
|
|
45
|
+
pageSize: Schema.optional(Schema.Number),
|
|
46
|
+
queueId: Schema.String,
|
|
39
47
|
}),
|
|
40
48
|
|
|
41
|
-
outputSchema:
|
|
42
|
-
newMessages:
|
|
49
|
+
outputSchema: Schema.Struct({
|
|
50
|
+
newMessages: Schema.Number,
|
|
43
51
|
}),
|
|
44
52
|
|
|
45
53
|
handler: ({
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Schema } from 'effect';
|
|
5
6
|
// @ts-ignore
|
|
6
|
-
import { defineFunction
|
|
7
|
+
import { defineFunction } from 'dxos:functions';
|
|
7
8
|
import {
|
|
8
9
|
HttpClient,
|
|
9
10
|
HttpClientRequest,
|
|
@@ -16,12 +17,12 @@ import { Effect, Schedule } from 'https://esm.sh/effect@3.13.3';
|
|
|
16
17
|
export default defineFunction({
|
|
17
18
|
description: 'Returns the exchange rate between two currencies.',
|
|
18
19
|
|
|
19
|
-
inputSchema:
|
|
20
|
-
from:
|
|
21
|
-
to:
|
|
20
|
+
inputSchema: Schema.Struct({
|
|
21
|
+
from: Schema.String.annotations({ description: 'The source currency' }),
|
|
22
|
+
to: Schema.String.annotations({ description: 'The target currency' }),
|
|
22
23
|
}),
|
|
23
24
|
|
|
24
|
-
outputSchema:
|
|
25
|
+
outputSchema: Schema.String.annotations({ description: 'The exchange rate between the two currencies' }),
|
|
25
26
|
|
|
26
27
|
handler: async ({
|
|
27
28
|
event: {
|
package/src/templates/forex.ts
CHANGED
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Schema } from 'effect';
|
|
5
6
|
// @ts-ignore
|
|
6
|
-
import { defineFunction
|
|
7
|
+
import { defineFunction } from 'dxos:functions';
|
|
7
8
|
|
|
8
9
|
export default defineFunction({
|
|
9
10
|
description: 'Returns the exchange rate between two currencies.',
|
|
10
11
|
|
|
11
|
-
inputSchema:
|
|
12
|
-
from:
|
|
13
|
-
to:
|
|
12
|
+
inputSchema: Schema.Struct({
|
|
13
|
+
from: Schema.String.annotations({ description: 'The source currency' }),
|
|
14
|
+
to: Schema.String.annotations({ description: 'The target currency' }),
|
|
14
15
|
}),
|
|
15
16
|
|
|
16
17
|
handler: async ({
|