@dxos/plugin-debug 0.8.3 → 0.8.4-main.1068cf700f
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-6VMEOKEV.mjs +15 -0
- package/dist/lib/browser/DebugGraph-6VMEOKEV.mjs.map +7 -0
- package/dist/lib/browser/DevtoolsOverviewContainer-2C6XMJ3L.mjs +19 -0
- package/dist/lib/browser/DevtoolsOverviewContainer-2C6XMJ3L.mjs.map +7 -0
- package/dist/lib/browser/SpaceGenerator-W3LJORYT.mjs +1152 -0
- package/dist/lib/browser/SpaceGenerator-W3LJORYT.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-DEBTVBQG.mjs +599 -0
- package/dist/lib/browser/app-graph-builder-DEBTVBQG.mjs.map +7 -0
- package/dist/lib/browser/{chunk-KS3YBEL7.mjs → chunk-4UFQXPP7.mjs} +13 -3
- package/dist/lib/browser/chunk-4UFQXPP7.mjs.map +7 -0
- package/dist/lib/browser/chunk-A5H5GRV6.mjs +20 -0
- package/dist/lib/browser/chunk-A5H5GRV6.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +42 -46
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-context-I3USIAF6.mjs +17 -0
- package/dist/lib/browser/react-context-I3USIAF6.mjs.map +7 -0
- package/dist/lib/browser/react-surface-FMVC5GPV.mjs +758 -0
- package/dist/lib/browser/react-surface-FMVC5GPV.mjs.map +7 -0
- package/dist/lib/browser/settings-SLTQJJNF.mjs +32 -0
- package/dist/lib/browser/settings-SLTQJJNF.mjs.map +7 -0
- package/dist/types/src/DebugPlugin.d.ts +2 -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 +3 -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 +5 -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/DebugGraph.d.ts +9 -0
- package/dist/types/src/components/DebugGraph.d.ts.map +1 -0
- package/dist/types/src/components/DebugObjectPanel.d.ts +1 -1
- package/dist/types/src/components/DebugObjectPanel.d.ts.map +1 -1
- package/dist/types/src/components/DebugSettings.d.ts +4 -2
- package/dist/types/src/components/DebugSettings.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts +6 -4
- package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts +1 -1
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts +13 -4
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/draw-util.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/presets.d.ts +5 -8
- package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -1
- package/dist/types/src/components/Wireframe.d.ts +2 -2
- package/dist/types/src/components/Wireframe.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +4 -3
- package/dist/types/src/components/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/translations.d.ts +62 -60
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +6 -1
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +79 -71
- package/src/DebugPlugin.tsx +19 -34
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +421 -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 +20 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +411 -0
- package/src/capabilities/settings/index.ts +7 -0
- package/src/capabilities/settings/settings.ts +31 -0
- package/src/components/DebugGraph.tsx +15 -0
- package/src/components/DebugObjectPanel.tsx +6 -9
- package/src/components/DebugSettings.tsx +109 -75
- package/src/components/DebugStatus.tsx +2 -2
- package/src/components/DevtoolsOverviewContainer.tsx +2 -2
- package/src/components/SpaceGenerator/ObjectGenerator.tsx +40 -41
- package/src/components/SpaceGenerator/SchemaTable.tsx +2 -2
- package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +17 -15
- package/src/components/SpaceGenerator/SpaceGenerator.tsx +41 -94
- package/src/components/SpaceGenerator/draw-util.ts +5 -5
- package/src/components/SpaceGenerator/presets.ts +537 -259
- package/src/components/Wireframe.tsx +6 -6
- package/src/components/index.ts +4 -1
- package/src/meta.ts +8 -7
- package/src/translations.ts +9 -5
- package/src/types.ts +9 -1
- package/dist/lib/browser/DebugApp-WSEJPCKY.mjs +0 -225
- package/dist/lib/browser/DebugApp-WSEJPCKY.mjs.map +0 -7
- package/dist/lib/browser/DevtoolsOverviewContainer-IIIWO77Q.mjs +0 -25
- package/dist/lib/browser/DevtoolsOverviewContainer-IIIWO77Q.mjs.map +0 -7
- package/dist/lib/browser/SpaceGenerator-VB6IB2LL.mjs +0 -1238
- package/dist/lib/browser/SpaceGenerator-VB6IB2LL.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-6HHJMKVU.mjs +0 -597
- package/dist/lib/browser/app-graph-builder-6HHJMKVU.mjs.map +0 -7
- package/dist/lib/browser/chunk-47JOZTT2.mjs +0 -18
- package/dist/lib/browser/chunk-47JOZTT2.mjs.map +0 -7
- package/dist/lib/browser/chunk-KS3YBEL7.mjs.map +0 -7
- package/dist/lib/browser/react-context-ZQRD2WG2.mjs +0 -16
- package/dist/lib/browser/react-context-ZQRD2WG2.mjs.map +0 -7
- package/dist/lib/browser/react-surface-UI6OK73H.mjs +0 -768
- package/dist/lib/browser/react-surface-UI6OK73H.mjs.map +0 -7
- package/dist/lib/browser/settings-SXQWSIM4.mjs +0 -22
- package/dist/lib/browser/settings-SXQWSIM4.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/DebugApp/DebugApp.d.ts +0 -6
- package/dist/types/src/components/DebugApp/DebugApp.d.ts.map +0 -1
- package/dist/types/src/components/DebugApp/Tree.d.ts +0 -18
- package/dist/types/src/components/DebugApp/Tree.d.ts.map +0 -1
- package/dist/types/src/components/DebugApp/index.d.ts +0 -3
- package/dist/types/src/components/DebugApp/index.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder.ts +0 -457
- package/src/capabilities/react-context.tsx +0 -16
- package/src/capabilities/react-surface.tsx +0 -397
- package/src/capabilities/settings.ts +0 -19
- package/src/components/DebugApp/DebugApp.tsx +0 -77
- package/src/components/DebugApp/Tree.tsx +0 -103
- package/src/components/DebugApp/index.ts +0 -7
|
@@ -1,1238 +0,0 @@
|
|
|
1
|
-
// packages/plugins/plugin-debug/src/components/SpaceGenerator/SpaceGenerator.tsx
|
|
2
|
-
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
3
|
-
import React2, { useCallback, useMemo, useState } from "react";
|
|
4
|
-
import { createIntent, useIntentDispatcher } from "@dxos/app-framework";
|
|
5
|
-
import { ComputeGraph as ComputeGraph2 } from "@dxos/conductor";
|
|
6
|
-
import { Filter as Filter3, Obj as Obj3, Type as Type2 } from "@dxos/echo";
|
|
7
|
-
import { log } from "@dxos/log";
|
|
8
|
-
import { DocumentType as DocumentType2 } from "@dxos/plugin-markdown/types";
|
|
9
|
-
import { SheetType as SheetType2 } from "@dxos/plugin-sheet/types";
|
|
10
|
-
import { DiagramType as DiagramType2 } from "@dxos/plugin-sketch/types";
|
|
11
|
-
import { SpaceAction } from "@dxos/plugin-space/types";
|
|
12
|
-
import { useClient } from "@dxos/react-client";
|
|
13
|
-
import { getTypename } from "@dxos/react-client/echo";
|
|
14
|
-
import { IconButton as IconButton2, Input, Toolbar, useAsyncEffect } from "@dxos/react-ui";
|
|
15
|
-
import { SyntaxHighlighter } from "@dxos/react-ui-syntax-highlighter";
|
|
16
|
-
import { initializeTable, TableType as TableType3 } from "@dxos/react-ui-table";
|
|
17
|
-
import { DataType as DataType2 } from "@dxos/schema";
|
|
18
|
-
import { jsonKeyReplacer, sortKeys } from "@dxos/util";
|
|
19
|
-
|
|
20
|
-
// packages/plugins/plugin-debug/src/components/SpaceGenerator/ObjectGenerator.tsx
|
|
21
|
-
import { addressToA1Notation } from "@dxos/compute";
|
|
22
|
-
import { ComputeGraph, ComputeGraphModel, DEFAULT_OUTPUT, NODE_INPUT, NODE_OUTPUT } from "@dxos/conductor";
|
|
23
|
-
import { DXN, Filter, Key, Obj, Ref } from "@dxos/echo";
|
|
24
|
-
import { DocumentType } from "@dxos/plugin-markdown/types";
|
|
25
|
-
import { createSheet } from "@dxos/plugin-sheet/types";
|
|
26
|
-
import { SheetType } from "@dxos/plugin-sheet/types";
|
|
27
|
-
import { CanvasType, DiagramType } from "@dxos/plugin-sketch/types";
|
|
28
|
-
import { faker } from "@dxos/random";
|
|
29
|
-
import { TableType } from "@dxos/react-ui-table";
|
|
30
|
-
import { createView, DataType } from "@dxos/schema";
|
|
31
|
-
import { createAsyncGenerator } from "@dxos/schema/testing";
|
|
32
|
-
import { range } from "@dxos/util";
|
|
33
|
-
var generator = faker;
|
|
34
|
-
var createGenerator = (type) => {
|
|
35
|
-
return async (space, n, cb) => {
|
|
36
|
-
const schema = await space.db.schemaRegistry.query({
|
|
37
|
-
typename: type.typename
|
|
38
|
-
}).firstOrUndefined() ?? (await space.db.schemaRegistry.register([
|
|
39
|
-
type
|
|
40
|
-
]))[0];
|
|
41
|
-
const generate = createAsyncGenerator(generator, schema.snapshot, {
|
|
42
|
-
db: space.db
|
|
43
|
-
});
|
|
44
|
-
const objects = await generate.createObjects(n);
|
|
45
|
-
const { objects: tables } = await space.db.query(Filter.type(TableType)).run();
|
|
46
|
-
const table = tables.find((table2) => table2.view?.target?.query?.typename === type.typename);
|
|
47
|
-
if (!table) {
|
|
48
|
-
const name = type.typename.split("/").pop() ?? type.typename;
|
|
49
|
-
const view = createView({
|
|
50
|
-
name,
|
|
51
|
-
typename: type.typename,
|
|
52
|
-
jsonSchema: schema.jsonSchema
|
|
53
|
-
});
|
|
54
|
-
space.db.add(Obj.make(TableType, {
|
|
55
|
-
name,
|
|
56
|
-
view: Ref.make(view)
|
|
57
|
-
}));
|
|
58
|
-
}
|
|
59
|
-
return objects;
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
var staticGenerators = /* @__PURE__ */ new Map([
|
|
63
|
-
[
|
|
64
|
-
DocumentType.typename,
|
|
65
|
-
async (space, n, cb) => {
|
|
66
|
-
const objects = range(n).map(() => {
|
|
67
|
-
return space.db.add(Obj.make(DocumentType, {
|
|
68
|
-
name: faker.commerce.productName(),
|
|
69
|
-
content: Ref.make(Obj.make(DataType.Text, {
|
|
70
|
-
content: faker.lorem.sentences(5)
|
|
71
|
-
}))
|
|
72
|
-
}));
|
|
73
|
-
});
|
|
74
|
-
cb?.(objects);
|
|
75
|
-
return objects;
|
|
76
|
-
}
|
|
77
|
-
],
|
|
78
|
-
[
|
|
79
|
-
DiagramType.typename,
|
|
80
|
-
async (space, n, cb) => {
|
|
81
|
-
const objects = range(n).map(() => {
|
|
82
|
-
const obj = space.db.add(Obj.make(DiagramType, {
|
|
83
|
-
name: faker.commerce.productName(),
|
|
84
|
-
canvas: Ref.make(Obj.make(CanvasType, {
|
|
85
|
-
content: {}
|
|
86
|
-
}))
|
|
87
|
-
}));
|
|
88
|
-
return obj;
|
|
89
|
-
});
|
|
90
|
-
cb?.(objects);
|
|
91
|
-
return objects;
|
|
92
|
-
}
|
|
93
|
-
],
|
|
94
|
-
// TODO(burdon): Create unit tests.
|
|
95
|
-
[
|
|
96
|
-
SheetType.typename,
|
|
97
|
-
async (space, n, cb) => {
|
|
98
|
-
const objects = range(n).map(() => {
|
|
99
|
-
const cells = {};
|
|
100
|
-
const year = (/* @__PURE__ */ new Date()).getFullYear();
|
|
101
|
-
const cols = 4;
|
|
102
|
-
const rows = 16;
|
|
103
|
-
for (let col = 1; col <= cols; col++) {
|
|
104
|
-
for (let row = 1; row <= rows; row++) {
|
|
105
|
-
const cell = addressToA1Notation({
|
|
106
|
-
col,
|
|
107
|
-
row
|
|
108
|
-
});
|
|
109
|
-
if (row === 1) {
|
|
110
|
-
cells[cell] = {
|
|
111
|
-
value: `${year} Q${col}`
|
|
112
|
-
};
|
|
113
|
-
} else if (row === rows) {
|
|
114
|
-
const from = addressToA1Notation({
|
|
115
|
-
col,
|
|
116
|
-
row: 2
|
|
117
|
-
});
|
|
118
|
-
const to = addressToA1Notation({
|
|
119
|
-
col,
|
|
120
|
-
row: rows - 1
|
|
121
|
-
});
|
|
122
|
-
cells[cell] = {
|
|
123
|
-
value: `=SUM(${from}:${to})`
|
|
124
|
-
};
|
|
125
|
-
} else if (row > 2 && row < rows - 1) {
|
|
126
|
-
cells[cell] = {
|
|
127
|
-
value: Math.floor(Math.random() * 1e4)
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return space.db.add(createSheet({
|
|
133
|
-
name: faker.commerce.productName(),
|
|
134
|
-
cells
|
|
135
|
-
}));
|
|
136
|
-
});
|
|
137
|
-
cb?.(objects);
|
|
138
|
-
return objects;
|
|
139
|
-
}
|
|
140
|
-
],
|
|
141
|
-
[
|
|
142
|
-
ComputeGraph.typename,
|
|
143
|
-
async (space, n, cb) => {
|
|
144
|
-
const objects = range(n, () => {
|
|
145
|
-
const model = ComputeGraphModel.create();
|
|
146
|
-
model.builder.createNode({
|
|
147
|
-
id: "gpt-INPUT",
|
|
148
|
-
type: NODE_INPUT
|
|
149
|
-
}).createNode({
|
|
150
|
-
id: "gpt-GPT",
|
|
151
|
-
type: "gpt"
|
|
152
|
-
}).createNode({
|
|
153
|
-
id: "gpt-QUEUE_ID",
|
|
154
|
-
type: "constant",
|
|
155
|
-
value: new DXN(DXN.kind.QUEUE, [
|
|
156
|
-
"data",
|
|
157
|
-
space.id,
|
|
158
|
-
Key.ObjectId.random()
|
|
159
|
-
]).toString()
|
|
160
|
-
}).createNode({
|
|
161
|
-
id: "gpt-APPEND",
|
|
162
|
-
type: "append"
|
|
163
|
-
}).createNode({
|
|
164
|
-
id: "gpt-OUTPUT",
|
|
165
|
-
type: NODE_OUTPUT
|
|
166
|
-
}).createEdge({
|
|
167
|
-
node: "gpt-INPUT",
|
|
168
|
-
property: "prompt"
|
|
169
|
-
}, {
|
|
170
|
-
node: "gpt-GPT",
|
|
171
|
-
property: "prompt"
|
|
172
|
-
}).createEdge({
|
|
173
|
-
node: "gpt-GPT",
|
|
174
|
-
property: "text"
|
|
175
|
-
}, {
|
|
176
|
-
node: "gpt-OUTPUT",
|
|
177
|
-
property: "text"
|
|
178
|
-
}).createEdge({
|
|
179
|
-
node: "gpt-QUEUE_ID",
|
|
180
|
-
property: DEFAULT_OUTPUT
|
|
181
|
-
}, {
|
|
182
|
-
node: "gpt-APPEND",
|
|
183
|
-
property: "id"
|
|
184
|
-
}).createEdge({
|
|
185
|
-
node: "gpt-GPT",
|
|
186
|
-
property: "messages"
|
|
187
|
-
}, {
|
|
188
|
-
node: "gpt-APPEND",
|
|
189
|
-
property: "items"
|
|
190
|
-
}).createEdge({
|
|
191
|
-
node: "gpt-QUEUE_ID",
|
|
192
|
-
property: DEFAULT_OUTPUT
|
|
193
|
-
}, {
|
|
194
|
-
node: "gpt-OUTPUT",
|
|
195
|
-
property: "queue"
|
|
196
|
-
});
|
|
197
|
-
return space.db.add(model.root);
|
|
198
|
-
});
|
|
199
|
-
cb?.(objects);
|
|
200
|
-
return objects;
|
|
201
|
-
}
|
|
202
|
-
]
|
|
203
|
-
]);
|
|
204
|
-
|
|
205
|
-
// packages/plugins/plugin-debug/src/components/SpaceGenerator/SchemaTable.tsx
|
|
206
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
207
|
-
import React from "react";
|
|
208
|
-
import { IconButton } from "@dxos/react-ui";
|
|
209
|
-
var SchemaTable = ({ types, objects = {}, label, onClick }) => {
|
|
210
|
-
var _effect = _useSignals();
|
|
211
|
-
try {
|
|
212
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
213
|
-
className: "grid grid-cols-[1fr_80px_40px] gap-1 overflow-none"
|
|
214
|
-
}, /* @__PURE__ */ React.createElement("h2", {
|
|
215
|
-
className: "p-2"
|
|
216
|
-
}, label), types.map((type) => /* @__PURE__ */ React.createElement("div", {
|
|
217
|
-
key: type.typename,
|
|
218
|
-
className: "grid grid-cols-subgrid col-span-3 items-center"
|
|
219
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
220
|
-
className: "px-2 text-sm font-mono text-subdued"
|
|
221
|
-
}, type.typename), /* @__PURE__ */ React.createElement("div", {
|
|
222
|
-
className: "px-2 text-right font-mono"
|
|
223
|
-
}, objects[type.typename] ?? 0), /* @__PURE__ */ React.createElement(IconButton, {
|
|
224
|
-
variant: "ghost",
|
|
225
|
-
icon: "ph--plus--regular",
|
|
226
|
-
iconOnly: true,
|
|
227
|
-
label: "Create data",
|
|
228
|
-
onClick: () => onClick(type.typename)
|
|
229
|
-
}))));
|
|
230
|
-
} finally {
|
|
231
|
-
_effect.f();
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
// packages/plugins/plugin-debug/src/components/SpaceGenerator/presets.ts
|
|
236
|
-
import { Schema, SchemaAST } from "effect";
|
|
237
|
-
import { NODE_INPUT as NODE_INPUT2 } from "@dxos/conductor";
|
|
238
|
-
import { DXN as DXN2, Key as Key2, Obj as Obj2, Ref as Ref2, Type } from "@dxos/echo";
|
|
239
|
-
import { FunctionTrigger, TriggerKind, EmailTriggerOutput } from "@dxos/functions";
|
|
240
|
-
import { invariant } from "@dxos/invariant";
|
|
241
|
-
import { Filter as Filter2 } from "@dxos/react-client/echo";
|
|
242
|
-
import { createAppend, createChat, createComputeGraph, createConstant, createFunction, createGpt, createQueue, createSurface, createRandom, createTemplate, createText, createTrigger } from "@dxos/react-ui-canvas-compute";
|
|
243
|
-
import { CanvasBoardType, CanvasGraphModel, pointMultiply, pointsToRect, rectToPoints } from "@dxos/react-ui-canvas-editor";
|
|
244
|
-
import { TableType as TableType2 } from "@dxos/react-ui-table";
|
|
245
|
-
import { range as range2 } from "@dxos/util";
|
|
246
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-debug/src/components/SpaceGenerator/presets.ts";
|
|
247
|
-
var PresetName = /* @__PURE__ */ function(PresetName2) {
|
|
248
|
-
PresetName2["EMAIL_TABLE"] = "email-table";
|
|
249
|
-
PresetName2["GPT_QUEUE"] = "webhook-gpt-queue";
|
|
250
|
-
PresetName2["CHAT_GPT"] = "chat-gpt-text";
|
|
251
|
-
PresetName2["EMAIL_WITH_SUMMARY"] = "email-gptSummary-table";
|
|
252
|
-
PresetName2["OBJECT_CHANGE_QUEUE"] = "objectChange-queue";
|
|
253
|
-
PresetName2["FOREX_FUNCTION_CALL"] = "forex-function-call";
|
|
254
|
-
PresetName2["TIMER_TICK_QUEUE"] = "timerTick-queue";
|
|
255
|
-
PresetName2["DISCORD_MESSAGES"] = "discord-messages";
|
|
256
|
-
PresetName2["KANBAN_QUEUE"] = "kanban-queue";
|
|
257
|
-
return PresetName2;
|
|
258
|
-
}({});
|
|
259
|
-
var generator2 = () => ({
|
|
260
|
-
schemas: [
|
|
261
|
-
CanvasBoardType,
|
|
262
|
-
FunctionTrigger
|
|
263
|
-
],
|
|
264
|
-
types: Object.values(PresetName).map((name) => ({
|
|
265
|
-
typename: name
|
|
266
|
-
})),
|
|
267
|
-
items: [
|
|
268
|
-
[
|
|
269
|
-
"webhook-gpt-queue",
|
|
270
|
-
async (space, n, cb) => {
|
|
271
|
-
const objects = range2(n, () => {
|
|
272
|
-
const canvasModel = CanvasGraphModel.create();
|
|
273
|
-
let functionTrigger;
|
|
274
|
-
canvasModel.builder.call((builder) => {
|
|
275
|
-
const gpt = canvasModel.createNode(createGpt(position({
|
|
276
|
-
x: 0,
|
|
277
|
-
y: -14
|
|
278
|
-
})));
|
|
279
|
-
const triggerShape = createTrigger({
|
|
280
|
-
spaceId: space.id,
|
|
281
|
-
triggerKind: TriggerKind.Webhook,
|
|
282
|
-
...position({
|
|
283
|
-
x: -18,
|
|
284
|
-
y: -2
|
|
285
|
-
})
|
|
286
|
-
});
|
|
287
|
-
const trigger = canvasModel.createNode(triggerShape);
|
|
288
|
-
const text = canvasModel.createNode(createText(position({
|
|
289
|
-
x: 19,
|
|
290
|
-
y: 3,
|
|
291
|
-
width: 10,
|
|
292
|
-
height: 10
|
|
293
|
-
})));
|
|
294
|
-
const { queueId } = setupQueue(space, canvasModel);
|
|
295
|
-
const append = canvasModel.createNode(createAppend(position({
|
|
296
|
-
x: 10,
|
|
297
|
-
y: 6
|
|
298
|
-
})));
|
|
299
|
-
builder.createEdge({
|
|
300
|
-
source: trigger.id,
|
|
301
|
-
target: gpt.id,
|
|
302
|
-
input: "prompt",
|
|
303
|
-
output: "bodyText"
|
|
304
|
-
}).createEdge({
|
|
305
|
-
source: gpt.id,
|
|
306
|
-
target: text.id,
|
|
307
|
-
output: "text"
|
|
308
|
-
}).createEdge({
|
|
309
|
-
source: queueId.id,
|
|
310
|
-
target: append.id,
|
|
311
|
-
input: "id"
|
|
312
|
-
}).createEdge({
|
|
313
|
-
source: gpt.id,
|
|
314
|
-
target: append.id,
|
|
315
|
-
output: "messages",
|
|
316
|
-
input: "items"
|
|
317
|
-
});
|
|
318
|
-
functionTrigger = triggerShape.functionTrigger.target;
|
|
319
|
-
});
|
|
320
|
-
const computeModel = createComputeGraph(canvasModel);
|
|
321
|
-
attachTrigger(functionTrigger, computeModel);
|
|
322
|
-
return addToSpace("webhook-gpt-queue", space, canvasModel, computeModel);
|
|
323
|
-
});
|
|
324
|
-
cb?.(objects);
|
|
325
|
-
return objects;
|
|
326
|
-
}
|
|
327
|
-
],
|
|
328
|
-
[
|
|
329
|
-
"objectChange-queue",
|
|
330
|
-
async (space, n, cb) => {
|
|
331
|
-
const objects = range2(n, () => {
|
|
332
|
-
const { canvasModel, computeModel } = createQueueSinkPreset(space, TriggerKind.Subscription, (triggerSpec) => triggerSpec.filter = {
|
|
333
|
-
type: "dxn:type:dxos.org/type/Chess"
|
|
334
|
-
}, "type");
|
|
335
|
-
return addToSpace("objectChange-queue", space, canvasModel, computeModel);
|
|
336
|
-
});
|
|
337
|
-
cb?.(objects);
|
|
338
|
-
return objects;
|
|
339
|
-
}
|
|
340
|
-
],
|
|
341
|
-
[
|
|
342
|
-
"timerTick-queue",
|
|
343
|
-
async (space, n, cb) => {
|
|
344
|
-
const objects = range2(n, () => {
|
|
345
|
-
const { canvasModel, computeModel } = createQueueSinkPreset(space, TriggerKind.Timer, (triggerSpec) => triggerSpec.cron = "*/5 * * * * *", "result");
|
|
346
|
-
return addToSpace("timerTick-queue", space, canvasModel, computeModel);
|
|
347
|
-
});
|
|
348
|
-
cb?.(objects);
|
|
349
|
-
return objects;
|
|
350
|
-
}
|
|
351
|
-
],
|
|
352
|
-
[
|
|
353
|
-
"email-table",
|
|
354
|
-
async (space, n, cb) => {
|
|
355
|
-
const objects = range2(n, () => {
|
|
356
|
-
const canvasModel = CanvasGraphModel.create();
|
|
357
|
-
const results = space.db.query(Filter2.type(TableType2)).runSync();
|
|
358
|
-
const emailTable = results.find((r) => r.object?.view?.target?.query?.typename?.endsWith("Email"));
|
|
359
|
-
invariant(emailTable, "Email table not found.", {
|
|
360
|
-
F: __dxlog_file,
|
|
361
|
-
L: 136,
|
|
362
|
-
S: void 0,
|
|
363
|
-
A: [
|
|
364
|
-
"emailTable",
|
|
365
|
-
"'Email table not found.'"
|
|
366
|
-
]
|
|
367
|
-
});
|
|
368
|
-
const template = canvasModel.createNode(createTemplate({
|
|
369
|
-
valueType: "object",
|
|
370
|
-
...rawPosition({
|
|
371
|
-
centerX: -80,
|
|
372
|
-
centerY: -64,
|
|
373
|
-
width: 320,
|
|
374
|
-
height: 320
|
|
375
|
-
})
|
|
376
|
-
}));
|
|
377
|
-
const templateContent = [
|
|
378
|
-
"{"
|
|
379
|
-
];
|
|
380
|
-
let functionTrigger;
|
|
381
|
-
canvasModel.builder.call((builder) => {
|
|
382
|
-
const triggerShape = createTrigger({
|
|
383
|
-
spaceId: space.id,
|
|
384
|
-
triggerKind: TriggerKind.Email,
|
|
385
|
-
...position({
|
|
386
|
-
x: -18,
|
|
387
|
-
y: -2
|
|
388
|
-
})
|
|
389
|
-
});
|
|
390
|
-
const trigger = canvasModel.createNode(triggerShape);
|
|
391
|
-
const tableId = canvasModel.createNode(createConstant({
|
|
392
|
-
value: DXN2.fromLocalObjectId(emailTable.id).toString(),
|
|
393
|
-
...position({
|
|
394
|
-
x: -18,
|
|
395
|
-
y: 5,
|
|
396
|
-
width: 8,
|
|
397
|
-
height: 6
|
|
398
|
-
})
|
|
399
|
-
}));
|
|
400
|
-
const appendToTable = canvasModel.createNode(createAppend(position({
|
|
401
|
-
x: 10,
|
|
402
|
-
y: 6
|
|
403
|
-
})));
|
|
404
|
-
const properties = SchemaAST.getPropertySignatures(EmailTriggerOutput.ast);
|
|
405
|
-
for (let i = 0; i < properties.length; i++) {
|
|
406
|
-
const propName = properties[i].name.toString();
|
|
407
|
-
builder.createEdge({
|
|
408
|
-
source: trigger.id,
|
|
409
|
-
target: template.id,
|
|
410
|
-
input: propName,
|
|
411
|
-
output: propName
|
|
412
|
-
});
|
|
413
|
-
templateContent.push(` "${propName}": "{{${propName}}}"` + (i === properties.length - 1 ? "" : ","));
|
|
414
|
-
}
|
|
415
|
-
templateContent.push("}");
|
|
416
|
-
builder.createEdge({
|
|
417
|
-
source: tableId.id,
|
|
418
|
-
target: appendToTable.id,
|
|
419
|
-
input: "id"
|
|
420
|
-
}).createEdge({
|
|
421
|
-
source: template.id,
|
|
422
|
-
target: appendToTable.id,
|
|
423
|
-
input: "items"
|
|
424
|
-
});
|
|
425
|
-
functionTrigger = triggerShape.functionTrigger.target;
|
|
426
|
-
});
|
|
427
|
-
const computeModel = createComputeGraph(canvasModel);
|
|
428
|
-
const templateComputeNode = computeModel.nodes.find((n2) => n2.id === template.node);
|
|
429
|
-
invariant(templateComputeNode, "Template compute node was not created.", {
|
|
430
|
-
F: __dxlog_file,
|
|
431
|
-
L: 182,
|
|
432
|
-
S: void 0,
|
|
433
|
-
A: [
|
|
434
|
-
"templateComputeNode",
|
|
435
|
-
"'Template compute node was not created.'"
|
|
436
|
-
]
|
|
437
|
-
});
|
|
438
|
-
templateComputeNode.value = templateContent.join("\n");
|
|
439
|
-
templateComputeNode.inputSchema = Type.toJsonSchema(EmailTriggerOutput);
|
|
440
|
-
attachTrigger(functionTrigger, computeModel);
|
|
441
|
-
return addToSpace("email-table", space, canvasModel, computeModel);
|
|
442
|
-
});
|
|
443
|
-
cb?.(objects);
|
|
444
|
-
return objects;
|
|
445
|
-
}
|
|
446
|
-
],
|
|
447
|
-
[
|
|
448
|
-
"chat-gpt-text",
|
|
449
|
-
async (space, n, cb) => {
|
|
450
|
-
const objects = range2(n, () => {
|
|
451
|
-
const canvasModel = CanvasGraphModel.create();
|
|
452
|
-
canvasModel.builder.call((builder) => {
|
|
453
|
-
const gpt = canvasModel.createNode(createGpt(position({
|
|
454
|
-
x: 0,
|
|
455
|
-
y: -14
|
|
456
|
-
})));
|
|
457
|
-
const chat = canvasModel.createNode(createChat(position({
|
|
458
|
-
x: -18,
|
|
459
|
-
y: -2
|
|
460
|
-
})));
|
|
461
|
-
const text = canvasModel.createNode(createText(position({
|
|
462
|
-
x: 19,
|
|
463
|
-
y: 3,
|
|
464
|
-
width: 10,
|
|
465
|
-
height: 10
|
|
466
|
-
})));
|
|
467
|
-
const { queueId } = setupQueue(space, canvasModel);
|
|
468
|
-
const append = canvasModel.createNode(createAppend(position({
|
|
469
|
-
x: 10,
|
|
470
|
-
y: 6
|
|
471
|
-
})));
|
|
472
|
-
builder.createEdge({
|
|
473
|
-
source: chat.id,
|
|
474
|
-
target: gpt.id,
|
|
475
|
-
input: "prompt"
|
|
476
|
-
}).createEdge({
|
|
477
|
-
source: gpt.id,
|
|
478
|
-
target: text.id,
|
|
479
|
-
output: "text"
|
|
480
|
-
}).createEdge({
|
|
481
|
-
source: queueId.id,
|
|
482
|
-
target: append.id,
|
|
483
|
-
input: "id"
|
|
484
|
-
}).createEdge({
|
|
485
|
-
source: gpt.id,
|
|
486
|
-
target: append.id,
|
|
487
|
-
output: "messages",
|
|
488
|
-
input: "items"
|
|
489
|
-
});
|
|
490
|
-
});
|
|
491
|
-
const computeModel = createComputeGraph(canvasModel);
|
|
492
|
-
return addToSpace("chat-gpt-text", space, canvasModel, computeModel);
|
|
493
|
-
});
|
|
494
|
-
cb?.(objects);
|
|
495
|
-
return objects;
|
|
496
|
-
}
|
|
497
|
-
],
|
|
498
|
-
[
|
|
499
|
-
"email-gptSummary-table",
|
|
500
|
-
async (space, n, cb) => {
|
|
501
|
-
const objects = range2(n, () => {
|
|
502
|
-
const canvasModel = CanvasGraphModel.create();
|
|
503
|
-
const results = space.db.query(Filter2.type(TableType2)).runSync();
|
|
504
|
-
const emailTable = results.find((r) => r.object?.view?.target?.query?.typename?.endsWith("Email"));
|
|
505
|
-
invariant(emailTable, "Email table not found.", {
|
|
506
|
-
F: __dxlog_file,
|
|
507
|
-
L: 233,
|
|
508
|
-
S: void 0,
|
|
509
|
-
A: [
|
|
510
|
-
"emailTable",
|
|
511
|
-
"'Email table not found.'"
|
|
512
|
-
]
|
|
513
|
-
});
|
|
514
|
-
const template = canvasModel.createNode(createTemplate({
|
|
515
|
-
valueType: "object",
|
|
516
|
-
...rawPosition({
|
|
517
|
-
centerX: 192,
|
|
518
|
-
centerY: -176,
|
|
519
|
-
width: 320,
|
|
520
|
-
height: 320
|
|
521
|
-
})
|
|
522
|
-
}));
|
|
523
|
-
const templateContent = [
|
|
524
|
-
"{"
|
|
525
|
-
];
|
|
526
|
-
let functionTrigger;
|
|
527
|
-
canvasModel.builder.call((builder) => {
|
|
528
|
-
const gpt = canvasModel.createNode(createGpt(rawPosition({
|
|
529
|
-
centerX: -400,
|
|
530
|
-
centerY: -112,
|
|
531
|
-
width: 256,
|
|
532
|
-
height: 202
|
|
533
|
-
})));
|
|
534
|
-
const systemPrompt = canvasModel.createNode(createConstant({
|
|
535
|
-
value: "use one word to describe content category. don't write anything else",
|
|
536
|
-
...rawPosition({
|
|
537
|
-
centerX: -800,
|
|
538
|
-
centerY: -160,
|
|
539
|
-
width: 192,
|
|
540
|
-
height: 128
|
|
541
|
-
})
|
|
542
|
-
}));
|
|
543
|
-
const triggerShape = createTrigger({
|
|
544
|
-
spaceId: space.id,
|
|
545
|
-
triggerKind: TriggerKind.Email,
|
|
546
|
-
...rawPosition({
|
|
547
|
-
centerX: -736,
|
|
548
|
-
centerY: -384,
|
|
549
|
-
width: 182,
|
|
550
|
-
height: 192
|
|
551
|
-
})
|
|
552
|
-
});
|
|
553
|
-
const trigger = canvasModel.createNode(triggerShape);
|
|
554
|
-
const { queueId } = setupQueue(space, canvasModel, {
|
|
555
|
-
idPosition: {
|
|
556
|
-
centerX: -720,
|
|
557
|
-
centerY: 224,
|
|
558
|
-
width: 192,
|
|
559
|
-
height: 256
|
|
560
|
-
},
|
|
561
|
-
queuePosition: {
|
|
562
|
-
centerX: -144,
|
|
563
|
-
centerY: 416,
|
|
564
|
-
width: 320,
|
|
565
|
-
height: 448
|
|
566
|
-
}
|
|
567
|
-
});
|
|
568
|
-
const appendToQueue = canvasModel.createNode(createAppend(rawPosition({
|
|
569
|
-
centerX: -80,
|
|
570
|
-
centerY: 96,
|
|
571
|
-
width: 122,
|
|
572
|
-
height: 128
|
|
573
|
-
})));
|
|
574
|
-
const tableId = canvasModel.createNode(createConstant({
|
|
575
|
-
value: DXN2.fromLocalObjectId(emailTable.id).toString(),
|
|
576
|
-
...rawPosition({
|
|
577
|
-
centerX: -112,
|
|
578
|
-
centerY: -544,
|
|
579
|
-
width: 192,
|
|
580
|
-
height: 256
|
|
581
|
-
})
|
|
582
|
-
}));
|
|
583
|
-
const appendToTable = canvasModel.createNode(createAppend(rawPosition({
|
|
584
|
-
centerX: 560,
|
|
585
|
-
centerY: -416,
|
|
586
|
-
width: 128,
|
|
587
|
-
height: 122
|
|
588
|
-
})));
|
|
589
|
-
templateContent.push(' "category": "{{text}}",');
|
|
590
|
-
builder.createEdge({
|
|
591
|
-
source: gpt.id,
|
|
592
|
-
target: template.id,
|
|
593
|
-
input: "text",
|
|
594
|
-
output: "text"
|
|
595
|
-
});
|
|
596
|
-
const properties = SchemaAST.getPropertySignatures(EmailTriggerOutput.ast);
|
|
597
|
-
for (let i = 0; i < properties.length; i++) {
|
|
598
|
-
const propName = properties[i].name.toString();
|
|
599
|
-
builder.createEdge({
|
|
600
|
-
source: trigger.id,
|
|
601
|
-
target: template.id,
|
|
602
|
-
input: propName,
|
|
603
|
-
output: propName
|
|
604
|
-
});
|
|
605
|
-
templateContent.push(` "${propName}": "{{${propName}}}"` + (i === properties.length - 1 ? "" : ","));
|
|
606
|
-
}
|
|
607
|
-
templateContent.push("}");
|
|
608
|
-
builder.createEdge({
|
|
609
|
-
source: tableId.id,
|
|
610
|
-
target: appendToTable.id,
|
|
611
|
-
input: "id"
|
|
612
|
-
}).createEdge({
|
|
613
|
-
source: queueId.id,
|
|
614
|
-
target: appendToQueue.id,
|
|
615
|
-
input: "id"
|
|
616
|
-
}).createEdge({
|
|
617
|
-
source: gpt.id,
|
|
618
|
-
target: appendToQueue.id,
|
|
619
|
-
output: "messages",
|
|
620
|
-
input: "items"
|
|
621
|
-
}).createEdge({
|
|
622
|
-
source: systemPrompt.id,
|
|
623
|
-
target: gpt.id,
|
|
624
|
-
input: "systemPrompt"
|
|
625
|
-
}).createEdge({
|
|
626
|
-
source: trigger.id,
|
|
627
|
-
target: gpt.id,
|
|
628
|
-
input: "prompt",
|
|
629
|
-
output: "body"
|
|
630
|
-
}).createEdge({
|
|
631
|
-
source: template.id,
|
|
632
|
-
target: appendToTable.id,
|
|
633
|
-
input: "items"
|
|
634
|
-
});
|
|
635
|
-
functionTrigger = triggerShape.functionTrigger.target;
|
|
636
|
-
});
|
|
637
|
-
const computeModel = createComputeGraph(canvasModel);
|
|
638
|
-
const templateComputeNode = computeModel.nodes.find((n2) => n2.id === template.node);
|
|
639
|
-
invariant(templateComputeNode, "Template compute node was not created.", {
|
|
640
|
-
F: __dxlog_file,
|
|
641
|
-
L: 305,
|
|
642
|
-
S: void 0,
|
|
643
|
-
A: [
|
|
644
|
-
"templateComputeNode",
|
|
645
|
-
"'Template compute node was not created.'"
|
|
646
|
-
]
|
|
647
|
-
});
|
|
648
|
-
templateComputeNode.value = templateContent.join("\n");
|
|
649
|
-
const extendedSchema = Schema.extend(EmailTriggerOutput, Schema.Struct({
|
|
650
|
-
text: Schema.String
|
|
651
|
-
}));
|
|
652
|
-
templateComputeNode.inputSchema = Type.toJsonSchema(extendedSchema);
|
|
653
|
-
attachTrigger(functionTrigger, computeModel);
|
|
654
|
-
return addToSpace("email-gptSummary-table", space, canvasModel, computeModel);
|
|
655
|
-
});
|
|
656
|
-
cb?.(objects);
|
|
657
|
-
return objects;
|
|
658
|
-
}
|
|
659
|
-
],
|
|
660
|
-
[
|
|
661
|
-
"forex-function-call",
|
|
662
|
-
async (space, n, cb) => {
|
|
663
|
-
const objects = range2(n, () => {
|
|
664
|
-
const canvasModel = CanvasGraphModel.create();
|
|
665
|
-
canvasModel.builder.call((builder) => {
|
|
666
|
-
const sourceCurrency = canvasModel.createNode(createConstant({
|
|
667
|
-
value: "USD",
|
|
668
|
-
...position({
|
|
669
|
-
x: -10,
|
|
670
|
-
y: -5
|
|
671
|
-
})
|
|
672
|
-
}));
|
|
673
|
-
const targetCurrency = canvasModel.createNode(createConstant({
|
|
674
|
-
value: "EUR",
|
|
675
|
-
...position({
|
|
676
|
-
x: -10,
|
|
677
|
-
y: 5
|
|
678
|
-
})
|
|
679
|
-
}));
|
|
680
|
-
const converter = canvasModel.createNode(createFunction(position({
|
|
681
|
-
x: 0,
|
|
682
|
-
y: 0
|
|
683
|
-
})));
|
|
684
|
-
const view = canvasModel.createNode(createSurface(position({
|
|
685
|
-
x: 12,
|
|
686
|
-
y: 0
|
|
687
|
-
})));
|
|
688
|
-
builder.createEdge({
|
|
689
|
-
source: sourceCurrency.id,
|
|
690
|
-
target: converter.id,
|
|
691
|
-
input: "from"
|
|
692
|
-
}).createEdge({
|
|
693
|
-
source: targetCurrency.id,
|
|
694
|
-
target: converter.id,
|
|
695
|
-
input: "to"
|
|
696
|
-
}).createEdge({
|
|
697
|
-
source: converter.id,
|
|
698
|
-
target: view.id,
|
|
699
|
-
output: "rate"
|
|
700
|
-
});
|
|
701
|
-
});
|
|
702
|
-
const computeModel = createComputeGraph(canvasModel);
|
|
703
|
-
return addToSpace("forex-function-call", space, canvasModel, computeModel);
|
|
704
|
-
});
|
|
705
|
-
cb?.(objects);
|
|
706
|
-
return objects;
|
|
707
|
-
}
|
|
708
|
-
],
|
|
709
|
-
[
|
|
710
|
-
"discord-messages",
|
|
711
|
-
async (space, n, cb) => {
|
|
712
|
-
const objects = range2(n, () => {
|
|
713
|
-
const canvasModel = CanvasGraphModel.create();
|
|
714
|
-
let functionTrigger;
|
|
715
|
-
canvasModel.builder.call((builder) => {
|
|
716
|
-
const triggerShape = createTrigger({
|
|
717
|
-
spaceId: space.id,
|
|
718
|
-
triggerKind: TriggerKind.Timer,
|
|
719
|
-
...position({
|
|
720
|
-
x: -10,
|
|
721
|
-
y: -5
|
|
722
|
-
})
|
|
723
|
-
});
|
|
724
|
-
const trigger = canvasModel.createNode(triggerShape);
|
|
725
|
-
const channelId = canvasModel.createNode(createConstant({
|
|
726
|
-
value: "1088569858767212554",
|
|
727
|
-
...position({
|
|
728
|
-
x: -10,
|
|
729
|
-
y: 0
|
|
730
|
-
})
|
|
731
|
-
}));
|
|
732
|
-
const queueId = canvasModel.createNode(createConstant({
|
|
733
|
-
value: new DXN2(DXN2.kind.QUEUE, [
|
|
734
|
-
"data",
|
|
735
|
-
space.id,
|
|
736
|
-
Key2.ObjectId.random()
|
|
737
|
-
]).toString(),
|
|
738
|
-
...position({
|
|
739
|
-
x: -10,
|
|
740
|
-
y: 5
|
|
741
|
-
})
|
|
742
|
-
}));
|
|
743
|
-
const converter = canvasModel.createNode(createFunction(position({
|
|
744
|
-
x: 0,
|
|
745
|
-
y: 0
|
|
746
|
-
})));
|
|
747
|
-
const view = canvasModel.createNode(createText(position({
|
|
748
|
-
x: 12,
|
|
749
|
-
y: 0
|
|
750
|
-
})));
|
|
751
|
-
const queue = canvasModel.createNode(createQueue(position({
|
|
752
|
-
x: 0,
|
|
753
|
-
y: 12
|
|
754
|
-
})));
|
|
755
|
-
builder.createEdge({
|
|
756
|
-
source: trigger.id,
|
|
757
|
-
target: converter.id,
|
|
758
|
-
input: "tick"
|
|
759
|
-
}).createEdge({
|
|
760
|
-
source: channelId.id,
|
|
761
|
-
target: converter.id,
|
|
762
|
-
input: "channelId"
|
|
763
|
-
}).createEdge({
|
|
764
|
-
source: queueId.id,
|
|
765
|
-
target: converter.id,
|
|
766
|
-
input: "queueId"
|
|
767
|
-
}).createEdge({
|
|
768
|
-
source: converter.id,
|
|
769
|
-
target: view.id,
|
|
770
|
-
output: "newMessages"
|
|
771
|
-
}).createEdge({
|
|
772
|
-
source: queueId.id,
|
|
773
|
-
target: queue.id,
|
|
774
|
-
input: "input"
|
|
775
|
-
});
|
|
776
|
-
functionTrigger = triggerShape.functionTrigger.target;
|
|
777
|
-
});
|
|
778
|
-
const computeModel = createComputeGraph(canvasModel);
|
|
779
|
-
attachTrigger(functionTrigger, computeModel);
|
|
780
|
-
return addToSpace("discord-messages", space, canvasModel, computeModel);
|
|
781
|
-
});
|
|
782
|
-
cb?.(objects);
|
|
783
|
-
return objects;
|
|
784
|
-
}
|
|
785
|
-
],
|
|
786
|
-
[
|
|
787
|
-
"kanban-queue",
|
|
788
|
-
async (space, n, cb) => {
|
|
789
|
-
const objects = range2(n, () => {
|
|
790
|
-
const canvasModel = CanvasGraphModel.create();
|
|
791
|
-
const results = space.db.query(Filter2.type(TableType2)).runSync();
|
|
792
|
-
const messages = results.find((r) => r.object?.view?.target?.query?.typename?.endsWith("Message"));
|
|
793
|
-
invariant(messages, "Table not found.", {
|
|
794
|
-
F: __dxlog_file,
|
|
795
|
-
L: 411,
|
|
796
|
-
S: void 0,
|
|
797
|
-
A: [
|
|
798
|
-
"messages",
|
|
799
|
-
"'Table not found.'"
|
|
800
|
-
]
|
|
801
|
-
});
|
|
802
|
-
let functionTrigger;
|
|
803
|
-
canvasModel.builder.call((builder) => {
|
|
804
|
-
const triggerShape = createTrigger({
|
|
805
|
-
spaceId: space.id,
|
|
806
|
-
triggerKind: TriggerKind.Queue,
|
|
807
|
-
...position({
|
|
808
|
-
x: -10,
|
|
809
|
-
y: -5
|
|
810
|
-
})
|
|
811
|
-
});
|
|
812
|
-
const trigger = canvasModel.createNode(triggerShape);
|
|
813
|
-
const tableId = canvasModel.createNode(createConstant({
|
|
814
|
-
value: DXN2.fromLocalObjectId(messages.id).toString(),
|
|
815
|
-
...position({
|
|
816
|
-
x: -10,
|
|
817
|
-
y: 5
|
|
818
|
-
})
|
|
819
|
-
}));
|
|
820
|
-
const appendToTable = canvasModel.createNode(createAppend(position({
|
|
821
|
-
x: 10,
|
|
822
|
-
y: 0
|
|
823
|
-
})));
|
|
824
|
-
builder.createEdge({
|
|
825
|
-
source: tableId.id,
|
|
826
|
-
target: appendToTable.id,
|
|
827
|
-
input: "id"
|
|
828
|
-
}).createEdge({
|
|
829
|
-
source: trigger.id,
|
|
830
|
-
target: appendToTable.id,
|
|
831
|
-
input: "items",
|
|
832
|
-
output: "item"
|
|
833
|
-
});
|
|
834
|
-
functionTrigger = triggerShape.functionTrigger.target;
|
|
835
|
-
});
|
|
836
|
-
const computeModel = createComputeGraph(canvasModel);
|
|
837
|
-
attachTrigger(functionTrigger, computeModel);
|
|
838
|
-
return addToSpace("kanban-queue", space, canvasModel, computeModel);
|
|
839
|
-
});
|
|
840
|
-
cb?.(objects);
|
|
841
|
-
return objects;
|
|
842
|
-
}
|
|
843
|
-
]
|
|
844
|
-
]
|
|
845
|
-
});
|
|
846
|
-
var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) => {
|
|
847
|
-
const canvasModel = CanvasGraphModel.create();
|
|
848
|
-
const template = canvasModel.createNode(createTemplate({
|
|
849
|
-
valueType: "object",
|
|
850
|
-
...rawPosition({
|
|
851
|
-
centerX: -64,
|
|
852
|
-
centerY: -79,
|
|
853
|
-
width: 320,
|
|
854
|
-
height: 320
|
|
855
|
-
})
|
|
856
|
-
}));
|
|
857
|
-
let functionTrigger;
|
|
858
|
-
canvasModel.builder.call((builder) => {
|
|
859
|
-
const triggerShape = createTrigger({
|
|
860
|
-
spaceId: space.id,
|
|
861
|
-
triggerKind,
|
|
862
|
-
...rawPosition({
|
|
863
|
-
centerX: -578,
|
|
864
|
-
centerY: -187,
|
|
865
|
-
height: 320,
|
|
866
|
-
width: 320
|
|
867
|
-
})
|
|
868
|
-
});
|
|
869
|
-
const trigger = canvasModel.createNode(triggerShape);
|
|
870
|
-
const { queueId } = setupQueue(space, canvasModel, {
|
|
871
|
-
queuePosition: {
|
|
872
|
-
centerX: -80,
|
|
873
|
-
centerY: 378,
|
|
874
|
-
width: 320,
|
|
875
|
-
height: 448
|
|
876
|
-
}
|
|
877
|
-
});
|
|
878
|
-
const append = canvasModel.createNode(createAppend(rawPosition({
|
|
879
|
-
centerX: 320,
|
|
880
|
-
centerY: 192,
|
|
881
|
-
width: 128,
|
|
882
|
-
height: 122
|
|
883
|
-
})));
|
|
884
|
-
const random = canvasModel.createNode(createRandom(rawPosition({
|
|
885
|
-
centerX: -509,
|
|
886
|
-
centerY: -30,
|
|
887
|
-
width: 64,
|
|
888
|
-
height: 64
|
|
889
|
-
})));
|
|
890
|
-
builder.createEdge({
|
|
891
|
-
source: queueId.id,
|
|
892
|
-
target: append.id,
|
|
893
|
-
input: "id"
|
|
894
|
-
}).createEdge({
|
|
895
|
-
source: template.id,
|
|
896
|
-
target: append.id,
|
|
897
|
-
input: "items"
|
|
898
|
-
}).createEdge({
|
|
899
|
-
source: trigger.id,
|
|
900
|
-
target: template.id,
|
|
901
|
-
output: triggerOutputName,
|
|
902
|
-
input: "type"
|
|
903
|
-
}).createEdge({
|
|
904
|
-
source: random.id,
|
|
905
|
-
target: template.id,
|
|
906
|
-
input: "changeId"
|
|
907
|
-
});
|
|
908
|
-
functionTrigger = triggerShape.functionTrigger.target;
|
|
909
|
-
const triggerSpec = functionTrigger.spec;
|
|
910
|
-
invariant(triggerSpec && triggerSpec.kind === triggerKind, "No trigger spec.", {
|
|
911
|
-
F: __dxlog_file,
|
|
912
|
-
L: 494,
|
|
913
|
-
S: void 0,
|
|
914
|
-
A: [
|
|
915
|
-
"triggerSpec && triggerSpec.kind === triggerKind",
|
|
916
|
-
"'No trigger spec.'"
|
|
917
|
-
]
|
|
918
|
-
});
|
|
919
|
-
initSpec(triggerSpec);
|
|
920
|
-
});
|
|
921
|
-
const computeModel = createComputeGraph(canvasModel);
|
|
922
|
-
const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
|
|
923
|
-
invariant(templateComputeNode, "Template compute node was not created.", {
|
|
924
|
-
F: __dxlog_file,
|
|
925
|
-
L: 501,
|
|
926
|
-
S: void 0,
|
|
927
|
-
A: [
|
|
928
|
-
"templateComputeNode",
|
|
929
|
-
"'Template compute node was not created.'"
|
|
930
|
-
]
|
|
931
|
-
});
|
|
932
|
-
templateComputeNode.value = [
|
|
933
|
-
"{",
|
|
934
|
-
' "@type": "{{type}}",',
|
|
935
|
-
' "id": "@{{changeId}}"',
|
|
936
|
-
"}"
|
|
937
|
-
].join("\n");
|
|
938
|
-
templateComputeNode.inputSchema = Type.toJsonSchema(Schema.Struct({
|
|
939
|
-
type: Schema.String,
|
|
940
|
-
changeId: Schema.String
|
|
941
|
-
}));
|
|
942
|
-
attachTrigger(functionTrigger, computeModel);
|
|
943
|
-
return {
|
|
944
|
-
canvasModel,
|
|
945
|
-
computeModel
|
|
946
|
-
};
|
|
947
|
-
};
|
|
948
|
-
var addToSpace = (name, space, canvas, compute) => {
|
|
949
|
-
return space.db.add(Obj2.make(CanvasBoardType, {
|
|
950
|
-
name,
|
|
951
|
-
computeGraph: Ref2.make(compute.root),
|
|
952
|
-
layout: canvas.graph
|
|
953
|
-
}));
|
|
954
|
-
};
|
|
955
|
-
var setupQueue = (space, canvasModel, args) => {
|
|
956
|
-
const queueId = canvasModel.createNode(createConstant({
|
|
957
|
-
value: new DXN2(DXN2.kind.QUEUE, [
|
|
958
|
-
"data",
|
|
959
|
-
space.id,
|
|
960
|
-
Key2.ObjectId.random()
|
|
961
|
-
]).toString(),
|
|
962
|
-
...args?.idPosition ? rawPosition(args.idPosition) : position({
|
|
963
|
-
x: -18,
|
|
964
|
-
y: 5,
|
|
965
|
-
width: 8,
|
|
966
|
-
height: 6
|
|
967
|
-
})
|
|
968
|
-
}));
|
|
969
|
-
const queue = canvasModel.createNode(createQueue(args?.queuePosition ? rawPosition(args.queuePosition) : position({
|
|
970
|
-
x: -3,
|
|
971
|
-
y: 3,
|
|
972
|
-
width: 14,
|
|
973
|
-
height: 10
|
|
974
|
-
})));
|
|
975
|
-
canvasModel.createEdge({
|
|
976
|
-
source: queueId.id,
|
|
977
|
-
target: queue.id
|
|
978
|
-
});
|
|
979
|
-
return {
|
|
980
|
-
queue,
|
|
981
|
-
queueId
|
|
982
|
-
};
|
|
983
|
-
};
|
|
984
|
-
var attachTrigger = (functionTrigger, computeModel) => {
|
|
985
|
-
invariant(functionTrigger, void 0, {
|
|
986
|
-
F: __dxlog_file,
|
|
987
|
-
L: 540,
|
|
988
|
-
S: void 0,
|
|
989
|
-
A: [
|
|
990
|
-
"functionTrigger",
|
|
991
|
-
""
|
|
992
|
-
]
|
|
993
|
-
});
|
|
994
|
-
functionTrigger.function = Ref2.make(computeModel.root);
|
|
995
|
-
const inputNode = computeModel.nodes.find((node) => node.type === NODE_INPUT2);
|
|
996
|
-
functionTrigger.inputNodeId = inputNode.id;
|
|
997
|
-
};
|
|
998
|
-
var rawPosition = (args) => {
|
|
999
|
-
return {
|
|
1000
|
-
center: {
|
|
1001
|
-
x: args.centerX,
|
|
1002
|
-
y: args.centerY
|
|
1003
|
-
},
|
|
1004
|
-
size: {
|
|
1005
|
-
width: args.width,
|
|
1006
|
-
height: args.height
|
|
1007
|
-
}
|
|
1008
|
-
};
|
|
1009
|
-
};
|
|
1010
|
-
var position = (rect) => {
|
|
1011
|
-
const snap = 32;
|
|
1012
|
-
const [center, size] = rectToPoints({
|
|
1013
|
-
width: 0,
|
|
1014
|
-
height: 0,
|
|
1015
|
-
...rect
|
|
1016
|
-
});
|
|
1017
|
-
const { x, y, width, height } = pointsToRect([
|
|
1018
|
-
pointMultiply(center, snap),
|
|
1019
|
-
pointMultiply(size, snap)
|
|
1020
|
-
]);
|
|
1021
|
-
if (width && height) {
|
|
1022
|
-
return {
|
|
1023
|
-
center: {
|
|
1024
|
-
x,
|
|
1025
|
-
y
|
|
1026
|
-
},
|
|
1027
|
-
size: width && height ? {
|
|
1028
|
-
width,
|
|
1029
|
-
height
|
|
1030
|
-
} : void 0
|
|
1031
|
-
};
|
|
1032
|
-
} else {
|
|
1033
|
-
return {
|
|
1034
|
-
center: {
|
|
1035
|
-
x,
|
|
1036
|
-
y
|
|
1037
|
-
}
|
|
1038
|
-
};
|
|
1039
|
-
}
|
|
1040
|
-
};
|
|
1041
|
-
|
|
1042
|
-
// packages/plugins/plugin-debug/src/components/SpaceGenerator/SpaceGenerator.tsx
|
|
1043
|
-
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-debug/src/components/SpaceGenerator/SpaceGenerator.tsx";
|
|
1044
|
-
var SpaceGenerator = ({ space, onCreateObjects }) => {
|
|
1045
|
-
var _effect = _useSignals2();
|
|
1046
|
-
try {
|
|
1047
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
1048
|
-
const client = useClient();
|
|
1049
|
-
const staticTypes = [
|
|
1050
|
-
DocumentType2,
|
|
1051
|
-
DiagramType2,
|
|
1052
|
-
SheetType2,
|
|
1053
|
-
ComputeGraph2
|
|
1054
|
-
];
|
|
1055
|
-
const mutableTypes = [
|
|
1056
|
-
DataType2.Organization,
|
|
1057
|
-
DataType2.Project,
|
|
1058
|
-
DataType2.Person,
|
|
1059
|
-
DataType2.Message
|
|
1060
|
-
];
|
|
1061
|
-
const [count, setCount] = useState(1);
|
|
1062
|
-
const [info, setInfo] = useState({});
|
|
1063
|
-
const presets = useMemo(() => generator2(), []);
|
|
1064
|
-
const typeMap = useMemo(() => {
|
|
1065
|
-
client.addTypes([
|
|
1066
|
-
...staticTypes,
|
|
1067
|
-
...presets.schemas
|
|
1068
|
-
]);
|
|
1069
|
-
const mutableGenerators = new Map(mutableTypes.map((type) => [
|
|
1070
|
-
type.typename,
|
|
1071
|
-
createGenerator(type)
|
|
1072
|
-
]));
|
|
1073
|
-
return new Map([
|
|
1074
|
-
...staticGenerators,
|
|
1075
|
-
...presets.items,
|
|
1076
|
-
...mutableGenerators
|
|
1077
|
-
]);
|
|
1078
|
-
}, [
|
|
1079
|
-
client,
|
|
1080
|
-
mutableTypes
|
|
1081
|
-
]);
|
|
1082
|
-
const updateInfo = async () => {
|
|
1083
|
-
const echoSchema = await space.db.schemaRegistry.query().run();
|
|
1084
|
-
const staticSchema = space.db.graph.schemaRegistry.schemas;
|
|
1085
|
-
const { objects } = await space.db.query(Filter3.everything()).run();
|
|
1086
|
-
const objectMap = sortKeys(objects.reduce((map, obj) => {
|
|
1087
|
-
const type = getTypename(obj);
|
|
1088
|
-
if (type) {
|
|
1089
|
-
const count2 = map[type] ?? 0;
|
|
1090
|
-
map[type] = count2 + 1;
|
|
1091
|
-
}
|
|
1092
|
-
return map;
|
|
1093
|
-
}, {}));
|
|
1094
|
-
setInfo({
|
|
1095
|
-
schema: {
|
|
1096
|
-
static: staticSchema.length,
|
|
1097
|
-
mutable: echoSchema.length
|
|
1098
|
-
},
|
|
1099
|
-
objects: objectMap
|
|
1100
|
-
});
|
|
1101
|
-
};
|
|
1102
|
-
useAsyncEffect(updateInfo, [
|
|
1103
|
-
space
|
|
1104
|
-
]);
|
|
1105
|
-
const handleCreateData = useCallback(async (typename) => {
|
|
1106
|
-
const constructor = typeMap.get(typename);
|
|
1107
|
-
if (constructor) {
|
|
1108
|
-
await constructor(space, count, onCreateObjects);
|
|
1109
|
-
await updateInfo();
|
|
1110
|
-
}
|
|
1111
|
-
}, [
|
|
1112
|
-
typeMap,
|
|
1113
|
-
count
|
|
1114
|
-
]);
|
|
1115
|
-
const handleLoadTables = useCallback(async () => {
|
|
1116
|
-
const input = document.createElement("input");
|
|
1117
|
-
input.type = "file";
|
|
1118
|
-
input.accept = ".json";
|
|
1119
|
-
input.onchange = async (e) => {
|
|
1120
|
-
const file = e.target.files?.[0];
|
|
1121
|
-
if (!file) {
|
|
1122
|
-
return;
|
|
1123
|
-
}
|
|
1124
|
-
try {
|
|
1125
|
-
const content = await file.text();
|
|
1126
|
-
const data = JSON.parse(content);
|
|
1127
|
-
const schemas = await space.db.schemaRegistry.register(data.schemas.map(Type2.toEffectSchema));
|
|
1128
|
-
await Promise.all(schemas.map(async (schema) => {
|
|
1129
|
-
const parts = schema.typename.split("/");
|
|
1130
|
-
const name = parts[parts.length - 1];
|
|
1131
|
-
const table = Obj3.make(TableType3, {
|
|
1132
|
-
name,
|
|
1133
|
-
threads: []
|
|
1134
|
-
});
|
|
1135
|
-
await initializeTable({
|
|
1136
|
-
client,
|
|
1137
|
-
space,
|
|
1138
|
-
table,
|
|
1139
|
-
typename: schema.typename
|
|
1140
|
-
});
|
|
1141
|
-
await dispatch(createIntent(SpaceAction.AddObject, {
|
|
1142
|
-
target: space,
|
|
1143
|
-
object: table
|
|
1144
|
-
}));
|
|
1145
|
-
return table;
|
|
1146
|
-
}));
|
|
1147
|
-
await Promise.all(data.objects.map(async ({ id, "@type": typename, ...fields }) => {
|
|
1148
|
-
const schema = schemas.find((s) => `dxn:type:${s.typename}:${s.version}` === typename);
|
|
1149
|
-
if (!schema) {
|
|
1150
|
-
log.warn("Missing schema for object", {
|
|
1151
|
-
id,
|
|
1152
|
-
typename
|
|
1153
|
-
}, {
|
|
1154
|
-
F: __dxlog_file2,
|
|
1155
|
-
L: 125,
|
|
1156
|
-
S: void 0,
|
|
1157
|
-
C: (f, a) => f(...a)
|
|
1158
|
-
});
|
|
1159
|
-
return;
|
|
1160
|
-
}
|
|
1161
|
-
const object = Obj3.make(schema, fields);
|
|
1162
|
-
space.db.add(object);
|
|
1163
|
-
return object;
|
|
1164
|
-
}));
|
|
1165
|
-
} catch (err) {
|
|
1166
|
-
log.catch(err, void 0, {
|
|
1167
|
-
F: __dxlog_file2,
|
|
1168
|
-
L: 134,
|
|
1169
|
-
S: void 0,
|
|
1170
|
-
C: (f, a) => f(...a)
|
|
1171
|
-
});
|
|
1172
|
-
}
|
|
1173
|
-
};
|
|
1174
|
-
input.click();
|
|
1175
|
-
}, []);
|
|
1176
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
1177
|
-
role: "none",
|
|
1178
|
-
className: "flex flex-col grow overflow-hidden"
|
|
1179
|
-
}, /* @__PURE__ */ React2.createElement(Toolbar.Root, {
|
|
1180
|
-
classNames: "border-be border-subduedSeparator"
|
|
1181
|
-
}, /* @__PURE__ */ React2.createElement(IconButton2, {
|
|
1182
|
-
icon: "ph--arrow-clockwise--regular",
|
|
1183
|
-
iconOnly: true,
|
|
1184
|
-
label: "Refresh",
|
|
1185
|
-
onClick: updateInfo
|
|
1186
|
-
}), /* @__PURE__ */ React2.createElement(IconButton2, {
|
|
1187
|
-
icon: "ph--file-arrow-up--regular",
|
|
1188
|
-
iconOnly: true,
|
|
1189
|
-
label: "Load tables from JSON",
|
|
1190
|
-
onClick: handleLoadTables
|
|
1191
|
-
}), /* @__PURE__ */ React2.createElement(Toolbar.Separator, {
|
|
1192
|
-
variant: "gap"
|
|
1193
|
-
}), /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
1194
|
-
type: "number",
|
|
1195
|
-
min: 1,
|
|
1196
|
-
max: 100,
|
|
1197
|
-
placeholder: "Count",
|
|
1198
|
-
classNames: "!w-[4rem] !text-right",
|
|
1199
|
-
size: 8,
|
|
1200
|
-
value: count,
|
|
1201
|
-
onChange: (ev) => setCount(parseInt(ev.target.value))
|
|
1202
|
-
}))), /* @__PURE__ */ React2.createElement("div", {
|
|
1203
|
-
className: "flex flex-col overflow-y-auto divide-y divide-separator"
|
|
1204
|
-
}, /* @__PURE__ */ React2.createElement(SchemaTable, {
|
|
1205
|
-
types: staticTypes,
|
|
1206
|
-
objects: info.objects,
|
|
1207
|
-
label: "Static Types",
|
|
1208
|
-
onClick: handleCreateData
|
|
1209
|
-
}), /* @__PURE__ */ React2.createElement(SchemaTable, {
|
|
1210
|
-
types: mutableTypes,
|
|
1211
|
-
objects: info.objects,
|
|
1212
|
-
label: "Mutable Types",
|
|
1213
|
-
onClick: handleCreateData
|
|
1214
|
-
}), /* @__PURE__ */ React2.createElement(SchemaTable, {
|
|
1215
|
-
types: presets.types,
|
|
1216
|
-
objects: info.objects,
|
|
1217
|
-
label: "Presets",
|
|
1218
|
-
onClick: handleCreateData
|
|
1219
|
-
}), /* @__PURE__ */ React2.createElement("div", null, /* @__PURE__ */ React2.createElement(SyntaxHighlighter, {
|
|
1220
|
-
classNames: "flex text-xs",
|
|
1221
|
-
language: "json"
|
|
1222
|
-
}, JSON.stringify({
|
|
1223
|
-
space,
|
|
1224
|
-
...info
|
|
1225
|
-
}, jsonKeyReplacer({
|
|
1226
|
-
truncate: true
|
|
1227
|
-
}), 2)))));
|
|
1228
|
-
} finally {
|
|
1229
|
-
_effect.f();
|
|
1230
|
-
}
|
|
1231
|
-
};
|
|
1232
|
-
|
|
1233
|
-
// packages/plugins/plugin-debug/src/components/SpaceGenerator/index.ts
|
|
1234
|
-
var SpaceGenerator_default = SpaceGenerator;
|
|
1235
|
-
export {
|
|
1236
|
-
SpaceGenerator_default as default
|
|
1237
|
-
};
|
|
1238
|
-
//# sourceMappingURL=SpaceGenerator-VB6IB2LL.mjs.map
|