@dxos/plugin-debug 0.8.3 → 0.8.4-main.1da679c
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-SB2YRVRT.mjs} +376 -494
- package/dist/lib/browser/SpaceGenerator-SB2YRVRT.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-6HHJMKVU.mjs → app-graph-builder-7ODCSP7R.mjs} +27 -37
- package/dist/lib/browser/app-graph-builder-7ODCSP7R.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-Y537DXK5.mjs} +5 -5
- package/dist/lib/browser/{react-context-ZQRD2WG2.mjs.map → react-context-Y537DXK5.mjs.map} +1 -1
- package/dist/lib/browser/{react-surface-UI6OK73H.mjs → react-surface-OP75RFNI.mjs} +45 -40
- package/dist/lib/browser/react-surface-OP75RFNI.mjs.map +7 -0
- package/dist/lib/browser/{settings-SXQWSIM4.mjs → settings-XAUQOU7I.mjs} +6 -6
- package/dist/lib/browser/{settings-SXQWSIM4.mjs.map → settings-XAUQOU7I.mjs.map} +1 -1
- 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 +61 -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 +346 -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
|
@@ -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,60 +196,32 @@ var staticGenerators = /* @__PURE__ */ new Map([
|
|
|
202
196
|
]
|
|
203
197
|
]);
|
|
204
198
|
|
|
205
|
-
//
|
|
206
|
-
import {
|
|
207
|
-
import
|
|
208
|
-
import {
|
|
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 { RESEARCH_BLUEPRINT, ResearchOn, agent } from "@dxos/assistant-testing";
|
|
202
|
+
import { Prompt } from "@dxos/blueprints";
|
|
237
203
|
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,
|
|
204
|
+
import { DXN as DXN2, Filter as Filter2, Key as Key2, Obj as Obj2, Query, Ref as Ref2, Relation, Type as Type2 } from "@dxos/echo";
|
|
205
|
+
import { FunctionTrigger, serializeFunction } from "@dxos/functions";
|
|
240
206
|
import { invariant } from "@dxos/invariant";
|
|
241
|
-
import {
|
|
242
|
-
import {
|
|
207
|
+
import { Mailbox } from "@dxos/plugin-inbox/types";
|
|
208
|
+
import { Markdown as Markdown2 } from "@dxos/plugin-markdown/types";
|
|
209
|
+
import { createAppend, createChat, createComputeGraph, createConstant, createFunction, createGpt, createQueue, createRandom, createSurface, createTemplate, createText, createTrigger } from "@dxos/react-ui-canvas-compute";
|
|
243
210
|
import { CanvasBoardType, CanvasGraphModel, pointMultiply, pointsToRect, rectToPoints } from "@dxos/react-ui-canvas-editor";
|
|
244
|
-
import {
|
|
211
|
+
import { DataType as DataType2, createView } from "@dxos/schema";
|
|
245
212
|
import { range as range2 } from "@dxos/util";
|
|
246
|
-
var __dxlog_file = "/
|
|
247
|
-
var PresetName = /* @__PURE__ */ function(PresetName2) {
|
|
248
|
-
PresetName2["
|
|
213
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-debug/src/components/SpaceGenerator/presets.ts";
|
|
214
|
+
var PresetName = /* @__PURE__ */ (function(PresetName2) {
|
|
215
|
+
PresetName2["DXOS_TEAM"] = "dxos-team";
|
|
216
|
+
PresetName2["ORG_RESEARCH_PROJECT"] = "org-research-project";
|
|
249
217
|
PresetName2["GPT_QUEUE"] = "webhook-gpt-queue";
|
|
250
218
|
PresetName2["CHAT_GPT"] = "chat-gpt-text";
|
|
251
|
-
PresetName2["EMAIL_WITH_SUMMARY"] = "email-gptSummary-table";
|
|
252
219
|
PresetName2["OBJECT_CHANGE_QUEUE"] = "objectChange-queue";
|
|
253
220
|
PresetName2["FOREX_FUNCTION_CALL"] = "forex-function-call";
|
|
254
221
|
PresetName2["TIMER_TICK_QUEUE"] = "timerTick-queue";
|
|
255
222
|
PresetName2["DISCORD_MESSAGES"] = "discord-messages";
|
|
256
|
-
PresetName2["KANBAN_QUEUE"] = "kanban-queue";
|
|
257
223
|
return PresetName2;
|
|
258
|
-
}({});
|
|
224
|
+
})({});
|
|
259
225
|
var generator2 = () => ({
|
|
260
226
|
schemas: [
|
|
261
227
|
CanvasBoardType,
|
|
@@ -265,6 +231,141 @@ var generator2 = () => ({
|
|
|
265
231
|
typename: name
|
|
266
232
|
})),
|
|
267
233
|
items: [
|
|
234
|
+
[
|
|
235
|
+
"dxos-team",
|
|
236
|
+
async (space, n, cb) => {
|
|
237
|
+
const objects = range2(n, () => {
|
|
238
|
+
const org = space.db.add(Obj2.make(DataType2.Organization, {
|
|
239
|
+
name: "DXOS",
|
|
240
|
+
website: "https://dxos.org"
|
|
241
|
+
}));
|
|
242
|
+
const doc = space.db.add(Markdown2.makeDocument({
|
|
243
|
+
name: "DXOS Research",
|
|
244
|
+
content: "DXOS builds Composer, an open-source AI-powered malleable application."
|
|
245
|
+
}));
|
|
246
|
+
space.db.add(Relation.make(ResearchOn, {
|
|
247
|
+
[Relation.Source]: doc,
|
|
248
|
+
[Relation.Target]: org,
|
|
249
|
+
completedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
250
|
+
}));
|
|
251
|
+
space.db.add(Obj2.make(DataType2.Person, {
|
|
252
|
+
fullName: "Rich",
|
|
253
|
+
jobTitle: "investor",
|
|
254
|
+
organization: Ref2.make(org)
|
|
255
|
+
}));
|
|
256
|
+
space.db.add(Obj2.make(DataType2.Person, {
|
|
257
|
+
fullName: "Josiah",
|
|
258
|
+
organization: Ref2.make(org)
|
|
259
|
+
}));
|
|
260
|
+
space.db.add(Obj2.make(DataType2.Person, {
|
|
261
|
+
fullName: "Dima",
|
|
262
|
+
organization: Ref2.make(org)
|
|
263
|
+
}));
|
|
264
|
+
space.db.add(Obj2.make(DataType2.Person, {
|
|
265
|
+
fullName: "Mykola",
|
|
266
|
+
organization: Ref2.make(org)
|
|
267
|
+
}));
|
|
268
|
+
space.db.add(Obj2.make(DataType2.Person, {
|
|
269
|
+
fullName: "Will",
|
|
270
|
+
organization: Ref2.make(org)
|
|
271
|
+
}));
|
|
272
|
+
return doc;
|
|
273
|
+
});
|
|
274
|
+
cb?.(objects);
|
|
275
|
+
return objects;
|
|
276
|
+
}
|
|
277
|
+
],
|
|
278
|
+
[
|
|
279
|
+
"org-research-project",
|
|
280
|
+
async (space, n, cb) => {
|
|
281
|
+
const mailbox = await space.db.query(Filter2.type(Mailbox.Mailbox)).first();
|
|
282
|
+
const objects = range2(n, () => {
|
|
283
|
+
const contactsQuery = Query.select(Filter2.type(DataType2.Person, {
|
|
284
|
+
jobTitle: "investor"
|
|
285
|
+
}));
|
|
286
|
+
const organizationsQuery = contactsQuery.reference("organization");
|
|
287
|
+
const notesQuery = organizationsQuery.targetOf(ResearchOn).source();
|
|
288
|
+
const researchPrompt = space.db.add(Prompt.make({
|
|
289
|
+
name: "Research",
|
|
290
|
+
description: "Research organization",
|
|
291
|
+
input: Schema.Struct({
|
|
292
|
+
org: Schema.Any
|
|
293
|
+
}),
|
|
294
|
+
output: Schema.Any,
|
|
295
|
+
// TODO(dmaretskyi): This mocks research (returns pre-baked result), the actual research might take compute minutes.
|
|
296
|
+
// Remove the mock prompt to do the actual research.
|
|
297
|
+
instructions: "Research the organization provided as input. Create a research note for it at the end. NOTE: Do mocked reseach (set mockSearch to true).",
|
|
298
|
+
blueprints: [
|
|
299
|
+
Ref2.make(RESEARCH_BLUEPRINT)
|
|
300
|
+
]
|
|
301
|
+
}));
|
|
302
|
+
const researchTrigger = Obj2.make(FunctionTrigger, {
|
|
303
|
+
enabled: true,
|
|
304
|
+
spec: {
|
|
305
|
+
kind: "subscription",
|
|
306
|
+
query: organizationsQuery.ast
|
|
307
|
+
},
|
|
308
|
+
function: Ref2.make(serializeFunction(agent)),
|
|
309
|
+
input: {
|
|
310
|
+
prompt: Ref2.make(researchPrompt),
|
|
311
|
+
input: "{{event.subject}}"
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
space.db.add(researchTrigger);
|
|
315
|
+
const mailboxView = createView({
|
|
316
|
+
name: "Mailbox",
|
|
317
|
+
query: Query.select(Filter2.type(DataType2.Message, {
|
|
318
|
+
properties: {
|
|
319
|
+
labels: Filter2.contains("investor")
|
|
320
|
+
}
|
|
321
|
+
})).options({
|
|
322
|
+
queues: [
|
|
323
|
+
mailbox.queue.dxn.toString()
|
|
324
|
+
]
|
|
325
|
+
}),
|
|
326
|
+
jsonSchema: Type2.toJsonSchema(DataType2.Message),
|
|
327
|
+
presentation: Obj2.make(DataType2.Collection, {
|
|
328
|
+
objects: []
|
|
329
|
+
})
|
|
330
|
+
});
|
|
331
|
+
const contactsView = createView({
|
|
332
|
+
name: "Contacts",
|
|
333
|
+
query: contactsQuery,
|
|
334
|
+
jsonSchema: Type2.toJsonSchema(DataType2.Person),
|
|
335
|
+
presentation: Obj2.make(DataType2.Collection, {
|
|
336
|
+
objects: []
|
|
337
|
+
})
|
|
338
|
+
});
|
|
339
|
+
const organizationsView = createView({
|
|
340
|
+
name: "Organizations",
|
|
341
|
+
query: organizationsQuery,
|
|
342
|
+
jsonSchema: Type2.toJsonSchema(DataType2.Organization),
|
|
343
|
+
presentation: Obj2.make(DataType2.Collection, {
|
|
344
|
+
objects: []
|
|
345
|
+
})
|
|
346
|
+
});
|
|
347
|
+
const notesView = createView({
|
|
348
|
+
name: "Notes",
|
|
349
|
+
query: notesQuery,
|
|
350
|
+
jsonSchema: Type2.toJsonSchema(Markdown2.Document),
|
|
351
|
+
presentation: Obj2.make(DataType2.Collection, {
|
|
352
|
+
objects: []
|
|
353
|
+
})
|
|
354
|
+
});
|
|
355
|
+
return space.db.add(DataType2.makeProject({
|
|
356
|
+
name: "Investor Research",
|
|
357
|
+
collections: [
|
|
358
|
+
mailboxView,
|
|
359
|
+
contactsView,
|
|
360
|
+
organizationsView,
|
|
361
|
+
notesView
|
|
362
|
+
].map((view) => Ref2.make(view))
|
|
363
|
+
}));
|
|
364
|
+
});
|
|
365
|
+
cb?.(objects.flat());
|
|
366
|
+
return objects.flat();
|
|
367
|
+
}
|
|
368
|
+
],
|
|
268
369
|
[
|
|
269
370
|
"webhook-gpt-queue",
|
|
270
371
|
async (space, n, cb) => {
|
|
@@ -278,7 +379,7 @@ var generator2 = () => ({
|
|
|
278
379
|
})));
|
|
279
380
|
const triggerShape = createTrigger({
|
|
280
381
|
spaceId: space.id,
|
|
281
|
-
triggerKind:
|
|
382
|
+
triggerKind: "webhook",
|
|
282
383
|
...position({
|
|
283
384
|
x: -18,
|
|
284
385
|
y: -2
|
|
@@ -329,9 +430,7 @@ var generator2 = () => ({
|
|
|
329
430
|
"objectChange-queue",
|
|
330
431
|
async (space, n, cb) => {
|
|
331
432
|
const objects = range2(n, () => {
|
|
332
|
-
const { canvasModel, computeModel } = createQueueSinkPreset(space,
|
|
333
|
-
type: "dxn:type:dxos.org/type/Chess"
|
|
334
|
-
}, "type");
|
|
433
|
+
const { canvasModel, computeModel } = createQueueSinkPreset(space, "subscription", (triggerSpec) => triggerSpec.query = Query.select(Filter2.typename("dxos.org/type/Chess")).ast, "type");
|
|
335
434
|
return addToSpace("objectChange-queue", space, canvasModel, computeModel);
|
|
336
435
|
});
|
|
337
436
|
cb?.(objects);
|
|
@@ -342,108 +441,68 @@ var generator2 = () => ({
|
|
|
342
441
|
"timerTick-queue",
|
|
343
442
|
async (space, n, cb) => {
|
|
344
443
|
const objects = range2(n, () => {
|
|
345
|
-
const { canvasModel, computeModel } = createQueueSinkPreset(space,
|
|
444
|
+
const { canvasModel, computeModel } = createQueueSinkPreset(space, "timer", (triggerSpec) => triggerSpec.cron = "*/5 * * * * *", "result");
|
|
346
445
|
return addToSpace("timerTick-queue", space, canvasModel, computeModel);
|
|
347
446
|
});
|
|
348
447
|
cb?.(objects);
|
|
349
448
|
return objects;
|
|
350
449
|
}
|
|
351
450
|
],
|
|
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
|
-
],
|
|
451
|
+
// TODO(wittjosiah): Remove?
|
|
452
|
+
// [
|
|
453
|
+
// PresetName.EMAIL_TABLE,
|
|
454
|
+
// async (space, n, cb) => {
|
|
455
|
+
// const objects = range(n, () => {
|
|
456
|
+
// const canvasModel = CanvasGraphModel.create<ComputeShape>();
|
|
457
|
+
// const results = space.db.query(Filter.type(TableType)).runSync();
|
|
458
|
+
// const emailTable = results.find((r) => r.object?.view?.target?.query?.typename?.endsWith('Email'));
|
|
459
|
+
// invariant(emailTable, 'Email table not found.');
|
|
460
|
+
// const template = canvasModel.createNode(
|
|
461
|
+
// createTemplate({
|
|
462
|
+
// valueType: 'object',
|
|
463
|
+
// ...rawPosition({ centerX: -80, centerY: -64, width: 320, height: 320 }),
|
|
464
|
+
// }),
|
|
465
|
+
// );
|
|
466
|
+
// const templateContent = ['{'];
|
|
467
|
+
// let functionTrigger: FunctionTrigger | undefined;
|
|
468
|
+
// canvasModel.builder.call((builder) => {
|
|
469
|
+
// const triggerShape = createTrigger({
|
|
470
|
+
// spaceId: space.id,
|
|
471
|
+
// triggerKind: 'email',
|
|
472
|
+
// ...position({ x: -18, y: -2 }),
|
|
473
|
+
// });
|
|
474
|
+
// const trigger = canvasModel.createNode(triggerShape);
|
|
475
|
+
// const tableId = canvasModel.createNode(
|
|
476
|
+
// createConstant({
|
|
477
|
+
// value: DXN.fromLocalObjectId(emailTable.id).toString(),
|
|
478
|
+
// ...position({ x: -18, y: 5, width: 8, height: 6 }),
|
|
479
|
+
// }),
|
|
480
|
+
// );
|
|
481
|
+
// const appendToTable = canvasModel.createNode(createAppend(position({ x: 10, y: 6 })));
|
|
482
|
+
// const properties = SchemaAST.getPropertySignatures(EmailTriggerOutput.ast);
|
|
483
|
+
// for (let i = 0; i < properties.length; i++) {
|
|
484
|
+
// const propName = properties[i].name.toString();
|
|
485
|
+
// builder.createEdge({ source: trigger.id, target: template.id, input: propName, output: propName });
|
|
486
|
+
// templateContent.push(` "${propName}": "{{${propName}}}"` + (i === properties.length - 1 ? '' : ','));
|
|
487
|
+
// }
|
|
488
|
+
// templateContent.push('}');
|
|
489
|
+
// builder
|
|
490
|
+
// .createEdge({ source: tableId.id, target: appendToTable.id, input: 'id' })
|
|
491
|
+
// .createEdge({ source: template.id, target: appendToTable.id, input: 'items' });
|
|
492
|
+
// functionTrigger = triggerShape.functionTrigger!.target!;
|
|
493
|
+
// });
|
|
494
|
+
// const computeModel = createComputeGraph(canvasModel);
|
|
495
|
+
// const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
|
|
496
|
+
// invariant(templateComputeNode, 'Template compute node was not created.');
|
|
497
|
+
// templateComputeNode.value = templateContent.join('\n');
|
|
498
|
+
// templateComputeNode.inputSchema = Type.toJsonSchema(EmailTriggerOutput);
|
|
499
|
+
// attachTrigger(functionTrigger, computeModel);
|
|
500
|
+
// return addToSpace(PresetName.EMAIL_TABLE, space, canvasModel, computeModel);
|
|
501
|
+
// });
|
|
502
|
+
// cb?.(objects);
|
|
503
|
+
// return objects;
|
|
504
|
+
// },
|
|
505
|
+
// ],
|
|
447
506
|
[
|
|
448
507
|
"chat-gpt-text",
|
|
449
508
|
async (space, n, cb) => {
|
|
@@ -495,168 +554,86 @@ var generator2 = () => ({
|
|
|
495
554
|
return objects;
|
|
496
555
|
}
|
|
497
556
|
],
|
|
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
|
-
],
|
|
557
|
+
// TODO(wittjosiah): Remove?
|
|
558
|
+
// [
|
|
559
|
+
// PresetName.EMAIL_WITH_SUMMARY,
|
|
560
|
+
// async (space, n, cb) => {
|
|
561
|
+
// const objects = range(n, () => {
|
|
562
|
+
// const canvasModel = CanvasGraphModel.create<ComputeShape>();
|
|
563
|
+
// const results = space.db.query(Filter.type(TableType)).runSync();
|
|
564
|
+
// const emailTable = results.find((r) => r.object?.view?.target?.query?.typename?.endsWith('Email'));
|
|
565
|
+
// invariant(emailTable, 'Email table not found.');
|
|
566
|
+
// const template = canvasModel.createNode(
|
|
567
|
+
// createTemplate({
|
|
568
|
+
// valueType: 'object',
|
|
569
|
+
// ...rawPosition({ centerX: 192, centerY: -176, width: 320, height: 320 }),
|
|
570
|
+
// }),
|
|
571
|
+
// );
|
|
572
|
+
// const templateContent = ['{'];
|
|
573
|
+
// let functionTrigger: FunctionTrigger | undefined;
|
|
574
|
+
// canvasModel.builder.call((builder) => {
|
|
575
|
+
// const gpt = canvasModel.createNode(
|
|
576
|
+
// createGpt(rawPosition({ centerX: -400, centerY: -112, width: 256, height: 202 })),
|
|
577
|
+
// );
|
|
578
|
+
// const systemPrompt = canvasModel.createNode(
|
|
579
|
+
// createConstant({
|
|
580
|
+
// value: "use one word to describe content category. don't write anything else",
|
|
581
|
+
// ...rawPosition({ centerX: -800, centerY: -160, width: 192, height: 128 }),
|
|
582
|
+
// }),
|
|
583
|
+
// );
|
|
584
|
+
// const triggerShape = createTrigger({
|
|
585
|
+
// spaceId: space.id,
|
|
586
|
+
// triggerKind: 'email',
|
|
587
|
+
// ...rawPosition({ centerX: -736, centerY: -384, width: 182, height: 192 }),
|
|
588
|
+
// });
|
|
589
|
+
// const trigger = canvasModel.createNode(triggerShape);
|
|
590
|
+
// const { queueId } = setupQueue(space, canvasModel, {
|
|
591
|
+
// idPosition: { centerX: -720, centerY: 224, width: 192, height: 256 },
|
|
592
|
+
// queuePosition: { centerX: -144, centerY: 416, width: 320, height: 448 },
|
|
593
|
+
// });
|
|
594
|
+
// const appendToQueue = canvasModel.createNode(
|
|
595
|
+
// createAppend(rawPosition({ centerX: -80, centerY: 96, width: 122, height: 128 })),
|
|
596
|
+
// );
|
|
597
|
+
// const tableId = canvasModel.createNode(
|
|
598
|
+
// createConstant({
|
|
599
|
+
// value: DXN.fromLocalObjectId(emailTable.id).toString(),
|
|
600
|
+
// ...rawPosition({ centerX: -112, centerY: -544, width: 192, height: 256 }),
|
|
601
|
+
// }),
|
|
602
|
+
// );
|
|
603
|
+
// const appendToTable = canvasModel.createNode(
|
|
604
|
+
// createAppend(rawPosition({ centerX: 560, centerY: -416, width: 128, height: 122 })),
|
|
605
|
+
// );
|
|
606
|
+
// templateContent.push(' "category": "{{text}}",');
|
|
607
|
+
// builder.createEdge({ source: gpt.id, target: template.id, input: 'text', output: 'text' });
|
|
608
|
+
// const properties = SchemaAST.getPropertySignatures(EmailTriggerOutput.ast);
|
|
609
|
+
// for (let i = 0; i < properties.length; i++) {
|
|
610
|
+
// const propName = properties[i].name.toString();
|
|
611
|
+
// builder.createEdge({ source: trigger.id, target: template.id, input: propName, output: propName });
|
|
612
|
+
// templateContent.push(` "${propName}": "{{${propName}}}"` + (i === properties.length - 1 ? '' : ','));
|
|
613
|
+
// }
|
|
614
|
+
// templateContent.push('}');
|
|
615
|
+
// builder
|
|
616
|
+
// .createEdge({ source: tableId.id, target: appendToTable.id, input: 'id' })
|
|
617
|
+
// .createEdge({ source: queueId.id, target: appendToQueue.id, input: 'id' })
|
|
618
|
+
// .createEdge({ source: gpt.id, target: appendToQueue.id, output: 'messages', input: 'items' })
|
|
619
|
+
// .createEdge({ source: systemPrompt.id, target: gpt.id, input: 'systemPrompt' })
|
|
620
|
+
// .createEdge({ source: trigger.id, target: gpt.id, input: 'prompt', output: 'body' })
|
|
621
|
+
// .createEdge({ source: template.id, target: appendToTable.id, input: 'items' });
|
|
622
|
+
// functionTrigger = triggerShape.functionTrigger!.target!;
|
|
623
|
+
// });
|
|
624
|
+
// const computeModel = createComputeGraph(canvasModel);
|
|
625
|
+
// const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
|
|
626
|
+
// invariant(templateComputeNode, 'Template compute node was not created.');
|
|
627
|
+
// templateComputeNode.value = templateContent.join('\n');
|
|
628
|
+
// const extendedSchema = Schema.extend(EmailTriggerOutput, Schema.Struct({ text: Schema.String }));
|
|
629
|
+
// templateComputeNode.inputSchema = Type.toJsonSchema(extendedSchema);
|
|
630
|
+
// attachTrigger(functionTrigger, computeModel);
|
|
631
|
+
// return addToSpace(PresetName.EMAIL_WITH_SUMMARY, space, canvasModel, computeModel);
|
|
632
|
+
// });
|
|
633
|
+
// cb?.(objects);
|
|
634
|
+
// return objects;
|
|
635
|
+
// },
|
|
636
|
+
// ],
|
|
660
637
|
[
|
|
661
638
|
"forex-function-call",
|
|
662
639
|
async (space, n, cb) => {
|
|
@@ -715,7 +692,7 @@ var generator2 = () => ({
|
|
|
715
692
|
canvasModel.builder.call((builder) => {
|
|
716
693
|
const triggerShape = createTrigger({
|
|
717
694
|
spaceId: space.id,
|
|
718
|
-
triggerKind:
|
|
695
|
+
triggerKind: "timer",
|
|
719
696
|
...position({
|
|
720
697
|
x: -10,
|
|
721
698
|
y: -5
|
|
@@ -782,64 +759,6 @@ var generator2 = () => ({
|
|
|
782
759
|
cb?.(objects);
|
|
783
760
|
return objects;
|
|
784
761
|
}
|
|
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
762
|
]
|
|
844
763
|
]
|
|
845
764
|
});
|
|
@@ -909,7 +828,7 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
|
|
|
909
828
|
const triggerSpec = functionTrigger.spec;
|
|
910
829
|
invariant(triggerSpec && triggerSpec.kind === triggerKind, "No trigger spec.", {
|
|
911
830
|
F: __dxlog_file,
|
|
912
|
-
L:
|
|
831
|
+
L: 619,
|
|
913
832
|
S: void 0,
|
|
914
833
|
A: [
|
|
915
834
|
"triggerSpec && triggerSpec.kind === triggerKind",
|
|
@@ -922,7 +841,7 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
|
|
|
922
841
|
const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
|
|
923
842
|
invariant(templateComputeNode, "Template compute node was not created.", {
|
|
924
843
|
F: __dxlog_file,
|
|
925
|
-
L:
|
|
844
|
+
L: 626,
|
|
926
845
|
S: void 0,
|
|
927
846
|
A: [
|
|
928
847
|
"templateComputeNode",
|
|
@@ -935,7 +854,7 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
|
|
|
935
854
|
' "id": "@{{changeId}}"',
|
|
936
855
|
"}"
|
|
937
856
|
].join("\n");
|
|
938
|
-
templateComputeNode.inputSchema =
|
|
857
|
+
templateComputeNode.inputSchema = Type2.toJsonSchema(Schema.Struct({
|
|
939
858
|
type: Schema.String,
|
|
940
859
|
changeId: Schema.String
|
|
941
860
|
}));
|
|
@@ -984,7 +903,7 @@ var setupQueue = (space, canvasModel, args) => {
|
|
|
984
903
|
var attachTrigger = (functionTrigger, computeModel) => {
|
|
985
904
|
invariant(functionTrigger, void 0, {
|
|
986
905
|
F: __dxlog_file,
|
|
987
|
-
L:
|
|
906
|
+
L: 665,
|
|
988
907
|
S: void 0,
|
|
989
908
|
A: [
|
|
990
909
|
"functionTrigger",
|
|
@@ -1039,24 +958,52 @@ var position = (rect) => {
|
|
|
1039
958
|
}
|
|
1040
959
|
};
|
|
1041
960
|
|
|
1042
|
-
//
|
|
1043
|
-
|
|
961
|
+
// src/components/SpaceGenerator/SchemaTable.tsx
|
|
962
|
+
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
963
|
+
import React from "react";
|
|
964
|
+
import { IconButton } from "@dxos/react-ui";
|
|
965
|
+
var SchemaTable = ({ types, objects = {}, label, onClick }) => {
|
|
966
|
+
var _effect = _useSignals();
|
|
967
|
+
try {
|
|
968
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
969
|
+
className: "grid grid-cols-[1fr_80px_40px] gap-1 overflow-none"
|
|
970
|
+
}, /* @__PURE__ */ React.createElement("h2", {
|
|
971
|
+
className: "p-2"
|
|
972
|
+
}, label), types.map((type) => /* @__PURE__ */ React.createElement("div", {
|
|
973
|
+
key: type.typename,
|
|
974
|
+
className: "grid grid-cols-subgrid col-span-3 items-center"
|
|
975
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
976
|
+
className: "px-2 text-sm font-mono text-subdued"
|
|
977
|
+
}, type.typename), /* @__PURE__ */ React.createElement("div", {
|
|
978
|
+
className: "px-2 text-right font-mono"
|
|
979
|
+
}, objects[type.typename] ?? 0), /* @__PURE__ */ React.createElement(IconButton, {
|
|
980
|
+
variant: "ghost",
|
|
981
|
+
icon: "ph--plus--regular",
|
|
982
|
+
iconOnly: true,
|
|
983
|
+
label: "Create data",
|
|
984
|
+
onClick: () => onClick(type.typename)
|
|
985
|
+
}))));
|
|
986
|
+
} finally {
|
|
987
|
+
_effect.f();
|
|
988
|
+
}
|
|
989
|
+
};
|
|
990
|
+
|
|
991
|
+
// src/components/SpaceGenerator/SpaceGenerator.tsx
|
|
1044
992
|
var SpaceGenerator = ({ space, onCreateObjects }) => {
|
|
1045
993
|
var _effect = _useSignals2();
|
|
1046
994
|
try {
|
|
1047
995
|
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
1048
996
|
const client = useClient();
|
|
1049
997
|
const staticTypes = [
|
|
1050
|
-
|
|
998
|
+
Markdown3.Document,
|
|
1051
999
|
DiagramType2,
|
|
1052
1000
|
SheetType2,
|
|
1053
1001
|
ComputeGraph2
|
|
1054
1002
|
];
|
|
1055
|
-
const
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
DataType2.Message
|
|
1003
|
+
const recordTypes = [
|
|
1004
|
+
DataType3.Organization,
|
|
1005
|
+
DataType3.Person,
|
|
1006
|
+
DataType3.Task
|
|
1060
1007
|
];
|
|
1061
1008
|
const [count, setCount] = useState(1);
|
|
1062
1009
|
const [info, setInfo] = useState({});
|
|
@@ -1064,20 +1011,21 @@ var SpaceGenerator = ({ space, onCreateObjects }) => {
|
|
|
1064
1011
|
const typeMap = useMemo(() => {
|
|
1065
1012
|
client.addTypes([
|
|
1066
1013
|
...staticTypes,
|
|
1014
|
+
...recordTypes,
|
|
1067
1015
|
...presets.schemas
|
|
1068
1016
|
]);
|
|
1069
|
-
const
|
|
1017
|
+
const recordGenerators = new Map(recordTypes.map((type) => [
|
|
1070
1018
|
type.typename,
|
|
1071
|
-
createGenerator(type)
|
|
1019
|
+
createGenerator(client, dispatch, type)
|
|
1072
1020
|
]));
|
|
1073
1021
|
return new Map([
|
|
1074
1022
|
...staticGenerators,
|
|
1075
1023
|
...presets.items,
|
|
1076
|
-
...
|
|
1024
|
+
...recordGenerators
|
|
1077
1025
|
]);
|
|
1078
1026
|
}, [
|
|
1079
1027
|
client,
|
|
1080
|
-
|
|
1028
|
+
recordTypes
|
|
1081
1029
|
]);
|
|
1082
1030
|
const updateInfo = async () => {
|
|
1083
1031
|
const echoSchema = await space.db.schemaRegistry.query().run();
|
|
@@ -1112,67 +1060,6 @@ var SpaceGenerator = ({ space, onCreateObjects }) => {
|
|
|
1112
1060
|
typeMap,
|
|
1113
1061
|
count
|
|
1114
1062
|
]);
|
|
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
1063
|
return /* @__PURE__ */ React2.createElement("div", {
|
|
1177
1064
|
role: "none",
|
|
1178
1065
|
className: "flex flex-col grow overflow-hidden"
|
|
@@ -1183,11 +1070,6 @@ var SpaceGenerator = ({ space, onCreateObjects }) => {
|
|
|
1183
1070
|
iconOnly: true,
|
|
1184
1071
|
label: "Refresh",
|
|
1185
1072
|
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
1073
|
}), /* @__PURE__ */ React2.createElement(Toolbar.Separator, {
|
|
1192
1074
|
variant: "gap"
|
|
1193
1075
|
}), /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
@@ -1207,9 +1089,9 @@ var SpaceGenerator = ({ space, onCreateObjects }) => {
|
|
|
1207
1089
|
label: "Static Types",
|
|
1208
1090
|
onClick: handleCreateData
|
|
1209
1091
|
}), /* @__PURE__ */ React2.createElement(SchemaTable, {
|
|
1210
|
-
types:
|
|
1092
|
+
types: recordTypes,
|
|
1211
1093
|
objects: info.objects,
|
|
1212
|
-
label: "
|
|
1094
|
+
label: "Record Types",
|
|
1213
1095
|
onClick: handleCreateData
|
|
1214
1096
|
}), /* @__PURE__ */ React2.createElement(SchemaTable, {
|
|
1215
1097
|
types: presets.types,
|
|
@@ -1217,8 +1099,8 @@ var SpaceGenerator = ({ space, onCreateObjects }) => {
|
|
|
1217
1099
|
label: "Presets",
|
|
1218
1100
|
onClick: handleCreateData
|
|
1219
1101
|
}), /* @__PURE__ */ React2.createElement("div", null, /* @__PURE__ */ React2.createElement(SyntaxHighlighter, {
|
|
1220
|
-
|
|
1221
|
-
|
|
1102
|
+
language: "json",
|
|
1103
|
+
classNames: "text-xs"
|
|
1222
1104
|
}, JSON.stringify({
|
|
1223
1105
|
space,
|
|
1224
1106
|
...info
|
|
@@ -1230,9 +1112,9 @@ var SpaceGenerator = ({ space, onCreateObjects }) => {
|
|
|
1230
1112
|
}
|
|
1231
1113
|
};
|
|
1232
1114
|
|
|
1233
|
-
//
|
|
1115
|
+
// src/components/SpaceGenerator/index.ts
|
|
1234
1116
|
var SpaceGenerator_default = SpaceGenerator;
|
|
1235
1117
|
export {
|
|
1236
1118
|
SpaceGenerator_default as default
|
|
1237
1119
|
};
|
|
1238
|
-
//# sourceMappingURL=SpaceGenerator-
|
|
1120
|
+
//# sourceMappingURL=SpaceGenerator-SB2YRVRT.mjs.map
|