@dxos/plugin-debug 0.8.3 → 0.8.4-main.1f223c7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs +20 -0
- package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs.map +7 -0
- package/dist/lib/browser/{DevtoolsOverviewContainer-IIIWO77Q.mjs → DevtoolsOverviewContainer-EPD6EWT5.mjs} +2 -2
- package/dist/lib/browser/{SpaceGenerator-VB6IB2LL.mjs → SpaceGenerator-SRCIEELZ.mjs} +355 -492
- package/dist/lib/browser/SpaceGenerator-SRCIEELZ.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-6HHJMKVU.mjs → app-graph-builder-JTIEFOWZ.mjs} +25 -35
- package/dist/lib/browser/app-graph-builder-JTIEFOWZ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-47JOZTT2.mjs → chunk-5XPIRNQS.mjs} +2 -2
- package/dist/lib/browser/{chunk-KS3YBEL7.mjs → chunk-AJA6RYN3.mjs} +2 -2
- package/dist/lib/browser/index.mjs +17 -14
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-context-ZQRD2WG2.mjs → react-context-NVAGLAJD.mjs} +3 -3
- package/dist/lib/browser/{react-surface-UI6OK73H.mjs → react-surface-HQPOGG33.mjs} +43 -38
- package/dist/lib/browser/react-surface-HQPOGG33.mjs.map +7 -0
- package/dist/lib/browser/{settings-SXQWSIM4.mjs → settings-LSSWLM5I.mjs} +4 -4
- package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +5 -5
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-context.d.ts +2 -2
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.d.ts +1 -1
- package/dist/types/src/components/DebugGraph.d.ts +8 -0
- package/dist/types/src/components/DebugGraph.d.ts.map +1 -0
- package/dist/types/src/components/DebugSettings.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts +3 -1
- 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 -3
- 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 -5
- package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -1
- package/dist/types/src/components/Wireframe.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +62 -60
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +60 -59
- package/src/DebugPlugin.tsx +2 -2
- package/src/capabilities/app-graph-builder.ts +13 -40
- package/src/capabilities/react-surface.tsx +9 -8
- package/src/components/DebugGraph.tsx +14 -0
- package/src/components/DebugObjectPanel.tsx +1 -1
- package/src/components/DebugSettings.tsx +72 -64
- package/src/components/SpaceGenerator/ObjectGenerator.tsx +32 -26
- package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +8 -6
- package/src/components/SpaceGenerator/SpaceGenerator.tsx +15 -72
- package/src/components/SpaceGenerator/draw-util.ts +3 -3
- package/src/components/SpaceGenerator/presets.ts +324 -221
- package/src/components/Wireframe.tsx +2 -1
- package/src/components/index.ts +1 -1
- package/src/translations.ts +8 -4
- package/dist/lib/browser/DebugApp-WSEJPCKY.mjs +0 -225
- package/dist/lib/browser/DebugApp-WSEJPCKY.mjs.map +0 -7
- package/dist/lib/browser/SpaceGenerator-VB6IB2LL.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-6HHJMKVU.mjs.map +0 -7
- package/dist/lib/browser/react-surface-UI6OK73H.mjs.map +0 -7
- package/dist/types/src/components/DebugApp/DebugApp.d.ts +0 -6
- package/dist/types/src/components/DebugApp/DebugApp.d.ts.map +0 -1
- package/dist/types/src/components/DebugApp/Tree.d.ts +0 -18
- package/dist/types/src/components/DebugApp/Tree.d.ts.map +0 -1
- package/dist/types/src/components/DebugApp/index.d.ts +0 -3
- package/dist/types/src/components/DebugApp/index.d.ts.map +0 -1
- package/src/components/DebugApp/DebugApp.tsx +0 -77
- package/src/components/DebugApp/Tree.tsx +0 -103
- package/src/components/DebugApp/index.ts +0 -7
- /package/dist/lib/browser/{DevtoolsOverviewContainer-IIIWO77Q.mjs.map → DevtoolsOverviewContainer-EPD6EWT5.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-47JOZTT2.mjs.map → chunk-5XPIRNQS.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-KS3YBEL7.mjs.map → chunk-AJA6RYN3.mjs.map} +0 -0
- /package/dist/lib/browser/{react-context-ZQRD2WG2.mjs.map → react-context-NVAGLAJD.mjs.map} +0 -0
- /package/dist/lib/browser/{settings-SXQWSIM4.mjs.map → settings-LSSWLM5I.mjs.map} +0 -0
|
@@ -1,74 +1,68 @@
|
|
|
1
|
-
//
|
|
1
|
+
// src/components/SpaceGenerator/SpaceGenerator.tsx
|
|
2
2
|
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
3
3
|
import React2, { useCallback, useMemo, useState } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { useIntentDispatcher } from "@dxos/app-framework";
|
|
5
5
|
import { ComputeGraph as ComputeGraph2 } from "@dxos/conductor";
|
|
6
|
-
import { Filter as Filter3
|
|
7
|
-
import {
|
|
8
|
-
import { DocumentType as DocumentType2 } from "@dxos/plugin-markdown/types";
|
|
6
|
+
import { Filter as Filter3 } from "@dxos/echo";
|
|
7
|
+
import { Markdown as Markdown3 } from "@dxos/plugin-markdown/types";
|
|
9
8
|
import { SheetType as SheetType2 } from "@dxos/plugin-sheet/types";
|
|
10
9
|
import { DiagramType as DiagramType2 } from "@dxos/plugin-sketch/types";
|
|
11
|
-
import { SpaceAction } from "@dxos/plugin-space/types";
|
|
12
10
|
import { useClient } from "@dxos/react-client";
|
|
13
11
|
import { getTypename } from "@dxos/react-client/echo";
|
|
14
12
|
import { IconButton as IconButton2, Input, Toolbar, useAsyncEffect } from "@dxos/react-ui";
|
|
15
13
|
import { SyntaxHighlighter } from "@dxos/react-ui-syntax-highlighter";
|
|
16
|
-
import {
|
|
17
|
-
import { DataType as DataType2 } from "@dxos/schema";
|
|
14
|
+
import { DataType as DataType3 } from "@dxos/schema";
|
|
18
15
|
import { jsonKeyReplacer, sortKeys } from "@dxos/util";
|
|
19
16
|
|
|
20
|
-
//
|
|
17
|
+
// src/components/SpaceGenerator/ObjectGenerator.tsx
|
|
18
|
+
import { createIntent } from "@dxos/app-framework";
|
|
21
19
|
import { addressToA1Notation } from "@dxos/compute";
|
|
22
20
|
import { ComputeGraph, ComputeGraphModel, DEFAULT_OUTPUT, NODE_INPUT, NODE_OUTPUT } from "@dxos/conductor";
|
|
23
|
-
import { DXN, Filter, Key, Obj, Ref } from "@dxos/echo";
|
|
24
|
-
import {
|
|
21
|
+
import { DXN, Filter, Key, Obj, Ref, Type } from "@dxos/echo";
|
|
22
|
+
import { Markdown } from "@dxos/plugin-markdown/types";
|
|
25
23
|
import { createSheet } from "@dxos/plugin-sheet/types";
|
|
26
24
|
import { SheetType } from "@dxos/plugin-sheet/types";
|
|
27
25
|
import { CanvasType, DiagramType } from "@dxos/plugin-sketch/types";
|
|
26
|
+
import { SpaceAction } from "@dxos/plugin-space/types";
|
|
28
27
|
import { faker } from "@dxos/random";
|
|
29
|
-
import {
|
|
30
|
-
import { createView, DataType } from "@dxos/schema";
|
|
28
|
+
import { DataType, typenameFromQuery } from "@dxos/schema";
|
|
31
29
|
import { createAsyncGenerator } from "@dxos/schema/testing";
|
|
32
30
|
import { range } from "@dxos/util";
|
|
33
31
|
var generator = faker;
|
|
34
|
-
var
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
typename
|
|
52
|
-
jsonSchema: schema.jsonSchema
|
|
53
|
-
});
|
|
54
|
-
space.db.add(Obj.make(TableType, {
|
|
55
|
-
name,
|
|
56
|
-
view: Ref.make(view)
|
|
32
|
+
var findViewByTypename = async (views, typename) => {
|
|
33
|
+
return views.find((view) => typenameFromQuery(view.query) === typename);
|
|
34
|
+
};
|
|
35
|
+
var createGenerator = (client, dispatch, schema) => {
|
|
36
|
+
return async (space, n) => {
|
|
37
|
+
const typename = schema.typename;
|
|
38
|
+
const { objects: views } = await space.db.query(Filter.type(DataType.View)).run();
|
|
39
|
+
const view = await findViewByTypename(views, typename);
|
|
40
|
+
const staticSchema = client?.graph.schemaRegistry.schemas.find((schema2) => Type.getTypename(schema2) === typename);
|
|
41
|
+
if (!view && !staticSchema) {
|
|
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
|
|
57
50
|
}));
|
|
58
51
|
}
|
|
59
|
-
|
|
52
|
+
const generate = createAsyncGenerator(generator, schema, {
|
|
53
|
+
db: space.db
|
|
54
|
+
});
|
|
55
|
+
return generate.createObjects(n);
|
|
60
56
|
};
|
|
61
57
|
};
|
|
62
58
|
var staticGenerators = /* @__PURE__ */ new Map([
|
|
63
59
|
[
|
|
64
|
-
|
|
60
|
+
Markdown.Document.typename,
|
|
65
61
|
async (space, n, cb) => {
|
|
66
62
|
const objects = range(n).map(() => {
|
|
67
|
-
return space.db.add(
|
|
63
|
+
return space.db.add(Markdown.makeDocument({
|
|
68
64
|
name: faker.commerce.productName(),
|
|
69
|
-
content:
|
|
70
|
-
content: faker.lorem.sentences(5)
|
|
71
|
-
}))
|
|
65
|
+
content: faker.lorem.sentences(5)
|
|
72
66
|
}));
|
|
73
67
|
});
|
|
74
68
|
cb?.(objects);
|
|
@@ -202,58 +196,29 @@ var staticGenerators = /* @__PURE__ */ new Map([
|
|
|
202
196
|
]
|
|
203
197
|
]);
|
|
204
198
|
|
|
205
|
-
//
|
|
206
|
-
import {
|
|
207
|
-
import
|
|
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";
|
|
199
|
+
// src/components/SpaceGenerator/presets.ts
|
|
200
|
+
import { Schema } from "effect";
|
|
201
|
+
import { ResearchOn, research } from "@dxos/assistant-testing";
|
|
237
202
|
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,
|
|
203
|
+
import { DXN as DXN2, Filter as Filter2, Key as Key2, Obj as Obj2, Query, Ref as Ref2, Relation, Type as Type2 } from "@dxos/echo";
|
|
204
|
+
import { FunctionTrigger, serializeFunction } from "@dxos/functions";
|
|
240
205
|
import { invariant } from "@dxos/invariant";
|
|
241
|
-
import {
|
|
242
|
-
import {
|
|
206
|
+
import { Mailbox } from "@dxos/plugin-inbox/types";
|
|
207
|
+
import { Markdown as Markdown2 } from "@dxos/plugin-markdown/types";
|
|
208
|
+
import { createAppend, createChat, createComputeGraph, createConstant, createFunction, createGpt, createQueue, createRandom, createSurface, createTemplate, createText, createTrigger } from "@dxos/react-ui-canvas-compute";
|
|
243
209
|
import { CanvasBoardType, CanvasGraphModel, pointMultiply, pointsToRect, rectToPoints } from "@dxos/react-ui-canvas-editor";
|
|
244
|
-
import {
|
|
210
|
+
import { DataType as DataType2, createView } from "@dxos/schema";
|
|
245
211
|
import { range as range2 } from "@dxos/util";
|
|
246
|
-
var __dxlog_file = "/
|
|
212
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-debug/src/components/SpaceGenerator/presets.ts";
|
|
247
213
|
var PresetName = /* @__PURE__ */ function(PresetName2) {
|
|
248
|
-
PresetName2["
|
|
214
|
+
PresetName2["DXOS_TEAM"] = "dxos-team";
|
|
215
|
+
PresetName2["ORG_RESEARCH_PROJECT"] = "org-research-project";
|
|
249
216
|
PresetName2["GPT_QUEUE"] = "webhook-gpt-queue";
|
|
250
217
|
PresetName2["CHAT_GPT"] = "chat-gpt-text";
|
|
251
|
-
PresetName2["EMAIL_WITH_SUMMARY"] = "email-gptSummary-table";
|
|
252
218
|
PresetName2["OBJECT_CHANGE_QUEUE"] = "objectChange-queue";
|
|
253
219
|
PresetName2["FOREX_FUNCTION_CALL"] = "forex-function-call";
|
|
254
220
|
PresetName2["TIMER_TICK_QUEUE"] = "timerTick-queue";
|
|
255
221
|
PresetName2["DISCORD_MESSAGES"] = "discord-messages";
|
|
256
|
-
PresetName2["KANBAN_QUEUE"] = "kanban-queue";
|
|
257
222
|
return PresetName2;
|
|
258
223
|
}({});
|
|
259
224
|
var generator2 = () => ({
|
|
@@ -265,6 +230,123 @@ var generator2 = () => ({
|
|
|
265
230
|
typename: name
|
|
266
231
|
})),
|
|
267
232
|
items: [
|
|
233
|
+
[
|
|
234
|
+
"dxos-team",
|
|
235
|
+
async (space, n, cb) => {
|
|
236
|
+
const objects = range2(n, () => {
|
|
237
|
+
const org = space.db.add(Obj2.make(DataType2.Organization, {
|
|
238
|
+
name: "DXOS",
|
|
239
|
+
website: "https://dxos.org"
|
|
240
|
+
}));
|
|
241
|
+
const doc = space.db.add(Markdown2.makeDocument({
|
|
242
|
+
name: "DXOS Research",
|
|
243
|
+
content: "DXOS builds Composer, an open-source AI-powered malleable application."
|
|
244
|
+
}));
|
|
245
|
+
space.db.add(Relation.make(ResearchOn, {
|
|
246
|
+
[Relation.Source]: doc,
|
|
247
|
+
[Relation.Target]: org,
|
|
248
|
+
completedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
249
|
+
}));
|
|
250
|
+
space.db.add(Obj2.make(DataType2.Person, {
|
|
251
|
+
fullName: "Rich",
|
|
252
|
+
jobTitle: "investor",
|
|
253
|
+
organization: Ref2.make(org)
|
|
254
|
+
}));
|
|
255
|
+
space.db.add(Obj2.make(DataType2.Person, {
|
|
256
|
+
fullName: "Josiah",
|
|
257
|
+
organization: Ref2.make(org)
|
|
258
|
+
}));
|
|
259
|
+
space.db.add(Obj2.make(DataType2.Person, {
|
|
260
|
+
fullName: "Dima",
|
|
261
|
+
organization: Ref2.make(org)
|
|
262
|
+
}));
|
|
263
|
+
space.db.add(Obj2.make(DataType2.Person, {
|
|
264
|
+
fullName: "Mykola",
|
|
265
|
+
organization: Ref2.make(org)
|
|
266
|
+
}));
|
|
267
|
+
space.db.add(Obj2.make(DataType2.Person, {
|
|
268
|
+
fullName: "Will",
|
|
269
|
+
organization: Ref2.make(org)
|
|
270
|
+
}));
|
|
271
|
+
return doc;
|
|
272
|
+
});
|
|
273
|
+
cb?.(objects);
|
|
274
|
+
return objects;
|
|
275
|
+
}
|
|
276
|
+
],
|
|
277
|
+
[
|
|
278
|
+
"org-research-project",
|
|
279
|
+
async (space, n, cb) => {
|
|
280
|
+
const mailbox = await space.db.query(Filter2.type(Mailbox.Mailbox)).first();
|
|
281
|
+
const objects = range2(n, () => {
|
|
282
|
+
const contactsQuery = Query.select(Filter2.type(DataType2.Person, {
|
|
283
|
+
jobTitle: "investor"
|
|
284
|
+
}));
|
|
285
|
+
const organizationsQuery = contactsQuery.reference("organization");
|
|
286
|
+
const notesQuery = organizationsQuery.targetOf(ResearchOn).source();
|
|
287
|
+
const researchTrigger = Obj2.make(FunctionTrigger, {
|
|
288
|
+
function: Ref2.make(serializeFunction(research)),
|
|
289
|
+
spec: {
|
|
290
|
+
kind: "subscription",
|
|
291
|
+
query: organizationsQuery.ast
|
|
292
|
+
},
|
|
293
|
+
enabled: true
|
|
294
|
+
});
|
|
295
|
+
space.db.add(researchTrigger);
|
|
296
|
+
const mailboxView = createView({
|
|
297
|
+
name: "Mailbox",
|
|
298
|
+
query: Query.select(Filter2.type(DataType2.Message, {
|
|
299
|
+
properties: {
|
|
300
|
+
labels: Filter2.contains("investor")
|
|
301
|
+
}
|
|
302
|
+
})).options({
|
|
303
|
+
queues: [
|
|
304
|
+
mailbox.queue.dxn.toString()
|
|
305
|
+
]
|
|
306
|
+
}),
|
|
307
|
+
jsonSchema: Type2.toJsonSchema(DataType2.Message),
|
|
308
|
+
presentation: Obj2.make(DataType2.Collection, {
|
|
309
|
+
objects: []
|
|
310
|
+
})
|
|
311
|
+
});
|
|
312
|
+
const contactsView = createView({
|
|
313
|
+
name: "Contacts",
|
|
314
|
+
query: contactsQuery,
|
|
315
|
+
jsonSchema: Type2.toJsonSchema(DataType2.Person),
|
|
316
|
+
presentation: Obj2.make(DataType2.Collection, {
|
|
317
|
+
objects: []
|
|
318
|
+
})
|
|
319
|
+
});
|
|
320
|
+
const organizationsView = createView({
|
|
321
|
+
name: "Organizations",
|
|
322
|
+
query: organizationsQuery,
|
|
323
|
+
jsonSchema: Type2.toJsonSchema(DataType2.Organization),
|
|
324
|
+
presentation: Obj2.make(DataType2.Collection, {
|
|
325
|
+
objects: []
|
|
326
|
+
})
|
|
327
|
+
});
|
|
328
|
+
const notesView = createView({
|
|
329
|
+
name: "Notes",
|
|
330
|
+
query: notesQuery,
|
|
331
|
+
jsonSchema: Type2.toJsonSchema(Markdown2.Document),
|
|
332
|
+
presentation: Obj2.make(DataType2.Collection, {
|
|
333
|
+
objects: []
|
|
334
|
+
})
|
|
335
|
+
});
|
|
336
|
+
return space.db.add(DataType2.makeProject({
|
|
337
|
+
name: "Investor Research",
|
|
338
|
+
collections: [
|
|
339
|
+
mailboxView,
|
|
340
|
+
contactsView,
|
|
341
|
+
organizationsView,
|
|
342
|
+
notesView
|
|
343
|
+
].map((view) => Ref2.make(view))
|
|
344
|
+
}));
|
|
345
|
+
});
|
|
346
|
+
cb?.(objects.flat());
|
|
347
|
+
return objects.flat();
|
|
348
|
+
}
|
|
349
|
+
],
|
|
268
350
|
[
|
|
269
351
|
"webhook-gpt-queue",
|
|
270
352
|
async (space, n, cb) => {
|
|
@@ -278,7 +360,7 @@ var generator2 = () => ({
|
|
|
278
360
|
})));
|
|
279
361
|
const triggerShape = createTrigger({
|
|
280
362
|
spaceId: space.id,
|
|
281
|
-
triggerKind:
|
|
363
|
+
triggerKind: "webhook",
|
|
282
364
|
...position({
|
|
283
365
|
x: -18,
|
|
284
366
|
y: -2
|
|
@@ -329,9 +411,7 @@ var generator2 = () => ({
|
|
|
329
411
|
"objectChange-queue",
|
|
330
412
|
async (space, n, cb) => {
|
|
331
413
|
const objects = range2(n, () => {
|
|
332
|
-
const { canvasModel, computeModel } = createQueueSinkPreset(space,
|
|
333
|
-
type: "dxn:type:dxos.org/type/Chess"
|
|
334
|
-
}, "type");
|
|
414
|
+
const { canvasModel, computeModel } = createQueueSinkPreset(space, "subscription", (triggerSpec) => triggerSpec.query = Query.select(Filter2.typename("dxos.org/type/Chess")).ast, "type");
|
|
335
415
|
return addToSpace("objectChange-queue", space, canvasModel, computeModel);
|
|
336
416
|
});
|
|
337
417
|
cb?.(objects);
|
|
@@ -342,108 +422,68 @@ var generator2 = () => ({
|
|
|
342
422
|
"timerTick-queue",
|
|
343
423
|
async (space, n, cb) => {
|
|
344
424
|
const objects = range2(n, () => {
|
|
345
|
-
const { canvasModel, computeModel } = createQueueSinkPreset(space,
|
|
425
|
+
const { canvasModel, computeModel } = createQueueSinkPreset(space, "timer", (triggerSpec) => triggerSpec.cron = "*/5 * * * * *", "result");
|
|
346
426
|
return addToSpace("timerTick-queue", space, canvasModel, computeModel);
|
|
347
427
|
});
|
|
348
428
|
cb?.(objects);
|
|
349
429
|
return objects;
|
|
350
430
|
}
|
|
351
431
|
],
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
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
|
-
],
|
|
432
|
+
// TODO(wittjosiah): Remove?
|
|
433
|
+
// [
|
|
434
|
+
// PresetName.EMAIL_TABLE,
|
|
435
|
+
// async (space, n, cb) => {
|
|
436
|
+
// const objects = range(n, () => {
|
|
437
|
+
// const canvasModel = CanvasGraphModel.create<ComputeShape>();
|
|
438
|
+
// const results = space.db.query(Filter.type(TableType)).runSync();
|
|
439
|
+
// const emailTable = results.find((r) => r.object?.view?.target?.query?.typename?.endsWith('Email'));
|
|
440
|
+
// invariant(emailTable, 'Email table not found.');
|
|
441
|
+
// const template = canvasModel.createNode(
|
|
442
|
+
// createTemplate({
|
|
443
|
+
// valueType: 'object',
|
|
444
|
+
// ...rawPosition({ centerX: -80, centerY: -64, width: 320, height: 320 }),
|
|
445
|
+
// }),
|
|
446
|
+
// );
|
|
447
|
+
// const templateContent = ['{'];
|
|
448
|
+
// let functionTrigger: FunctionTrigger | undefined;
|
|
449
|
+
// canvasModel.builder.call((builder) => {
|
|
450
|
+
// const triggerShape = createTrigger({
|
|
451
|
+
// spaceId: space.id,
|
|
452
|
+
// triggerKind: 'email',
|
|
453
|
+
// ...position({ x: -18, y: -2 }),
|
|
454
|
+
// });
|
|
455
|
+
// const trigger = canvasModel.createNode(triggerShape);
|
|
456
|
+
// const tableId = canvasModel.createNode(
|
|
457
|
+
// createConstant({
|
|
458
|
+
// value: DXN.fromLocalObjectId(emailTable.id).toString(),
|
|
459
|
+
// ...position({ x: -18, y: 5, width: 8, height: 6 }),
|
|
460
|
+
// }),
|
|
461
|
+
// );
|
|
462
|
+
// const appendToTable = canvasModel.createNode(createAppend(position({ x: 10, y: 6 })));
|
|
463
|
+
// const properties = SchemaAST.getPropertySignatures(EmailTriggerOutput.ast);
|
|
464
|
+
// for (let i = 0; i < properties.length; i++) {
|
|
465
|
+
// const propName = properties[i].name.toString();
|
|
466
|
+
// builder.createEdge({ source: trigger.id, target: template.id, input: propName, output: propName });
|
|
467
|
+
// templateContent.push(` "${propName}": "{{${propName}}}"` + (i === properties.length - 1 ? '' : ','));
|
|
468
|
+
// }
|
|
469
|
+
// templateContent.push('}');
|
|
470
|
+
// builder
|
|
471
|
+
// .createEdge({ source: tableId.id, target: appendToTable.id, input: 'id' })
|
|
472
|
+
// .createEdge({ source: template.id, target: appendToTable.id, input: 'items' });
|
|
473
|
+
// functionTrigger = triggerShape.functionTrigger!.target!;
|
|
474
|
+
// });
|
|
475
|
+
// const computeModel = createComputeGraph(canvasModel);
|
|
476
|
+
// const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
|
|
477
|
+
// invariant(templateComputeNode, 'Template compute node was not created.');
|
|
478
|
+
// templateComputeNode.value = templateContent.join('\n');
|
|
479
|
+
// templateComputeNode.inputSchema = Type.toJsonSchema(EmailTriggerOutput);
|
|
480
|
+
// attachTrigger(functionTrigger, computeModel);
|
|
481
|
+
// return addToSpace(PresetName.EMAIL_TABLE, space, canvasModel, computeModel);
|
|
482
|
+
// });
|
|
483
|
+
// cb?.(objects);
|
|
484
|
+
// return objects;
|
|
485
|
+
// },
|
|
486
|
+
// ],
|
|
447
487
|
[
|
|
448
488
|
"chat-gpt-text",
|
|
449
489
|
async (space, n, cb) => {
|
|
@@ -495,168 +535,86 @@ var generator2 = () => ({
|
|
|
495
535
|
return objects;
|
|
496
536
|
}
|
|
497
537
|
],
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
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
|
-
],
|
|
538
|
+
// TODO(wittjosiah): Remove?
|
|
539
|
+
// [
|
|
540
|
+
// PresetName.EMAIL_WITH_SUMMARY,
|
|
541
|
+
// async (space, n, cb) => {
|
|
542
|
+
// const objects = range(n, () => {
|
|
543
|
+
// const canvasModel = CanvasGraphModel.create<ComputeShape>();
|
|
544
|
+
// const results = space.db.query(Filter.type(TableType)).runSync();
|
|
545
|
+
// const emailTable = results.find((r) => r.object?.view?.target?.query?.typename?.endsWith('Email'));
|
|
546
|
+
// invariant(emailTable, 'Email table not found.');
|
|
547
|
+
// const template = canvasModel.createNode(
|
|
548
|
+
// createTemplate({
|
|
549
|
+
// valueType: 'object',
|
|
550
|
+
// ...rawPosition({ centerX: 192, centerY: -176, width: 320, height: 320 }),
|
|
551
|
+
// }),
|
|
552
|
+
// );
|
|
553
|
+
// const templateContent = ['{'];
|
|
554
|
+
// let functionTrigger: FunctionTrigger | undefined;
|
|
555
|
+
// canvasModel.builder.call((builder) => {
|
|
556
|
+
// const gpt = canvasModel.createNode(
|
|
557
|
+
// createGpt(rawPosition({ centerX: -400, centerY: -112, width: 256, height: 202 })),
|
|
558
|
+
// );
|
|
559
|
+
// const systemPrompt = canvasModel.createNode(
|
|
560
|
+
// createConstant({
|
|
561
|
+
// value: "use one word to describe content category. don't write anything else",
|
|
562
|
+
// ...rawPosition({ centerX: -800, centerY: -160, width: 192, height: 128 }),
|
|
563
|
+
// }),
|
|
564
|
+
// );
|
|
565
|
+
// const triggerShape = createTrigger({
|
|
566
|
+
// spaceId: space.id,
|
|
567
|
+
// triggerKind: 'email',
|
|
568
|
+
// ...rawPosition({ centerX: -736, centerY: -384, width: 182, height: 192 }),
|
|
569
|
+
// });
|
|
570
|
+
// const trigger = canvasModel.createNode(triggerShape);
|
|
571
|
+
// const { queueId } = setupQueue(space, canvasModel, {
|
|
572
|
+
// idPosition: { centerX: -720, centerY: 224, width: 192, height: 256 },
|
|
573
|
+
// queuePosition: { centerX: -144, centerY: 416, width: 320, height: 448 },
|
|
574
|
+
// });
|
|
575
|
+
// const appendToQueue = canvasModel.createNode(
|
|
576
|
+
// createAppend(rawPosition({ centerX: -80, centerY: 96, width: 122, height: 128 })),
|
|
577
|
+
// );
|
|
578
|
+
// const tableId = canvasModel.createNode(
|
|
579
|
+
// createConstant({
|
|
580
|
+
// value: DXN.fromLocalObjectId(emailTable.id).toString(),
|
|
581
|
+
// ...rawPosition({ centerX: -112, centerY: -544, width: 192, height: 256 }),
|
|
582
|
+
// }),
|
|
583
|
+
// );
|
|
584
|
+
// const appendToTable = canvasModel.createNode(
|
|
585
|
+
// createAppend(rawPosition({ centerX: 560, centerY: -416, width: 128, height: 122 })),
|
|
586
|
+
// );
|
|
587
|
+
// templateContent.push(' "category": "{{text}}",');
|
|
588
|
+
// builder.createEdge({ source: gpt.id, target: template.id, input: 'text', output: 'text' });
|
|
589
|
+
// const properties = SchemaAST.getPropertySignatures(EmailTriggerOutput.ast);
|
|
590
|
+
// for (let i = 0; i < properties.length; i++) {
|
|
591
|
+
// const propName = properties[i].name.toString();
|
|
592
|
+
// builder.createEdge({ source: trigger.id, target: template.id, input: propName, output: propName });
|
|
593
|
+
// templateContent.push(` "${propName}": "{{${propName}}}"` + (i === properties.length - 1 ? '' : ','));
|
|
594
|
+
// }
|
|
595
|
+
// templateContent.push('}');
|
|
596
|
+
// builder
|
|
597
|
+
// .createEdge({ source: tableId.id, target: appendToTable.id, input: 'id' })
|
|
598
|
+
// .createEdge({ source: queueId.id, target: appendToQueue.id, input: 'id' })
|
|
599
|
+
// .createEdge({ source: gpt.id, target: appendToQueue.id, output: 'messages', input: 'items' })
|
|
600
|
+
// .createEdge({ source: systemPrompt.id, target: gpt.id, input: 'systemPrompt' })
|
|
601
|
+
// .createEdge({ source: trigger.id, target: gpt.id, input: 'prompt', output: 'body' })
|
|
602
|
+
// .createEdge({ source: template.id, target: appendToTable.id, input: 'items' });
|
|
603
|
+
// functionTrigger = triggerShape.functionTrigger!.target!;
|
|
604
|
+
// });
|
|
605
|
+
// const computeModel = createComputeGraph(canvasModel);
|
|
606
|
+
// const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
|
|
607
|
+
// invariant(templateComputeNode, 'Template compute node was not created.');
|
|
608
|
+
// templateComputeNode.value = templateContent.join('\n');
|
|
609
|
+
// const extendedSchema = Schema.extend(EmailTriggerOutput, Schema.Struct({ text: Schema.String }));
|
|
610
|
+
// templateComputeNode.inputSchema = Type.toJsonSchema(extendedSchema);
|
|
611
|
+
// attachTrigger(functionTrigger, computeModel);
|
|
612
|
+
// return addToSpace(PresetName.EMAIL_WITH_SUMMARY, space, canvasModel, computeModel);
|
|
613
|
+
// });
|
|
614
|
+
// cb?.(objects);
|
|
615
|
+
// return objects;
|
|
616
|
+
// },
|
|
617
|
+
// ],
|
|
660
618
|
[
|
|
661
619
|
"forex-function-call",
|
|
662
620
|
async (space, n, cb) => {
|
|
@@ -715,7 +673,7 @@ var generator2 = () => ({
|
|
|
715
673
|
canvasModel.builder.call((builder) => {
|
|
716
674
|
const triggerShape = createTrigger({
|
|
717
675
|
spaceId: space.id,
|
|
718
|
-
triggerKind:
|
|
676
|
+
triggerKind: "timer",
|
|
719
677
|
...position({
|
|
720
678
|
x: -10,
|
|
721
679
|
y: -5
|
|
@@ -782,64 +740,6 @@ var generator2 = () => ({
|
|
|
782
740
|
cb?.(objects);
|
|
783
741
|
return objects;
|
|
784
742
|
}
|
|
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
743
|
]
|
|
844
744
|
]
|
|
845
745
|
});
|
|
@@ -909,7 +809,7 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
|
|
|
909
809
|
const triggerSpec = functionTrigger.spec;
|
|
910
810
|
invariant(triggerSpec && triggerSpec.kind === triggerKind, "No trigger spec.", {
|
|
911
811
|
F: __dxlog_file,
|
|
912
|
-
L:
|
|
812
|
+
L: 597,
|
|
913
813
|
S: void 0,
|
|
914
814
|
A: [
|
|
915
815
|
"triggerSpec && triggerSpec.kind === triggerKind",
|
|
@@ -922,7 +822,7 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
|
|
|
922
822
|
const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
|
|
923
823
|
invariant(templateComputeNode, "Template compute node was not created.", {
|
|
924
824
|
F: __dxlog_file,
|
|
925
|
-
L:
|
|
825
|
+
L: 604,
|
|
926
826
|
S: void 0,
|
|
927
827
|
A: [
|
|
928
828
|
"templateComputeNode",
|
|
@@ -935,7 +835,7 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
|
|
|
935
835
|
' "id": "@{{changeId}}"',
|
|
936
836
|
"}"
|
|
937
837
|
].join("\n");
|
|
938
|
-
templateComputeNode.inputSchema =
|
|
838
|
+
templateComputeNode.inputSchema = Type2.toJsonSchema(Schema.Struct({
|
|
939
839
|
type: Schema.String,
|
|
940
840
|
changeId: Schema.String
|
|
941
841
|
}));
|
|
@@ -984,7 +884,7 @@ var setupQueue = (space, canvasModel, args) => {
|
|
|
984
884
|
var attachTrigger = (functionTrigger, computeModel) => {
|
|
985
885
|
invariant(functionTrigger, void 0, {
|
|
986
886
|
F: __dxlog_file,
|
|
987
|
-
L:
|
|
887
|
+
L: 643,
|
|
988
888
|
S: void 0,
|
|
989
889
|
A: [
|
|
990
890
|
"functionTrigger",
|
|
@@ -1039,24 +939,52 @@ var position = (rect) => {
|
|
|
1039
939
|
}
|
|
1040
940
|
};
|
|
1041
941
|
|
|
1042
|
-
//
|
|
1043
|
-
|
|
942
|
+
// src/components/SpaceGenerator/SchemaTable.tsx
|
|
943
|
+
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
944
|
+
import React from "react";
|
|
945
|
+
import { IconButton } from "@dxos/react-ui";
|
|
946
|
+
var SchemaTable = ({ types, objects = {}, label, onClick }) => {
|
|
947
|
+
var _effect = _useSignals();
|
|
948
|
+
try {
|
|
949
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
950
|
+
className: "grid grid-cols-[1fr_80px_40px] gap-1 overflow-none"
|
|
951
|
+
}, /* @__PURE__ */ React.createElement("h2", {
|
|
952
|
+
className: "p-2"
|
|
953
|
+
}, label), types.map((type) => /* @__PURE__ */ React.createElement("div", {
|
|
954
|
+
key: type.typename,
|
|
955
|
+
className: "grid grid-cols-subgrid col-span-3 items-center"
|
|
956
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
957
|
+
className: "px-2 text-sm font-mono text-subdued"
|
|
958
|
+
}, type.typename), /* @__PURE__ */ React.createElement("div", {
|
|
959
|
+
className: "px-2 text-right font-mono"
|
|
960
|
+
}, objects[type.typename] ?? 0), /* @__PURE__ */ React.createElement(IconButton, {
|
|
961
|
+
variant: "ghost",
|
|
962
|
+
icon: "ph--plus--regular",
|
|
963
|
+
iconOnly: true,
|
|
964
|
+
label: "Create data",
|
|
965
|
+
onClick: () => onClick(type.typename)
|
|
966
|
+
}))));
|
|
967
|
+
} finally {
|
|
968
|
+
_effect.f();
|
|
969
|
+
}
|
|
970
|
+
};
|
|
971
|
+
|
|
972
|
+
// src/components/SpaceGenerator/SpaceGenerator.tsx
|
|
1044
973
|
var SpaceGenerator = ({ space, onCreateObjects }) => {
|
|
1045
974
|
var _effect = _useSignals2();
|
|
1046
975
|
try {
|
|
1047
976
|
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
1048
977
|
const client = useClient();
|
|
1049
978
|
const staticTypes = [
|
|
1050
|
-
|
|
979
|
+
Markdown3.Document,
|
|
1051
980
|
DiagramType2,
|
|
1052
981
|
SheetType2,
|
|
1053
982
|
ComputeGraph2
|
|
1054
983
|
];
|
|
1055
|
-
const
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
DataType2.Message
|
|
984
|
+
const recordTypes = [
|
|
985
|
+
DataType3.Organization,
|
|
986
|
+
DataType3.Person,
|
|
987
|
+
DataType3.Task
|
|
1060
988
|
];
|
|
1061
989
|
const [count, setCount] = useState(1);
|
|
1062
990
|
const [info, setInfo] = useState({});
|
|
@@ -1064,20 +992,21 @@ var SpaceGenerator = ({ space, onCreateObjects }) => {
|
|
|
1064
992
|
const typeMap = useMemo(() => {
|
|
1065
993
|
client.addTypes([
|
|
1066
994
|
...staticTypes,
|
|
995
|
+
...recordTypes,
|
|
1067
996
|
...presets.schemas
|
|
1068
997
|
]);
|
|
1069
|
-
const
|
|
998
|
+
const recordGenerators = new Map(recordTypes.map((type) => [
|
|
1070
999
|
type.typename,
|
|
1071
|
-
createGenerator(type)
|
|
1000
|
+
createGenerator(client, dispatch, type)
|
|
1072
1001
|
]));
|
|
1073
1002
|
return new Map([
|
|
1074
1003
|
...staticGenerators,
|
|
1075
1004
|
...presets.items,
|
|
1076
|
-
...
|
|
1005
|
+
...recordGenerators
|
|
1077
1006
|
]);
|
|
1078
1007
|
}, [
|
|
1079
1008
|
client,
|
|
1080
|
-
|
|
1009
|
+
recordTypes
|
|
1081
1010
|
]);
|
|
1082
1011
|
const updateInfo = async () => {
|
|
1083
1012
|
const echoSchema = await space.db.schemaRegistry.query().run();
|
|
@@ -1112,67 +1041,6 @@ var SpaceGenerator = ({ space, onCreateObjects }) => {
|
|
|
1112
1041
|
typeMap,
|
|
1113
1042
|
count
|
|
1114
1043
|
]);
|
|
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
1044
|
return /* @__PURE__ */ React2.createElement("div", {
|
|
1177
1045
|
role: "none",
|
|
1178
1046
|
className: "flex flex-col grow overflow-hidden"
|
|
@@ -1183,11 +1051,6 @@ var SpaceGenerator = ({ space, onCreateObjects }) => {
|
|
|
1183
1051
|
iconOnly: true,
|
|
1184
1052
|
label: "Refresh",
|
|
1185
1053
|
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
1054
|
}), /* @__PURE__ */ React2.createElement(Toolbar.Separator, {
|
|
1192
1055
|
variant: "gap"
|
|
1193
1056
|
}), /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
@@ -1207,9 +1070,9 @@ var SpaceGenerator = ({ space, onCreateObjects }) => {
|
|
|
1207
1070
|
label: "Static Types",
|
|
1208
1071
|
onClick: handleCreateData
|
|
1209
1072
|
}), /* @__PURE__ */ React2.createElement(SchemaTable, {
|
|
1210
|
-
types:
|
|
1073
|
+
types: recordTypes,
|
|
1211
1074
|
objects: info.objects,
|
|
1212
|
-
label: "
|
|
1075
|
+
label: "Record Types",
|
|
1213
1076
|
onClick: handleCreateData
|
|
1214
1077
|
}), /* @__PURE__ */ React2.createElement(SchemaTable, {
|
|
1215
1078
|
types: presets.types,
|
|
@@ -1217,8 +1080,8 @@ var SpaceGenerator = ({ space, onCreateObjects }) => {
|
|
|
1217
1080
|
label: "Presets",
|
|
1218
1081
|
onClick: handleCreateData
|
|
1219
1082
|
}), /* @__PURE__ */ React2.createElement("div", null, /* @__PURE__ */ React2.createElement(SyntaxHighlighter, {
|
|
1220
|
-
|
|
1221
|
-
|
|
1083
|
+
language: "json",
|
|
1084
|
+
classNames: "text-xs"
|
|
1222
1085
|
}, JSON.stringify({
|
|
1223
1086
|
space,
|
|
1224
1087
|
...info
|
|
@@ -1230,9 +1093,9 @@ var SpaceGenerator = ({ space, onCreateObjects }) => {
|
|
|
1230
1093
|
}
|
|
1231
1094
|
};
|
|
1232
1095
|
|
|
1233
|
-
//
|
|
1096
|
+
// src/components/SpaceGenerator/index.ts
|
|
1234
1097
|
var SpaceGenerator_default = SpaceGenerator;
|
|
1235
1098
|
export {
|
|
1236
1099
|
SpaceGenerator_default as default
|
|
1237
1100
|
};
|
|
1238
|
-
//# sourceMappingURL=SpaceGenerator-
|
|
1101
|
+
//# sourceMappingURL=SpaceGenerator-SRCIEELZ.mjs.map
|