@dxos/plugin-script 0.8.2-main.12df754 → 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 (181) hide show
  1. package/dist/lib/browser/{DeploymentDialog-QEKJ54ZB.mjs → DeploymentDialog-UG5U6FV3.mjs} +4 -4
  2. package/dist/lib/browser/{ScriptContainer-ATBYTIFH.mjs → ScriptContainer-DXWBDTTY.mjs} +30 -17
  3. package/dist/lib/browser/ScriptContainer-DXWBDTTY.mjs.map +7 -0
  4. package/dist/lib/browser/{artifact-definition-OEDM2SCN.mjs → artifact-definition-PD4UAAQZ.mjs} +41 -35
  5. package/dist/lib/browser/artifact-definition-PD4UAAQZ.mjs.map +7 -0
  6. package/dist/lib/browser/{chunk-EGDYE5MW.mjs → chunk-46GGDAF3.mjs} +81 -150
  7. package/dist/lib/browser/chunk-46GGDAF3.mjs.map +7 -0
  8. package/dist/lib/browser/{chunk-OZEMT3NO.mjs → chunk-6KNSDU6W.mjs} +2 -2
  9. package/dist/lib/browser/chunk-6KNSDU6W.mjs.map +7 -0
  10. package/dist/lib/browser/chunk-6MLJJI73.mjs +40 -0
  11. package/dist/lib/browser/chunk-6MLJJI73.mjs.map +7 -0
  12. package/dist/lib/browser/{chunk-SXS6PUU5.mjs → chunk-DC5K5J2I.mjs} +6 -6
  13. package/dist/lib/browser/chunk-DC5K5J2I.mjs.map +7 -0
  14. package/dist/lib/browser/chunk-GTJJTVTQ.mjs +87 -0
  15. package/dist/lib/browser/chunk-GTJJTVTQ.mjs.map +7 -0
  16. package/dist/lib/browser/{chunk-QNXJNXQZ.mjs → chunk-XA23QLKB.mjs} +6 -6
  17. package/dist/lib/browser/chunk-XA23QLKB.mjs.map +7 -0
  18. package/dist/lib/browser/index.mjs +12 -12
  19. package/dist/lib/browser/index.mjs.map +3 -3
  20. package/dist/lib/browser/{intent-resolver-C5D6TNPC.mjs → intent-resolver-R4K3E4TC.mjs} +11 -11
  21. package/dist/lib/browser/intent-resolver-R4K3E4TC.mjs.map +7 -0
  22. package/dist/lib/browser/meta.json +1 -1
  23. package/dist/lib/browser/{react-surface-XJCN7XXF.mjs → react-surface-CB57UU7H.mjs} +8 -8
  24. package/dist/lib/browser/react-surface-CB57UU7H.mjs.map +7 -0
  25. package/dist/lib/browser/{settings-NK4XVS2E.mjs → settings-EOKSUGB6.mjs} +2 -2
  26. package/dist/lib/browser/types.mjs +1 -1
  27. package/dist/lib/node/{DeploymentDialog-NUKZNILK.cjs → DeploymentDialog-AN3MHEJO.cjs} +9 -9
  28. package/dist/lib/node/{DeploymentDialog-NUKZNILK.cjs.map → DeploymentDialog-AN3MHEJO.cjs.map} +2 -2
  29. package/dist/lib/node/{ScriptContainer-OHHMLPUE.cjs → ScriptContainer-G7ZMW2Q7.cjs} +30 -19
  30. package/dist/lib/node/ScriptContainer-G7ZMW2Q7.cjs.map +7 -0
  31. package/dist/lib/node/{artifact-definition-SEGATFNH.cjs → artifact-definition-C644EAYM.cjs} +47 -41
  32. package/dist/lib/node/artifact-definition-C644EAYM.cjs.map +7 -0
  33. package/dist/lib/node/{chunk-DSFCLQ5F.cjs → chunk-3TAIWINX.cjs} +11 -11
  34. package/dist/lib/node/chunk-3TAIWINX.cjs.map +7 -0
  35. package/dist/lib/node/chunk-DGFQHBA7.cjs +91 -0
  36. package/dist/lib/node/chunk-DGFQHBA7.cjs.map +7 -0
  37. package/dist/lib/node/{chunk-ZZ4HK5KM.cjs → chunk-OWEKYL6J.cjs} +11 -11
  38. package/dist/lib/node/chunk-OWEKYL6J.cjs.map +7 -0
  39. package/dist/lib/node/{chunk-UUGLBCMY.cjs → chunk-SB2KMOBO.cjs} +85 -152
  40. package/dist/lib/node/chunk-SB2KMOBO.cjs.map +7 -0
  41. package/dist/lib/node/{chunk-PGEGRJP3.cjs → chunk-SXJGHLK6.cjs} +16 -17
  42. package/dist/lib/node/chunk-SXJGHLK6.cjs.map +7 -0
  43. package/dist/lib/node/{chunk-PMGWL64F.cjs → chunk-TEALGRAH.cjs} +6 -6
  44. package/dist/lib/node/chunk-TEALGRAH.cjs.map +7 -0
  45. package/dist/lib/node/index.cjs +24 -24
  46. package/dist/lib/node/index.cjs.map +3 -3
  47. package/dist/lib/node/{intent-resolver-BQPBRVHM.cjs → intent-resolver-CVBZQA4C.cjs} +20 -20
  48. package/dist/lib/node/intent-resolver-CVBZQA4C.cjs.map +7 -0
  49. package/dist/lib/node/meta.json +1 -1
  50. package/dist/lib/node/{react-surface-5XHS5WYW.cjs → react-surface-DX24JIJ2.cjs} +26 -26
  51. package/dist/lib/node/react-surface-DX24JIJ2.cjs.map +7 -0
  52. package/dist/lib/node/{settings-7PVJBWC4.cjs → settings-425QHVGC.cjs} +7 -7
  53. package/dist/lib/node/types.cjs +3 -3
  54. package/dist/lib/node/types.cjs.map +1 -1
  55. package/dist/lib/node-esm/{DeploymentDialog-BIXZ5Q57.mjs → DeploymentDialog-D5K6GURW.mjs} +4 -4
  56. package/dist/lib/node-esm/{ScriptContainer-4YWGWPY7.mjs → ScriptContainer-ILGGJ7Z2.mjs} +30 -17
  57. package/dist/lib/node-esm/ScriptContainer-ILGGJ7Z2.mjs.map +7 -0
  58. package/dist/lib/node-esm/{artifact-definition-5UHIXXHW.mjs → artifact-definition-J6UM6BQF.mjs} +41 -35
  59. package/dist/lib/node-esm/artifact-definition-J6UM6BQF.mjs.map +7 -0
  60. package/dist/lib/node-esm/chunk-5ES2REWL.mjs +89 -0
  61. package/dist/lib/node-esm/chunk-5ES2REWL.mjs.map +7 -0
  62. package/dist/lib/node-esm/{chunk-TN35DSTF.mjs → chunk-BHP3ROOY.mjs} +6 -6
  63. package/dist/lib/node-esm/chunk-BHP3ROOY.mjs.map +7 -0
  64. package/dist/lib/node-esm/{chunk-NNQXJQBG.mjs → chunk-OE2RF62T.mjs} +81 -150
  65. package/dist/lib/node-esm/chunk-OE2RF62T.mjs.map +7 -0
  66. package/dist/lib/node-esm/{chunk-GR4VTXVM.mjs → chunk-PYEI5U66.mjs} +2 -2
  67. package/dist/lib/node-esm/chunk-PYEI5U66.mjs.map +7 -0
  68. package/dist/lib/node-esm/{chunk-4ISQLIIH.mjs → chunk-RR3TOXE5.mjs} +6 -6
  69. package/dist/lib/node-esm/chunk-RR3TOXE5.mjs.map +7 -0
  70. package/dist/lib/node-esm/{chunk-KGYTIL33.mjs → chunk-VMQPOPKV.mjs} +12 -13
  71. package/dist/lib/node-esm/chunk-VMQPOPKV.mjs.map +7 -0
  72. package/dist/lib/node-esm/index.mjs +12 -12
  73. package/dist/lib/node-esm/index.mjs.map +3 -3
  74. package/dist/lib/node-esm/{intent-resolver-PPJKPHUQ.mjs → intent-resolver-LOA5H2J3.mjs} +11 -11
  75. package/dist/lib/node-esm/intent-resolver-LOA5H2J3.mjs.map +7 -0
  76. package/dist/lib/node-esm/meta.json +1 -1
  77. package/dist/lib/node-esm/{react-surface-7ELFL7IO.mjs → react-surface-SO4EPQE4.mjs} +8 -8
  78. package/dist/lib/node-esm/react-surface-SO4EPQE4.mjs.map +7 -0
  79. package/dist/lib/node-esm/{settings-SJYC4JLT.mjs → settings-BWSKKIVQ.mjs} +2 -2
  80. package/dist/lib/node-esm/types.mjs +1 -1
  81. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  82. package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
  83. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  84. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts +2 -2
  85. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
  86. package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
  87. package/dist/types/src/components/ScriptContainer.d.ts +1 -1
  88. package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
  89. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +1 -1
  90. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
  91. package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts +1 -1
  92. package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts.map +1 -1
  93. package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +1 -1
  94. package/dist/types/src/components/TestPanel/TestPanel.d.ts.map +1 -1
  95. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
  96. package/dist/types/src/components/index.d.ts +1 -1
  97. package/dist/types/src/hooks/deploy.d.ts +20 -17
  98. package/dist/types/src/hooks/deploy.d.ts.map +1 -1
  99. package/dist/types/src/hooks/format.d.ts +2 -5
  100. package/dist/types/src/hooks/format.d.ts.map +1 -1
  101. package/dist/types/src/hooks/index.d.ts +0 -1
  102. package/dist/types/src/hooks/index.d.ts.map +1 -1
  103. package/dist/types/src/hooks/template.d.ts +2 -5
  104. package/dist/types/src/hooks/template.d.ts.map +1 -1
  105. package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts.map +1 -1
  106. package/dist/types/src/hooks/useToolbarState.d.ts.map +1 -1
  107. package/dist/types/src/templates/chat.d.ts.map +1 -1
  108. package/dist/types/src/templates/discord.d.ts.map +1 -1
  109. package/dist/types/src/templates/echo.d.ts.map +1 -1
  110. package/dist/types/src/templates/email.d.ts.map +1 -1
  111. package/dist/types/src/templates/gmail.d.ts.map +1 -1
  112. package/dist/types/src/translations.d.ts +2 -110
  113. package/dist/types/src/translations.d.ts.map +1 -1
  114. package/dist/types/src/types.d.ts +27 -26
  115. package/dist/types/src/types.d.ts.map +1 -1
  116. package/dist/types/src/util/deploy.d.ts.map +1 -1
  117. package/dist/types/src/util/functions.d.ts.map +1 -1
  118. package/dist/types/tsconfig.tsbuildinfo +1 -1
  119. package/package.json +52 -50
  120. package/src/ScriptPlugin.tsx +3 -3
  121. package/src/capabilities/artifact-definition.ts +33 -30
  122. package/src/capabilities/intent-resolver.ts +5 -5
  123. package/src/capabilities/react-surface.tsx +3 -3
  124. package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +1 -1
  125. package/src/components/DeploymentDialog/DeploymentDialog.tsx +2 -2
  126. package/src/components/ScriptContainer.tsx +1 -1
  127. package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +1 -1
  128. package/src/components/ScriptToolbar/ScriptToolbar.tsx +16 -10
  129. package/src/components/Settings/ScriptObjectSettings.tsx +3 -3
  130. package/src/hooks/deploy.ts +60 -54
  131. package/src/hooks/format.ts +26 -26
  132. package/src/hooks/index.ts +0 -1
  133. package/src/hooks/template.ts +24 -32
  134. package/src/templates/discord.ts +10 -3
  135. package/src/templates/forex-effect.ts +1 -1
  136. package/src/templates/gmail.ts +42 -28
  137. package/src/translations.ts +1 -1
  138. package/src/types.ts +13 -14
  139. package/src/util/deploy.ts +2 -4
  140. package/dist/lib/browser/ScriptContainer-ATBYTIFH.mjs.map +0 -7
  141. package/dist/lib/browser/artifact-definition-OEDM2SCN.mjs.map +0 -7
  142. package/dist/lib/browser/chunk-EGDYE5MW.mjs.map +0 -7
  143. package/dist/lib/browser/chunk-OZEMT3NO.mjs.map +0 -7
  144. package/dist/lib/browser/chunk-QNXJNXQZ.mjs.map +0 -7
  145. package/dist/lib/browser/chunk-SXS6PUU5.mjs.map +0 -7
  146. package/dist/lib/browser/chunk-XEPVXV72.mjs +0 -87
  147. package/dist/lib/browser/chunk-XEPVXV72.mjs.map +0 -7
  148. package/dist/lib/browser/chunk-ZFTDU4WS.mjs +0 -41
  149. package/dist/lib/browser/chunk-ZFTDU4WS.mjs.map +0 -7
  150. package/dist/lib/browser/intent-resolver-C5D6TNPC.mjs.map +0 -7
  151. package/dist/lib/browser/react-surface-XJCN7XXF.mjs.map +0 -7
  152. package/dist/lib/node/ScriptContainer-OHHMLPUE.cjs.map +0 -7
  153. package/dist/lib/node/artifact-definition-SEGATFNH.cjs.map +0 -7
  154. package/dist/lib/node/chunk-4K23KEYT.cjs +0 -91
  155. package/dist/lib/node/chunk-4K23KEYT.cjs.map +0 -7
  156. package/dist/lib/node/chunk-DSFCLQ5F.cjs.map +0 -7
  157. package/dist/lib/node/chunk-PGEGRJP3.cjs.map +0 -7
  158. package/dist/lib/node/chunk-PMGWL64F.cjs.map +0 -7
  159. package/dist/lib/node/chunk-UUGLBCMY.cjs.map +0 -7
  160. package/dist/lib/node/chunk-ZZ4HK5KM.cjs.map +0 -7
  161. package/dist/lib/node/intent-resolver-BQPBRVHM.cjs.map +0 -7
  162. package/dist/lib/node/react-surface-5XHS5WYW.cjs.map +0 -7
  163. package/dist/lib/node-esm/ScriptContainer-4YWGWPY7.mjs.map +0 -7
  164. package/dist/lib/node-esm/artifact-definition-5UHIXXHW.mjs.map +0 -7
  165. package/dist/lib/node-esm/chunk-4ISQLIIH.mjs.map +0 -7
  166. package/dist/lib/node-esm/chunk-GR4VTXVM.mjs.map +0 -7
  167. package/dist/lib/node-esm/chunk-KGYTIL33.mjs.map +0 -7
  168. package/dist/lib/node-esm/chunk-NNQXJQBG.mjs.map +0 -7
  169. package/dist/lib/node-esm/chunk-TN35DSTF.mjs.map +0 -7
  170. package/dist/lib/node-esm/chunk-X64SI6XO.mjs +0 -89
  171. package/dist/lib/node-esm/chunk-X64SI6XO.mjs.map +0 -7
  172. package/dist/lib/node-esm/intent-resolver-PPJKPHUQ.mjs.map +0 -7
  173. package/dist/lib/node-esm/react-surface-7ELFL7IO.mjs.map +0 -7
  174. package/dist/types/src/hooks/useToolbarAction.d.ts +0 -13
  175. package/dist/types/src/hooks/useToolbarAction.d.ts.map +0 -1
  176. package/src/hooks/useToolbarAction.ts +0 -50
  177. /package/dist/lib/browser/{DeploymentDialog-QEKJ54ZB.mjs.map → DeploymentDialog-UG5U6FV3.mjs.map} +0 -0
  178. /package/dist/lib/browser/{settings-NK4XVS2E.mjs.map → settings-EOKSUGB6.mjs.map} +0 -0
  179. /package/dist/lib/node/{settings-7PVJBWC4.cjs.map → settings-425QHVGC.cjs.map} +0 -0
  180. /package/dist/lib/node-esm/{DeploymentDialog-BIXZ5Q57.mjs.map → DeploymentDialog-D5K6GURW.mjs.map} +0 -0
  181. /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 { ObjectId, S } from '@dxos/echo-schema';
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 { TextType } from '@dxos/schema';
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: S.Schema,
75
- outputSchema: S.Schema,
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 S;
82
+ export const Schema;
82
83
 
83
84
  // Examples:
84
85
 
85
- S.String
86
- S.Number
87
- S.Boolean
88
- S.Struct({
89
- from: S.String.annotations({ description: 'The source currency' }),
90
- to: S.String.annotations({ description: 'The target currency' }),
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
- S.Array(S.String)
93
- S.Union(S.String, S.Number)
94
- S.optional(S.String)
95
- S.String.annotations({ description: 'The source currency' })
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: S.Struct({
117
- from: S.String.annotations({ description: 'The source currency' }),
118
- to: S.String.annotations({ description: 'The target currency' }),
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: S.Struct({
122
- rate: S.String.annotations({ description: 'The exchange 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: S.Struct({
147
- name: S.String.annotations({ description: 'The name of the script' }),
148
- code: S.String.annotations({
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(TextType, {
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: S.Struct({
180
- id: ObjectId,
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: S.Struct({
199
- id: ObjectId,
200
- code: S.String.annotations({
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 { isNotNullable } from 'effect/Predicate';
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/types';
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 { TextType } from '@dxos/schema';
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(TextType, { content })),
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/types';
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 AccessTokenType } from '@dxos/schema';
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: AccessTokenType; scriptTemplates: any } } =>
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({ tooltips: true })],
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 AccessTokenType } from '@dxos/schema';
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: AccessTokenType;
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/types';
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';
@@ -24,7 +24,7 @@ export const Default = {
24
24
  const meta: Meta = {
25
25
  title: 'plugins/plugin-script/Toolbar',
26
26
  component: ScriptToolbar,
27
- decorators: [withTheme, withLayout({ tooltips: true })],
27
+ decorators: [withTheme, withLayout()],
28
28
  };
29
29
 
30
30
  export default meta;
@@ -4,19 +4,21 @@
4
4
 
5
5
  import React, { useCallback } from 'react';
6
6
 
7
- import { type ScriptType } from '@dxos/functions/types';
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
- useToolbarAction,
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: ScriptToolbarState) => {
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 handleAction = useToolbarAction({ state, script });
40
- const toolbarCreator = useCallback(() => createToolbar(state), [state]);
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} onAction={handleAction} attendableId={fullyQualifiedId(script)}>
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/types';
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 { AccessTokenType } from '@dxos/schema';
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(AccessTokenType, { source: 'github.com' }));
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
 
@@ -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,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/types';
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('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,9 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { useCallback } from 'react';
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>(`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
- };
@@ -3,7 +3,7 @@
3
3
  //
4
4
 
5
5
  // @ts-ignore
6
- import { create, EchoObject, defineFunction, DXN, Filter, ObjectId, S } from 'dxos:functions';
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: S.String,
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(EchoObject({ typename: 'example.com/type/Message', version: '0.1.0' }));
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
 
@@ -3,7 +3,7 @@
3
3
  //
4
4
 
5
5
  // @ts-ignore
6
- import { defineFunction, S } from 'dxos:functions';
6
+ import { S, defineFunction } from 'dxos:functions';
7
7
  import {
8
8
  HttpClient,
9
9
  HttpClientRequest,