@dxos/plugin-debug 0.8.4-main.70d3990 → 0.8.4-main.7996785055
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-7HXJ2PS2.mjs +16 -0
- package/dist/lib/browser/DebugGraph-7HXJ2PS2.mjs.map +7 -0
- package/dist/lib/browser/DebugObjectPanel-KXVFOGU6.mjs +35 -0
- package/dist/lib/browser/DebugObjectPanel-KXVFOGU6.mjs.map +7 -0
- package/dist/lib/browser/DebugSettings-DQXOXF6A.mjs +183 -0
- package/dist/lib/browser/DebugSettings-DQXOXF6A.mjs.map +7 -0
- package/dist/lib/browser/DebugSpaceObjectsPanel-SIK72DXV.mjs +45 -0
- package/dist/lib/browser/DebugSpaceObjectsPanel-SIK72DXV.mjs.map +7 -0
- package/dist/lib/browser/DebugStatus-FWF3YFBA.mjs +124 -0
- package/dist/lib/browser/DebugStatus-FWF3YFBA.mjs.map +7 -0
- package/dist/lib/browser/DevtoolsOverviewContainer-TBTTPXVF.mjs +24 -0
- package/dist/lib/browser/DevtoolsOverviewContainer-TBTTPXVF.mjs.map +7 -0
- package/dist/lib/browser/{SpaceGenerator-BED4UXGS.mjs → SpaceGenerator-UUQS6TYY.mjs} +432 -401
- package/dist/lib/browser/SpaceGenerator-UUQS6TYY.mjs.map +7 -0
- package/dist/lib/browser/Wireframe-KAGOKEFW.mjs +53 -0
- package/dist/lib/browser/Wireframe-KAGOKEFW.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-FBLOEOH5.mjs +594 -0
- package/dist/lib/browser/app-graph-builder-FBLOEOH5.mjs.map +7 -0
- package/dist/lib/browser/{chunk-SRV2AIGJ.mjs → chunk-Q37TZWW5.mjs} +12 -2
- package/dist/lib/browser/chunk-Q37TZWW5.mjs.map +7 -0
- package/dist/lib/browser/{chunk-WZFZ4ESO.mjs → chunk-ZOM2FBHQ.mjs} +2 -2
- package/dist/lib/browser/chunk-ZOM2FBHQ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +40 -38
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-context-KBHXEMRS.mjs +18 -0
- package/dist/lib/browser/react-context-KBHXEMRS.mjs.map +7 -0
- package/dist/lib/browser/react-surface-HYT4HKZX.mjs +428 -0
- package/dist/lib/browser/react-surface-HYT4HKZX.mjs.map +7 -0
- package/dist/lib/browser/settings-XXFUM3QJ.mjs +32 -0
- package/dist/lib/browser/settings-XXFUM3QJ.mjs.map +7 -0
- package/dist/types/src/DebugPlugin.d.ts +7 -1
- package/dist/types/src/DebugPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +4 -8
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-context/index.d.ts +7 -0
- package/dist/types/src/capabilities/react-context/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-context/react-context.d.ts +10 -0
- package/dist/types/src/capabilities/react-context/react-context.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +9 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/index.d.ts +3 -0
- package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/settings.d.ts +6 -0
- package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
- package/dist/types/src/components/SchemaTable/SchemaTable.d.ts.map +1 -0
- package/dist/types/src/components/SchemaTable/index.d.ts +2 -0
- package/dist/types/src/components/SchemaTable/index.d.ts.map +1 -0
- package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts +5 -5
- package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/index.d.ts +2 -2
- package/dist/types/src/components/SpaceGenerator/index.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/presets.d.ts +1 -48
- package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -10
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/DebugGraph/DebugGraph.d.ts +8 -0
- package/dist/types/src/containers/DebugGraph/DebugGraph.d.ts.map +1 -0
- package/dist/types/src/containers/DebugGraph/index.d.ts +3 -0
- package/dist/types/src/containers/DebugGraph/index.d.ts.map +1 -0
- package/dist/types/src/{components → containers/DebugObjectPanel}/DebugObjectPanel.d.ts +2 -2
- package/dist/types/src/containers/DebugObjectPanel/DebugObjectPanel.d.ts.map +1 -0
- package/dist/types/src/containers/DebugObjectPanel/index.d.ts +3 -0
- package/dist/types/src/containers/DebugObjectPanel/index.d.ts.map +1 -0
- package/dist/types/src/containers/DebugSettings/DebugSettings.d.ts +10 -0
- package/dist/types/src/containers/DebugSettings/DebugSettings.d.ts.map +1 -0
- package/dist/types/src/containers/DebugSettings/index.d.ts +3 -0
- package/dist/types/src/containers/DebugSettings/index.d.ts.map +1 -0
- package/dist/types/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.d.ts +3 -0
- package/dist/types/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.d.ts.map +1 -0
- package/dist/types/src/containers/DebugSpaceObjectsPanel/index.d.ts +3 -0
- package/dist/types/src/containers/DebugSpaceObjectsPanel/index.d.ts.map +1 -0
- package/dist/types/src/containers/DebugStatus/DebugStatus.d.ts.map +1 -0
- package/dist/types/src/containers/DebugStatus/index.d.ts +3 -0
- package/dist/types/src/containers/DebugStatus/index.d.ts.map +1 -0
- package/dist/types/src/{components → containers/DevtoolsOverviewContainer}/DevtoolsOverviewContainer.d.ts +0 -1
- package/dist/types/src/containers/DevtoolsOverviewContainer/DevtoolsOverviewContainer.d.ts.map +1 -0
- package/dist/types/src/containers/DevtoolsOverviewContainer/index.d.ts +3 -0
- package/dist/types/src/containers/DevtoolsOverviewContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/SpaceGenerator/SpaceGenerator.d.ts +15 -0
- package/dist/types/src/containers/SpaceGenerator/SpaceGenerator.d.ts.map +1 -0
- package/dist/types/src/containers/SpaceGenerator/index.d.ts +3 -0
- package/dist/types/src/containers/SpaceGenerator/index.d.ts.map +1 -0
- package/dist/types/src/{components → containers/Wireframe}/Wireframe.d.ts +1 -1
- package/dist/types/src/containers/Wireframe/Wireframe.d.ts.map +1 -0
- package/dist/types/src/containers/Wireframe/index.d.ts +3 -0
- package/dist/types/src/containers/Wireframe/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +10 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +2 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +39 -34
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +75 -70
- package/src/DebugPlugin.tsx +27 -31
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +419 -0
- package/src/capabilities/app-graph-builder/index.ts +7 -0
- package/src/capabilities/index.ts +4 -6
- package/src/capabilities/react-context/index.ts +7 -0
- package/src/capabilities/react-context/react-context.tsx +25 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +414 -0
- package/src/capabilities/settings/index.ts +7 -0
- package/src/capabilities/settings/settings.ts +31 -0
- package/src/components/{SpaceGenerator → SchemaTable}/SchemaTable.tsx +2 -2
- package/src/components/SchemaTable/index.ts +5 -0
- package/src/components/SpaceGenerator/ObjectGenerator.tsx +19 -21
- package/src/components/SpaceGenerator/index.ts +2 -3
- package/src/components/SpaceGenerator/presets.ts +174 -66
- package/src/components/index.ts +2 -10
- package/src/containers/DebugGraph/DebugGraph.tsx +13 -0
- package/src/containers/DebugGraph/index.ts +7 -0
- package/src/containers/DebugObjectPanel/DebugObjectPanel.tsx +47 -0
- package/src/containers/DebugObjectPanel/index.ts +7 -0
- package/src/{components → containers/DebugSettings}/DebugSettings.tsx +51 -25
- package/src/containers/DebugSettings/index.ts +7 -0
- package/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.tsx +55 -0
- package/src/containers/DebugSpaceObjectsPanel/index.ts +7 -0
- package/src/{components → containers/DebugStatus}/DebugStatus.tsx +40 -16
- package/src/containers/DebugStatus/index.ts +7 -0
- package/src/containers/DevtoolsOverviewContainer/DevtoolsOverviewContainer.tsx +25 -0
- package/src/containers/DevtoolsOverviewContainer/index.ts +7 -0
- package/src/containers/SpaceGenerator/SpaceGenerator.tsx +130 -0
- package/src/containers/SpaceGenerator/index.ts +7 -0
- package/src/{components → containers/Wireframe}/Wireframe.tsx +4 -4
- package/src/containers/Wireframe/index.ts +7 -0
- package/src/containers/index.ts +14 -0
- package/src/meta.ts +3 -3
- package/src/translations.ts +2 -0
- package/src/types.ts +9 -2
- package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs +0 -20
- package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs.map +0 -7
- package/dist/lib/browser/DevtoolsOverviewContainer-JXVZVPHN.mjs +0 -25
- package/dist/lib/browser/DevtoolsOverviewContainer-JXVZVPHN.mjs.map +0 -7
- package/dist/lib/browser/SpaceGenerator-BED4UXGS.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-CRH2HJKT.mjs +0 -588
- package/dist/lib/browser/app-graph-builder-CRH2HJKT.mjs.map +0 -7
- package/dist/lib/browser/chunk-SRV2AIGJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-WZFZ4ESO.mjs.map +0 -7
- package/dist/lib/browser/react-context-P2YDWEWI.mjs +0 -16
- package/dist/lib/browser/react-context-P2YDWEWI.mjs.map +0 -7
- package/dist/lib/browser/react-surface-JM2H3RZI.mjs +0 -774
- package/dist/lib/browser/react-surface-JM2H3RZI.mjs.map +0 -7
- package/dist/lib/browser/settings-SQXR3OAH.mjs +0 -22
- package/dist/lib/browser/settings-SQXR3OAH.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-context.d.ts +0 -8
- package/dist/types/src/capabilities/react-context.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings.d.ts +0 -4
- package/dist/types/src/capabilities/settings.d.ts.map +0 -1
- package/dist/types/src/components/Container.d.ts +0 -5
- package/dist/types/src/components/Container.d.ts.map +0 -1
- package/dist/types/src/components/DebugGraph.d.ts +0 -8
- package/dist/types/src/components/DebugGraph.d.ts.map +0 -1
- package/dist/types/src/components/DebugObjectPanel.d.ts.map +0 -1
- package/dist/types/src/components/DebugSettings.d.ts +0 -6
- package/dist/types/src/components/DebugSettings.d.ts.map +0 -1
- package/dist/types/src/components/DebugStatus.d.ts.map +0 -1
- package/dist/types/src/components/DevtoolsOverviewContainer.d.ts.map +0 -1
- package/dist/types/src/components/SpaceGenerator/SchemaTable.d.ts.map +0 -1
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts +0 -9
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +0 -1
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts +0 -15
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts.map +0 -1
- package/dist/types/src/components/Wireframe.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder.ts +0 -431
- package/src/capabilities/react-context.tsx +0 -16
- package/src/capabilities/react-surface.tsx +0 -418
- package/src/capabilities/settings.ts +0 -19
- package/src/components/Container.tsx +0 -15
- package/src/components/DebugGraph.tsx +0 -14
- package/src/components/DebugObjectPanel.tsx +0 -33
- package/src/components/DevtoolsOverviewContainer.tsx +0 -20
- package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +0 -52
- package/src/components/SpaceGenerator/SpaceGenerator.tsx +0 -122
- /package/dist/types/src/components/{SpaceGenerator → SchemaTable}/SchemaTable.d.ts +0 -0
- /package/dist/types/src/{components → containers/DebugStatus}/DebugStatus.d.ts +0 -0
|
@@ -1,214 +1,59 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
1
|
+
// src/containers/SpaceGenerator/SpaceGenerator.tsx
|
|
3
2
|
import React2, { useCallback, useMemo, useState } from "react";
|
|
4
|
-
import {
|
|
3
|
+
import { useOperationInvoker } from "@dxos/app-framework/ui";
|
|
5
4
|
import { ComputeGraph as ComputeGraph2 } from "@dxos/conductor";
|
|
6
5
|
import { Filter as Filter3, Obj as Obj2 } from "@dxos/echo";
|
|
7
6
|
import { Markdown as Markdown3 } from "@dxos/plugin-markdown/types";
|
|
8
7
|
import { Sheet as Sheet2 } from "@dxos/plugin-sheet/types";
|
|
9
|
-
import {
|
|
8
|
+
import { Sketch as Sketch2 } from "@dxos/plugin-sketch/types";
|
|
10
9
|
import { useClient } from "@dxos/react-client";
|
|
11
|
-
import { IconButton as IconButton2, Input, Toolbar, useAsyncEffect } from "@dxos/react-ui";
|
|
10
|
+
import { IconButton as IconButton2, Input, Panel, ScrollArea, Toolbar, useAsyncEffect } from "@dxos/react-ui";
|
|
12
11
|
import { SyntaxHighlighter } from "@dxos/react-ui-syntax-highlighter";
|
|
13
12
|
import { Organization as Organization2, Person as Person2, Task } from "@dxos/types";
|
|
13
|
+
import { composable, composableProps } from "@dxos/ui-theme";
|
|
14
14
|
import { jsonKeyReplacer, sortKeys } from "@dxos/util";
|
|
15
15
|
|
|
16
|
-
// src/components/
|
|
17
|
-
import
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const staticSchema = client?.graph.schemaRegistry.schemas.find((schema2) => Type.getTypename(schema2) === typename);
|
|
39
|
-
if (!view && !staticSchema) {
|
|
40
|
-
await dispatch(createIntent(SpaceAction.AddSchema, {
|
|
41
|
-
space,
|
|
42
|
-
schema,
|
|
43
|
-
show: false
|
|
44
|
-
}));
|
|
45
|
-
} else if (!view && staticSchema) {
|
|
46
|
-
await dispatch(createIntent(SpaceAction.UseStaticSchema, {
|
|
47
|
-
space,
|
|
48
|
-
typename,
|
|
49
|
-
show: false
|
|
50
|
-
}));
|
|
51
|
-
}
|
|
52
|
-
const generate = createAsyncGenerator(generator, schema, {
|
|
53
|
-
db: space.db
|
|
54
|
-
});
|
|
55
|
-
return generate.createObjects(n);
|
|
56
|
-
};
|
|
16
|
+
// src/components/SchemaTable/SchemaTable.tsx
|
|
17
|
+
import React from "react";
|
|
18
|
+
import { IconButton } from "@dxos/react-ui";
|
|
19
|
+
var SchemaTable = ({ types, objects = {}, label, onClick }) => {
|
|
20
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
21
|
+
className: "grid grid-cols-[1fr_80px_40px] gap-1 overflow-none"
|
|
22
|
+
}, /* @__PURE__ */ React.createElement("h2", {
|
|
23
|
+
className: "p-2"
|
|
24
|
+
}, label), types.map((type) => /* @__PURE__ */ React.createElement("div", {
|
|
25
|
+
key: type.typename,
|
|
26
|
+
className: "grid grid-cols-subgrid col-span-3 items-center"
|
|
27
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
28
|
+
className: "px-2 text-sm font-mono text-subdued"
|
|
29
|
+
}, type.typename), /* @__PURE__ */ React.createElement("div", {
|
|
30
|
+
className: "px-2 text-right font-mono"
|
|
31
|
+
}, objects[type.typename] ?? 0), /* @__PURE__ */ React.createElement(IconButton, {
|
|
32
|
+
variant: "ghost",
|
|
33
|
+
icon: "ph--plus--regular",
|
|
34
|
+
iconOnly: true,
|
|
35
|
+
label: "Create data",
|
|
36
|
+
onClick: () => onClick(type.typename)
|
|
37
|
+
}))));
|
|
57
38
|
};
|
|
58
|
-
var staticGenerators = /* @__PURE__ */ new Map([
|
|
59
|
-
[
|
|
60
|
-
Markdown.Document.typename,
|
|
61
|
-
async (space, n, cb) => {
|
|
62
|
-
const objects = range(n).map(() => {
|
|
63
|
-
return space.db.add(Markdown.make({
|
|
64
|
-
name: faker.commerce.productName(),
|
|
65
|
-
content: faker.lorem.sentences(5)
|
|
66
|
-
}));
|
|
67
|
-
});
|
|
68
|
-
cb?.(objects);
|
|
69
|
-
return objects;
|
|
70
|
-
}
|
|
71
|
-
],
|
|
72
|
-
[
|
|
73
|
-
Diagram.Diagram.typename,
|
|
74
|
-
async (space, n, cb) => {
|
|
75
|
-
const objects = range(n).map(() => {
|
|
76
|
-
const obj = space.db.add(Diagram.make({
|
|
77
|
-
name: faker.commerce.productName()
|
|
78
|
-
}));
|
|
79
|
-
return obj;
|
|
80
|
-
});
|
|
81
|
-
cb?.(objects);
|
|
82
|
-
return objects;
|
|
83
|
-
}
|
|
84
|
-
],
|
|
85
|
-
// TODO(burdon): Create unit tests.
|
|
86
|
-
[
|
|
87
|
-
Sheet.Sheet.typename,
|
|
88
|
-
async (space, n, cb) => {
|
|
89
|
-
const objects = range(n).map(() => {
|
|
90
|
-
const cells = {};
|
|
91
|
-
const year = (/* @__PURE__ */ new Date()).getFullYear();
|
|
92
|
-
const cols = 4;
|
|
93
|
-
const rows = 16;
|
|
94
|
-
for (let col = 1; col <= cols; col++) {
|
|
95
|
-
for (let row = 1; row <= rows; row++) {
|
|
96
|
-
const cell = addressToA1Notation({
|
|
97
|
-
col,
|
|
98
|
-
row
|
|
99
|
-
});
|
|
100
|
-
if (row === 1) {
|
|
101
|
-
cells[cell] = {
|
|
102
|
-
value: `${year} Q${col}`
|
|
103
|
-
};
|
|
104
|
-
} else if (row === rows) {
|
|
105
|
-
const from = addressToA1Notation({
|
|
106
|
-
col,
|
|
107
|
-
row: 2
|
|
108
|
-
});
|
|
109
|
-
const to = addressToA1Notation({
|
|
110
|
-
col,
|
|
111
|
-
row: rows - 1
|
|
112
|
-
});
|
|
113
|
-
cells[cell] = {
|
|
114
|
-
value: `=SUM(${from}:${to})`
|
|
115
|
-
};
|
|
116
|
-
} else if (row > 2 && row < rows - 1) {
|
|
117
|
-
cells[cell] = {
|
|
118
|
-
value: Math.floor(Math.random() * 1e4)
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return space.db.add(Sheet.make({
|
|
124
|
-
name: faker.commerce.productName(),
|
|
125
|
-
cells
|
|
126
|
-
}));
|
|
127
|
-
});
|
|
128
|
-
cb?.(objects);
|
|
129
|
-
return objects;
|
|
130
|
-
}
|
|
131
|
-
],
|
|
132
|
-
[
|
|
133
|
-
ComputeGraph.typename,
|
|
134
|
-
async (space, n, cb) => {
|
|
135
|
-
const objects = range(n, () => {
|
|
136
|
-
const model = ComputeGraphModel.create();
|
|
137
|
-
model.builder.createNode({
|
|
138
|
-
id: "gpt-INPUT",
|
|
139
|
-
type: NODE_INPUT
|
|
140
|
-
}).createNode({
|
|
141
|
-
id: "gpt-GPT",
|
|
142
|
-
type: "gpt"
|
|
143
|
-
}).createNode({
|
|
144
|
-
id: "gpt-QUEUE_ID",
|
|
145
|
-
type: "constant",
|
|
146
|
-
value: new DXN(DXN.kind.QUEUE, [
|
|
147
|
-
"data",
|
|
148
|
-
space.id,
|
|
149
|
-
Key.ObjectId.random()
|
|
150
|
-
]).toString()
|
|
151
|
-
}).createNode({
|
|
152
|
-
id: "gpt-APPEND",
|
|
153
|
-
type: "append"
|
|
154
|
-
}).createNode({
|
|
155
|
-
id: "gpt-OUTPUT",
|
|
156
|
-
type: NODE_OUTPUT
|
|
157
|
-
}).createEdge({
|
|
158
|
-
node: "gpt-INPUT",
|
|
159
|
-
property: "prompt"
|
|
160
|
-
}, {
|
|
161
|
-
node: "gpt-GPT",
|
|
162
|
-
property: "prompt"
|
|
163
|
-
}).createEdge({
|
|
164
|
-
node: "gpt-GPT",
|
|
165
|
-
property: "text"
|
|
166
|
-
}, {
|
|
167
|
-
node: "gpt-OUTPUT",
|
|
168
|
-
property: "text"
|
|
169
|
-
}).createEdge({
|
|
170
|
-
node: "gpt-QUEUE_ID",
|
|
171
|
-
property: DEFAULT_OUTPUT
|
|
172
|
-
}, {
|
|
173
|
-
node: "gpt-APPEND",
|
|
174
|
-
property: "id"
|
|
175
|
-
}).createEdge({
|
|
176
|
-
node: "gpt-GPT",
|
|
177
|
-
property: "messages"
|
|
178
|
-
}, {
|
|
179
|
-
node: "gpt-APPEND",
|
|
180
|
-
property: "items"
|
|
181
|
-
}).createEdge({
|
|
182
|
-
node: "gpt-QUEUE_ID",
|
|
183
|
-
property: DEFAULT_OUTPUT
|
|
184
|
-
}, {
|
|
185
|
-
node: "gpt-OUTPUT",
|
|
186
|
-
property: "queue"
|
|
187
|
-
});
|
|
188
|
-
return space.db.add(model.root);
|
|
189
|
-
});
|
|
190
|
-
cb?.(objects);
|
|
191
|
-
return objects;
|
|
192
|
-
}
|
|
193
|
-
]
|
|
194
|
-
]);
|
|
195
39
|
|
|
196
40
|
// src/components/SpaceGenerator/presets.ts
|
|
197
41
|
import * as Schema from "effect/Schema";
|
|
198
|
-
import {
|
|
42
|
+
import { AgentPrompt, EntityExtraction, ResearchBlueprint } from "@dxos/assistant-toolkit";
|
|
199
43
|
import { Prompt } from "@dxos/blueprints";
|
|
200
|
-
import { NODE_INPUT
|
|
201
|
-
import { DXN
|
|
202
|
-
import { Trigger
|
|
44
|
+
import { NODE_INPUT } from "@dxos/conductor";
|
|
45
|
+
import { DXN, Feed, Filter, JsonSchema, Key, Obj, Query, Ref, Tag } from "@dxos/echo";
|
|
46
|
+
import { Trigger } from "@dxos/functions";
|
|
203
47
|
import { invariant } from "@dxos/invariant";
|
|
204
|
-
import {
|
|
48
|
+
import { Operation } from "@dxos/operation";
|
|
49
|
+
import { InboxOperation } from "@dxos/plugin-inbox";
|
|
205
50
|
import { Mailbox } from "@dxos/plugin-inbox/types";
|
|
206
|
-
import { Markdown
|
|
51
|
+
import { Markdown } from "@dxos/plugin-markdown/types";
|
|
207
52
|
import { createAppend, createChat, createComputeGraph, createConstant, createFunction, createGpt, createQueue, createRandom, createSurface, createTemplate, createText, createTrigger } from "@dxos/react-ui-canvas-compute";
|
|
208
|
-
import {
|
|
209
|
-
import {
|
|
210
|
-
import { Message, Organization, Person,
|
|
211
|
-
import { range
|
|
53
|
+
import { CanvasBoard, CanvasGraphModel, pointMultiply, pointsToRect, rectToPoints } from "@dxos/react-ui-canvas-editor";
|
|
54
|
+
import { ViewModel } from "@dxos/schema";
|
|
55
|
+
import { Message, Organization, Person, Pipeline } from "@dxos/types";
|
|
56
|
+
import { range, trim } from "@dxos/util";
|
|
212
57
|
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-debug/src/components/SpaceGenerator/presets.ts";
|
|
213
58
|
var PresetName = /* @__PURE__ */ (function(PresetName2) {
|
|
214
59
|
PresetName2["DXOS_TEAM"] = "dxos-team";
|
|
@@ -221,9 +66,9 @@ var PresetName = /* @__PURE__ */ (function(PresetName2) {
|
|
|
221
66
|
PresetName2["DISCORD_MESSAGES"] = "discord-messages";
|
|
222
67
|
return PresetName2;
|
|
223
68
|
})({});
|
|
224
|
-
var
|
|
69
|
+
var generator = () => ({
|
|
225
70
|
schemas: [
|
|
226
|
-
|
|
71
|
+
CanvasBoard.CanvasBoard,
|
|
227
72
|
Trigger.Trigger
|
|
228
73
|
],
|
|
229
74
|
types: Object.values(PresetName).map((name) => ({
|
|
@@ -233,12 +78,12 @@ var generator2 = () => ({
|
|
|
233
78
|
[
|
|
234
79
|
"dxos-team",
|
|
235
80
|
async (space, n, cb) => {
|
|
236
|
-
const objects =
|
|
81
|
+
const objects = range(n, () => {
|
|
237
82
|
const org = space.db.add(Obj.make(Organization.Organization, {
|
|
238
83
|
name: "DXOS",
|
|
239
84
|
website: "https://dxos.org"
|
|
240
85
|
}));
|
|
241
|
-
const doc = space.db.add(
|
|
86
|
+
const doc = space.db.add(Markdown.make({
|
|
242
87
|
name: "DXOS Research",
|
|
243
88
|
content: "DXOS builds Composer, an open-source AI-powered malleable application."
|
|
244
89
|
}));
|
|
@@ -246,16 +91,19 @@ var generator2 = () => ({
|
|
|
246
91
|
label: "Investor"
|
|
247
92
|
}));
|
|
248
93
|
const tagDxn = Obj.getDXN(tag).toString();
|
|
249
|
-
Obj.
|
|
250
|
-
|
|
251
|
-
|
|
94
|
+
Obj.change(doc, (obj) => {
|
|
95
|
+
Obj.getMeta(obj).tags = [
|
|
96
|
+
tagDxn
|
|
97
|
+
];
|
|
98
|
+
});
|
|
252
99
|
space.db.add(Obj.make(Person.Person, {
|
|
100
|
+
[Obj.Meta]: {
|
|
101
|
+
tags: [
|
|
102
|
+
tagDxn
|
|
103
|
+
]
|
|
104
|
+
},
|
|
253
105
|
fullName: "Rich",
|
|
254
106
|
organization: Ref.make(org)
|
|
255
|
-
}, {
|
|
256
|
-
tags: [
|
|
257
|
-
tagDxn
|
|
258
|
-
]
|
|
259
107
|
}));
|
|
260
108
|
space.db.add(Obj.make(Person.Person, {
|
|
261
109
|
fullName: "Josiah",
|
|
@@ -278,24 +126,54 @@ var generator2 = () => ({
|
|
|
278
126
|
[
|
|
279
127
|
"org-research-project",
|
|
280
128
|
async (space, n, cb) => {
|
|
281
|
-
const
|
|
282
|
-
const
|
|
129
|
+
const mailboxes = await space.db.query(Filter.type(Mailbox.Mailbox)).run();
|
|
130
|
+
const mailbox = mailboxes[0];
|
|
131
|
+
invariant(mailbox, "Mailbox not found", {
|
|
132
|
+
F: __dxlog_file,
|
|
133
|
+
L: 122,
|
|
134
|
+
S: void 0,
|
|
135
|
+
A: [
|
|
136
|
+
"mailbox",
|
|
137
|
+
"'Mailbox not found'"
|
|
138
|
+
]
|
|
139
|
+
});
|
|
140
|
+
const mailboxFeed = await mailbox.feed?.tryLoad();
|
|
141
|
+
invariant(mailboxFeed, "Mailbox missing feed reference", {
|
|
142
|
+
F: __dxlog_file,
|
|
143
|
+
L: 124,
|
|
144
|
+
S: void 0,
|
|
145
|
+
A: [
|
|
146
|
+
"mailboxFeed",
|
|
147
|
+
"'Mailbox missing feed reference'"
|
|
148
|
+
]
|
|
149
|
+
});
|
|
150
|
+
const queueDxn = Feed.getQueueDxn(mailboxFeed)?.toString();
|
|
151
|
+
invariant(queueDxn, "Mailbox feed missing queue DXN key", {
|
|
152
|
+
F: __dxlog_file,
|
|
153
|
+
L: 126,
|
|
154
|
+
S: void 0,
|
|
155
|
+
A: [
|
|
156
|
+
"queueDxn",
|
|
157
|
+
"'Mailbox feed missing queue DXN key'"
|
|
158
|
+
]
|
|
159
|
+
});
|
|
160
|
+
const tag = await space.db.query(Filter.type(Tag.Tag, {
|
|
283
161
|
label: "Investor"
|
|
284
162
|
})).first();
|
|
285
163
|
const tagDxn = Obj.getDXN(tag).toString();
|
|
286
|
-
const objects =
|
|
287
|
-
const contactsQuery = Query.select(
|
|
288
|
-
const organizationsQuery = Query.select(
|
|
289
|
-
const notesQuery = Query.select(
|
|
164
|
+
const objects = range(n, () => {
|
|
165
|
+
const contactsQuery = Query.select(Filter.type(Person.Person)).select(Filter.tag(tagDxn));
|
|
166
|
+
const organizationsQuery = Query.select(Filter.type(Organization.Organization)).select(Filter.tag(tagDxn));
|
|
167
|
+
const notesQuery = Query.select(Filter.type(Markdown.Document)).select(Filter.tag(tagDxn));
|
|
290
168
|
space.db.add(Trigger.make({
|
|
291
169
|
enabled: true,
|
|
292
170
|
spec: {
|
|
293
171
|
kind: "timer",
|
|
294
172
|
cron: "* * * * *"
|
|
295
173
|
},
|
|
296
|
-
function: Ref.make(
|
|
174
|
+
function: Ref.make(Operation.serialize(InboxOperation.GoogleMailSync)),
|
|
297
175
|
input: {
|
|
298
|
-
|
|
176
|
+
mailbox: Ref.make(mailbox)
|
|
299
177
|
}
|
|
300
178
|
}));
|
|
301
179
|
space.db.add(Trigger.make({
|
|
@@ -303,9 +181,9 @@ var generator2 = () => ({
|
|
|
303
181
|
// TODO(wittjosiah): Queue trigger doesn't support matching query of the column.
|
|
304
182
|
spec: {
|
|
305
183
|
kind: "queue",
|
|
306
|
-
queue:
|
|
184
|
+
queue: queueDxn
|
|
307
185
|
},
|
|
308
|
-
function: Ref.make(
|
|
186
|
+
function: Ref.make(Operation.serialize(EntityExtraction)),
|
|
309
187
|
input: {
|
|
310
188
|
source: "{{event.item}}"
|
|
311
189
|
}
|
|
@@ -325,7 +203,7 @@ var generator2 = () => ({
|
|
|
325
203
|
NOTE: Do mocked reseach (set mockSearch to true).
|
|
326
204
|
`,
|
|
327
205
|
blueprints: [
|
|
328
|
-
Ref.make(ResearchBlueprint)
|
|
206
|
+
Ref.make(ResearchBlueprint.make())
|
|
329
207
|
]
|
|
330
208
|
}));
|
|
331
209
|
space.db.add(Trigger.make({
|
|
@@ -336,37 +214,37 @@ var generator2 = () => ({
|
|
|
336
214
|
ast: organizationsQuery.ast
|
|
337
215
|
}
|
|
338
216
|
},
|
|
339
|
-
function: Ref.make(
|
|
217
|
+
function: Ref.make(Operation.serialize(AgentPrompt)),
|
|
340
218
|
input: {
|
|
341
219
|
prompt: Ref.make(researchPrompt),
|
|
342
220
|
input: "{{event.subject}}"
|
|
343
221
|
}
|
|
344
222
|
}));
|
|
345
|
-
const mailboxView =
|
|
346
|
-
query: Query.select(
|
|
223
|
+
const mailboxView = ViewModel.make({
|
|
224
|
+
query: Query.select(Filter.type(Message.Message, {
|
|
347
225
|
properties: {
|
|
348
|
-
labels:
|
|
226
|
+
labels: Filter.contains("investor")
|
|
349
227
|
}
|
|
350
|
-
})).
|
|
228
|
+
})).from({
|
|
351
229
|
queues: [
|
|
352
|
-
|
|
230
|
+
queueDxn
|
|
353
231
|
]
|
|
354
232
|
}),
|
|
355
|
-
jsonSchema:
|
|
233
|
+
jsonSchema: JsonSchema.toJsonSchema(Message.Message)
|
|
356
234
|
});
|
|
357
|
-
const contactsView =
|
|
235
|
+
const contactsView = ViewModel.make({
|
|
358
236
|
query: contactsQuery,
|
|
359
|
-
jsonSchema:
|
|
237
|
+
jsonSchema: JsonSchema.toJsonSchema(Person.Person)
|
|
360
238
|
});
|
|
361
|
-
const organizationsView =
|
|
239
|
+
const organizationsView = ViewModel.make({
|
|
362
240
|
query: organizationsQuery,
|
|
363
|
-
jsonSchema:
|
|
241
|
+
jsonSchema: JsonSchema.toJsonSchema(Organization.Organization)
|
|
364
242
|
});
|
|
365
|
-
const notesView =
|
|
243
|
+
const notesView = ViewModel.make({
|
|
366
244
|
query: notesQuery,
|
|
367
|
-
jsonSchema:
|
|
245
|
+
jsonSchema: JsonSchema.toJsonSchema(Markdown.Document)
|
|
368
246
|
});
|
|
369
|
-
return space.db.add(
|
|
247
|
+
return space.db.add(Pipeline.make({
|
|
370
248
|
name: "Investor Research",
|
|
371
249
|
columns: [
|
|
372
250
|
{
|
|
@@ -399,7 +277,7 @@ var generator2 = () => ({
|
|
|
399
277
|
[
|
|
400
278
|
"webhook-gpt-queue",
|
|
401
279
|
async (space, n, cb) => {
|
|
402
|
-
const objects =
|
|
280
|
+
const objects = range(n, () => {
|
|
403
281
|
const canvasModel = CanvasGraphModel.create();
|
|
404
282
|
let functionTrigger;
|
|
405
283
|
canvasModel.builder.call((builder) => {
|
|
@@ -459,9 +337,9 @@ var generator2 = () => ({
|
|
|
459
337
|
[
|
|
460
338
|
"objectChange-queue",
|
|
461
339
|
async (space, n, cb) => {
|
|
462
|
-
const objects =
|
|
340
|
+
const objects = range(n, () => {
|
|
463
341
|
const { canvasModel, computeModel } = createQueueSinkPreset(space, "subscription", (triggerSpec) => triggerSpec.query = {
|
|
464
|
-
ast: Query.select(
|
|
342
|
+
ast: Query.select(Filter.typename("org.dxos.type.chess")).ast
|
|
465
343
|
}, "type");
|
|
466
344
|
return addToSpace("objectChange-queue", space, canvasModel, computeModel);
|
|
467
345
|
});
|
|
@@ -472,7 +350,7 @@ var generator2 = () => ({
|
|
|
472
350
|
[
|
|
473
351
|
"timerTick-queue",
|
|
474
352
|
async (space, n, cb) => {
|
|
475
|
-
const objects =
|
|
353
|
+
const objects = range(n, () => {
|
|
476
354
|
const { canvasModel, computeModel } = createQueueSinkPreset(space, "timer", (triggerSpec) => triggerSpec.cron = "*/5 * * * * *", "result");
|
|
477
355
|
return addToSpace("timerTick-queue", space, canvasModel, computeModel);
|
|
478
356
|
});
|
|
@@ -527,7 +405,7 @@ var generator2 = () => ({
|
|
|
527
405
|
// const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
|
|
528
406
|
// invariant(templateComputeNode, 'Template compute node was not created.');
|
|
529
407
|
// templateComputeNode.value = templateContent.join('\n');
|
|
530
|
-
// templateComputeNode.inputSchema =
|
|
408
|
+
// templateComputeNode.inputSchema = JsonSchema.toJsonSchema(EmailTriggerOutput);
|
|
531
409
|
// attachTrigger(functionTrigger, computeModel);
|
|
532
410
|
// return addToSpace(PresetName.EMAIL_TABLE, space, canvasModel, computeModel);
|
|
533
411
|
// });
|
|
@@ -538,7 +416,7 @@ var generator2 = () => ({
|
|
|
538
416
|
[
|
|
539
417
|
"chat-gpt-text",
|
|
540
418
|
async (space, n, cb) => {
|
|
541
|
-
const objects =
|
|
419
|
+
const objects = range(n, () => {
|
|
542
420
|
const canvasModel = CanvasGraphModel.create();
|
|
543
421
|
canvasModel.builder.call((builder) => {
|
|
544
422
|
const gpt = canvasModel.createNode(createGpt(position({
|
|
@@ -658,7 +536,7 @@ var generator2 = () => ({
|
|
|
658
536
|
// invariant(templateComputeNode, 'Template compute node was not created.');
|
|
659
537
|
// templateComputeNode.value = templateContent.join('\n');
|
|
660
538
|
// const extendedSchema = Schema.extend(EmailTriggerOutput, Schema.Struct({ text: Schema.String }));
|
|
661
|
-
// templateComputeNode.inputSchema =
|
|
539
|
+
// templateComputeNode.inputSchema = JsonSchema.toJsonSchema(extendedSchema);
|
|
662
540
|
// attachTrigger(functionTrigger, computeModel);
|
|
663
541
|
// return addToSpace(PresetName.EMAIL_WITH_SUMMARY, space, canvasModel, computeModel);
|
|
664
542
|
// });
|
|
@@ -669,7 +547,7 @@ var generator2 = () => ({
|
|
|
669
547
|
[
|
|
670
548
|
"forex-function-call",
|
|
671
549
|
async (space, n, cb) => {
|
|
672
|
-
const objects =
|
|
550
|
+
const objects = range(n, () => {
|
|
673
551
|
const canvasModel = CanvasGraphModel.create();
|
|
674
552
|
canvasModel.builder.call((builder) => {
|
|
675
553
|
const sourceCurrency = canvasModel.createNode(createConstant({
|
|
@@ -718,7 +596,7 @@ var generator2 = () => ({
|
|
|
718
596
|
[
|
|
719
597
|
"discord-messages",
|
|
720
598
|
async (space, n, cb) => {
|
|
721
|
-
const objects =
|
|
599
|
+
const objects = range(n, () => {
|
|
722
600
|
const canvasModel = CanvasGraphModel.create();
|
|
723
601
|
let functionTrigger;
|
|
724
602
|
canvasModel.builder.call((builder) => {
|
|
@@ -739,10 +617,10 @@ var generator2 = () => ({
|
|
|
739
617
|
})
|
|
740
618
|
}));
|
|
741
619
|
const queueId = canvasModel.createNode(createConstant({
|
|
742
|
-
value: new
|
|
620
|
+
value: new DXN(DXN.kind.QUEUE, [
|
|
743
621
|
"data",
|
|
744
622
|
space.id,
|
|
745
|
-
|
|
623
|
+
Key.ObjectId.random()
|
|
746
624
|
]).toString(),
|
|
747
625
|
...position({
|
|
748
626
|
x: -10,
|
|
@@ -860,20 +738,22 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
|
|
|
860
738
|
const triggerSpec = functionTrigger.spec;
|
|
861
739
|
invariant(triggerSpec && triggerSpec.kind === triggerKind, "No trigger spec.", {
|
|
862
740
|
F: __dxlog_file,
|
|
863
|
-
L:
|
|
741
|
+
L: 765,
|
|
864
742
|
S: void 0,
|
|
865
743
|
A: [
|
|
866
744
|
"triggerSpec && triggerSpec.kind === triggerKind",
|
|
867
745
|
"'No trigger spec.'"
|
|
868
746
|
]
|
|
869
747
|
});
|
|
870
|
-
|
|
748
|
+
Obj.change(functionTrigger, (ft) => {
|
|
749
|
+
initSpec(ft.spec);
|
|
750
|
+
});
|
|
871
751
|
});
|
|
872
752
|
const computeModel = createComputeGraph(canvasModel);
|
|
873
753
|
const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
|
|
874
754
|
invariant(templateComputeNode, "Template compute node was not created.", {
|
|
875
755
|
F: __dxlog_file,
|
|
876
|
-
L:
|
|
756
|
+
L: 774,
|
|
877
757
|
S: void 0,
|
|
878
758
|
A: [
|
|
879
759
|
"templateComputeNode",
|
|
@@ -886,7 +766,7 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
|
|
|
886
766
|
' "id": "@{{changeId}}"',
|
|
887
767
|
"}"
|
|
888
768
|
].join("\n");
|
|
889
|
-
templateComputeNode.inputSchema =
|
|
769
|
+
templateComputeNode.inputSchema = JsonSchema.toJsonSchema(Schema.Struct({
|
|
890
770
|
type: Schema.String,
|
|
891
771
|
changeId: Schema.String
|
|
892
772
|
}));
|
|
@@ -897,7 +777,7 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
|
|
|
897
777
|
};
|
|
898
778
|
};
|
|
899
779
|
var addToSpace = (name, space, canvas, compute) => {
|
|
900
|
-
return space.db.add(Obj.make(
|
|
780
|
+
return space.db.add(Obj.make(CanvasBoard.CanvasBoard, {
|
|
901
781
|
name,
|
|
902
782
|
computeGraph: Ref.make(compute.root),
|
|
903
783
|
layout: canvas.graph
|
|
@@ -905,10 +785,10 @@ var addToSpace = (name, space, canvas, compute) => {
|
|
|
905
785
|
};
|
|
906
786
|
var setupQueue = (space, canvasModel, args) => {
|
|
907
787
|
const queueId = canvasModel.createNode(createConstant({
|
|
908
|
-
value: new
|
|
788
|
+
value: new DXN(DXN.kind.QUEUE, [
|
|
909
789
|
"data",
|
|
910
790
|
space.id,
|
|
911
|
-
|
|
791
|
+
Key.ObjectId.random()
|
|
912
792
|
]).toString(),
|
|
913
793
|
...args?.idPosition ? rawPosition(args.idPosition) : position({
|
|
914
794
|
x: -18,
|
|
@@ -935,16 +815,18 @@ var setupQueue = (space, canvasModel, args) => {
|
|
|
935
815
|
var attachTrigger = (functionTrigger, computeModel) => {
|
|
936
816
|
invariant(functionTrigger, void 0, {
|
|
937
817
|
F: __dxlog_file,
|
|
938
|
-
L:
|
|
818
|
+
L: 816,
|
|
939
819
|
S: void 0,
|
|
940
820
|
A: [
|
|
941
821
|
"functionTrigger",
|
|
942
822
|
""
|
|
943
823
|
]
|
|
944
824
|
});
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
825
|
+
const inputNode = computeModel.nodes.find((node) => node.type === NODE_INPUT);
|
|
826
|
+
Obj.change(functionTrigger, (obj) => {
|
|
827
|
+
obj.function = Ref.make(computeModel.root);
|
|
828
|
+
obj.inputNodeId = inputNode.id;
|
|
829
|
+
});
|
|
948
830
|
};
|
|
949
831
|
var rawPosition = (args) => {
|
|
950
832
|
return {
|
|
@@ -990,163 +872,312 @@ var position = (rect) => {
|
|
|
990
872
|
}
|
|
991
873
|
};
|
|
992
874
|
|
|
993
|
-
// src/components/SpaceGenerator/
|
|
994
|
-
import {
|
|
995
|
-
import
|
|
996
|
-
import {
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
}, type.typename), /* @__PURE__ */ React.createElement("div", {
|
|
1010
|
-
className: "pli-2 text-right font-mono"
|
|
1011
|
-
}, objects[type.typename] ?? 0), /* @__PURE__ */ React.createElement(IconButton, {
|
|
1012
|
-
variant: "ghost",
|
|
1013
|
-
icon: "ph--plus--regular",
|
|
1014
|
-
iconOnly: true,
|
|
1015
|
-
label: "Create data",
|
|
1016
|
-
onClick: () => onClick(type.typename)
|
|
1017
|
-
}))));
|
|
1018
|
-
} finally {
|
|
1019
|
-
_effect.f();
|
|
1020
|
-
}
|
|
875
|
+
// src/components/SpaceGenerator/ObjectGenerator.tsx
|
|
876
|
+
import { addressToA1Notation } from "@dxos/compute";
|
|
877
|
+
import { ComputeGraph, ComputeGraphModel, DEFAULT_OUTPUT, NODE_INPUT as NODE_INPUT2, NODE_OUTPUT } from "@dxos/conductor";
|
|
878
|
+
import { DXN as DXN2, Filter as Filter2, Key as Key2 } from "@dxos/echo";
|
|
879
|
+
import { View } from "@dxos/echo";
|
|
880
|
+
import { Markdown as Markdown2 } from "@dxos/plugin-markdown/types";
|
|
881
|
+
import { Sheet } from "@dxos/plugin-sheet/types";
|
|
882
|
+
import { Sketch } from "@dxos/plugin-sketch/types";
|
|
883
|
+
import { SpaceOperation } from "@dxos/plugin-space/operations";
|
|
884
|
+
import { faker } from "@dxos/random";
|
|
885
|
+
import { getTypenameFromQuery } from "@dxos/schema";
|
|
886
|
+
import { createAsyncGenerator } from "@dxos/schema/testing";
|
|
887
|
+
import { range as range2 } from "@dxos/util";
|
|
888
|
+
var generator2 = faker;
|
|
889
|
+
var findViewByTypename = async (views, typename) => {
|
|
890
|
+
return views.find((view) => getTypenameFromQuery(view.query.ast) === typename);
|
|
1021
891
|
};
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
const
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
892
|
+
var createGenerator = (client, invokePromise, schema) => {
|
|
893
|
+
return async (space, n) => {
|
|
894
|
+
const typename = schema.typename;
|
|
895
|
+
const views = await space.db.query(Filter2.type(View.View)).run();
|
|
896
|
+
const view = await findViewByTypename(views, typename);
|
|
897
|
+
const staticSchema = client?.graph.schemaRegistry.query({
|
|
898
|
+
typename
|
|
899
|
+
}).runSync()[0];
|
|
900
|
+
if (!view && !staticSchema) {
|
|
901
|
+
await invokePromise(SpaceOperation.AddSchema, {
|
|
902
|
+
db: space.db,
|
|
903
|
+
schema,
|
|
904
|
+
show: false
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
const generate = createAsyncGenerator(generator2, schema, {
|
|
908
|
+
db: space.db
|
|
909
|
+
});
|
|
910
|
+
return generate.createObjects(n);
|
|
911
|
+
};
|
|
912
|
+
};
|
|
913
|
+
var staticGenerators = /* @__PURE__ */ new Map([
|
|
914
|
+
[
|
|
915
|
+
Markdown2.Document.typename,
|
|
916
|
+
async (space, n, cb) => {
|
|
917
|
+
const objects = range2(n).map(() => {
|
|
918
|
+
return space.db.add(Markdown2.make({
|
|
919
|
+
name: faker.commerce.productName(),
|
|
920
|
+
content: faker.lorem.sentences(5)
|
|
921
|
+
}));
|
|
922
|
+
});
|
|
923
|
+
cb?.(objects);
|
|
924
|
+
return objects;
|
|
925
|
+
}
|
|
926
|
+
],
|
|
927
|
+
[
|
|
928
|
+
Sketch.Sketch.typename,
|
|
929
|
+
async (space, n, cb) => {
|
|
930
|
+
const objects = range2(n).map(() => {
|
|
931
|
+
const obj = space.db.add(Sketch.make({
|
|
932
|
+
name: faker.commerce.productName()
|
|
933
|
+
}));
|
|
934
|
+
return obj;
|
|
935
|
+
});
|
|
936
|
+
cb?.(objects);
|
|
937
|
+
return objects;
|
|
938
|
+
}
|
|
939
|
+
],
|
|
940
|
+
// TODO(burdon): Create unit tests.
|
|
941
|
+
[
|
|
942
|
+
Sheet.Sheet.typename,
|
|
943
|
+
async (space, n, cb) => {
|
|
944
|
+
const objects = range2(n).map(() => {
|
|
945
|
+
const cells = {};
|
|
946
|
+
const year = (/* @__PURE__ */ new Date()).getFullYear();
|
|
947
|
+
const cols = 4;
|
|
948
|
+
const rows = 16;
|
|
949
|
+
for (let col = 1; col <= cols; col++) {
|
|
950
|
+
for (let row = 1; row <= rows; row++) {
|
|
951
|
+
const cell = addressToA1Notation({
|
|
952
|
+
col,
|
|
953
|
+
row
|
|
954
|
+
});
|
|
955
|
+
if (row === 1) {
|
|
956
|
+
cells[cell] = {
|
|
957
|
+
value: `${year} Q${col}`
|
|
958
|
+
};
|
|
959
|
+
} else if (row === rows) {
|
|
960
|
+
const from = addressToA1Notation({
|
|
961
|
+
col,
|
|
962
|
+
row: 2
|
|
963
|
+
});
|
|
964
|
+
const to = addressToA1Notation({
|
|
965
|
+
col,
|
|
966
|
+
row: rows - 1
|
|
967
|
+
});
|
|
968
|
+
cells[cell] = {
|
|
969
|
+
value: `=SUM(${from}:${to})`
|
|
970
|
+
};
|
|
971
|
+
} else if (row > 2 && row < rows - 1) {
|
|
972
|
+
cells[cell] = {
|
|
973
|
+
value: Math.floor(Math.random() * 1e4)
|
|
974
|
+
};
|
|
975
|
+
}
|
|
976
|
+
}
|
|
1071
977
|
}
|
|
1072
|
-
return
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
static: staticSchema.length,
|
|
1077
|
-
mutable: echoSchema.length
|
|
1078
|
-
},
|
|
1079
|
-
objects: objectMap
|
|
978
|
+
return space.db.add(Sheet.make({
|
|
979
|
+
name: faker.commerce.productName(),
|
|
980
|
+
cells
|
|
981
|
+
}));
|
|
1080
982
|
});
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
983
|
+
cb?.(objects);
|
|
984
|
+
return objects;
|
|
985
|
+
}
|
|
986
|
+
],
|
|
987
|
+
[
|
|
988
|
+
ComputeGraph.typename,
|
|
989
|
+
async (space, n, cb) => {
|
|
990
|
+
const objects = range2(n, () => {
|
|
991
|
+
const model = ComputeGraphModel.create();
|
|
992
|
+
model.builder.createNode({
|
|
993
|
+
id: "gpt-INPUT",
|
|
994
|
+
type: NODE_INPUT2
|
|
995
|
+
}).createNode({
|
|
996
|
+
id: "gpt-GPT",
|
|
997
|
+
type: "gpt"
|
|
998
|
+
}).createNode({
|
|
999
|
+
id: "gpt-QUEUE_ID",
|
|
1000
|
+
type: "constant",
|
|
1001
|
+
value: new DXN2(DXN2.kind.QUEUE, [
|
|
1002
|
+
"data",
|
|
1003
|
+
space.id,
|
|
1004
|
+
Key2.ObjectId.random()
|
|
1005
|
+
]).toString()
|
|
1006
|
+
}).createNode({
|
|
1007
|
+
id: "gpt-APPEND",
|
|
1008
|
+
type: "append"
|
|
1009
|
+
}).createNode({
|
|
1010
|
+
id: "gpt-OUTPUT",
|
|
1011
|
+
type: NODE_OUTPUT
|
|
1012
|
+
}).createEdge({
|
|
1013
|
+
node: "gpt-INPUT",
|
|
1014
|
+
property: "prompt"
|
|
1015
|
+
}, {
|
|
1016
|
+
node: "gpt-GPT",
|
|
1017
|
+
property: "prompt"
|
|
1018
|
+
}).createEdge({
|
|
1019
|
+
node: "gpt-GPT",
|
|
1020
|
+
property: "text"
|
|
1021
|
+
}, {
|
|
1022
|
+
node: "gpt-OUTPUT",
|
|
1023
|
+
property: "text"
|
|
1024
|
+
}).createEdge({
|
|
1025
|
+
node: "gpt-QUEUE_ID",
|
|
1026
|
+
property: DEFAULT_OUTPUT
|
|
1027
|
+
}, {
|
|
1028
|
+
node: "gpt-APPEND",
|
|
1029
|
+
property: "id"
|
|
1030
|
+
}).createEdge({
|
|
1031
|
+
node: "gpt-GPT",
|
|
1032
|
+
property: "messages"
|
|
1033
|
+
}, {
|
|
1034
|
+
node: "gpt-APPEND",
|
|
1035
|
+
property: "items"
|
|
1036
|
+
}).createEdge({
|
|
1037
|
+
node: "gpt-QUEUE_ID",
|
|
1038
|
+
property: DEFAULT_OUTPUT
|
|
1039
|
+
}, {
|
|
1040
|
+
node: "gpt-OUTPUT",
|
|
1041
|
+
property: "queue"
|
|
1042
|
+
});
|
|
1043
|
+
return space.db.add(model.root);
|
|
1044
|
+
});
|
|
1045
|
+
cb?.(objects);
|
|
1046
|
+
return objects;
|
|
1047
|
+
}
|
|
1048
|
+
]
|
|
1049
|
+
]);
|
|
1050
|
+
|
|
1051
|
+
// src/containers/SpaceGenerator/SpaceGenerator.tsx
|
|
1052
|
+
var SpaceGenerator = composable(({ space, onCreateObjects, children, ...props }, forwardedRef) => {
|
|
1053
|
+
const { invokePromise } = useOperationInvoker();
|
|
1054
|
+
const client = useClient();
|
|
1055
|
+
const staticTypes = [
|
|
1056
|
+
Markdown3.Document,
|
|
1057
|
+
Sketch2.Sketch,
|
|
1058
|
+
Sheet2.Sheet,
|
|
1059
|
+
ComputeGraph2
|
|
1060
|
+
];
|
|
1061
|
+
const recordTypes = [
|
|
1062
|
+
Organization2.Organization,
|
|
1063
|
+
Person2.Person,
|
|
1064
|
+
Task.Task
|
|
1065
|
+
];
|
|
1066
|
+
const [count, setCount] = useState(1);
|
|
1067
|
+
const [info, setInfo] = useState({});
|
|
1068
|
+
const presets = useMemo(() => generator(), []);
|
|
1069
|
+
useAsyncEffect(async () => {
|
|
1070
|
+
await client.addTypes([
|
|
1071
|
+
...staticTypes,
|
|
1072
|
+
...recordTypes,
|
|
1073
|
+
...presets.schemas
|
|
1084
1074
|
]);
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1075
|
+
}, [
|
|
1076
|
+
client
|
|
1077
|
+
]);
|
|
1078
|
+
const typeMap = useMemo(() => {
|
|
1079
|
+
const recordGenerators = new Map(recordTypes.map((type) => [
|
|
1080
|
+
type.typename,
|
|
1081
|
+
createGenerator(client, invokePromise, type)
|
|
1082
|
+
]));
|
|
1083
|
+
return new Map([
|
|
1084
|
+
...staticGenerators,
|
|
1085
|
+
...presets.items,
|
|
1086
|
+
...recordGenerators
|
|
1094
1087
|
]);
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
}
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1088
|
+
}, [
|
|
1089
|
+
client,
|
|
1090
|
+
recordTypes,
|
|
1091
|
+
invokePromise
|
|
1092
|
+
]);
|
|
1093
|
+
const updateInfo = async () => {
|
|
1094
|
+
const echoSchema = await space.db.schemaRegistry.query().run();
|
|
1095
|
+
const staticSchema = await space.db.graph.schemaRegistry.query().run();
|
|
1096
|
+
const objects = await space.db.query(Filter3.everything()).run();
|
|
1097
|
+
const objectMap = sortKeys(objects.reduce((map, obj) => {
|
|
1098
|
+
const type = Obj2.getTypename(obj);
|
|
1099
|
+
if (type) {
|
|
1100
|
+
const count2 = map[type] ?? 0;
|
|
1101
|
+
map[type] = count2 + 1;
|
|
1102
|
+
}
|
|
1103
|
+
return map;
|
|
1104
|
+
}, {}));
|
|
1105
|
+
setInfo({
|
|
1106
|
+
schema: {
|
|
1107
|
+
static: staticSchema.length,
|
|
1108
|
+
mutable: echoSchema.length
|
|
1109
|
+
},
|
|
1110
|
+
objects: objectMap
|
|
1111
|
+
});
|
|
1112
|
+
};
|
|
1113
|
+
useAsyncEffect(updateInfo, [
|
|
1114
|
+
space
|
|
1115
|
+
]);
|
|
1116
|
+
const handleCreateData = useCallback(async (typename) => {
|
|
1117
|
+
const constructor = typeMap.get(typename);
|
|
1118
|
+
if (constructor) {
|
|
1119
|
+
await constructor(space, count, onCreateObjects);
|
|
1120
|
+
await updateInfo();
|
|
1121
|
+
}
|
|
1122
|
+
}, [
|
|
1123
|
+
typeMap,
|
|
1124
|
+
count
|
|
1125
|
+
]);
|
|
1126
|
+
return /* @__PURE__ */ React2.createElement(Panel.Root, {
|
|
1127
|
+
...composableProps(props),
|
|
1128
|
+
ref: forwardedRef
|
|
1129
|
+
}, /* @__PURE__ */ React2.createElement(Panel.Toolbar, {
|
|
1130
|
+
asChild: true
|
|
1131
|
+
}, /* @__PURE__ */ React2.createElement(Toolbar.Root, null, /* @__PURE__ */ React2.createElement(IconButton2, {
|
|
1132
|
+
icon: "ph--arrow-clockwise--regular",
|
|
1133
|
+
iconOnly: true,
|
|
1134
|
+
label: "Refresh",
|
|
1135
|
+
onClick: updateInfo
|
|
1136
|
+
}), /* @__PURE__ */ React2.createElement(Toolbar.Separator, null), /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
1137
|
+
type: "number",
|
|
1138
|
+
placeholder: "Count",
|
|
1139
|
+
classNames: "w-[4rem] text-right",
|
|
1140
|
+
min: 1,
|
|
1141
|
+
max: 100,
|
|
1142
|
+
size: 8,
|
|
1143
|
+
value: count,
|
|
1144
|
+
onChange: (event) => setCount(parseInt(event.target.value))
|
|
1145
|
+
})))), /* @__PURE__ */ React2.createElement(Panel.Content, {
|
|
1146
|
+
asChild: true
|
|
1147
|
+
}, /* @__PURE__ */ React2.createElement(ScrollArea.Root, {
|
|
1148
|
+
thin: true,
|
|
1149
|
+
orientation: "vertical"
|
|
1150
|
+
}, /* @__PURE__ */ React2.createElement(ScrollArea.Viewport, {
|
|
1151
|
+
classNames: "gap-4 divide-y divide-subdued-separator"
|
|
1152
|
+
}, /* @__PURE__ */ React2.createElement(SchemaTable, {
|
|
1153
|
+
types: staticTypes,
|
|
1154
|
+
objects: info.objects,
|
|
1155
|
+
label: "Static Types",
|
|
1156
|
+
onClick: handleCreateData
|
|
1157
|
+
}), /* @__PURE__ */ React2.createElement(SchemaTable, {
|
|
1158
|
+
types: recordTypes,
|
|
1159
|
+
objects: info.objects,
|
|
1160
|
+
label: "Record Types",
|
|
1161
|
+
onClick: handleCreateData
|
|
1162
|
+
}), /* @__PURE__ */ React2.createElement(SchemaTable, {
|
|
1163
|
+
types: presets.types,
|
|
1164
|
+
objects: info.objects,
|
|
1165
|
+
label: "Presets",
|
|
1166
|
+
onClick: handleCreateData
|
|
1167
|
+
}), /* @__PURE__ */ React2.createElement(SyntaxHighlighter, {
|
|
1168
|
+
language: "json",
|
|
1169
|
+
classNames: "text-xs"
|
|
1170
|
+
}, JSON.stringify({
|
|
1171
|
+
space,
|
|
1172
|
+
...info
|
|
1173
|
+
}, jsonKeyReplacer({
|
|
1174
|
+
truncate: true
|
|
1175
|
+
}), 2))))));
|
|
1176
|
+
});
|
|
1146
1177
|
|
|
1147
|
-
// src/
|
|
1178
|
+
// src/containers/SpaceGenerator/index.ts
|
|
1148
1179
|
var SpaceGenerator_default = SpaceGenerator;
|
|
1149
1180
|
export {
|
|
1150
1181
|
SpaceGenerator_default as default
|
|
1151
1182
|
};
|
|
1152
|
-
//# sourceMappingURL=SpaceGenerator-
|
|
1183
|
+
//# sourceMappingURL=SpaceGenerator-UUQS6TYY.mjs.map
|