@dxos/plugin-debug 0.8.4-main.dedc0f3 → 0.8.4-main.dfabb4ec29
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/neutral/DebugGraph-G4FWS57E.mjs +15 -0
- package/dist/lib/neutral/DebugGraph-G4FWS57E.mjs.map +7 -0
- package/dist/lib/neutral/DebugObjectPanel-UJ63CV25.mjs +59 -0
- package/dist/lib/neutral/DebugObjectPanel-UJ63CV25.mjs.map +7 -0
- package/dist/lib/neutral/DebugPlugin.mjs +47 -0
- package/dist/lib/neutral/DebugPlugin.mjs.map +7 -0
- package/dist/lib/neutral/DebugPlugin.node.mjs +18 -0
- package/dist/lib/neutral/DebugPlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/DebugSettings-Z3XADRNK.mjs +224 -0
- package/dist/lib/neutral/DebugSettings-Z3XADRNK.mjs.map +7 -0
- package/dist/lib/neutral/DebugSpaceObjectsPanel-NISULU6U.mjs +34 -0
- package/dist/lib/neutral/DebugSpaceObjectsPanel-NISULU6U.mjs.map +7 -0
- package/dist/lib/neutral/DebugStatus-YB3KFP7G.mjs +121 -0
- package/dist/lib/neutral/DebugStatus-YB3KFP7G.mjs.map +7 -0
- package/dist/lib/neutral/DevtoolsOverviewContainer-YX7Z3D2H.mjs +23 -0
- package/dist/lib/neutral/DevtoolsOverviewContainer-YX7Z3D2H.mjs.map +7 -0
- package/dist/lib/neutral/SpaceGenerator-UBYB4NPD.mjs +143 -0
- package/dist/lib/neutral/SpaceGenerator-UBYB4NPD.mjs.map +7 -0
- package/dist/lib/neutral/Wireframe-7SNRUKET.mjs +52 -0
- package/dist/lib/neutral/Wireframe-7SNRUKET.mjs.map +7 -0
- package/dist/lib/neutral/app-graph-builder-YPYHL2K5.mjs +577 -0
- package/dist/lib/neutral/app-graph-builder-YPYHL2K5.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +15 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-3OGPOE7H.mjs +20 -0
- package/dist/lib/neutral/chunk-3OGPOE7H.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/{browser/chunk-AJA6RYN3.mjs → neutral/chunk-NFIOTQRZ.mjs} +30 -9
- package/dist/lib/neutral/chunk-NFIOTQRZ.mjs.map +7 -0
- package/dist/lib/{browser/SpaceGenerator-DANYBPYZ.mjs → neutral/components/index.mjs} +414 -411
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +21 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +18 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +8 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +12 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/react-context-MUZ3KVLU.mjs +17 -0
- package/dist/lib/neutral/react-context-MUZ3KVLU.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-NH2H63KW.mjs +420 -0
- package/dist/lib/neutral/react-surface-NH2H63KW.mjs.map +7 -0
- package/dist/lib/neutral/settings-MPM6YUP4.mjs +28 -0
- package/dist/lib/neutral/settings-MPM6YUP4.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +83 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +14 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/types/src/DebugPlugin.d.ts +4 -1
- package/dist/types/src/DebugPlugin.d.ts.map +1 -1
- package/dist/types/src/DebugPlugin.node.d.ts +5 -0
- package/dist/types/src/DebugPlugin.node.d.ts.map +1 -0
- package/dist/types/src/DebugPlugin.test.d.ts +2 -0
- package/dist/types/src/DebugPlugin.test.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +8 -5
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-context.d.ts +4 -2
- package/dist/types/src/capabilities/react-context.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +7 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.d.ts +5 -2
- package/dist/types/src/capabilities/settings.d.ts.map +1 -1
- package/dist/types/src/components/DebugSettings/DebugSettings.d.ts +11 -0
- package/dist/types/src/components/DebugSettings/DebugSettings.d.ts.map +1 -0
- package/dist/types/src/components/DebugSettings/DebugSettings.stories.d.ts +99 -0
- package/dist/types/src/components/DebugSettings/DebugSettings.stories.d.ts.map +1 -0
- package/dist/types/src/components/DebugSettings/index.d.ts +2 -0
- package/dist/types/src/components/DebugSettings/index.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/draw-util.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 +4 -5
- package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +4 -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 +2 -0
- package/dist/types/src/containers/DebugGraph/index.d.ts.map +1 -0
- package/dist/types/src/containers/DebugObjectPanel/DebugObjectPanel.d.ts +6 -0
- package/dist/types/src/containers/DebugObjectPanel/DebugObjectPanel.d.ts.map +1 -0
- package/dist/types/src/containers/DebugObjectPanel/index.d.ts +2 -0
- package/dist/types/src/containers/DebugObjectPanel/index.d.ts.map +1 -0
- package/dist/types/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.d.ts +5 -0
- package/dist/types/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.d.ts.map +1 -0
- package/dist/types/src/containers/DebugSpaceObjectsPanel/index.d.ts +2 -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 +2 -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 +2 -0
- package/dist/types/src/containers/DevtoolsOverviewContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/SpaceGenerator/SpaceGenerator.d.ts +11 -0
- package/dist/types/src/containers/SpaceGenerator/SpaceGenerator.d.ts.map +1 -0
- package/dist/types/src/containers/SpaceGenerator/index.d.ts +2 -0
- package/dist/types/src/containers/SpaceGenerator/index.d.ts.map +1 -0
- package/dist/types/src/{components → containers/Wireframe}/Wireframe.d.ts +2 -2
- package/dist/types/src/containers/Wireframe/Wireframe.d.ts.map +1 -0
- package/dist/types/src/containers/Wireframe/index.d.ts +2 -0
- package/dist/types/src/containers/Wireframe/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +9 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +80 -59
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Settings.d.ts +8 -0
- package/dist/types/src/types/Settings.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +69 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +131 -72
- package/src/DebugPlugin.node.ts +18 -0
- package/src/DebugPlugin.test.ts +29 -0
- package/src/DebugPlugin.tsx +30 -37
- package/src/capabilities/app-graph-builder.ts +362 -387
- package/src/capabilities/index.ts +5 -5
- package/src/capabilities/react-context.tsx +16 -7
- package/src/capabilities/react-surface.tsx +379 -338
- package/src/capabilities/settings.ts +24 -12
- package/src/components/DebugSettings/DebugSettings.stories.tsx +36 -0
- package/src/components/DebugSettings/DebugSettings.tsx +262 -0
- package/src/components/DebugSettings/index.ts +5 -0
- package/src/components/SchemaTable/index.ts +5 -0
- package/src/components/SpaceGenerator/ObjectGenerator.tsx +33 -41
- package/src/components/SpaceGenerator/draw-util.ts +10 -10
- package/src/components/SpaceGenerator/index.ts +2 -3
- package/src/components/SpaceGenerator/presets.ts +310 -48
- package/src/components/index.ts +4 -8
- package/src/containers/DebugGraph/DebugGraph.tsx +14 -0
- package/src/containers/DebugGraph/index.ts +5 -0
- package/src/containers/DebugObjectPanel/DebugObjectPanel.tsx +76 -0
- package/src/containers/DebugObjectPanel/index.ts +5 -0
- package/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.tsx +47 -0
- package/src/containers/DebugSpaceObjectsPanel/index.ts +5 -0
- package/src/{components → containers/DebugStatus}/DebugStatus.tsx +43 -21
- package/src/containers/DebugStatus/index.ts +5 -0
- package/src/containers/DevtoolsOverviewContainer/DevtoolsOverviewContainer.tsx +25 -0
- package/src/containers/DevtoolsOverviewContainer/index.ts +5 -0
- package/src/containers/SpaceGenerator/SpaceGenerator.tsx +126 -0
- package/src/containers/SpaceGenerator/index.ts +5 -0
- package/src/{components → containers/Wireframe}/Wireframe.tsx +7 -12
- package/src/containers/Wireframe/index.ts +5 -0
- package/src/containers/index.ts +13 -0
- package/src/index.ts +1 -1
- package/src/meta.ts +8 -7
- package/src/plugin.ts +10 -0
- package/src/translations.ts +75 -58
- package/src/types/Settings.ts +16 -0
- package/src/{types.ts → types/index.ts} +20 -11
- package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs +0 -20
- package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs.map +0 -7
- package/dist/lib/browser/DevtoolsOverviewContainer-EPD6EWT5.mjs +0 -25
- package/dist/lib/browser/DevtoolsOverviewContainer-EPD6EWT5.mjs.map +0 -7
- package/dist/lib/browser/SpaceGenerator-DANYBPYZ.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-JTIEFOWZ.mjs +0 -587
- package/dist/lib/browser/app-graph-builder-JTIEFOWZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-5XPIRNQS.mjs +0 -18
- package/dist/lib/browser/chunk-5XPIRNQS.mjs.map +0 -7
- package/dist/lib/browser/chunk-AJA6RYN3.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -133
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-context-NVAGLAJD.mjs +0 -16
- package/dist/lib/browser/react-context-NVAGLAJD.mjs.map +0 -7
- package/dist/lib/browser/react-surface-YLOWSIBU.mjs +0 -773
- package/dist/lib/browser/react-surface-YLOWSIBU.mjs.map +0 -7
- package/dist/lib/browser/settings-LSSWLM5I.mjs +0 -22
- package/dist/lib/browser/settings-LSSWLM5I.mjs.map +0 -7
- 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 +0 -7
- 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 -16
- 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/dist/types/src/types.d.ts +0 -63
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/components/Container.tsx +0 -15
- package/src/components/DebugGraph.tsx +0 -14
- package/src/components/DebugObjectPanel.tsx +0 -35
- package/src/components/DebugSettings.tsx +0 -159
- package/src/components/DevtoolsOverviewContainer.tsx +0 -20
- package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +0 -54
- 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
- /package/src/components/{SpaceGenerator → SchemaTable}/SchemaTable.tsx +0 -0
|
@@ -1,233 +1,227 @@
|
|
|
1
|
-
|
|
2
|
-
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
3
|
-
import React2, { useCallback, useMemo, useState } from "react";
|
|
4
|
-
import { useIntentDispatcher } from "@dxos/app-framework";
|
|
5
|
-
import { ComputeGraph as ComputeGraph2 } from "@dxos/conductor";
|
|
6
|
-
import { Filter as Filter3 } from "@dxos/echo";
|
|
7
|
-
import { Markdown as Markdown2 } from "@dxos/plugin-markdown/types";
|
|
8
|
-
import { SheetType as SheetType2 } from "@dxos/plugin-sheet/types";
|
|
9
|
-
import { DiagramType as DiagramType2 } from "@dxos/plugin-sketch/types";
|
|
10
|
-
import { useClient } from "@dxos/react-client";
|
|
11
|
-
import { getTypename } from "@dxos/react-client/echo";
|
|
12
|
-
import { IconButton as IconButton2, Input, Toolbar, useAsyncEffect } from "@dxos/react-ui";
|
|
13
|
-
import { SyntaxHighlighter } from "@dxos/react-ui-syntax-highlighter";
|
|
14
|
-
import { DataType as DataType2 } from "@dxos/schema";
|
|
15
|
-
import { jsonKeyReplacer, sortKeys } from "@dxos/util";
|
|
1
|
+
import "../chunk-J5LGTIGS.mjs";
|
|
16
2
|
|
|
17
|
-
// src/components/
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
import
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
await dispatch(createIntent(SpaceAction.AddSchema, {
|
|
43
|
-
space,
|
|
44
|
-
schema
|
|
45
|
-
}));
|
|
46
|
-
} else if (!view && staticSchema) {
|
|
47
|
-
await dispatch(createIntent(SpaceAction.UseStaticSchema, {
|
|
48
|
-
space,
|
|
49
|
-
typename
|
|
50
|
-
}));
|
|
51
|
-
}
|
|
52
|
-
const generate = createAsyncGenerator(generator, schema, {
|
|
53
|
-
db: space.db
|
|
54
|
-
});
|
|
55
|
-
return generate.createObjects(n);
|
|
56
|
-
};
|
|
3
|
+
// src/components/index.ts
|
|
4
|
+
import { lazy } from "react";
|
|
5
|
+
|
|
6
|
+
// src/components/SchemaTable/SchemaTable.tsx
|
|
7
|
+
import React from "react";
|
|
8
|
+
import { IconButton } from "@dxos/react-ui";
|
|
9
|
+
var SchemaTable = ({ types, objects = {}, label, onClick }) => {
|
|
10
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
11
|
+
className: "grid grid-cols-[1fr_80px_40px] gap-1 overflow-none"
|
|
12
|
+
}, /* @__PURE__ */ React.createElement("h2", {
|
|
13
|
+
className: "p-2"
|
|
14
|
+
}, label), types.map((type) => /* @__PURE__ */ React.createElement("div", {
|
|
15
|
+
key: type.typename,
|
|
16
|
+
className: "grid grid-cols-subgrid col-span-3 items-center"
|
|
17
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
18
|
+
className: "px-2 text-sm font-mono text-subdued"
|
|
19
|
+
}, type.typename), /* @__PURE__ */ React.createElement("div", {
|
|
20
|
+
className: "px-2 text-right font-mono"
|
|
21
|
+
}, objects[type.typename] ?? 0), /* @__PURE__ */ React.createElement(IconButton, {
|
|
22
|
+
variant: "ghost",
|
|
23
|
+
icon: "ph--plus--regular",
|
|
24
|
+
iconOnly: true,
|
|
25
|
+
label: "Create data",
|
|
26
|
+
onClick: () => onClick(type.typename)
|
|
27
|
+
}))));
|
|
57
28
|
};
|
|
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.makeDocument({
|
|
64
|
-
name: faker.commerce.productName(),
|
|
65
|
-
content: faker.lorem.sentences(5)
|
|
66
|
-
}));
|
|
67
|
-
});
|
|
68
|
-
cb?.(objects);
|
|
69
|
-
return objects;
|
|
70
|
-
}
|
|
71
|
-
],
|
|
72
|
-
[
|
|
73
|
-
DiagramType.typename,
|
|
74
|
-
async (space, n, cb) => {
|
|
75
|
-
const objects = range(n).map(() => {
|
|
76
|
-
const obj = space.db.add(Obj.make(DiagramType, {
|
|
77
|
-
name: faker.commerce.productName(),
|
|
78
|
-
canvas: Ref.make(Obj.make(CanvasType, {
|
|
79
|
-
content: {}
|
|
80
|
-
}))
|
|
81
|
-
}));
|
|
82
|
-
return obj;
|
|
83
|
-
});
|
|
84
|
-
cb?.(objects);
|
|
85
|
-
return objects;
|
|
86
|
-
}
|
|
87
|
-
],
|
|
88
|
-
// TODO(burdon): Create unit tests.
|
|
89
|
-
[
|
|
90
|
-
SheetType.typename,
|
|
91
|
-
async (space, n, cb) => {
|
|
92
|
-
const objects = range(n).map(() => {
|
|
93
|
-
const cells = {};
|
|
94
|
-
const year = (/* @__PURE__ */ new Date()).getFullYear();
|
|
95
|
-
const cols = 4;
|
|
96
|
-
const rows = 16;
|
|
97
|
-
for (let col = 1; col <= cols; col++) {
|
|
98
|
-
for (let row = 1; row <= rows; row++) {
|
|
99
|
-
const cell = addressToA1Notation({
|
|
100
|
-
col,
|
|
101
|
-
row
|
|
102
|
-
});
|
|
103
|
-
if (row === 1) {
|
|
104
|
-
cells[cell] = {
|
|
105
|
-
value: `${year} Q${col}`
|
|
106
|
-
};
|
|
107
|
-
} else if (row === rows) {
|
|
108
|
-
const from = addressToA1Notation({
|
|
109
|
-
col,
|
|
110
|
-
row: 2
|
|
111
|
-
});
|
|
112
|
-
const to = addressToA1Notation({
|
|
113
|
-
col,
|
|
114
|
-
row: rows - 1
|
|
115
|
-
});
|
|
116
|
-
cells[cell] = {
|
|
117
|
-
value: `=SUM(${from}:${to})`
|
|
118
|
-
};
|
|
119
|
-
} else if (row > 2 && row < rows - 1) {
|
|
120
|
-
cells[cell] = {
|
|
121
|
-
value: Math.floor(Math.random() * 1e4)
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return space.db.add(createSheet({
|
|
127
|
-
name: faker.commerce.productName(),
|
|
128
|
-
cells
|
|
129
|
-
}));
|
|
130
|
-
});
|
|
131
|
-
cb?.(objects);
|
|
132
|
-
return objects;
|
|
133
|
-
}
|
|
134
|
-
],
|
|
135
|
-
[
|
|
136
|
-
ComputeGraph.typename,
|
|
137
|
-
async (space, n, cb) => {
|
|
138
|
-
const objects = range(n, () => {
|
|
139
|
-
const model = ComputeGraphModel.create();
|
|
140
|
-
model.builder.createNode({
|
|
141
|
-
id: "gpt-INPUT",
|
|
142
|
-
type: NODE_INPUT
|
|
143
|
-
}).createNode({
|
|
144
|
-
id: "gpt-GPT",
|
|
145
|
-
type: "gpt"
|
|
146
|
-
}).createNode({
|
|
147
|
-
id: "gpt-QUEUE_ID",
|
|
148
|
-
type: "constant",
|
|
149
|
-
value: new DXN(DXN.kind.QUEUE, [
|
|
150
|
-
"data",
|
|
151
|
-
space.id,
|
|
152
|
-
Key.ObjectId.random()
|
|
153
|
-
]).toString()
|
|
154
|
-
}).createNode({
|
|
155
|
-
id: "gpt-APPEND",
|
|
156
|
-
type: "append"
|
|
157
|
-
}).createNode({
|
|
158
|
-
id: "gpt-OUTPUT",
|
|
159
|
-
type: NODE_OUTPUT
|
|
160
|
-
}).createEdge({
|
|
161
|
-
node: "gpt-INPUT",
|
|
162
|
-
property: "prompt"
|
|
163
|
-
}, {
|
|
164
|
-
node: "gpt-GPT",
|
|
165
|
-
property: "prompt"
|
|
166
|
-
}).createEdge({
|
|
167
|
-
node: "gpt-GPT",
|
|
168
|
-
property: "text"
|
|
169
|
-
}, {
|
|
170
|
-
node: "gpt-OUTPUT",
|
|
171
|
-
property: "text"
|
|
172
|
-
}).createEdge({
|
|
173
|
-
node: "gpt-QUEUE_ID",
|
|
174
|
-
property: DEFAULT_OUTPUT
|
|
175
|
-
}, {
|
|
176
|
-
node: "gpt-APPEND",
|
|
177
|
-
property: "id"
|
|
178
|
-
}).createEdge({
|
|
179
|
-
node: "gpt-GPT",
|
|
180
|
-
property: "messages"
|
|
181
|
-
}, {
|
|
182
|
-
node: "gpt-APPEND",
|
|
183
|
-
property: "items"
|
|
184
|
-
}).createEdge({
|
|
185
|
-
node: "gpt-QUEUE_ID",
|
|
186
|
-
property: DEFAULT_OUTPUT
|
|
187
|
-
}, {
|
|
188
|
-
node: "gpt-OUTPUT",
|
|
189
|
-
property: "queue"
|
|
190
|
-
});
|
|
191
|
-
return space.db.add(model.root);
|
|
192
|
-
});
|
|
193
|
-
cb?.(objects);
|
|
194
|
-
return objects;
|
|
195
|
-
}
|
|
196
|
-
]
|
|
197
|
-
]);
|
|
198
29
|
|
|
199
30
|
// src/components/SpaceGenerator/presets.ts
|
|
200
|
-
import
|
|
201
|
-
import {
|
|
202
|
-
import {
|
|
203
|
-
import {
|
|
31
|
+
import * as Schema from "effect/Schema";
|
|
32
|
+
import { AgentPrompt, WebSearchBlueprint } from "@dxos/assistant-toolkit";
|
|
33
|
+
import { Routine, Trigger, Operation } from "@dxos/compute";
|
|
34
|
+
import { NODE_INPUT } from "@dxos/conductor";
|
|
35
|
+
import { DXN, Feed, Filter, JsonSchema, Key, Obj, Query, Ref, Tag } from "@dxos/echo";
|
|
204
36
|
import { invariant } from "@dxos/invariant";
|
|
205
|
-
import {
|
|
206
|
-
import {
|
|
207
|
-
import {
|
|
37
|
+
import { InboxOperation } from "@dxos/plugin-inbox";
|
|
38
|
+
import { Mailbox } from "@dxos/plugin-inbox";
|
|
39
|
+
import { Markdown } from "@dxos/plugin-markdown";
|
|
40
|
+
import { createAppend, createChat, createComputeGraph, createConstant, createFeed, createFunction, createGpt, createRandom, createSurface, createTemplate, createText, createTrigger } from "@dxos/react-ui-canvas-compute";
|
|
41
|
+
import { CanvasBoard, CanvasGraphModel, pointMultiply, pointsToRect, rectToPoints } from "@dxos/react-ui-canvas-editor";
|
|
42
|
+
import { ViewModel } from "@dxos/schema";
|
|
43
|
+
import { Message, Organization, Person, Pipeline } from "@dxos/types";
|
|
44
|
+
import { range, trim } from "@dxos/util";
|
|
208
45
|
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-debug/src/components/SpaceGenerator/presets.ts";
|
|
209
|
-
var PresetName = /* @__PURE__ */ function(PresetName2) {
|
|
46
|
+
var PresetName = /* @__PURE__ */ (function(PresetName2) {
|
|
47
|
+
PresetName2["DXOS_TEAM"] = "dxos-team";
|
|
48
|
+
PresetName2["ORG_RESEARCH_PROJECT"] = "org-research-project";
|
|
210
49
|
PresetName2["GPT_QUEUE"] = "webhook-gpt-queue";
|
|
211
50
|
PresetName2["CHAT_GPT"] = "chat-gpt-text";
|
|
212
51
|
PresetName2["OBJECT_CHANGE_QUEUE"] = "objectChange-queue";
|
|
213
|
-
PresetName2["FOREX_FUNCTION_CALL"] = "forex-function-call";
|
|
214
52
|
PresetName2["TIMER_TICK_QUEUE"] = "timerTick-queue";
|
|
53
|
+
PresetName2["FOREX_FUNCTION_CALL"] = "forex-function-call";
|
|
215
54
|
PresetName2["DISCORD_MESSAGES"] = "discord-messages";
|
|
216
55
|
return PresetName2;
|
|
217
|
-
}({});
|
|
218
|
-
var
|
|
56
|
+
})({});
|
|
57
|
+
var generator = () => ({
|
|
219
58
|
schemas: [
|
|
220
|
-
|
|
221
|
-
|
|
59
|
+
CanvasBoard.CanvasBoard,
|
|
60
|
+
Trigger.Trigger
|
|
222
61
|
],
|
|
223
62
|
types: Object.values(PresetName).map((name) => ({
|
|
224
63
|
typename: name
|
|
225
64
|
})),
|
|
226
65
|
items: [
|
|
66
|
+
[
|
|
67
|
+
"dxos-team",
|
|
68
|
+
async (space, n, cb) => {
|
|
69
|
+
const objects = range(n, () => {
|
|
70
|
+
const org = space.db.add(Obj.make(Organization.Organization, {
|
|
71
|
+
name: "DXOS",
|
|
72
|
+
website: "https://dxos.org"
|
|
73
|
+
}));
|
|
74
|
+
const doc = space.db.add(Markdown.make({
|
|
75
|
+
name: "DXOS Research",
|
|
76
|
+
content: "DXOS builds Composer, an open-source AI-powered malleable application."
|
|
77
|
+
}));
|
|
78
|
+
const tag = space.db.add(Tag.make({
|
|
79
|
+
label: "Investor"
|
|
80
|
+
}));
|
|
81
|
+
const tagDxn = Obj.getDXN(tag).toString();
|
|
82
|
+
Obj.update(doc, (doc2) => {
|
|
83
|
+
Obj.getMeta(doc2).tags = [
|
|
84
|
+
tagDxn
|
|
85
|
+
];
|
|
86
|
+
});
|
|
87
|
+
space.db.add(Obj.make(Person.Person, {
|
|
88
|
+
[Obj.Meta]: {
|
|
89
|
+
tags: [
|
|
90
|
+
tagDxn
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
fullName: "Rich",
|
|
94
|
+
organization: Ref.make(org)
|
|
95
|
+
}));
|
|
96
|
+
space.db.add(Obj.make(Person.Person, {
|
|
97
|
+
fullName: "Josiah",
|
|
98
|
+
organization: Ref.make(org)
|
|
99
|
+
}));
|
|
100
|
+
space.db.add(Obj.make(Person.Person, {
|
|
101
|
+
fullName: "Dima",
|
|
102
|
+
organization: Ref.make(org)
|
|
103
|
+
}));
|
|
104
|
+
space.db.add(Obj.make(Person.Person, {
|
|
105
|
+
fullName: "Mykola",
|
|
106
|
+
organization: Ref.make(org)
|
|
107
|
+
}));
|
|
108
|
+
return doc;
|
|
109
|
+
});
|
|
110
|
+
cb?.(objects);
|
|
111
|
+
return objects;
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
[
|
|
115
|
+
"org-research-project",
|
|
116
|
+
async (space, n, cb) => {
|
|
117
|
+
const mailboxes = await space.db.query(Filter.type(Mailbox.Mailbox)).run();
|
|
118
|
+
const mailbox = mailboxes[0];
|
|
119
|
+
invariant(mailbox, "Mailbox not found", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 100, S: void 0, A: ["mailbox", "'Mailbox not found'"] });
|
|
120
|
+
const mailboxFeed = await mailbox.feed?.tryLoad();
|
|
121
|
+
invariant(mailboxFeed, "Mailbox missing feed reference", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 102, S: void 0, A: ["mailboxFeed", "'Mailbox missing feed reference'"] });
|
|
122
|
+
const queueDxn = Feed.getQueueDxn(mailboxFeed)?.toString();
|
|
123
|
+
invariant(queueDxn, "Mailbox feed missing queue DXN key", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 104, S: void 0, A: ["queueDxn", "'Mailbox feed missing queue DXN key'"] });
|
|
124
|
+
const tag = await space.db.query(Filter.type(Tag.Tag, {
|
|
125
|
+
label: "Investor"
|
|
126
|
+
})).first();
|
|
127
|
+
const tagDxn = Obj.getDXN(tag).toString();
|
|
128
|
+
const objects = range(n, () => {
|
|
129
|
+
const contactsQuery = Query.select(Filter.type(Person.Person)).select(Filter.tag(tagDxn));
|
|
130
|
+
const organizationsQuery = Query.select(Filter.type(Organization.Organization)).select(Filter.tag(tagDxn));
|
|
131
|
+
const notesQuery = Query.select(Filter.type(Markdown.Document)).select(Filter.tag(tagDxn));
|
|
132
|
+
space.db.add(Trigger.make({
|
|
133
|
+
enabled: true,
|
|
134
|
+
spec: Trigger.specTimer("* * * * *"),
|
|
135
|
+
function: Ref.make(Operation.serialize(InboxOperation.GoogleMailSync)),
|
|
136
|
+
input: {
|
|
137
|
+
mailbox: Ref.make(mailbox)
|
|
138
|
+
}
|
|
139
|
+
}));
|
|
140
|
+
const researchPrompt = space.db.add(Routine.make({
|
|
141
|
+
name: "Research",
|
|
142
|
+
description: "Research organization",
|
|
143
|
+
input: Schema.Struct({
|
|
144
|
+
org: Schema.Any
|
|
145
|
+
}),
|
|
146
|
+
output: Schema.Any,
|
|
147
|
+
// TODO(dmaretskyi): This mocks research (returns pre-baked result), the actual research might take compute minutes.
|
|
148
|
+
// Remove the mock prompt to do the actual research.
|
|
149
|
+
instructions: trim`
|
|
150
|
+
Research the organization provided as input.
|
|
151
|
+
Create a research note for it at the end.
|
|
152
|
+
NOTE: Do mocked reseach (set mockSearch to true).
|
|
153
|
+
`,
|
|
154
|
+
blueprints: [
|
|
155
|
+
Ref.make(WebSearchBlueprint.make())
|
|
156
|
+
]
|
|
157
|
+
}));
|
|
158
|
+
space.db.add(Trigger.make({
|
|
159
|
+
enabled: true,
|
|
160
|
+
spec: Trigger.specSubscription(organizationsQuery),
|
|
161
|
+
function: Ref.make(Operation.serialize(AgentPrompt)),
|
|
162
|
+
input: {
|
|
163
|
+
prompt: Ref.make(researchPrompt),
|
|
164
|
+
input: "{{event.subject}}"
|
|
165
|
+
}
|
|
166
|
+
}));
|
|
167
|
+
const mailboxView = ViewModel.make({
|
|
168
|
+
query: Query.select(Filter.type(Message.Message, {
|
|
169
|
+
properties: {
|
|
170
|
+
labels: Filter.contains("investor")
|
|
171
|
+
}
|
|
172
|
+
})).from({
|
|
173
|
+
queues: [
|
|
174
|
+
queueDxn
|
|
175
|
+
]
|
|
176
|
+
}),
|
|
177
|
+
jsonSchema: JsonSchema.toJsonSchema(Message.Message)
|
|
178
|
+
});
|
|
179
|
+
const contactsView = ViewModel.make({
|
|
180
|
+
query: contactsQuery,
|
|
181
|
+
jsonSchema: JsonSchema.toJsonSchema(Person.Person)
|
|
182
|
+
});
|
|
183
|
+
const organizationsView = ViewModel.make({
|
|
184
|
+
query: organizationsQuery,
|
|
185
|
+
jsonSchema: JsonSchema.toJsonSchema(Organization.Organization)
|
|
186
|
+
});
|
|
187
|
+
const notesView = ViewModel.make({
|
|
188
|
+
query: notesQuery,
|
|
189
|
+
jsonSchema: JsonSchema.toJsonSchema(Markdown.Document)
|
|
190
|
+
});
|
|
191
|
+
return space.db.add(Pipeline.make({
|
|
192
|
+
name: "Investor Research",
|
|
193
|
+
columns: [
|
|
194
|
+
{
|
|
195
|
+
name: "Mailbox",
|
|
196
|
+
view: Ref.make(mailboxView),
|
|
197
|
+
order: []
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
name: "Contacts",
|
|
201
|
+
view: Ref.make(contactsView),
|
|
202
|
+
order: []
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
name: "Organizations",
|
|
206
|
+
view: Ref.make(organizationsView),
|
|
207
|
+
order: []
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
name: "Notes",
|
|
211
|
+
view: Ref.make(notesView),
|
|
212
|
+
order: []
|
|
213
|
+
}
|
|
214
|
+
]
|
|
215
|
+
}));
|
|
216
|
+
});
|
|
217
|
+
cb?.(objects.flat());
|
|
218
|
+
return objects.flat();
|
|
219
|
+
}
|
|
220
|
+
],
|
|
227
221
|
[
|
|
228
222
|
"webhook-gpt-queue",
|
|
229
223
|
async (space, n, cb) => {
|
|
230
|
-
const objects =
|
|
224
|
+
const objects = range(n, () => {
|
|
231
225
|
const canvasModel = CanvasGraphModel.create();
|
|
232
226
|
let functionTrigger;
|
|
233
227
|
canvasModel.builder.call((builder) => {
|
|
@@ -287,8 +281,10 @@ var generator2 = () => ({
|
|
|
287
281
|
[
|
|
288
282
|
"objectChange-queue",
|
|
289
283
|
async (space, n, cb) => {
|
|
290
|
-
const objects =
|
|
291
|
-
const { canvasModel, computeModel } = createQueueSinkPreset(space, "subscription", (triggerSpec) => triggerSpec.query =
|
|
284
|
+
const objects = range(n, () => {
|
|
285
|
+
const { canvasModel, computeModel } = createQueueSinkPreset(space, "subscription", (triggerSpec) => triggerSpec.query = {
|
|
286
|
+
ast: Query.select(Filter.typename("org.dxos.type.chess")).ast
|
|
287
|
+
}, "type");
|
|
292
288
|
return addToSpace("objectChange-queue", space, canvasModel, computeModel);
|
|
293
289
|
});
|
|
294
290
|
cb?.(objects);
|
|
@@ -298,7 +294,7 @@ var generator2 = () => ({
|
|
|
298
294
|
[
|
|
299
295
|
"timerTick-queue",
|
|
300
296
|
async (space, n, cb) => {
|
|
301
|
-
const objects =
|
|
297
|
+
const objects = range(n, () => {
|
|
302
298
|
const { canvasModel, computeModel } = createQueueSinkPreset(space, "timer", (triggerSpec) => triggerSpec.cron = "*/5 * * * * *", "result");
|
|
303
299
|
return addToSpace("timerTick-queue", space, canvasModel, computeModel);
|
|
304
300
|
});
|
|
@@ -353,7 +349,7 @@ var generator2 = () => ({
|
|
|
353
349
|
// const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
|
|
354
350
|
// invariant(templateComputeNode, 'Template compute node was not created.');
|
|
355
351
|
// templateComputeNode.value = templateContent.join('\n');
|
|
356
|
-
// templateComputeNode.inputSchema =
|
|
352
|
+
// templateComputeNode.inputSchema = JsonSchema.toJsonSchema(EmailTriggerOutput);
|
|
357
353
|
// attachTrigger(functionTrigger, computeModel);
|
|
358
354
|
// return addToSpace(PresetName.EMAIL_TABLE, space, canvasModel, computeModel);
|
|
359
355
|
// });
|
|
@@ -364,7 +360,7 @@ var generator2 = () => ({
|
|
|
364
360
|
[
|
|
365
361
|
"chat-gpt-text",
|
|
366
362
|
async (space, n, cb) => {
|
|
367
|
-
const objects =
|
|
363
|
+
const objects = range(n, () => {
|
|
368
364
|
const canvasModel = CanvasGraphModel.create();
|
|
369
365
|
canvasModel.builder.call((builder) => {
|
|
370
366
|
const gpt = canvasModel.createNode(createGpt(position({
|
|
@@ -484,7 +480,7 @@ var generator2 = () => ({
|
|
|
484
480
|
// invariant(templateComputeNode, 'Template compute node was not created.');
|
|
485
481
|
// templateComputeNode.value = templateContent.join('\n');
|
|
486
482
|
// const extendedSchema = Schema.extend(EmailTriggerOutput, Schema.Struct({ text: Schema.String }));
|
|
487
|
-
// templateComputeNode.inputSchema =
|
|
483
|
+
// templateComputeNode.inputSchema = JsonSchema.toJsonSchema(extendedSchema);
|
|
488
484
|
// attachTrigger(functionTrigger, computeModel);
|
|
489
485
|
// return addToSpace(PresetName.EMAIL_WITH_SUMMARY, space, canvasModel, computeModel);
|
|
490
486
|
// });
|
|
@@ -495,7 +491,7 @@ var generator2 = () => ({
|
|
|
495
491
|
[
|
|
496
492
|
"forex-function-call",
|
|
497
493
|
async (space, n, cb) => {
|
|
498
|
-
const objects =
|
|
494
|
+
const objects = range(n, () => {
|
|
499
495
|
const canvasModel = CanvasGraphModel.create();
|
|
500
496
|
canvasModel.builder.call((builder) => {
|
|
501
497
|
const sourceCurrency = canvasModel.createNode(createConstant({
|
|
@@ -544,7 +540,7 @@ var generator2 = () => ({
|
|
|
544
540
|
[
|
|
545
541
|
"discord-messages",
|
|
546
542
|
async (space, n, cb) => {
|
|
547
|
-
const objects =
|
|
543
|
+
const objects = range(n, () => {
|
|
548
544
|
const canvasModel = CanvasGraphModel.create();
|
|
549
545
|
let functionTrigger;
|
|
550
546
|
canvasModel.builder.call((builder) => {
|
|
@@ -565,10 +561,10 @@ var generator2 = () => ({
|
|
|
565
561
|
})
|
|
566
562
|
}));
|
|
567
563
|
const queueId = canvasModel.createNode(createConstant({
|
|
568
|
-
value: new
|
|
564
|
+
value: new DXN(DXN.kind.QUEUE, [
|
|
569
565
|
"data",
|
|
570
566
|
space.id,
|
|
571
|
-
|
|
567
|
+
Key.ObjectId.random()
|
|
572
568
|
]).toString(),
|
|
573
569
|
...position({
|
|
574
570
|
x: -10,
|
|
@@ -583,7 +579,7 @@ var generator2 = () => ({
|
|
|
583
579
|
x: 12,
|
|
584
580
|
y: 0
|
|
585
581
|
})));
|
|
586
|
-
const queue = canvasModel.createNode(
|
|
582
|
+
const queue = canvasModel.createNode(createFeed(position({
|
|
587
583
|
x: 0,
|
|
588
584
|
y: 12
|
|
589
585
|
})));
|
|
@@ -658,7 +654,7 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
|
|
|
658
654
|
width: 128,
|
|
659
655
|
height: 122
|
|
660
656
|
})));
|
|
661
|
-
const
|
|
657
|
+
const random2 = canvasModel.createNode(createRandom(rawPosition({
|
|
662
658
|
centerX: -509,
|
|
663
659
|
centerY: -30,
|
|
664
660
|
width: 64,
|
|
@@ -678,41 +674,27 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
|
|
|
678
674
|
output: triggerOutputName,
|
|
679
675
|
input: "type"
|
|
680
676
|
}).createEdge({
|
|
681
|
-
source:
|
|
677
|
+
source: random2.id,
|
|
682
678
|
target: template.id,
|
|
683
679
|
input: "changeId"
|
|
684
680
|
});
|
|
685
681
|
functionTrigger = triggerShape.functionTrigger.target;
|
|
686
682
|
const triggerSpec = functionTrigger.spec;
|
|
687
|
-
invariant(triggerSpec && triggerSpec.kind === triggerKind, "No trigger spec.", {
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
S: void 0,
|
|
691
|
-
A: [
|
|
692
|
-
"triggerSpec && triggerSpec.kind === triggerKind",
|
|
693
|
-
"'No trigger spec.'"
|
|
694
|
-
]
|
|
683
|
+
invariant(triggerSpec && triggerSpec.kind === triggerKind, "No trigger spec.", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 665, S: void 0, A: ["triggerSpec && triggerSpec.kind === triggerKind", "'No trigger spec.'"] });
|
|
684
|
+
Obj.update(functionTrigger, (functionTrigger2) => {
|
|
685
|
+
initSpec(functionTrigger2.spec);
|
|
695
686
|
});
|
|
696
|
-
initSpec(triggerSpec);
|
|
697
687
|
});
|
|
698
688
|
const computeModel = createComputeGraph(canvasModel);
|
|
699
689
|
const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
|
|
700
|
-
invariant(templateComputeNode, "Template compute node was not created.", {
|
|
701
|
-
F: __dxlog_file,
|
|
702
|
-
L: 503,
|
|
703
|
-
S: void 0,
|
|
704
|
-
A: [
|
|
705
|
-
"templateComputeNode",
|
|
706
|
-
"'Template compute node was not created.'"
|
|
707
|
-
]
|
|
708
|
-
});
|
|
690
|
+
invariant(templateComputeNode, "Template compute node was not created.", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 672, S: void 0, A: ["templateComputeNode", "'Template compute node was not created.'"] });
|
|
709
691
|
templateComputeNode.value = [
|
|
710
692
|
"{",
|
|
711
693
|
' "@type": "{{type}}",',
|
|
712
694
|
' "id": "@{{changeId}}"',
|
|
713
695
|
"}"
|
|
714
696
|
].join("\n");
|
|
715
|
-
templateComputeNode.inputSchema =
|
|
697
|
+
templateComputeNode.inputSchema = JsonSchema.toJsonSchema(Schema.Struct({
|
|
716
698
|
type: Schema.String,
|
|
717
699
|
changeId: Schema.String
|
|
718
700
|
}));
|
|
@@ -723,18 +705,18 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
|
|
|
723
705
|
};
|
|
724
706
|
};
|
|
725
707
|
var addToSpace = (name, space, canvas, compute) => {
|
|
726
|
-
return space.db.add(
|
|
708
|
+
return space.db.add(Obj.make(CanvasBoard.CanvasBoard, {
|
|
727
709
|
name,
|
|
728
|
-
computeGraph:
|
|
710
|
+
computeGraph: Ref.make(compute.root),
|
|
729
711
|
layout: canvas.graph
|
|
730
712
|
}));
|
|
731
713
|
};
|
|
732
714
|
var setupQueue = (space, canvasModel, args) => {
|
|
733
715
|
const queueId = canvasModel.createNode(createConstant({
|
|
734
|
-
value: new
|
|
716
|
+
value: new DXN(DXN.kind.QUEUE, [
|
|
735
717
|
"data",
|
|
736
718
|
space.id,
|
|
737
|
-
|
|
719
|
+
Key.ObjectId.random()
|
|
738
720
|
]).toString(),
|
|
739
721
|
...args?.idPosition ? rawPosition(args.idPosition) : position({
|
|
740
722
|
x: -18,
|
|
@@ -743,7 +725,7 @@ var setupQueue = (space, canvasModel, args) => {
|
|
|
743
725
|
height: 6
|
|
744
726
|
})
|
|
745
727
|
}));
|
|
746
|
-
const queue = canvasModel.createNode(
|
|
728
|
+
const queue = canvasModel.createNode(createFeed(args?.queuePosition ? rawPosition(args.queuePosition) : position({
|
|
747
729
|
x: -3,
|
|
748
730
|
y: 3,
|
|
749
731
|
width: 14,
|
|
@@ -759,18 +741,12 @@ var setupQueue = (space, canvasModel, args) => {
|
|
|
759
741
|
};
|
|
760
742
|
};
|
|
761
743
|
var attachTrigger = (functionTrigger, computeModel) => {
|
|
762
|
-
invariant(functionTrigger, void 0, {
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
"functionTrigger",
|
|
768
|
-
""
|
|
769
|
-
]
|
|
744
|
+
invariant(functionTrigger, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 727, S: void 0, A: ["functionTrigger", ""] });
|
|
745
|
+
const inputNode = computeModel.nodes.find((node) => node.type === NODE_INPUT);
|
|
746
|
+
Obj.update(functionTrigger, (functionTrigger2) => {
|
|
747
|
+
functionTrigger2.function = Ref.make(computeModel.root);
|
|
748
|
+
functionTrigger2.inputNodeId = inputNode.id;
|
|
770
749
|
});
|
|
771
|
-
functionTrigger.function = Ref2.make(computeModel.root);
|
|
772
|
-
const inputNode = computeModel.nodes.find((node) => node.type === NODE_INPUT2);
|
|
773
|
-
functionTrigger.inputNodeId = inputNode.id;
|
|
774
750
|
};
|
|
775
751
|
var rawPosition = (args) => {
|
|
776
752
|
return {
|
|
@@ -816,163 +792,190 @@ var position = (rect) => {
|
|
|
816
792
|
}
|
|
817
793
|
};
|
|
818
794
|
|
|
819
|
-
// src/components/SpaceGenerator/
|
|
820
|
-
import {
|
|
821
|
-
import
|
|
822
|
-
import {
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
}, type.typename), /* @__PURE__ */ React.createElement("div", {
|
|
836
|
-
className: "px-2 text-right font-mono"
|
|
837
|
-
}, objects[type.typename] ?? 0), /* @__PURE__ */ React.createElement(IconButton, {
|
|
838
|
-
variant: "ghost",
|
|
839
|
-
icon: "ph--plus--regular",
|
|
840
|
-
iconOnly: true,
|
|
841
|
-
label: "Create data",
|
|
842
|
-
onClick: () => onClick(type.typename)
|
|
843
|
-
}))));
|
|
844
|
-
} finally {
|
|
845
|
-
_effect.f();
|
|
846
|
-
}
|
|
795
|
+
// src/components/SpaceGenerator/ObjectGenerator.tsx
|
|
796
|
+
import { addressToA1Notation } from "@dxos/compute-hyperformula";
|
|
797
|
+
import { ComputeGraph, ComputeGraphModel, DEFAULT_OUTPUT, NODE_INPUT as NODE_INPUT2, NODE_OUTPUT } from "@dxos/conductor";
|
|
798
|
+
import { DXN as DXN2, Filter as Filter2, Key as Key2 } from "@dxos/echo";
|
|
799
|
+
import { View } from "@dxos/echo";
|
|
800
|
+
import { Markdown as Markdown2 } from "@dxos/plugin-markdown";
|
|
801
|
+
import { Sheet } from "@dxos/plugin-sheet";
|
|
802
|
+
import { Sketch } from "@dxos/plugin-sketch";
|
|
803
|
+
import { SpaceOperation } from "@dxos/plugin-space";
|
|
804
|
+
import { random } from "@dxos/random";
|
|
805
|
+
import { getTypenameFromQuery } from "@dxos/schema";
|
|
806
|
+
import { createAsyncGenerator } from "@dxos/schema/testing";
|
|
807
|
+
import { range as range2 } from "@dxos/util";
|
|
808
|
+
var generator2 = random;
|
|
809
|
+
var findViewByTypename = async (views, typename) => {
|
|
810
|
+
return views.find((view) => getTypenameFromQuery(view.query.ast) === typename);
|
|
847
811
|
};
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
const
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
const recordTypes = [
|
|
862
|
-
DataType2.Organization,
|
|
863
|
-
DataType2.Person,
|
|
864
|
-
DataType2.Task
|
|
865
|
-
];
|
|
866
|
-
const [count, setCount] = useState(1);
|
|
867
|
-
const [info, setInfo] = useState({});
|
|
868
|
-
const presets = useMemo(() => generator2(), []);
|
|
869
|
-
const typeMap = useMemo(() => {
|
|
870
|
-
client.addTypes([
|
|
871
|
-
...staticTypes,
|
|
872
|
-
...recordTypes,
|
|
873
|
-
...presets.schemas
|
|
874
|
-
]);
|
|
875
|
-
const recordGenerators = new Map(recordTypes.map((type) => [
|
|
876
|
-
type.typename,
|
|
877
|
-
createGenerator(client, dispatch, type)
|
|
878
|
-
]));
|
|
879
|
-
return new Map([
|
|
880
|
-
...staticGenerators,
|
|
881
|
-
...presets.items,
|
|
882
|
-
...recordGenerators
|
|
883
|
-
]);
|
|
884
|
-
}, [
|
|
885
|
-
client,
|
|
886
|
-
recordTypes
|
|
887
|
-
]);
|
|
888
|
-
const updateInfo = async () => {
|
|
889
|
-
const echoSchema = await space.db.schemaRegistry.query().run();
|
|
890
|
-
const staticSchema = space.db.graph.schemaRegistry.schemas;
|
|
891
|
-
const { objects } = await space.db.query(Filter3.everything()).run();
|
|
892
|
-
const objectMap = sortKeys(objects.reduce((map, obj) => {
|
|
893
|
-
const type = getTypename(obj);
|
|
894
|
-
if (type) {
|
|
895
|
-
const count2 = map[type] ?? 0;
|
|
896
|
-
map[type] = count2 + 1;
|
|
897
|
-
}
|
|
898
|
-
return map;
|
|
899
|
-
}, {}));
|
|
900
|
-
setInfo({
|
|
901
|
-
schema: {
|
|
902
|
-
static: staticSchema.length,
|
|
903
|
-
mutable: echoSchema.length
|
|
904
|
-
},
|
|
905
|
-
objects: objectMap
|
|
812
|
+
var createGenerator = (client, invokePromise, schema) => {
|
|
813
|
+
return async (space, n) => {
|
|
814
|
+
const typename = schema.typename;
|
|
815
|
+
const views = await space.db.query(Filter2.type(View.View)).run();
|
|
816
|
+
const view = await findViewByTypename(views, typename);
|
|
817
|
+
const staticSchema = client?.graph.schemaRegistry.query({
|
|
818
|
+
typename
|
|
819
|
+
}).runSync()[0];
|
|
820
|
+
if (!view && !staticSchema) {
|
|
821
|
+
await invokePromise(SpaceOperation.AddSchema, {
|
|
822
|
+
db: space.db,
|
|
823
|
+
schema,
|
|
824
|
+
show: false
|
|
906
825
|
});
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
space
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
if (constructor) {
|
|
914
|
-
await constructor(space, count, onCreateObjects);
|
|
915
|
-
await updateInfo();
|
|
916
|
-
}
|
|
917
|
-
}, [
|
|
918
|
-
typeMap,
|
|
919
|
-
count
|
|
920
|
-
]);
|
|
921
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
922
|
-
role: "none",
|
|
923
|
-
className: "flex flex-col grow overflow-hidden"
|
|
924
|
-
}, /* @__PURE__ */ React2.createElement(Toolbar.Root, {
|
|
925
|
-
classNames: "border-be border-subduedSeparator"
|
|
926
|
-
}, /* @__PURE__ */ React2.createElement(IconButton2, {
|
|
927
|
-
icon: "ph--arrow-clockwise--regular",
|
|
928
|
-
iconOnly: true,
|
|
929
|
-
label: "Refresh",
|
|
930
|
-
onClick: updateInfo
|
|
931
|
-
}), /* @__PURE__ */ React2.createElement(Toolbar.Separator, {
|
|
932
|
-
variant: "gap"
|
|
933
|
-
}), /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
934
|
-
type: "number",
|
|
935
|
-
min: 1,
|
|
936
|
-
max: 100,
|
|
937
|
-
placeholder: "Count",
|
|
938
|
-
classNames: "!w-[4rem] !text-right",
|
|
939
|
-
size: 8,
|
|
940
|
-
value: count,
|
|
941
|
-
onChange: (ev) => setCount(parseInt(ev.target.value))
|
|
942
|
-
}))), /* @__PURE__ */ React2.createElement("div", {
|
|
943
|
-
className: "flex flex-col overflow-y-auto divide-y divide-separator"
|
|
944
|
-
}, /* @__PURE__ */ React2.createElement(SchemaTable, {
|
|
945
|
-
types: staticTypes,
|
|
946
|
-
objects: info.objects,
|
|
947
|
-
label: "Static Types",
|
|
948
|
-
onClick: handleCreateData
|
|
949
|
-
}), /* @__PURE__ */ React2.createElement(SchemaTable, {
|
|
950
|
-
types: recordTypes,
|
|
951
|
-
objects: info.objects,
|
|
952
|
-
label: "Record Types",
|
|
953
|
-
onClick: handleCreateData
|
|
954
|
-
}), /* @__PURE__ */ React2.createElement(SchemaTable, {
|
|
955
|
-
types: presets.types,
|
|
956
|
-
objects: info.objects,
|
|
957
|
-
label: "Presets",
|
|
958
|
-
onClick: handleCreateData
|
|
959
|
-
}), /* @__PURE__ */ React2.createElement("div", null, /* @__PURE__ */ React2.createElement(SyntaxHighlighter, {
|
|
960
|
-
language: "json",
|
|
961
|
-
classNames: "text-xs"
|
|
962
|
-
}, JSON.stringify({
|
|
963
|
-
space,
|
|
964
|
-
...info
|
|
965
|
-
}, jsonKeyReplacer({
|
|
966
|
-
truncate: true
|
|
967
|
-
}), 2)))));
|
|
968
|
-
} finally {
|
|
969
|
-
_effect.f();
|
|
970
|
-
}
|
|
826
|
+
}
|
|
827
|
+
const generate = createAsyncGenerator(generator2, schema, {
|
|
828
|
+
db: space.db
|
|
829
|
+
});
|
|
830
|
+
return generate.createObjects(n);
|
|
831
|
+
};
|
|
971
832
|
};
|
|
833
|
+
var staticGenerators = /* @__PURE__ */ new Map([
|
|
834
|
+
[
|
|
835
|
+
Markdown2.Document.typename,
|
|
836
|
+
async (space, n, cb) => {
|
|
837
|
+
const objects = range2(n).map(() => {
|
|
838
|
+
return space.db.add(Markdown2.make({
|
|
839
|
+
name: random.commerce.productName(),
|
|
840
|
+
content: random.lorem.sentences(5)
|
|
841
|
+
}));
|
|
842
|
+
});
|
|
843
|
+
cb?.(objects);
|
|
844
|
+
return objects;
|
|
845
|
+
}
|
|
846
|
+
],
|
|
847
|
+
[
|
|
848
|
+
Sketch.Sketch.typename,
|
|
849
|
+
async (space, n, cb) => {
|
|
850
|
+
const objects = range2(n).map(() => {
|
|
851
|
+
const obj = space.db.add(Sketch.make({
|
|
852
|
+
name: random.commerce.productName()
|
|
853
|
+
}));
|
|
854
|
+
return obj;
|
|
855
|
+
});
|
|
856
|
+
cb?.(objects);
|
|
857
|
+
return objects;
|
|
858
|
+
}
|
|
859
|
+
],
|
|
860
|
+
// TODO(burdon): Create unit tests.
|
|
861
|
+
[
|
|
862
|
+
Sheet.Sheet.typename,
|
|
863
|
+
async (space, n, cb) => {
|
|
864
|
+
const objects = range2(n).map(() => {
|
|
865
|
+
const cells = {};
|
|
866
|
+
const year = (/* @__PURE__ */ new Date()).getFullYear();
|
|
867
|
+
const cols = 4;
|
|
868
|
+
const rows = 16;
|
|
869
|
+
for (let col = 1; col <= cols; col++) {
|
|
870
|
+
for (let row = 1; row <= rows; row++) {
|
|
871
|
+
const cell = addressToA1Notation({
|
|
872
|
+
col,
|
|
873
|
+
row
|
|
874
|
+
});
|
|
875
|
+
if (row === 1) {
|
|
876
|
+
cells[cell] = {
|
|
877
|
+
value: `${year} Q${col}`
|
|
878
|
+
};
|
|
879
|
+
} else if (row === rows) {
|
|
880
|
+
const from = addressToA1Notation({
|
|
881
|
+
col,
|
|
882
|
+
row: 2
|
|
883
|
+
});
|
|
884
|
+
const to = addressToA1Notation({
|
|
885
|
+
col,
|
|
886
|
+
row: rows - 1
|
|
887
|
+
});
|
|
888
|
+
cells[cell] = {
|
|
889
|
+
value: `=SUM(${from}:${to})`
|
|
890
|
+
};
|
|
891
|
+
} else if (row > 2 && row < rows - 1) {
|
|
892
|
+
cells[cell] = {
|
|
893
|
+
value: Math.floor(Math.random() * 1e4)
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
return space.db.add(Sheet.make({
|
|
899
|
+
name: random.commerce.productName(),
|
|
900
|
+
cells
|
|
901
|
+
}));
|
|
902
|
+
});
|
|
903
|
+
cb?.(objects);
|
|
904
|
+
return objects;
|
|
905
|
+
}
|
|
906
|
+
],
|
|
907
|
+
[
|
|
908
|
+
ComputeGraph.typename,
|
|
909
|
+
async (space, n, cb) => {
|
|
910
|
+
const objects = range2(n, () => {
|
|
911
|
+
const model = ComputeGraphModel.create();
|
|
912
|
+
model.builder.createNode({
|
|
913
|
+
id: "gpt-INPUT",
|
|
914
|
+
type: NODE_INPUT2
|
|
915
|
+
}).createNode({
|
|
916
|
+
id: "gpt-GPT",
|
|
917
|
+
type: "gpt"
|
|
918
|
+
}).createNode({
|
|
919
|
+
id: "gpt-QUEUE_ID",
|
|
920
|
+
type: "constant",
|
|
921
|
+
value: new DXN2(DXN2.kind.QUEUE, [
|
|
922
|
+
"data",
|
|
923
|
+
space.id,
|
|
924
|
+
Key2.ObjectId.random()
|
|
925
|
+
]).toString()
|
|
926
|
+
}).createNode({
|
|
927
|
+
id: "gpt-APPEND",
|
|
928
|
+
type: "append"
|
|
929
|
+
}).createNode({
|
|
930
|
+
id: "gpt-OUTPUT",
|
|
931
|
+
type: NODE_OUTPUT
|
|
932
|
+
}).createEdge({
|
|
933
|
+
node: "gpt-INPUT",
|
|
934
|
+
property: "prompt"
|
|
935
|
+
}, {
|
|
936
|
+
node: "gpt-GPT",
|
|
937
|
+
property: "prompt"
|
|
938
|
+
}).createEdge({
|
|
939
|
+
node: "gpt-GPT",
|
|
940
|
+
property: "text"
|
|
941
|
+
}, {
|
|
942
|
+
node: "gpt-OUTPUT",
|
|
943
|
+
property: "text"
|
|
944
|
+
}).createEdge({
|
|
945
|
+
node: "gpt-QUEUE_ID",
|
|
946
|
+
property: DEFAULT_OUTPUT
|
|
947
|
+
}, {
|
|
948
|
+
node: "gpt-APPEND",
|
|
949
|
+
property: "id"
|
|
950
|
+
}).createEdge({
|
|
951
|
+
node: "gpt-GPT",
|
|
952
|
+
property: "messages"
|
|
953
|
+
}, {
|
|
954
|
+
node: "gpt-APPEND",
|
|
955
|
+
property: "items"
|
|
956
|
+
}).createEdge({
|
|
957
|
+
node: "gpt-QUEUE_ID",
|
|
958
|
+
property: DEFAULT_OUTPUT
|
|
959
|
+
}, {
|
|
960
|
+
node: "gpt-OUTPUT",
|
|
961
|
+
property: "queue"
|
|
962
|
+
});
|
|
963
|
+
return space.db.add(model.root);
|
|
964
|
+
});
|
|
965
|
+
cb?.(objects);
|
|
966
|
+
return objects;
|
|
967
|
+
}
|
|
968
|
+
]
|
|
969
|
+
]);
|
|
972
970
|
|
|
973
|
-
// src/components/
|
|
974
|
-
var
|
|
971
|
+
// src/components/index.ts
|
|
972
|
+
var DebugSettings = lazy(() => import("../DebugSettings-Z3XADRNK.mjs"));
|
|
975
973
|
export {
|
|
976
|
-
|
|
974
|
+
DebugSettings,
|
|
975
|
+
PresetName,
|
|
976
|
+
SchemaTable,
|
|
977
|
+
createGenerator,
|
|
978
|
+
generator,
|
|
979
|
+
staticGenerators
|
|
977
980
|
};
|
|
978
|
-
//# sourceMappingURL=
|
|
981
|
+
//# sourceMappingURL=index.mjs.map
|