@dxos/plugin-explorer 0.8.1 → 0.8.2-main.10c050d
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/ExplorerContainer-BBZ54DJS.mjs +37 -0
- package/dist/lib/browser/ExplorerContainer-BBZ54DJS.mjs.map +7 -0
- package/dist/lib/browser/{chunk-B2DMPSP5.mjs → chunk-73GQ46YO.mjs} +430 -170
- package/dist/lib/{node-esm/chunk-PZOORWFE.mjs.map → browser/chunk-73GQ46YO.mjs.map} +4 -4
- package/dist/lib/browser/{chunk-QLQLPZNI.mjs → chunk-73YTQHOT.mjs} +12 -11
- package/dist/lib/browser/chunk-73YTQHOT.mjs.map +7 -0
- package/dist/lib/browser/chunk-M2BGAY6H.mjs +177 -0
- package/dist/lib/browser/chunk-M2BGAY6H.mjs.map +7 -0
- package/dist/lib/browser/{chunk-Z2SDLMQM.mjs → chunk-OBAFAA5V.mjs} +3 -3
- package/dist/lib/browser/{chunk-Z2SDLMQM.mjs.map → chunk-OBAFAA5V.mjs.map} +1 -1
- package/dist/lib/browser/chunk-SLB2F5AO.mjs +30 -0
- package/dist/lib/browser/chunk-SLB2F5AO.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +15 -11
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/{intent-resolver-NHHRWTOP.mjs → intent-resolver-FJDVBDE3.mjs} +5 -5
- package/dist/lib/browser/intent-resolver-FJDVBDE3.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -1
- package/dist/lib/browser/{react-surface-N7TC6BMF.mjs → react-surface-H3YDMXAQ.mjs} +5 -5
- package/dist/lib/browser/types/index.mjs +2 -2
- package/dist/lib/node/{ExplorerContainer-73AHSBAG.cjs → ExplorerContainer-MVP2AM7R.cjs} +24 -16
- package/dist/lib/node/ExplorerContainer-MVP2AM7R.cjs.map +7 -0
- package/dist/lib/node/chunk-4T4LCT5R.cjs +52 -0
- package/dist/lib/node/chunk-4T4LCT5R.cjs.map +7 -0
- package/dist/lib/node/{chunk-HCDBN6NN.cjs → chunk-72H5HBTK.cjs} +429 -168
- package/dist/lib/node/chunk-72H5HBTK.cjs.map +7 -0
- package/dist/lib/node/{chunk-VB3QE6XY.cjs → chunk-BCDVG2CH.cjs} +6 -6
- package/dist/lib/node/{chunk-VB3QE6XY.cjs.map → chunk-BCDVG2CH.cjs.map} +1 -1
- package/dist/lib/node/{chunk-YLL7H7CZ.cjs → chunk-MLRYW4WQ.cjs} +15 -14
- package/dist/lib/node/chunk-MLRYW4WQ.cjs.map +7 -0
- package/dist/lib/node/chunk-NELWWGBU.cjs +204 -0
- package/dist/lib/node/chunk-NELWWGBU.cjs.map +7 -0
- package/dist/lib/node/index.cjs +34 -31
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/{intent-resolver-EEOTX3OZ.cjs → intent-resolver-DRT67ZU4.cjs} +8 -8
- package/dist/lib/node/intent-resolver-DRT67ZU4.cjs.map +7 -0
- package/dist/lib/node/meta.cjs +3 -3
- package/dist/lib/node/meta.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-WD4G2NRS.cjs → react-surface-6ESLSM33.cjs} +11 -11
- package/dist/lib/node/types/index.cjs +4 -4
- package/dist/lib/node/types/index.cjs.map +1 -1
- package/dist/lib/node-esm/ExplorerContainer-APGUQI4M.mjs +38 -0
- package/dist/lib/node-esm/ExplorerContainer-APGUQI4M.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-PZOORWFE.mjs → chunk-34X2VFQN.mjs} +430 -169
- package/dist/lib/{browser/chunk-B2DMPSP5.mjs.map → node-esm/chunk-34X2VFQN.mjs.map} +4 -4
- package/dist/lib/node-esm/{chunk-PUFSCMN4.mjs → chunk-3CMBLK6W.mjs} +3 -3
- package/dist/lib/node-esm/{chunk-PUFSCMN4.mjs.map → chunk-3CMBLK6W.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-QZH2GDN5.mjs → chunk-N6VEANUZ.mjs} +12 -11
- package/dist/lib/node-esm/chunk-N6VEANUZ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-PVII2K2B.mjs +179 -0
- package/dist/lib/node-esm/chunk-PVII2K2B.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-VSORIAHH.mjs +32 -0
- package/dist/lib/node-esm/chunk-VSORIAHH.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +15 -11
- package/dist/lib/node-esm/index.mjs.map +1 -1
- package/dist/lib/node-esm/{intent-resolver-PTFKXAT4.mjs → intent-resolver-4RBV644N.mjs} +5 -5
- package/dist/lib/node-esm/intent-resolver-4RBV644N.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/meta.mjs +1 -1
- package/dist/lib/node-esm/{react-surface-J5SW7VF2.mjs → react-surface-ZEVL3FXG.mjs} +5 -5
- package/dist/lib/node-esm/types/index.mjs +2 -2
- package/dist/types/src/components/Chart/Chart.d.ts.map +1 -1
- package/dist/types/src/components/ExplorerContainer.d.ts +4 -3
- package/dist/types/src/components/ExplorerContainer.d.ts.map +1 -1
- package/dist/types/src/components/Globe/Globe.d.ts.map +1 -1
- package/dist/types/src/components/Graph/D3ForceGraph.d.ts +14 -0
- package/dist/types/src/components/Graph/D3ForceGraph.d.ts.map +1 -0
- package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts +6 -0
- package/dist/types/src/components/Graph/D3ForceGraph.stories.d.ts.map +1 -0
- package/dist/types/src/components/Graph/ForceGraph.d.ts +8 -0
- package/dist/types/src/components/Graph/ForceGraph.d.ts.map +1 -0
- package/dist/types/src/components/Graph/{Graph.stories.d.ts → ForceGraph.stories.d.ts} +1 -1
- package/dist/types/src/components/Graph/ForceGraph.stories.d.ts.map +1 -0
- package/dist/types/src/components/Graph/adapter.d.ts +21 -0
- package/dist/types/src/components/Graph/adapter.d.ts.map +1 -0
- package/dist/types/src/components/Graph/index.d.ts +2 -2
- package/dist/types/src/components/Graph/index.d.ts.map +1 -1
- package/dist/types/src/components/Graph/testing.d.ts +14 -0
- package/dist/types/src/components/Graph/testing.d.ts.map +1 -0
- package/dist/types/src/components/Tree/Tree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/layout/HierarchicalEdgeBundling.d.ts.map +1 -1
- package/dist/types/src/components/Tree/layout/RadialTree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/layout/TidyTree.d.ts.map +1 -1
- package/dist/types/src/components/Tree/testing/generator.d.ts +8 -0
- package/dist/types/src/components/Tree/testing/generator.d.ts.map +1 -0
- package/dist/types/src/components/Tree/testing/index.d.ts +2 -0
- package/dist/types/src/components/Tree/testing/index.d.ts.map +1 -0
- package/dist/types/src/components/Tree/types/index.d.ts +3 -0
- package/dist/types/src/components/Tree/types/index.d.ts.map +1 -0
- package/dist/types/src/components/Tree/types/tree.d.ts +83 -0
- package/dist/types/src/components/Tree/types/tree.d.ts.map +1 -0
- package/dist/types/src/components/Tree/types/tree.test.d.ts +2 -0
- package/dist/types/src/components/Tree/types/tree.test.d.ts.map +1 -0
- package/dist/types/src/components/Tree/types/types.d.ts +8 -0
- package/dist/types/src/components/Tree/types/types.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +2 -2
- package/dist/types/src/components/plot.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +2 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useGraphModel.d.ts +4 -0
- package/dist/types/src/hooks/useGraphModel.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +2 -8
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +6 -6
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +6 -6
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +30 -27
- package/src/capabilities/intent-resolver.ts +2 -2
- package/src/components/ExplorerContainer.tsx +11 -4
- package/src/components/Globe/Globe.stories.tsx +13 -13
- package/src/components/Graph/D3ForceGraph.stories.tsx +64 -0
- package/src/components/Graph/D3ForceGraph.tsx +101 -0
- package/src/components/Graph/ForceGraph.stories.tsx +64 -0
- package/src/components/Graph/{Graph.tsx → ForceGraph.tsx} +19 -26
- package/src/components/Graph/adapter.ts +47 -0
- package/src/components/Graph/index.ts +2 -3
- package/src/components/Graph/testing.ts +57 -0
- package/src/components/Tree/Tree.stories.tsx +1 -1
- package/src/components/Tree/Tree.tsx +11 -18
- package/src/components/Tree/layout/HierarchicalEdgeBundling.ts +17 -19
- package/src/components/Tree/layout/RadialTree.ts +5 -7
- package/src/components/Tree/layout/TidyTree.ts +5 -6
- package/src/components/Tree/testing/generator.ts +46 -0
- package/src/components/Tree/testing/index.ts +5 -0
- package/src/components/Tree/types/index.ts +6 -0
- package/src/components/Tree/types/tree.test.ts +133 -0
- package/src/components/Tree/types/tree.ts +287 -0
- package/src/components/Tree/types/types.ts +41 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/useGraphModel.ts +35 -0
- package/src/index.ts +2 -2
- package/src/meta.ts +2 -2
- package/src/types/schema.ts +5 -3
- package/src/types/types.ts +5 -5
- package/dist/lib/browser/ExplorerContainer-HL532ODG.mjs +0 -27
- package/dist/lib/browser/ExplorerContainer-HL532ODG.mjs.map +0 -7
- package/dist/lib/browser/chunk-QLQLPZNI.mjs.map +0 -7
- package/dist/lib/browser/chunk-SBLNE7FL.mjs +0 -205
- package/dist/lib/browser/chunk-SBLNE7FL.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-NHHRWTOP.mjs.map +0 -7
- package/dist/lib/node/ExplorerContainer-73AHSBAG.cjs.map +0 -7
- package/dist/lib/node/chunk-HCDBN6NN.cjs.map +0 -7
- package/dist/lib/node/chunk-OIHH6TVE.cjs +0 -236
- package/dist/lib/node/chunk-OIHH6TVE.cjs.map +0 -7
- package/dist/lib/node/chunk-YLL7H7CZ.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-EEOTX3OZ.cjs.map +0 -7
- package/dist/lib/node-esm/ExplorerContainer-NMI55PYM.mjs +0 -28
- package/dist/lib/node-esm/ExplorerContainer-NMI55PYM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QZH2GDN5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SZRRNWYT.mjs +0 -207
- package/dist/lib/node-esm/chunk-SZRRNWYT.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-PTFKXAT4.mjs.map +0 -7
- package/dist/types/src/components/Graph/Graph.d.ts +0 -8
- package/dist/types/src/components/Graph/Graph.d.ts.map +0 -1
- package/dist/types/src/components/Graph/Graph.stories.d.ts.map +0 -1
- package/dist/types/src/components/Graph/graph-model.d.ts +0 -39
- package/dist/types/src/components/Graph/graph-model.d.ts.map +0 -1
- package/dist/types/src/components/Tree/types.d.ts +0 -8
- package/dist/types/src/components/Tree/types.d.ts.map +0 -1
- package/src/components/Graph/Graph.stories.tsx +0 -62
- package/src/components/Graph/graph-model.ts +0 -193
- package/src/components/Tree/types.ts +0 -40
- /package/dist/lib/browser/{react-surface-N7TC6BMF.mjs.map → react-surface-H3YDMXAQ.mjs.map} +0 -0
- /package/dist/lib/node/{react-surface-WD4G2NRS.cjs.map → react-surface-6ESLSM33.cjs.map} +0 -0
- /package/dist/lib/node-esm/{react-surface-J5SW7VF2.mjs.map → react-surface-ZEVL3FXG.mjs.map} +0 -0
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { type GraphData, GraphModel } from '@dxos/gem-spore';
|
|
2
|
-
import { type ReactiveEchoObject, type Space } from '@dxos/react-client/echo';
|
|
3
|
-
export type SpaceGraphModelOptions = {
|
|
4
|
-
schema?: boolean;
|
|
5
|
-
};
|
|
6
|
-
type SchemaGraphNode = {
|
|
7
|
-
id: string;
|
|
8
|
-
type: 'schema';
|
|
9
|
-
data: {
|
|
10
|
-
typename: string;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
type ObjectGraphNode = {
|
|
14
|
-
id: string;
|
|
15
|
-
type: 'object';
|
|
16
|
-
data: {
|
|
17
|
-
typename: string;
|
|
18
|
-
object: ReactiveEchoObject<any>;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
export type EchoGraphNode = SchemaGraphNode | ObjectGraphNode;
|
|
22
|
-
/**
|
|
23
|
-
* Converts ECHO objects to a graph.
|
|
24
|
-
*/
|
|
25
|
-
export declare class SpaceGraphModel extends GraphModel<EchoGraphNode> {
|
|
26
|
-
private readonly _options;
|
|
27
|
-
private readonly _graph;
|
|
28
|
-
private _schema?;
|
|
29
|
-
private _schemaSubscription?;
|
|
30
|
-
private _objects?;
|
|
31
|
-
private _objectsSubscription?;
|
|
32
|
-
constructor(_options?: SpaceGraphModelOptions);
|
|
33
|
-
get graph(): GraphData<EchoGraphNode>;
|
|
34
|
-
get objects(): ReactiveEchoObject<any>[];
|
|
35
|
-
open(space: Space, objectId?: string): Promise<this>;
|
|
36
|
-
close(): this;
|
|
37
|
-
}
|
|
38
|
-
export {};
|
|
39
|
-
//# sourceMappingURL=graph-model.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"graph-model.d.ts","sourceRoot":"","sources":["../../../../../src/components/Graph/graph-model.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,SAAS,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7D,OAAO,EAAU,KAAK,kBAAkB,EAAE,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEtF,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAIF,KAAK,eAAe,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5B,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG,CAAC,CAAA;KAAE,CAAC;CAC7D,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG,eAAe,CAAC;AAE9D;;GAEG;AACH,qBAAa,eAAgB,SAAQ,UAAU,CAAC,aAAa,CAAC;IAWhD,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAVrC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAGrB;IAEF,OAAO,CAAC,OAAO,CAAC,CAAe;IAC/B,OAAO,CAAC,mBAAmB,CAAC,CAAY;IACxC,OAAO,CAAC,QAAQ,CAAC,CAA4B;IAC7C,OAAO,CAAC,oBAAoB,CAAC,CAAY;gBAEZ,QAAQ,GAAE,sBAA2B;IAIlE,IAAa,KAAK,IAAI,SAAS,CAAC,aAAa,CAAC,CAE7C;IAED,IAAI,OAAO,IAAI,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAEvC;IASK,IAAI,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,CAAC,EAAE,MAAM;IAgH1C,KAAK;CAQN"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type GraphModel } from '@dxos/gem-spore';
|
|
2
|
-
export type TreeNode = {
|
|
3
|
-
id: string;
|
|
4
|
-
label?: string;
|
|
5
|
-
children?: TreeNode[];
|
|
6
|
-
};
|
|
7
|
-
export declare const mapGraphToTreeData: <N>(model: GraphModel<N>, maxDepth?: number) => TreeNode | undefined;
|
|
8
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/components/Tree/types.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,wBAAiB,QAAQ,GAAG,SA0BrF,CAAC"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
|
-
import { type Meta } from '@storybook/react';
|
|
8
|
-
import React, { useEffect, useState } from 'react';
|
|
9
|
-
|
|
10
|
-
import { createSpaceObjectGenerator, TestSchemaType } from '@dxos/echo-generator';
|
|
11
|
-
import { faker } from '@dxos/random';
|
|
12
|
-
import { useClient } from '@dxos/react-client';
|
|
13
|
-
import { create } from '@dxos/react-client/echo';
|
|
14
|
-
import { type Space } from '@dxos/react-client/echo';
|
|
15
|
-
import { ClientRepeater } from '@dxos/react-client/testing';
|
|
16
|
-
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
17
|
-
|
|
18
|
-
import { Graph } from './Graph';
|
|
19
|
-
import { ViewType } from '../../types';
|
|
20
|
-
|
|
21
|
-
faker.seed(1);
|
|
22
|
-
|
|
23
|
-
const Story = () => {
|
|
24
|
-
const client = useClient();
|
|
25
|
-
const [space, setSpace] = useState<Space>();
|
|
26
|
-
const [view, setView] = useState<ViewType>();
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
const space = client.spaces.default;
|
|
29
|
-
const generator = createSpaceObjectGenerator(space);
|
|
30
|
-
queueMicrotask(async () => {
|
|
31
|
-
await generator.addSchemas();
|
|
32
|
-
await generator.createObjects({
|
|
33
|
-
[TestSchemaType.organization]: 20,
|
|
34
|
-
[TestSchemaType.contact]: 50,
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const view = space.db.add(create(ViewType, { name: '', type: '' }));
|
|
39
|
-
setSpace(space);
|
|
40
|
-
setView(view);
|
|
41
|
-
}, []);
|
|
42
|
-
|
|
43
|
-
if (!space || !view) {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return <Graph space={space} />;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const meta: Meta = {
|
|
51
|
-
title: 'plugins/plugin-explorer/Graph',
|
|
52
|
-
component: Graph,
|
|
53
|
-
render: () => <ClientRepeater component={Story} createSpace types={[ViewType]} />,
|
|
54
|
-
decorators: [withTheme, withLayout({ fullscreen: true })],
|
|
55
|
-
parameters: {
|
|
56
|
-
layout: 'fullscreen',
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export default meta;
|
|
61
|
-
|
|
62
|
-
export const Default = {};
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type CleanupFn } from '@dxos/async';
|
|
6
|
-
import {
|
|
7
|
-
getSchema,
|
|
8
|
-
getSchemaDXN,
|
|
9
|
-
AST,
|
|
10
|
-
type EchoSchema,
|
|
11
|
-
ReferenceAnnotationId,
|
|
12
|
-
SchemaValidator,
|
|
13
|
-
StoredSchema,
|
|
14
|
-
} from '@dxos/echo-schema';
|
|
15
|
-
import { type GraphData, GraphModel } from '@dxos/gem-spore';
|
|
16
|
-
import { log } from '@dxos/log';
|
|
17
|
-
import { CollectionType } from '@dxos/plugin-space/types';
|
|
18
|
-
import { Filter, type ReactiveEchoObject, type Space } from '@dxos/react-client/echo';
|
|
19
|
-
|
|
20
|
-
export type SpaceGraphModelOptions = {
|
|
21
|
-
schema?: boolean;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// TODO(burdon): Convert to common/graph.
|
|
25
|
-
|
|
26
|
-
type SchemaGraphNode = {
|
|
27
|
-
id: string;
|
|
28
|
-
type: 'schema';
|
|
29
|
-
data: { typename: string };
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
type ObjectGraphNode = {
|
|
33
|
-
id: string;
|
|
34
|
-
type: 'object';
|
|
35
|
-
data: { typename: string; object: ReactiveEchoObject<any> };
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export type EchoGraphNode = SchemaGraphNode | ObjectGraphNode;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Converts ECHO objects to a graph.
|
|
42
|
-
*/
|
|
43
|
-
export class SpaceGraphModel extends GraphModel<EchoGraphNode> {
|
|
44
|
-
private readonly _graph: GraphData<EchoGraphNode> = {
|
|
45
|
-
nodes: [],
|
|
46
|
-
links: [],
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
private _schema?: EchoSchema[];
|
|
50
|
-
private _schemaSubscription?: CleanupFn;
|
|
51
|
-
private _objects?: ReactiveEchoObject<any>[];
|
|
52
|
-
private _objectsSubscription?: CleanupFn;
|
|
53
|
-
|
|
54
|
-
constructor(private readonly _options: SpaceGraphModelOptions = {}) {
|
|
55
|
-
super();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
override get graph(): GraphData<EchoGraphNode> {
|
|
59
|
-
return this._graph;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
get objects(): ReactiveEchoObject<any>[] {
|
|
63
|
-
return this._objects ?? [];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// TODO(burdon): Alternative diagram types:
|
|
67
|
-
// - https://observablehq.com/@d3/radial-tree/2
|
|
68
|
-
// - https://observablehq.com/@d3/disjoint-force-directed-graph/2
|
|
69
|
-
// - https://observablehq.com/@mbostock/tadpoles
|
|
70
|
-
// - https://observablehq.com/@d3/psr-b1919-21
|
|
71
|
-
// - https://vasturiano.github.io/react-force-graph/example/basic (3D)
|
|
72
|
-
|
|
73
|
-
async open(space: Space, objectId?: string) {
|
|
74
|
-
// TODO(burdon): Factor out graph builder to lib (use common/graph abstraction).
|
|
75
|
-
if (!this._schemaSubscription) {
|
|
76
|
-
// TODO(burdon): Normalize unsubscribe callbacks and merge handlers.
|
|
77
|
-
// TODO(burdon): Trigger initial subscription update.
|
|
78
|
-
// TODO(burdon): Normalize subscription cb for objects, schema, etc.
|
|
79
|
-
|
|
80
|
-
const schemaaQuery = space.db.schemaRegistry.query({});
|
|
81
|
-
const schemas = await schemaaQuery.run();
|
|
82
|
-
const onSchemaUpdate = ({ results }: { results: EchoSchema[] }) => (this._schema = results);
|
|
83
|
-
this._schemaSubscription = schemaaQuery.subscribe(onSchemaUpdate);
|
|
84
|
-
onSchemaUpdate({ results: schemas });
|
|
85
|
-
|
|
86
|
-
this._objectsSubscription = space.db
|
|
87
|
-
// TODO(burdon): ERROR: Cannot mix type and or filters.
|
|
88
|
-
.query(Filter.not(Filter.or(Filter.schema(StoredSchema), Filter.schema(CollectionType))))
|
|
89
|
-
.subscribe(
|
|
90
|
-
({ objects }) => {
|
|
91
|
-
this._objects = objects;
|
|
92
|
-
|
|
93
|
-
// Merge with current nodes.
|
|
94
|
-
const currentNodes = this._graph.nodes;
|
|
95
|
-
|
|
96
|
-
this._graph.nodes = [];
|
|
97
|
-
this._graph.links = [];
|
|
98
|
-
|
|
99
|
-
const addSchema = (typename: string) => {
|
|
100
|
-
const current = currentNodes.find((node) => node.id === typename);
|
|
101
|
-
if (typename) {
|
|
102
|
-
this._graph.nodes.push({
|
|
103
|
-
...current,
|
|
104
|
-
id: typename,
|
|
105
|
-
type: 'schema',
|
|
106
|
-
data: { typename },
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
// Runtime schema.
|
|
112
|
-
space.db.graph.schemaRegistry.schemas.forEach((schema) => {
|
|
113
|
-
const typename = getSchemaDXN(schema)?.typename;
|
|
114
|
-
if (typename) {
|
|
115
|
-
addSchema(typename);
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
// Database Schema.
|
|
120
|
-
this._schema?.forEach((schema) => {
|
|
121
|
-
const typename = getSchemaDXN(schema)?.typename;
|
|
122
|
-
if (typename) {
|
|
123
|
-
addSchema(typename);
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
// Database Objects.
|
|
128
|
-
this._objects.forEach((object) => {
|
|
129
|
-
const schema = getSchema(object);
|
|
130
|
-
if (schema) {
|
|
131
|
-
const typename = getSchemaDXN(schema)?.typename;
|
|
132
|
-
if (typename) {
|
|
133
|
-
const current = currentNodes.find((node) => node.id === object.id);
|
|
134
|
-
this._graph.nodes.push({ ...current, id: object.id, type: 'object', data: { typename, object } });
|
|
135
|
-
|
|
136
|
-
// Link to schema.
|
|
137
|
-
const schemaNode = this._graph.nodes.find(
|
|
138
|
-
(node) => node.type === 'schema' && node.data.typename === typename,
|
|
139
|
-
);
|
|
140
|
-
if (schemaNode) {
|
|
141
|
-
this._graph.links.push({
|
|
142
|
-
id: `${object.id}-${schemaNode.id}`,
|
|
143
|
-
source: object.id,
|
|
144
|
-
target: schemaNode.id,
|
|
145
|
-
});
|
|
146
|
-
} else {
|
|
147
|
-
log.info('schema node not found', { typename });
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Link ot refs.
|
|
151
|
-
// TODO(burdon): This isn't working.
|
|
152
|
-
AST.getPropertySignatures(schema.ast).forEach((prop) => {
|
|
153
|
-
if (!SchemaValidator.hasTypeAnnotation(schema, prop.name.toString(), ReferenceAnnotationId)) {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const value = object[String(prop.name)];
|
|
158
|
-
if (value) {
|
|
159
|
-
const refs = Array.isArray(value) ? value : [value];
|
|
160
|
-
for (const ref of refs) {
|
|
161
|
-
if (objects.findIndex((obj) => obj.id === ref.id) !== -1) {
|
|
162
|
-
this._graph.links.push({
|
|
163
|
-
id: `${object.id}-${String(prop.name)}-${ref.id}`,
|
|
164
|
-
source: object.id,
|
|
165
|
-
target: ref.id,
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
this.triggerUpdate();
|
|
176
|
-
},
|
|
177
|
-
{ fire: true },
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
this.setSelected(objectId);
|
|
182
|
-
return this;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
close() {
|
|
186
|
-
this._schemaSubscription?.();
|
|
187
|
-
this._schemaSubscription = undefined;
|
|
188
|
-
this._objectsSubscription?.();
|
|
189
|
-
this._objectsSubscription = undefined;
|
|
190
|
-
|
|
191
|
-
return this;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
// TODO(burdon): Convert to common/graph.
|
|
6
|
-
import { type GraphModel } from '@dxos/gem-spore';
|
|
7
|
-
|
|
8
|
-
export type TreeNode = {
|
|
9
|
-
id: string;
|
|
10
|
-
label?: string;
|
|
11
|
-
children?: TreeNode[];
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const mapGraphToTreeData = <N>(model: GraphModel<N>, maxDepth = 8): TreeNode | undefined => {
|
|
15
|
-
const mapNode = (node: N, depth = 0): TreeNode => {
|
|
16
|
-
const treeNode: TreeNode = {
|
|
17
|
-
id: model.idAccessor(node),
|
|
18
|
-
label: model.idAccessor(node).slice(0, 8),
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const links = model.graph.links.filter((link) => link.source === treeNode.id);
|
|
22
|
-
if (depth < maxDepth) {
|
|
23
|
-
treeNode.children = links.map((link) =>
|
|
24
|
-
mapNode(model.graph.nodes.find((node) => model.idAccessor(node) === link.target)!, depth + 1),
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return treeNode;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
let data: TreeNode | undefined;
|
|
32
|
-
if (model.selected) {
|
|
33
|
-
const node = model.graph.nodes.find((node) => model.idAccessor(node) === model.selected);
|
|
34
|
-
if (node) {
|
|
35
|
-
data = mapNode(node);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return data;
|
|
40
|
-
};
|
|
File without changes
|
|
File without changes
|
/package/dist/lib/node-esm/{react-surface-J5SW7VF2.mjs.map → react-surface-ZEVL3FXG.mjs.map}
RENAMED
|
File without changes
|