@dxos/plugin-debug 0.8.4-main.5acf9ea → 0.8.4-main.66e292d
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/DebugGraph-EDOH6R2G.mjs +20 -0
- package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs.map +7 -0
- package/dist/lib/browser/{DevtoolsOverviewContainer-EPD6EWT5.mjs → DevtoolsOverviewContainer-JXVZVPHN.mjs} +2 -2
- package/dist/lib/browser/{DevtoolsOverviewContainer-EPD6EWT5.mjs.map → DevtoolsOverviewContainer-JXVZVPHN.mjs.map} +1 -1
- package/dist/lib/browser/{SpaceGenerator-6ZOCEREN.mjs → SpaceGenerator-BED4UXGS.mjs} +261 -90
- package/dist/lib/browser/SpaceGenerator-BED4UXGS.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-SQXFD2BL.mjs → app-graph-builder-CRH2HJKT.mjs} +77 -86
- package/dist/lib/browser/app-graph-builder-CRH2HJKT.mjs.map +7 -0
- package/dist/lib/browser/{chunk-AJA6RYN3.mjs → chunk-SRV2AIGJ.mjs} +2 -2
- package/dist/lib/browser/chunk-SRV2AIGJ.mjs.map +7 -0
- package/dist/lib/browser/chunk-WZFZ4ESO.mjs +20 -0
- package/dist/lib/browser/chunk-WZFZ4ESO.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +13 -13
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-context-NVAGLAJD.mjs → react-context-P2YDWEWI.mjs} +6 -6
- package/dist/lib/browser/react-context-P2YDWEWI.mjs.map +7 -0
- package/dist/lib/browser/{react-surface-CHHHE5CF.mjs → react-surface-JM2H3RZI.mjs} +104 -98
- package/dist/lib/browser/react-surface-JM2H3RZI.mjs.map +7 -0
- package/dist/lib/browser/{settings-LSSWLM5I.mjs → settings-SQXR3OAH.mjs} +5 -5
- package/dist/lib/browser/{settings-LSSWLM5I.mjs.map → settings-SQXR3OAH.mjs.map} +1 -1
- package/dist/types/src/DebugPlugin.d.ts +1 -1
- package/dist/types/src/DebugPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +5 -5
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-context.d.ts +2 -2
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.d.ts +1 -1
- package/dist/types/src/components/DebugGraph.d.ts +8 -0
- package/dist/types/src/components/DebugGraph.d.ts.map +1 -0
- package/dist/types/src/components/DebugObjectPanel.d.ts.map +1 -1
- package/dist/types/src/components/DebugSettings.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts +2 -2
- package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts +1 -1
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts +13 -4
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/draw-util.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/presets.d.ts +51 -4
- package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -1
- package/dist/types/src/components/Wireframe.d.ts +1 -1
- package/dist/types/src/components/Wireframe.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +3 -1
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +1 -1
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +69 -66
- package/src/DebugPlugin.tsx +6 -7
- package/src/capabilities/app-graph-builder.ts +68 -94
- package/src/capabilities/react-context.tsx +2 -2
- package/src/capabilities/react-surface.tsx +77 -56
- package/src/components/DebugGraph.tsx +14 -0
- package/src/components/DebugObjectPanel.tsx +2 -4
- package/src/components/DebugSettings.tsx +102 -73
- package/src/components/DebugStatus.tsx +2 -2
- package/src/components/DevtoolsOverviewContainer.tsx +1 -1
- package/src/components/SpaceGenerator/ObjectGenerator.tsx +21 -27
- package/src/components/SpaceGenerator/SchemaTable.tsx +2 -2
- package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +11 -11
- package/src/components/SpaceGenerator/SpaceGenerator.tsx +12 -12
- package/src/components/SpaceGenerator/draw-util.ts +5 -5
- package/src/components/SpaceGenerator/presets.ts +200 -21
- package/src/components/Wireframe.tsx +4 -4
- package/src/components/index.ts +1 -1
- package/src/meta.ts +6 -5
- package/src/translations.ts +3 -1
- package/src/types.ts +1 -1
- package/dist/lib/browser/DebugApp-ZDL4CPY5.mjs +0 -228
- package/dist/lib/browser/DebugApp-ZDL4CPY5.mjs.map +0 -7
- package/dist/lib/browser/SpaceGenerator-6ZOCEREN.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-SQXFD2BL.mjs.map +0 -7
- package/dist/lib/browser/chunk-5XPIRNQS.mjs +0 -18
- package/dist/lib/browser/chunk-5XPIRNQS.mjs.map +0 -7
- package/dist/lib/browser/chunk-AJA6RYN3.mjs.map +0 -7
- package/dist/lib/browser/react-context-NVAGLAJD.mjs.map +0 -7
- package/dist/lib/browser/react-surface-CHHHE5CF.mjs.map +0 -7
- package/dist/types/src/components/DebugApp/DebugApp.d.ts +0 -6
- package/dist/types/src/components/DebugApp/DebugApp.d.ts.map +0 -1
- package/dist/types/src/components/DebugApp/Tree.d.ts +0 -18
- package/dist/types/src/components/DebugApp/Tree.d.ts.map +0 -1
- package/dist/types/src/components/DebugApp/index.d.ts +0 -3
- package/dist/types/src/components/DebugApp/index.d.ts.map +0 -1
- package/src/components/DebugApp/DebugApp.tsx +0 -84
- package/src/components/DebugApp/Tree.tsx +0 -103
- package/src/components/DebugApp/index.ts +0 -7
|
@@ -59,7 +59,7 @@ const _timer = (cb: (err?: Error) => void, options?: { min?: number; max?: numbe
|
|
|
59
59
|
// TODO(burdon): Integrate with Sentry?
|
|
60
60
|
const ErrorIndicator = () => {
|
|
61
61
|
const [, forceUpdate] = useState({});
|
|
62
|
-
const errorRef = useRef<Error>();
|
|
62
|
+
const errorRef = useRef<Error>(null);
|
|
63
63
|
useEffect(() => {
|
|
64
64
|
const errorListener = (event: any) => {
|
|
65
65
|
const error: Error = event.error ?? event.reason;
|
|
@@ -83,7 +83,7 @@ const ErrorIndicator = () => {
|
|
|
83
83
|
}, []);
|
|
84
84
|
|
|
85
85
|
const handleReset = () => {
|
|
86
|
-
errorRef.current =
|
|
86
|
+
errorRef.current = null;
|
|
87
87
|
forceUpdate({});
|
|
88
88
|
};
|
|
89
89
|
|
|
@@ -2,47 +2,46 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { type PromiseIntentDispatcher, createIntent } from '@dxos/app-framework';
|
|
6
6
|
import { addressToA1Notation } from '@dxos/compute';
|
|
7
7
|
import { ComputeGraph, ComputeGraphModel, DEFAULT_OUTPUT, NODE_INPUT, NODE_OUTPUT } from '@dxos/conductor';
|
|
8
|
-
import { DXN, Filter, Key, Obj,
|
|
9
|
-
import { type TypedObject } from '@dxos/echo
|
|
8
|
+
import { DXN, Filter, Key, type Obj, Type } from '@dxos/echo';
|
|
9
|
+
import { type TypedObject } from '@dxos/echo/internal';
|
|
10
10
|
import { Markdown } from '@dxos/plugin-markdown/types';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { CanvasType, DiagramType } from '@dxos/plugin-sketch/types';
|
|
11
|
+
import { Sheet } from '@dxos/plugin-sheet/types';
|
|
12
|
+
import { Diagram } from '@dxos/plugin-sketch/types';
|
|
14
13
|
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
15
14
|
import { faker } from '@dxos/random';
|
|
16
15
|
import { type Client } from '@dxos/react-client';
|
|
17
16
|
import { type Space } from '@dxos/react-client/echo';
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
17
|
+
import { View, getTypenameFromQuery } from '@dxos/schema';
|
|
18
|
+
import { type ValueGenerator, createAsyncGenerator } from '@dxos/schema/testing';
|
|
20
19
|
import { range } from '@dxos/util';
|
|
21
20
|
|
|
22
21
|
const generator: ValueGenerator = faker as any;
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const findViewByTypename = async (views: DataType.View[], typename: string) => {
|
|
27
|
-
return views.find((view) => view.query.typename === typename);
|
|
23
|
+
const findViewByTypename = async (views: View.View[], typename: string) => {
|
|
24
|
+
return views.find((view) => getTypenameFromQuery(view.query.ast) === typename);
|
|
28
25
|
};
|
|
29
26
|
|
|
27
|
+
export type ObjectGenerator<T extends Obj.Any> = (space: Space, n: number, cb?: (objects: T[]) => void) => Promise<T[]>;
|
|
28
|
+
|
|
30
29
|
export const createGenerator = <T extends Obj.Any>(
|
|
31
30
|
client: Client,
|
|
32
31
|
dispatch: PromiseIntentDispatcher,
|
|
33
32
|
schema: TypedObject<T>,
|
|
34
33
|
): ObjectGenerator<T> => {
|
|
35
|
-
return async (space: Space, n: number
|
|
34
|
+
return async (space: Space, n: number): Promise<T[]> => {
|
|
36
35
|
const typename = schema.typename;
|
|
37
36
|
|
|
38
37
|
// Find or create table and view.
|
|
39
|
-
const { objects: views } = await space.db.query(Filter.type(
|
|
38
|
+
const { objects: views } = await space.db.query(Filter.type(View.View)).run();
|
|
40
39
|
const view = await findViewByTypename(views, typename);
|
|
41
40
|
const staticSchema = client?.graph.schemaRegistry.schemas.find((schema) => Type.getTypename(schema) === typename);
|
|
42
41
|
if (!view && !staticSchema) {
|
|
43
|
-
await dispatch(createIntent(SpaceAction.AddSchema, { space, schema }));
|
|
42
|
+
await dispatch(createIntent(SpaceAction.AddSchema, { space, schema, show: false }));
|
|
44
43
|
} else if (!view && staticSchema) {
|
|
45
|
-
await dispatch(createIntent(SpaceAction.UseStaticSchema, { space, typename }));
|
|
44
|
+
await dispatch(createIntent(SpaceAction.UseStaticSchema, { space, typename, show: false }));
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
// Create objects.
|
|
@@ -57,7 +56,7 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
|
|
|
57
56
|
async (space, n, cb) => {
|
|
58
57
|
const objects = range(n).map(() => {
|
|
59
58
|
return space.db.add(
|
|
60
|
-
Markdown.
|
|
59
|
+
Markdown.make({
|
|
61
60
|
name: faker.commerce.productName(),
|
|
62
61
|
content: faker.lorem.sentences(5),
|
|
63
62
|
}),
|
|
@@ -69,16 +68,11 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
|
|
|
69
68
|
},
|
|
70
69
|
],
|
|
71
70
|
[
|
|
72
|
-
|
|
71
|
+
Diagram.Diagram.typename,
|
|
73
72
|
async (space, n, cb) => {
|
|
74
73
|
const objects = range(n).map(() => {
|
|
75
74
|
// TODO(burdon): Generate diagram.
|
|
76
|
-
const obj = space.db.add(
|
|
77
|
-
Obj.make(DiagramType, {
|
|
78
|
-
name: faker.commerce.productName(),
|
|
79
|
-
canvas: Ref.make(Obj.make(CanvasType, { content: {} })),
|
|
80
|
-
}),
|
|
81
|
-
);
|
|
75
|
+
const obj = space.db.add(Diagram.make({ name: faker.commerce.productName() }));
|
|
82
76
|
|
|
83
77
|
return obj;
|
|
84
78
|
});
|
|
@@ -89,10 +83,10 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
|
|
|
89
83
|
],
|
|
90
84
|
// TODO(burdon): Create unit tests.
|
|
91
85
|
[
|
|
92
|
-
|
|
86
|
+
Sheet.Sheet.typename,
|
|
93
87
|
async (space, n, cb) => {
|
|
94
88
|
const objects = range(n).map(() => {
|
|
95
|
-
const cells: Record<string, CellValue> = {};
|
|
89
|
+
const cells: Record<string, Sheet.CellValue> = {};
|
|
96
90
|
const year = new Date().getFullYear();
|
|
97
91
|
const cols = 4;
|
|
98
92
|
const rows = 16;
|
|
@@ -114,7 +108,7 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
|
|
|
114
108
|
// TODO(burdon): Set width.
|
|
115
109
|
// TODO(burdon): Set formatting for columns.
|
|
116
110
|
return space.db.add(
|
|
117
|
-
|
|
111
|
+
Sheet.make({
|
|
118
112
|
name: faker.commerce.productName(),
|
|
119
113
|
cells,
|
|
120
114
|
}),
|
|
@@ -19,8 +19,8 @@ export const SchemaTable = ({ types, objects = {}, label, onClick }: SchemaTable
|
|
|
19
19
|
<h2 className='p-2'>{label}</h2>
|
|
20
20
|
{types.map((type) => (
|
|
21
21
|
<div key={type.typename} className='grid grid-cols-subgrid col-span-3 items-center'>
|
|
22
|
-
<div className='
|
|
23
|
-
<div className='
|
|
22
|
+
<div className='pli-2 text-sm font-mono text-subdued'>{type.typename}</div>
|
|
23
|
+
<div className='pli-2 text-right font-mono'>{objects[type.typename] ?? 0}</div>
|
|
24
24
|
<IconButton
|
|
25
25
|
variant='ghost'
|
|
26
26
|
icon='ph--plus--regular'
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type Meta } from '@storybook/react-vite';
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React from 'react';
|
|
9
7
|
|
|
10
8
|
import { IntentPlugin } from '@dxos/app-framework';
|
|
11
9
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
12
10
|
import { ClientPlugin } from '@dxos/plugin-client';
|
|
13
11
|
import { useSpaces } from '@dxos/react-client/echo';
|
|
14
|
-
import {
|
|
12
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
13
|
+
import { render } from '@dxos/storybook-utils';
|
|
15
14
|
|
|
16
15
|
import { SpaceGenerator } from './SpaceGenerator';
|
|
17
16
|
|
|
@@ -24,29 +23,30 @@ const DefaultStory = () => {
|
|
|
24
23
|
return <SpaceGenerator space={space} />;
|
|
25
24
|
};
|
|
26
25
|
|
|
27
|
-
const meta
|
|
26
|
+
const meta = {
|
|
28
27
|
title: 'plugins/plugin-debug/SpaceGenerator',
|
|
29
|
-
component: SpaceGenerator,
|
|
28
|
+
component: SpaceGenerator as any,
|
|
30
29
|
render: render(DefaultStory),
|
|
31
30
|
decorators: [
|
|
31
|
+
withTheme,
|
|
32
32
|
withPluginManager({
|
|
33
33
|
plugins: [
|
|
34
34
|
ClientPlugin({
|
|
35
|
-
onClientInitialized: async (
|
|
35
|
+
onClientInitialized: async ({ client }) => {
|
|
36
36
|
await client.halo.createIdentity();
|
|
37
37
|
},
|
|
38
38
|
}),
|
|
39
39
|
IntentPlugin(),
|
|
40
40
|
],
|
|
41
41
|
}),
|
|
42
|
-
withLayout(),
|
|
43
|
-
withTheme,
|
|
44
42
|
],
|
|
45
43
|
parameters: {
|
|
46
44
|
layout: 'fullscreen',
|
|
47
45
|
},
|
|
48
|
-
}
|
|
46
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
49
47
|
|
|
50
48
|
export default meta;
|
|
51
49
|
|
|
52
|
-
|
|
50
|
+
type Story = StoryObj<typeof meta>;
|
|
51
|
+
|
|
52
|
+
export const Default: Story = {};
|
|
@@ -4,22 +4,22 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { useIntentDispatcher } from '@dxos/app-framework';
|
|
7
|
+
import { useIntentDispatcher } from '@dxos/app-framework/react';
|
|
8
8
|
import { ComputeGraph } from '@dxos/conductor';
|
|
9
|
-
import { Filter,
|
|
9
|
+
import { Filter, Obj } from '@dxos/echo';
|
|
10
10
|
import { Markdown } from '@dxos/plugin-markdown/types';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { Sheet } from '@dxos/plugin-sheet/types';
|
|
12
|
+
import { Diagram } from '@dxos/plugin-sketch/types';
|
|
13
13
|
import { useClient } from '@dxos/react-client';
|
|
14
|
-
import {
|
|
14
|
+
import { type Space } from '@dxos/react-client/echo';
|
|
15
15
|
import { IconButton, Input, Toolbar, useAsyncEffect } from '@dxos/react-ui';
|
|
16
16
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
17
|
-
import {
|
|
17
|
+
import { Organization, Person, Task } from '@dxos/types';
|
|
18
18
|
import { jsonKeyReplacer, sortKeys } from '@dxos/util';
|
|
19
19
|
|
|
20
|
-
import { createGenerator, staticGenerators
|
|
21
|
-
import { SchemaTable } from './SchemaTable';
|
|
20
|
+
import { type ObjectGenerator, createGenerator, staticGenerators } from './ObjectGenerator';
|
|
22
21
|
import { generator } from './presets';
|
|
22
|
+
import { SchemaTable } from './SchemaTable';
|
|
23
23
|
|
|
24
24
|
export type SpaceGeneratorProps = {
|
|
25
25
|
space: Space;
|
|
@@ -29,8 +29,8 @@ export type SpaceGeneratorProps = {
|
|
|
29
29
|
export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps) => {
|
|
30
30
|
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
31
31
|
const client = useClient();
|
|
32
|
-
const staticTypes = [Markdown.Document,
|
|
33
|
-
const recordTypes = [
|
|
32
|
+
const staticTypes = [Markdown.Document, Diagram.Diagram, Sheet.Sheet, ComputeGraph]; // TODO(burdon): Make extensible.
|
|
33
|
+
const recordTypes = [Organization.Organization, Person.Person, Task.Task];
|
|
34
34
|
const [count, setCount] = useState(1);
|
|
35
35
|
const [info, setInfo] = useState<any>({});
|
|
36
36
|
const presets = useMemo(() => generator(), []);
|
|
@@ -55,7 +55,7 @@ export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps)
|
|
|
55
55
|
const { objects } = await space.db.query(Filter.everything()).run();
|
|
56
56
|
const objectMap = sortKeys(
|
|
57
57
|
objects.reduce<Record<string, number>>((map, obj) => {
|
|
58
|
-
const type = getTypename(obj);
|
|
58
|
+
const type = Obj.getTypename(obj);
|
|
59
59
|
if (type) {
|
|
60
60
|
const count = map[type] ?? 0;
|
|
61
61
|
map[type] = count + 1;
|
|
@@ -112,7 +112,7 @@ export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps)
|
|
|
112
112
|
<SchemaTable types={presets.types} objects={info.objects} label='Presets' onClick={handleCreateData} />
|
|
113
113
|
|
|
114
114
|
<div>
|
|
115
|
-
<SyntaxHighlighter classNames='
|
|
115
|
+
<SyntaxHighlighter language='json' classNames='text-xs'>
|
|
116
116
|
{JSON.stringify({ space, ...info }, jsonKeyReplacer({ truncate: true }), 2)}
|
|
117
117
|
</SyntaxHighlighter>
|
|
118
118
|
</div>
|
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
// TODO(burdon): workerize-loader dep.
|
|
6
|
-
import {
|
|
6
|
+
import { type Edge, Graph, type PlainObject } from '@antv/graphlib';
|
|
7
7
|
import {
|
|
8
|
-
type Layout,
|
|
9
8
|
D3ForceLayout,
|
|
10
9
|
type D3ForceLayoutOptions,
|
|
11
10
|
GridLayout,
|
|
12
11
|
type GridLayoutOptions,
|
|
12
|
+
type Layout,
|
|
13
13
|
RadialLayout,
|
|
14
14
|
type RadialLayoutOptions,
|
|
15
15
|
} from '@antv/layout';
|
|
16
|
-
import {
|
|
16
|
+
import { type Editor, type SerializedStore, type TLRecord, createBindingId, createShapeId } from '@tldraw/tldraw';
|
|
17
17
|
|
|
18
18
|
import { faker } from '@dxos/random';
|
|
19
|
-
import {
|
|
19
|
+
import { isTruthy, range } from '@dxos/util';
|
|
20
20
|
|
|
21
21
|
// TODO(burdon): Graph layout:
|
|
22
22
|
// - https://www.npmjs.com/package/@antv/layout (uses d3)
|
|
@@ -67,7 +67,7 @@ export const generateGraph = (): Graph<PlainObject, PlainObject> => {
|
|
|
67
67
|
}
|
|
68
68
|
return target;
|
|
69
69
|
})
|
|
70
|
-
.filter(
|
|
70
|
+
.filter(isTruthy);
|
|
71
71
|
|
|
72
72
|
for (const target of targets) {
|
|
73
73
|
traverse(target);
|
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
+
import { Agent, EntityExtraction, ResearchBlueprint } from '@dxos/assistant-toolkit';
|
|
8
|
+
import { Prompt } from '@dxos/blueprints';
|
|
7
9
|
import { type ComputeGraphModel, NODE_INPUT } from '@dxos/conductor';
|
|
8
|
-
import { DXN, Key, Obj, Ref, Type } from '@dxos/echo';
|
|
9
|
-
import {
|
|
10
|
+
import { DXN, Filter, Key, Obj, Query, Ref, Tag, Type } from '@dxos/echo';
|
|
11
|
+
import { Trigger, serializeFunction } from '@dxos/functions';
|
|
10
12
|
import { invariant } from '@dxos/invariant';
|
|
13
|
+
import { gmail } from '@dxos/plugin-inbox';
|
|
14
|
+
import { Mailbox } from '@dxos/plugin-inbox/types';
|
|
15
|
+
import { Markdown } from '@dxos/plugin-markdown/types';
|
|
11
16
|
import { type Space } from '@dxos/react-client/echo';
|
|
12
17
|
import {
|
|
13
18
|
type ComputeShape,
|
|
@@ -18,8 +23,8 @@ import {
|
|
|
18
23
|
createFunction,
|
|
19
24
|
createGpt,
|
|
20
25
|
createQueue,
|
|
21
|
-
createSurface,
|
|
22
26
|
createRandom,
|
|
27
|
+
createSurface,
|
|
23
28
|
createTemplate,
|
|
24
29
|
createText,
|
|
25
30
|
createTrigger,
|
|
@@ -31,38 +36,209 @@ import {
|
|
|
31
36
|
pointsToRect,
|
|
32
37
|
rectToPoints,
|
|
33
38
|
} from '@dxos/react-ui-canvas-editor';
|
|
34
|
-
import {
|
|
39
|
+
import { View } from '@dxos/schema';
|
|
40
|
+
import { Message, Organization, Person, Project } from '@dxos/types';
|
|
41
|
+
import { range, trim } from '@dxos/util';
|
|
35
42
|
|
|
36
43
|
import { type ObjectGenerator } from './ObjectGenerator';
|
|
37
44
|
|
|
38
45
|
export enum PresetName {
|
|
46
|
+
DXOS_TEAM = 'dxos-team',
|
|
47
|
+
ORG_RESEARCH_PROJECT = 'org-research-project',
|
|
39
48
|
// EMAIL_TABLE = 'email-table',
|
|
40
49
|
GPT_QUEUE = 'webhook-gpt-queue',
|
|
41
50
|
CHAT_GPT = 'chat-gpt-text',
|
|
42
51
|
// EMAIL_WITH_SUMMARY = 'email-gptSummary-table',
|
|
43
52
|
OBJECT_CHANGE_QUEUE = 'objectChange-queue',
|
|
44
|
-
FOREX_FUNCTION_CALL = 'forex-function-call',
|
|
45
53
|
TIMER_TICK_QUEUE = 'timerTick-queue',
|
|
54
|
+
FOREX_FUNCTION_CALL = 'forex-function-call',
|
|
46
55
|
DISCORD_MESSAGES = 'discord-messages',
|
|
47
56
|
// KANBAN_QUEUE = 'kanban-queue',
|
|
48
57
|
}
|
|
49
58
|
|
|
50
59
|
export const generator = () => ({
|
|
51
|
-
schemas: [CanvasBoardType,
|
|
60
|
+
schemas: [CanvasBoardType, Trigger.Trigger],
|
|
52
61
|
types: Object.values(PresetName).map((name) => ({ typename: name })),
|
|
53
62
|
items: [
|
|
63
|
+
[
|
|
64
|
+
PresetName.DXOS_TEAM,
|
|
65
|
+
async (space, n, cb) => {
|
|
66
|
+
const objects = range(n, () => {
|
|
67
|
+
const org = space.db.add(Obj.make(Organization.Organization, { name: 'DXOS', website: 'https://dxos.org' }));
|
|
68
|
+
const doc = space.db.add(
|
|
69
|
+
Markdown.make({
|
|
70
|
+
name: 'DXOS Research',
|
|
71
|
+
content: 'DXOS builds Composer, an open-source AI-powered malleable application.',
|
|
72
|
+
}),
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const tag = space.db.add(Tag.make({ label: 'Investor' }));
|
|
76
|
+
const tagDxn = Obj.getDXN(tag).toString();
|
|
77
|
+
Obj.getMeta(doc).tags = [tagDxn];
|
|
78
|
+
|
|
79
|
+
// space.db.add(
|
|
80
|
+
// Relation.make(HasSubject, {
|
|
81
|
+
// [Relation.Source]: doc,
|
|
82
|
+
// [Relation.Target]: org,
|
|
83
|
+
// completedAt: new Date().toISOString(),
|
|
84
|
+
// }),
|
|
85
|
+
// );
|
|
86
|
+
|
|
87
|
+
space.db.add(Obj.make(Person.Person, { fullName: 'Rich', organization: Ref.make(org) }, { tags: [tagDxn] }));
|
|
88
|
+
space.db.add(Obj.make(Person.Person, { fullName: 'Josiah', organization: Ref.make(org) }));
|
|
89
|
+
space.db.add(Obj.make(Person.Person, { fullName: 'Dima', organization: Ref.make(org) }));
|
|
90
|
+
space.db.add(Obj.make(Person.Person, { fullName: 'Mykola', organization: Ref.make(org) }));
|
|
91
|
+
|
|
92
|
+
return doc;
|
|
93
|
+
});
|
|
94
|
+
cb?.(objects);
|
|
95
|
+
return objects;
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
[
|
|
99
|
+
PresetName.ORG_RESEARCH_PROJECT,
|
|
100
|
+
async (space, n, cb) => {
|
|
101
|
+
const mailbox = await space.db.query(Filter.type(Mailbox.Mailbox)).first();
|
|
102
|
+
const tag = await space.db.query(Filter.type(Tag.Tag, { label: 'Investor' })).first();
|
|
103
|
+
const tagDxn = Obj.getDXN(tag).toString();
|
|
104
|
+
|
|
105
|
+
const objects = range(n, () => {
|
|
106
|
+
const contactsQuery = Query.select(Filter.type(Person.Person)).select(Filter.tag(tagDxn));
|
|
107
|
+
const organizationsQuery = Query.select(Filter.type(Organization.Organization)).select(Filter.tag(tagDxn));
|
|
108
|
+
const notesQuery = Query.select(Filter.type(Markdown.Document)).select(Filter.tag(tagDxn));
|
|
109
|
+
|
|
110
|
+
space.db.add(
|
|
111
|
+
Trigger.make({
|
|
112
|
+
enabled: true,
|
|
113
|
+
spec: {
|
|
114
|
+
kind: 'timer',
|
|
115
|
+
cron: '* * * * *', // Every minute.
|
|
116
|
+
},
|
|
117
|
+
function: Ref.make(serializeFunction(gmail.sync)),
|
|
118
|
+
input: {
|
|
119
|
+
mailboxId: Obj.getDXN(mailbox).toString(),
|
|
120
|
+
},
|
|
121
|
+
}),
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
space.db.add(
|
|
125
|
+
Trigger.make({
|
|
126
|
+
enabled: true,
|
|
127
|
+
// TODO(wittjosiah): Queue trigger doesn't support matching query of the column.
|
|
128
|
+
spec: {
|
|
129
|
+
kind: 'queue',
|
|
130
|
+
queue: mailbox.queue.dxn.toString(),
|
|
131
|
+
},
|
|
132
|
+
function: Ref.make(serializeFunction(EntityExtraction.extract)),
|
|
133
|
+
input: {
|
|
134
|
+
source: '{{event.item}}',
|
|
135
|
+
},
|
|
136
|
+
}),
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
const researchPrompt = space.db.add(
|
|
140
|
+
Prompt.make({
|
|
141
|
+
name: 'Research',
|
|
142
|
+
description: 'Research organization',
|
|
143
|
+
input: Schema.Struct({
|
|
144
|
+
org: Schema.Any,
|
|
145
|
+
}),
|
|
146
|
+
output: Schema.Any,
|
|
147
|
+
|
|
148
|
+
// TODO(dmaretskyi): This mocks research (returns pre-baked result), the actual research might take compute minutes.
|
|
149
|
+
// Remove the mock prompt to do the actual research.
|
|
150
|
+
instructions: trim`
|
|
151
|
+
Research the organization provided as input.
|
|
152
|
+
Create a research note for it at the end.
|
|
153
|
+
NOTE: Do mocked reseach (set mockSearch to true).
|
|
154
|
+
`,
|
|
155
|
+
blueprints: [Ref.make(ResearchBlueprint)],
|
|
156
|
+
}),
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
space.db.add(
|
|
160
|
+
Trigger.make({
|
|
161
|
+
enabled: true,
|
|
162
|
+
spec: {
|
|
163
|
+
kind: 'subscription',
|
|
164
|
+
query: {
|
|
165
|
+
ast: organizationsQuery.ast,
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
function: Ref.make(serializeFunction(Agent.prompt)),
|
|
169
|
+
input: {
|
|
170
|
+
prompt: Ref.make(researchPrompt),
|
|
171
|
+
input: '{{event.subject}}',
|
|
172
|
+
},
|
|
173
|
+
}),
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
const mailboxView = View.make({
|
|
177
|
+
query: Query.select(
|
|
178
|
+
Filter.type(Message.Message, { properties: { labels: Filter.contains('investor') } }),
|
|
179
|
+
).options({
|
|
180
|
+
queues: [mailbox.queue.dxn.toString()],
|
|
181
|
+
}),
|
|
182
|
+
jsonSchema: Type.toJsonSchema(Message.Message),
|
|
183
|
+
});
|
|
184
|
+
const contactsView = View.make({
|
|
185
|
+
query: contactsQuery,
|
|
186
|
+
jsonSchema: Type.toJsonSchema(Person.Person),
|
|
187
|
+
});
|
|
188
|
+
const organizationsView = View.make({
|
|
189
|
+
query: organizationsQuery,
|
|
190
|
+
jsonSchema: Type.toJsonSchema(Organization.Organization),
|
|
191
|
+
});
|
|
192
|
+
const notesView = View.make({
|
|
193
|
+
query: notesQuery,
|
|
194
|
+
jsonSchema: Type.toJsonSchema(Markdown.Document),
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
return space.db.add(
|
|
198
|
+
Project.make({
|
|
199
|
+
name: 'Investor Research',
|
|
200
|
+
columns: [
|
|
201
|
+
{
|
|
202
|
+
name: 'Mailbox',
|
|
203
|
+
view: Ref.make(mailboxView),
|
|
204
|
+
order: [],
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: 'Contacts',
|
|
208
|
+
view: Ref.make(contactsView),
|
|
209
|
+
order: [],
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
name: 'Organizations',
|
|
213
|
+
view: Ref.make(organizationsView),
|
|
214
|
+
order: [],
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
name: 'Notes',
|
|
218
|
+
view: Ref.make(notesView),
|
|
219
|
+
order: [],
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
}),
|
|
223
|
+
);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
cb?.(objects.flat());
|
|
227
|
+
return objects.flat();
|
|
228
|
+
},
|
|
229
|
+
],
|
|
54
230
|
[
|
|
55
231
|
PresetName.GPT_QUEUE,
|
|
56
232
|
async (space, n, cb) => {
|
|
57
233
|
const objects = range(n, () => {
|
|
58
234
|
const canvasModel = CanvasGraphModel.create<ComputeShape>();
|
|
59
235
|
|
|
60
|
-
let functionTrigger:
|
|
236
|
+
let functionTrigger: Trigger.Trigger | undefined;
|
|
61
237
|
canvasModel.builder.call((builder) => {
|
|
62
238
|
const gpt = canvasModel.createNode(createGpt(position({ x: 0, y: -14 })));
|
|
63
239
|
const triggerShape = createTrigger({
|
|
64
240
|
spaceId: space.id,
|
|
65
|
-
triggerKind:
|
|
241
|
+
triggerKind: 'webhook',
|
|
66
242
|
...position({ x: -18, y: -2 }),
|
|
67
243
|
});
|
|
68
244
|
const trigger = canvasModel.createNode(triggerShape);
|
|
@@ -96,8 +272,11 @@ export const generator = () => ({
|
|
|
96
272
|
const objects = range(n, () => {
|
|
97
273
|
const { canvasModel, computeModel } = createQueueSinkPreset(
|
|
98
274
|
space,
|
|
99
|
-
|
|
100
|
-
(triggerSpec) =>
|
|
275
|
+
'subscription',
|
|
276
|
+
(triggerSpec) =>
|
|
277
|
+
(triggerSpec.query = {
|
|
278
|
+
ast: Query.select(Filter.typename('dxos.org/type/Chess')).ast,
|
|
279
|
+
}),
|
|
101
280
|
'type',
|
|
102
281
|
);
|
|
103
282
|
return addToSpace(PresetName.OBJECT_CHANGE_QUEUE, space, canvasModel, computeModel);
|
|
@@ -113,7 +292,7 @@ export const generator = () => ({
|
|
|
113
292
|
const objects = range(n, () => {
|
|
114
293
|
const { canvasModel, computeModel } = createQueueSinkPreset(
|
|
115
294
|
space,
|
|
116
|
-
|
|
295
|
+
'timer',
|
|
117
296
|
(triggerSpec) => (triggerSpec.cron = '*/5 * * * * *'),
|
|
118
297
|
'result',
|
|
119
298
|
);
|
|
@@ -147,7 +326,7 @@ export const generator = () => ({
|
|
|
147
326
|
// canvasModel.builder.call((builder) => {
|
|
148
327
|
// const triggerShape = createTrigger({
|
|
149
328
|
// spaceId: space.id,
|
|
150
|
-
// triggerKind:
|
|
329
|
+
// triggerKind: 'email',
|
|
151
330
|
// ...position({ x: -18, y: -2 }),
|
|
152
331
|
// });
|
|
153
332
|
// const trigger = canvasModel.createNode(triggerShape);
|
|
@@ -254,7 +433,7 @@ export const generator = () => ({
|
|
|
254
433
|
// );
|
|
255
434
|
// const triggerShape = createTrigger({
|
|
256
435
|
// spaceId: space.id,
|
|
257
|
-
// triggerKind:
|
|
436
|
+
// triggerKind: 'email',
|
|
258
437
|
// ...rawPosition({ centerX: -736, centerY: -384, width: 182, height: 192 }),
|
|
259
438
|
// });
|
|
260
439
|
// const trigger = canvasModel.createNode(triggerShape);
|
|
@@ -354,11 +533,11 @@ export const generator = () => ({
|
|
|
354
533
|
const objects = range(n, () => {
|
|
355
534
|
const canvasModel = CanvasGraphModel.create<ComputeShape>();
|
|
356
535
|
|
|
357
|
-
let functionTrigger:
|
|
536
|
+
let functionTrigger: Trigger.Trigger | undefined;
|
|
358
537
|
canvasModel.builder.call((builder) => {
|
|
359
538
|
const triggerShape = createTrigger({
|
|
360
539
|
spaceId: space.id,
|
|
361
|
-
triggerKind:
|
|
540
|
+
triggerKind: 'timer',
|
|
362
541
|
...position({ x: -10, y: -5 }),
|
|
363
542
|
});
|
|
364
543
|
const trigger = canvasModel.createNode(triggerShape);
|
|
@@ -416,7 +595,7 @@ export const generator = () => ({
|
|
|
416
595
|
// canvasModel.builder.call((builder) => {
|
|
417
596
|
// const triggerShape = createTrigger({
|
|
418
597
|
// spaceId: space.id,
|
|
419
|
-
// triggerKind:
|
|
598
|
+
// triggerKind: 'queue',
|
|
420
599
|
// ...position({ x: -10, y: -5 }),
|
|
421
600
|
// });
|
|
422
601
|
// const trigger = canvasModel.createNode(triggerShape);
|
|
@@ -448,10 +627,10 @@ export const generator = () => ({
|
|
|
448
627
|
] as [PresetName, ObjectGenerator<any>][],
|
|
449
628
|
});
|
|
450
629
|
|
|
451
|
-
const createQueueSinkPreset = <SpecType extends
|
|
630
|
+
const createQueueSinkPreset = <SpecType extends Trigger.Kind>(
|
|
452
631
|
space: Space,
|
|
453
632
|
triggerKind: SpecType,
|
|
454
|
-
initSpec: (spec: Extract<
|
|
633
|
+
initSpec: (spec: Extract<Trigger.Spec, { kind: SpecType }>) => void,
|
|
455
634
|
triggerOutputName: string,
|
|
456
635
|
) => {
|
|
457
636
|
const canvasModel = CanvasGraphModel.create<ComputeShape>();
|
|
@@ -463,7 +642,7 @@ const createQueueSinkPreset = <SpecType extends TriggerKind>(
|
|
|
463
642
|
}),
|
|
464
643
|
);
|
|
465
644
|
|
|
466
|
-
let functionTrigger:
|
|
645
|
+
let functionTrigger: Trigger.Trigger | undefined;
|
|
467
646
|
canvasModel.builder.call((builder) => {
|
|
468
647
|
const triggerShape = createTrigger({
|
|
469
648
|
spaceId: space.id,
|
|
@@ -538,7 +717,7 @@ const setupQueue = (
|
|
|
538
717
|
return { queue, queueId };
|
|
539
718
|
};
|
|
540
719
|
|
|
541
|
-
const attachTrigger = (functionTrigger:
|
|
720
|
+
const attachTrigger = (functionTrigger: Trigger.Trigger | undefined, computeModel: ComputeGraphModel) => {
|
|
542
721
|
invariant(functionTrigger);
|
|
543
722
|
functionTrigger.function = Ref.make(computeModel.root);
|
|
544
723
|
const inputNode = computeModel.nodes.find((node) => node.type === NODE_INPUT)!;
|
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { useResizeDetector } from 'react-resize-detector';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import { fullyQualifiedId } from '@dxos/react-client/echo';
|
|
8
|
+
import { Obj } from '@dxos/echo';
|
|
10
9
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
11
10
|
import { useAttentionAttributes } from '@dxos/react-ui-attention';
|
|
12
11
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
@@ -20,8 +19,9 @@ export type WireframeProps = ThemedClassName<{
|
|
|
20
19
|
|
|
21
20
|
// TODO(burdon): Make focusable and attendable with input.
|
|
22
21
|
export const Wireframe = ({ classNames, label, object }: WireframeProps) => {
|
|
23
|
-
const attentionAttrs = useAttentionAttributes(
|
|
22
|
+
const attentionAttrs = useAttentionAttributes(Obj.getDXN(object).toString());
|
|
24
23
|
const { width, height, ref } = useResizeDetector();
|
|
24
|
+
|
|
25
25
|
return (
|
|
26
26
|
<div ref={ref} className={mx('relative grow min-bs-96', classNames)} {...attentionAttrs}>
|
|
27
27
|
<div className='absolute inset-2 flex flex-col gap-2 overflow-hidden font-mono'>
|
|
@@ -30,7 +30,7 @@ export const Wireframe = ({ classNames, label, object }: WireframeProps) => {
|
|
|
30
30
|
<div>{`[${width}x${height}]`}</div>
|
|
31
31
|
</div>
|
|
32
32
|
{object && (
|
|
33
|
-
<SyntaxHighlighter language='json' classNames='
|
|
33
|
+
<SyntaxHighlighter language='json' classNames='text-xs opacity-75 rounded'>
|
|
34
34
|
{JSON.stringify(object, undefined, 2)}
|
|
35
35
|
</SyntaxHighlighter>
|
|
36
36
|
)}
|