@dxos/plugin-script 0.8.2-main.2f9c567 → 0.8.2-main.30e4dbb

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.
Files changed (127) hide show
  1. package/dist/lib/browser/{DeploymentDialog-EMYG5BCD.mjs → DeploymentDialog-UG5U6FV3.mjs} +3 -3
  2. package/dist/lib/browser/{ScriptContainer-YI4U25EM.mjs → ScriptContainer-DXWBDTTY.mjs} +29 -16
  3. package/dist/lib/browser/ScriptContainer-DXWBDTTY.mjs.map +7 -0
  4. package/dist/lib/browser/{chunk-FIWZUPMO.mjs → chunk-46GGDAF3.mjs} +80 -149
  5. package/dist/lib/browser/chunk-46GGDAF3.mjs.map +7 -0
  6. package/dist/lib/browser/{chunk-RIKHDIEO.mjs → chunk-6KNSDU6W.mjs} +2 -2
  7. package/dist/lib/browser/{chunk-AA3MEHWR.mjs → chunk-DC5K5J2I.mjs} +3 -4
  8. package/dist/lib/browser/chunk-DC5K5J2I.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-GTJJTVTQ.mjs +87 -0
  10. package/dist/lib/browser/chunk-GTJJTVTQ.mjs.map +7 -0
  11. package/dist/lib/browser/{chunk-4EA5VWVM.mjs → chunk-XA23QLKB.mjs} +3 -3
  12. package/dist/lib/browser/index.mjs +5 -5
  13. package/dist/lib/browser/{intent-resolver-UCPY7F6I.mjs → intent-resolver-R4K3E4TC.mjs} +5 -5
  14. package/dist/lib/browser/meta.json +1 -1
  15. package/dist/lib/browser/{react-surface-M76DWUVT.mjs → react-surface-CB57UU7H.mjs} +6 -6
  16. package/dist/lib/node/{DeploymentDialog-VWKE3X2Y.cjs → DeploymentDialog-AN3MHEJO.cjs} +8 -8
  17. package/dist/lib/node/{DeploymentDialog-VWKE3X2Y.cjs.map → DeploymentDialog-AN3MHEJO.cjs.map} +2 -2
  18. package/dist/lib/node/{ScriptContainer-2MIDQAOV.cjs → ScriptContainer-G7ZMW2Q7.cjs} +29 -18
  19. package/dist/lib/node/ScriptContainer-G7ZMW2Q7.cjs.map +7 -0
  20. package/dist/lib/node/{chunk-XT76CMHH.cjs → chunk-3TAIWINX.cjs} +6 -7
  21. package/dist/lib/node/chunk-3TAIWINX.cjs.map +7 -0
  22. package/dist/lib/node/chunk-DGFQHBA7.cjs +91 -0
  23. package/dist/lib/node/chunk-DGFQHBA7.cjs.map +7 -0
  24. package/dist/lib/node/{chunk-I4U27VO6.cjs → chunk-OWEKYL6J.cjs} +6 -6
  25. package/dist/lib/node/{chunk-FVCSTJDX.cjs → chunk-SB2KMOBO.cjs} +84 -151
  26. package/dist/lib/node/chunk-SB2KMOBO.cjs.map +7 -0
  27. package/dist/lib/node/{chunk-NBOJUJSM.cjs → chunk-TEALGRAH.cjs} +6 -6
  28. package/dist/lib/node/index.cjs +12 -12
  29. package/dist/lib/node/{intent-resolver-IO3FBKP2.cjs → intent-resolver-CVBZQA4C.cjs} +12 -12
  30. package/dist/lib/node/meta.json +1 -1
  31. package/dist/lib/node/{react-surface-AIHO75E7.cjs → react-surface-DX24JIJ2.cjs} +19 -19
  32. package/dist/lib/node-esm/{DeploymentDialog-FGFA6MG2.mjs → DeploymentDialog-D5K6GURW.mjs} +3 -3
  33. package/dist/lib/node-esm/{ScriptContainer-GYTXNQMB.mjs → ScriptContainer-ILGGJ7Z2.mjs} +29 -16
  34. package/dist/lib/node-esm/ScriptContainer-ILGGJ7Z2.mjs.map +7 -0
  35. package/dist/lib/node-esm/chunk-5ES2REWL.mjs +89 -0
  36. package/dist/lib/node-esm/chunk-5ES2REWL.mjs.map +7 -0
  37. package/dist/lib/node-esm/{chunk-X27CHZ64.mjs → chunk-BHP3ROOY.mjs} +3 -4
  38. package/dist/lib/node-esm/chunk-BHP3ROOY.mjs.map +7 -0
  39. package/dist/lib/node-esm/{chunk-3FAUXSL4.mjs → chunk-OE2RF62T.mjs} +80 -149
  40. package/dist/lib/node-esm/chunk-OE2RF62T.mjs.map +7 -0
  41. package/dist/lib/node-esm/{chunk-NERLX6GG.mjs → chunk-PYEI5U66.mjs} +2 -2
  42. package/dist/lib/node-esm/{chunk-OSDNCSBE.mjs → chunk-RR3TOXE5.mjs} +3 -3
  43. package/dist/lib/node-esm/index.mjs +5 -5
  44. package/dist/lib/node-esm/{intent-resolver-W3MJ427G.mjs → intent-resolver-LOA5H2J3.mjs} +5 -5
  45. package/dist/lib/node-esm/meta.json +1 -1
  46. package/dist/lib/node-esm/{react-surface-IAUELUG6.mjs → react-surface-SO4EPQE4.mjs} +6 -6
  47. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  48. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  49. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
  50. package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
  51. package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
  52. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
  53. package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts.map +1 -1
  54. package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +1 -1
  55. package/dist/types/src/components/TestPanel/TestPanel.d.ts.map +1 -1
  56. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
  57. package/dist/types/src/hooks/deploy.d.ts +16 -14
  58. package/dist/types/src/hooks/deploy.d.ts.map +1 -1
  59. package/dist/types/src/hooks/format.d.ts +1 -4
  60. package/dist/types/src/hooks/format.d.ts.map +1 -1
  61. package/dist/types/src/hooks/index.d.ts +0 -1
  62. package/dist/types/src/hooks/index.d.ts.map +1 -1
  63. package/dist/types/src/hooks/template.d.ts +1 -4
  64. package/dist/types/src/hooks/template.d.ts.map +1 -1
  65. package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts.map +1 -1
  66. package/dist/types/src/hooks/useToolbarState.d.ts.map +1 -1
  67. package/dist/types/src/templates/chat.d.ts.map +1 -1
  68. package/dist/types/src/templates/chess.d.ts.map +1 -1
  69. package/dist/types/src/templates/data-generator.d.ts.map +1 -1
  70. package/dist/types/src/templates/discord.d.ts.map +1 -1
  71. package/dist/types/src/templates/echo.d.ts.map +1 -1
  72. package/dist/types/src/templates/email.d.ts.map +1 -1
  73. package/dist/types/src/templates/forex-effect.d.ts.map +1 -1
  74. package/dist/types/src/templates/forex.d.ts.map +1 -1
  75. package/dist/types/src/translations.d.ts +2 -110
  76. package/dist/types/src/translations.d.ts.map +1 -1
  77. package/dist/types/src/types.d.ts.map +1 -1
  78. package/dist/types/src/util/deploy.d.ts.map +1 -1
  79. package/dist/types/src/util/functions.d.ts.map +1 -1
  80. package/dist/types/tsconfig.tsbuildinfo +1 -1
  81. package/package.json +49 -49
  82. package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +1 -1
  83. package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +1 -1
  84. package/src/components/ScriptToolbar/ScriptToolbar.tsx +15 -9
  85. package/src/hooks/deploy.ts +60 -54
  86. package/src/hooks/format.ts +25 -25
  87. package/src/hooks/index.ts +0 -1
  88. package/src/hooks/template.ts +23 -31
  89. package/src/templates/chess.ts +6 -7
  90. package/src/templates/data-generator.ts +5 -6
  91. package/src/templates/discord.ts +13 -14
  92. package/src/templates/forex-effect.ts +5 -6
  93. package/src/templates/forex.ts +4 -5
  94. package/src/templates/gmail.ts +68 -68
  95. package/src/util/deploy.ts +1 -2
  96. package/dist/lib/browser/ScriptContainer-YI4U25EM.mjs.map +0 -7
  97. package/dist/lib/browser/chunk-AA3MEHWR.mjs.map +0 -7
  98. package/dist/lib/browser/chunk-AIO76GTZ.mjs +0 -87
  99. package/dist/lib/browser/chunk-AIO76GTZ.mjs.map +0 -7
  100. package/dist/lib/browser/chunk-FIWZUPMO.mjs.map +0 -7
  101. package/dist/lib/node/ScriptContainer-2MIDQAOV.cjs.map +0 -7
  102. package/dist/lib/node/chunk-BWBZ22HH.cjs +0 -91
  103. package/dist/lib/node/chunk-BWBZ22HH.cjs.map +0 -7
  104. package/dist/lib/node/chunk-FVCSTJDX.cjs.map +0 -7
  105. package/dist/lib/node/chunk-XT76CMHH.cjs.map +0 -7
  106. package/dist/lib/node-esm/ScriptContainer-GYTXNQMB.mjs.map +0 -7
  107. package/dist/lib/node-esm/chunk-3FAUXSL4.mjs.map +0 -7
  108. package/dist/lib/node-esm/chunk-NMMN5ZIG.mjs +0 -89
  109. package/dist/lib/node-esm/chunk-NMMN5ZIG.mjs.map +0 -7
  110. package/dist/lib/node-esm/chunk-X27CHZ64.mjs.map +0 -7
  111. package/dist/types/src/hooks/useToolbarAction.d.ts +0 -13
  112. package/dist/types/src/hooks/useToolbarAction.d.ts.map +0 -1
  113. package/src/hooks/useToolbarAction.ts +0 -50
  114. /package/dist/lib/browser/{DeploymentDialog-EMYG5BCD.mjs.map → DeploymentDialog-UG5U6FV3.mjs.map} +0 -0
  115. /package/dist/lib/browser/{chunk-RIKHDIEO.mjs.map → chunk-6KNSDU6W.mjs.map} +0 -0
  116. /package/dist/lib/browser/{chunk-4EA5VWVM.mjs.map → chunk-XA23QLKB.mjs.map} +0 -0
  117. /package/dist/lib/browser/{intent-resolver-UCPY7F6I.mjs.map → intent-resolver-R4K3E4TC.mjs.map} +0 -0
  118. /package/dist/lib/browser/{react-surface-M76DWUVT.mjs.map → react-surface-CB57UU7H.mjs.map} +0 -0
  119. /package/dist/lib/node/{chunk-I4U27VO6.cjs.map → chunk-OWEKYL6J.cjs.map} +0 -0
  120. /package/dist/lib/node/{chunk-NBOJUJSM.cjs.map → chunk-TEALGRAH.cjs.map} +0 -0
  121. /package/dist/lib/node/{intent-resolver-IO3FBKP2.cjs.map → intent-resolver-CVBZQA4C.cjs.map} +0 -0
  122. /package/dist/lib/node/{react-surface-AIHO75E7.cjs.map → react-surface-DX24JIJ2.cjs.map} +0 -0
  123. /package/dist/lib/node-esm/{DeploymentDialog-FGFA6MG2.mjs.map → DeploymentDialog-D5K6GURW.mjs.map} +0 -0
  124. /package/dist/lib/node-esm/{chunk-NERLX6GG.mjs.map → chunk-PYEI5U66.mjs.map} +0 -0
  125. /package/dist/lib/node-esm/{chunk-OSDNCSBE.mjs.map → chunk-RR3TOXE5.mjs.map} +0 -0
  126. /package/dist/lib/node-esm/{intent-resolver-W3MJ427G.mjs.map → intent-resolver-LOA5H2J3.mjs.map} +0 -0
  127. /package/dist/lib/node-esm/{react-surface-IAUELUG6.mjs.map → react-surface-SO4EPQE4.mjs.map} +0 -0
@@ -2,13 +2,13 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { useCallback, useEffect, useMemo } from 'react';
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 { useTranslation } from '@dxos/react-ui';
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 const createDeploy = (state: Partial<DeployState>) => {
28
- const errorItem = createMenuAction('error', {
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>('deploy', {
36
- type: 'deploy',
37
- label: [state.deploying ? 'pending label' : 'deploy label', { ns: SCRIPT_PLUGIN }],
38
- icon: state.deploying ? 'ph--spinner-gap--regular' : 'ph--cloud-arrow-up--regular',
39
- disabled: state.deploying,
40
- classNames: state.deploying ? '[&_svg]:animate-spin' : '',
41
- });
42
-
43
- const copyAction = createMenuAction<DeployActionProperties>('copy', {
44
- type: 'copy',
45
- label: ['copy link label', { ns: SCRIPT_PLUGIN }],
46
- icon: 'ph--link--regular',
47
- disabled: !state.functionUrl,
48
- });
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]);
@@ -5,7 +5,6 @@
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
9
  import { type ScriptType } from '@dxos/functions';
11
10
  import { log } from '@dxos/log';
@@ -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('format', {
20
- label: ['format label', { ns: SCRIPT_PLUGIN }],
21
- icon: 'ph--magic-wand--regular',
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]);
@@ -7,5 +7,4 @@ export * from './format';
7
7
  export * from './template';
8
8
 
9
9
  export * from './useCreateAndDeployScriptTemplates';
10
- export * from './useToolbarAction';
11
10
  export * from './useToolbarState';
@@ -2,8 +2,6 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { useCallback } from 'react';
6
-
7
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';
@@ -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>(`template--${template.id}`, {
26
- label: template.name,
27
- value: template.id,
28
- type: 'template',
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
- };
@@ -2,26 +2,25 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
6
5
  // @ts-ignore
7
- import { defineFunction } from 'dxos:functions';
6
+ import { defineFunction, S } from 'dxos:functions';
8
7
  // @ts-ignore
9
8
  import { Chess } from 'https://esm.sh/chess.js@0.13.1';
10
9
 
11
10
  export default defineFunction({
12
11
  description: 'Plays a random move in a chess game.',
13
12
 
14
- inputSchema: Schema.Struct({
15
- changedObjectId: Schema.String.annotations({
13
+ inputSchema: S.Struct({
14
+ changedObjectId: S.String.annotations({
16
15
  description: 'The objects to play the game on.',
17
16
  }),
18
- player: Schema.optional(Schema.Literal('w', 'b')).annotations({
17
+ player: S.optional(S.Literal('w', 'b')).annotations({
19
18
  description: 'The player to play the game as.',
20
19
  }),
21
20
  }),
22
21
 
23
- outputSchema: Schema.Struct({
24
- state: Schema.String.annotations({
22
+ outputSchema: S.Struct({
23
+ state: S.String.annotations({
25
24
  description: 'The state of the game as an ASCII art board.',
26
25
  }),
27
26
  }),
@@ -2,20 +2,19 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
6
5
  // @ts-ignore
7
6
  import { defineFunction, S, create, Expando } from 'dxos:functions';
8
7
  // @ts-ignore
9
8
  import { randText } from 'https://esm.sh/@ngneat/falso@7.1.1';
10
9
 
11
10
  export default defineFunction({
12
- inputSchema: Schema.Struct({
13
- documentAmount: Schema.optional(Schema.Number),
14
- textSize: Schema.optional(Schema.Number),
15
- mutationAmount: Schema.optional(Schema.Number),
11
+ inputSchema: S.Struct({
12
+ documentAmount: S.optional(S.Number),
13
+ textSize: S.optional(S.Number),
14
+ mutationAmount: S.optional(S.Number),
16
15
  }),
17
16
 
18
- outputSchema: Schema.Struct({}),
17
+ outputSchema: S.Struct({}),
19
18
 
20
19
  handler: async ({
21
20
  event: {
@@ -2,7 +2,6 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
6
5
  // @ts-ignore
7
6
  import { create, defineFunction, DXN, Filter, ObjectId, S } from 'dxos:functions';
8
7
  import {
@@ -16,12 +15,12 @@ import { Effect, Config, Redacted, Ref } from 'https://esm.sh/effect@3.13.3';
16
15
 
17
16
  import { Type } from '@dxos/echo';
18
17
 
19
- const MessageSchema = Schema.Struct({
18
+ const MessageSchema = S.Struct({
20
19
  id: ObjectId,
21
- foreignId: Schema.Any, // bigint?
22
- from: Schema.String,
23
- created: Schema.String,
24
- content: Schema.String,
20
+ foreignId: S.Any, // bigint?
21
+ from: S.String,
22
+ created: S.String,
23
+ content: S.String,
25
24
  }).pipe(
26
25
  Type.def({
27
26
  typename: 'example.com/type/Message',
@@ -37,17 +36,17 @@ const generateSnowflake = (unixTimestamp: number): bigint => {
37
36
  };
38
37
 
39
38
  export default defineFunction({
40
- inputSchema: Schema.Struct({
39
+ inputSchema: S.Struct({
41
40
  // TODO(wittjosiah): Remove. This is used to provide a terminal for a cron trigger.
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,
41
+ tick: S.optional(S.String),
42
+ channelId: S.String,
43
+ after: S.optional(S.Number),
44
+ pageSize: S.optional(S.Number),
45
+ queueId: S.String,
47
46
  }),
48
47
 
49
- outputSchema: Schema.Struct({
50
- newMessages: Schema.Number,
48
+ outputSchema: S.Struct({
49
+ newMessages: S.Number,
51
50
  }),
52
51
 
53
52
  handler: ({
@@ -2,9 +2,8 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
6
5
  // @ts-ignore
7
- import { defineFunction } from 'dxos:functions';
6
+ import { S, defineFunction } from 'dxos:functions';
8
7
  import {
9
8
  HttpClient,
10
9
  HttpClientRequest,
@@ -17,12 +16,12 @@ import { Effect, Schedule } from 'https://esm.sh/effect@3.13.3';
17
16
  export default defineFunction({
18
17
  description: 'Returns the exchange rate between two currencies.',
19
18
 
20
- inputSchema: Schema.Struct({
21
- from: Schema.String.annotations({ description: 'The source currency' }),
22
- to: Schema.String.annotations({ description: 'The target currency' }),
19
+ inputSchema: S.Struct({
20
+ from: S.String.annotations({ description: 'The source currency' }),
21
+ to: S.String.annotations({ description: 'The target currency' }),
23
22
  }),
24
23
 
25
- outputSchema: Schema.String.annotations({ description: 'The exchange rate between the two currencies' }),
24
+ outputSchema: S.String.annotations({ description: 'The exchange rate between the two currencies' }),
26
25
 
27
26
  handler: async ({
28
27
  event: {
@@ -2,16 +2,15 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
6
5
  // @ts-ignore
7
- import { defineFunction } from 'dxos:functions';
6
+ import { defineFunction, S } from 'dxos:functions';
8
7
 
9
8
  export default defineFunction({
10
9
  description: 'Returns the exchange rate between two currencies.',
11
10
 
12
- inputSchema: Schema.Struct({
13
- from: Schema.String.annotations({ description: 'The source currency' }),
14
- to: Schema.String.annotations({ description: 'The target currency' }),
11
+ inputSchema: S.Struct({
12
+ from: S.String.annotations({ description: 'The source currency' }),
13
+ to: S.String.annotations({ description: 'The target currency' }),
15
14
  }),
16
15
 
17
16
  handler: async ({
@@ -3,7 +3,7 @@
3
3
  //
4
4
 
5
5
  // @ts-ignore
6
- import { create, defineFunction, Filter, ObjectId } from 'dxos:functions';
6
+ import { create, defineFunction, Filter, ObjectId, S } from 'dxos:functions';
7
7
  // @ts-ignore
8
8
  import {
9
9
  HttpClient,
@@ -14,24 +14,24 @@ import {
14
14
  // @ts-ignore
15
15
  import { format, subDays } from 'https://esm.sh/date-fns@3.3.1';
16
16
  // @ts-ignore
17
- import { pipe, Chunk, Effect, Ref, Schedule, Schema, Stream } from 'https://esm.sh/effect@3.13.3';
17
+ import { pipe, Chunk, Effect, Ref, Schedule, Stream } from 'https://esm.sh/effect@3.13.3';
18
18
 
19
19
  import { Type } from '@dxos/echo';
20
20
 
21
21
  export default defineFunction({
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')),
22
+ inputSchema: S.Struct({
23
+ mailboxId: S.String,
24
+ userId: S.optional(S.String).pipe(S.withDecodingDefault(() => 'me')),
25
+ after: S.optional(S.Union(S.Number, S.String)).pipe(
26
+ S.withDecodingDefault(() => format(subDays(new Date(), 30), 'yyyy-MM-dd')),
27
27
  ),
28
- pageSize: Schema.optional(Schema.Number).pipe(Schema.withDecodingDefault(() => 100)),
28
+ pageSize: S.optional(S.Number).pipe(S.withDecodingDefault(() => 100)),
29
29
  // TODO(wittjosiah): Remove. This is used to provide a terminal for a cron trigger.
30
- tick: Schema.optional(Schema.String),
30
+ tick: S.optional(S.String),
31
31
  }),
32
32
 
33
- outputSchema: Schema.Struct({
34
- newMessages: Schema.Number,
33
+ outputSchema: S.Struct({
34
+ newMessages: S.Number,
35
35
  }),
36
36
 
37
37
  handler: ({
@@ -165,86 +165,86 @@ const parseEmailString = (emailString: string): { name?: string; email: string }
165
165
 
166
166
  //
167
167
  // Schemas
168
- // TODO(wittjosiah): These schemas should be imported from @dxos/schema.
168
+ // TODO(wittjosiah): These schemas should be imported from @dxos/S.
169
169
  //
170
170
 
171
171
  const ActorRoles = ['user', 'assistant'] as const;
172
- const ActorRole = Schema.Literal(...ActorRoles);
173
- type ActorRole = Schema.Schema.Type<typeof ActorRole>;
172
+ const ActorRole = S.Literal(...ActorRoles);
173
+ type ActorRole = S.S.Type<typeof ActorRole>;
174
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),
175
+ const ActorSchema = S.Struct({
176
+ identityKey: S.optional(S.String),
177
+ email: S.optional(S.String),
178
+ name: S.optional(S.String),
179
+ role: S.optional(ActorRole),
180
180
  });
181
181
 
182
- const AbstractContentBlock = Schema.Struct({
183
- pending: Schema.optional(Schema.Boolean),
182
+ const AbstractContentBlock = S.Struct({
183
+ pending: S.optional(S.Boolean),
184
184
  });
185
- type AbstractContentBlock = Schema.Schema.Type<typeof AbstractContentBlock>;
186
- const TextContentBlock = Schema.extend(
185
+ type AbstractContentBlock = S.S.Type<typeof AbstractContentBlock>;
186
+ const TextContentBlock = S.extend(
187
187
  AbstractContentBlock,
188
- Schema.Struct({
189
- type: Schema.Literal('text'),
190
- disposition: Schema.optional(Schema.String),
191
- text: Schema.String,
188
+ S.Struct({
189
+ type: S.Literal('text'),
190
+ disposition: S.optional(S.String),
191
+ text: S.String,
192
192
  }),
193
- ).pipe(Schema.mutable);
194
- type TextContentBlock = Schema.Schema.Type<typeof TextContentBlock>;
195
- const JsonContentBlock = Schema.extend(
193
+ ).pipe(S.mutable);
194
+ type TextContentBlock = S.S.Type<typeof TextContentBlock>;
195
+ const JsonContentBlock = S.extend(
196
196
  AbstractContentBlock,
197
- Schema.Struct({
198
- type: Schema.Literal('json'),
199
- disposition: Schema.optional(Schema.String),
200
- data: Schema.String,
197
+ S.Struct({
198
+ type: S.Literal('json'),
199
+ disposition: S.optional(S.String),
200
+ data: S.String,
201
201
  }),
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(
202
+ ).pipe(S.mutable);
203
+ type JsonContentBlock = S.S.Type<typeof JsonContentBlock>;
204
+ const Base64ImageSource = S.Struct({
205
+ type: S.Literal('base64'),
206
+ mediaType: S.String,
207
+ data: S.String,
208
+ }).pipe(S.mutable);
209
+ const HttpImageSource = S.Struct({
210
+ type: S.Literal('http'),
211
+ url: S.String,
212
+ }).pipe(S.mutable);
213
+ const ImageSource = S.Union(Base64ImageSource, HttpImageSource);
214
+ type ImageSource = S.S.Type<typeof ImageSource>;
215
+ const ImageContentBlock = S.extend(
216
216
  AbstractContentBlock,
217
- Schema.Struct({
218
- type: Schema.Literal('image'),
219
- id: Schema.optional(Schema.String),
220
- source: Schema.optional(ImageSource),
217
+ S.Struct({
218
+ type: S.Literal('image'),
219
+ id: S.optional(S.String),
220
+ source: S.optional(ImageSource),
221
221
  }),
222
- ).pipe(Schema.mutable);
223
- type ImageContentBlock = Schema.Schema.Type<typeof ImageContentBlock>;
224
- const ReferenceContentBlock = Schema.extend(
222
+ ).pipe(S.mutable);
223
+ type ImageContentBlock = S.S.Type<typeof ImageContentBlock>;
224
+ const ReferenceContentBlock = S.extend(
225
225
  AbstractContentBlock,
226
- Schema.Struct({
227
- type: Schema.Literal('reference'),
228
- reference: Schema.Any,
226
+ S.Struct({
227
+ type: S.Literal('reference'),
228
+ reference: S.Any,
229
229
  }),
230
- ).pipe(Schema.mutable);
231
- type ReferenceContentBlock = Schema.Schema.Type<typeof ReferenceContentBlock>;
232
- const MessageContentBlock = Schema.Union(TextContentBlock, JsonContentBlock, ImageContentBlock, ReferenceContentBlock);
230
+ ).pipe(S.mutable);
231
+ type ReferenceContentBlock = S.S.Type<typeof ReferenceContentBlock>;
232
+ const MessageContentBlock = S.Union(TextContentBlock, JsonContentBlock, ImageContentBlock, ReferenceContentBlock);
233
233
 
234
- const MessageType = Schema.Struct({
234
+ const MessageType = S.Struct({
235
235
  id: ObjectId,
236
- created: Schema.String.annotations({
236
+ created: S.String.annotations({
237
237
  description: 'ISO date string when the message was sent.',
238
238
  }),
239
239
  sender: ActorSchema.annotations({
240
240
  description: 'Identity of the message sender.',
241
241
  }),
242
- blocks: Schema.Array(MessageContentBlock).annotations({
242
+ blocks: S.Array(MessageContentBlock).annotations({
243
243
  description: 'Contents of the message.',
244
244
  }),
245
- properties: Schema.optional(
246
- Schema.mutable(
247
- Schema.Record({ key: Schema.String, value: Schema.Any }).annotations({
245
+ properties: S.optional(
246
+ S.mutable(
247
+ S.Record({ key: S.String, value: S.Any }).annotations({
248
248
  description: 'Custom properties for specific message types (e.g. attention context, email subject, etc.).',
249
249
  }),
250
250
  ),
@@ -255,4 +255,4 @@ const MessageType = Schema.Struct({
255
255
  version: '0.1.0',
256
256
  }),
257
257
  );
258
- type MessageType = Schema.Schema.Type<typeof MessageType>;
258
+ type MessageType = S.S.Type<typeof MessageType>;
@@ -57,7 +57,6 @@ export const deployScript = async ({
57
57
 
58
58
  const { functionId, version, meta } = await uploadWorkerFunction({
59
59
  client,
60
- spaceId: space.id,
61
60
  version: fn ? incrementSemverPatch(fn.version) : '0.0.1',
62
61
  functionId: existingFunctionId,
63
62
  source: bundle,
@@ -71,7 +70,7 @@ export const deployScript = async ({
71
70
  script.changed = false;
72
71
  updateFunctionMetadata(script, storedFunction, meta, functionId);
73
72
 
74
- const functionUrl = makeFunctionUrl(space.id, { functionId });
73
+ const functionUrl = makeFunctionUrl({ functionId });
75
74
  setUserFunctionUrlInMetadata(getMeta(storedFunction), functionUrl);
76
75
 
77
76
  return { success: true, functionUrl };