@dxos/plugin-debug 0.8.4-main.406dc2a → 0.8.4-main.52d7546f51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/DebugGraph-6VMEOKEV.mjs +15 -0
- package/dist/lib/browser/DebugGraph-6VMEOKEV.mjs.map +7 -0
- package/dist/lib/browser/DevtoolsOverviewContainer-2C6XMJ3L.mjs +19 -0
- package/dist/lib/browser/DevtoolsOverviewContainer-2C6XMJ3L.mjs.map +7 -0
- package/dist/lib/browser/{SpaceGenerator-VMWHGAJZ.mjs → SpaceGenerator-W3LJORYT.mjs} +259 -266
- package/dist/lib/browser/SpaceGenerator-W3LJORYT.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-DEBTVBQG.mjs +599 -0
- package/dist/lib/browser/app-graph-builder-DEBTVBQG.mjs.map +7 -0
- package/dist/lib/browser/{chunk-SRV2AIGJ.mjs → chunk-4UFQXPP7.mjs} +11 -1
- package/dist/lib/browser/chunk-4UFQXPP7.mjs.map +7 -0
- package/dist/lib/browser/chunk-A5H5GRV6.mjs +20 -0
- package/dist/lib/browser/chunk-A5H5GRV6.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +36 -41
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-context-I3USIAF6.mjs +17 -0
- package/dist/lib/browser/react-context-I3USIAF6.mjs.map +7 -0
- package/dist/lib/browser/react-surface-FMVC5GPV.mjs +758 -0
- package/dist/lib/browser/react-surface-FMVC5GPV.mjs.map +7 -0
- package/dist/lib/browser/settings-SLTQJJNF.mjs +32 -0
- package/dist/lib/browser/settings-SLTQJJNF.mjs.map +7 -0
- package/dist/types/src/DebugPlugin.d.ts +2 -1
- package/dist/types/src/DebugPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +4 -8
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-context/index.d.ts +7 -0
- package/dist/types/src/capabilities/react-context/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-context/react-context.d.ts +10 -0
- package/dist/types/src/capabilities/react-context/react-context.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/index.d.ts +3 -0
- package/dist/types/src/capabilities/settings/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings/settings.d.ts +6 -0
- package/dist/types/src/capabilities/settings/settings.d.ts.map +1 -0
- package/dist/types/src/components/DebugGraph.d.ts +5 -4
- package/dist/types/src/components/DebugGraph.d.ts.map +1 -1
- package/dist/types/src/components/DebugObjectPanel.d.ts +1 -1
- package/dist/types/src/components/DebugObjectPanel.d.ts.map +1 -1
- package/dist/types/src/components/DebugSettings.d.ts +4 -2
- package/dist/types/src/components/DebugSettings.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts +5 -5
- package/dist/types/src/components/SpaceGenerator/ObjectGenerator.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts +2 -2
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/SpaceGenerator.stories.d.ts.map +1 -1
- package/dist/types/src/components/SpaceGenerator/presets.d.ts +2 -5
- package/dist/types/src/components/SpaceGenerator/presets.d.ts.map +1 -1
- package/dist/types/src/components/Wireframe.d.ts +2 -2
- package/dist/types/src/components/Wireframe.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +4 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -1
- package/dist/types/src/types.d.ts +5 -0
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +77 -70
- package/src/DebugPlugin.tsx +17 -31
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +421 -0
- package/src/capabilities/app-graph-builder/index.ts +7 -0
- package/src/capabilities/index.ts +4 -6
- package/src/capabilities/react-context/index.ts +7 -0
- package/src/capabilities/react-context/react-context.tsx +20 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +411 -0
- package/src/capabilities/settings/index.ts +7 -0
- package/src/capabilities/settings/settings.ts +31 -0
- package/src/components/DebugGraph.tsx +4 -3
- package/src/components/DebugObjectPanel.tsx +4 -5
- package/src/components/DebugSettings.tsx +59 -33
- package/src/components/DevtoolsOverviewContainer.tsx +2 -2
- package/src/components/SpaceGenerator/ObjectGenerator.tsx +25 -32
- package/src/components/SpaceGenerator/SchemaTable.tsx +2 -2
- package/src/components/SpaceGenerator/SpaceGenerator.stories.tsx +8 -6
- package/src/components/SpaceGenerator/SpaceGenerator.tsx +35 -31
- package/src/components/SpaceGenerator/presets.ts +235 -120
- package/src/components/Wireframe.tsx +4 -5
- package/src/components/index.ts +4 -1
- package/src/meta.ts +7 -4
- package/src/translations.ts +1 -1
- package/src/types.ts +8 -0
- package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs +0 -20
- package/dist/lib/browser/DebugGraph-EDOH6R2G.mjs.map +0 -7
- package/dist/lib/browser/DevtoolsOverviewContainer-EPD6EWT5.mjs +0 -25
- package/dist/lib/browser/DevtoolsOverviewContainer-EPD6EWT5.mjs.map +0 -7
- package/dist/lib/browser/SpaceGenerator-VMWHGAJZ.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-I4IHBKKN.mjs +0 -588
- package/dist/lib/browser/app-graph-builder-I4IHBKKN.mjs.map +0 -7
- package/dist/lib/browser/chunk-SRV2AIGJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-SVCKCXCL.mjs +0 -16
- package/dist/lib/browser/chunk-SVCKCXCL.mjs.map +0 -7
- package/dist/lib/browser/react-context-QLZE7VSQ.mjs +0 -16
- package/dist/lib/browser/react-context-QLZE7VSQ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-GFORPA3A.mjs +0 -772
- package/dist/lib/browser/react-surface-GFORPA3A.mjs.map +0 -7
- package/dist/lib/browser/settings-EBVICEEW.mjs +0 -22
- package/dist/lib/browser/settings-EBVICEEW.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-context.d.ts +0 -8
- package/dist/types/src/capabilities/react-context.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings.d.ts +0 -4
- package/dist/types/src/capabilities/settings.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder.ts +0 -431
- package/src/capabilities/react-context.tsx +0 -16
- package/src/capabilities/react-surface.tsx +0 -399
- package/src/capabilities/settings.ts +0 -19
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useEffect, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { useCapabilities } from '@dxos/app-framework/ui';
|
|
8
|
+
import { AppCapabilities } from '@dxos/app-toolkit';
|
|
8
9
|
import { type ConfigProto, SaveConfig, Storage, defs } from '@dxos/config';
|
|
9
10
|
import { log } from '@dxos/log';
|
|
10
11
|
import { useClient } from '@dxos/react-client';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
12
|
+
import { Icon, IconButton, Input, Select, Toast, useFileDownload, useTranslation } from '@dxos/react-ui';
|
|
13
|
+
import { Settings } from '@dxos/react-ui-form';
|
|
13
14
|
import { setDeep } from '@dxos/util';
|
|
14
15
|
|
|
15
16
|
import { meta } from '../meta';
|
|
@@ -25,14 +26,19 @@ const StorageAdapters = {
|
|
|
25
26
|
idb: defs.Runtime.Client.Storage.StorageDriver.IDB,
|
|
26
27
|
} as const;
|
|
27
28
|
|
|
28
|
-
export
|
|
29
|
+
export type DebugSettingsComponentProps = {
|
|
30
|
+
settings: DebugSettingsProps;
|
|
31
|
+
onSettingsChange: (fn: (current: DebugSettingsProps) => DebugSettingsProps) => void;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const DebugSettings = ({ settings, onSettingsChange }: DebugSettingsComponentProps) => {
|
|
29
35
|
const { t } = useTranslation(meta.id);
|
|
30
36
|
const [toast, setToast] = useState<Toast>();
|
|
31
37
|
const client = useClient();
|
|
32
38
|
const download = useFileDownload();
|
|
33
39
|
// TODO(mykola): Get updates from other places that change Config.
|
|
34
40
|
const [storageConfig, setStorageConfig] = useState<ConfigProto>({});
|
|
35
|
-
const [upload] = useCapabilities(
|
|
41
|
+
const [upload] = useCapabilities(AppCapabilities.FileUploader);
|
|
36
42
|
|
|
37
43
|
useEffect(() => {
|
|
38
44
|
void Storage().then((config) => setStorageConfig(config));
|
|
@@ -46,22 +52,30 @@ export const DebugSettings = ({ settings }: { settings: DebugSettingsProps }) =>
|
|
|
46
52
|
|
|
47
53
|
const handleDownload = async () => {
|
|
48
54
|
const data = await client.diagnostics();
|
|
49
|
-
const file = new Blob([JSON.stringify(data, undefined, 2)], {
|
|
55
|
+
const file = new Blob([JSON.stringify(data, undefined, 2)], {
|
|
56
|
+
type: 'text/plain',
|
|
57
|
+
});
|
|
50
58
|
const fileName = `composer-${new Date().toISOString().replace(/\W/g, '-')}.json`;
|
|
51
59
|
download(file, fileName);
|
|
52
60
|
|
|
53
61
|
if (upload) {
|
|
54
|
-
const info = await upload(new File([file], fileName)
|
|
62
|
+
const info = await upload(client.spaces.default.db, new File([file], fileName));
|
|
55
63
|
if (!info) {
|
|
56
64
|
log.error('diagnostics failed to upload to IPFS');
|
|
57
65
|
return;
|
|
58
66
|
}
|
|
59
|
-
handleToast({
|
|
67
|
+
handleToast({
|
|
68
|
+
title: t('settings uploaded'),
|
|
69
|
+
description: t('settings uploaded to clipboard'),
|
|
70
|
+
});
|
|
60
71
|
|
|
61
72
|
// TODO(nf): move to IpfsPlugin?
|
|
62
73
|
const url = client.config.values.runtime!.services!.ipfs!.gateway + '/' + info.cid;
|
|
63
74
|
void navigator.clipboard.writeText(url);
|
|
64
|
-
handleToast({
|
|
75
|
+
handleToast({
|
|
76
|
+
title: t('settings uploaded'),
|
|
77
|
+
description: t('settings uploaded to clipboard'),
|
|
78
|
+
});
|
|
65
79
|
log.info('diagnostics', { url });
|
|
66
80
|
}
|
|
67
81
|
};
|
|
@@ -70,32 +84,44 @@ export const DebugSettings = ({ settings }: { settings: DebugSettingsProps }) =>
|
|
|
70
84
|
try {
|
|
71
85
|
const info = await client.repair();
|
|
72
86
|
setStorageConfig(await Storage());
|
|
73
|
-
handleToast({
|
|
87
|
+
handleToast({
|
|
88
|
+
title: t('settings repair success'),
|
|
89
|
+
description: JSON.stringify(info, undefined, 2),
|
|
90
|
+
});
|
|
74
91
|
} catch (err: any) {
|
|
75
|
-
handleToast({
|
|
92
|
+
handleToast({
|
|
93
|
+
title: t('settings repair failed'),
|
|
94
|
+
description: err.message,
|
|
95
|
+
});
|
|
76
96
|
}
|
|
77
97
|
};
|
|
78
98
|
|
|
79
99
|
return (
|
|
80
|
-
<
|
|
81
|
-
<
|
|
82
|
-
<
|
|
83
|
-
<
|
|
100
|
+
<Settings.Root>
|
|
101
|
+
<Settings.Section title={t('settings title', { ns: meta.id })}>
|
|
102
|
+
<Settings.Group>
|
|
103
|
+
<Settings.ItemInput title={t('settings wireframe')}>
|
|
84
104
|
<Input.Switch
|
|
85
105
|
checked={settings.wireframe}
|
|
86
|
-
onCheckedChange={(checked) => (
|
|
106
|
+
onCheckedChange={(checked) => onSettingsChange((s) => ({ ...s, wireframe: !!checked }))}
|
|
107
|
+
/>
|
|
108
|
+
</Settings.ItemInput>
|
|
109
|
+
<Settings.ItemInput title={t('settings download diagnostics')}>
|
|
110
|
+
<IconButton
|
|
111
|
+
icon='ph--download-simple--regular'
|
|
112
|
+
iconOnly
|
|
113
|
+
label={t('settings download diagnostics')}
|
|
114
|
+
onClick={handleDownload}
|
|
115
|
+
/>
|
|
116
|
+
</Settings.ItemInput>
|
|
117
|
+
<Settings.ItemInput title={t('settings repair')}>
|
|
118
|
+
<IconButton
|
|
119
|
+
icon='ph--first-aid-kit--regular'
|
|
120
|
+
iconOnly
|
|
121
|
+
label={t('settings repair')}
|
|
122
|
+
onClick={handleRepair}
|
|
87
123
|
/>
|
|
88
|
-
</
|
|
89
|
-
<ControlItemInput title={t('settings download diagnostics')}>
|
|
90
|
-
<Button onClick={handleDownload}>
|
|
91
|
-
<Icon icon='ph--download-simple--regular' size={5} />
|
|
92
|
-
</Button>
|
|
93
|
-
</ControlItemInput>
|
|
94
|
-
<ControlItemInput title={t('settings repair')}>
|
|
95
|
-
<Button onClick={handleRepair}>
|
|
96
|
-
<Icon icon='ph--first-aid-kit--regular' size={5} />
|
|
97
|
-
</Button>
|
|
98
|
-
</ControlItemInput>
|
|
124
|
+
</Settings.ItemInput>
|
|
99
125
|
|
|
100
126
|
{/* TODO(burdon): Move to layout? */}
|
|
101
127
|
{toast && (
|
|
@@ -110,11 +136,11 @@ export const DebugSettings = ({ settings }: { settings: DebugSettingsProps }) =>
|
|
|
110
136
|
</Toast.Root>
|
|
111
137
|
)}
|
|
112
138
|
|
|
113
|
-
<
|
|
139
|
+
<Settings.ItemInput title={t('settings choose storage adaptor')}>
|
|
114
140
|
<Select.Root
|
|
115
141
|
value={
|
|
116
142
|
Object.entries(StorageAdapters).find(
|
|
117
|
-
([
|
|
143
|
+
([_name, value]) => value === storageConfig?.runtime?.client?.storage?.dataStore,
|
|
118
144
|
)?.[0]
|
|
119
145
|
}
|
|
120
146
|
onValueChange={(value) => {
|
|
@@ -142,10 +168,10 @@ export const DebugSettings = ({ settings }: { settings: DebugSettingsProps }) =>
|
|
|
142
168
|
</Select.Content>
|
|
143
169
|
</Select.Portal>
|
|
144
170
|
</Select.Root>
|
|
145
|
-
</
|
|
146
|
-
</
|
|
147
|
-
</
|
|
148
|
-
</
|
|
171
|
+
</Settings.ItemInput>
|
|
172
|
+
</Settings.Group>
|
|
173
|
+
</Settings.Section>
|
|
174
|
+
</Settings.Root>
|
|
149
175
|
);
|
|
150
176
|
};
|
|
151
177
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { Surface } from '@dxos/app-framework';
|
|
7
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
8
8
|
import { StatsPanel, useStats } from '@dxos/devtools';
|
|
9
9
|
|
|
10
10
|
export const DevtoolsOverviewContainer = () => {
|
|
@@ -12,7 +12,7 @@ export const DevtoolsOverviewContainer = () => {
|
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
14
|
<StatsPanel stats={stats} onRefresh={refreshStats}>
|
|
15
|
-
<Surface role='devtools-overview' />
|
|
15
|
+
<Surface.Surface role='devtools-overview' />
|
|
16
16
|
</StatsPanel>
|
|
17
17
|
);
|
|
18
18
|
};
|
|
@@ -2,47 +2,47 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import type * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
6
7
|
import { addressToA1Notation } from '@dxos/compute';
|
|
7
8
|
import { ComputeGraph, ComputeGraphModel, DEFAULT_OUTPUT, NODE_INPUT, NODE_OUTPUT } from '@dxos/conductor';
|
|
8
|
-
import { DXN, Filter, Key,
|
|
9
|
-
import { type
|
|
9
|
+
import { DXN, Filter, Key, type Type } from '@dxos/echo';
|
|
10
|
+
import { type OperationInvoker } from '@dxos/operation';
|
|
10
11
|
import { Markdown } from '@dxos/plugin-markdown/types';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
12
|
+
import { Sheet } from '@dxos/plugin-sheet/types';
|
|
13
|
+
import { Diagram } from '@dxos/plugin-sketch/types';
|
|
14
|
+
import { SpaceOperation } from '@dxos/plugin-space/types';
|
|
15
15
|
import { faker } from '@dxos/random';
|
|
16
16
|
import { type Client } from '@dxos/react-client';
|
|
17
17
|
import { type Space } from '@dxos/react-client/echo';
|
|
18
|
-
import {
|
|
18
|
+
import { View, getTypenameFromQuery } from '@dxos/schema';
|
|
19
19
|
import { type ValueGenerator, createAsyncGenerator } from '@dxos/schema/testing';
|
|
20
20
|
import { range } from '@dxos/util';
|
|
21
21
|
|
|
22
22
|
const generator: ValueGenerator = faker as any;
|
|
23
23
|
|
|
24
|
-
const findViewByTypename = async (views:
|
|
24
|
+
const findViewByTypename = async (views: View.View[], typename: string) => {
|
|
25
25
|
return views.find((view) => getTypenameFromQuery(view.query.ast) === typename);
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
export type ObjectGenerator<T
|
|
28
|
+
export type ObjectGenerator<T> = (space: Space, n: number, cb?: (objects: T[]) => void) => Promise<T[]>;
|
|
29
29
|
|
|
30
|
-
export const createGenerator = <
|
|
30
|
+
export const createGenerator = <S extends Type.Obj.Any>(
|
|
31
31
|
client: Client,
|
|
32
|
-
|
|
33
|
-
schema:
|
|
34
|
-
): ObjectGenerator<
|
|
35
|
-
return async (space: Space, n: number): Promise<
|
|
32
|
+
invokePromise: OperationInvoker.OperationInvoker['invokePromise'],
|
|
33
|
+
schema: S,
|
|
34
|
+
): ObjectGenerator<Schema.Schema.Type<S>> => {
|
|
35
|
+
return async (space: Space, n: number): Promise<Schema.Schema.Type<S>[]> => {
|
|
36
36
|
const typename = schema.typename;
|
|
37
37
|
|
|
38
38
|
// Find or create table and view.
|
|
39
|
-
const
|
|
39
|
+
const views = await space.db.query(Filter.type(View.View)).run();
|
|
40
40
|
const view = await findViewByTypename(views, typename);
|
|
41
|
-
const staticSchema = client?.graph.schemaRegistry.
|
|
41
|
+
const staticSchema = client?.graph.schemaRegistry.query({ typename }).runSync()[0];
|
|
42
42
|
if (!view && !staticSchema) {
|
|
43
|
-
await
|
|
43
|
+
await invokePromise(SpaceOperation.AddSchema, { db: space.db, schema, show: false });
|
|
44
44
|
} else if (!view && staticSchema) {
|
|
45
|
-
await
|
|
45
|
+
await invokePromise(SpaceOperation.UseStaticSchema, { db: space.db, typename, show: false });
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
// Create objects.
|
|
@@ -57,7 +57,7 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
|
|
|
57
57
|
async (space, n, cb) => {
|
|
58
58
|
const objects = range(n).map(() => {
|
|
59
59
|
return space.db.add(
|
|
60
|
-
Markdown.
|
|
60
|
+
Markdown.make({
|
|
61
61
|
name: faker.commerce.productName(),
|
|
62
62
|
content: faker.lorem.sentences(5),
|
|
63
63
|
}),
|
|
@@ -69,17 +69,10 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
|
|
|
69
69
|
},
|
|
70
70
|
],
|
|
71
71
|
[
|
|
72
|
-
|
|
72
|
+
Diagram.Diagram.typename,
|
|
73
73
|
async (space, n, cb) => {
|
|
74
74
|
const objects = range(n).map(() => {
|
|
75
|
-
|
|
76
|
-
const obj = space.db.add(
|
|
77
|
-
Obj.make(DiagramType, {
|
|
78
|
-
name: faker.commerce.productName(),
|
|
79
|
-
canvas: Ref.make(Obj.make(CanvasType, { content: {} })),
|
|
80
|
-
}),
|
|
81
|
-
);
|
|
82
|
-
|
|
75
|
+
const obj = space.db.add(Diagram.make({ name: faker.commerce.productName() }));
|
|
83
76
|
return obj;
|
|
84
77
|
});
|
|
85
78
|
|
|
@@ -89,10 +82,10 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
|
|
|
89
82
|
],
|
|
90
83
|
// TODO(burdon): Create unit tests.
|
|
91
84
|
[
|
|
92
|
-
|
|
85
|
+
Sheet.Sheet.typename,
|
|
93
86
|
async (space, n, cb) => {
|
|
94
87
|
const objects = range(n).map(() => {
|
|
95
|
-
const cells: Record<string, CellValue> = {};
|
|
88
|
+
const cells: Record<string, Sheet.CellValue> = {};
|
|
96
89
|
const year = new Date().getFullYear();
|
|
97
90
|
const cols = 4;
|
|
98
91
|
const rows = 16;
|
|
@@ -114,7 +107,7 @@ export const staticGenerators = new Map<string, ObjectGenerator<any>>([
|
|
|
114
107
|
// TODO(burdon): Set width.
|
|
115
108
|
// TODO(burdon): Set formatting for columns.
|
|
116
109
|
return space.db.add(
|
|
117
|
-
|
|
110
|
+
Sheet.make({
|
|
118
111
|
name: faker.commerce.productName(),
|
|
119
112
|
cells,
|
|
120
113
|
}),
|
|
@@ -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='
|
|
23
|
-
<div className='
|
|
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>
|
|
24
24
|
<IconButton
|
|
25
25
|
variant='ghost'
|
|
26
26
|
icon='ph--plus--regular'
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
6
7
|
import React from 'react';
|
|
7
8
|
|
|
8
|
-
import {
|
|
9
|
+
import { OperationPlugin } from '@dxos/app-framework';
|
|
9
10
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
10
11
|
import { ClientPlugin } from '@dxos/plugin-client';
|
|
11
12
|
import { useSpaces } from '@dxos/react-client/echo';
|
|
@@ -28,15 +29,16 @@ const meta = {
|
|
|
28
29
|
component: SpaceGenerator as any,
|
|
29
30
|
render: render(DefaultStory),
|
|
30
31
|
decorators: [
|
|
31
|
-
withTheme,
|
|
32
|
+
withTheme(),
|
|
32
33
|
withPluginManager({
|
|
33
34
|
plugins: [
|
|
34
35
|
ClientPlugin({
|
|
35
|
-
onClientInitialized:
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
onClientInitialized: ({ client }) =>
|
|
37
|
+
Effect.gen(function* () {
|
|
38
|
+
yield* Effect.promise(() => client.halo.createIdentity());
|
|
39
|
+
}),
|
|
38
40
|
}),
|
|
39
|
-
|
|
41
|
+
OperationPlugin(),
|
|
40
42
|
],
|
|
41
43
|
}),
|
|
42
44
|
],
|
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { useOperationInvoker } from '@dxos/app-framework/ui';
|
|
8
8
|
import { ComputeGraph } from '@dxos/conductor';
|
|
9
|
-
import { Filter, type
|
|
9
|
+
import { Filter, Obj, type Type } from '@dxos/echo';
|
|
10
10
|
import { Markdown } from '@dxos/plugin-markdown/types';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { Sheet } from '@dxos/plugin-sheet/types';
|
|
12
|
+
import { Diagram } from '@dxos/plugin-sketch/types';
|
|
13
13
|
import { useClient } from '@dxos/react-client';
|
|
14
|
-
import { type Space
|
|
15
|
-
import { IconButton, Input, Toolbar, useAsyncEffect } from '@dxos/react-ui';
|
|
14
|
+
import { type Space } from '@dxos/react-client/echo';
|
|
15
|
+
import { IconButton, Input, Layout, ScrollArea, Toolbar, useAsyncEffect } from '@dxos/react-ui';
|
|
16
16
|
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
17
|
-
import {
|
|
17
|
+
import { Organization, Person, Task } from '@dxos/types';
|
|
18
18
|
import { jsonKeyReplacer, sortKeys } from '@dxos/util';
|
|
19
19
|
|
|
20
20
|
import { type ObjectGenerator, createGenerator, staticGenerators } from './ObjectGenerator';
|
|
@@ -23,43 +23,48 @@ import { SchemaTable } from './SchemaTable';
|
|
|
23
23
|
|
|
24
24
|
export type SpaceGeneratorProps = {
|
|
25
25
|
space: Space;
|
|
26
|
-
onCreateObjects?: (objects: Obj.
|
|
26
|
+
onCreateObjects?: (objects: Obj.Unknown[]) => void;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps) => {
|
|
30
|
-
const {
|
|
30
|
+
const { invokePromise } = useOperationInvoker();
|
|
31
31
|
const client = useClient();
|
|
32
|
-
const staticTypes = [Markdown.Document,
|
|
33
|
-
const recordTypes = [
|
|
32
|
+
const staticTypes = [Markdown.Document, Diagram.Diagram, Sheet.Sheet, ComputeGraph]; // TODO(burdon): Make extensible.
|
|
33
|
+
const recordTypes: Type.Obj.Any[] = [Organization.Organization, Person.Person, Task.Task];
|
|
34
34
|
const [count, setCount] = useState(1);
|
|
35
35
|
const [info, setInfo] = useState<any>({});
|
|
36
36
|
const presets = useMemo(() => generator(), []);
|
|
37
37
|
|
|
38
|
+
// Register types.
|
|
39
|
+
useAsyncEffect(async () => {
|
|
40
|
+
await client.addTypes([...staticTypes, ...recordTypes, ...presets.schemas]);
|
|
41
|
+
}, [client]);
|
|
42
|
+
|
|
38
43
|
// Create type generators.
|
|
39
44
|
const typeMap = useMemo(() => {
|
|
40
|
-
client.addTypes([...staticTypes, ...recordTypes, ...presets.schemas]);
|
|
41
45
|
const recordGenerators = new Map<string, ObjectGenerator<any>>(
|
|
42
|
-
recordTypes.map((type) => [type.typename, createGenerator(client,
|
|
46
|
+
recordTypes.map((type) => [type.typename, createGenerator(client, invokePromise, type)]),
|
|
43
47
|
);
|
|
44
48
|
|
|
45
49
|
return new Map([...staticGenerators, ...presets.items, ...recordGenerators]);
|
|
46
|
-
}, [client, recordTypes]);
|
|
50
|
+
}, [client, recordTypes, invokePromise]);
|
|
47
51
|
|
|
48
52
|
// Query space to get info.
|
|
49
53
|
const updateInfo = async () => {
|
|
50
54
|
// Create schema map.
|
|
51
55
|
const echoSchema = await space.db.schemaRegistry.query().run();
|
|
52
|
-
const staticSchema = space.db.graph.schemaRegistry.
|
|
56
|
+
const staticSchema = await space.db.graph.schemaRegistry.query().run();
|
|
53
57
|
|
|
54
58
|
// Create object map.
|
|
55
|
-
const
|
|
59
|
+
const objects = await space.db.query(Filter.everything()).run();
|
|
56
60
|
const objectMap = sortKeys(
|
|
57
61
|
objects.reduce<Record<string, number>>((map, obj) => {
|
|
58
|
-
const type = getTypename(obj);
|
|
62
|
+
const type = Obj.getTypename(obj);
|
|
59
63
|
if (type) {
|
|
60
64
|
const count = map[type] ?? 0;
|
|
61
65
|
map[type] = count + 1;
|
|
62
66
|
}
|
|
67
|
+
|
|
63
68
|
return map;
|
|
64
69
|
}, {}),
|
|
65
70
|
);
|
|
@@ -88,35 +93,34 @@ export const SpaceGenerator = ({ space, onCreateObjects }: SpaceGeneratorProps)
|
|
|
88
93
|
);
|
|
89
94
|
|
|
90
95
|
return (
|
|
91
|
-
<
|
|
92
|
-
<Toolbar.Root
|
|
96
|
+
<Layout.Main toolbar>
|
|
97
|
+
<Toolbar.Root>
|
|
93
98
|
<IconButton icon='ph--arrow-clockwise--regular' iconOnly label='Refresh' onClick={updateInfo} />
|
|
94
99
|
<Toolbar.Separator variant='gap' />
|
|
95
100
|
<Input.Root>
|
|
96
101
|
<Input.TextInput
|
|
97
102
|
type='number'
|
|
103
|
+
placeholder='Count'
|
|
104
|
+
classNames='is-[4rem] text-right'
|
|
98
105
|
min={1}
|
|
99
106
|
max={100}
|
|
100
|
-
placeholder={'Count'}
|
|
101
|
-
classNames='!w-[4rem] !text-right'
|
|
102
107
|
size={8}
|
|
103
108
|
value={count}
|
|
104
|
-
onChange={(
|
|
109
|
+
onChange={(event) => setCount(parseInt(event.target.value))}
|
|
105
110
|
/>
|
|
106
111
|
</Input.Root>
|
|
107
112
|
</Toolbar.Root>
|
|
108
113
|
|
|
109
|
-
<
|
|
110
|
-
<
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
<div>
|
|
114
|
+
<ScrollArea.Root thin orientation='vertical'>
|
|
115
|
+
<ScrollArea.Viewport classNames='gap-4 divide-y divide-subduedSeparator'>
|
|
116
|
+
<SchemaTable types={staticTypes} objects={info.objects} label='Static Types' onClick={handleCreateData} />
|
|
117
|
+
<SchemaTable types={recordTypes} objects={info.objects} label='Record Types' onClick={handleCreateData} />
|
|
118
|
+
<SchemaTable types={presets.types} objects={info.objects} label='Presets' onClick={handleCreateData} />
|
|
115
119
|
<SyntaxHighlighter language='json' classNames='text-xs'>
|
|
116
120
|
{JSON.stringify({ space, ...info }, jsonKeyReplacer({ truncate: true }), 2)}
|
|
117
121
|
</SyntaxHighlighter>
|
|
118
|
-
</
|
|
119
|
-
</
|
|
120
|
-
</
|
|
122
|
+
</ScrollArea.Viewport>
|
|
123
|
+
</ScrollArea.Root>
|
|
124
|
+
</Layout.Main>
|
|
121
125
|
);
|
|
122
126
|
};
|