@dxos/plugin-debug 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6

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 (164) hide show
  1. package/dist/lib/browser/index.mjs +97 -91
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/types/src/DebugPlugin.d.ts +6 -1
  5. package/dist/types/src/DebugPlugin.d.ts.map +1 -1
  6. package/dist/types/src/capabilities/app-graph-builder.d.ts +6 -0
  7. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
  8. package/dist/types/src/capabilities/index.d.ts +15 -4
  9. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  10. package/dist/types/src/capabilities/{react-context/react-context.d.ts → react-context.d.ts} +1 -1
  11. package/dist/types/src/capabilities/react-context.d.ts.map +1 -0
  12. package/dist/types/src/capabilities/react-surface.d.ts +9 -0
  13. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  14. package/dist/types/src/capabilities/settings.d.ts +10 -0
  15. package/dist/types/src/capabilities/settings.d.ts.map +1 -0
  16. package/dist/types/src/components/DebugSettings/DebugSettings.d.ts +11 -0
  17. package/dist/types/src/components/DebugSettings/DebugSettings.d.ts.map +1 -0
  18. package/dist/types/src/components/DebugSettings/DebugSettings.stories.d.ts +79 -0
  19. package/dist/types/src/components/DebugSettings/DebugSettings.stories.d.ts.map +1 -0
  20. package/dist/types/src/components/DebugSettings/index.d.ts +3 -0
  21. package/dist/types/src/components/DebugSettings/index.d.ts.map +1 -0
  22. package/dist/types/src/components/SchemaTable/SchemaTable.d.ts.map +1 -0
  23. package/dist/types/src/components/SchemaTable/index.d.ts +2 -0
  24. package/dist/types/src/components/SchemaTable/index.d.ts.map +1 -0
  25. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts +1 -1
  26. package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
  27. package/dist/types/src/components/SpaceGenerator/index.d.ts +2 -2
  28. package/dist/types/src/components/SpaceGenerator/index.d.ts.map +1 -1
  29. package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -1
  30. package/dist/types/src/components/index.d.ts +4 -10
  31. package/dist/types/src/components/index.d.ts.map +1 -1
  32. package/dist/types/src/{components → containers/DebugGraph}/DebugGraph.d.ts +0 -1
  33. package/dist/types/src/containers/DebugGraph/DebugGraph.d.ts.map +1 -0
  34. package/dist/types/src/containers/DebugGraph/index.d.ts +3 -0
  35. package/dist/types/src/containers/DebugGraph/index.d.ts.map +1 -0
  36. package/dist/types/src/{components → containers/DebugObjectPanel}/DebugObjectPanel.d.ts +1 -1
  37. package/dist/types/src/containers/DebugObjectPanel/DebugObjectPanel.d.ts.map +1 -0
  38. package/dist/types/src/containers/DebugObjectPanel/index.d.ts +3 -0
  39. package/dist/types/src/containers/DebugObjectPanel/index.d.ts.map +1 -0
  40. package/dist/types/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.d.ts +3 -0
  41. package/dist/types/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.d.ts.map +1 -0
  42. package/dist/types/src/containers/DebugSpaceObjectsPanel/index.d.ts +3 -0
  43. package/dist/types/src/containers/DebugSpaceObjectsPanel/index.d.ts.map +1 -0
  44. package/dist/types/src/containers/DebugStatus/DebugStatus.d.ts.map +1 -0
  45. package/dist/types/src/containers/DebugStatus/index.d.ts +3 -0
  46. package/dist/types/src/containers/DebugStatus/index.d.ts.map +1 -0
  47. package/dist/types/src/{components → containers/DevtoolsOverviewContainer}/DevtoolsOverviewContainer.d.ts +0 -1
  48. package/dist/types/src/containers/DevtoolsOverviewContainer/DevtoolsOverviewContainer.d.ts.map +1 -0
  49. package/dist/types/src/containers/DevtoolsOverviewContainer/index.d.ts +3 -0
  50. package/dist/types/src/containers/DevtoolsOverviewContainer/index.d.ts.map +1 -0
  51. package/dist/types/src/containers/SpaceGenerator/SpaceGenerator.d.ts +15 -0
  52. package/dist/types/src/{components → containers}/SpaceGenerator/SpaceGenerator.d.ts.map +1 -1
  53. package/dist/types/src/containers/SpaceGenerator/index.d.ts +3 -0
  54. package/dist/types/src/containers/SpaceGenerator/index.d.ts.map +1 -0
  55. package/dist/types/src/containers/Wireframe/Wireframe.d.ts.map +1 -0
  56. package/dist/types/src/containers/Wireframe/index.d.ts +3 -0
  57. package/dist/types/src/containers/Wireframe/index.d.ts.map +1 -0
  58. package/dist/types/src/containers/index.d.ts +9 -0
  59. package/dist/types/src/containers/index.d.ts.map +1 -0
  60. package/dist/types/src/translations.d.ts +60 -58
  61. package/dist/types/src/translations.d.ts.map +1 -1
  62. package/dist/types/src/types/Settings.d.ts +6 -0
  63. package/dist/types/src/types/Settings.d.ts.map +1 -0
  64. package/dist/types/src/types/index.d.ts +67 -0
  65. package/dist/types/src/types/index.d.ts.map +1 -0
  66. package/dist/types/tsconfig.tsbuildinfo +1 -1
  67. package/package.json +74 -67
  68. package/src/DebugPlugin.tsx +23 -10
  69. package/src/capabilities/app-graph-builder.ts +406 -0
  70. package/src/capabilities/index.ts +6 -4
  71. package/src/capabilities/react-context.tsx +25 -0
  72. package/src/capabilities/{react-surface/react-surface.tsx → react-surface.tsx} +122 -109
  73. package/src/capabilities/{settings/settings.ts → settings.ts} +7 -6
  74. package/src/components/DebugSettings/DebugSettings.stories.tsx +36 -0
  75. package/src/components/DebugSettings/DebugSettings.tsx +228 -0
  76. package/src/components/DebugSettings/index.ts +7 -0
  77. package/src/components/{SpaceGenerator → SchemaTable}/SchemaTable.tsx +2 -2
  78. package/src/components/SchemaTable/index.ts +5 -0
  79. package/src/components/SpaceGenerator/ObjectGenerator.tsx +7 -8
  80. package/src/components/SpaceGenerator/index.ts +2 -3
  81. package/src/components/SpaceGenerator/presets.ts +51 -46
  82. package/src/components/index.ts +4 -11
  83. package/src/{components → containers/DebugGraph}/DebugGraph.tsx +0 -2
  84. package/src/containers/DebugGraph/index.ts +7 -0
  85. package/src/containers/DebugObjectPanel/DebugObjectPanel.tsx +47 -0
  86. package/src/containers/DebugObjectPanel/index.ts +7 -0
  87. package/src/containers/DebugSpaceObjectsPanel/DebugSpaceObjectsPanel.tsx +55 -0
  88. package/src/containers/DebugSpaceObjectsPanel/index.ts +7 -0
  89. package/src/{components → containers/DebugStatus}/DebugStatus.tsx +41 -17
  90. package/src/containers/DebugStatus/index.ts +7 -0
  91. package/src/containers/DevtoolsOverviewContainer/DevtoolsOverviewContainer.tsx +25 -0
  92. package/src/containers/DevtoolsOverviewContainer/index.ts +7 -0
  93. package/src/containers/SpaceGenerator/SpaceGenerator.tsx +130 -0
  94. package/src/containers/SpaceGenerator/index.ts +7 -0
  95. package/src/{components → containers/Wireframe}/Wireframe.tsx +2 -2
  96. package/src/containers/Wireframe/index.ts +7 -0
  97. package/src/containers/index.ts +13 -0
  98. package/src/meta.ts +1 -1
  99. package/src/translations.ts +66 -58
  100. package/src/types/Settings.ts +15 -0
  101. package/src/{types.ts → types/index.ts} +7 -13
  102. package/dist/lib/browser/DebugGraph-6VMEOKEV.mjs +0 -15
  103. package/dist/lib/browser/DebugGraph-6VMEOKEV.mjs.map +0 -7
  104. package/dist/lib/browser/DevtoolsOverviewContainer-77PKFLYV.mjs +0 -19
  105. package/dist/lib/browser/DevtoolsOverviewContainer-77PKFLYV.mjs.map +0 -7
  106. package/dist/lib/browser/SpaceGenerator-H33AEFGC.mjs +0 -1152
  107. package/dist/lib/browser/SpaceGenerator-H33AEFGC.mjs.map +0 -7
  108. package/dist/lib/browser/app-graph-builder-LV73R7HR.mjs +0 -598
  109. package/dist/lib/browser/app-graph-builder-LV73R7HR.mjs.map +0 -7
  110. package/dist/lib/browser/chunk-4UFQXPP7.mjs +0 -78
  111. package/dist/lib/browser/chunk-4UFQXPP7.mjs.map +0 -7
  112. package/dist/lib/browser/chunk-A5H5GRV6.mjs +0 -20
  113. package/dist/lib/browser/chunk-A5H5GRV6.mjs.map +0 -7
  114. package/dist/lib/browser/react-context-FSWBT3MH.mjs +0 -17
  115. package/dist/lib/browser/react-context-FSWBT3MH.mjs.map +0 -7
  116. package/dist/lib/browser/react-surface-2N6CPSHR.mjs +0 -757
  117. package/dist/lib/browser/react-surface-2N6CPSHR.mjs.map +0 -7
  118. package/dist/lib/browser/settings-KA4GN73K.mjs +0 -31
  119. package/dist/lib/browser/settings-KA4GN73K.mjs.map +0 -7
  120. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +0 -6
  121. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +0 -1
  122. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +0 -3
  123. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +0 -1
  124. package/dist/types/src/capabilities/react-context/index.d.ts +0 -7
  125. package/dist/types/src/capabilities/react-context/index.d.ts.map +0 -1
  126. package/dist/types/src/capabilities/react-context/react-context.d.ts.map +0 -1
  127. package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
  128. package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
  129. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
  130. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
  131. package/dist/types/src/capabilities/settings/index.d.ts +0 -3
  132. package/dist/types/src/capabilities/settings/index.d.ts.map +0 -1
  133. package/dist/types/src/capabilities/settings/settings.d.ts +0 -5
  134. package/dist/types/src/capabilities/settings/settings.d.ts.map +0 -1
  135. package/dist/types/src/components/Container.d.ts +0 -5
  136. package/dist/types/src/components/Container.d.ts.map +0 -1
  137. package/dist/types/src/components/DebugGraph.d.ts.map +0 -1
  138. package/dist/types/src/components/DebugObjectPanel.d.ts.map +0 -1
  139. package/dist/types/src/components/DebugSettings.d.ts +0 -8
  140. package/dist/types/src/components/DebugSettings.d.ts.map +0 -1
  141. package/dist/types/src/components/DebugStatus.d.ts.map +0 -1
  142. package/dist/types/src/components/DevtoolsOverviewContainer.d.ts.map +0 -1
  143. package/dist/types/src/components/SpaceGenerator/SchemaTable.d.ts.map +0 -1
  144. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts +0 -9
  145. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts +0 -15
  146. package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts.map +0 -1
  147. package/dist/types/src/components/Wireframe.d.ts.map +0 -1
  148. package/dist/types/src/types.d.ts +0 -68
  149. package/dist/types/src/types.d.ts.map +0 -1
  150. package/src/capabilities/app-graph-builder/app-graph-builder.ts +0 -420
  151. package/src/capabilities/app-graph-builder/index.ts +0 -7
  152. package/src/capabilities/react-context/index.ts +0 -7
  153. package/src/capabilities/react-context/react-context.tsx +0 -20
  154. package/src/capabilities/react-surface/index.ts +0 -7
  155. package/src/capabilities/settings/index.ts +0 -7
  156. package/src/components/Container.tsx +0 -15
  157. package/src/components/DebugObjectPanel.tsx +0 -33
  158. package/src/components/DebugSettings.tsx +0 -185
  159. package/src/components/DevtoolsOverviewContainer.tsx +0 -20
  160. package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +0 -54
  161. package/src/components/SpaceGenerator/SpaceGenerator.tsx +0 -127
  162. /package/dist/types/src/components/{SpaceGenerator → SchemaTable}/SchemaTable.d.ts +0 -0
  163. /package/dist/types/src/{components → containers/DebugStatus}/DebugStatus.d.ts +0 -0
  164. /package/dist/types/src/{components → containers/Wireframe}/Wireframe.d.ts +0 -0
@@ -0,0 +1,228 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import React, { useCallback, useEffect, useState } from 'react';
6
+
7
+ import { AppCapabilities, getPersonalSpace } from '@dxos/app-toolkit';
8
+ import { type SettingsSurfaceProps } from '@dxos/app-toolkit/ui';
9
+ import { type ConfigProto, SaveConfig, Storage, defs } from '@dxos/config';
10
+ import { type LogBuffer, log } from '@dxos/log';
11
+ import { useClient } from '@dxos/react-client';
12
+ import { Icon, IconButton, Input, Select, Toast, useFileDownload, useTranslation } from '@dxos/react-ui';
13
+ import { Settings as SettingsForm } from '@dxos/react-ui-form';
14
+ import { setDeep } from '@dxos/util';
15
+
16
+ import { meta } from '#meta';
17
+ import { type Settings } from '#types';
18
+
19
+ type Toast = {
20
+ title: string;
21
+ description?: string;
22
+ };
23
+
24
+ const StorageAdapters = {
25
+ opfs: defs.Runtime.Client.Storage.StorageDriver.WEBFS,
26
+ idb: defs.Runtime.Client.Storage.StorageDriver.IDB,
27
+ } as const;
28
+
29
+ export type DebugSettingsProps = SettingsSurfaceProps<
30
+ Settings.Settings,
31
+ {
32
+ logBuffer: LogBuffer;
33
+ onUpload?: AppCapabilities.FileUploader;
34
+ }
35
+ >;
36
+
37
+ export const DebugSettings = ({ settings, onSettingsChange, logBuffer, onUpload }: DebugSettingsProps) => {
38
+ const { t } = useTranslation(meta.id);
39
+ const [toast, setToast] = useState<Toast>();
40
+ const download = useFileDownload();
41
+ const [storageConfig, setStorageConfig] = useState<ConfigProto>({});
42
+ const client = useClient();
43
+
44
+ useEffect(() => {
45
+ void Storage().then((config) => setStorageConfig(config));
46
+ }, []);
47
+
48
+ const handleToast = useCallback(
49
+ (toast: Toast) => {
50
+ setToast(toast);
51
+ const timer = setTimeout(() => setToast(undefined), 5_000);
52
+ return () => clearTimeout(timer);
53
+ },
54
+ [setToast],
55
+ );
56
+
57
+ const handleDownload = useCallback(async () => {
58
+ const data = await client.diagnostics();
59
+ const file = new Blob([JSON.stringify(data, undefined, 2)], {
60
+ type: 'text/plain',
61
+ });
62
+ const fileName = `composer-${new Date().toISOString().replace(/\W/g, '-')}.json`;
63
+ download(file, fileName);
64
+
65
+ if (onUpload) {
66
+ const personalSpace = getPersonalSpace(client);
67
+ if (!personalSpace) {
68
+ log.error('no personal space available for upload');
69
+ return;
70
+ }
71
+ const info = await onUpload(personalSpace.db, new File([file], fileName));
72
+ if (!info) {
73
+ log.error('diagnostics failed to upload to IPFS');
74
+ return;
75
+ }
76
+ handleToast({
77
+ title: t('settings.uploaded.message'),
78
+ description: t('settings.uploaded.description'),
79
+ });
80
+
81
+ // TODO(nf): move to IpfsPlugin?
82
+ const url = client.config.values.runtime!.services!.ipfs!.gateway + '/' + info.cid;
83
+ void navigator.clipboard.writeText(url);
84
+ handleToast({
85
+ title: t('settings.uploaded.message'),
86
+ description: t('settings.uploaded.description'),
87
+ });
88
+ log.info('diagnostics', { url });
89
+ }
90
+ }, [client, download, handleToast, onUpload, t]);
91
+
92
+ const handleDownloadLogs = useCallback(() => {
93
+ const ndjson = logBuffer.serialize();
94
+ const file = new Blob([ndjson], { type: 'application/x-ndjson' });
95
+ const fileName = `composer-logs-${new Date().toISOString().slice(0, 19).replace(/:/g, '-')}.ndjson`;
96
+ download(file, fileName);
97
+ }, [download, logBuffer]);
98
+
99
+ const handleRepair = useCallback(async () => {
100
+ try {
101
+ const info = await client.repair();
102
+ setStorageConfig(await Storage());
103
+ handleToast({
104
+ title: t('settings.repair-success.message'),
105
+ description: JSON.stringify(info, undefined, 2),
106
+ });
107
+ } catch (err: any) {
108
+ handleToast({
109
+ title: t('settings.repair-failed.message'),
110
+ description: err.message,
111
+ });
112
+ }
113
+ }, [client, handleToast, t]);
114
+
115
+ const handleWireframeChange = useCallback(
116
+ (checked: boolean) => onSettingsChange?.((s) => ({ ...s, wireframe: !!checked })),
117
+ [onSettingsChange],
118
+ );
119
+
120
+ const handleStorageAdapterChange = useCallback(
121
+ (value: string) => {
122
+ if (confirm(t('settings.storage-adapter.changed-alert.message'))) {
123
+ updateConfig(
124
+ storageConfig,
125
+ setStorageConfig,
126
+ ['runtime', 'client', 'storage', 'dataStore'],
127
+ StorageAdapters[value as keyof typeof StorageAdapters],
128
+ );
129
+ }
130
+ },
131
+ [storageConfig, t],
132
+ );
133
+
134
+ return (
135
+ <SettingsForm.Viewport>
136
+ <SettingsForm.Section title={t('settings.title', { ns: meta.id })}>
137
+ <SettingsForm.Item title={t('settings.wireframe.label')} description={t('settings.wireframe.description')}>
138
+ <Input.Switch
139
+ disabled={!onSettingsChange}
140
+ checked={settings.wireframe}
141
+ onCheckedChange={handleWireframeChange}
142
+ />
143
+ </SettingsForm.Item>
144
+ <SettingsForm.Item
145
+ title={t('settings.download-diagnostics.label')}
146
+ description={t('settings.download-diagnostics.description')}
147
+ >
148
+ <IconButton
149
+ icon='ph--download-simple--regular'
150
+ iconOnly
151
+ label={t('settings.download-diagnostics.label')}
152
+ onClick={handleDownload}
153
+ />
154
+ </SettingsForm.Item>
155
+ <SettingsForm.Item
156
+ title={t('settings.download-logs.label')}
157
+ description={t('settings.download-logs.description')}
158
+ >
159
+ <IconButton
160
+ icon='ph--download-simple--regular'
161
+ iconOnly
162
+ label={t('settings.download-logs.label')}
163
+ onClick={handleDownloadLogs}
164
+ />
165
+ </SettingsForm.Item>
166
+ <SettingsForm.Item title={t('settings.repair.label')} description={t('settings.repair.description')}>
167
+ <IconButton
168
+ icon='ph--first-aid-kit--regular'
169
+ iconOnly
170
+ label={t('settings.repair.label')}
171
+ onClick={handleRepair}
172
+ />
173
+ </SettingsForm.Item>
174
+
175
+ {/* TODO(burdon): Move to layout? */}
176
+ {toast && (
177
+ <Toast.Root>
178
+ <Toast.Body>
179
+ <Toast.Title>
180
+ <Icon icon='ph--gift--duotone' classNames='inline mr-1' />
181
+ <span>{toast.title}</span>
182
+ </Toast.Title>
183
+ {toast.description && <Toast.Description>{toast.description}</Toast.Description>}
184
+ </Toast.Body>
185
+ </Toast.Root>
186
+ )}
187
+
188
+ <SettingsForm.Item
189
+ title={t('settings.choose-storage-adaptor.label')}
190
+ description={t('settings.choose-storage-adaptor.description')}
191
+ >
192
+ <Select.Root
193
+ disabled={!onSettingsChange}
194
+ value={
195
+ Object.entries(StorageAdapters).find(
196
+ ([_name, value]) => value === storageConfig?.runtime?.client?.storage?.dataStore,
197
+ )?.[0]
198
+ }
199
+ onValueChange={handleStorageAdapterChange}
200
+ >
201
+ <Select.TriggerButton disabled={!onSettingsChange} placeholder={t('settings.data-store.label')} />
202
+ <Select.Portal>
203
+ <Select.Content>
204
+ <Select.Viewport>
205
+ {Object.keys(StorageAdapters).map((key) => (
206
+ <Select.Option key={key} value={key}>
207
+ {t(`settings.storage-adaptor.${key}.label`)}
208
+ </Select.Option>
209
+ ))}
210
+ </Select.Viewport>
211
+ <Select.Arrow />
212
+ </Select.Content>
213
+ </Select.Portal>
214
+ </Select.Root>
215
+ </SettingsForm.Item>
216
+ </SettingsForm.Section>
217
+ </SettingsForm.Viewport>
218
+ );
219
+ };
220
+
221
+ const updateConfig = (config: ConfigProto, setConfig: (newConfig: ConfigProto) => void, path: string[], value: any) => {
222
+ const storageConfigCopy = JSON.parse(JSON.stringify(config ?? {}));
223
+ setDeep(storageConfigCopy, path, value);
224
+ setConfig(storageConfigCopy);
225
+ queueMicrotask(async () => {
226
+ await SaveConfig(storageConfigCopy);
227
+ });
228
+ };
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { DebugSettings } from './DebugSettings';
6
+
7
+ export default DebugSettings;
@@ -19,8 +19,8 @@ export const SchemaTable = ({ types, objects = {}, label, onClick }: SchemaTable
19
19
  <h2 className='p-2'>{label}</h2>
20
20
  {types.map((type) => (
21
21
  <div key={type.typename} className='grid grid-cols-subgrid col-span-3 items-center'>
22
- <div className='pli-2 text-sm font-mono text-subdued'>{type.typename}</div>
23
- <div className='pli-2 text-right font-mono'>{objects[type.typename] ?? 0}</div>
22
+ <div className='px-2 text-sm font-mono text-subdued'>{type.typename}</div>
23
+ <div className='px-2 text-right font-mono'>{objects[type.typename] ?? 0}</div>
24
24
  <IconButton
25
25
  variant='ghost'
26
26
  icon='ph--plus--regular'
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ export * from './SchemaTable';
@@ -7,15 +7,16 @@ import type * as Schema from 'effect/Schema';
7
7
  import { addressToA1Notation } from '@dxos/compute';
8
8
  import { ComputeGraph, ComputeGraphModel, DEFAULT_OUTPUT, NODE_INPUT, NODE_OUTPUT } from '@dxos/conductor';
9
9
  import { DXN, Filter, Key, type Type } from '@dxos/echo';
10
+ import { View } from '@dxos/echo';
10
11
  import { type OperationInvoker } from '@dxos/operation';
11
12
  import { Markdown } from '@dxos/plugin-markdown/types';
12
13
  import { Sheet } from '@dxos/plugin-sheet/types';
13
- import { Diagram } from '@dxos/plugin-sketch/types';
14
- import { SpaceOperation } from '@dxos/plugin-space/types';
14
+ import { Sketch } from '@dxos/plugin-sketch/types';
15
+ import { SpaceOperation } from '@dxos/plugin-space/operations';
15
16
  import { faker } from '@dxos/random';
16
17
  import { type Client } from '@dxos/react-client';
17
18
  import { type Space } from '@dxos/react-client/echo';
18
- import { View, getTypenameFromQuery } from '@dxos/schema';
19
+ import { getTypenameFromQuery } from '@dxos/schema';
19
20
  import { type ValueGenerator, createAsyncGenerator } from '@dxos/schema/testing';
20
21
  import { range } from '@dxos/util';
21
22
 
@@ -27,7 +28,7 @@ const findViewByTypename = async (views: View.View[], typename: string) => {
27
28
 
28
29
  export type ObjectGenerator<T> = (space: Space, n: number, cb?: (objects: T[]) => void) => Promise<T[]>;
29
30
 
30
- export const createGenerator = <S extends Type.Obj.Any>(
31
+ export const createGenerator = <S extends Type.AnyObj>(
31
32
  client: Client,
32
33
  invokePromise: OperationInvoker.OperationInvoker['invokePromise'],
33
34
  schema: S,
@@ -41,8 +42,6 @@ export const createGenerator = <S extends Type.Obj.Any>(
41
42
  const staticSchema = client?.graph.schemaRegistry.query({ typename }).runSync()[0];
42
43
  if (!view && !staticSchema) {
43
44
  await invokePromise(SpaceOperation.AddSchema, { db: space.db, schema, show: false });
44
- } else if (!view && staticSchema) {
45
- await invokePromise(SpaceOperation.UseStaticSchema, { db: space.db, typename, show: false });
46
45
  }
47
46
 
48
47
  // Create objects.
@@ -69,10 +68,10 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
69
68
  },
70
69
  ],
71
70
  [
72
- Diagram.Diagram.typename,
71
+ Sketch.Sketch.typename,
73
72
  async (space, n, cb) => {
74
73
  const objects = range(n).map(() => {
75
- const obj = space.db.add(Diagram.make({ name: faker.commerce.productName() }));
74
+ const obj = space.db.add(Sketch.make({ name: faker.commerce.productName() }));
76
75
  return obj;
77
76
  });
78
77
 
@@ -2,6 +2,5 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { SpaceGenerator } from './SpaceGenerator';
6
-
7
- export default SpaceGenerator;
5
+ export * from './presets';
6
+ export * from './ObjectGenerator';
@@ -4,13 +4,14 @@
4
4
 
5
5
  import * as Schema from 'effect/Schema';
6
6
 
7
- import { Agent, EntityExtraction, ResearchBlueprint } from '@dxos/assistant-toolkit';
7
+ import { AgentPrompt, EntityExtraction, ResearchBlueprint } from '@dxos/assistant-toolkit';
8
8
  import { Prompt } from '@dxos/blueprints';
9
9
  import { type ComputeGraphModel, NODE_INPUT } from '@dxos/conductor';
10
- import { DXN, Filter, Key, Obj, Query, type QueryAST, Ref, Tag, Type } from '@dxos/echo';
11
- import { Trigger, serializeFunction } from '@dxos/functions';
10
+ import { DXN, Feed, Filter, JsonSchema, Key, Obj, Query, type QueryAST, Ref, Tag } from '@dxos/echo';
11
+ import { Trigger } from '@dxos/functions';
12
12
  import { invariant } from '@dxos/invariant';
13
- import { gmail } from '@dxos/plugin-inbox';
13
+ import { Operation } from '@dxos/operation';
14
+ import { InboxOperation } from '@dxos/plugin-inbox';
14
15
  import { Mailbox } from '@dxos/plugin-inbox/types';
15
16
  import { Markdown } from '@dxos/plugin-markdown/types';
16
17
  import { type Space } from '@dxos/react-client/echo';
@@ -20,24 +21,18 @@ import {
20
21
  createChat,
21
22
  createComputeGraph,
22
23
  createConstant,
24
+ createFeed,
23
25
  createFunction,
24
26
  createGpt,
25
- createQueue,
26
27
  createRandom,
27
28
  createSurface,
28
29
  createTemplate,
29
30
  createText,
30
31
  createTrigger,
31
32
  } from '@dxos/react-ui-canvas-compute';
32
- import {
33
- CanvasBoardType,
34
- CanvasGraphModel,
35
- pointMultiply,
36
- pointsToRect,
37
- rectToPoints,
38
- } from '@dxos/react-ui-canvas-editor';
39
- import { View } from '@dxos/schema';
40
- import { Message, Organization, Person, Project } from '@dxos/types';
33
+ import { CanvasBoard, CanvasGraphModel, pointMultiply, pointsToRect, rectToPoints } from '@dxos/react-ui-canvas-editor';
34
+ import { ViewModel } from '@dxos/schema';
35
+ import { Message, Organization, Person, Pipeline } from '@dxos/types';
41
36
  import { range, trim } from '@dxos/util';
42
37
 
43
38
  import { type ObjectGenerator } from './ObjectGenerator';
@@ -57,7 +52,7 @@ export enum PresetName {
57
52
  }
58
53
 
59
54
  export const generator = () => ({
60
- schemas: [CanvasBoardType, Trigger.Trigger] as any[],
55
+ schemas: [CanvasBoard.CanvasBoard, Trigger.Trigger] as any[],
61
56
  types: Object.values(PresetName).map((name) => ({ typename: name })),
62
57
  items: [
63
58
  [
@@ -79,8 +74,8 @@ export const generator = () => ({
79
74
 
80
75
  const tag = space.db.add(Tag.make({ label: 'Investor' }));
81
76
  const tagDxn = Obj.getDXN(tag).toString();
82
- Obj.change(doc, (d) => {
83
- Obj.getMeta(d).tags = [tagDxn];
77
+ Obj.change(doc, (obj) => {
78
+ Obj.getMeta(obj).tags = [tagDxn];
84
79
  });
85
80
 
86
81
  // space.db.add(
@@ -91,7 +86,9 @@ export const generator = () => ({
91
86
  // }),
92
87
  // );
93
88
 
94
- space.db.add(Obj.make(Person.Person, { fullName: 'Rich', organization: Ref.make(org) }, { tags: [tagDxn] }));
89
+ space.db.add(
90
+ Obj.make(Person.Person, { [Obj.Meta]: { tags: [tagDxn] }, fullName: 'Rich', organization: Ref.make(org) }),
91
+ );
95
92
  space.db.add(
96
93
  Obj.make(Person.Person, {
97
94
  fullName: 'Josiah',
@@ -120,7 +117,13 @@ export const generator = () => ({
120
117
  [
121
118
  PresetName.ORG_RESEARCH_PROJECT,
122
119
  async (space, n, cb) => {
123
- const mailbox = await space.db.query(Filter.type(Mailbox.Mailbox)).first();
120
+ const mailboxes = await space.db.query(Filter.type(Mailbox.Mailbox)).run();
121
+ const mailbox = mailboxes[0];
122
+ invariant(mailbox, 'Mailbox not found');
123
+ const mailboxFeed = await mailbox.feed?.tryLoad();
124
+ invariant(mailboxFeed, 'Mailbox missing feed reference');
125
+ const queueDxn = Feed.getQueueDxn(mailboxFeed)?.toString();
126
+ invariant(queueDxn, 'Mailbox feed missing queue DXN key');
124
127
  const tag = await space.db.query(Filter.type(Tag.Tag, { label: 'Investor' })).first();
125
128
  const tagDxn = Obj.getDXN(tag).toString();
126
129
 
@@ -136,9 +139,9 @@ export const generator = () => ({
136
139
  kind: 'timer',
137
140
  cron: '* * * * *', // Every minute.
138
141
  },
139
- function: Ref.make(serializeFunction(gmail.sync)),
142
+ function: Ref.make(Operation.serialize(InboxOperation.GoogleMailSync)),
140
143
  input: {
141
- mailboxId: Obj.getDXN(mailbox).toString(),
144
+ mailbox: Ref.make(mailbox),
142
145
  },
143
146
  }),
144
147
  );
@@ -149,9 +152,9 @@ export const generator = () => ({
149
152
  // TODO(wittjosiah): Queue trigger doesn't support matching query of the column.
150
153
  spec: {
151
154
  kind: 'queue',
152
- queue: mailbox.queue.dxn.toString(),
155
+ queue: queueDxn,
153
156
  },
154
- function: Ref.make(serializeFunction(EntityExtraction.extract)),
157
+ function: Ref.make(Operation.serialize(EntityExtraction)),
155
158
  input: {
156
159
  source: '{{event.item}}',
157
160
  },
@@ -174,7 +177,7 @@ export const generator = () => ({
174
177
  Create a research note for it at the end.
175
178
  NOTE: Do mocked reseach (set mockSearch to true).
176
179
  `,
177
- blueprints: [Ref.make(ResearchBlueprint)],
180
+ blueprints: [Ref.make(ResearchBlueprint.make())],
178
181
  }),
179
182
  );
180
183
 
@@ -187,7 +190,7 @@ export const generator = () => ({
187
190
  ast: organizationsQuery.ast,
188
191
  },
189
192
  },
190
- function: Ref.make(serializeFunction(Agent.prompt)),
193
+ function: Ref.make(Operation.serialize(AgentPrompt)),
191
194
  input: {
192
195
  prompt: Ref.make(researchPrompt),
193
196
  input: '{{event.subject}}',
@@ -195,31 +198,31 @@ export const generator = () => ({
195
198
  }),
196
199
  );
197
200
 
198
- const mailboxView = View.make({
201
+ const mailboxView = ViewModel.make({
199
202
  query: Query.select(
200
203
  Filter.type(Message.Message, {
201
204
  properties: { labels: Filter.contains('investor') },
202
205
  }),
203
- ).options({
204
- queues: [mailbox.queue.dxn.toString()],
206
+ ).from({
207
+ queues: [queueDxn],
205
208
  }),
206
- jsonSchema: Type.toJsonSchema(Message.Message),
209
+ jsonSchema: JsonSchema.toJsonSchema(Message.Message),
207
210
  });
208
- const contactsView = View.make({
211
+ const contactsView = ViewModel.make({
209
212
  query: contactsQuery,
210
- jsonSchema: Type.toJsonSchema(Person.Person),
213
+ jsonSchema: JsonSchema.toJsonSchema(Person.Person),
211
214
  });
212
- const organizationsView = View.make({
215
+ const organizationsView = ViewModel.make({
213
216
  query: organizationsQuery,
214
- jsonSchema: Type.toJsonSchema(Organization.Organization),
217
+ jsonSchema: JsonSchema.toJsonSchema(Organization.Organization),
215
218
  });
216
- const notesView = View.make({
219
+ const notesView = ViewModel.make({
217
220
  query: notesQuery,
218
- jsonSchema: Type.toJsonSchema(Markdown.Document),
221
+ jsonSchema: JsonSchema.toJsonSchema(Markdown.Document),
219
222
  });
220
223
 
221
224
  return space.db.add(
222
- Project.make({
225
+ Pipeline.make({
223
226
  name: 'Investor Research',
224
227
  columns: [
225
228
  {
@@ -313,7 +316,7 @@ export const generator = () => ({
313
316
  'subscription',
314
317
  (triggerSpec) =>
315
318
  (triggerSpec.query = {
316
- ast: Query.select(Filter.typename('dxos.org/type/Chess')).ast as Obj.Mutable<QueryAST.Query>,
319
+ ast: Query.select(Filter.typename('org.dxos.type.chess')).ast as Obj.Mutable<QueryAST.Query>,
317
320
  }),
318
321
  'type',
319
322
  );
@@ -398,7 +401,7 @@ export const generator = () => ({
398
401
  // const templateComputeNode = computeModel.nodes.find((n) => n.id === template.node);
399
402
  // invariant(templateComputeNode, 'Template compute node was not created.');
400
403
  // templateComputeNode.value = templateContent.join('\n');
401
- // templateComputeNode.inputSchema = Type.toJsonSchema(EmailTriggerOutput);
404
+ // templateComputeNode.inputSchema = JsonSchema.toJsonSchema(EmailTriggerOutput);
402
405
 
403
406
  // attachTrigger(functionTrigger, computeModel);
404
407
 
@@ -532,7 +535,7 @@ export const generator = () => ({
532
535
  // invariant(templateComputeNode, 'Template compute node was not created.');
533
536
  // templateComputeNode.value = templateContent.join('\n');
534
537
  // const extendedSchema = Schema.extend(EmailTriggerOutput, Schema.Struct({ text: Schema.String }));
535
- // templateComputeNode.inputSchema = Type.toJsonSchema(extendedSchema);
538
+ // templateComputeNode.inputSchema = JsonSchema.toJsonSchema(extendedSchema);
536
539
 
537
540
  // attachTrigger(functionTrigger, computeModel);
538
541
 
@@ -615,7 +618,7 @@ export const generator = () => ({
615
618
  );
616
619
  const converter = canvasModel.createNode(createFunction(position({ x: 0, y: 0 })));
617
620
  const view = canvasModel.createNode(createText(position({ x: 12, y: 0 })));
618
- const queue = canvasModel.createNode(createQueue(position({ x: 0, y: 12 })));
621
+ const queue = canvasModel.createNode(createFeed(position({ x: 0, y: 12 })));
619
622
 
620
623
  builder
621
624
  .createEdge({
@@ -771,7 +774,9 @@ const createQueueSinkPreset = <SpecType extends Trigger.Kind>(
771
774
  invariant(templateComputeNode, 'Template compute node was not created.');
772
775
  // NOTE: These are plain object mutations during model construction, not ECHO object mutations.
773
776
  templateComputeNode.value = ['{', ' "@type": "{{type}}",', ' "id": "@{{changeId}}"', '}'].join('\n');
774
- templateComputeNode.inputSchema = Type.toJsonSchema(Schema.Struct({ type: Schema.String, changeId: Schema.String }));
777
+ templateComputeNode.inputSchema = JsonSchema.toJsonSchema(
778
+ Schema.Struct({ type: Schema.String, changeId: Schema.String }),
779
+ );
775
780
  attachTrigger(functionTrigger, computeModel);
776
781
 
777
782
  return { canvasModel, computeModel };
@@ -779,7 +784,7 @@ const createQueueSinkPreset = <SpecType extends Trigger.Kind>(
779
784
 
780
785
  const addToSpace = (name: string, space: Space, canvas: CanvasGraphModel, compute: ComputeGraphModel) => {
781
786
  return space.db.add(
782
- Obj.make(CanvasBoardType, {
787
+ Obj.make(CanvasBoard.CanvasBoard, {
783
788
  name,
784
789
  computeGraph: Ref.make(compute.root),
785
790
  layout: canvas.graph,
@@ -799,7 +804,7 @@ const setupQueue = (
799
804
  }),
800
805
  );
801
806
  const queue = canvasModel.createNode(
802
- createQueue(
807
+ createFeed(
803
808
  args?.queuePosition ? rawPosition(args.queuePosition) : position({ x: -3, y: 3, width: 14, height: 10 }),
804
809
  ),
805
810
  );
@@ -810,9 +815,9 @@ const setupQueue = (
810
815
  const attachTrigger = (functionTrigger: Trigger.Trigger | undefined, computeModel: ComputeGraphModel) => {
811
816
  invariant(functionTrigger);
812
817
  const inputNode = computeModel.nodes.find((node) => node.type === NODE_INPUT)!;
813
- Obj.change(functionTrigger, (t) => {
814
- t.function = Ref.make(computeModel.root);
815
- t.inputNodeId = inputNode.id;
818
+ Obj.change(functionTrigger, (obj) => {
819
+ obj.function = Ref.make(computeModel.root);
820
+ obj.inputNodeId = inputNode.id;
816
821
  });
817
822
  };
818
823
 
@@ -2,16 +2,9 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { lazy } from 'react';
6
- import { type FC } from 'react';
5
+ import { type ComponentType, lazy } from 'react';
7
6
 
8
- import { type DebugGraphProps } from './DebugGraph';
7
+ export const DebugSettings: ComponentType<any> = lazy(() => import('./DebugSettings'));
9
8
 
10
- export const DebugGraph: ReturnType<typeof lazy<FC<DebugGraphProps>>> = lazy(() => import('./DebugGraph'));
11
- export const DevtoolsOverviewContainer = lazy(() => import('./DevtoolsOverviewContainer'));
12
- export const SpaceGenerator = lazy(() => import('./SpaceGenerator'));
13
-
14
- export * from './DebugObjectPanel';
15
- export * from './DebugSettings';
16
- export * from './DebugStatus';
17
- export * from './Wireframe';
9
+ export * from './SchemaTable';
10
+ export * from './SpaceGenerator';
@@ -11,5 +11,3 @@ export type DebugGraphProps = { graph: Graph.Graph; root: string };
11
11
  export const DebugGraph: FC<DebugGraphProps> = ({ graph, root }) => {
12
12
  return <Tree data={Graph.toJSON(graph, root)} />;
13
13
  };
14
-
15
- export default DebugGraph;
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { DebugGraph } from './DebugGraph';
6
+
7
+ export default DebugGraph;
@@ -0,0 +1,47 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import React, { useState } from 'react';
6
+
7
+ import { ObjectsTree } from '@dxos/devtools';
8
+ import { Filter, Obj, Query } from '@dxos/echo';
9
+ import type { ObjectId } from '@dxos/keys';
10
+ import { useQuery } from '@dxos/react-client/echo';
11
+ import { Clipboard, Grid, Panel, ScrollArea, Toolbar } from '@dxos/react-ui';
12
+ import { Json } from '@dxos/react-ui-syntax-highlighter';
13
+
14
+ export type DebugObjectPanelProps = {
15
+ object: Obj.Unknown;
16
+ };
17
+
18
+ export const DebugObjectPanel = ({ object }: DebugObjectPanelProps) => {
19
+ const db = Obj.getDatabase(object);
20
+ const [selectedId, setSelectedId] = useState<ObjectId | null>(null);
21
+ const [selectedObject] = useQuery(
22
+ db,
23
+ Query.select(Filter.id(selectedId ?? object.id)).options({ deleted: 'include' }),
24
+ );
25
+
26
+ return (
27
+ <Clipboard.Provider>
28
+ <Panel.Root>
29
+ <Panel.Toolbar asChild>
30
+ <Toolbar.Root />
31
+ </Panel.Toolbar>
32
+ <Panel.Content asChild>
33
+ <Grid rows={db ? 2 : 1} classNames='divide-y divide-separator'>
34
+ {db && (
35
+ <ScrollArea.Root>
36
+ <ScrollArea.Viewport>
37
+ <ObjectsTree db={db} root={object} onSelect={(entity) => setSelectedId(entity.id)} />
38
+ </ScrollArea.Viewport>
39
+ </ScrollArea.Root>
40
+ )}
41
+ <Json.Data data={selectedObject} />
42
+ </Grid>
43
+ </Panel.Content>
44
+ </Panel.Root>
45
+ </Clipboard.Provider>
46
+ );
47
+ };
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { DebugObjectPanel } from './DebugObjectPanel';
6
+
7
+ export default DebugObjectPanel;