@dxos/plugin-debug 0.8.3 → 0.8.4-main.5acf9ea
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/{DebugApp-WSEJPCKY.mjs → DebugApp-ZDL4CPY5.mjs} +28 -25
- package/dist/lib/browser/DebugApp-ZDL4CPY5.mjs.map +7 -0
- package/dist/lib/browser/{DevtoolsOverviewContainer-IIIWO77Q.mjs → DevtoolsOverviewContainer-EPD6EWT5.mjs} +2 -2
- package/dist/lib/browser/{SpaceGenerator-VB6IB2LL.mjs → SpaceGenerator-6ZOCEREN.mjs} +192 -449
- package/dist/lib/browser/SpaceGenerator-6ZOCEREN.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-6HHJMKVU.mjs → app-graph-builder-SQXFD2BL.mjs} +4 -4
- 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 +12 -12
- 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-CHHHE5CF.mjs} +18 -18
- package/dist/lib/browser/react-surface-CHHHE5CF.mjs.map +7 -0
- package/dist/lib/browser/{settings-SXQWSIM4.mjs → settings-LSSWLM5I.mjs} +4 -4
- package/dist/types/src/components/DebugApp/DebugApp.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 +1 -1
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/presets.d.ts +1 -4
- package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +60 -60
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +58 -59
- package/src/DebugPlugin.tsx +1 -1
- package/src/capabilities/react-surface.tsx +2 -2
- package/src/components/DebugApp/DebugApp.tsx +19 -12
- package/src/components/SpaceGenerator/ObjectGenerator.tsx +29 -23
- package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +1 -1
- package/src/components/SpaceGenerator/SpaceGenerator.tsx +11 -68
- package/src/components/SpaceGenerator/presets.ts +216 -214
- package/src/translations.ts +6 -4
- package/dist/lib/browser/DebugApp-WSEJPCKY.mjs.map +0 -7
- package/dist/lib/browser/SpaceGenerator-VB6IB2LL.mjs.map +0 -7
- package/dist/lib/browser/react-surface-UI6OK73H.mjs.map +0 -7
- /package/dist/lib/browser/{DevtoolsOverviewContainer-IIIWO77Q.mjs.map → DevtoolsOverviewContainer-EPD6EWT5.mjs.map} +0 -0
- /package/dist/lib/browser/{app-graph-builder-6HHJMKVU.mjs.map → app-graph-builder-SQXFD2BL.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
|
|
7
|
-
import {
|
|
8
|
-
import { DocumentType as DocumentType2 } from "@dxos/plugin-markdown/types";
|
|
6
|
+
import { Filter as Filter2 } from "@dxos/echo";
|
|
7
|
+
import { Markdown as Markdown2 } 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 { initializeTable, TableType as TableType3 } from "@dxos/react-ui-table";
|
|
17
14
|
import { DataType as DataType2 } 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 } 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
|
|
32
|
+
var findViewByTypename = async (views, typename) => {
|
|
33
|
+
return views.find((view) => view.query.typename === typename);
|
|
34
|
+
};
|
|
35
|
+
var createGenerator = (client, dispatch, schema) => {
|
|
35
36
|
return async (space, n, cb) => {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const view = createView({
|
|
50
|
-
name,
|
|
51
|
-
typename: type.typename,
|
|
52
|
-
jsonSchema: schema.jsonSchema
|
|
53
|
-
});
|
|
54
|
-
space.db.add(Obj.make(TableType, {
|
|
55
|
-
name,
|
|
56
|
-
view: Ref.make(view)
|
|
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,7 +196,7 @@ var staticGenerators = /* @__PURE__ */ new Map([
|
|
|
202
196
|
]
|
|
203
197
|
]);
|
|
204
198
|
|
|
205
|
-
//
|
|
199
|
+
// src/components/SpaceGenerator/SchemaTable.tsx
|
|
206
200
|
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
207
201
|
import React from "react";
|
|
208
202
|
import { IconButton } from "@dxos/react-ui";
|
|
@@ -232,28 +226,23 @@ var SchemaTable = ({ types, objects = {}, label, onClick }) => {
|
|
|
232
226
|
}
|
|
233
227
|
};
|
|
234
228
|
|
|
235
|
-
//
|
|
236
|
-
import { Schema
|
|
229
|
+
// src/components/SpaceGenerator/presets.ts
|
|
230
|
+
import { Schema } from "effect";
|
|
237
231
|
import { NODE_INPUT as NODE_INPUT2 } from "@dxos/conductor";
|
|
238
|
-
import { DXN as DXN2, Key as Key2, Obj as Obj2, Ref as Ref2, Type } from "@dxos/echo";
|
|
239
|
-
import { FunctionTrigger, TriggerKind
|
|
232
|
+
import { DXN as DXN2, Key as Key2, Obj as Obj2, Ref as Ref2, Type as Type2 } from "@dxos/echo";
|
|
233
|
+
import { FunctionTrigger, TriggerKind } from "@dxos/functions";
|
|
240
234
|
import { invariant } from "@dxos/invariant";
|
|
241
|
-
import { Filter as Filter2 } from "@dxos/react-client/echo";
|
|
242
235
|
import { createAppend, createChat, createComputeGraph, createConstant, createFunction, createGpt, createQueue, createSurface, createRandom, createTemplate, createText, createTrigger } from "@dxos/react-ui-canvas-compute";
|
|
243
236
|
import { CanvasBoardType, CanvasGraphModel, pointMultiply, pointsToRect, rectToPoints } from "@dxos/react-ui-canvas-editor";
|
|
244
|
-
import { TableType as TableType2 } from "@dxos/react-ui-table";
|
|
245
237
|
import { range as range2 } from "@dxos/util";
|
|
246
|
-
var __dxlog_file = "/
|
|
238
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-debug/src/components/SpaceGenerator/presets.ts";
|
|
247
239
|
var PresetName = /* @__PURE__ */ function(PresetName2) {
|
|
248
|
-
PresetName2["EMAIL_TABLE"] = "email-table";
|
|
249
240
|
PresetName2["GPT_QUEUE"] = "webhook-gpt-queue";
|
|
250
241
|
PresetName2["CHAT_GPT"] = "chat-gpt-text";
|
|
251
|
-
PresetName2["EMAIL_WITH_SUMMARY"] = "email-gptSummary-table";
|
|
252
242
|
PresetName2["OBJECT_CHANGE_QUEUE"] = "objectChange-queue";
|
|
253
243
|
PresetName2["FOREX_FUNCTION_CALL"] = "forex-function-call";
|
|
254
244
|
PresetName2["TIMER_TICK_QUEUE"] = "timerTick-queue";
|
|
255
245
|
PresetName2["DISCORD_MESSAGES"] = "discord-messages";
|
|
256
|
-
PresetName2["KANBAN_QUEUE"] = "kanban-queue";
|
|
257
246
|
return PresetName2;
|
|
258
247
|
}({});
|
|
259
248
|
var generator2 = () => ({
|
|
@@ -349,101 +338,61 @@ var generator2 = () => ({
|
|
|
349
338
|
return objects;
|
|
350
339
|
}
|
|
351
340
|
],
|
|
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
|
-
],
|
|
341
|
+
// TODO(wittjosiah): Remove?
|
|
342
|
+
// [
|
|
343
|
+
// PresetName.EMAIL_TABLE,
|
|
344
|
+
// async (space, n, cb) => {
|
|
345
|
+
// const objects = range(n, () => {
|
|
346
|
+
// const canvasModel = CanvasGraphModel.create<ComputeShape>();
|
|
347
|
+
// const results = space.db.query(Filter.type(TableType)).runSync();
|
|
348
|
+
// const emailTable = results.find((r) => r.object?.view?.target?.query?.typename?.endsWith('Email'));
|
|
349
|
+
// invariant(emailTable, 'Email table not found.');
|
|
350
|
+
// const template = canvasModel.createNode(
|
|
351
|
+
// createTemplate({
|
|
352
|
+
// valueType: 'object',
|
|
353
|
+
// ...rawPosition({ centerX: -80, centerY: -64, width: 320, height: 320 }),
|
|
354
|
+
// }),
|
|
355
|
+
// );
|
|
356
|
+
// const templateContent = ['{'];
|
|
357
|
+
// let functionTrigger: FunctionTrigger | undefined;
|
|
358
|
+
// canvasModel.builder.call((builder) => {
|
|
359
|
+
// const triggerShape = createTrigger({
|
|
360
|
+
// spaceId: space.id,
|
|
361
|
+
// triggerKind: TriggerKind.Email,
|
|
362
|
+
// ...position({ x: -18, y: -2 }),
|
|
363
|
+
// });
|
|
364
|
+
// const trigger = canvasModel.createNode(triggerShape);
|
|
365
|
+
// const tableId = canvasModel.createNode(
|
|
366
|
+
// createConstant({
|
|
367
|
+
// value: DXN.fromLocalObjectId(emailTable.id).toString(),
|
|
368
|
+
// ...position({ x: -18, y: 5, width: 8, height: 6 }),
|
|
369
|
+
// }),
|
|
370
|
+
// );
|
|
371
|
+
// const appendToTable = canvasModel.createNode(createAppend(position({ x: 10, y: 6 })));
|
|
372
|
+
// const properties = SchemaAST.getPropertySignatures(EmailTriggerOutput.ast);
|
|
373
|
+
// for (let i = 0; i < properties.length; i++) {
|
|
374
|
+
// const propName = properties[i].name.toString();
|
|
375
|
+
// builder.createEdge({ source: trigger.id, target: template.id, input: propName, output: propName });
|
|
376
|
+
// templateContent.push(` "${propName}": "{{${propName}}}"` + (i === properties.length - 1 ? '' : ','));
|
|
377
|
+
// }
|
|
378
|
+
// templateContent.push('}');
|
|
379
|
+
// builder
|
|
380
|
+
// .createEdge({ source: tableId.id, target: appendToTable.id, input: 'id' })
|
|
381
|
+
// .createEdge({ source: template.id, target: appendToTable.id, input: 'items' });
|
|
382
|
+
// functionTrigger = triggerShape.functionTrigger!.target!;
|
|
383
|
+
// });
|
|
384
|
+
// const computeModel = createComputeGraph(canvasModel);
|
|
385
|
+
// const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
|
|
386
|
+
// invariant(templateComputeNode, 'Template compute node was not created.');
|
|
387
|
+
// templateComputeNode.value = templateContent.join('\n');
|
|
388
|
+
// templateComputeNode.inputSchema = Type.toJsonSchema(EmailTriggerOutput);
|
|
389
|
+
// attachTrigger(functionTrigger, computeModel);
|
|
390
|
+
// return addToSpace(PresetName.EMAIL_TABLE, space, canvasModel, computeModel);
|
|
391
|
+
// });
|
|
392
|
+
// cb?.(objects);
|
|
393
|
+
// return objects;
|
|
394
|
+
// },
|
|
395
|
+
// ],
|
|
447
396
|
[
|
|
448
397
|
"chat-gpt-text",
|
|
449
398
|
async (space, n, cb) => {
|
|
@@ -495,168 +444,86 @@ var generator2 = () => ({
|
|
|
495
444
|
return objects;
|
|
496
445
|
}
|
|
497
446
|
],
|
|
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
|
-
],
|
|
447
|
+
// TODO(wittjosiah): Remove?
|
|
448
|
+
// [
|
|
449
|
+
// PresetName.EMAIL_WITH_SUMMARY,
|
|
450
|
+
// async (space, n, cb) => {
|
|
451
|
+
// const objects = range(n, () => {
|
|
452
|
+
// const canvasModel = CanvasGraphModel.create<ComputeShape>();
|
|
453
|
+
// const results = space.db.query(Filter.type(TableType)).runSync();
|
|
454
|
+
// const emailTable = results.find((r) => r.object?.view?.target?.query?.typename?.endsWith('Email'));
|
|
455
|
+
// invariant(emailTable, 'Email table not found.');
|
|
456
|
+
// const template = canvasModel.createNode(
|
|
457
|
+
// createTemplate({
|
|
458
|
+
// valueType: 'object',
|
|
459
|
+
// ...rawPosition({ centerX: 192, centerY: -176, width: 320, height: 320 }),
|
|
460
|
+
// }),
|
|
461
|
+
// );
|
|
462
|
+
// const templateContent = ['{'];
|
|
463
|
+
// let functionTrigger: FunctionTrigger | undefined;
|
|
464
|
+
// canvasModel.builder.call((builder) => {
|
|
465
|
+
// const gpt = canvasModel.createNode(
|
|
466
|
+
// createGpt(rawPosition({ centerX: -400, centerY: -112, width: 256, height: 202 })),
|
|
467
|
+
// );
|
|
468
|
+
// const systemPrompt = canvasModel.createNode(
|
|
469
|
+
// createConstant({
|
|
470
|
+
// value: "use one word to describe content category. don't write anything else",
|
|
471
|
+
// ...rawPosition({ centerX: -800, centerY: -160, width: 192, height: 128 }),
|
|
472
|
+
// }),
|
|
473
|
+
// );
|
|
474
|
+
// const triggerShape = createTrigger({
|
|
475
|
+
// spaceId: space.id,
|
|
476
|
+
// triggerKind: TriggerKind.Email,
|
|
477
|
+
// ...rawPosition({ centerX: -736, centerY: -384, width: 182, height: 192 }),
|
|
478
|
+
// });
|
|
479
|
+
// const trigger = canvasModel.createNode(triggerShape);
|
|
480
|
+
// const { queueId } = setupQueue(space, canvasModel, {
|
|
481
|
+
// idPosition: { centerX: -720, centerY: 224, width: 192, height: 256 },
|
|
482
|
+
// queuePosition: { centerX: -144, centerY: 416, width: 320, height: 448 },
|
|
483
|
+
// });
|
|
484
|
+
// const appendToQueue = canvasModel.createNode(
|
|
485
|
+
// createAppend(rawPosition({ centerX: -80, centerY: 96, width: 122, height: 128 })),
|
|
486
|
+
// );
|
|
487
|
+
// const tableId = canvasModel.createNode(
|
|
488
|
+
// createConstant({
|
|
489
|
+
// value: DXN.fromLocalObjectId(emailTable.id).toString(),
|
|
490
|
+
// ...rawPosition({ centerX: -112, centerY: -544, width: 192, height: 256 }),
|
|
491
|
+
// }),
|
|
492
|
+
// );
|
|
493
|
+
// const appendToTable = canvasModel.createNode(
|
|
494
|
+
// createAppend(rawPosition({ centerX: 560, centerY: -416, width: 128, height: 122 })),
|
|
495
|
+
// );
|
|
496
|
+
// templateContent.push(' "category": "{{text}}",');
|
|
497
|
+
// builder.createEdge({ source: gpt.id, target: template.id, input: 'text', output: 'text' });
|
|
498
|
+
// const properties = SchemaAST.getPropertySignatures(EmailTriggerOutput.ast);
|
|
499
|
+
// for (let i = 0; i < properties.length; i++) {
|
|
500
|
+
// const propName = properties[i].name.toString();
|
|
501
|
+
// builder.createEdge({ source: trigger.id, target: template.id, input: propName, output: propName });
|
|
502
|
+
// templateContent.push(` "${propName}": "{{${propName}}}"` + (i === properties.length - 1 ? '' : ','));
|
|
503
|
+
// }
|
|
504
|
+
// templateContent.push('}');
|
|
505
|
+
// builder
|
|
506
|
+
// .createEdge({ source: tableId.id, target: appendToTable.id, input: 'id' })
|
|
507
|
+
// .createEdge({ source: queueId.id, target: appendToQueue.id, input: 'id' })
|
|
508
|
+
// .createEdge({ source: gpt.id, target: appendToQueue.id, output: 'messages', input: 'items' })
|
|
509
|
+
// .createEdge({ source: systemPrompt.id, target: gpt.id, input: 'systemPrompt' })
|
|
510
|
+
// .createEdge({ source: trigger.id, target: gpt.id, input: 'prompt', output: 'body' })
|
|
511
|
+
// .createEdge({ source: template.id, target: appendToTable.id, input: 'items' });
|
|
512
|
+
// functionTrigger = triggerShape.functionTrigger!.target!;
|
|
513
|
+
// });
|
|
514
|
+
// const computeModel = createComputeGraph(canvasModel);
|
|
515
|
+
// const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
|
|
516
|
+
// invariant(templateComputeNode, 'Template compute node was not created.');
|
|
517
|
+
// templateComputeNode.value = templateContent.join('\n');
|
|
518
|
+
// const extendedSchema = Schema.extend(EmailTriggerOutput, Schema.Struct({ text: Schema.String }));
|
|
519
|
+
// templateComputeNode.inputSchema = Type.toJsonSchema(extendedSchema);
|
|
520
|
+
// attachTrigger(functionTrigger, computeModel);
|
|
521
|
+
// return addToSpace(PresetName.EMAIL_WITH_SUMMARY, space, canvasModel, computeModel);
|
|
522
|
+
// });
|
|
523
|
+
// cb?.(objects);
|
|
524
|
+
// return objects;
|
|
525
|
+
// },
|
|
526
|
+
// ],
|
|
660
527
|
[
|
|
661
528
|
"forex-function-call",
|
|
662
529
|
async (space, n, cb) => {
|
|
@@ -782,64 +649,6 @@ var generator2 = () => ({
|
|
|
782
649
|
cb?.(objects);
|
|
783
650
|
return objects;
|
|
784
651
|
}
|
|
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
652
|
]
|
|
844
653
|
]
|
|
845
654
|
});
|
|
@@ -909,7 +718,7 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
|
|
|
909
718
|
const triggerSpec = functionTrigger.spec;
|
|
910
719
|
invariant(triggerSpec && triggerSpec.kind === triggerKind, "No trigger spec.", {
|
|
911
720
|
F: __dxlog_file,
|
|
912
|
-
L:
|
|
721
|
+
L: 496,
|
|
913
722
|
S: void 0,
|
|
914
723
|
A: [
|
|
915
724
|
"triggerSpec && triggerSpec.kind === triggerKind",
|
|
@@ -922,7 +731,7 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
|
|
|
922
731
|
const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
|
|
923
732
|
invariant(templateComputeNode, "Template compute node was not created.", {
|
|
924
733
|
F: __dxlog_file,
|
|
925
|
-
L:
|
|
734
|
+
L: 503,
|
|
926
735
|
S: void 0,
|
|
927
736
|
A: [
|
|
928
737
|
"templateComputeNode",
|
|
@@ -935,7 +744,7 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
|
|
|
935
744
|
' "id": "@{{changeId}}"',
|
|
936
745
|
"}"
|
|
937
746
|
].join("\n");
|
|
938
|
-
templateComputeNode.inputSchema =
|
|
747
|
+
templateComputeNode.inputSchema = Type2.toJsonSchema(Schema.Struct({
|
|
939
748
|
type: Schema.String,
|
|
940
749
|
changeId: Schema.String
|
|
941
750
|
}));
|
|
@@ -984,7 +793,7 @@ var setupQueue = (space, canvasModel, args) => {
|
|
|
984
793
|
var attachTrigger = (functionTrigger, computeModel) => {
|
|
985
794
|
invariant(functionTrigger, void 0, {
|
|
986
795
|
F: __dxlog_file,
|
|
987
|
-
L:
|
|
796
|
+
L: 542,
|
|
988
797
|
S: void 0,
|
|
989
798
|
A: [
|
|
990
799
|
"functionTrigger",
|
|
@@ -1039,20 +848,19 @@ var position = (rect) => {
|
|
|
1039
848
|
}
|
|
1040
849
|
};
|
|
1041
850
|
|
|
1042
|
-
//
|
|
1043
|
-
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-debug/src/components/SpaceGenerator/SpaceGenerator.tsx";
|
|
851
|
+
// src/components/SpaceGenerator/SpaceGenerator.tsx
|
|
1044
852
|
var SpaceGenerator = ({ space, onCreateObjects }) => {
|
|
1045
853
|
var _effect = _useSignals2();
|
|
1046
854
|
try {
|
|
1047
855
|
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
1048
856
|
const client = useClient();
|
|
1049
857
|
const staticTypes = [
|
|
1050
|
-
|
|
858
|
+
Markdown2.Document,
|
|
1051
859
|
DiagramType2,
|
|
1052
860
|
SheetType2,
|
|
1053
861
|
ComputeGraph2
|
|
1054
862
|
];
|
|
1055
|
-
const
|
|
863
|
+
const recordTypes = [
|
|
1056
864
|
DataType2.Organization,
|
|
1057
865
|
DataType2.Project,
|
|
1058
866
|
DataType2.Person,
|
|
@@ -1064,25 +872,26 @@ var SpaceGenerator = ({ space, onCreateObjects }) => {
|
|
|
1064
872
|
const typeMap = useMemo(() => {
|
|
1065
873
|
client.addTypes([
|
|
1066
874
|
...staticTypes,
|
|
875
|
+
...recordTypes,
|
|
1067
876
|
...presets.schemas
|
|
1068
877
|
]);
|
|
1069
|
-
const
|
|
878
|
+
const recordGenerators = new Map(recordTypes.map((type) => [
|
|
1070
879
|
type.typename,
|
|
1071
|
-
createGenerator(type)
|
|
880
|
+
createGenerator(client, dispatch, type)
|
|
1072
881
|
]));
|
|
1073
882
|
return new Map([
|
|
1074
883
|
...staticGenerators,
|
|
1075
884
|
...presets.items,
|
|
1076
|
-
...
|
|
885
|
+
...recordGenerators
|
|
1077
886
|
]);
|
|
1078
887
|
}, [
|
|
1079
888
|
client,
|
|
1080
|
-
|
|
889
|
+
recordTypes
|
|
1081
890
|
]);
|
|
1082
891
|
const updateInfo = async () => {
|
|
1083
892
|
const echoSchema = await space.db.schemaRegistry.query().run();
|
|
1084
893
|
const staticSchema = space.db.graph.schemaRegistry.schemas;
|
|
1085
|
-
const { objects } = await space.db.query(
|
|
894
|
+
const { objects } = await space.db.query(Filter2.everything()).run();
|
|
1086
895
|
const objectMap = sortKeys(objects.reduce((map, obj) => {
|
|
1087
896
|
const type = getTypename(obj);
|
|
1088
897
|
if (type) {
|
|
@@ -1112,67 +921,6 @@ var SpaceGenerator = ({ space, onCreateObjects }) => {
|
|
|
1112
921
|
typeMap,
|
|
1113
922
|
count
|
|
1114
923
|
]);
|
|
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
924
|
return /* @__PURE__ */ React2.createElement("div", {
|
|
1177
925
|
role: "none",
|
|
1178
926
|
className: "flex flex-col grow overflow-hidden"
|
|
@@ -1183,11 +931,6 @@ var SpaceGenerator = ({ space, onCreateObjects }) => {
|
|
|
1183
931
|
iconOnly: true,
|
|
1184
932
|
label: "Refresh",
|
|
1185
933
|
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
934
|
}), /* @__PURE__ */ React2.createElement(Toolbar.Separator, {
|
|
1192
935
|
variant: "gap"
|
|
1193
936
|
}), /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
@@ -1207,9 +950,9 @@ var SpaceGenerator = ({ space, onCreateObjects }) => {
|
|
|
1207
950
|
label: "Static Types",
|
|
1208
951
|
onClick: handleCreateData
|
|
1209
952
|
}), /* @__PURE__ */ React2.createElement(SchemaTable, {
|
|
1210
|
-
types:
|
|
953
|
+
types: recordTypes,
|
|
1211
954
|
objects: info.objects,
|
|
1212
|
-
label: "
|
|
955
|
+
label: "Record Types",
|
|
1213
956
|
onClick: handleCreateData
|
|
1214
957
|
}), /* @__PURE__ */ React2.createElement(SchemaTable, {
|
|
1215
958
|
types: presets.types,
|
|
@@ -1230,9 +973,9 @@ var SpaceGenerator = ({ space, onCreateObjects }) => {
|
|
|
1230
973
|
}
|
|
1231
974
|
};
|
|
1232
975
|
|
|
1233
|
-
//
|
|
976
|
+
// src/components/SpaceGenerator/index.ts
|
|
1234
977
|
var SpaceGenerator_default = SpaceGenerator;
|
|
1235
978
|
export {
|
|
1236
979
|
SpaceGenerator_default as default
|
|
1237
980
|
};
|
|
1238
|
-
//# sourceMappingURL=SpaceGenerator-
|
|
981
|
+
//# sourceMappingURL=SpaceGenerator-6ZOCEREN.mjs.map
|