@dxos/react-ui-canvas-compute 0.8.4-main.67995b8 → 0.8.4-main.ae835ea
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +195 -169
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +195 -169
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/compute.stories.d.ts +12 -5
- package/dist/types/src/compute.stories.d.ts.map +1 -1
- package/dist/types/src/graph/controller.d.ts +9 -22
- package/dist/types/src/graph/controller.d.ts.map +1 -1
- package/dist/types/src/graph/node-defs.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeGraphController.d.ts +2 -2
- package/dist/types/src/hooks/useComputeGraphController.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeNodeState.d.ts +1 -1
- package/dist/types/src/hooks/useComputeNodeState.d.ts.map +1 -1
- package/dist/types/src/hooks/useGraphMonitor.d.ts +1 -1
- package/dist/types/src/hooks/useGraphMonitor.d.ts.map +1 -1
- package/dist/types/src/json.test.d.ts +1 -1
- package/dist/types/src/json.test.d.ts.map +1 -1
- package/dist/types/src/shapes/Append.d.ts +1 -1
- package/dist/types/src/shapes/Append.d.ts.map +1 -1
- package/dist/types/src/shapes/Array.d.ts +1 -1
- package/dist/types/src/shapes/Array.d.ts.map +1 -1
- package/dist/types/src/shapes/Audio.d.ts +1 -1
- package/dist/types/src/shapes/Audio.d.ts.map +1 -1
- package/dist/types/src/shapes/Beacon.d.ts +1 -1
- package/dist/types/src/shapes/Beacon.d.ts.map +1 -1
- package/dist/types/src/shapes/Boolean.d.ts +1 -1
- package/dist/types/src/shapes/Boolean.d.ts.map +1 -1
- package/dist/types/src/shapes/Chat.d.ts +1 -1
- package/dist/types/src/shapes/Chat.d.ts.map +1 -1
- package/dist/types/src/shapes/Constant.d.ts +1 -1
- package/dist/types/src/shapes/Constant.d.ts.map +1 -1
- package/dist/types/src/shapes/Database.d.ts +1 -1
- package/dist/types/src/shapes/Database.d.ts.map +1 -1
- package/dist/types/src/shapes/Function.d.ts +1 -1
- package/dist/types/src/shapes/Function.d.ts.map +1 -1
- package/dist/types/src/shapes/Gpt.d.ts +1 -1
- package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
- package/dist/types/src/shapes/GptRealtime.d.ts +1 -1
- package/dist/types/src/shapes/GptRealtime.d.ts.map +1 -1
- package/dist/types/src/shapes/Json.d.ts +1 -1
- package/dist/types/src/shapes/Json.d.ts.map +1 -1
- package/dist/types/src/shapes/Logic.d.ts +1 -1
- package/dist/types/src/shapes/Logic.d.ts.map +1 -1
- package/dist/types/src/shapes/Queue.d.ts +1 -1
- package/dist/types/src/shapes/Queue.d.ts.map +1 -1
- package/dist/types/src/shapes/RNG.d.ts +1 -1
- package/dist/types/src/shapes/RNG.d.ts.map +1 -1
- package/dist/types/src/shapes/Scope.d.ts +1 -1
- package/dist/types/src/shapes/Scope.d.ts.map +1 -1
- package/dist/types/src/shapes/Surface.d.ts +1 -1
- package/dist/types/src/shapes/Surface.d.ts.map +1 -1
- package/dist/types/src/shapes/Switch.d.ts +1 -1
- package/dist/types/src/shapes/Switch.d.ts.map +1 -1
- package/dist/types/src/shapes/Table.d.ts +1 -1
- package/dist/types/src/shapes/Table.d.ts.map +1 -1
- package/dist/types/src/shapes/Template.d.ts +1 -1
- package/dist/types/src/shapes/Template.d.ts.map +1 -1
- package/dist/types/src/shapes/Text.d.ts +1 -1
- package/dist/types/src/shapes/Text.d.ts.map +1 -1
- package/dist/types/src/shapes/TextToImage.d.ts +1 -1
- package/dist/types/src/shapes/TextToImage.d.ts.map +1 -1
- package/dist/types/src/shapes/Thread.d.ts +1 -1
- package/dist/types/src/shapes/Thread.d.ts.map +1 -1
- package/dist/types/src/shapes/Trigger.d.ts +4 -33
- package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
- package/dist/types/src/shapes/common/Box.d.ts.map +1 -1
- package/dist/types/src/shapes/common/FunctionBody.d.ts +1 -1
- package/dist/types/src/shapes/common/FunctionBody.d.ts.map +1 -1
- package/dist/types/src/shapes/defs.d.ts +2 -1
- package/dist/types/src/shapes/defs.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +52 -51
- package/src/compute-layout.ts +1 -1
- package/src/compute.stories.tsx +15 -14
- package/src/graph/controller.ts +18 -6
- package/src/graph/node-defs.ts +4 -4
- package/src/hooks/useComputeGraphController.ts +2 -2
- package/src/hooks/useComputeNodeState.ts +4 -3
- package/src/hooks/useGraphMonitor.ts +2 -2
- package/src/json.test.ts +1 -1
- package/src/registry.ts +2 -2
- package/src/schema.test.ts +4 -4
- package/src/shapes/Append.tsx +3 -3
- package/src/shapes/Array.tsx +3 -3
- package/src/shapes/Audio.tsx +4 -3
- package/src/shapes/Beacon.tsx +4 -3
- package/src/shapes/Boolean.tsx +3 -3
- package/src/shapes/Chat.tsx +4 -3
- package/src/shapes/Constant.tsx +4 -3
- package/src/shapes/Database.tsx +2 -2
- package/src/shapes/Function.tsx +10 -9
- package/src/shapes/Gpt.tsx +7 -5
- package/src/shapes/GptRealtime.tsx +2 -2
- package/src/shapes/Json.tsx +4 -3
- package/src/shapes/Logic.tsx +3 -3
- package/src/shapes/Queue.tsx +4 -3
- package/src/shapes/RNG.tsx +4 -3
- package/src/shapes/Scope.tsx +5 -4
- package/src/shapes/Surface.tsx +4 -3
- package/src/shapes/Switch.tsx +4 -3
- package/src/shapes/Table.tsx +3 -3
- package/src/shapes/Template.tsx +6 -5
- package/src/shapes/Text.tsx +5 -4
- package/src/shapes/TextToImage.tsx +2 -2
- package/src/shapes/Thread.tsx +3 -3
- package/src/shapes/Trigger.tsx +41 -53
- package/src/shapes/common/Box.tsx +1 -1
- package/src/shapes/common/FunctionBody.tsx +3 -2
- package/src/shapes/defs.ts +3 -2
- package/src/testing/circuits.ts +1 -1
package/src/shapes/Gpt.tsx
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { useEffect, useState } from 'react';
|
|
7
7
|
|
|
8
|
-
import { type GenerationStreamEvent } from '@dxos/ai';
|
|
9
8
|
import { GptInput, GptOutput } from '@dxos/conductor';
|
|
10
9
|
import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
11
10
|
|
|
12
|
-
import { createFunctionAnchors, FunctionBody, getHeight } from './common';
|
|
13
|
-
import { ComputeShape, createShape, type CreateShapeProps } from './defs';
|
|
14
11
|
import { useComputeNodeState } from '../hooks';
|
|
15
12
|
|
|
13
|
+
import { FunctionBody, createFunctionAnchors, getHeight } from './common';
|
|
14
|
+
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
15
|
+
|
|
16
16
|
export const GptShape = Schema.extend(
|
|
17
17
|
ComputeShape,
|
|
18
18
|
Schema.Struct({
|
|
@@ -43,8 +43,10 @@ export const GptComponent = ({ shape }: ShapeComponentProps<GptShape>) => {
|
|
|
43
43
|
setText('');
|
|
44
44
|
break;
|
|
45
45
|
}
|
|
46
|
+
|
|
46
47
|
case 'custom': {
|
|
47
|
-
|
|
48
|
+
// TODO(burdon): Any?
|
|
49
|
+
const token = ev.event;
|
|
48
50
|
switch (token.type) {
|
|
49
51
|
case 'content_block_delta':
|
|
50
52
|
switch (token.delta.type) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import { log } from '@dxos/log';
|
|
@@ -11,7 +11,7 @@ import { Icon } from '@dxos/react-ui';
|
|
|
11
11
|
import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
12
12
|
|
|
13
13
|
import { createFunctionAnchors } from './common';
|
|
14
|
-
import { ComputeShape,
|
|
14
|
+
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
15
15
|
|
|
16
16
|
export const GptRealtimeShape = Schema.extend(
|
|
17
17
|
ComputeShape,
|
package/src/shapes/Json.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
8
|
import { DEFAULT_INPUT, DefaultOutput, JsonTransformInput } from '@dxos/conductor';
|
|
@@ -10,10 +10,11 @@ import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-e
|
|
|
10
10
|
import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
11
11
|
import { JsonFilter } from '@dxos/react-ui-syntax-highlighter';
|
|
12
12
|
|
|
13
|
-
import { createFunctionAnchors, getHeight, Box } from './common';
|
|
14
|
-
import { ComputeShape, createAnchorId, createShape, type CreateShapeProps } from './defs';
|
|
15
13
|
import { useComputeNodeState } from '../hooks';
|
|
16
14
|
|
|
15
|
+
import { Box, createFunctionAnchors, getHeight } from './common';
|
|
16
|
+
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
17
|
+
|
|
17
18
|
//
|
|
18
19
|
// Data
|
|
19
20
|
//
|
package/src/shapes/Logic.tsx
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
8
|
import { IfElseInput, IfElseOutput, IfInput, IfOutput } from '@dxos/conductor';
|
|
9
9
|
import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
10
10
|
|
|
11
|
-
import {
|
|
12
|
-
import { ComputeShape,
|
|
11
|
+
import { FunctionBody, createFunctionAnchors, getHeight } from './common';
|
|
12
|
+
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
13
13
|
|
|
14
14
|
//
|
|
15
15
|
// Data
|
package/src/shapes/Queue.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { Fragment } from 'react';
|
|
7
7
|
|
|
8
8
|
import { DEFAULT_OUTPUT, QueueInput, QueueOutput } from '@dxos/conductor';
|
|
@@ -10,10 +10,11 @@ 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';
|
|
12
12
|
|
|
13
|
+
import { useComputeNodeState } from '../hooks';
|
|
14
|
+
|
|
13
15
|
import { createFunctionAnchors } from './common';
|
|
14
16
|
import { Box, type BoxActionHandler } from './common';
|
|
15
|
-
import { ComputeShape,
|
|
16
|
-
import { useComputeNodeState } from '../hooks';
|
|
17
|
+
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
17
18
|
|
|
18
19
|
export const QueueShape = Schema.extend(
|
|
19
20
|
ComputeShape,
|
package/src/shapes/RNG.tsx
CHANGED
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { useEffect, useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import { DEFAULT_OUTPUT } from '@dxos/conductor';
|
|
9
9
|
import { Icon, type IconProps } from '@dxos/react-ui';
|
|
10
|
-
import {
|
|
10
|
+
import { type ShapeComponentProps, type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
11
11
|
|
|
12
|
-
import { ComputeShape, createAnchorId, createShape, type CreateShapeProps } from './defs';
|
|
13
12
|
import { useComputeNodeState } from '../hooks';
|
|
14
13
|
|
|
14
|
+
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
15
|
+
|
|
15
16
|
export const RandomShape = Schema.extend(
|
|
16
17
|
ComputeShape,
|
|
17
18
|
Schema.Struct({
|
package/src/shapes/Scope.tsx
CHANGED
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
8
|
import { DEFAULT_INPUT } from '@dxos/conductor';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { type ShapeComponentProps, type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
10
|
+
import { Chaos, shaderPresets, useAudioStream } from '@dxos/react-ui-sfx';
|
|
11
11
|
|
|
12
|
-
import { ComputeShape, createAnchorId, createShape, type CreateShapeProps } from './defs';
|
|
13
12
|
import { useComputeNodeState } from '../hooks';
|
|
14
13
|
|
|
14
|
+
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
15
|
+
|
|
15
16
|
export const ScopeShape = Schema.extend(
|
|
16
17
|
ComputeShape,
|
|
17
18
|
Schema.Struct({
|
package/src/shapes/Surface.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
8
|
import { Surface } from '@dxos/app-framework';
|
|
@@ -10,10 +10,11 @@ import { DEFAULT_INPUT } from '@dxos/conductor';
|
|
|
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
|
|
|
13
|
-
import { Box, type BoxActionHandler } from './common';
|
|
14
|
-
import { ComputeShape, createAnchorId, createShape, type CreateShapeProps } from './defs';
|
|
15
13
|
import { useComputeNodeState } from '../hooks';
|
|
16
14
|
|
|
15
|
+
import { Box, type BoxActionHandler } from './common';
|
|
16
|
+
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
17
|
+
|
|
17
18
|
export const SurfaceShape = Schema.extend(
|
|
18
19
|
ComputeShape,
|
|
19
20
|
Schema.Struct({
|
package/src/shapes/Switch.tsx
CHANGED
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { useEffect, useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import { DEFAULT_OUTPUT } from '@dxos/conductor';
|
|
9
9
|
import { Input } from '@dxos/react-ui';
|
|
10
|
-
import {
|
|
10
|
+
import { type ShapeComponentProps, type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
11
11
|
|
|
12
|
-
import { ComputeShape, createAnchorId, createShape, type CreateShapeProps } from './defs';
|
|
13
12
|
import { useComputeNodeState } from '../hooks';
|
|
14
13
|
|
|
14
|
+
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
15
|
+
|
|
15
16
|
export const SwitchShape = Schema.extend(
|
|
16
17
|
ComputeShape,
|
|
17
18
|
Schema.Struct({
|
package/src/shapes/Table.tsx
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
8
|
import { createInputSchema, createOutputSchema } from '@dxos/conductor';
|
|
9
9
|
import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
10
10
|
import { DataType } from '@dxos/schema';
|
|
11
11
|
|
|
12
|
-
import {
|
|
13
|
-
import { ComputeShape,
|
|
12
|
+
import { Box, createFunctionAnchors } from './common';
|
|
13
|
+
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
14
14
|
|
|
15
15
|
const InputSchema = createInputSchema(DataType.Message);
|
|
16
16
|
const OutputSchema = createOutputSchema(Schema.mutable(Schema.Array(DataType.Message)));
|
package/src/shapes/Template.tsx
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { useRef } from 'react';
|
|
7
7
|
|
|
8
|
-
import { ComputeValueType,
|
|
9
|
-
import { toJsonSchema } from '@dxos/echo
|
|
8
|
+
import { ComputeValueType, TemplateOutput, VoidInput, getTemplateInputSchema } from '@dxos/conductor';
|
|
9
|
+
import { toJsonSchema } from '@dxos/echo/internal';
|
|
10
10
|
import { invariant } from '@dxos/invariant';
|
|
11
11
|
import {
|
|
12
12
|
type ShapeComponentProps,
|
|
@@ -16,10 +16,11 @@ import {
|
|
|
16
16
|
type TextBoxProps,
|
|
17
17
|
} from '@dxos/react-ui-canvas-editor';
|
|
18
18
|
|
|
19
|
-
import { Box, createFunctionAnchors, TypeSelect } from './common';
|
|
20
|
-
import { ComputeShape, createShape, type CreateShapeProps } from './defs';
|
|
21
19
|
import { useComputeNodeState } from '../hooks';
|
|
22
20
|
|
|
21
|
+
import { Box, TypeSelect, createFunctionAnchors } from './common';
|
|
22
|
+
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
23
|
+
|
|
23
24
|
//
|
|
24
25
|
// Data
|
|
25
26
|
//
|
package/src/shapes/Text.tsx
CHANGED
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
8
|
import { DEFAULT_INPUT } from '@dxos/conductor';
|
|
9
|
-
import {
|
|
9
|
+
import { type ShapeComponentProps, type ShapeDef, TextBox } from '@dxos/react-ui-canvas-editor';
|
|
10
10
|
import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
11
11
|
|
|
12
|
-
import { Box, type BoxActionHandler } from './common';
|
|
13
|
-
import { ComputeShape, createAnchorId, createShape, type CreateShapeProps } from './defs';
|
|
14
12
|
import { useComputeNodeState } from '../hooks';
|
|
15
13
|
|
|
14
|
+
import { Box, type BoxActionHandler } from './common';
|
|
15
|
+
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
16
|
+
|
|
16
17
|
export const TextShape = Schema.extend(
|
|
17
18
|
ComputeShape,
|
|
18
19
|
Schema.Struct({
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
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
|
-
import { ComputeShape, createAnchorId, createShape
|
|
12
|
+
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
13
13
|
|
|
14
14
|
export const TextToImageShape = Schema.extend(
|
|
15
15
|
ComputeShape,
|
package/src/shapes/Thread.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { useEffect, useRef } from 'react';
|
|
7
7
|
|
|
8
8
|
import { createInputSchema, createOutputSchema } from '@dxos/conductor';
|
|
@@ -11,8 +11,8 @@ import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-e
|
|
|
11
11
|
import { mx } from '@dxos/react-ui-theme';
|
|
12
12
|
import { DataType } from '@dxos/schema';
|
|
13
13
|
|
|
14
|
-
import {
|
|
15
|
-
import { ComputeShape,
|
|
14
|
+
import { Box, createFunctionAnchors } from './common';
|
|
15
|
+
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
16
16
|
|
|
17
17
|
const InputSchema = createInputSchema(DataType.Message);
|
|
18
18
|
const OutputSchema = createOutputSchema(Schema.mutable(Schema.Array(DataType.Message)));
|
package/src/shapes/Trigger.tsx
CHANGED
|
@@ -2,57 +2,44 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { useEffect } from 'react';
|
|
7
7
|
|
|
8
8
|
import { VoidInput } from '@dxos/conductor';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
EmailTriggerOutput,
|
|
13
|
-
FunctionTrigger,
|
|
14
|
-
type QueueTrigger,
|
|
15
|
-
QueueTriggerOutput,
|
|
16
|
-
type SubscriptionTrigger,
|
|
17
|
-
type TimerTrigger,
|
|
18
|
-
TriggerKind,
|
|
19
|
-
type TriggerType,
|
|
20
|
-
SubscriptionTriggerOutput,
|
|
21
|
-
TimerTriggerOutput,
|
|
22
|
-
type WebhookTrigger,
|
|
23
|
-
WebhookTriggerOutput,
|
|
24
|
-
} from '@dxos/functions';
|
|
9
|
+
import { Filter, Query } from '@dxos/echo';
|
|
10
|
+
import { ObjectId, Ref } from '@dxos/echo/internal';
|
|
11
|
+
import { Trigger, TriggerEvent } from '@dxos/functions';
|
|
25
12
|
import { DXN, SpaceId } from '@dxos/keys';
|
|
26
|
-
import {
|
|
13
|
+
import { useSpace } from '@dxos/react-client/echo';
|
|
27
14
|
import { Select, type SelectRootProps } from '@dxos/react-ui';
|
|
28
15
|
import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
29
16
|
|
|
30
|
-
import {
|
|
31
|
-
import { ComputeShape,
|
|
17
|
+
import { FunctionBody, createFunctionAnchors, getHeight } from './common';
|
|
18
|
+
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
32
19
|
|
|
33
20
|
export const TriggerShape = Schema.extend(
|
|
34
21
|
ComputeShape,
|
|
35
22
|
Schema.Struct({
|
|
36
23
|
type: Schema.Literal('trigger'),
|
|
37
|
-
functionTrigger: Schema.optional(Ref(
|
|
24
|
+
functionTrigger: Schema.optional(Ref(Trigger.Trigger)),
|
|
38
25
|
}),
|
|
39
26
|
);
|
|
40
27
|
export type TriggerShape = Schema.Schema.Type<typeof TriggerShape>;
|
|
41
28
|
|
|
42
29
|
export type CreateTriggerProps = CreateShapeProps<Omit<TriggerShape, 'functionTrigger'>> & {
|
|
43
30
|
spaceId?: SpaceId;
|
|
44
|
-
triggerKind?:
|
|
31
|
+
triggerKind?: Trigger.Kind;
|
|
45
32
|
};
|
|
46
33
|
|
|
47
34
|
export const createTrigger = (props: CreateTriggerProps): TriggerShape => {
|
|
48
|
-
const functionTrigger =
|
|
35
|
+
const functionTrigger = Trigger.make({
|
|
49
36
|
enabled: true,
|
|
50
37
|
spec: createTriggerSpec(props),
|
|
51
38
|
});
|
|
52
39
|
return createShape<TriggerShape>({
|
|
53
40
|
type: 'trigger',
|
|
54
41
|
functionTrigger: Ref.make(functionTrigger),
|
|
55
|
-
size: { width: 192, height: getHeight(
|
|
42
|
+
size: { width: 192, height: getHeight(TriggerEvent.EmailEvent) },
|
|
56
43
|
...props,
|
|
57
44
|
});
|
|
58
45
|
};
|
|
@@ -65,15 +52,15 @@ export const TriggerComponent = ({ shape }: TriggerComponentProps) => {
|
|
|
65
52
|
|
|
66
53
|
useEffect(() => {
|
|
67
54
|
if (functionTrigger && !functionTrigger.spec) {
|
|
68
|
-
functionTrigger.spec = createTriggerSpec({ triggerKind:
|
|
55
|
+
functionTrigger.spec = createTriggerSpec({ triggerKind: 'email', spaceId: space?.id });
|
|
69
56
|
}
|
|
70
57
|
}, [functionTrigger, functionTrigger?.spec]);
|
|
71
58
|
|
|
72
59
|
useEffect(() => {
|
|
73
|
-
shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ??
|
|
60
|
+
shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ?? 'email'));
|
|
74
61
|
}, [functionTrigger?.spec?.kind]);
|
|
75
62
|
|
|
76
|
-
const setKind = (kind:
|
|
63
|
+
const setKind = (kind: Trigger.Kind) => {
|
|
77
64
|
if (functionTrigger?.spec?.kind !== kind) {
|
|
78
65
|
functionTrigger!.spec = createTriggerSpec({ triggerKind: kind, spaceId: space?.id });
|
|
79
66
|
}
|
|
@@ -87,7 +74,7 @@ export const TriggerComponent = ({ shape }: TriggerComponentProps) => {
|
|
|
87
74
|
<FunctionBody
|
|
88
75
|
shape={shape}
|
|
89
76
|
status={
|
|
90
|
-
<TriggerKindSelect value={functionTrigger.spec?.kind} onValueChange={(kind) => setKind(kind as
|
|
77
|
+
<TriggerKindSelect value={functionTrigger.spec?.kind} onValueChange={(kind) => setKind(kind as Trigger.Kind)} />
|
|
91
78
|
}
|
|
92
79
|
inputSchema={VoidInput}
|
|
93
80
|
outputSchema={getOutputSchema(functionTrigger.spec!.kind!)}
|
|
@@ -104,7 +91,7 @@ const TriggerKindSelect = ({ value, onValueChange }: Pick<SelectRootProps, 'valu
|
|
|
104
91
|
<Select.Content>
|
|
105
92
|
<Select.ScrollUpButton />
|
|
106
93
|
<Select.Viewport>
|
|
107
|
-
{
|
|
94
|
+
{Trigger.Kinds.map((kind) => (
|
|
108
95
|
<Select.Option key={kind} value={kind}>
|
|
109
96
|
{kind}
|
|
110
97
|
</Select.Option>
|
|
@@ -118,31 +105,36 @@ const TriggerKindSelect = ({ value, onValueChange }: Pick<SelectRootProps, 'valu
|
|
|
118
105
|
);
|
|
119
106
|
};
|
|
120
107
|
|
|
121
|
-
const createTriggerSpec = (props: { triggerKind?:
|
|
122
|
-
const kind = props.triggerKind ??
|
|
108
|
+
const createTriggerSpec = (props: { triggerKind?: Trigger.Kind; spaceId?: SpaceId }): Trigger.Spec => {
|
|
109
|
+
const kind = props.triggerKind ?? 'email';
|
|
123
110
|
switch (kind) {
|
|
124
|
-
case
|
|
125
|
-
return { kind:
|
|
126
|
-
case
|
|
127
|
-
return { kind:
|
|
128
|
-
case
|
|
129
|
-
return {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
111
|
+
case 'timer':
|
|
112
|
+
return { kind: 'timer', cron: '*/10 * * * * *' } satisfies Trigger.TimerSpec;
|
|
113
|
+
case 'webhook':
|
|
114
|
+
return { kind: 'webhook', method: 'POST' } satisfies Trigger.WebhookSpec;
|
|
115
|
+
case 'subscription':
|
|
116
|
+
return {
|
|
117
|
+
kind: 'subscription',
|
|
118
|
+
query: {
|
|
119
|
+
ast: Query.select(Filter.nothing()).ast,
|
|
120
|
+
},
|
|
121
|
+
} satisfies Trigger.SubscriptionSpec;
|
|
122
|
+
case 'email':
|
|
123
|
+
return { kind: 'email' } satisfies Trigger.EmailSpec;
|
|
124
|
+
case 'queue': {
|
|
133
125
|
const dxn = new DXN(DXN.kind.QUEUE, ['data', props.spaceId ?? SpaceId.random(), ObjectId.random()]).toString();
|
|
134
|
-
return { kind:
|
|
126
|
+
return { kind: 'queue', queue: dxn } satisfies Trigger.QueueSpec;
|
|
135
127
|
}
|
|
136
128
|
}
|
|
137
129
|
};
|
|
138
130
|
|
|
139
|
-
const getOutputSchema = (kind:
|
|
140
|
-
const kindToSchema: Record<
|
|
141
|
-
[
|
|
142
|
-
[
|
|
143
|
-
[
|
|
144
|
-
[
|
|
145
|
-
[
|
|
131
|
+
const getOutputSchema = (kind: Trigger.Kind) => {
|
|
132
|
+
const kindToSchema: Record<Trigger.Kind, Schema.Schema<any>> = {
|
|
133
|
+
['email']: TriggerEvent.EmailEvent,
|
|
134
|
+
['subscription']: TriggerEvent.SubscriptionEvent,
|
|
135
|
+
['timer']: TriggerEvent.TimerEvent,
|
|
136
|
+
['webhook']: TriggerEvent.WebhookEvent,
|
|
137
|
+
['queue']: TriggerEvent.QueueEvent,
|
|
146
138
|
};
|
|
147
139
|
return kindToSchema[kind];
|
|
148
140
|
};
|
|
@@ -154,9 +146,5 @@ export const triggerShape: ShapeDef<TriggerShape> = {
|
|
|
154
146
|
component: TriggerComponent,
|
|
155
147
|
createShape: createTrigger,
|
|
156
148
|
getAnchors: (shape) =>
|
|
157
|
-
createFunctionAnchors(
|
|
158
|
-
shape,
|
|
159
|
-
VoidInput,
|
|
160
|
-
getOutputSchema(shape.functionTrigger?.target?.spec?.kind ?? TriggerKind.Email),
|
|
161
|
-
),
|
|
149
|
+
createFunctionAnchors(shape, VoidInput, getOutputSchema(shape.functionTrigger?.target?.spec?.kind ?? 'email')),
|
|
162
150
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, {
|
|
5
|
+
import React, { type PropsWithChildren, type ReactNode, forwardRef } from 'react';
|
|
6
6
|
|
|
7
7
|
import { invariant } from '@dxos/invariant';
|
|
8
8
|
import { Icon, IconButton, type ThemedClassName } from '@dxos/react-ui';
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import type * as Schema from 'effect/Schema';
|
|
6
|
+
import * as SchemaAST from 'effect/SchemaAST';
|
|
6
7
|
import React, { type JSX, useRef, useState } from 'react';
|
|
7
8
|
|
|
8
9
|
import { VoidInput, VoidOutput } from '@dxos/conductor';
|
|
9
10
|
import { useCanvasContext } from '@dxos/react-ui-canvas';
|
|
10
11
|
import { type Polygon, type Shape } from '@dxos/react-ui-canvas-editor';
|
|
11
|
-
import {
|
|
12
|
+
import { createAnchors, getParentShapeElement, rowHeight } from '@dxos/react-ui-canvas-editor';
|
|
12
13
|
|
|
13
14
|
import { Box, type BoxProps, footerHeight, headerHeight } from '../common';
|
|
14
15
|
import { createAnchorId, getProperties } from '../defs';
|
package/src/shapes/defs.ts
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
import * as SchemaAST from 'effect/SchemaAST';
|
|
6
7
|
|
|
7
8
|
import { DEFAULT_INPUT, DEFAULT_OUTPUT } from '@dxos/conductor';
|
|
8
|
-
import { ObjectId } from '@dxos/echo
|
|
9
|
+
import { ObjectId } from '@dxos/echo/internal';
|
|
9
10
|
import { Polygon } from '@dxos/react-ui-canvas-editor';
|
|
10
11
|
import { type MakeOptional } from '@dxos/util';
|
|
11
12
|
|
package/src/testing/circuits.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { createSystemPrompt } from '@dxos/assistant';
|
|
6
|
-
import { ObjectId } from '@dxos/echo
|
|
6
|
+
import { ObjectId } from '@dxos/echo/internal';
|
|
7
7
|
import { type ServiceContainer } from '@dxos/functions';
|
|
8
8
|
import { DXN, SpaceId } from '@dxos/keys';
|
|
9
9
|
import { type Dimension, type Point } from '@dxos/react-ui-canvas';
|