@dxos/plugin-debug 0.8.4-main.72ec0f3 → 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-46TAISVE.mjs → SpaceGenerator-UUQS6TYY.mjs} +455 -425
- 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 -4
- 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 +196 -75
- 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-46TAISVE.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-2SNVZDEA.mjs +0 -774
- package/dist/lib/browser/react-surface-2SNVZDEA.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,215 +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
|
-
import { Filter as Filter3 } from "@dxos/echo";
|
|
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 {
|
|
12
|
-
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";
|
|
13
11
|
import { SyntaxHighlighter } from "@dxos/react-ui-syntax-highlighter";
|
|
14
12
|
import { Organization as Organization2, Person as Person2, Task } from "@dxos/types";
|
|
13
|
+
import { composable, composableProps } from "@dxos/ui-theme";
|
|
15
14
|
import { jsonKeyReplacer, sortKeys } from "@dxos/util";
|
|
16
15
|
|
|
17
|
-
// src/components/
|
|
18
|
-
import
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const staticSchema = client?.graph.schemaRegistry.schemas.find((schema2) => Type.getTypename(schema2) === typename);
|
|
40
|
-
if (!view && !staticSchema) {
|
|
41
|
-
await dispatch(createIntent(SpaceAction.AddSchema, {
|
|
42
|
-
space,
|
|
43
|
-
schema,
|
|
44
|
-
show: false
|
|
45
|
-
}));
|
|
46
|
-
} else if (!view && staticSchema) {
|
|
47
|
-
await dispatch(createIntent(SpaceAction.UseStaticSchema, {
|
|
48
|
-
space,
|
|
49
|
-
typename,
|
|
50
|
-
show: false
|
|
51
|
-
}));
|
|
52
|
-
}
|
|
53
|
-
const generate = createAsyncGenerator(generator, schema, {
|
|
54
|
-
db: space.db
|
|
55
|
-
});
|
|
56
|
-
return generate.createObjects(n);
|
|
57
|
-
};
|
|
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
|
+
}))));
|
|
58
38
|
};
|
|
59
|
-
var staticGenerators = /* @__PURE__ */ new Map([
|
|
60
|
-
[
|
|
61
|
-
Markdown.Document.typename,
|
|
62
|
-
async (space, n, cb) => {
|
|
63
|
-
const objects = range(n).map(() => {
|
|
64
|
-
return space.db.add(Markdown.make({
|
|
65
|
-
name: faker.commerce.productName(),
|
|
66
|
-
content: faker.lorem.sentences(5)
|
|
67
|
-
}));
|
|
68
|
-
});
|
|
69
|
-
cb?.(objects);
|
|
70
|
-
return objects;
|
|
71
|
-
}
|
|
72
|
-
],
|
|
73
|
-
[
|
|
74
|
-
Diagram.Diagram.typename,
|
|
75
|
-
async (space, n, cb) => {
|
|
76
|
-
const objects = range(n).map(() => {
|
|
77
|
-
const obj = space.db.add(Diagram.make({
|
|
78
|
-
name: faker.commerce.productName()
|
|
79
|
-
}));
|
|
80
|
-
return obj;
|
|
81
|
-
});
|
|
82
|
-
cb?.(objects);
|
|
83
|
-
return objects;
|
|
84
|
-
}
|
|
85
|
-
],
|
|
86
|
-
// TODO(burdon): Create unit tests.
|
|
87
|
-
[
|
|
88
|
-
Sheet.Sheet.typename,
|
|
89
|
-
async (space, n, cb) => {
|
|
90
|
-
const objects = range(n).map(() => {
|
|
91
|
-
const cells = {};
|
|
92
|
-
const year = (/* @__PURE__ */ new Date()).getFullYear();
|
|
93
|
-
const cols = 4;
|
|
94
|
-
const rows = 16;
|
|
95
|
-
for (let col = 1; col <= cols; col++) {
|
|
96
|
-
for (let row = 1; row <= rows; row++) {
|
|
97
|
-
const cell = addressToA1Notation({
|
|
98
|
-
col,
|
|
99
|
-
row
|
|
100
|
-
});
|
|
101
|
-
if (row === 1) {
|
|
102
|
-
cells[cell] = {
|
|
103
|
-
value: `${year} Q${col}`
|
|
104
|
-
};
|
|
105
|
-
} else if (row === rows) {
|
|
106
|
-
const from = addressToA1Notation({
|
|
107
|
-
col,
|
|
108
|
-
row: 2
|
|
109
|
-
});
|
|
110
|
-
const to = addressToA1Notation({
|
|
111
|
-
col,
|
|
112
|
-
row: rows - 1
|
|
113
|
-
});
|
|
114
|
-
cells[cell] = {
|
|
115
|
-
value: `=SUM(${from}:${to})`
|
|
116
|
-
};
|
|
117
|
-
} else if (row > 2 && row < rows - 1) {
|
|
118
|
-
cells[cell] = {
|
|
119
|
-
value: Math.floor(Math.random() * 1e4)
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return space.db.add(Sheet.make({
|
|
125
|
-
name: faker.commerce.productName(),
|
|
126
|
-
cells
|
|
127
|
-
}));
|
|
128
|
-
});
|
|
129
|
-
cb?.(objects);
|
|
130
|
-
return objects;
|
|
131
|
-
}
|
|
132
|
-
],
|
|
133
|
-
[
|
|
134
|
-
ComputeGraph.typename,
|
|
135
|
-
async (space, n, cb) => {
|
|
136
|
-
const objects = range(n, () => {
|
|
137
|
-
const model = ComputeGraphModel.create();
|
|
138
|
-
model.builder.createNode({
|
|
139
|
-
id: "gpt-INPUT",
|
|
140
|
-
type: NODE_INPUT
|
|
141
|
-
}).createNode({
|
|
142
|
-
id: "gpt-GPT",
|
|
143
|
-
type: "gpt"
|
|
144
|
-
}).createNode({
|
|
145
|
-
id: "gpt-QUEUE_ID",
|
|
146
|
-
type: "constant",
|
|
147
|
-
value: new DXN(DXN.kind.QUEUE, [
|
|
148
|
-
"data",
|
|
149
|
-
space.id,
|
|
150
|
-
Key.ObjectId.random()
|
|
151
|
-
]).toString()
|
|
152
|
-
}).createNode({
|
|
153
|
-
id: "gpt-APPEND",
|
|
154
|
-
type: "append"
|
|
155
|
-
}).createNode({
|
|
156
|
-
id: "gpt-OUTPUT",
|
|
157
|
-
type: NODE_OUTPUT
|
|
158
|
-
}).createEdge({
|
|
159
|
-
node: "gpt-INPUT",
|
|
160
|
-
property: "prompt"
|
|
161
|
-
}, {
|
|
162
|
-
node: "gpt-GPT",
|
|
163
|
-
property: "prompt"
|
|
164
|
-
}).createEdge({
|
|
165
|
-
node: "gpt-GPT",
|
|
166
|
-
property: "text"
|
|
167
|
-
}, {
|
|
168
|
-
node: "gpt-OUTPUT",
|
|
169
|
-
property: "text"
|
|
170
|
-
}).createEdge({
|
|
171
|
-
node: "gpt-QUEUE_ID",
|
|
172
|
-
property: DEFAULT_OUTPUT
|
|
173
|
-
}, {
|
|
174
|
-
node: "gpt-APPEND",
|
|
175
|
-
property: "id"
|
|
176
|
-
}).createEdge({
|
|
177
|
-
node: "gpt-GPT",
|
|
178
|
-
property: "messages"
|
|
179
|
-
}, {
|
|
180
|
-
node: "gpt-APPEND",
|
|
181
|
-
property: "items"
|
|
182
|
-
}).createEdge({
|
|
183
|
-
node: "gpt-QUEUE_ID",
|
|
184
|
-
property: DEFAULT_OUTPUT
|
|
185
|
-
}, {
|
|
186
|
-
node: "gpt-OUTPUT",
|
|
187
|
-
property: "queue"
|
|
188
|
-
});
|
|
189
|
-
return space.db.add(model.root);
|
|
190
|
-
});
|
|
191
|
-
cb?.(objects);
|
|
192
|
-
return objects;
|
|
193
|
-
}
|
|
194
|
-
]
|
|
195
|
-
]);
|
|
196
39
|
|
|
197
40
|
// src/components/SpaceGenerator/presets.ts
|
|
198
41
|
import * as Schema from "effect/Schema";
|
|
199
|
-
import {
|
|
42
|
+
import { AgentPrompt, EntityExtraction, ResearchBlueprint } from "@dxos/assistant-toolkit";
|
|
200
43
|
import { Prompt } from "@dxos/blueprints";
|
|
201
|
-
import { NODE_INPUT
|
|
202
|
-
import { DXN
|
|
203
|
-
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";
|
|
204
47
|
import { invariant } from "@dxos/invariant";
|
|
205
|
-
import {
|
|
48
|
+
import { Operation } from "@dxos/operation";
|
|
49
|
+
import { InboxOperation } from "@dxos/plugin-inbox";
|
|
206
50
|
import { Mailbox } from "@dxos/plugin-inbox/types";
|
|
207
|
-
import { Markdown
|
|
51
|
+
import { Markdown } from "@dxos/plugin-markdown/types";
|
|
208
52
|
import { createAppend, createChat, createComputeGraph, createConstant, createFunction, createGpt, createQueue, createRandom, createSurface, createTemplate, createText, createTrigger } from "@dxos/react-ui-canvas-compute";
|
|
209
|
-
import {
|
|
210
|
-
import {
|
|
211
|
-
import { Message, Organization, Person,
|
|
212
|
-
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";
|
|
213
57
|
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-debug/src/components/SpaceGenerator/presets.ts";
|
|
214
58
|
var PresetName = /* @__PURE__ */ (function(PresetName2) {
|
|
215
59
|
PresetName2["DXOS_TEAM"] = "dxos-team";
|
|
@@ -222,9 +66,9 @@ var PresetName = /* @__PURE__ */ (function(PresetName2) {
|
|
|
222
66
|
PresetName2["DISCORD_MESSAGES"] = "discord-messages";
|
|
223
67
|
return PresetName2;
|
|
224
68
|
})({});
|
|
225
|
-
var
|
|
69
|
+
var generator = () => ({
|
|
226
70
|
schemas: [
|
|
227
|
-
|
|
71
|
+
CanvasBoard.CanvasBoard,
|
|
228
72
|
Trigger.Trigger
|
|
229
73
|
],
|
|
230
74
|
types: Object.values(PresetName).map((name) => ({
|
|
@@ -234,12 +78,12 @@ var generator2 = () => ({
|
|
|
234
78
|
[
|
|
235
79
|
"dxos-team",
|
|
236
80
|
async (space, n, cb) => {
|
|
237
|
-
const objects =
|
|
81
|
+
const objects = range(n, () => {
|
|
238
82
|
const org = space.db.add(Obj.make(Organization.Organization, {
|
|
239
83
|
name: "DXOS",
|
|
240
84
|
website: "https://dxos.org"
|
|
241
85
|
}));
|
|
242
|
-
const doc = space.db.add(
|
|
86
|
+
const doc = space.db.add(Markdown.make({
|
|
243
87
|
name: "DXOS Research",
|
|
244
88
|
content: "DXOS builds Composer, an open-source AI-powered malleable application."
|
|
245
89
|
}));
|
|
@@ -247,16 +91,19 @@ var generator2 = () => ({
|
|
|
247
91
|
label: "Investor"
|
|
248
92
|
}));
|
|
249
93
|
const tagDxn = Obj.getDXN(tag).toString();
|
|
250
|
-
Obj.
|
|
251
|
-
|
|
252
|
-
|
|
94
|
+
Obj.change(doc, (obj) => {
|
|
95
|
+
Obj.getMeta(obj).tags = [
|
|
96
|
+
tagDxn
|
|
97
|
+
];
|
|
98
|
+
});
|
|
253
99
|
space.db.add(Obj.make(Person.Person, {
|
|
100
|
+
[Obj.Meta]: {
|
|
101
|
+
tags: [
|
|
102
|
+
tagDxn
|
|
103
|
+
]
|
|
104
|
+
},
|
|
254
105
|
fullName: "Rich",
|
|
255
106
|
organization: Ref.make(org)
|
|
256
|
-
}, {
|
|
257
|
-
tags: [
|
|
258
|
-
tagDxn
|
|
259
|
-
]
|
|
260
107
|
}));
|
|
261
108
|
space.db.add(Obj.make(Person.Person, {
|
|
262
109
|
fullName: "Josiah",
|
|
@@ -279,24 +126,54 @@ var generator2 = () => ({
|
|
|
279
126
|
[
|
|
280
127
|
"org-research-project",
|
|
281
128
|
async (space, n, cb) => {
|
|
282
|
-
const
|
|
283
|
-
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, {
|
|
284
161
|
label: "Investor"
|
|
285
162
|
})).first();
|
|
286
163
|
const tagDxn = Obj.getDXN(tag).toString();
|
|
287
|
-
const objects =
|
|
288
|
-
const contactsQuery = Query.select(
|
|
289
|
-
const organizationsQuery = Query.select(
|
|
290
|
-
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));
|
|
291
168
|
space.db.add(Trigger.make({
|
|
292
169
|
enabled: true,
|
|
293
170
|
spec: {
|
|
294
171
|
kind: "timer",
|
|
295
172
|
cron: "* * * * *"
|
|
296
173
|
},
|
|
297
|
-
function: Ref.make(
|
|
174
|
+
function: Ref.make(Operation.serialize(InboxOperation.GoogleMailSync)),
|
|
298
175
|
input: {
|
|
299
|
-
|
|
176
|
+
mailbox: Ref.make(mailbox)
|
|
300
177
|
}
|
|
301
178
|
}));
|
|
302
179
|
space.db.add(Trigger.make({
|
|
@@ -304,9 +181,9 @@ var generator2 = () => ({
|
|
|
304
181
|
// TODO(wittjosiah): Queue trigger doesn't support matching query of the column.
|
|
305
182
|
spec: {
|
|
306
183
|
kind: "queue",
|
|
307
|
-
queue:
|
|
184
|
+
queue: queueDxn
|
|
308
185
|
},
|
|
309
|
-
function: Ref.make(
|
|
186
|
+
function: Ref.make(Operation.serialize(EntityExtraction)),
|
|
310
187
|
input: {
|
|
311
188
|
source: "{{event.item}}"
|
|
312
189
|
}
|
|
@@ -326,7 +203,7 @@ var generator2 = () => ({
|
|
|
326
203
|
NOTE: Do mocked reseach (set mockSearch to true).
|
|
327
204
|
`,
|
|
328
205
|
blueprints: [
|
|
329
|
-
Ref.make(ResearchBlueprint)
|
|
206
|
+
Ref.make(ResearchBlueprint.make())
|
|
330
207
|
]
|
|
331
208
|
}));
|
|
332
209
|
space.db.add(Trigger.make({
|
|
@@ -337,60 +214,60 @@ var generator2 = () => ({
|
|
|
337
214
|
ast: organizationsQuery.ast
|
|
338
215
|
}
|
|
339
216
|
},
|
|
340
|
-
function: Ref.make(
|
|
217
|
+
function: Ref.make(Operation.serialize(AgentPrompt)),
|
|
341
218
|
input: {
|
|
342
219
|
prompt: Ref.make(researchPrompt),
|
|
343
220
|
input: "{{event.subject}}"
|
|
344
221
|
}
|
|
345
222
|
}));
|
|
346
|
-
const mailboxView =
|
|
347
|
-
|
|
348
|
-
query: Query.select(Filter2.type(Message.Message, {
|
|
223
|
+
const mailboxView = ViewModel.make({
|
|
224
|
+
query: Query.select(Filter.type(Message.Message, {
|
|
349
225
|
properties: {
|
|
350
|
-
labels:
|
|
226
|
+
labels: Filter.contains("investor")
|
|
351
227
|
}
|
|
352
|
-
})).
|
|
228
|
+
})).from({
|
|
353
229
|
queues: [
|
|
354
|
-
|
|
230
|
+
queueDxn
|
|
355
231
|
]
|
|
356
232
|
}),
|
|
357
|
-
jsonSchema:
|
|
358
|
-
presentation: Obj.make(Collection.Collection, {
|
|
359
|
-
objects: []
|
|
360
|
-
})
|
|
233
|
+
jsonSchema: JsonSchema.toJsonSchema(Message.Message)
|
|
361
234
|
});
|
|
362
|
-
const contactsView =
|
|
363
|
-
name: "Contacts",
|
|
235
|
+
const contactsView = ViewModel.make({
|
|
364
236
|
query: contactsQuery,
|
|
365
|
-
jsonSchema:
|
|
366
|
-
presentation: Obj.make(Collection.Collection, {
|
|
367
|
-
objects: []
|
|
368
|
-
})
|
|
237
|
+
jsonSchema: JsonSchema.toJsonSchema(Person.Person)
|
|
369
238
|
});
|
|
370
|
-
const organizationsView =
|
|
371
|
-
name: "Organizations",
|
|
239
|
+
const organizationsView = ViewModel.make({
|
|
372
240
|
query: organizationsQuery,
|
|
373
|
-
jsonSchema:
|
|
374
|
-
presentation: Obj.make(Collection.Collection, {
|
|
375
|
-
objects: []
|
|
376
|
-
})
|
|
241
|
+
jsonSchema: JsonSchema.toJsonSchema(Organization.Organization)
|
|
377
242
|
});
|
|
378
|
-
const notesView =
|
|
379
|
-
name: "Notes",
|
|
243
|
+
const notesView = ViewModel.make({
|
|
380
244
|
query: notesQuery,
|
|
381
|
-
jsonSchema:
|
|
382
|
-
presentation: Obj.make(Collection.Collection, {
|
|
383
|
-
objects: []
|
|
384
|
-
})
|
|
245
|
+
jsonSchema: JsonSchema.toJsonSchema(Markdown.Document)
|
|
385
246
|
});
|
|
386
|
-
return space.db.add(
|
|
247
|
+
return space.db.add(Pipeline.make({
|
|
387
248
|
name: "Investor Research",
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
249
|
+
columns: [
|
|
250
|
+
{
|
|
251
|
+
name: "Mailbox",
|
|
252
|
+
view: Ref.make(mailboxView),
|
|
253
|
+
order: []
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
name: "Contacts",
|
|
257
|
+
view: Ref.make(contactsView),
|
|
258
|
+
order: []
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
name: "Organizations",
|
|
262
|
+
view: Ref.make(organizationsView),
|
|
263
|
+
order: []
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
name: "Notes",
|
|
267
|
+
view: Ref.make(notesView),
|
|
268
|
+
order: []
|
|
269
|
+
}
|
|
270
|
+
]
|
|
394
271
|
}));
|
|
395
272
|
});
|
|
396
273
|
cb?.(objects.flat());
|
|
@@ -400,7 +277,7 @@ var generator2 = () => ({
|
|
|
400
277
|
[
|
|
401
278
|
"webhook-gpt-queue",
|
|
402
279
|
async (space, n, cb) => {
|
|
403
|
-
const objects =
|
|
280
|
+
const objects = range(n, () => {
|
|
404
281
|
const canvasModel = CanvasGraphModel.create();
|
|
405
282
|
let functionTrigger;
|
|
406
283
|
canvasModel.builder.call((builder) => {
|
|
@@ -460,9 +337,9 @@ var generator2 = () => ({
|
|
|
460
337
|
[
|
|
461
338
|
"objectChange-queue",
|
|
462
339
|
async (space, n, cb) => {
|
|
463
|
-
const objects =
|
|
340
|
+
const objects = range(n, () => {
|
|
464
341
|
const { canvasModel, computeModel } = createQueueSinkPreset(space, "subscription", (triggerSpec) => triggerSpec.query = {
|
|
465
|
-
ast: Query.select(
|
|
342
|
+
ast: Query.select(Filter.typename("org.dxos.type.chess")).ast
|
|
466
343
|
}, "type");
|
|
467
344
|
return addToSpace("objectChange-queue", space, canvasModel, computeModel);
|
|
468
345
|
});
|
|
@@ -473,7 +350,7 @@ var generator2 = () => ({
|
|
|
473
350
|
[
|
|
474
351
|
"timerTick-queue",
|
|
475
352
|
async (space, n, cb) => {
|
|
476
|
-
const objects =
|
|
353
|
+
const objects = range(n, () => {
|
|
477
354
|
const { canvasModel, computeModel } = createQueueSinkPreset(space, "timer", (triggerSpec) => triggerSpec.cron = "*/5 * * * * *", "result");
|
|
478
355
|
return addToSpace("timerTick-queue", space, canvasModel, computeModel);
|
|
479
356
|
});
|
|
@@ -528,7 +405,7 @@ var generator2 = () => ({
|
|
|
528
405
|
// const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
|
|
529
406
|
// invariant(templateComputeNode, 'Template compute node was not created.');
|
|
530
407
|
// templateComputeNode.value = templateContent.join('\n');
|
|
531
|
-
// templateComputeNode.inputSchema =
|
|
408
|
+
// templateComputeNode.inputSchema = JsonSchema.toJsonSchema(EmailTriggerOutput);
|
|
532
409
|
// attachTrigger(functionTrigger, computeModel);
|
|
533
410
|
// return addToSpace(PresetName.EMAIL_TABLE, space, canvasModel, computeModel);
|
|
534
411
|
// });
|
|
@@ -539,7 +416,7 @@ var generator2 = () => ({
|
|
|
539
416
|
[
|
|
540
417
|
"chat-gpt-text",
|
|
541
418
|
async (space, n, cb) => {
|
|
542
|
-
const objects =
|
|
419
|
+
const objects = range(n, () => {
|
|
543
420
|
const canvasModel = CanvasGraphModel.create();
|
|
544
421
|
canvasModel.builder.call((builder) => {
|
|
545
422
|
const gpt = canvasModel.createNode(createGpt(position({
|
|
@@ -659,7 +536,7 @@ var generator2 = () => ({
|
|
|
659
536
|
// invariant(templateComputeNode, 'Template compute node was not created.');
|
|
660
537
|
// templateComputeNode.value = templateContent.join('\n');
|
|
661
538
|
// const extendedSchema = Schema.extend(EmailTriggerOutput, Schema.Struct({ text: Schema.String }));
|
|
662
|
-
// templateComputeNode.inputSchema =
|
|
539
|
+
// templateComputeNode.inputSchema = JsonSchema.toJsonSchema(extendedSchema);
|
|
663
540
|
// attachTrigger(functionTrigger, computeModel);
|
|
664
541
|
// return addToSpace(PresetName.EMAIL_WITH_SUMMARY, space, canvasModel, computeModel);
|
|
665
542
|
// });
|
|
@@ -670,7 +547,7 @@ var generator2 = () => ({
|
|
|
670
547
|
[
|
|
671
548
|
"forex-function-call",
|
|
672
549
|
async (space, n, cb) => {
|
|
673
|
-
const objects =
|
|
550
|
+
const objects = range(n, () => {
|
|
674
551
|
const canvasModel = CanvasGraphModel.create();
|
|
675
552
|
canvasModel.builder.call((builder) => {
|
|
676
553
|
const sourceCurrency = canvasModel.createNode(createConstant({
|
|
@@ -719,7 +596,7 @@ var generator2 = () => ({
|
|
|
719
596
|
[
|
|
720
597
|
"discord-messages",
|
|
721
598
|
async (space, n, cb) => {
|
|
722
|
-
const objects =
|
|
599
|
+
const objects = range(n, () => {
|
|
723
600
|
const canvasModel = CanvasGraphModel.create();
|
|
724
601
|
let functionTrigger;
|
|
725
602
|
canvasModel.builder.call((builder) => {
|
|
@@ -740,10 +617,10 @@ var generator2 = () => ({
|
|
|
740
617
|
})
|
|
741
618
|
}));
|
|
742
619
|
const queueId = canvasModel.createNode(createConstant({
|
|
743
|
-
value: new
|
|
620
|
+
value: new DXN(DXN.kind.QUEUE, [
|
|
744
621
|
"data",
|
|
745
622
|
space.id,
|
|
746
|
-
|
|
623
|
+
Key.ObjectId.random()
|
|
747
624
|
]).toString(),
|
|
748
625
|
...position({
|
|
749
626
|
x: -10,
|
|
@@ -861,20 +738,22 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
|
|
|
861
738
|
const triggerSpec = functionTrigger.spec;
|
|
862
739
|
invariant(triggerSpec && triggerSpec.kind === triggerKind, "No trigger spec.", {
|
|
863
740
|
F: __dxlog_file,
|
|
864
|
-
L:
|
|
741
|
+
L: 765,
|
|
865
742
|
S: void 0,
|
|
866
743
|
A: [
|
|
867
744
|
"triggerSpec && triggerSpec.kind === triggerKind",
|
|
868
745
|
"'No trigger spec.'"
|
|
869
746
|
]
|
|
870
747
|
});
|
|
871
|
-
|
|
748
|
+
Obj.change(functionTrigger, (ft) => {
|
|
749
|
+
initSpec(ft.spec);
|
|
750
|
+
});
|
|
872
751
|
});
|
|
873
752
|
const computeModel = createComputeGraph(canvasModel);
|
|
874
753
|
const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
|
|
875
754
|
invariant(templateComputeNode, "Template compute node was not created.", {
|
|
876
755
|
F: __dxlog_file,
|
|
877
|
-
L:
|
|
756
|
+
L: 774,
|
|
878
757
|
S: void 0,
|
|
879
758
|
A: [
|
|
880
759
|
"templateComputeNode",
|
|
@@ -887,7 +766,7 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
|
|
|
887
766
|
' "id": "@{{changeId}}"',
|
|
888
767
|
"}"
|
|
889
768
|
].join("\n");
|
|
890
|
-
templateComputeNode.inputSchema =
|
|
769
|
+
templateComputeNode.inputSchema = JsonSchema.toJsonSchema(Schema.Struct({
|
|
891
770
|
type: Schema.String,
|
|
892
771
|
changeId: Schema.String
|
|
893
772
|
}));
|
|
@@ -898,7 +777,7 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
|
|
|
898
777
|
};
|
|
899
778
|
};
|
|
900
779
|
var addToSpace = (name, space, canvas, compute) => {
|
|
901
|
-
return space.db.add(Obj.make(
|
|
780
|
+
return space.db.add(Obj.make(CanvasBoard.CanvasBoard, {
|
|
902
781
|
name,
|
|
903
782
|
computeGraph: Ref.make(compute.root),
|
|
904
783
|
layout: canvas.graph
|
|
@@ -906,10 +785,10 @@ var addToSpace = (name, space, canvas, compute) => {
|
|
|
906
785
|
};
|
|
907
786
|
var setupQueue = (space, canvasModel, args) => {
|
|
908
787
|
const queueId = canvasModel.createNode(createConstant({
|
|
909
|
-
value: new
|
|
788
|
+
value: new DXN(DXN.kind.QUEUE, [
|
|
910
789
|
"data",
|
|
911
790
|
space.id,
|
|
912
|
-
|
|
791
|
+
Key.ObjectId.random()
|
|
913
792
|
]).toString(),
|
|
914
793
|
...args?.idPosition ? rawPosition(args.idPosition) : position({
|
|
915
794
|
x: -18,
|
|
@@ -936,16 +815,18 @@ var setupQueue = (space, canvasModel, args) => {
|
|
|
936
815
|
var attachTrigger = (functionTrigger, computeModel) => {
|
|
937
816
|
invariant(functionTrigger, void 0, {
|
|
938
817
|
F: __dxlog_file,
|
|
939
|
-
L:
|
|
818
|
+
L: 816,
|
|
940
819
|
S: void 0,
|
|
941
820
|
A: [
|
|
942
821
|
"functionTrigger",
|
|
943
822
|
""
|
|
944
823
|
]
|
|
945
824
|
});
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
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
|
+
});
|
|
949
830
|
};
|
|
950
831
|
var rawPosition = (args) => {
|
|
951
832
|
return {
|
|
@@ -991,163 +872,312 @@ var position = (rect) => {
|
|
|
991
872
|
}
|
|
992
873
|
};
|
|
993
874
|
|
|
994
|
-
// src/components/SpaceGenerator/
|
|
995
|
-
import {
|
|
996
|
-
import
|
|
997
|
-
import {
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
}, type.typename), /* @__PURE__ */ React.createElement("div", {
|
|
1011
|
-
className: "pli-2 text-right font-mono"
|
|
1012
|
-
}, objects[type.typename] ?? 0), /* @__PURE__ */ React.createElement(IconButton, {
|
|
1013
|
-
variant: "ghost",
|
|
1014
|
-
icon: "ph--plus--regular",
|
|
1015
|
-
iconOnly: true,
|
|
1016
|
-
label: "Create data",
|
|
1017
|
-
onClick: () => onClick(type.typename)
|
|
1018
|
-
}))));
|
|
1019
|
-
} finally {
|
|
1020
|
-
_effect.f();
|
|
1021
|
-
}
|
|
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);
|
|
1022
891
|
};
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
const
|
|
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
|
-
|
|
1071
|
-
|
|
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
|
+
}
|
|
1072
977
|
}
|
|
1073
|
-
return
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
static: staticSchema.length,
|
|
1078
|
-
mutable: echoSchema.length
|
|
1079
|
-
},
|
|
1080
|
-
objects: objectMap
|
|
978
|
+
return space.db.add(Sheet.make({
|
|
979
|
+
name: faker.commerce.productName(),
|
|
980
|
+
cells
|
|
981
|
+
}));
|
|
1081
982
|
});
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
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
|
|
1085
1074
|
]);
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
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
|
|
1095
1087
|
]);
|
|
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
|
-
|
|
1146
|
-
|
|
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
|
+
});
|
|
1147
1177
|
|
|
1148
|
-
// src/
|
|
1178
|
+
// src/containers/SpaceGenerator/index.ts
|
|
1149
1179
|
var SpaceGenerator_default = SpaceGenerator;
|
|
1150
1180
|
export {
|
|
1151
1181
|
SpaceGenerator_default as default
|
|
1152
1182
|
};
|
|
1153
|
-
//# sourceMappingURL=SpaceGenerator-
|
|
1183
|
+
//# sourceMappingURL=SpaceGenerator-UUQS6TYY.mjs.map
|