@dxos/react-ui-canvas-compute 0.8.4-main.67995b8 → 0.8.4-main.a4bbb77
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 +178 -140
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +178 -140
- 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 +4 -4
- 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/shapes/Append.d.ts.map +1 -1
- package/dist/types/src/shapes/Array.d.ts.map +1 -1
- package/dist/types/src/shapes/Audio.d.ts.map +1 -1
- package/dist/types/src/shapes/Beacon.d.ts.map +1 -1
- package/dist/types/src/shapes/Boolean.d.ts.map +1 -1
- package/dist/types/src/shapes/Chat.d.ts.map +1 -1
- package/dist/types/src/shapes/Constant.d.ts.map +1 -1
- package/dist/types/src/shapes/Database.d.ts.map +1 -1
- package/dist/types/src/shapes/Function.d.ts.map +1 -1
- package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
- package/dist/types/src/shapes/GptRealtime.d.ts.map +1 -1
- package/dist/types/src/shapes/Json.d.ts.map +1 -1
- package/dist/types/src/shapes/Logic.d.ts.map +1 -1
- package/dist/types/src/shapes/Queue.d.ts.map +1 -1
- package/dist/types/src/shapes/RNG.d.ts.map +1 -1
- package/dist/types/src/shapes/Scope.d.ts.map +1 -1
- package/dist/types/src/shapes/Surface.d.ts.map +1 -1
- package/dist/types/src/shapes/Switch.d.ts.map +1 -1
- package/dist/types/src/shapes/Table.d.ts.map +1 -1
- package/dist/types/src/shapes/Template.d.ts.map +1 -1
- package/dist/types/src/shapes/Text.d.ts.map +1 -1
- package/dist/types/src/shapes/TextToImage.d.ts.map +1 -1
- package/dist/types/src/shapes/Thread.d.ts.map +1 -1
- package/dist/types/src/shapes/Trigger.d.ts +2 -31
- 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/tsconfig.tsbuildinfo +1 -1
- package/package.json +53 -51
- package/src/compute.stories.tsx +13 -12
- package/src/graph/controller.ts +5 -4
- package/src/graph/node-defs.ts +3 -3
- package/src/hooks/useComputeGraphController.ts +2 -2
- package/src/hooks/useComputeNodeState.ts +3 -2
- package/src/hooks/useGraphMonitor.ts +1 -1
- package/src/registry.ts +2 -2
- package/src/schema.test.ts +2 -2
- package/src/shapes/Append.tsx +2 -2
- package/src/shapes/Array.tsx +2 -2
- package/src/shapes/Audio.tsx +3 -2
- package/src/shapes/Beacon.tsx +3 -2
- package/src/shapes/Boolean.tsx +2 -2
- package/src/shapes/Chat.tsx +3 -2
- package/src/shapes/Constant.tsx +3 -2
- package/src/shapes/Database.tsx +1 -1
- package/src/shapes/Function.tsx +6 -5
- package/src/shapes/Gpt.tsx +6 -4
- package/src/shapes/GptRealtime.tsx +1 -1
- package/src/shapes/Json.tsx +3 -2
- package/src/shapes/Logic.tsx +2 -2
- package/src/shapes/Queue.tsx +3 -2
- package/src/shapes/RNG.tsx +3 -2
- package/src/shapes/Scope.tsx +4 -3
- package/src/shapes/Surface.tsx +3 -2
- package/src/shapes/Switch.tsx +3 -2
- package/src/shapes/Table.tsx +2 -2
- package/src/shapes/Template.tsx +4 -3
- package/src/shapes/Text.tsx +4 -3
- package/src/shapes/TextToImage.tsx +1 -1
- package/src/shapes/Thread.tsx +2 -2
- package/src/shapes/Trigger.tsx +29 -31
- package/src/shapes/common/Box.tsx +1 -1
- package/src/shapes/common/FunctionBody.tsx +1 -1
package/src/shapes/Switch.tsx
CHANGED
|
@@ -7,11 +7,12 @@ 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
|
@@ -9,8 +9,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
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { Schema } from 'effect';
|
|
6
6
|
import React, { useRef } from 'react';
|
|
7
7
|
|
|
8
|
-
import { ComputeValueType,
|
|
8
|
+
import { ComputeValueType, TemplateOutput, VoidInput, getTemplateInputSchema } from '@dxos/conductor';
|
|
9
9
|
import { toJsonSchema } from '@dxos/echo-schema';
|
|
10
10
|
import { invariant } from '@dxos/invariant';
|
|
11
11
|
import {
|
|
@@ -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
|
@@ -6,13 +6,14 @@ import { Schema } from 'effect';
|
|
|
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({
|
|
@@ -9,7 +9,7 @@ import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-e
|
|
|
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
|
@@ -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
|
@@ -6,6 +6,7 @@ import { Schema } from 'effect';
|
|
|
6
6
|
import React, { useEffect } from 'react';
|
|
7
7
|
|
|
8
8
|
import { VoidInput } from '@dxos/conductor';
|
|
9
|
+
import { Filter, Obj, Query } from '@dxos/echo';
|
|
9
10
|
import { ObjectId, Ref } from '@dxos/echo-schema';
|
|
10
11
|
import {
|
|
11
12
|
type EmailTrigger,
|
|
@@ -14,21 +15,22 @@ import {
|
|
|
14
15
|
type QueueTrigger,
|
|
15
16
|
QueueTriggerOutput,
|
|
16
17
|
type SubscriptionTrigger,
|
|
17
|
-
type TimerTrigger,
|
|
18
|
-
TriggerKind,
|
|
19
|
-
type TriggerType,
|
|
20
18
|
SubscriptionTriggerOutput,
|
|
19
|
+
type TimerTrigger,
|
|
21
20
|
TimerTriggerOutput,
|
|
21
|
+
type TriggerKind,
|
|
22
|
+
TriggerKinds,
|
|
23
|
+
type TriggerType,
|
|
22
24
|
type WebhookTrigger,
|
|
23
25
|
WebhookTriggerOutput,
|
|
24
26
|
} from '@dxos/functions';
|
|
25
27
|
import { DXN, SpaceId } from '@dxos/keys';
|
|
26
|
-
import {
|
|
28
|
+
import { useSpace } from '@dxos/react-client/echo';
|
|
27
29
|
import { Select, type SelectRootProps } from '@dxos/react-ui';
|
|
28
30
|
import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
29
31
|
|
|
30
|
-
import {
|
|
31
|
-
import { ComputeShape,
|
|
32
|
+
import { FunctionBody, createFunctionAnchors, getHeight } from './common';
|
|
33
|
+
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
32
34
|
|
|
33
35
|
export const TriggerShape = Schema.extend(
|
|
34
36
|
ComputeShape,
|
|
@@ -45,7 +47,7 @@ export type CreateTriggerProps = CreateShapeProps<Omit<TriggerShape, 'functionTr
|
|
|
45
47
|
};
|
|
46
48
|
|
|
47
49
|
export const createTrigger = (props: CreateTriggerProps): TriggerShape => {
|
|
48
|
-
const functionTrigger =
|
|
50
|
+
const functionTrigger = Obj.make(FunctionTrigger, {
|
|
49
51
|
enabled: true,
|
|
50
52
|
spec: createTriggerSpec(props),
|
|
51
53
|
});
|
|
@@ -65,12 +67,12 @@ export const TriggerComponent = ({ shape }: TriggerComponentProps) => {
|
|
|
65
67
|
|
|
66
68
|
useEffect(() => {
|
|
67
69
|
if (functionTrigger && !functionTrigger.spec) {
|
|
68
|
-
functionTrigger.spec = createTriggerSpec({ triggerKind:
|
|
70
|
+
functionTrigger.spec = createTriggerSpec({ triggerKind: 'email', spaceId: space?.id });
|
|
69
71
|
}
|
|
70
72
|
}, [functionTrigger, functionTrigger?.spec]);
|
|
71
73
|
|
|
72
74
|
useEffect(() => {
|
|
73
|
-
shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ??
|
|
75
|
+
shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ?? 'email'));
|
|
74
76
|
}, [functionTrigger?.spec?.kind]);
|
|
75
77
|
|
|
76
78
|
const setKind = (kind: TriggerKind) => {
|
|
@@ -104,7 +106,7 @@ const TriggerKindSelect = ({ value, onValueChange }: Pick<SelectRootProps, 'valu
|
|
|
104
106
|
<Select.Content>
|
|
105
107
|
<Select.ScrollUpButton />
|
|
106
108
|
<Select.Viewport>
|
|
107
|
-
{
|
|
109
|
+
{TriggerKinds.map((kind) => (
|
|
108
110
|
<Select.Option key={kind} value={kind}>
|
|
109
111
|
{kind}
|
|
110
112
|
</Select.Option>
|
|
@@ -119,30 +121,30 @@ const TriggerKindSelect = ({ value, onValueChange }: Pick<SelectRootProps, 'valu
|
|
|
119
121
|
};
|
|
120
122
|
|
|
121
123
|
const createTriggerSpec = (props: { triggerKind?: TriggerKind; spaceId?: SpaceId }): TriggerType => {
|
|
122
|
-
const kind = props.triggerKind ??
|
|
124
|
+
const kind = props.triggerKind ?? 'email';
|
|
123
125
|
switch (kind) {
|
|
124
|
-
case
|
|
125
|
-
return { kind:
|
|
126
|
-
case
|
|
127
|
-
return { kind:
|
|
128
|
-
case
|
|
129
|
-
return { kind:
|
|
130
|
-
case
|
|
131
|
-
return { kind:
|
|
132
|
-
case
|
|
126
|
+
case 'timer':
|
|
127
|
+
return { kind: 'timer', cron: '*/10 * * * * *' } satisfies TimerTrigger;
|
|
128
|
+
case 'webhook':
|
|
129
|
+
return { kind: 'webhook', method: 'POST' } satisfies WebhookTrigger;
|
|
130
|
+
case 'subscription':
|
|
131
|
+
return { kind: 'subscription', query: Query.select(Filter.nothing()).ast } satisfies SubscriptionTrigger;
|
|
132
|
+
case 'email':
|
|
133
|
+
return { kind: 'email' } satisfies EmailTrigger;
|
|
134
|
+
case 'queue': {
|
|
133
135
|
const dxn = new DXN(DXN.kind.QUEUE, ['data', props.spaceId ?? SpaceId.random(), ObjectId.random()]).toString();
|
|
134
|
-
return { kind:
|
|
136
|
+
return { kind: 'queue', queue: dxn } satisfies QueueTrigger;
|
|
135
137
|
}
|
|
136
138
|
}
|
|
137
139
|
};
|
|
138
140
|
|
|
139
141
|
const getOutputSchema = (kind: TriggerKind) => {
|
|
140
142
|
const kindToSchema: Record<TriggerKind, Schema.Schema<any>> = {
|
|
141
|
-
[
|
|
142
|
-
[
|
|
143
|
-
[
|
|
144
|
-
[
|
|
145
|
-
[
|
|
143
|
+
['email']: EmailTriggerOutput,
|
|
144
|
+
['subscription']: SubscriptionTriggerOutput,
|
|
145
|
+
['timer']: TimerTriggerOutput,
|
|
146
|
+
['webhook']: WebhookTriggerOutput,
|
|
147
|
+
['queue']: QueueTriggerOutput,
|
|
146
148
|
};
|
|
147
149
|
return kindToSchema[kind];
|
|
148
150
|
};
|
|
@@ -154,9 +156,5 @@ export const triggerShape: ShapeDef<TriggerShape> = {
|
|
|
154
156
|
component: TriggerComponent,
|
|
155
157
|
createShape: createTrigger,
|
|
156
158
|
getAnchors: (shape) =>
|
|
157
|
-
createFunctionAnchors(
|
|
158
|
-
shape,
|
|
159
|
-
VoidInput,
|
|
160
|
-
getOutputSchema(shape.functionTrigger?.target?.spec?.kind ?? TriggerKind.Email),
|
|
161
|
-
),
|
|
159
|
+
createFunctionAnchors(shape, VoidInput, getOutputSchema(shape.functionTrigger?.target?.spec?.kind ?? 'email')),
|
|
162
160
|
};
|
|
@@ -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';
|
|
@@ -8,7 +8,7 @@ import React, { type JSX, useRef, useState } from 'react';
|
|
|
8
8
|
import { VoidInput, VoidOutput } from '@dxos/conductor';
|
|
9
9
|
import { useCanvasContext } from '@dxos/react-ui-canvas';
|
|
10
10
|
import { type Polygon, type Shape } from '@dxos/react-ui-canvas-editor';
|
|
11
|
-
import {
|
|
11
|
+
import { createAnchors, getParentShapeElement, rowHeight } from '@dxos/react-ui-canvas-editor';
|
|
12
12
|
|
|
13
13
|
import { Box, type BoxProps, footerHeight, headerHeight } from '../common';
|
|
14
14
|
import { createAnchorId, getProperties } from '../defs';
|