@dxos/plugin-script 0.8.2-main.5885341 → 0.8.2-main.600d381
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-W7PY33VN.mjs} +4 -4
- package/dist/lib/browser/{ScriptContainer-ATBYTIFH.mjs → ScriptContainer-FL5IQIOY.mjs} +30 -17
- package/dist/lib/browser/ScriptContainer-FL5IQIOY.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-6MLJJI73.mjs +40 -0
- package/dist/lib/browser/chunk-6MLJJI73.mjs.map +7 -0
- package/dist/lib/browser/{chunk-EGDYE5MW.mjs → chunk-EYYIND3U.mjs} +81 -150
- package/dist/lib/browser/chunk-EYYIND3U.mjs.map +7 -0
- package/dist/lib/browser/chunk-GTJJTVTQ.mjs +87 -0
- package/dist/lib/browser/chunk-GTJJTVTQ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-SXS6PUU5.mjs → chunk-INL55MFV.mjs} +7 -6
- package/dist/lib/browser/chunk-INL55MFV.mjs.map +7 -0
- package/dist/lib/browser/{chunk-QNXJNXQZ.mjs → chunk-IUOZNPZF.mjs} +6 -6
- package/dist/lib/browser/chunk-IUOZNPZF.mjs.map +7 -0
- package/dist/lib/browser/{chunk-OZEMT3NO.mjs → chunk-YNOCAJYT.mjs} +2 -2
- package/dist/lib/browser/chunk-YNOCAJYT.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-E7HKIGR3.mjs} +11 -11
- package/dist/lib/browser/intent-resolver-E7HKIGR3.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-XJCN7XXF.mjs → react-surface-WPZCULNC.mjs} +8 -8
- package/dist/lib/browser/react-surface-WPZCULNC.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-43SI7XFL.cjs} +9 -9
- package/dist/lib/node/{DeploymentDialog-NUKZNILK.cjs.map → DeploymentDialog-43SI7XFL.cjs.map} +2 -2
- package/dist/lib/node/{ScriptContainer-OHHMLPUE.cjs → ScriptContainer-EQFJBC66.cjs} +30 -19
- package/dist/lib/node/ScriptContainer-EQFJBC66.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-UUGLBCMY.cjs → chunk-57MPT7DU.cjs} +85 -152
- package/dist/lib/node/chunk-57MPT7DU.cjs.map +7 -0
- package/dist/lib/node/chunk-DGFQHBA7.cjs +91 -0
- package/dist/lib/node/chunk-DGFQHBA7.cjs.map +7 -0
- package/dist/lib/node/{chunk-DSFCLQ5F.cjs → chunk-K7PPLRVQ.cjs} +12 -11
- package/dist/lib/node/chunk-K7PPLRVQ.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-PMGWL64F.cjs → chunk-VHSIOCS5.cjs} +6 -6
- package/dist/lib/node/chunk-VHSIOCS5.cjs.map +7 -0
- package/dist/lib/node/{chunk-ZZ4HK5KM.cjs → chunk-WNV2RXSK.cjs} +11 -11
- package/dist/lib/node/chunk-WNV2RXSK.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-RNT5VWAM.cjs} +20 -20
- package/dist/lib/node/intent-resolver-RNT5VWAM.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-5XHS5WYW.cjs → react-surface-GQM7SGY3.cjs} +26 -26
- package/dist/lib/node/react-surface-GQM7SGY3.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-2RRUJEBC.mjs} +4 -4
- package/dist/lib/node-esm/{ScriptContainer-4YWGWPY7.mjs → ScriptContainer-VG6BYEG6.mjs} +30 -17
- package/dist/lib/node-esm/ScriptContainer-VG6BYEG6.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-5ES2REWL.mjs +89 -0
- package/dist/lib/node-esm/chunk-5ES2REWL.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-TN35DSTF.mjs → chunk-F47OE6ZM.mjs} +7 -6
- package/dist/lib/node-esm/chunk-F47OE6ZM.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-NNQXJQBG.mjs → chunk-SB3GNMN2.mjs} +81 -150
- package/dist/lib/node-esm/chunk-SB3GNMN2.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-GR4VTXVM.mjs → chunk-V733VFCJ.mjs} +2 -2
- package/dist/lib/node-esm/chunk-V733VFCJ.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-4ISQLIIH.mjs → chunk-ZB55NKKZ.mjs} +6 -6
- package/dist/lib/node-esm/chunk-ZB55NKKZ.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-BZFM7LZ2.mjs} +11 -11
- package/dist/lib/node-esm/intent-resolver-BZFM7LZ2.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-7ELFL7IO.mjs → react-surface-QEOIJO4I.mjs} +8 -8
- package/dist/lib/node-esm/react-surface-QEOIJO4I.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/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 +20 -17
- package/dist/types/src/hooks/deploy.d.ts.map +1 -1
- package/dist/types/src/hooks/format.d.ts +2 -5
- package/dist/types/src/hooks/format.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +0 -1
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/template.d.ts +2 -5
- 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/useToolbarState.d.ts.map +1 -1
- package/dist/types/src/templates/chat.d.ts.map +1 -1
- package/dist/types/src/templates/discord.d.ts.map +1 -1
- package/dist/types/src/templates/echo.d.ts.map +1 -1
- package/dist/types/src/templates/email.d.ts.map +1 -1
- package/dist/types/src/templates/gmail.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +2 -110
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +26 -25
- 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 +52 -50
- 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.stories.tsx +1 -1
- package/src/components/DeploymentDialog/DeploymentDialog.tsx +2 -2
- package/src/components/ScriptContainer.tsx +1 -1
- package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +1 -1
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +16 -10
- package/src/components/Settings/ScriptObjectSettings.tsx +3 -3
- package/src/hooks/deploy.ts +60 -54
- package/src/hooks/format.ts +26 -26
- package/src/hooks/index.ts +0 -1
- package/src/hooks/template.ts +24 -32
- package/src/templates/discord.ts +10 -3
- package/src/templates/forex-effect.ts +1 -1
- package/src/templates/gmail.ts +42 -28
- package/src/translations.ts +1 -1
- package/src/types.ts +13 -14
- package/src/util/deploy.ts +3 -4
- 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-EGDYE5MW.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-NNQXJQBG.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/types/src/hooks/useToolbarAction.d.ts +0 -13
- package/dist/types/src/hooks/useToolbarAction.d.ts.map +0 -1
- package/src/hooks/useToolbarAction.ts +0 -50
- /package/dist/lib/browser/{DeploymentDialog-QEKJ54ZB.mjs.map → DeploymentDialog-W7PY33VN.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-2RRUJEBC.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
|
}),
|
|
@@ -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()],
|
|
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 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,19 +4,21 @@
|
|
|
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
|
-
import { ElevationProvider, type ThemedClassName } from '@dxos/react-ui';
|
|
9
|
+
import { ElevationProvider, useTranslation, 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,
|
|
14
15
|
type ScriptToolbarState,
|
|
15
16
|
createDeploy,
|
|
16
17
|
createFormat,
|
|
17
18
|
createTemplateSelect,
|
|
18
|
-
|
|
19
|
+
useDeployDeps,
|
|
19
20
|
} from '../../hooks';
|
|
21
|
+
import { SCRIPT_PLUGIN } from '../../meta';
|
|
20
22
|
|
|
21
23
|
export type ScriptToolbarProps = ThemedClassName<{
|
|
22
24
|
role?: string;
|
|
@@ -24,11 +26,11 @@ export type ScriptToolbarProps = ThemedClassName<{
|
|
|
24
26
|
state: ScriptToolbarState;
|
|
25
27
|
}>;
|
|
26
28
|
|
|
27
|
-
const createToolbar = (state:
|
|
28
|
-
const templateSelect = createTemplateSelect();
|
|
29
|
-
const format = createFormat();
|
|
29
|
+
const createToolbar = ({ state, script, ...options }: CreateDeployOptions) => {
|
|
30
|
+
const templateSelect = createTemplateSelect(script);
|
|
31
|
+
const format = createFormat(script);
|
|
30
32
|
const gap = createGapSeparator();
|
|
31
|
-
const deploy = createDeploy(state);
|
|
33
|
+
const deploy = createDeploy({ state, script, ...options });
|
|
32
34
|
return {
|
|
33
35
|
nodes: [...templateSelect.nodes, ...format.nodes, ...gap.nodes, ...deploy.nodes],
|
|
34
36
|
edges: [...templateSelect.edges, ...format.edges, ...gap.edges, ...deploy.edges],
|
|
@@ -36,14 +38,18 @@ const createToolbar = (state: ScriptToolbarState) => {
|
|
|
36
38
|
};
|
|
37
39
|
|
|
38
40
|
export const ScriptToolbar = ({ script, role, state, classNames }: ScriptToolbarProps) => {
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
+
const { t } = useTranslation(SCRIPT_PLUGIN);
|
|
42
|
+
const options = useDeployDeps({ script });
|
|
43
|
+
const toolbarCreator = useCallback(
|
|
44
|
+
() => createToolbar({ state, script, t, ...options }),
|
|
45
|
+
[state, script, options, t],
|
|
46
|
+
);
|
|
41
47
|
const menu = useMenuActions(toolbarCreator);
|
|
42
48
|
|
|
43
49
|
return (
|
|
44
50
|
<div role='none' className={stackItemContentToolbarClassNames(role)}>
|
|
45
51
|
<ElevationProvider elevation={role === 'section' ? 'positioned' : 'base'}>
|
|
46
|
-
<MenuProvider {...menu}
|
|
52
|
+
<MenuProvider {...menu} attendableId={fullyQualifiedId(script)}>
|
|
47
53
|
<ToolbarMenu classNames={classNames} />
|
|
48
54
|
</MenuProvider>
|
|
49
55
|
</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';
|
|
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/deploy.ts
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { 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 { useClient } from '@dxos/react-client';
|
|
10
|
-
import { Filter, getMeta, getSpace, useQuery } from '@dxos/react-client/echo';
|
|
11
|
-
import {
|
|
9
|
+
import { type Client, useClient } from '@dxos/react-client';
|
|
10
|
+
import { Filter, getMeta, getSpace, type Space, useQuery } from '@dxos/react-client/echo';
|
|
11
|
+
import { type TFunction } 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,28 +24,68 @@ export type DeployState = {
|
|
|
24
24
|
error: string;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
export
|
|
28
|
-
|
|
27
|
+
export type CreateDeployOptions = {
|
|
28
|
+
state: Partial<DeployState>;
|
|
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', () => {}, {
|
|
29
40
|
label: state.error ?? ['no error label', { ns: SCRIPT_PLUGIN }],
|
|
30
41
|
icon: 'ph--warning-circle--regular',
|
|
31
42
|
hidden: !state.error,
|
|
32
43
|
classNames: state.error && errorMessageColors,
|
|
33
44
|
});
|
|
34
45
|
|
|
35
|
-
const deployAction = createMenuAction<DeployActionProperties>(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
const deployAction = createMenuAction<DeployActionProperties>(
|
|
47
|
+
'deploy',
|
|
48
|
+
async () => {
|
|
49
|
+
if (!script.source || !space) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
state.error = undefined;
|
|
54
|
+
state.deploying = true;
|
|
55
|
+
|
|
56
|
+
const result = await deployScript({ script, client, space, fn, existingFunctionUrl });
|
|
57
|
+
|
|
58
|
+
if (!result.success) {
|
|
59
|
+
log.catch(result.error);
|
|
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
|
+
);
|
|
49
89
|
|
|
50
90
|
return {
|
|
51
91
|
nodes: [errorItem, deployAction, copyAction],
|
|
@@ -83,37 +123,3 @@ export const useDeployDeps = ({ script }: { script: ScriptType }) => {
|
|
|
83
123
|
const existingFunctionUrl = useMemo(() => fn && getUserFunctionUrlInMetadata(getMeta(fn)), [fn]);
|
|
84
124
|
return { space, fn, client, existingFunctionUrl };
|
|
85
125
|
};
|
|
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,9 +5,8 @@
|
|
|
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';
|
|
9
8
|
|
|
10
|
-
import { type ScriptType } from '@dxos/functions
|
|
9
|
+
import { type ScriptType } from '@dxos/functions';
|
|
11
10
|
import { log } from '@dxos/log';
|
|
12
11
|
import { createMenuAction } from '@dxos/react-ui-menu';
|
|
13
12
|
|
|
@@ -15,33 +14,34 @@ import { SCRIPT_PLUGIN } from '../meta';
|
|
|
15
14
|
|
|
16
15
|
export type FormatActionProperties = { type: 'format' };
|
|
17
16
|
|
|
18
|
-
export const createFormat = () => {
|
|
19
|
-
const formatAction = createMenuAction(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
export const createFormat = (script: ScriptType) => {
|
|
18
|
+
const formatAction = createMenuAction(
|
|
19
|
+
'format',
|
|
20
|
+
async () => {
|
|
21
|
+
if (!script.source) {
|
|
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
|
+
);
|
|
23
42
|
|
|
24
43
|
return {
|
|
25
44
|
nodes: [formatAction],
|
|
26
45
|
edges: [{ source: 'root', target: 'format' }],
|
|
27
46
|
};
|
|
28
47
|
};
|
|
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]);
|
package/src/hooks/index.ts
CHANGED
package/src/hooks/template.ts
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import { FUNCTIONS_PRESET_META_KEY, type ScriptType } from '@dxos/functions/types';
|
|
5
|
+
import { FUNCTIONS_PRESET_META_KEY, type ScriptType } from '@dxos/functions';
|
|
8
6
|
import { getMeta } from '@dxos/live-object';
|
|
9
7
|
import { createMenuItemGroup, createMenuAction } from '@dxos/react-ui-menu';
|
|
10
8
|
|
|
@@ -20,19 +18,34 @@ const createTemplateSelectGroup = () => {
|
|
|
20
18
|
});
|
|
21
19
|
};
|
|
22
20
|
|
|
23
|
-
const createTemplateSelectActions = () => {
|
|
21
|
+
const createTemplateSelectActions = (script: ScriptType) => {
|
|
24
22
|
return templates.map((template) => {
|
|
25
|
-
return createMenuAction<TemplateActionProperties>(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
return createMenuAction<TemplateActionProperties>(
|
|
24
|
+
`template--${template.id}`,
|
|
25
|
+
() => {
|
|
26
|
+
script.name = template.name;
|
|
27
|
+
script.source!.target!.content = template.source;
|
|
28
|
+
const metaKeys = getMeta(script).keys;
|
|
29
|
+
const oldPresetIndex = metaKeys.findIndex((key) => key.source === FUNCTIONS_PRESET_META_KEY);
|
|
30
|
+
if (oldPresetIndex >= 0) {
|
|
31
|
+
metaKeys.splice(oldPresetIndex, 1);
|
|
32
|
+
}
|
|
33
|
+
if (template.presetId) {
|
|
34
|
+
metaKeys.push({ source: FUNCTIONS_PRESET_META_KEY, id: template.presetId });
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
label: template.name,
|
|
39
|
+
value: template.id,
|
|
40
|
+
type: 'template',
|
|
41
|
+
},
|
|
42
|
+
);
|
|
30
43
|
});
|
|
31
44
|
};
|
|
32
45
|
|
|
33
|
-
export const createTemplateSelect = () => {
|
|
46
|
+
export const createTemplateSelect = (script: ScriptType) => {
|
|
34
47
|
const templateSelectGroup = createTemplateSelectGroup();
|
|
35
|
-
const templateSelectActions = createTemplateSelectActions();
|
|
48
|
+
const templateSelectActions = createTemplateSelectActions(script);
|
|
36
49
|
return {
|
|
37
50
|
nodes: [templateSelectGroup, ...templateSelectActions],
|
|
38
51
|
edges: [
|
|
@@ -41,24 +54,3 @@ export const createTemplateSelect = () => {
|
|
|
41
54
|
],
|
|
42
55
|
};
|
|
43
56
|
};
|
|
44
|
-
|
|
45
|
-
export const useTemplateSelectHandler = ({ script }: { script: ScriptType }) => {
|
|
46
|
-
return useCallback(
|
|
47
|
-
(templateId: string) => {
|
|
48
|
-
const template = templates.find((template) => template.id === templateId);
|
|
49
|
-
if (template) {
|
|
50
|
-
script.name = template.name;
|
|
51
|
-
script.source!.target!.content = template.source;
|
|
52
|
-
const metaKeys = getMeta(script).keys;
|
|
53
|
-
const oldPresetIndex = metaKeys.findIndex((key) => key.source === FUNCTIONS_PRESET_META_KEY);
|
|
54
|
-
if (oldPresetIndex >= 0) {
|
|
55
|
-
metaKeys.splice(oldPresetIndex, 1);
|
|
56
|
-
}
|
|
57
|
-
if (template.presetId) {
|
|
58
|
-
metaKeys.push({ source: FUNCTIONS_PRESET_META_KEY, id: template.presetId });
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
[script],
|
|
63
|
-
);
|
|
64
|
-
};
|
package/src/templates/discord.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
// @ts-ignore
|
|
6
|
-
import { create,
|
|
6
|
+
import { create, defineFunction, DXN, Filter, ObjectId, S } from 'dxos:functions';
|
|
7
7
|
import {
|
|
8
8
|
FetchHttpClient,
|
|
9
9
|
// @ts-ignore
|
|
@@ -13,13 +13,20 @@ import { DiscordConfig, DiscordREST, DiscordRESTMemoryLive } from 'https://esm.s
|
|
|
13
13
|
// @ts-ignore
|
|
14
14
|
import { Effect, Config, Redacted, Ref } from 'https://esm.sh/effect@3.13.3';
|
|
15
15
|
|
|
16
|
+
import { Type } from '@dxos/echo';
|
|
17
|
+
|
|
16
18
|
const MessageSchema = S.Struct({
|
|
17
|
-
id:
|
|
19
|
+
id: ObjectId,
|
|
18
20
|
foreignId: S.Any, // bigint?
|
|
19
21
|
from: S.String,
|
|
20
22
|
created: S.String,
|
|
21
23
|
content: S.String,
|
|
22
|
-
}).pipe(
|
|
24
|
+
}).pipe(
|
|
25
|
+
Type.def({
|
|
26
|
+
typename: 'example.com/type/Message',
|
|
27
|
+
version: '0.1.0',
|
|
28
|
+
}),
|
|
29
|
+
);
|
|
23
30
|
|
|
24
31
|
const DEFAULT_AFTER = 1704067200; // 2024-01-01
|
|
25
32
|
|