@dxos/plugin-debug 0.8.4-main.c4373fc → 0.8.4-main.c85a9c8dae

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.
Files changed (188) hide show
  1. package/dist/lib/browser/DebugGraph-7HXJ2PS2.mjs +16 -0
  2. package/dist/lib/browser/DebugGraph-7HXJ2PS2.mjs.map +7 -0
  3. package/dist/lib/browser/DebugObjectPanel-3TCDNUNW.mjs +33 -0
  4. package/dist/lib/browser/DebugObjectPanel-3TCDNUNW.mjs.map +7 -0
  5. package/dist/lib/browser/DebugSettings-JZMIUDYB.mjs +174 -0
  6. package/dist/lib/browser/DebugSettings-JZMIUDYB.mjs.map +7 -0
  7. package/dist/lib/browser/DebugSpaceObjectsPanel-7NRPLWZ4.mjs +50 -0
  8. package/dist/lib/browser/DebugSpaceObjectsPanel-7NRPLWZ4.mjs.map +7 -0
  9. package/dist/lib/browser/DebugStatus-COQGH37G.mjs +125 -0
  10. package/dist/lib/browser/DebugStatus-COQGH37G.mjs.map +7 -0
  11. package/dist/lib/browser/DevtoolsOverviewContainer-C75NFVER.mjs +20 -0
  12. package/dist/lib/browser/DevtoolsOverviewContainer-C75NFVER.mjs.map +7 -0
  13. package/dist/lib/browser/{SpaceGenerator-54FUIZIH.mjs → SpaceGenerator-SWSGJEEL.mjs} +476 -461
  14. package/dist/lib/browser/SpaceGenerator-SWSGJEEL.mjs.map +7 -0
  15. package/dist/lib/browser/Wireframe-KAGOKEFW.mjs +53 -0
  16. package/dist/lib/browser/Wireframe-KAGOKEFW.mjs.map +7 -0
  17. package/dist/lib/browser/app-graph-builder-LGUQNXHD.mjs +625 -0
  18. package/dist/lib/browser/app-graph-builder-LGUQNXHD.mjs.map +7 -0
  19. package/dist/lib/browser/{chunk-SRV2AIGJ.mjs → chunk-4UFQXPP7.mjs} +11 -1
  20. package/dist/lib/browser/chunk-4UFQXPP7.mjs.map +7 -0
  21. package/dist/lib/browser/chunk-A5H5GRV6.mjs +20 -0
  22. package/dist/lib/browser/chunk-A5H5GRV6.mjs.map +7 -0
  23. package/dist/lib/browser/index.mjs +42 -41
  24. package/dist/lib/browser/index.mjs.map +4 -4
  25. package/dist/lib/browser/meta.json +1 -1
  26. package/dist/lib/browser/react-context-I3USIAF6.mjs +17 -0
  27. package/dist/lib/browser/react-context-I3USIAF6.mjs.map +7 -0
  28. package/dist/lib/browser/react-surface-BTVNKKVQ.mjs +443 -0
  29. package/dist/lib/browser/react-surface-BTVNKKVQ.mjs.map +7 -0
  30. package/dist/lib/browser/settings-SLTQJJNF.mjs +32 -0
  31. package/dist/lib/browser/settings-SLTQJJNF.mjs.map +7 -0
  32. package/dist/types/src/DebugPlugin.d.ts +7 -1
  33. package/dist/types/src/DebugPlugin.d.ts.map +1 -1
  34. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
  35. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
  36. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
  37. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
  38. package/dist/types/src/capabilities/index.d.ts +4 -8
  39. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  40. package/dist/types/src/capabilities/react-context/index.d.ts +7 -0
  41. package/dist/types/src/capabilities/react-context/index.d.ts.map +1 -0
  42. package/dist/types/src/capabilities/react-context/react-context.d.ts +10 -0
  43. package/dist/types/src/capabilities/react-context/react-context.d.ts.map +1 -0
  44. package/dist/types/src/capabilities/react-surface/index.d.ts +5 -0
  45. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  46. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +9 -0
  47. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  48. package/dist/types/src/capabilities/settings/index.d.ts +3 -0
  49. package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
  50. package/dist/types/src/capabilities/settings/settings.d.ts +6 -0
  51. package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
  52. package/dist/types/src/components/SchemaTable/SchemaTable.d.ts.map +1 -0
  53. package/dist/types/src/components/SchemaTable/index.d.ts +2 -0
  54. package/dist/types/src/components/SchemaTable/index.d.ts.map +1 -0
  55. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts +5 -5
  56. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
  57. package/dist/types/src/components/SpaceGenerator/index.d.ts +2 -2
  58. package/dist/types/src/components/SpaceGenerator/index.d.ts.map +1 -1
  59. package/dist/types/src/components/SpaceGenerator/presets.d.ts +2 -5
  60. package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -1
  61. package/dist/types/src/components/index.d.ts +2 -10
  62. package/dist/types/src/components/index.d.ts.map +1 -1
  63. package/dist/types/src/containers/DebugGraph/DebugGraph.d.ts +8 -0
  64. package/dist/types/src/containers/DebugGraph/DebugGraph.d.ts.map +1 -0
  65. package/dist/types/src/containers/DebugGraph/index.d.ts +3 -0
  66. package/dist/types/src/containers/DebugGraph/index.d.ts.map +1 -0
  67. package/dist/types/src/{components → containers/DebugObjectPanel}/DebugObjectPanel.d.ts +2 -2
  68. package/dist/types/src/containers/DebugObjectPanel/DebugObjectPanel.d.ts.map +1 -0
  69. package/dist/types/src/containers/DebugObjectPanel/index.d.ts +3 -0
  70. package/dist/types/src/containers/DebugObjectPanel/index.d.ts.map +1 -0
  71. package/dist/types/src/containers/DebugSettings/DebugSettings.d.ts +10 -0
  72. package/dist/types/src/containers/DebugSettings/DebugSettings.d.ts.map +1 -0
  73. package/dist/types/src/containers/DebugSettings/index.d.ts +3 -0
  74. package/dist/types/src/containers/DebugSettings/index.d.ts.map +1 -0
  75. package/dist/types/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.d.ts +3 -0
  76. package/dist/types/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.d.ts.map +1 -0
  77. package/dist/types/src/containers/DebugSpaceObjectsPanel/index.d.ts +3 -0
  78. package/dist/types/src/containers/DebugSpaceObjectsPanel/index.d.ts.map +1 -0
  79. package/dist/types/src/containers/DebugStatus/DebugStatus.d.ts.map +1 -0
  80. package/dist/types/src/containers/DebugStatus/index.d.ts +3 -0
  81. package/dist/types/src/containers/DebugStatus/index.d.ts.map +1 -0
  82. package/dist/types/src/{components → containers/DevtoolsOverviewContainer}/DevtoolsOverviewContainer.d.ts +0 -1
  83. package/dist/types/src/containers/DevtoolsOverviewContainer/DevtoolsOverviewContainer.d.ts.map +1 -0
  84. package/dist/types/src/containers/DevtoolsOverviewContainer/index.d.ts +3 -0
  85. package/dist/types/src/containers/DevtoolsOverviewContainer/index.d.ts.map +1 -0
  86. package/dist/types/src/{components → containers}/SpaceGenerator/SpaceGenerator.d.ts +2 -2
  87. package/dist/types/src/containers/SpaceGenerator/SpaceGenerator.d.ts.map +1 -0
  88. package/dist/types/src/containers/SpaceGenerator/index.d.ts +3 -0
  89. package/dist/types/src/containers/SpaceGenerator/index.d.ts.map +1 -0
  90. package/dist/types/src/{components → containers/Wireframe}/Wireframe.d.ts +2 -2
  91. package/dist/types/src/containers/Wireframe/Wireframe.d.ts.map +1 -0
  92. package/dist/types/src/containers/Wireframe/index.d.ts +3 -0
  93. package/dist/types/src/containers/Wireframe/index.d.ts.map +1 -0
  94. package/dist/types/src/containers/index.d.ts +10 -0
  95. package/dist/types/src/containers/index.d.ts.map +1 -0
  96. package/dist/types/src/meta.d.ts +2 -2
  97. package/dist/types/src/meta.d.ts.map +1 -1
  98. package/dist/types/src/translations.d.ts +3 -1
  99. package/dist/types/src/translations.d.ts.map +1 -1
  100. package/dist/types/src/types.d.ts +5 -0
  101. package/dist/types/src/types.d.ts.map +1 -1
  102. package/dist/types/tsconfig.tsbuildinfo +1 -1
  103. package/package.json +75 -69
  104. package/src/DebugPlugin.tsx +27 -31
  105. package/src/capabilities/app-graph-builder/app-graph-builder.ts +441 -0
  106. package/src/capabilities/app-graph-builder/index.ts +7 -0
  107. package/src/capabilities/index.ts +4 -6
  108. package/src/capabilities/react-context/index.ts +7 -0
  109. package/src/capabilities/react-context/react-context.tsx +20 -0
  110. package/src/capabilities/react-surface/index.ts +7 -0
  111. package/src/capabilities/react-surface/react-surface.tsx +428 -0
  112. package/src/capabilities/settings/index.ts +7 -0
  113. package/src/capabilities/settings/settings.ts +31 -0
  114. package/src/components/SchemaTable/index.ts +5 -0
  115. package/src/components/SpaceGenerator/ObjectGenerator.tsx +26 -32
  116. package/src/components/SpaceGenerator/index.ts +2 -3
  117. package/src/components/SpaceGenerator/presets.ts +258 -141
  118. package/src/components/index.ts +2 -10
  119. package/src/containers/DebugGraph/DebugGraph.tsx +13 -0
  120. package/src/containers/DebugGraph/index.ts +7 -0
  121. package/src/containers/DebugObjectPanel/DebugObjectPanel.tsx +45 -0
  122. package/src/containers/DebugObjectPanel/index.ts +7 -0
  123. package/src/{components → containers/DebugSettings}/DebugSettings.tsx +78 -36
  124. package/src/containers/DebugSettings/index.ts +7 -0
  125. package/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.tsx +60 -0
  126. package/src/containers/DebugSpaceObjectsPanel/index.ts +7 -0
  127. package/src/containers/DebugStatus/index.ts +7 -0
  128. package/src/{components → containers/DevtoolsOverviewContainer}/DevtoolsOverviewContainer.tsx +2 -4
  129. package/src/containers/DevtoolsOverviewContainer/index.ts +7 -0
  130. package/src/containers/SpaceGenerator/SpaceGenerator.tsx +127 -0
  131. package/src/containers/SpaceGenerator/index.ts +7 -0
  132. package/src/{components → containers/Wireframe}/Wireframe.tsx +6 -7
  133. package/src/containers/Wireframe/index.ts +7 -0
  134. package/src/containers/index.ts +14 -0
  135. package/src/meta.ts +7 -4
  136. package/src/translations.ts +3 -1
  137. package/src/types.ts +8 -0
  138. package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs +0 -20
  139. package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs.map +0 -7
  140. package/dist/lib/browser/DevtoolsOverviewContainer-EPD6EWT5.mjs +0 -25
  141. package/dist/lib/browser/DevtoolsOverviewContainer-EPD6EWT5.mjs.map +0 -7
  142. package/dist/lib/browser/SpaceGenerator-54FUIZIH.mjs.map +0 -7
  143. package/dist/lib/browser/app-graph-builder-I4IHBKKN.mjs +0 -588
  144. package/dist/lib/browser/app-graph-builder-I4IHBKKN.mjs.map +0 -7
  145. package/dist/lib/browser/chunk-SRV2AIGJ.mjs.map +0 -7
  146. package/dist/lib/browser/chunk-SVCKCXCL.mjs +0 -16
  147. package/dist/lib/browser/chunk-SVCKCXCL.mjs.map +0 -7
  148. package/dist/lib/browser/react-context-QLZE7VSQ.mjs +0 -16
  149. package/dist/lib/browser/react-context-QLZE7VSQ.mjs.map +0 -7
  150. package/dist/lib/browser/react-surface-BTWJ2I3F.mjs +0 -772
  151. package/dist/lib/browser/react-surface-BTWJ2I3F.mjs.map +0 -7
  152. package/dist/lib/browser/settings-EBVICEEW.mjs +0 -22
  153. package/dist/lib/browser/settings-EBVICEEW.mjs.map +0 -7
  154. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  155. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  156. package/dist/types/src/capabilities/react-context.d.ts +0 -8
  157. package/dist/types/src/capabilities/react-context.d.ts.map +0 -1
  158. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  159. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  160. package/dist/types/src/capabilities/settings.d.ts +0 -4
  161. package/dist/types/src/capabilities/settings.d.ts.map +0 -1
  162. package/dist/types/src/components/Container.d.ts +0 -5
  163. package/dist/types/src/components/Container.d.ts.map +0 -1
  164. package/dist/types/src/components/DebugGraph.d.ts +0 -8
  165. package/dist/types/src/components/DebugGraph.d.ts.map +0 -1
  166. package/dist/types/src/components/DebugObjectPanel.d.ts.map +0 -1
  167. package/dist/types/src/components/DebugSettings.d.ts +0 -6
  168. package/dist/types/src/components/DebugSettings.d.ts.map +0 -1
  169. package/dist/types/src/components/DebugStatus.d.ts.map +0 -1
  170. package/dist/types/src/components/DevtoolsOverviewContainer.d.ts.map +0 -1
  171. package/dist/types/src/components/SpaceGenerator/SchemaTable.d.ts.map +0 -1
  172. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +0 -1
  173. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts +0 -15
  174. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts.map +0 -1
  175. package/dist/types/src/components/Wireframe.d.ts.map +0 -1
  176. package/src/capabilities/app-graph-builder.ts +0 -431
  177. package/src/capabilities/react-context.tsx +0 -16
  178. package/src/capabilities/react-surface.tsx +0 -399
  179. package/src/capabilities/settings.ts +0 -19
  180. package/src/components/Container.tsx +0 -15
  181. package/src/components/DebugGraph.tsx +0 -14
  182. package/src/components/DebugObjectPanel.tsx +0 -33
  183. package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +0 -52
  184. package/src/components/SpaceGenerator/SpaceGenerator.tsx +0 -122
  185. /package/dist/types/src/components/{SpaceGenerator → SchemaTable}/SchemaTable.d.ts +0 -0
  186. /package/dist/types/src/{components → containers/DebugStatus}/DebugStatus.d.ts +0 -0
  187. /package/src/components/{SpaceGenerator → SchemaTable}/SchemaTable.tsx +0 -0
  188. /package/src/{components → containers/DebugStatus}/DebugStatus.tsx +0 -0
@@ -1,216 +1,57 @@
1
- // src/components/SpaceGenerator/SpaceGenerator.tsx
2
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
1
+ // src/containers/SpaceGenerator/SpaceGenerator.tsx
3
2
  import React2, { useCallback, useMemo, useState } from "react";
4
- import { useIntentDispatcher } from "@dxos/app-framework";
3
+ import { useOperationInvoker } from "@dxos/app-framework/ui";
5
4
  import { ComputeGraph as ComputeGraph2 } from "@dxos/conductor";
6
- import { Filter as Filter3 } from "@dxos/echo";
5
+ import { Filter as Filter3, Obj as Obj2 } from "@dxos/echo";
7
6
  import { Markdown as Markdown3 } from "@dxos/plugin-markdown/types";
8
- import { SheetType as SheetType2 } from "@dxos/plugin-sheet/types";
9
- import { DiagramType as DiagramType2 } from "@dxos/plugin-sketch/types";
7
+ import { Sheet as Sheet2 } from "@dxos/plugin-sheet/types";
8
+ import { Diagram as Diagram2 } from "@dxos/plugin-sketch/types";
10
9
  import { useClient } from "@dxos/react-client";
11
- import { getTypename } from "@dxos/react-client/echo";
12
- import { IconButton as IconButton2, Input, Toolbar, useAsyncEffect } from "@dxos/react-ui";
10
+ import { IconButton as IconButton2, Input, Panel, ScrollArea, Toolbar, useAsyncEffect } from "@dxos/react-ui";
13
11
  import { SyntaxHighlighter } from "@dxos/react-ui-syntax-highlighter";
14
- import { DataType as DataType3 } from "@dxos/schema";
12
+ import { Organization as Organization2, Person as Person2, Task } from "@dxos/types";
15
13
  import { jsonKeyReplacer, sortKeys } from "@dxos/util";
16
14
 
17
- // src/components/SpaceGenerator/ObjectGenerator.tsx
18
- import { createIntent } from "@dxos/app-framework";
19
- import { addressToA1Notation } from "@dxos/compute";
20
- import { ComputeGraph, ComputeGraphModel, DEFAULT_OUTPUT, NODE_INPUT, NODE_OUTPUT } from "@dxos/conductor";
21
- import { DXN, Filter, Key, Obj, Ref, Type } from "@dxos/echo";
22
- import { Markdown } from "@dxos/plugin-markdown/types";
23
- import { createSheet } from "@dxos/plugin-sheet/types";
24
- import { SheetType } from "@dxos/plugin-sheet/types";
25
- import { CanvasType, DiagramType } from "@dxos/plugin-sketch/types";
26
- import { SpaceAction } from "@dxos/plugin-space/types";
27
- import { faker } from "@dxos/random";
28
- import { DataType, getTypenameFromQuery } from "@dxos/schema";
29
- import { createAsyncGenerator } from "@dxos/schema/testing";
30
- import { range } from "@dxos/util";
31
- var generator = faker;
32
- var findViewByTypename = async (views, typename) => {
33
- return views.find((view) => getTypenameFromQuery(view.query.ast) === 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
50
- }));
51
- }
52
- const generate = createAsyncGenerator(generator, schema, {
53
- db: space.db
54
- });
55
- return generate.createObjects(n);
56
- };
15
+ // src/components/SchemaTable/SchemaTable.tsx
16
+ import React from "react";
17
+ import { IconButton } from "@dxos/react-ui";
18
+ var SchemaTable = ({ types, objects = {}, label, onClick }) => {
19
+ return /* @__PURE__ */ React.createElement("div", {
20
+ className: "grid grid-cols-[1fr_80px_40px] gap-1 overflow-none"
21
+ }, /* @__PURE__ */ React.createElement("h2", {
22
+ className: "p-2"
23
+ }, label), types.map((type) => /* @__PURE__ */ React.createElement("div", {
24
+ key: type.typename,
25
+ className: "grid grid-cols-subgrid col-span-3 items-center"
26
+ }, /* @__PURE__ */ React.createElement("div", {
27
+ className: "px-2 text-sm font-mono text-subdued"
28
+ }, type.typename), /* @__PURE__ */ React.createElement("div", {
29
+ className: "px-2 text-right font-mono"
30
+ }, objects[type.typename] ?? 0), /* @__PURE__ */ React.createElement(IconButton, {
31
+ variant: "ghost",
32
+ icon: "ph--plus--regular",
33
+ iconOnly: true,
34
+ label: "Create data",
35
+ onClick: () => onClick(type.typename)
36
+ }))));
57
37
  };
58
- var staticGenerators = /* @__PURE__ */ new Map([
59
- [
60
- Markdown.Document.typename,
61
- async (space, n, cb) => {
62
- const objects = range(n).map(() => {
63
- return space.db.add(Markdown.makeDocument({
64
- name: faker.commerce.productName(),
65
- content: faker.lorem.sentences(5)
66
- }));
67
- });
68
- cb?.(objects);
69
- return objects;
70
- }
71
- ],
72
- [
73
- DiagramType.typename,
74
- async (space, n, cb) => {
75
- const objects = range(n).map(() => {
76
- const obj = space.db.add(Obj.make(DiagramType, {
77
- name: faker.commerce.productName(),
78
- canvas: Ref.make(Obj.make(CanvasType, {
79
- content: {}
80
- }))
81
- }));
82
- return obj;
83
- });
84
- cb?.(objects);
85
- return objects;
86
- }
87
- ],
88
- // TODO(burdon): Create unit tests.
89
- [
90
- SheetType.typename,
91
- async (space, n, cb) => {
92
- const objects = range(n).map(() => {
93
- const cells = {};
94
- const year = (/* @__PURE__ */ new Date()).getFullYear();
95
- const cols = 4;
96
- const rows = 16;
97
- for (let col = 1; col <= cols; col++) {
98
- for (let row = 1; row <= rows; row++) {
99
- const cell = addressToA1Notation({
100
- col,
101
- row
102
- });
103
- if (row === 1) {
104
- cells[cell] = {
105
- value: `${year} Q${col}`
106
- };
107
- } else if (row === rows) {
108
- const from = addressToA1Notation({
109
- col,
110
- row: 2
111
- });
112
- const to = addressToA1Notation({
113
- col,
114
- row: rows - 1
115
- });
116
- cells[cell] = {
117
- value: `=SUM(${from}:${to})`
118
- };
119
- } else if (row > 2 && row < rows - 1) {
120
- cells[cell] = {
121
- value: Math.floor(Math.random() * 1e4)
122
- };
123
- }
124
- }
125
- }
126
- return space.db.add(createSheet({
127
- name: faker.commerce.productName(),
128
- cells
129
- }));
130
- });
131
- cb?.(objects);
132
- return objects;
133
- }
134
- ],
135
- [
136
- ComputeGraph.typename,
137
- async (space, n, cb) => {
138
- const objects = range(n, () => {
139
- const model = ComputeGraphModel.create();
140
- model.builder.createNode({
141
- id: "gpt-INPUT",
142
- type: NODE_INPUT
143
- }).createNode({
144
- id: "gpt-GPT",
145
- type: "gpt"
146
- }).createNode({
147
- id: "gpt-QUEUE_ID",
148
- type: "constant",
149
- value: new DXN(DXN.kind.QUEUE, [
150
- "data",
151
- space.id,
152
- Key.ObjectId.random()
153
- ]).toString()
154
- }).createNode({
155
- id: "gpt-APPEND",
156
- type: "append"
157
- }).createNode({
158
- id: "gpt-OUTPUT",
159
- type: NODE_OUTPUT
160
- }).createEdge({
161
- node: "gpt-INPUT",
162
- property: "prompt"
163
- }, {
164
- node: "gpt-GPT",
165
- property: "prompt"
166
- }).createEdge({
167
- node: "gpt-GPT",
168
- property: "text"
169
- }, {
170
- node: "gpt-OUTPUT",
171
- property: "text"
172
- }).createEdge({
173
- node: "gpt-QUEUE_ID",
174
- property: DEFAULT_OUTPUT
175
- }, {
176
- node: "gpt-APPEND",
177
- property: "id"
178
- }).createEdge({
179
- node: "gpt-GPT",
180
- property: "messages"
181
- }, {
182
- node: "gpt-APPEND",
183
- property: "items"
184
- }).createEdge({
185
- node: "gpt-QUEUE_ID",
186
- property: DEFAULT_OUTPUT
187
- }, {
188
- node: "gpt-OUTPUT",
189
- property: "queue"
190
- });
191
- return space.db.add(model.root);
192
- });
193
- cb?.(objects);
194
- return objects;
195
- }
196
- ]
197
- ]);
198
38
 
199
39
  // src/components/SpaceGenerator/presets.ts
200
40
  import * as Schema from "effect/Schema";
201
- import { RESEARCH_BLUEPRINT, ResearchOn, agent, entityExtraction } from "@dxos/assistant-testing";
41
+ import { AgentFunctions, EntityExtractionFunctions, ResearchBlueprint } from "@dxos/assistant-toolkit";
202
42
  import { Prompt } from "@dxos/blueprints";
203
- import { NODE_INPUT as NODE_INPUT2 } from "@dxos/conductor";
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";
43
+ import { NODE_INPUT } from "@dxos/conductor";
44
+ import { DXN, Feed, Filter, JsonSchema, Key, Obj, Query, Ref, Tag } from "@dxos/echo";
45
+ import { Trigger, serializeFunction } from "@dxos/functions";
206
46
  import { invariant } from "@dxos/invariant";
207
- import { sync } from "@dxos/plugin-inbox";
47
+ import { GmailFunctions } from "@dxos/plugin-inbox";
208
48
  import { Mailbox } from "@dxos/plugin-inbox/types";
209
- import { Markdown as Markdown2 } from "@dxos/plugin-markdown/types";
49
+ import { Markdown } from "@dxos/plugin-markdown/types";
210
50
  import { createAppend, createChat, createComputeGraph, createConstant, createFunction, createGpt, createQueue, createRandom, createSurface, createTemplate, createText, createTrigger } from "@dxos/react-ui-canvas-compute";
211
- import { CanvasBoardType, CanvasGraphModel, pointMultiply, pointsToRect, rectToPoints } from "@dxos/react-ui-canvas-editor";
212
- import { DataType as DataType2, createView } from "@dxos/schema";
213
- import { range as range2 } from "@dxos/util";
51
+ import { CanvasBoard, CanvasGraphModel, pointMultiply, pointsToRect, rectToPoints } from "@dxos/react-ui-canvas-editor";
52
+ import { ViewModel } from "@dxos/schema";
53
+ import { Message, Organization, Person, Pipeline } from "@dxos/types";
54
+ import { range, trim } from "@dxos/util";
214
55
  var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-debug/src/components/SpaceGenerator/presets.ts";
215
56
  var PresetName = /* @__PURE__ */ (function(PresetName2) {
216
57
  PresetName2["DXOS_TEAM"] = "dxos-team";
@@ -218,15 +59,15 @@ var PresetName = /* @__PURE__ */ (function(PresetName2) {
218
59
  PresetName2["GPT_QUEUE"] = "webhook-gpt-queue";
219
60
  PresetName2["CHAT_GPT"] = "chat-gpt-text";
220
61
  PresetName2["OBJECT_CHANGE_QUEUE"] = "objectChange-queue";
221
- PresetName2["FOREX_FUNCTION_CALL"] = "forex-function-call";
222
62
  PresetName2["TIMER_TICK_QUEUE"] = "timerTick-queue";
63
+ PresetName2["FOREX_FUNCTION_CALL"] = "forex-function-call";
223
64
  PresetName2["DISCORD_MESSAGES"] = "discord-messages";
224
65
  return PresetName2;
225
66
  })({});
226
- var generator2 = () => ({
67
+ var generator = () => ({
227
68
  schemas: [
228
- CanvasBoardType,
229
- FunctionTrigger
69
+ CanvasBoard.CanvasBoard,
70
+ Trigger.Trigger
230
71
  ],
231
72
  types: Object.values(PresetName).map((name) => ({
232
73
  typename: name
@@ -235,40 +76,44 @@ var generator2 = () => ({
235
76
  [
236
77
  "dxos-team",
237
78
  async (space, n, cb) => {
238
- const objects = range2(n, () => {
239
- const org = space.db.add(Obj2.make(DataType2.Organization, {
79
+ const objects = range(n, () => {
80
+ const org = space.db.add(Obj.make(Organization.Organization, {
240
81
  name: "DXOS",
241
82
  website: "https://dxos.org"
242
83
  }));
243
- const doc = space.db.add(Markdown2.makeDocument({
84
+ const doc = space.db.add(Markdown.make({
244
85
  name: "DXOS Research",
245
86
  content: "DXOS builds Composer, an open-source AI-powered malleable application."
246
87
  }));
247
- space.db.add(Relation.make(ResearchOn, {
248
- [Relation.Source]: doc,
249
- [Relation.Target]: org,
250
- completedAt: (/* @__PURE__ */ new Date()).toISOString()
88
+ const tag = space.db.add(Tag.make({
89
+ label: "Investor"
251
90
  }));
252
- space.db.add(Obj2.make(DataType2.Person, {
91
+ const tagDxn = Obj.getDXN(tag).toString();
92
+ Obj.change(doc, (d) => {
93
+ Obj.getMeta(d).tags = [
94
+ tagDxn
95
+ ];
96
+ });
97
+ space.db.add(Obj.make(Person.Person, {
98
+ [Obj.Meta]: {
99
+ tags: [
100
+ tagDxn
101
+ ]
102
+ },
253
103
  fullName: "Rich",
254
- jobTitle: "investor",
255
- organization: Ref2.make(org)
104
+ organization: Ref.make(org)
256
105
  }));
257
- space.db.add(Obj2.make(DataType2.Person, {
106
+ space.db.add(Obj.make(Person.Person, {
258
107
  fullName: "Josiah",
259
- organization: Ref2.make(org)
108
+ organization: Ref.make(org)
260
109
  }));
261
- space.db.add(Obj2.make(DataType2.Person, {
110
+ space.db.add(Obj.make(Person.Person, {
262
111
  fullName: "Dima",
263
- organization: Ref2.make(org)
112
+ organization: Ref.make(org)
264
113
  }));
265
- space.db.add(Obj2.make(DataType2.Person, {
114
+ space.db.add(Obj.make(Person.Person, {
266
115
  fullName: "Mykola",
267
- organization: Ref2.make(org)
268
- }));
269
- space.db.add(Obj2.make(DataType2.Person, {
270
- fullName: "Will",
271
- organization: Ref2.make(org)
116
+ organization: Ref.make(org)
272
117
  }));
273
118
  return doc;
274
119
  });
@@ -279,41 +124,58 @@ var generator2 = () => ({
279
124
  [
280
125
  "org-research-project",
281
126
  async (space, n, cb) => {
282
- const mailbox = await space.db.query(Filter2.type(Mailbox.Mailbox)).first();
283
- const objects = range2(n, () => {
284
- const contactsQuery = Query.select(Filter2.type(DataType2.Person, {
285
- jobTitle: "investor"
286
- }));
287
- const organizationsQuery = contactsQuery.reference("organization");
288
- const notesQuery = organizationsQuery.targetOf(ResearchOn).source();
289
- const contactsQueryString = 'Query.select(Filter.type(DataType.Person, { jobTitle: "investor" }))';
290
- const organizationsQueryString = `${contactsQueryString}.reference("organization")`;
291
- const notesQueryString = `${organizationsQueryString}.targetOf(ResearchOn).source()`;
292
- const emailSyncTrigger = Obj2.make(FunctionTrigger, {
127
+ const feeds = await space.db.query(Filter.type(Feed.Feed)).run();
128
+ const mailbox = feeds.find((feed) => feed.kind === Mailbox.kind);
129
+ invariant(mailbox, "Mailbox feed not found", {
130
+ F: __dxlog_file,
131
+ L: 121,
132
+ S: void 0,
133
+ A: [
134
+ "mailbox",
135
+ "'Mailbox feed not found'"
136
+ ]
137
+ });
138
+ const queueDxn = Feed.getQueueDxn(mailbox)?.toString();
139
+ invariant(queueDxn, "Mailbox feed missing queue DXN key", {
140
+ F: __dxlog_file,
141
+ L: 123,
142
+ S: void 0,
143
+ A: [
144
+ "queueDxn",
145
+ "'Mailbox feed missing queue DXN key'"
146
+ ]
147
+ });
148
+ const tag = await space.db.query(Filter.type(Tag.Tag, {
149
+ label: "Investor"
150
+ })).first();
151
+ const tagDxn = Obj.getDXN(tag).toString();
152
+ const objects = range(n, () => {
153
+ const contactsQuery = Query.select(Filter.type(Person.Person)).select(Filter.tag(tagDxn));
154
+ const organizationsQuery = Query.select(Filter.type(Organization.Organization)).select(Filter.tag(tagDxn));
155
+ const notesQuery = Query.select(Filter.type(Markdown.Document)).select(Filter.tag(tagDxn));
156
+ space.db.add(Trigger.make({
293
157
  enabled: true,
294
158
  spec: {
295
159
  kind: "timer",
296
160
  cron: "* * * * *"
297
161
  },
298
- function: Ref2.make(serializeFunction(sync)),
162
+ function: Ref.make(serializeFunction(GmailFunctions.Sync)),
299
163
  input: {
300
- mailboxId: Obj2.getDXN(mailbox).toString()
164
+ mailbox: Ref.make(mailbox)
301
165
  }
302
- });
303
- space.db.add(emailSyncTrigger);
304
- const contactExtractionTrigger = Obj2.make(FunctionTrigger, {
166
+ }));
167
+ space.db.add(Trigger.make({
305
168
  enabled: true,
306
169
  // TODO(wittjosiah): Queue trigger doesn't support matching query of the column.
307
170
  spec: {
308
171
  kind: "queue",
309
- queue: mailbox.queue.dxn.toString()
172
+ queue: queueDxn
310
173
  },
311
- function: Ref2.make(serializeFunction(entityExtraction)),
174
+ function: Ref.make(serializeFunction(EntityExtractionFunctions.Extract)),
312
175
  input: {
313
176
  source: "{{event.item}}"
314
177
  }
315
- });
316
- space.db.add(contactExtractionTrigger);
178
+ }));
317
179
  const researchPrompt = space.db.add(Prompt.make({
318
180
  name: "Research",
319
181
  description: "Research organization",
@@ -323,79 +185,77 @@ var generator2 = () => ({
323
185
  output: Schema.Any,
324
186
  // TODO(dmaretskyi): This mocks research (returns pre-baked result), the actual research might take compute minutes.
325
187
  // Remove the mock prompt to do the actual research.
326
- instructions: "Research the organization provided as input. Create a research note for it at the end. NOTE: Do mocked reseach (set mockSearch to true).",
188
+ instructions: trim`
189
+ Research the organization provided as input.
190
+ Create a research note for it at the end.
191
+ NOTE: Do mocked reseach (set mockSearch to true).
192
+ `,
327
193
  blueprints: [
328
- Ref2.make(RESEARCH_BLUEPRINT)
194
+ Ref.make(ResearchBlueprint.make())
329
195
  ]
330
196
  }));
331
- const researchTrigger = Obj2.make(FunctionTrigger, {
197
+ space.db.add(Trigger.make({
332
198
  enabled: true,
333
199
  spec: {
334
200
  kind: "subscription",
335
201
  query: {
336
- string: organizationsQueryString,
337
202
  ast: organizationsQuery.ast
338
203
  }
339
204
  },
340
- function: Ref2.make(serializeFunction(agent)),
205
+ function: Ref.make(serializeFunction(AgentFunctions.Prompt)),
341
206
  input: {
342
- prompt: Ref2.make(researchPrompt),
207
+ prompt: Ref.make(researchPrompt),
343
208
  input: "{{event.subject}}"
344
209
  }
345
- });
346
- space.db.add(researchTrigger);
347
- const mailboxView = createView({
348
- name: "Mailbox",
349
- query: Query.select(Filter2.type(DataType2.Message, {
210
+ }));
211
+ const mailboxView = ViewModel.make({
212
+ query: Query.select(Filter.type(Message.Message, {
350
213
  properties: {
351
- labels: Filter2.contains("investor")
214
+ labels: Filter.contains("investor")
352
215
  }
353
- })).options({
216
+ })).from({
354
217
  queues: [
355
- mailbox.queue.dxn.toString()
218
+ queueDxn
356
219
  ]
357
220
  }),
358
- queryString: 'Query.select(Filter.type(DataType.Message, { properties: { labels: Filter.contains("investor") } }))',
359
- jsonSchema: Type2.toJsonSchema(DataType2.Message),
360
- presentation: Obj2.make(DataType2.Collection, {
361
- objects: []
362
- })
221
+ jsonSchema: JsonSchema.toJsonSchema(Message.Message)
363
222
  });
364
- const contactsView = createView({
365
- name: "Contacts",
223
+ const contactsView = ViewModel.make({
366
224
  query: contactsQuery,
367
- queryString: contactsQueryString,
368
- jsonSchema: Type2.toJsonSchema(DataType2.Person),
369
- presentation: Obj2.make(DataType2.Collection, {
370
- objects: []
371
- })
225
+ jsonSchema: JsonSchema.toJsonSchema(Person.Person)
372
226
  });
373
- const organizationsView = createView({
374
- name: "Organizations",
227
+ const organizationsView = ViewModel.make({
375
228
  query: organizationsQuery,
376
- queryString: organizationsQueryString,
377
- jsonSchema: Type2.toJsonSchema(DataType2.Organization),
378
- presentation: Obj2.make(DataType2.Collection, {
379
- objects: []
380
- })
229
+ jsonSchema: JsonSchema.toJsonSchema(Organization.Organization)
381
230
  });
382
- const notesView = createView({
383
- name: "Notes",
231
+ const notesView = ViewModel.make({
384
232
  query: notesQuery,
385
- queryString: notesQueryString,
386
- jsonSchema: Type2.toJsonSchema(Markdown2.Document),
387
- presentation: Obj2.make(DataType2.Collection, {
388
- objects: []
389
- })
233
+ jsonSchema: JsonSchema.toJsonSchema(Markdown.Document)
390
234
  });
391
- return space.db.add(DataType2.makeProject({
235
+ return space.db.add(Pipeline.make({
392
236
  name: "Investor Research",
393
- collections: [
394
- mailboxView,
395
- contactsView,
396
- organizationsView,
397
- notesView
398
- ].map((view) => Ref2.make(view))
237
+ columns: [
238
+ {
239
+ name: "Mailbox",
240
+ view: Ref.make(mailboxView),
241
+ order: []
242
+ },
243
+ {
244
+ name: "Contacts",
245
+ view: Ref.make(contactsView),
246
+ order: []
247
+ },
248
+ {
249
+ name: "Organizations",
250
+ view: Ref.make(organizationsView),
251
+ order: []
252
+ },
253
+ {
254
+ name: "Notes",
255
+ view: Ref.make(notesView),
256
+ order: []
257
+ }
258
+ ]
399
259
  }));
400
260
  });
401
261
  cb?.(objects.flat());
@@ -405,7 +265,7 @@ var generator2 = () => ({
405
265
  [
406
266
  "webhook-gpt-queue",
407
267
  async (space, n, cb) => {
408
- const objects = range2(n, () => {
268
+ const objects = range(n, () => {
409
269
  const canvasModel = CanvasGraphModel.create();
410
270
  let functionTrigger;
411
271
  canvasModel.builder.call((builder) => {
@@ -465,10 +325,9 @@ var generator2 = () => ({
465
325
  [
466
326
  "objectChange-queue",
467
327
  async (space, n, cb) => {
468
- const objects = range2(n, () => {
328
+ const objects = range(n, () => {
469
329
  const { canvasModel, computeModel } = createQueueSinkPreset(space, "subscription", (triggerSpec) => triggerSpec.query = {
470
- string: 'Query.select(Filter.typename("dxos.org/type/Chess"))',
471
- ast: Query.select(Filter2.typename("dxos.org/type/Chess")).ast
330
+ ast: Query.select(Filter.typename("dxos.org/type/Chess")).ast
472
331
  }, "type");
473
332
  return addToSpace("objectChange-queue", space, canvasModel, computeModel);
474
333
  });
@@ -479,7 +338,7 @@ var generator2 = () => ({
479
338
  [
480
339
  "timerTick-queue",
481
340
  async (space, n, cb) => {
482
- const objects = range2(n, () => {
341
+ const objects = range(n, () => {
483
342
  const { canvasModel, computeModel } = createQueueSinkPreset(space, "timer", (triggerSpec) => triggerSpec.cron = "*/5 * * * * *", "result");
484
343
  return addToSpace("timerTick-queue", space, canvasModel, computeModel);
485
344
  });
@@ -534,7 +393,7 @@ var generator2 = () => ({
534
393
  // const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
535
394
  // invariant(templateComputeNode, 'Template compute node was not created.');
536
395
  // templateComputeNode.value = templateContent.join('\n');
537
- // templateComputeNode.inputSchema = Type.toJsonSchema(EmailTriggerOutput);
396
+ // templateComputeNode.inputSchema = JsonSchema.toJsonSchema(EmailTriggerOutput);
538
397
  // attachTrigger(functionTrigger, computeModel);
539
398
  // return addToSpace(PresetName.EMAIL_TABLE, space, canvasModel, computeModel);
540
399
  // });
@@ -545,7 +404,7 @@ var generator2 = () => ({
545
404
  [
546
405
  "chat-gpt-text",
547
406
  async (space, n, cb) => {
548
- const objects = range2(n, () => {
407
+ const objects = range(n, () => {
549
408
  const canvasModel = CanvasGraphModel.create();
550
409
  canvasModel.builder.call((builder) => {
551
410
  const gpt = canvasModel.createNode(createGpt(position({
@@ -665,7 +524,7 @@ var generator2 = () => ({
665
524
  // invariant(templateComputeNode, 'Template compute node was not created.');
666
525
  // templateComputeNode.value = templateContent.join('\n');
667
526
  // const extendedSchema = Schema.extend(EmailTriggerOutput, Schema.Struct({ text: Schema.String }));
668
- // templateComputeNode.inputSchema = Type.toJsonSchema(extendedSchema);
527
+ // templateComputeNode.inputSchema = JsonSchema.toJsonSchema(extendedSchema);
669
528
  // attachTrigger(functionTrigger, computeModel);
670
529
  // return addToSpace(PresetName.EMAIL_WITH_SUMMARY, space, canvasModel, computeModel);
671
530
  // });
@@ -676,7 +535,7 @@ var generator2 = () => ({
676
535
  [
677
536
  "forex-function-call",
678
537
  async (space, n, cb) => {
679
- const objects = range2(n, () => {
538
+ const objects = range(n, () => {
680
539
  const canvasModel = CanvasGraphModel.create();
681
540
  canvasModel.builder.call((builder) => {
682
541
  const sourceCurrency = canvasModel.createNode(createConstant({
@@ -725,7 +584,7 @@ var generator2 = () => ({
725
584
  [
726
585
  "discord-messages",
727
586
  async (space, n, cb) => {
728
- const objects = range2(n, () => {
587
+ const objects = range(n, () => {
729
588
  const canvasModel = CanvasGraphModel.create();
730
589
  let functionTrigger;
731
590
  canvasModel.builder.call((builder) => {
@@ -746,10 +605,10 @@ var generator2 = () => ({
746
605
  })
747
606
  }));
748
607
  const queueId = canvasModel.createNode(createConstant({
749
- value: new DXN2(DXN2.kind.QUEUE, [
608
+ value: new DXN(DXN.kind.QUEUE, [
750
609
  "data",
751
610
  space.id,
752
- Key2.ObjectId.random()
611
+ Key.ObjectId.random()
753
612
  ]).toString(),
754
613
  ...position({
755
614
  x: -10,
@@ -867,20 +726,22 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
867
726
  const triggerSpec = functionTrigger.spec;
868
727
  invariant(triggerSpec && triggerSpec.kind === triggerKind, "No trigger spec.", {
869
728
  F: __dxlog_file,
870
- L: 663,
729
+ L: 762,
871
730
  S: void 0,
872
731
  A: [
873
732
  "triggerSpec && triggerSpec.kind === triggerKind",
874
733
  "'No trigger spec.'"
875
734
  ]
876
735
  });
877
- initSpec(triggerSpec);
736
+ Obj.change(functionTrigger, (ft) => {
737
+ initSpec(ft.spec);
738
+ });
878
739
  });
879
740
  const computeModel = createComputeGraph(canvasModel);
880
741
  const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
881
742
  invariant(templateComputeNode, "Template compute node was not created.", {
882
743
  F: __dxlog_file,
883
- L: 670,
744
+ L: 771,
884
745
  S: void 0,
885
746
  A: [
886
747
  "templateComputeNode",
@@ -893,7 +754,7 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
893
754
  ' "id": "@{{changeId}}"',
894
755
  "}"
895
756
  ].join("\n");
896
- templateComputeNode.inputSchema = Type2.toJsonSchema(Schema.Struct({
757
+ templateComputeNode.inputSchema = JsonSchema.toJsonSchema(Schema.Struct({
897
758
  type: Schema.String,
898
759
  changeId: Schema.String
899
760
  }));
@@ -904,18 +765,18 @@ var createQueueSinkPreset = (space, triggerKind, initSpec, triggerOutputName) =>
904
765
  };
905
766
  };
906
767
  var addToSpace = (name, space, canvas, compute) => {
907
- return space.db.add(Obj2.make(CanvasBoardType, {
768
+ return space.db.add(Obj.make(CanvasBoard.CanvasBoard, {
908
769
  name,
909
- computeGraph: Ref2.make(compute.root),
770
+ computeGraph: Ref.make(compute.root),
910
771
  layout: canvas.graph
911
772
  }));
912
773
  };
913
774
  var setupQueue = (space, canvasModel, args) => {
914
775
  const queueId = canvasModel.createNode(createConstant({
915
- value: new DXN2(DXN2.kind.QUEUE, [
776
+ value: new DXN(DXN.kind.QUEUE, [
916
777
  "data",
917
778
  space.id,
918
- Key2.ObjectId.random()
779
+ Key.ObjectId.random()
919
780
  ]).toString(),
920
781
  ...args?.idPosition ? rawPosition(args.idPosition) : position({
921
782
  x: -18,
@@ -942,16 +803,18 @@ var setupQueue = (space, canvasModel, args) => {
942
803
  var attachTrigger = (functionTrigger, computeModel) => {
943
804
  invariant(functionTrigger, void 0, {
944
805
  F: __dxlog_file,
945
- L: 709,
806
+ L: 813,
946
807
  S: void 0,
947
808
  A: [
948
809
  "functionTrigger",
949
810
  ""
950
811
  ]
951
812
  });
952
- functionTrigger.function = Ref2.make(computeModel.root);
953
- const inputNode = computeModel.nodes.find((node) => node.type === NODE_INPUT2);
954
- functionTrigger.inputNodeId = inputNode.id;
813
+ const inputNode = computeModel.nodes.find((node) => node.type === NODE_INPUT);
814
+ Obj.change(functionTrigger, (t) => {
815
+ t.function = Ref.make(computeModel.root);
816
+ t.inputNodeId = inputNode.id;
817
+ });
955
818
  };
956
819
  var rawPosition = (args) => {
957
820
  return {
@@ -997,163 +860,315 @@ var position = (rect) => {
997
860
  }
998
861
  };
999
862
 
1000
- // src/components/SpaceGenerator/SchemaTable.tsx
1001
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
1002
- import React from "react";
1003
- import { IconButton } from "@dxos/react-ui";
1004
- var SchemaTable = ({ types, objects = {}, label, onClick }) => {
1005
- var _effect = _useSignals();
1006
- try {
1007
- return /* @__PURE__ */ React.createElement("div", {
1008
- className: "grid grid-cols-[1fr_80px_40px] gap-1 overflow-none"
1009
- }, /* @__PURE__ */ React.createElement("h2", {
1010
- className: "p-2"
1011
- }, label), types.map((type) => /* @__PURE__ */ React.createElement("div", {
1012
- key: type.typename,
1013
- className: "grid grid-cols-subgrid col-span-3 items-center"
1014
- }, /* @__PURE__ */ React.createElement("div", {
1015
- className: "px-2 text-sm font-mono text-subdued"
1016
- }, type.typename), /* @__PURE__ */ React.createElement("div", {
1017
- className: "px-2 text-right font-mono"
1018
- }, objects[type.typename] ?? 0), /* @__PURE__ */ React.createElement(IconButton, {
1019
- variant: "ghost",
1020
- icon: "ph--plus--regular",
1021
- iconOnly: true,
1022
- label: "Create data",
1023
- onClick: () => onClick(type.typename)
1024
- }))));
1025
- } finally {
1026
- _effect.f();
1027
- }
863
+ // src/components/SpaceGenerator/ObjectGenerator.tsx
864
+ import { addressToA1Notation } from "@dxos/compute";
865
+ import { ComputeGraph, ComputeGraphModel, DEFAULT_OUTPUT, NODE_INPUT as NODE_INPUT2, NODE_OUTPUT } from "@dxos/conductor";
866
+ import { DXN as DXN2, Filter as Filter2, Key as Key2 } from "@dxos/echo";
867
+ import { View } from "@dxos/echo";
868
+ import { Markdown as Markdown2 } from "@dxos/plugin-markdown/types";
869
+ import { Sheet } from "@dxos/plugin-sheet/types";
870
+ import { Diagram } from "@dxos/plugin-sketch/types";
871
+ import { SpaceOperation } from "@dxos/plugin-space/types";
872
+ import { faker } from "@dxos/random";
873
+ import { getTypenameFromQuery } from "@dxos/schema";
874
+ import { createAsyncGenerator } from "@dxos/schema/testing";
875
+ import { range as range2 } from "@dxos/util";
876
+ var generator2 = faker;
877
+ var findViewByTypename = async (views, typename) => {
878
+ return views.find((view) => getTypenameFromQuery(view.query.ast) === typename);
1028
879
  };
880
+ var createGenerator = (client, invokePromise, schema) => {
881
+ return async (space, n) => {
882
+ const typename = schema.typename;
883
+ const views = await space.db.query(Filter2.type(View.View)).run();
884
+ const view = await findViewByTypename(views, typename);
885
+ const staticSchema = client?.graph.schemaRegistry.query({
886
+ typename
887
+ }).runSync()[0];
888
+ if (!view && !staticSchema) {
889
+ await invokePromise(SpaceOperation.AddSchema, {
890
+ db: space.db,
891
+ schema,
892
+ show: false
893
+ });
894
+ } else if (!view && staticSchema) {
895
+ await invokePromise(SpaceOperation.UseStaticSchema, {
896
+ db: space.db,
897
+ typename,
898
+ show: false
899
+ });
900
+ }
901
+ const generate = createAsyncGenerator(generator2, schema, {
902
+ db: space.db
903
+ });
904
+ return generate.createObjects(n);
905
+ };
906
+ };
907
+ var staticGenerators = /* @__PURE__ */ new Map([
908
+ [
909
+ Markdown2.Document.typename,
910
+ async (space, n, cb) => {
911
+ const objects = range2(n).map(() => {
912
+ return space.db.add(Markdown2.make({
913
+ name: faker.commerce.productName(),
914
+ content: faker.lorem.sentences(5)
915
+ }));
916
+ });
917
+ cb?.(objects);
918
+ return objects;
919
+ }
920
+ ],
921
+ [
922
+ Diagram.Diagram.typename,
923
+ async (space, n, cb) => {
924
+ const objects = range2(n).map(() => {
925
+ const obj = space.db.add(Diagram.make({
926
+ name: faker.commerce.productName()
927
+ }));
928
+ return obj;
929
+ });
930
+ cb?.(objects);
931
+ return objects;
932
+ }
933
+ ],
934
+ // TODO(burdon): Create unit tests.
935
+ [
936
+ Sheet.Sheet.typename,
937
+ async (space, n, cb) => {
938
+ const objects = range2(n).map(() => {
939
+ const cells = {};
940
+ const year = (/* @__PURE__ */ new Date()).getFullYear();
941
+ const cols = 4;
942
+ const rows = 16;
943
+ for (let col = 1; col <= cols; col++) {
944
+ for (let row = 1; row <= rows; row++) {
945
+ const cell = addressToA1Notation({
946
+ col,
947
+ row
948
+ });
949
+ if (row === 1) {
950
+ cells[cell] = {
951
+ value: `${year} Q${col}`
952
+ };
953
+ } else if (row === rows) {
954
+ const from = addressToA1Notation({
955
+ col,
956
+ row: 2
957
+ });
958
+ const to = addressToA1Notation({
959
+ col,
960
+ row: rows - 1
961
+ });
962
+ cells[cell] = {
963
+ value: `=SUM(${from}:${to})`
964
+ };
965
+ } else if (row > 2 && row < rows - 1) {
966
+ cells[cell] = {
967
+ value: Math.floor(Math.random() * 1e4)
968
+ };
969
+ }
970
+ }
971
+ }
972
+ return space.db.add(Sheet.make({
973
+ name: faker.commerce.productName(),
974
+ cells
975
+ }));
976
+ });
977
+ cb?.(objects);
978
+ return objects;
979
+ }
980
+ ],
981
+ [
982
+ ComputeGraph.typename,
983
+ async (space, n, cb) => {
984
+ const objects = range2(n, () => {
985
+ const model = ComputeGraphModel.create();
986
+ model.builder.createNode({
987
+ id: "gpt-INPUT",
988
+ type: NODE_INPUT2
989
+ }).createNode({
990
+ id: "gpt-GPT",
991
+ type: "gpt"
992
+ }).createNode({
993
+ id: "gpt-QUEUE_ID",
994
+ type: "constant",
995
+ value: new DXN2(DXN2.kind.QUEUE, [
996
+ "data",
997
+ space.id,
998
+ Key2.ObjectId.random()
999
+ ]).toString()
1000
+ }).createNode({
1001
+ id: "gpt-APPEND",
1002
+ type: "append"
1003
+ }).createNode({
1004
+ id: "gpt-OUTPUT",
1005
+ type: NODE_OUTPUT
1006
+ }).createEdge({
1007
+ node: "gpt-INPUT",
1008
+ property: "prompt"
1009
+ }, {
1010
+ node: "gpt-GPT",
1011
+ property: "prompt"
1012
+ }).createEdge({
1013
+ node: "gpt-GPT",
1014
+ property: "text"
1015
+ }, {
1016
+ node: "gpt-OUTPUT",
1017
+ property: "text"
1018
+ }).createEdge({
1019
+ node: "gpt-QUEUE_ID",
1020
+ property: DEFAULT_OUTPUT
1021
+ }, {
1022
+ node: "gpt-APPEND",
1023
+ property: "id"
1024
+ }).createEdge({
1025
+ node: "gpt-GPT",
1026
+ property: "messages"
1027
+ }, {
1028
+ node: "gpt-APPEND",
1029
+ property: "items"
1030
+ }).createEdge({
1031
+ node: "gpt-QUEUE_ID",
1032
+ property: DEFAULT_OUTPUT
1033
+ }, {
1034
+ node: "gpt-OUTPUT",
1035
+ property: "queue"
1036
+ });
1037
+ return space.db.add(model.root);
1038
+ });
1039
+ cb?.(objects);
1040
+ return objects;
1041
+ }
1042
+ ]
1043
+ ]);
1029
1044
 
1030
- // src/components/SpaceGenerator/SpaceGenerator.tsx
1045
+ // src/containers/SpaceGenerator/SpaceGenerator.tsx
1031
1046
  var SpaceGenerator = ({ space, onCreateObjects }) => {
1032
- var _effect = _useSignals2();
1033
- try {
1034
- const { dispatchPromise: dispatch } = useIntentDispatcher();
1035
- const client = useClient();
1036
- const staticTypes = [
1037
- Markdown3.Document,
1038
- DiagramType2,
1039
- SheetType2,
1040
- ComputeGraph2
1041
- ];
1042
- const recordTypes = [
1043
- DataType3.Organization,
1044
- DataType3.Person,
1045
- DataType3.Task
1046
- ];
1047
- const [count, setCount] = useState(1);
1048
- const [info, setInfo] = useState({});
1049
- const presets = useMemo(() => generator2(), []);
1050
- const typeMap = useMemo(() => {
1051
- client.addTypes([
1052
- ...staticTypes,
1053
- ...recordTypes,
1054
- ...presets.schemas
1055
- ]);
1056
- const recordGenerators = new Map(recordTypes.map((type) => [
1057
- type.typename,
1058
- createGenerator(client, dispatch, type)
1059
- ]));
1060
- return new Map([
1061
- ...staticGenerators,
1062
- ...presets.items,
1063
- ...recordGenerators
1064
- ]);
1065
- }, [
1066
- client,
1067
- recordTypes
1047
+ const { invokePromise } = useOperationInvoker();
1048
+ const client = useClient();
1049
+ const staticTypes = [
1050
+ Markdown3.Document,
1051
+ Diagram2.Diagram,
1052
+ Sheet2.Sheet,
1053
+ ComputeGraph2
1054
+ ];
1055
+ const recordTypes = [
1056
+ Organization2.Organization,
1057
+ Person2.Person,
1058
+ Task.Task
1059
+ ];
1060
+ const [count, setCount] = useState(1);
1061
+ const [info, setInfo] = useState({});
1062
+ const presets = useMemo(() => generator(), []);
1063
+ useAsyncEffect(async () => {
1064
+ await client.addTypes([
1065
+ ...staticTypes,
1066
+ ...recordTypes,
1067
+ ...presets.schemas
1068
1068
  ]);
1069
- const updateInfo = async () => {
1070
- const echoSchema = await space.db.schemaRegistry.query().run();
1071
- const staticSchema = space.db.graph.schemaRegistry.schemas;
1072
- const { objects } = await space.db.query(Filter3.everything()).run();
1073
- const objectMap = sortKeys(objects.reduce((map, obj) => {
1074
- const type = getTypename(obj);
1075
- if (type) {
1076
- const count2 = map[type] ?? 0;
1077
- map[type] = count2 + 1;
1078
- }
1079
- return map;
1080
- }, {}));
1081
- setInfo({
1082
- schema: {
1083
- static: staticSchema.length,
1084
- mutable: echoSchema.length
1085
- },
1086
- objects: objectMap
1087
- });
1088
- };
1089
- useAsyncEffect(updateInfo, [
1090
- space
1069
+ }, [
1070
+ client
1071
+ ]);
1072
+ const typeMap = useMemo(() => {
1073
+ const recordGenerators = new Map(recordTypes.map((type) => [
1074
+ type.typename,
1075
+ createGenerator(client, invokePromise, type)
1076
+ ]));
1077
+ return new Map([
1078
+ ...staticGenerators,
1079
+ ...presets.items,
1080
+ ...recordGenerators
1091
1081
  ]);
1092
- const handleCreateData = useCallback(async (typename) => {
1093
- const constructor = typeMap.get(typename);
1094
- if (constructor) {
1095
- await constructor(space, count, onCreateObjects);
1096
- await updateInfo();
1082
+ }, [
1083
+ client,
1084
+ recordTypes,
1085
+ invokePromise
1086
+ ]);
1087
+ const updateInfo = async () => {
1088
+ const echoSchema = await space.db.schemaRegistry.query().run();
1089
+ const staticSchema = await space.db.graph.schemaRegistry.query().run();
1090
+ const objects = await space.db.query(Filter3.everything()).run();
1091
+ const objectMap = sortKeys(objects.reduce((map, obj) => {
1092
+ const type = Obj2.getTypename(obj);
1093
+ if (type) {
1094
+ const count2 = map[type] ?? 0;
1095
+ map[type] = count2 + 1;
1097
1096
  }
1098
- }, [
1099
- typeMap,
1100
- count
1101
- ]);
1102
- return /* @__PURE__ */ React2.createElement("div", {
1103
- role: "none",
1104
- className: "flex flex-col grow overflow-hidden"
1105
- }, /* @__PURE__ */ React2.createElement(Toolbar.Root, {
1106
- classNames: "border-be border-subduedSeparator"
1107
- }, /* @__PURE__ */ React2.createElement(IconButton2, {
1108
- icon: "ph--arrow-clockwise--regular",
1109
- iconOnly: true,
1110
- label: "Refresh",
1111
- onClick: updateInfo
1112
- }), /* @__PURE__ */ React2.createElement(Toolbar.Separator, {
1113
- variant: "gap"
1114
- }), /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.TextInput, {
1115
- type: "number",
1116
- min: 1,
1117
- max: 100,
1118
- placeholder: "Count",
1119
- classNames: "!w-[4rem] !text-right",
1120
- size: 8,
1121
- value: count,
1122
- onChange: (ev) => setCount(parseInt(ev.target.value))
1123
- }))), /* @__PURE__ */ React2.createElement("div", {
1124
- className: "flex flex-col overflow-y-auto divide-y divide-separator"
1125
- }, /* @__PURE__ */ React2.createElement(SchemaTable, {
1126
- types: staticTypes,
1127
- objects: info.objects,
1128
- label: "Static Types",
1129
- onClick: handleCreateData
1130
- }), /* @__PURE__ */ React2.createElement(SchemaTable, {
1131
- types: recordTypes,
1132
- objects: info.objects,
1133
- label: "Record Types",
1134
- onClick: handleCreateData
1135
- }), /* @__PURE__ */ React2.createElement(SchemaTable, {
1136
- types: presets.types,
1137
- objects: info.objects,
1138
- label: "Presets",
1139
- onClick: handleCreateData
1140
- }), /* @__PURE__ */ React2.createElement("div", null, /* @__PURE__ */ React2.createElement(SyntaxHighlighter, {
1141
- language: "json",
1142
- classNames: "text-xs"
1143
- }, JSON.stringify({
1144
- space,
1145
- ...info
1146
- }, jsonKeyReplacer({
1147
- truncate: true
1148
- }), 2)))));
1149
- } finally {
1150
- _effect.f();
1151
- }
1097
+ return map;
1098
+ }, {}));
1099
+ setInfo({
1100
+ schema: {
1101
+ static: staticSchema.length,
1102
+ mutable: echoSchema.length
1103
+ },
1104
+ objects: objectMap
1105
+ });
1106
+ };
1107
+ useAsyncEffect(updateInfo, [
1108
+ space
1109
+ ]);
1110
+ const handleCreateData = useCallback(async (typename) => {
1111
+ const constructor = typeMap.get(typename);
1112
+ if (constructor) {
1113
+ await constructor(space, count, onCreateObjects);
1114
+ await updateInfo();
1115
+ }
1116
+ }, [
1117
+ typeMap,
1118
+ count
1119
+ ]);
1120
+ return /* @__PURE__ */ React2.createElement(Panel.Root, null, /* @__PURE__ */ React2.createElement(Panel.Toolbar, {
1121
+ asChild: true
1122
+ }, /* @__PURE__ */ React2.createElement(Toolbar.Root, null, /* @__PURE__ */ React2.createElement(IconButton2, {
1123
+ icon: "ph--arrow-clockwise--regular",
1124
+ iconOnly: true,
1125
+ label: "Refresh",
1126
+ onClick: updateInfo
1127
+ }), /* @__PURE__ */ React2.createElement(Toolbar.Separator, null), /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.TextInput, {
1128
+ type: "number",
1129
+ placeholder: "Count",
1130
+ classNames: "w-[4rem] text-right",
1131
+ min: 1,
1132
+ max: 100,
1133
+ size: 8,
1134
+ value: count,
1135
+ onChange: (event) => setCount(parseInt(event.target.value))
1136
+ })))), /* @__PURE__ */ React2.createElement(Panel.Content, {
1137
+ asChild: true
1138
+ }, /* @__PURE__ */ React2.createElement(ScrollArea.Root, {
1139
+ thin: true,
1140
+ orientation: "vertical"
1141
+ }, /* @__PURE__ */ React2.createElement(ScrollArea.Viewport, {
1142
+ classNames: "gap-4 divide-y divide-subdued-separator"
1143
+ }, /* @__PURE__ */ React2.createElement(SchemaTable, {
1144
+ types: staticTypes,
1145
+ objects: info.objects,
1146
+ label: "Static Types",
1147
+ onClick: handleCreateData
1148
+ }), /* @__PURE__ */ React2.createElement(SchemaTable, {
1149
+ types: recordTypes,
1150
+ objects: info.objects,
1151
+ label: "Record Types",
1152
+ onClick: handleCreateData
1153
+ }), /* @__PURE__ */ React2.createElement(SchemaTable, {
1154
+ types: presets.types,
1155
+ objects: info.objects,
1156
+ label: "Presets",
1157
+ onClick: handleCreateData
1158
+ }), /* @__PURE__ */ React2.createElement(SyntaxHighlighter, {
1159
+ language: "json",
1160
+ classNames: "text-xs"
1161
+ }, JSON.stringify({
1162
+ space,
1163
+ ...info
1164
+ }, jsonKeyReplacer({
1165
+ truncate: true
1166
+ }), 2))))));
1152
1167
  };
1153
1168
 
1154
- // src/components/SpaceGenerator/index.ts
1169
+ // src/containers/SpaceGenerator/index.ts
1155
1170
  var SpaceGenerator_default = SpaceGenerator;
1156
1171
  export {
1157
1172
  SpaceGenerator_default as default
1158
1173
  };
1159
- //# sourceMappingURL=SpaceGenerator-54FUIZIH.mjs.map
1174
+ //# sourceMappingURL=SpaceGenerator-SWSGJEEL.mjs.map