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