@dxos/react-ui-canvas-compute 0.8.2-main.fbd8ed0 → 0.8.2-staging.7ac8446

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 (105) hide show
  1. package/dist/lib/browser/index.mjs +137 -138
  2. package/dist/lib/browser/index.mjs.map +3 -3
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +160 -161
  5. package/dist/lib/node/index.cjs.map +3 -3
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/lib/node-esm/index.mjs +137 -138
  8. package/dist/lib/node-esm/index.mjs.map +3 -3
  9. package/dist/lib/node-esm/meta.json +1 -1
  10. package/dist/types/src/components/DiagnosticOverlay.d.ts.map +1 -1
  11. package/dist/types/src/graph/controller.d.ts +17 -1
  12. package/dist/types/src/graph/controller.d.ts.map +1 -1
  13. package/dist/types/src/graph/node-defs.d.ts.map +1 -1
  14. package/dist/types/src/hooks/useComputeGraphController.d.ts.map +1 -1
  15. package/dist/types/src/hooks/useComputeNodeState.d.ts.map +1 -1
  16. package/dist/types/src/hooks/useGraphMonitor.d.ts.map +1 -1
  17. package/dist/types/src/json.test.d.ts +18 -18
  18. package/dist/types/src/json.test.d.ts.map +1 -1
  19. package/dist/types/src/shapes/Append.d.ts +19 -19
  20. package/dist/types/src/shapes/Append.d.ts.map +1 -1
  21. package/dist/types/src/shapes/Array.d.ts +19 -19
  22. package/dist/types/src/shapes/Array.d.ts.map +1 -1
  23. package/dist/types/src/shapes/Audio.d.ts +19 -19
  24. package/dist/types/src/shapes/Audio.d.ts.map +1 -1
  25. package/dist/types/src/shapes/Beacon.d.ts +19 -19
  26. package/dist/types/src/shapes/Beacon.d.ts.map +1 -1
  27. package/dist/types/src/shapes/Boolean.d.ts +70 -70
  28. package/dist/types/src/shapes/Boolean.d.ts.map +1 -1
  29. package/dist/types/src/shapes/Chat.d.ts +19 -19
  30. package/dist/types/src/shapes/Chat.d.ts.map +1 -1
  31. package/dist/types/src/shapes/Constant.d.ts +20 -20
  32. package/dist/types/src/shapes/Constant.d.ts.map +1 -1
  33. package/dist/types/src/shapes/Database.d.ts +19 -19
  34. package/dist/types/src/shapes/Database.d.ts.map +1 -1
  35. package/dist/types/src/shapes/Function.d.ts +19 -19
  36. package/dist/types/src/shapes/Function.d.ts.map +1 -1
  37. package/dist/types/src/shapes/Gpt.d.ts +19 -19
  38. package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
  39. package/dist/types/src/shapes/GptRealtime.d.ts +19 -19
  40. package/dist/types/src/shapes/GptRealtime.d.ts.map +1 -1
  41. package/dist/types/src/shapes/Json.d.ts +37 -37
  42. package/dist/types/src/shapes/Json.d.ts.map +1 -1
  43. package/dist/types/src/shapes/Logic.d.ts +37 -37
  44. package/dist/types/src/shapes/Logic.d.ts.map +1 -1
  45. package/dist/types/src/shapes/Queue.d.ts +19 -19
  46. package/dist/types/src/shapes/Queue.d.ts.map +1 -1
  47. package/dist/types/src/shapes/RNG.d.ts +21 -21
  48. package/dist/types/src/shapes/RNG.d.ts.map +1 -1
  49. package/dist/types/src/shapes/Scope.d.ts +19 -19
  50. package/dist/types/src/shapes/Scope.d.ts.map +1 -1
  51. package/dist/types/src/shapes/Surface.d.ts +19 -19
  52. package/dist/types/src/shapes/Surface.d.ts.map +1 -1
  53. package/dist/types/src/shapes/Switch.d.ts +19 -19
  54. package/dist/types/src/shapes/Switch.d.ts.map +1 -1
  55. package/dist/types/src/shapes/Table.d.ts +19 -19
  56. package/dist/types/src/shapes/Table.d.ts.map +1 -1
  57. package/dist/types/src/shapes/Template.d.ts +20 -20
  58. package/dist/types/src/shapes/Template.d.ts.map +1 -1
  59. package/dist/types/src/shapes/Text.d.ts +19 -19
  60. package/dist/types/src/shapes/Text.d.ts.map +1 -1
  61. package/dist/types/src/shapes/TextToImage.d.ts +19 -19
  62. package/dist/types/src/shapes/TextToImage.d.ts.map +1 -1
  63. package/dist/types/src/shapes/Thread.d.ts +19 -19
  64. package/dist/types/src/shapes/Thread.d.ts.map +1 -1
  65. package/dist/types/src/shapes/Trigger.d.ts +45 -47
  66. package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
  67. package/dist/types/src/shapes/common/FunctionBody.d.ts +5 -5
  68. package/dist/types/src/shapes/common/FunctionBody.d.ts.map +1 -1
  69. package/dist/types/src/shapes/common/TypeSelect.d.ts.map +1 -1
  70. package/dist/types/src/shapes/defs.d.ts +19 -18
  71. package/dist/types/src/shapes/defs.d.ts.map +1 -1
  72. package/dist/types/src/testing/circuits.d.ts.map +1 -1
  73. package/dist/types/tsconfig.tsbuildinfo +1 -1
  74. package/package.json +40 -40
  75. package/src/compute.stories.tsx +2 -2
  76. package/src/hooks/useComputeNodeState.ts +3 -3
  77. package/src/hooks/useGraphMonitor.ts +5 -3
  78. package/src/json.test.ts +10 -10
  79. package/src/schema.test.ts +7 -7
  80. package/src/shapes/Append.tsx +5 -5
  81. package/src/shapes/Array.tsx +5 -5
  82. package/src/shapes/Audio.tsx +5 -5
  83. package/src/shapes/Beacon.tsx +5 -5
  84. package/src/shapes/Boolean.tsx +5 -5
  85. package/src/shapes/Chat.tsx +5 -5
  86. package/src/shapes/Constant.tsx +6 -6
  87. package/src/shapes/Database.tsx +5 -5
  88. package/src/shapes/Function.tsx +7 -8
  89. package/src/shapes/Gpt.tsx +5 -5
  90. package/src/shapes/GptRealtime.tsx +8 -8
  91. package/src/shapes/Json.tsx +9 -9
  92. package/src/shapes/Logic.tsx +9 -9
  93. package/src/shapes/Queue.tsx +5 -5
  94. package/src/shapes/RNG.tsx +7 -7
  95. package/src/shapes/Scope.tsx +5 -5
  96. package/src/shapes/Surface.tsx +5 -5
  97. package/src/shapes/Switch.tsx +5 -5
  98. package/src/shapes/Table.tsx +6 -6
  99. package/src/shapes/Template.tsx +7 -8
  100. package/src/shapes/Text.tsx +5 -5
  101. package/src/shapes/TextToImage.tsx +5 -5
  102. package/src/shapes/Thread.tsx +6 -6
  103. package/src/shapes/Trigger.tsx +33 -32
  104. package/src/shapes/common/FunctionBody.tsx +9 -11
  105. package/src/shapes/defs.ts +9 -9
@@ -2,10 +2,10 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
6
5
  import React from 'react';
7
6
 
8
7
  import { IfElseInput, IfElseOutput, IfInput, IfOutput } from '@dxos/conductor';
8
+ import { S } from '@dxos/echo-schema';
9
9
  import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
10
10
 
11
11
  import { createFunctionAnchors, FunctionBody, getHeight } from './common';
@@ -15,23 +15,23 @@ import { ComputeShape, createShape, type CreateShapeProps } from './defs';
15
15
  // Data
16
16
  //
17
17
 
18
- export const IfShape = Schema.extend(
18
+ export const IfShape = S.extend(
19
19
  ComputeShape,
20
- Schema.Struct({
21
- type: Schema.Literal('if'),
20
+ S.Struct({
21
+ type: S.Literal('if'),
22
22
  }),
23
23
  );
24
24
 
25
- export type IfShape = Schema.Schema.Type<typeof IfShape>;
25
+ export type IfShape = S.Schema.Type<typeof IfShape>;
26
26
 
27
- export const IfElseShape = Schema.extend(
27
+ export const IfElseShape = S.extend(
28
28
  ComputeShape,
29
- Schema.Struct({
30
- type: Schema.Literal('if-else'),
29
+ S.Struct({
30
+ type: S.Literal('if-else'),
31
31
  }),
32
32
  );
33
33
 
34
- export type IfElseShape = Schema.Schema.Type<typeof IfElseShape>;
34
+ export type IfElseShape = S.Schema.Type<typeof IfElseShape>;
35
35
 
36
36
  //
37
37
  // Components
@@ -2,10 +2,10 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
6
5
  import React, { Fragment } from 'react';
7
6
 
8
7
  import { DEFAULT_OUTPUT, QueueInput, QueueOutput } from '@dxos/conductor';
8
+ import { S } from '@dxos/echo-schema';
9
9
  import { type ThemedClassName } from '@dxos/react-ui';
10
10
  import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
11
11
  import { mx } from '@dxos/react-ui-theme';
@@ -15,14 +15,14 @@ import { Box, type BoxActionHandler } from './common';
15
15
  import { ComputeShape, createShape, type CreateShapeProps } from './defs';
16
16
  import { useComputeNodeState } from '../hooks';
17
17
 
18
- export const QueueShape = Schema.extend(
18
+ export const QueueShape = S.extend(
19
19
  ComputeShape,
20
- Schema.Struct({
21
- type: Schema.Literal('queue'),
20
+ S.Struct({
21
+ type: S.Literal('queue'),
22
22
  }),
23
23
  );
24
24
 
25
- export type QueueShape = Schema.Schema.Type<typeof QueueShape>;
25
+ export type QueueShape = S.Schema.Type<typeof QueueShape>;
26
26
 
27
27
  export type CreateQueueProps = CreateShapeProps<QueueShape>;
28
28
 
@@ -2,10 +2,10 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
6
5
  import React, { useEffect, useState } from 'react';
7
6
 
8
7
  import { DEFAULT_OUTPUT } from '@dxos/conductor';
8
+ import { S } from '@dxos/echo-schema';
9
9
  import { Icon, type IconProps } from '@dxos/react-ui';
10
10
  import { createAnchorMap, type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
11
11
  import { mx } from '@dxos/react-ui-theme';
@@ -13,16 +13,16 @@ import { mx } from '@dxos/react-ui-theme';
13
13
  import { ComputeShape, createAnchorId, createShape, type CreateShapeProps } from './defs';
14
14
  import { useComputeNodeState } from '../hooks';
15
15
 
16
- export const RandomShape = Schema.extend(
16
+ export const RandomShape = S.extend(
17
17
  ComputeShape,
18
- Schema.Struct({
19
- type: Schema.Literal('rng'),
20
- min: Schema.optional(Schema.Number),
21
- max: Schema.optional(Schema.Number),
18
+ S.Struct({
19
+ type: S.Literal('rng'),
20
+ min: S.optional(S.Number),
21
+ max: S.optional(S.Number),
22
22
  }),
23
23
  );
24
24
 
25
- export type RandomShape = Schema.Schema.Type<typeof RandomShape>;
25
+ export type RandomShape = S.Schema.Type<typeof RandomShape>;
26
26
 
27
27
  export type CreateRandomProps = CreateShapeProps<RandomShape>;
28
28
 
@@ -2,24 +2,24 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
6
5
  import React from 'react';
7
6
 
8
7
  import { DEFAULT_INPUT } from '@dxos/conductor';
8
+ import { S } from '@dxos/echo-schema';
9
9
  import { createAnchorMap, type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
10
10
  import { useAudioStream, Chaos, shaderPresets } from '@dxos/react-ui-sfx';
11
11
 
12
12
  import { ComputeShape, createAnchorId, createShape, type CreateShapeProps } from './defs';
13
13
  import { useComputeNodeState } from '../hooks';
14
14
 
15
- export const ScopeShape = Schema.extend(
15
+ export const ScopeShape = S.extend(
16
16
  ComputeShape,
17
- Schema.Struct({
18
- type: Schema.Literal('scope'),
17
+ S.Struct({
18
+ type: S.Literal('scope'),
19
19
  }),
20
20
  );
21
21
 
22
- export type ScopeShape = Schema.Schema.Type<typeof ScopeShape>;
22
+ export type ScopeShape = S.Schema.Type<typeof ScopeShape>;
23
23
 
24
24
  export type CreateScopeProps = CreateShapeProps<ScopeShape>;
25
25
 
@@ -2,11 +2,11 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
6
5
  import React from 'react';
7
6
 
8
7
  import { Surface } from '@dxos/app-framework';
9
8
  import { DEFAULT_INPUT } from '@dxos/conductor';
9
+ import { S } from '@dxos/echo-schema';
10
10
  import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
11
11
  import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
12
12
 
@@ -14,14 +14,14 @@ import { Box, type BoxActionHandler } from './common';
14
14
  import { ComputeShape, createAnchorId, createShape, type CreateShapeProps } from './defs';
15
15
  import { useComputeNodeState } from '../hooks';
16
16
 
17
- export const SurfaceShape = Schema.extend(
17
+ export const SurfaceShape = S.extend(
18
18
  ComputeShape,
19
- Schema.Struct({
20
- type: Schema.Literal('surface'),
19
+ S.Struct({
20
+ type: S.Literal('surface'),
21
21
  }),
22
22
  );
23
23
 
24
- export type SurfaceShape = Schema.Schema.Type<typeof SurfaceShape>;
24
+ export type SurfaceShape = S.Schema.Type<typeof SurfaceShape>;
25
25
 
26
26
  export type CreateSurfaceProps = CreateShapeProps<SurfaceShape>;
27
27
 
@@ -2,24 +2,24 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
6
5
  import React, { useEffect, useState } from 'react';
7
6
 
8
7
  import { DEFAULT_OUTPUT } from '@dxos/conductor';
8
+ import { S } from '@dxos/echo-schema';
9
9
  import { Input } from '@dxos/react-ui';
10
10
  import { createAnchorMap, type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
11
11
 
12
12
  import { ComputeShape, createAnchorId, createShape, type CreateShapeProps } from './defs';
13
13
  import { useComputeNodeState } from '../hooks';
14
14
 
15
- export const SwitchShape = Schema.extend(
15
+ export const SwitchShape = S.extend(
16
16
  ComputeShape,
17
- Schema.Struct({
18
- type: Schema.Literal('switch'),
17
+ S.Struct({
18
+ type: S.Literal('switch'),
19
19
  }),
20
20
  );
21
21
 
22
- export type SwitchShape = Schema.Schema.Type<typeof SwitchShape>;
22
+ export type SwitchShape = S.Schema.Type<typeof SwitchShape>;
23
23
 
24
24
  export type CreateSwitchProps = CreateShapeProps<SwitchShape>;
25
25
 
@@ -2,26 +2,26 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
6
5
  import React from 'react';
7
6
 
8
7
  import { createInputSchema, createOutputSchema, GptMessage } from '@dxos/conductor';
8
+ import { S } from '@dxos/echo-schema';
9
9
  import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
10
10
 
11
11
  import { createFunctionAnchors, Box } from './common';
12
12
  import { ComputeShape, createShape, type CreateShapeProps } from './defs';
13
13
 
14
14
  const InputSchema = createInputSchema(GptMessage);
15
- const OutputSchema = createOutputSchema(Schema.mutable(Schema.Array(GptMessage)));
15
+ const OutputSchema = createOutputSchema(S.mutable(S.Array(GptMessage)));
16
16
 
17
- export const TableShape = Schema.extend(
17
+ export const TableShape = S.extend(
18
18
  ComputeShape,
19
- Schema.Struct({
20
- type: Schema.Literal('table'),
19
+ S.Struct({
20
+ type: S.Literal('table'),
21
21
  }),
22
22
  );
23
23
 
24
- export type TableShape = Schema.Schema.Type<typeof TableShape>;
24
+ export type TableShape = S.Schema.Type<typeof TableShape>;
25
25
 
26
26
  export type CreateTableProps = CreateShapeProps<TableShape>;
27
27
 
@@ -2,11 +2,10 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
6
5
  import React, { useRef } from 'react';
7
6
 
8
7
  import { ComputeValueType, getTemplateInputSchema, TemplateOutput, VoidInput } from '@dxos/conductor';
9
- import { toJsonSchema } from '@dxos/echo-schema';
8
+ import { S, toJsonSchema } from '@dxos/echo-schema';
10
9
  import { invariant } from '@dxos/invariant';
11
10
  import {
12
11
  type ShapeComponentProps,
@@ -24,15 +23,15 @@ import { useComputeNodeState } from '../hooks';
24
23
  // Data
25
24
  //
26
25
 
27
- export const TemplateShape = Schema.extend(
26
+ export const TemplateShape = S.extend(
28
27
  ComputeShape,
29
- Schema.Struct({
30
- type: Schema.Literal('template'),
31
- valueType: Schema.optional(ComputeValueType),
28
+ S.Struct({
29
+ type: S.Literal('template'),
30
+ valueType: S.optional(ComputeValueType),
32
31
  }),
33
32
  );
34
33
 
35
- export type TemplateShape = Schema.Schema.Type<typeof TemplateShape>;
34
+ export type TemplateShape = S.Schema.Type<typeof TemplateShape>;
36
35
 
37
36
  //
38
37
  // Component
@@ -55,7 +54,7 @@ const TextInputComponent = ({ shape, title, ...props }: TextInputComponentProps)
55
54
  };
56
55
 
57
56
  const handleTypeChange = (newType: string) => {
58
- invariant(Schema.is(ComputeValueType)(newType), 'Invalid type');
57
+ invariant(S.is(ComputeValueType)(newType), 'Invalid type');
59
58
 
60
59
  node.valueType = newType;
61
60
  node.inputSchema = toJsonSchema(getTemplateInputSchema(node));
@@ -2,10 +2,10 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
6
5
  import React from 'react';
7
6
 
8
7
  import { DEFAULT_INPUT } from '@dxos/conductor';
8
+ import { S } from '@dxos/echo-schema';
9
9
  import { TextBox, type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
10
10
  import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
11
11
 
@@ -13,14 +13,14 @@ import { Box, type BoxActionHandler } from './common';
13
13
  import { ComputeShape, createAnchorId, createShape, type CreateShapeProps } from './defs';
14
14
  import { useComputeNodeState } from '../hooks';
15
15
 
16
- export const TextShape = Schema.extend(
16
+ export const TextShape = S.extend(
17
17
  ComputeShape,
18
- Schema.Struct({
19
- type: Schema.Literal('text'),
18
+ S.Struct({
19
+ type: S.Literal('text'),
20
20
  }),
21
21
  );
22
22
 
23
- export type TextShape = Schema.Schema.Type<typeof TextShape>;
23
+ export type TextShape = S.Schema.Type<typeof TextShape>;
24
24
 
25
25
  export type CreateTextProps = CreateShapeProps<TextShape>;
26
26
 
@@ -2,23 +2,23 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
6
5
  import React from 'react';
7
6
 
7
+ import { S } from '@dxos/echo-schema';
8
8
  import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
9
9
  import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
10
10
 
11
11
  import { Box } from './common';
12
12
  import { ComputeShape, createAnchorId, createShape, type CreateShapeProps } from './defs';
13
13
 
14
- export const TextToImageShape = Schema.extend(
14
+ export const TextToImageShape = S.extend(
15
15
  ComputeShape,
16
- Schema.Struct({
17
- type: Schema.Literal('text-to-image'),
16
+ S.Struct({
17
+ type: S.Literal('text-to-image'),
18
18
  }),
19
19
  );
20
20
 
21
- export type TextToImageShape = Schema.Schema.Type<typeof TextToImageShape>;
21
+ export type TextToImageShape = S.Schema.Type<typeof TextToImageShape>;
22
22
 
23
23
  export type CreateTextToImageProps = CreateShapeProps<TextToImageShape>;
24
24
 
@@ -2,10 +2,10 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
6
5
  import React, { useEffect, useRef } from 'react';
7
6
 
8
7
  import { createInputSchema, createOutputSchema, GptMessage } from '@dxos/conductor';
8
+ import { S } from '@dxos/echo-schema';
9
9
  import { type ThemedClassName } from '@dxos/react-ui';
10
10
  import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
11
11
  import { mx } from '@dxos/react-ui-theme';
@@ -14,16 +14,16 @@ import { createFunctionAnchors, Box } from './common';
14
14
  import { ComputeShape, createShape, type CreateShapeProps } from './defs';
15
15
 
16
16
  const InputSchema = createInputSchema(GptMessage);
17
- const OutputSchema = createOutputSchema(Schema.mutable(Schema.Array(GptMessage)));
17
+ const OutputSchema = createOutputSchema(S.mutable(S.Array(GptMessage)));
18
18
 
19
- export const ThreadShape = Schema.extend(
19
+ export const ThreadShape = S.extend(
20
20
  ComputeShape,
21
- Schema.Struct({
22
- type: Schema.Literal('thread'),
21
+ S.Struct({
22
+ type: S.Literal('thread'),
23
23
  }),
24
24
  );
25
25
 
26
- export type ThreadShape = Schema.Schema.Type<typeof ThreadShape>;
26
+ export type ThreadShape = S.Schema.Type<typeof ThreadShape>;
27
27
 
28
28
  export type CreateThreadProps = CreateShapeProps<ThreadShape>;
29
29
 
@@ -2,11 +2,17 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { Schema } from 'effect';
6
5
  import React, { useEffect } from 'react';
7
6
 
8
- import { VoidInput } from '@dxos/conductor';
9
- import { ObjectId, Ref } from '@dxos/echo-schema';
7
+ import {
8
+ EmailTriggerOutput,
9
+ QueueTriggerOutput,
10
+ SubscriptionTriggerOutput,
11
+ TimerTriggerOutput,
12
+ VoidInput,
13
+ WebhookTriggerOutput,
14
+ } from '@dxos/conductor';
15
+ import { ObjectId, Ref, S } from '@dxos/echo-schema';
10
16
  import {
11
17
  type EmailTrigger,
12
18
  FunctionTrigger,
@@ -16,28 +22,23 @@ import {
16
22
  TriggerKind,
17
23
  type TriggerType,
18
24
  type WebhookTrigger,
19
- EmailTriggerOutput,
20
- QueueTriggerOutput,
21
- SubscriptionTriggerOutput,
22
- TimerTriggerOutput,
23
- WebhookTriggerOutput,
24
- } from '@dxos/functions';
25
+ } from '@dxos/functions/types';
25
26
  import { DXN, SpaceId } from '@dxos/keys';
26
- import { live, makeRef, useSpace } from '@dxos/react-client/echo';
27
+ import { create, makeRef, useSpace } from '@dxos/react-client/echo';
27
28
  import { Select, type SelectRootProps } from '@dxos/react-ui';
28
29
  import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
29
30
 
30
31
  import { createFunctionAnchors, FunctionBody, getHeight } from './common';
31
32
  import { ComputeShape, createShape, type CreateShapeProps } from './defs';
32
33
 
33
- export const TriggerShape = Schema.extend(
34
+ export const TriggerShape = S.extend(
34
35
  ComputeShape,
35
- Schema.Struct({
36
- type: Schema.Literal('trigger'),
37
- functionTrigger: Schema.optional(Ref(FunctionTrigger)),
36
+ S.Struct({
37
+ type: S.Literal('trigger'),
38
+ functionTrigger: S.optional(Ref(FunctionTrigger)),
38
39
  }),
39
40
  );
40
- export type TriggerShape = Schema.Schema.Type<typeof TriggerShape>;
41
+ export type TriggerShape = S.Schema.Type<typeof TriggerShape>;
41
42
 
42
43
  export type CreateTriggerProps = CreateShapeProps<Omit<TriggerShape, 'functionTrigger'>> & {
43
44
  spaceId?: SpaceId;
@@ -45,7 +46,7 @@ export type CreateTriggerProps = CreateShapeProps<Omit<TriggerShape, 'functionTr
45
46
  };
46
47
 
47
48
  export const createTrigger = (props: CreateTriggerProps): TriggerShape => {
48
- const functionTrigger = live(FunctionTrigger, {
49
+ const functionTrigger = create(FunctionTrigger, {
49
50
  enabled: true,
50
51
  spec: createTriggerSpec(props),
51
52
  });
@@ -70,12 +71,12 @@ export const TriggerComponent = ({ shape }: TriggerComponentProps) => {
70
71
  }, [functionTrigger, functionTrigger?.spec]);
71
72
 
72
73
  useEffect(() => {
73
- shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ?? TriggerKind.Email));
74
- }, [functionTrigger?.spec?.kind]);
74
+ shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.type ?? TriggerKind.Email));
75
+ }, [functionTrigger?.spec?.type]);
75
76
 
76
77
  const setKind = (kind: TriggerKind) => {
77
- if (functionTrigger?.spec?.kind !== kind) {
78
- functionTrigger!.spec = createTriggerSpec({ triggerKind: kind, spaceId: space?.id });
78
+ if (functionTrigger?.spec?.type !== kind) {
79
+ functionTrigger!.spec = createTriggerSpec({ triggerKind: TriggerKind.Email, spaceId: space?.id });
79
80
  }
80
81
  };
81
82
 
@@ -87,10 +88,10 @@ export const TriggerComponent = ({ shape }: TriggerComponentProps) => {
87
88
  <FunctionBody
88
89
  shape={shape}
89
90
  status={
90
- <TriggerKindSelect value={functionTrigger.spec?.kind} onValueChange={(kind) => setKind(kind as TriggerKind)} />
91
+ <TriggerKindSelect value={functionTrigger.spec?.type} onValueChange={(kind) => setKind(kind as TriggerKind)} />
91
92
  }
92
93
  inputSchema={VoidInput}
93
- outputSchema={getOutputSchema(functionTrigger.spec!.kind!)}
94
+ outputSchema={getOutputSchema(functionTrigger.spec!.type!)}
94
95
  />
95
96
  );
96
97
  };
@@ -104,9 +105,9 @@ const TriggerKindSelect = ({ value, onValueChange }: Pick<SelectRootProps, 'valu
104
105
  <Select.Content>
105
106
  <Select.ScrollUpButton />
106
107
  <Select.Viewport>
107
- {Object.values(TriggerKind).map((kind) => (
108
- <Select.Option key={kind} value={kind}>
109
- {kind}
108
+ {Object.values(TriggerKind).map((type) => (
109
+ <Select.Option key={type} value={type}>
110
+ {type}
110
111
  </Select.Option>
111
112
  ))}
112
113
  </Select.Viewport>
@@ -122,22 +123,22 @@ const createTriggerSpec = (props: { triggerKind?: TriggerKind; spaceId?: SpaceId
122
123
  const kind = props.triggerKind ?? TriggerKind.Email;
123
124
  switch (kind) {
124
125
  case TriggerKind.Timer:
125
- return { kind: TriggerKind.Timer, cron: '*/10 * * * * *' } satisfies TimerTrigger;
126
+ return { type: TriggerKind.Timer, cron: '*/10 * * * * *' } satisfies TimerTrigger;
126
127
  case TriggerKind.Webhook:
127
- return { kind: TriggerKind.Webhook, method: 'POST' } satisfies WebhookTrigger;
128
+ return { type: TriggerKind.Webhook, method: 'POST' } satisfies WebhookTrigger;
128
129
  case TriggerKind.Subscription:
129
- return { kind: TriggerKind.Subscription, filter: {} } satisfies SubscriptionTrigger;
130
+ return { type: TriggerKind.Subscription, filter: {} } satisfies SubscriptionTrigger;
130
131
  case TriggerKind.Email:
131
- return { kind: TriggerKind.Email } satisfies EmailTrigger;
132
+ return { type: TriggerKind.Email } satisfies EmailTrigger;
132
133
  case TriggerKind.Queue: {
133
134
  const dxn = new DXN(DXN.kind.QUEUE, ['data', props.spaceId ?? SpaceId.random(), ObjectId.random()]).toString();
134
- return { kind: TriggerKind.Queue, queue: dxn } satisfies QueueTrigger;
135
+ return { type: TriggerKind.Queue, queue: dxn } satisfies QueueTrigger;
135
136
  }
136
137
  }
137
138
  };
138
139
 
139
140
  const getOutputSchema = (kind: TriggerKind) => {
140
- const kindToSchema: Record<TriggerKind, Schema.Schema<any>> = {
141
+ const kindToSchema: Record<TriggerKind, S.Schema<any>> = {
141
142
  [TriggerKind.Email]: EmailTriggerOutput,
142
143
  [TriggerKind.Subscription]: SubscriptionTriggerOutput,
143
144
  [TriggerKind.Timer]: TimerTriggerOutput,
@@ -157,6 +158,6 @@ export const triggerShape: ShapeDef<TriggerShape> = {
157
158
  createFunctionAnchors(
158
159
  shape,
159
160
  VoidInput,
160
- getOutputSchema(shape.functionTrigger?.target?.spec?.kind ?? TriggerKind.Email),
161
+ getOutputSchema(shape.functionTrigger?.target?.spec?.type ?? TriggerKind.Email),
161
162
  ),
162
163
  };
@@ -2,10 +2,10 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { type Schema, SchemaAST } from 'effect';
6
5
  import React, { type JSX, useRef, useState } from 'react';
7
6
 
8
7
  import { VoidInput, VoidOutput } from '@dxos/conductor';
8
+ import { AST, type S } from '@dxos/echo-schema';
9
9
  import { useCanvasContext } from '@dxos/react-ui-canvas';
10
10
  import { type Polygon, type Shape } from '@dxos/react-ui-canvas-editor';
11
11
  import { getParentShapeElement, createAnchors, rowHeight } from '@dxos/react-ui-canvas-editor';
@@ -20,8 +20,8 @@ export type FunctionBodyProps = {
20
20
  shape: Shape;
21
21
  name?: string;
22
22
  content?: JSX.Element;
23
- inputSchema?: Schema.Schema.Any;
24
- outputSchema?: Schema.Schema.Any;
23
+ inputSchema?: S.Schema.Any;
24
+ outputSchema?: S.Schema.Any;
25
25
  } & Pick<BoxProps, 'status'>;
26
26
 
27
27
  // TODO(wittjosiah): Rename, not used for functions.
@@ -106,20 +106,18 @@ export const FunctionBody = ({
106
106
  );
107
107
  };
108
108
 
109
- export const getHeight = (input: Schema.Schema<any>) => {
110
- const properties = SchemaAST.getPropertySignatures(input.ast);
109
+ export const getHeight = (input: S.Schema<any>) => {
110
+ const properties = AST.getPropertySignatures(input.ast);
111
111
  return headerHeight + footerHeight + bodyPadding * 2 + properties.length * rowHeight + 2; // Incl. borders.
112
112
  };
113
113
 
114
114
  export const createFunctionAnchors = (
115
115
  shape: Polygon,
116
- input: Schema.Schema<any> = VoidInput,
117
- output: Schema.Schema<any> = VoidOutput,
116
+ input: S.Schema<any> = VoidInput,
117
+ output: S.Schema<any> = VoidOutput,
118
118
  ) => {
119
119
  // TODO(burdon): Set type.
120
- const inputs = SchemaAST.getPropertySignatures(input.ast).map(({ name }) => createAnchorId('input', name.toString()));
121
- const outputs = SchemaAST.getPropertySignatures(output.ast).map(({ name }) =>
122
- createAnchorId('output', name.toString()),
123
- );
120
+ const inputs = AST.getPropertySignatures(input.ast).map(({ name }) => createAnchorId('input', name.toString()));
121
+ const outputs = AST.getPropertySignatures(output.ast).map(({ name }) => createAnchorId('output', name.toString()));
124
122
  return createAnchors({ shape, inputs, outputs, center: { x: 0, y: (headerHeight - footerHeight) / 2 + 1 } });
125
123
  };
@@ -2,10 +2,10 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { Schema, SchemaAST } from 'effect';
5
+ import { SchemaAST as AST } from 'effect';
6
6
 
7
7
  import { DEFAULT_INPUT, DEFAULT_OUTPUT } from '@dxos/conductor';
8
- import { ObjectId } from '@dxos/echo-schema';
8
+ import { ObjectId, S } from '@dxos/echo-schema';
9
9
  import { Polygon } from '@dxos/react-ui-canvas-editor';
10
10
  import { type MakeOptional } from '@dxos/util';
11
11
 
@@ -15,8 +15,8 @@ import { type MakeOptional } from '@dxos/util';
15
15
 
16
16
  export type PropertyKind = 'input' | 'output';
17
17
 
18
- export const getProperties = (ast: SchemaAST.AST) =>
19
- SchemaAST.getPropertySignatures(ast).map(({ name }) => ({ name: name.toString() }));
18
+ export const getProperties = (ast: AST.AST) =>
19
+ AST.getPropertySignatures(ast).map(({ name }) => ({ name: name.toString() }));
20
20
 
21
21
  export const createAnchorId = (kind: PropertyKind, property = kind === 'input' ? DEFAULT_INPUT : DEFAULT_OUTPUT) =>
22
22
  [kind, property].join('.');
@@ -32,15 +32,15 @@ export const parseAnchorId = (id: string): [PropertyKind | undefined, string] =>
32
32
 
33
33
  export type CreateShapeProps<S extends Polygon> = Omit<MakeOptional<S, 'id' | 'size'>, 'type' | 'node'>;
34
34
 
35
- export const ComputeShape = Schema.extend(
35
+ export const ComputeShape = S.extend(
36
36
  Polygon,
37
- Schema.Struct({
37
+ S.Struct({
38
38
  // TODO(burdon): Rename computeNode?
39
- node: Schema.optional(ObjectId.annotations({ [SchemaAST.DescriptionAnnotationId]: 'Compute node id' })),
40
- }).pipe(Schema.mutable),
39
+ node: S.optional(ObjectId.annotations({ [AST.DescriptionAnnotationId]: 'Compute node id' })),
40
+ }).pipe(S.mutable),
41
41
  );
42
42
 
43
- export type ComputeShape = Schema.Schema.Type<typeof ComputeShape>;
43
+ export type ComputeShape = S.Schema.Type<typeof ComputeShape>;
44
44
 
45
45
  export const createShape = <S extends ComputeShape>({ id, ...rest }: CreateShapeProps<S> & { type: string }): S => {
46
46
  return {