@dxos/plugin-script 0.8.1 → 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-EMYG5BCD.mjs +12 -0
- package/dist/lib/browser/{ScriptContainer-R25PRK2D.mjs → ScriptContainer-YI4U25EM.mjs} +6 -6
- package/dist/lib/browser/ScriptContainer-YI4U25EM.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-RRLY67QC.mjs → app-graph-builder-2GIBRQLV.mjs} +2 -2
- package/dist/lib/browser/{artifact-definition-WXFYD2V5.mjs → artifact-definition-PD4UAAQZ.mjs} +44 -38
- package/dist/lib/browser/artifact-definition-PD4UAAQZ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-2CGZFDCR.mjs → chunk-4EA5VWVM.mjs} +7 -7
- 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-4VD3K3PY.mjs → chunk-A4VOGQ2P.mjs} +2 -2
- package/dist/lib/browser/{chunk-MQZQB5VD.mjs → chunk-AA3MEHWR.mjs} +9 -9
- 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-KLEOGVXY.mjs → chunk-FIWZUPMO.mjs} +7 -7
- package/dist/lib/browser/chunk-FIWZUPMO.mjs.map +7 -0
- package/dist/lib/browser/{chunk-WSK3YQXI.mjs → chunk-KJMVDGRB.mjs} +2 -1
- package/dist/lib/browser/{chunk-WSK3YQXI.mjs.map → chunk-KJMVDGRB.mjs.map} +2 -2
- package/dist/lib/browser/{chunk-CSZXPLYY.mjs → chunk-RIKHDIEO.mjs} +3 -3
- package/dist/lib/browser/chunk-RIKHDIEO.mjs.map +7 -0
- package/dist/lib/browser/{compiler-56LTBEQB.mjs → compiler-O4FJK7RR.mjs} +3 -3
- package/dist/lib/browser/index.mjs +16 -15
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-WCVXKRBR.mjs → intent-resolver-UCPY7F6I.mjs} +14 -14
- 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-WXZVPNGI.mjs → react-surface-M76DWUVT.mjs} +10 -10
- package/dist/lib/browser/react-surface-M76DWUVT.mjs.map +7 -0
- package/dist/lib/browser/{settings-Z7B37V2I.mjs → settings-EOKSUGB6.mjs} +5 -5
- package/dist/lib/browser/settings-EOKSUGB6.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +2 -2
- package/dist/lib/node/{DeploymentDialog-O4MU4OMF.cjs → DeploymentDialog-VWKE3X2Y.cjs} +10 -10
- package/dist/lib/node/DeploymentDialog-VWKE3X2Y.cjs.map +7 -0
- package/dist/lib/node/{ScriptContainer-5KY6ZOQD.cjs → ScriptContainer-2MIDQAOV.cjs} +15 -15
- package/dist/lib/node/ScriptContainer-2MIDQAOV.cjs.map +7 -0
- package/dist/lib/node/{app-graph-builder-6I2BWD46.cjs → app-graph-builder-LNI22TZF.cjs} +9 -9
- package/dist/lib/node/{artifact-definition-6NVXEHJD.cjs → artifact-definition-C644EAYM.cjs} +53 -47
- 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-F4DP7WON.cjs → chunk-FVCSTJDX.cjs} +22 -22
- package/dist/lib/node/chunk-FVCSTJDX.cjs.map +7 -0
- package/dist/lib/node/{chunk-SLDJM45C.cjs → chunk-I4U27VO6.cjs} +17 -17
- package/dist/lib/node/chunk-I4U27VO6.cjs.map +7 -0
- package/dist/lib/node/{chunk-JICWAOWZ.cjs → chunk-KFJQVOGS.cjs} +6 -6
- package/dist/lib/node/{chunk-65MIJR3Q.cjs → chunk-NBOJUJSM.cjs} +17 -17
- package/dist/lib/node/chunk-NBOJUJSM.cjs.map +7 -0
- package/dist/lib/node/{chunk-YJQZHKKA.cjs → chunk-NO5Y74F3.cjs} +5 -4
- package/dist/lib/node/{chunk-YJQZHKKA.cjs.map → chunk-NO5Y74F3.cjs.map} +2 -2
- package/dist/lib/node/{chunk-XFZPWFEG.cjs → chunk-SXJGHLK6.cjs} +18 -19
- package/dist/lib/node/chunk-SXJGHLK6.cjs.map +7 -0
- package/dist/lib/node/{chunk-VYBEBLDO.cjs → chunk-XT76CMHH.cjs} +13 -13
- package/dist/lib/node/chunk-XT76CMHH.cjs.map +7 -0
- package/dist/lib/node/{compiler-W2RU3M7U.cjs → compiler-FBC6ELQN.cjs} +7 -7
- package/dist/lib/node/index.cjs +45 -44
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/{intent-resolver-J4NBDNFH.cjs → intent-resolver-IO3FBKP2.cjs} +21 -21
- 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-27KTUBIZ.cjs → react-surface-AIHO75E7.cjs} +37 -37
- package/dist/lib/node/react-surface-AIHO75E7.cjs.map +7 -0
- package/dist/lib/node/{settings-EI6VPNKN.cjs → settings-425QHVGC.cjs} +9 -9
- package/dist/lib/node/settings-425QHVGC.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-SSQSWLHX.mjs → DeploymentDialog-FGFA6MG2.mjs} +5 -5
- package/dist/lib/node-esm/{ScriptContainer-W2F4FGDV.mjs → ScriptContainer-GYTXNQMB.mjs} +6 -6
- package/dist/lib/node-esm/ScriptContainer-GYTXNQMB.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-H5XLRVX3.mjs → app-graph-builder-NNUXXXMZ.mjs} +2 -2
- package/dist/lib/node-esm/{artifact-definition-KQ64AYBP.mjs → artifact-definition-J6UM6BQF.mjs} +44 -38
- package/dist/lib/node-esm/artifact-definition-J6UM6BQF.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-PBGVTGL2.mjs → chunk-3FAUXSL4.mjs} +7 -7
- package/dist/lib/node-esm/chunk-3FAUXSL4.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-FDEAVT67.mjs → chunk-H7FRB3M7.mjs} +2 -1
- package/dist/lib/node-esm/{chunk-FDEAVT67.mjs.map → chunk-H7FRB3M7.mjs.map} +2 -2
- package/dist/lib/node-esm/{chunk-EB5DSAD4.mjs → chunk-HKJUN636.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-MU3JKVL2.mjs → chunk-NERLX6GG.mjs} +3 -3
- 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-4MTPYMV2.mjs → chunk-OSDNCSBE.mjs} +7 -7
- package/dist/lib/node-esm/chunk-OSDNCSBE.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-RW2APVMV.mjs → chunk-VMQPOPKV.mjs} +13 -14
- package/dist/lib/node-esm/chunk-VMQPOPKV.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-F4HA5C34.mjs → chunk-X27CHZ64.mjs} +9 -9
- package/dist/lib/node-esm/chunk-X27CHZ64.mjs.map +7 -0
- package/dist/lib/node-esm/{compiler-VT5C2Z3T.mjs → compiler-3NG4T5LH.mjs} +3 -3
- package/dist/lib/node-esm/index.mjs +16 -15
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-PDZ2A26X.mjs → intent-resolver-W3MJ427G.mjs} +14 -14
- 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-UCUVDVSH.mjs → react-surface-IAUELUG6.mjs} +10 -10
- package/dist/lib/node-esm/react-surface-IAUELUG6.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-HU5UEFRF.mjs → settings-BWSKKIVQ.mjs} +5 -5
- package/dist/lib/node-esm/settings-BWSKKIVQ.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.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/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/chess.d.ts.map +1 -1
- package/dist/types/src/templates/data-generator.d.ts +0 -7
- 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 +4 -2
- package/src/capabilities/artifact-definition.ts +35 -32
- package/src/capabilities/intent-resolver.ts +7 -7
- package/src/capabilities/react-surface.tsx +3 -3
- package/src/capabilities/settings.ts +2 -2
- 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/hooks/useToolbarState.ts +2 -2
- package/src/meta.ts +1 -0
- package/src/templates/chess.ts +7 -6
- package/src/templates/data-generator.ts +31 -50
- package/src/templates/discord.ts +25 -17
- package/src/templates/forex-effect.ts +6 -5
- package/src/templates/forex.ts +5 -4
- package/src/templates/gmail.ts +97 -83
- package/src/translations.ts +1 -1
- package/src/types.ts +13 -14
- package/src/util/deploy.ts +5 -9
- package/dist/lib/browser/DeploymentDialog-AEPYJKPO.mjs +0 -12
- package/dist/lib/browser/ScriptContainer-R25PRK2D.mjs.map +0 -7
- package/dist/lib/browser/artifact-definition-WXFYD2V5.mjs.map +0 -7
- package/dist/lib/browser/chunk-2CGZFDCR.mjs.map +0 -7
- package/dist/lib/browser/chunk-CSZXPLYY.mjs.map +0 -7
- package/dist/lib/browser/chunk-KLEOGVXY.mjs.map +0 -7
- package/dist/lib/browser/chunk-MQZQB5VD.mjs.map +0 -7
- package/dist/lib/browser/chunk-R2CHVWJ2.mjs +0 -41
- package/dist/lib/browser/chunk-R2CHVWJ2.mjs.map +0 -7
- package/dist/lib/browser/chunk-SUCBNCEQ.mjs +0 -87
- package/dist/lib/browser/chunk-SUCBNCEQ.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-WCVXKRBR.mjs.map +0 -7
- package/dist/lib/browser/react-surface-WXZVPNGI.mjs.map +0 -7
- package/dist/lib/browser/settings-Z7B37V2I.mjs.map +0 -7
- package/dist/lib/node/DeploymentDialog-O4MU4OMF.cjs.map +0 -7
- package/dist/lib/node/ScriptContainer-5KY6ZOQD.cjs.map +0 -7
- package/dist/lib/node/artifact-definition-6NVXEHJD.cjs.map +0 -7
- package/dist/lib/node/chunk-65MIJR3Q.cjs.map +0 -7
- package/dist/lib/node/chunk-F4DP7WON.cjs.map +0 -7
- package/dist/lib/node/chunk-SLDJM45C.cjs.map +0 -7
- package/dist/lib/node/chunk-VYBEBLDO.cjs.map +0 -7
- package/dist/lib/node/chunk-X7MHLHHS.cjs +0 -91
- package/dist/lib/node/chunk-X7MHLHHS.cjs.map +0 -7
- package/dist/lib/node/chunk-XFZPWFEG.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-J4NBDNFH.cjs.map +0 -7
- package/dist/lib/node/react-surface-27KTUBIZ.cjs.map +0 -7
- package/dist/lib/node/settings-EI6VPNKN.cjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-W2F4FGDV.mjs.map +0 -7
- package/dist/lib/node-esm/artifact-definition-KQ64AYBP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4MTPYMV2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-F4HA5C34.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MU3JKVL2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-PBGVTGL2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QDYGTY4L.mjs +0 -89
- package/dist/lib/node-esm/chunk-QDYGTY4L.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RW2APVMV.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-PDZ2A26X.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-UCUVDVSH.mjs.map +0 -7
- package/dist/lib/node-esm/settings-HU5UEFRF.mjs.map +0 -7
- /package/dist/lib/browser/{DeploymentDialog-AEPYJKPO.mjs.map → DeploymentDialog-EMYG5BCD.mjs.map} +0 -0
- /package/dist/lib/browser/{app-graph-builder-RRLY67QC.mjs.map → app-graph-builder-2GIBRQLV.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-4VD3K3PY.mjs.map → chunk-A4VOGQ2P.mjs.map} +0 -0
- /package/dist/lib/browser/{compiler-56LTBEQB.mjs.map → compiler-O4FJK7RR.mjs.map} +0 -0
- /package/dist/lib/node/{app-graph-builder-6I2BWD46.cjs.map → app-graph-builder-LNI22TZF.cjs.map} +0 -0
- /package/dist/lib/node/{chunk-JICWAOWZ.cjs.map → chunk-KFJQVOGS.cjs.map} +0 -0
- /package/dist/lib/node/{compiler-W2RU3M7U.cjs.map → compiler-FBC6ELQN.cjs.map} +0 -0
- /package/dist/lib/node-esm/{DeploymentDialog-SSQSWLHX.mjs.map → DeploymentDialog-FGFA6MG2.mjs.map} +0 -0
- /package/dist/lib/node-esm/{app-graph-builder-H5XLRVX3.mjs.map → app-graph-builder-NNUXXXMZ.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-EB5DSAD4.mjs.map → chunk-HKJUN636.mjs.map} +0 -0
- /package/dist/lib/node-esm/{compiler-VT5C2Z3T.mjs.map → compiler-3NG4T5LH.mjs.map} +0 -0
|
@@ -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
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { live } from '@dxos/live-object';
|
|
8
8
|
|
|
9
9
|
import { type DeployState } from './deploy';
|
|
10
10
|
|
|
@@ -12,5 +12,5 @@ export type ScriptToolbarState = Partial<DeployState>;
|
|
|
12
12
|
|
|
13
13
|
// TODO(burdon): Replace with context provider?
|
|
14
14
|
export const useToolbarState = (initialState: ScriptToolbarState = {}) => {
|
|
15
|
-
return useMemo(() =>
|
|
15
|
+
return useMemo(() => live<ScriptToolbarState>(initialState), []);
|
|
16
16
|
};
|
package/src/meta.ts
CHANGED
|
@@ -19,5 +19,6 @@ export const meta: PluginMeta = {
|
|
|
19
19
|
|
|
20
20
|
// TODO(ZaymonFC): Configure by scopes?
|
|
21
21
|
export const defaultScriptsForIntegration: Record<string, string[]> = {
|
|
22
|
+
// TODO(wittjosiah): Also include content extraction scripts in the default set.
|
|
22
23
|
'gmail.com': ['dxos.org/script/gmail'],
|
|
23
24
|
};
|
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,72 +2,53 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
EchoObject,
|
|
7
|
-
defineFunction,
|
|
8
|
-
S,
|
|
9
|
-
createStatic,
|
|
10
|
-
Expando,
|
|
11
|
-
TypedObject,
|
|
12
|
-
Ref,
|
|
13
|
-
LabelAnnotationId,
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
} from 'dxos:functions';
|
|
5
|
+
import { Schema } from 'effect';
|
|
16
6
|
// @ts-ignore
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
content: S.String,
|
|
21
|
-
}) {}
|
|
22
|
-
|
|
23
|
-
export const DocumentSchema = S.Struct({
|
|
24
|
-
name: S.optional(S.String),
|
|
25
|
-
fallbackName: S.optional(S.String),
|
|
26
|
-
content: Ref(TextType),
|
|
27
|
-
threads: S.mutable(S.Array(Ref(Expando))),
|
|
28
|
-
}).annotations({
|
|
29
|
-
[LabelAnnotationId]: ['name', 'fallbackName'],
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
export const DocumentType = DocumentSchema.pipe(EchoObject('dxos.org/type/Document', '0.1.0'));
|
|
33
|
-
export type DocumentType = S.Schema.Type<typeof DocumentType>;
|
|
7
|
+
import { defineFunction, S, create, Expando } from 'dxos:functions';
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
import { randText } from 'https://esm.sh/@ngneat/falso@7.1.1';
|
|
34
10
|
|
|
35
11
|
export default defineFunction({
|
|
36
|
-
inputSchema:
|
|
37
|
-
documentAmount:
|
|
38
|
-
textSize:
|
|
39
|
-
mutationAmount:
|
|
12
|
+
inputSchema: Schema.Struct({
|
|
13
|
+
documentAmount: Schema.optional(Schema.Number),
|
|
14
|
+
textSize: Schema.optional(Schema.Number),
|
|
15
|
+
mutationAmount: Schema.optional(Schema.Number),
|
|
40
16
|
}),
|
|
41
17
|
|
|
42
|
-
outputSchema:
|
|
18
|
+
outputSchema: Schema.Struct({}),
|
|
43
19
|
|
|
44
|
-
handler: async ({
|
|
20
|
+
handler: async ({
|
|
21
|
+
event: {
|
|
22
|
+
data: { documentAmount = 1, textSize = 10, mutationAmount = 0 },
|
|
23
|
+
},
|
|
24
|
+
context: { space },
|
|
25
|
+
}: any) => {
|
|
45
26
|
await space.db.graph.schemaRegistry.addSchema([Expando]);
|
|
27
|
+
const result: Record<string, any> = {};
|
|
28
|
+
const objects: Expando[] = [];
|
|
46
29
|
|
|
47
|
-
|
|
48
|
-
// const rootCollection = await space.properties[COLLECTION_TYPENAME]?.load();
|
|
30
|
+
// Create objects.
|
|
49
31
|
for (let i = 0; i < documentAmount; i++) {
|
|
50
32
|
const obj = space.db.add(
|
|
51
|
-
|
|
33
|
+
create(Expando, {
|
|
52
34
|
name: 'scriptGenerated',
|
|
53
|
-
content:
|
|
35
|
+
content: randText({ charCount: textSize }),
|
|
54
36
|
}),
|
|
55
37
|
);
|
|
56
|
-
// rootCollection.objects.push(obj);
|
|
57
38
|
objects.push(obj);
|
|
39
|
+
const objectResult: any = {};
|
|
40
|
+
// Mutate the object.
|
|
41
|
+
for (let i = 0; i < mutationAmount; i++) {
|
|
42
|
+
obj.content = randText({ charCount: textSize });
|
|
43
|
+
}
|
|
44
|
+
objectResult.mutations = mutationAmount;
|
|
45
|
+
objectResult.contentLength = obj.content.length;
|
|
46
|
+
result[obj.id] = objectResult;
|
|
58
47
|
}
|
|
59
48
|
|
|
60
|
-
|
|
61
|
-
const obj = objects[Math.floor(Math.random() * objects.length)];
|
|
62
|
-
obj.content = randParagraph({ length: textSize });
|
|
63
|
-
}
|
|
64
|
-
|
|
49
|
+
// Flush and wait for data to propagate.
|
|
65
50
|
await space.db.flush();
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
await space.db.query({ id: obj.id }).first();
|
|
69
|
-
console.log('obj', obj.id);
|
|
70
|
-
}
|
|
71
|
-
return 'OK';
|
|
51
|
+
await new Promise((resolve) => setTimeout(resolve, 10_000));
|
|
52
|
+
return result;
|
|
72
53
|
},
|
|
73
54
|
});
|
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 {
|
|
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: ({
|
|
@@ -73,7 +81,7 @@ export default defineFunction({
|
|
|
73
81
|
const messages = yield* rest.getChannelMessages(channelId, options).pipe((res: any) => res.json);
|
|
74
82
|
const queueMessages = messages
|
|
75
83
|
.map((message: any) =>
|
|
76
|
-
|
|
84
|
+
create(MessageSchema, {
|
|
77
85
|
id: ObjectId.random(),
|
|
78
86
|
foreignId: message.id,
|
|
79
87
|
from: message.author.username,
|
|
@@ -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 ({
|
package/src/templates/gmail.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
// @ts-ignore
|
|
6
|
-
import {
|
|
6
|
+
import { create, defineFunction, Filter, ObjectId } from 'dxos:functions';
|
|
7
|
+
// @ts-ignore
|
|
7
8
|
import {
|
|
8
9
|
HttpClient,
|
|
9
10
|
HttpClientRequest,
|
|
@@ -11,30 +12,33 @@ import {
|
|
|
11
12
|
// @ts-ignore
|
|
12
13
|
} from 'https://esm.sh/@effect/platform@0.77.2?deps=effect@3.13.3';
|
|
13
14
|
// @ts-ignore
|
|
14
|
-
import {
|
|
15
|
+
import { format, subDays } from 'https://esm.sh/date-fns@3.3.1';
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
import { pipe, Chunk, Effect, Ref, Schedule, Schema, Stream } from 'https://esm.sh/effect@3.13.3';
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
const DEFAULT_AFTER = '2025-01-01';
|
|
19
|
+
import { Type } from '@dxos/echo';
|
|
18
20
|
|
|
19
21
|
export default defineFunction({
|
|
20
|
-
inputSchema:
|
|
22
|
+
inputSchema: Schema.Struct({
|
|
23
|
+
mailboxId: Schema.String,
|
|
24
|
+
userId: Schema.optional(Schema.String).pipe(Schema.withDecodingDefault(() => 'me')),
|
|
25
|
+
after: Schema.optional(Schema.Union(Schema.Number, Schema.String)).pipe(
|
|
26
|
+
Schema.withDecodingDefault(() => format(subDays(new Date(), 30), 'yyyy-MM-dd')),
|
|
27
|
+
),
|
|
28
|
+
pageSize: Schema.optional(Schema.Number).pipe(Schema.withDecodingDefault(() => 100)),
|
|
21
29
|
// TODO(wittjosiah): Remove. This is used to provide a terminal for a cron trigger.
|
|
22
|
-
tick:
|
|
23
|
-
userId: S.optional(S.String),
|
|
24
|
-
after: S.optional(S.Union(S.Number, S.String)),
|
|
25
|
-
pageSize: S.optional(S.Number),
|
|
26
|
-
mailboxId: S.String,
|
|
30
|
+
tick: Schema.optional(Schema.String),
|
|
27
31
|
}),
|
|
28
32
|
|
|
29
|
-
outputSchema:
|
|
30
|
-
newMessages:
|
|
33
|
+
outputSchema: Schema.Struct({
|
|
34
|
+
newMessages: Schema.Number,
|
|
31
35
|
}),
|
|
32
36
|
|
|
33
37
|
handler: ({
|
|
38
|
+
context: { space },
|
|
34
39
|
event: {
|
|
35
|
-
data: { mailboxId, userId
|
|
40
|
+
data: { mailboxId, userId, after, pageSize },
|
|
36
41
|
},
|
|
37
|
-
context: { space },
|
|
38
42
|
}: any) =>
|
|
39
43
|
Effect.gen(function* () {
|
|
40
44
|
const { token } = yield* Effect.tryPromise({
|
|
@@ -42,9 +46,10 @@ export default defineFunction({
|
|
|
42
46
|
catch: (e: any) => e,
|
|
43
47
|
});
|
|
44
48
|
|
|
45
|
-
|
|
49
|
+
// NOTE: Google API bundles size is v. large and caused runtime issues.
|
|
50
|
+
const makeRequest = (url: string) =>
|
|
46
51
|
pipe(
|
|
47
|
-
|
|
52
|
+
url,
|
|
48
53
|
HttpClientRequest.get,
|
|
49
54
|
HttpClientRequest.setHeaders({ Authorization: `Bearer ${token}`, Accept: 'application/json' }),
|
|
50
55
|
HttpClient.execute,
|
|
@@ -54,13 +59,10 @@ export default defineFunction({
|
|
|
54
59
|
Effect.scoped,
|
|
55
60
|
);
|
|
56
61
|
|
|
57
|
-
const listMessages = (userId: string, q: string, pageSize: number, pageToken: string | null) =>
|
|
58
|
-
|
|
59
|
-
return makeRequest(pageToken ? `${url}&pageToken=${pageToken}` : url);
|
|
60
|
-
};
|
|
62
|
+
const listMessages = (userId: string, q: string, pageSize: number, pageToken: string | null) =>
|
|
63
|
+
makeRequest(getUrl(userId, undefined, { q, pageSize, pageToken }));
|
|
61
64
|
|
|
62
|
-
const getMessage = (userId: string,
|
|
63
|
-
makeRequest(`https://gmail.googleapis.com/gmail/v1/users/${userId}/messages/${id}`);
|
|
65
|
+
const getMessage = (userId: string, messageId: string) => makeRequest(getUrl(userId, messageId));
|
|
64
66
|
|
|
65
67
|
const mailbox = yield* Effect.tryPromise({
|
|
66
68
|
try: () => space.db.query({ id: mailboxId }).first(),
|
|
@@ -97,7 +99,7 @@ export default defineFunction({
|
|
|
97
99
|
continue;
|
|
98
100
|
}
|
|
99
101
|
const subject = messageDetails.payload.headers.find((h: any) => h.name === 'Subject')?.value;
|
|
100
|
-
const object =
|
|
102
|
+
const object = create(MessageType, {
|
|
101
103
|
id: ObjectId.random(),
|
|
102
104
|
created,
|
|
103
105
|
sender,
|
|
@@ -137,6 +139,14 @@ export default defineFunction({
|
|
|
137
139
|
}).pipe(Effect.provide(FetchHttpClient.layer)),
|
|
138
140
|
});
|
|
139
141
|
|
|
142
|
+
const getUrl = (userId: string, messageId?: string, params?: Record<string, any>) => {
|
|
143
|
+
const api = new URL(
|
|
144
|
+
[`https://gmail.googleapis.com/gmail/v1/users/${userId}/messages`, messageId].filter(Boolean).join('/'),
|
|
145
|
+
);
|
|
146
|
+
Object.entries(params ?? {}).forEach(([key, value]) => api.searchParams.set(key, value));
|
|
147
|
+
return api.toString();
|
|
148
|
+
};
|
|
149
|
+
|
|
140
150
|
/**
|
|
141
151
|
* Parses an email string in the format "Name <email@example.com>" into separate name and email components.
|
|
142
152
|
*/
|
|
@@ -153,92 +163,96 @@ const parseEmailString = (emailString: string): { name?: string; email: string }
|
|
|
153
163
|
return undefined;
|
|
154
164
|
};
|
|
155
165
|
|
|
156
|
-
// TODO(wittjosiah): These schemas should be imported from @dxos/schema.
|
|
157
|
-
|
|
158
166
|
//
|
|
159
167
|
// Schemas
|
|
168
|
+
// TODO(wittjosiah): These schemas should be imported from @dxos/schema.
|
|
160
169
|
//
|
|
161
170
|
|
|
162
171
|
const ActorRoles = ['user', 'assistant'] as const;
|
|
163
|
-
const ActorRole =
|
|
164
|
-
type ActorRole =
|
|
165
|
-
|
|
166
|
-
const ActorSchema =
|
|
167
|
-
identityKey:
|
|
168
|
-
email:
|
|
169
|
-
name:
|
|
170
|
-
role:
|
|
172
|
+
const ActorRole = Schema.Literal(...ActorRoles);
|
|
173
|
+
type ActorRole = Schema.Schema.Type<typeof ActorRole>;
|
|
174
|
+
|
|
175
|
+
const ActorSchema = Schema.Struct({
|
|
176
|
+
identityKey: Schema.optional(Schema.String),
|
|
177
|
+
email: Schema.optional(Schema.String),
|
|
178
|
+
name: Schema.optional(Schema.String),
|
|
179
|
+
role: Schema.optional(ActorRole),
|
|
171
180
|
});
|
|
172
181
|
|
|
173
|
-
const AbstractContentBlock =
|
|
174
|
-
pending:
|
|
182
|
+
const AbstractContentBlock = Schema.Struct({
|
|
183
|
+
pending: Schema.optional(Schema.Boolean),
|
|
175
184
|
});
|
|
176
|
-
type AbstractContentBlock =
|
|
177
|
-
const TextContentBlock =
|
|
185
|
+
type AbstractContentBlock = Schema.Schema.Type<typeof AbstractContentBlock>;
|
|
186
|
+
const TextContentBlock = Schema.extend(
|
|
178
187
|
AbstractContentBlock,
|
|
179
|
-
|
|
180
|
-
type:
|
|
181
|
-
disposition:
|
|
182
|
-
text:
|
|
188
|
+
Schema.Struct({
|
|
189
|
+
type: Schema.Literal('text'),
|
|
190
|
+
disposition: Schema.optional(Schema.String),
|
|
191
|
+
text: Schema.String,
|
|
183
192
|
}),
|
|
184
|
-
).pipe(
|
|
185
|
-
type TextContentBlock =
|
|
186
|
-
const JsonContentBlock =
|
|
193
|
+
).pipe(Schema.mutable);
|
|
194
|
+
type TextContentBlock = Schema.Schema.Type<typeof TextContentBlock>;
|
|
195
|
+
const JsonContentBlock = Schema.extend(
|
|
187
196
|
AbstractContentBlock,
|
|
188
|
-
|
|
189
|
-
type:
|
|
190
|
-
disposition:
|
|
191
|
-
data:
|
|
197
|
+
Schema.Struct({
|
|
198
|
+
type: Schema.Literal('json'),
|
|
199
|
+
disposition: Schema.optional(Schema.String),
|
|
200
|
+
data: Schema.String,
|
|
192
201
|
}),
|
|
193
|
-
).pipe(
|
|
194
|
-
type JsonContentBlock =
|
|
195
|
-
const Base64ImageSource =
|
|
196
|
-
type:
|
|
197
|
-
mediaType:
|
|
198
|
-
data:
|
|
199
|
-
}).pipe(
|
|
200
|
-
const HttpImageSource =
|
|
201
|
-
type:
|
|
202
|
-
url:
|
|
203
|
-
}).pipe(
|
|
204
|
-
const ImageSource =
|
|
205
|
-
type ImageSource =
|
|
206
|
-
const ImageContentBlock =
|
|
202
|
+
).pipe(Schema.mutable);
|
|
203
|
+
type JsonContentBlock = Schema.Schema.Type<typeof JsonContentBlock>;
|
|
204
|
+
const Base64ImageSource = Schema.Struct({
|
|
205
|
+
type: Schema.Literal('base64'),
|
|
206
|
+
mediaType: Schema.String,
|
|
207
|
+
data: Schema.String,
|
|
208
|
+
}).pipe(Schema.mutable);
|
|
209
|
+
const HttpImageSource = Schema.Struct({
|
|
210
|
+
type: Schema.Literal('http'),
|
|
211
|
+
url: Schema.String,
|
|
212
|
+
}).pipe(Schema.mutable);
|
|
213
|
+
const ImageSource = Schema.Union(Base64ImageSource, HttpImageSource);
|
|
214
|
+
type ImageSource = Schema.Schema.Type<typeof ImageSource>;
|
|
215
|
+
const ImageContentBlock = Schema.extend(
|
|
207
216
|
AbstractContentBlock,
|
|
208
|
-
|
|
209
|
-
type:
|
|
210
|
-
id:
|
|
211
|
-
source:
|
|
217
|
+
Schema.Struct({
|
|
218
|
+
type: Schema.Literal('image'),
|
|
219
|
+
id: Schema.optional(Schema.String),
|
|
220
|
+
source: Schema.optional(ImageSource),
|
|
212
221
|
}),
|
|
213
|
-
).pipe(
|
|
214
|
-
type ImageContentBlock =
|
|
215
|
-
const ReferenceContentBlock =
|
|
222
|
+
).pipe(Schema.mutable);
|
|
223
|
+
type ImageContentBlock = Schema.Schema.Type<typeof ImageContentBlock>;
|
|
224
|
+
const ReferenceContentBlock = Schema.extend(
|
|
216
225
|
AbstractContentBlock,
|
|
217
|
-
|
|
218
|
-
type:
|
|
219
|
-
reference:
|
|
226
|
+
Schema.Struct({
|
|
227
|
+
type: Schema.Literal('reference'),
|
|
228
|
+
reference: Schema.Any,
|
|
220
229
|
}),
|
|
221
|
-
).pipe(
|
|
222
|
-
type ReferenceContentBlock =
|
|
223
|
-
const MessageContentBlock =
|
|
230
|
+
).pipe(Schema.mutable);
|
|
231
|
+
type ReferenceContentBlock = Schema.Schema.Type<typeof ReferenceContentBlock>;
|
|
232
|
+
const MessageContentBlock = Schema.Union(TextContentBlock, JsonContentBlock, ImageContentBlock, ReferenceContentBlock);
|
|
224
233
|
|
|
225
|
-
const MessageType =
|
|
234
|
+
const MessageType = Schema.Struct({
|
|
226
235
|
id: ObjectId,
|
|
227
|
-
created:
|
|
236
|
+
created: Schema.String.annotations({
|
|
228
237
|
description: 'ISO date string when the message was sent.',
|
|
229
238
|
}),
|
|
230
239
|
sender: ActorSchema.annotations({
|
|
231
240
|
description: 'Identity of the message sender.',
|
|
232
241
|
}),
|
|
233
|
-
blocks:
|
|
242
|
+
blocks: Schema.Array(MessageContentBlock).annotations({
|
|
234
243
|
description: 'Contents of the message.',
|
|
235
244
|
}),
|
|
236
|
-
properties:
|
|
237
|
-
|
|
238
|
-
|
|
245
|
+
properties: Schema.optional(
|
|
246
|
+
Schema.mutable(
|
|
247
|
+
Schema.Record({ key: Schema.String, value: Schema.Any }).annotations({
|
|
239
248
|
description: 'Custom properties for specific message types (e.g. attention context, email subject, etc.).',
|
|
240
249
|
}),
|
|
241
250
|
),
|
|
242
251
|
),
|
|
243
|
-
}).pipe(
|
|
244
|
-
|
|
252
|
+
}).pipe(
|
|
253
|
+
Type.def({
|
|
254
|
+
typename: 'dxos.org/type/Message',
|
|
255
|
+
version: '0.1.0',
|
|
256
|
+
}),
|
|
257
|
+
);
|
|
258
|
+
type MessageType = Schema.Schema.Type<typeof MessageType>;
|