@dxos/app-graph 0.8.2-staging.7ac8446 → 0.8.2
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/index.mjs +593 -794
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +585 -785
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +593 -794
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/experimental/graph-projections.test.d.ts +25 -0
- package/dist/types/src/experimental/graph-projections.test.d.ts.map +1 -0
- package/dist/types/src/graph-builder.d.ts +48 -91
- package/dist/types/src/graph-builder.d.ts.map +1 -1
- package/dist/types/src/graph.d.ts +191 -98
- package/dist/types/src/graph.d.ts.map +1 -1
- package/dist/types/src/node.d.ts +3 -3
- package/dist/types/src/node.d.ts.map +1 -1
- package/dist/types/src/signals-integration.test.d.ts +2 -0
- package/dist/types/src/signals-integration.test.d.ts.map +1 -0
- package/dist/types/src/stories/EchoGraph.stories.d.ts.map +1 -1
- package/dist/types/src/testing.d.ts +5 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +24 -17
- package/src/experimental/graph-projections.test.ts +56 -0
- package/src/graph-builder.test.ts +293 -310
- package/src/graph-builder.ts +235 -318
- package/src/graph.test.ts +314 -463
- package/src/graph.ts +452 -455
- package/src/node.ts +4 -4
- package/src/signals-integration.test.ts +218 -0
- package/src/stories/EchoGraph.stories.tsx +67 -76
- package/src/testing.ts +20 -0
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
import { Registry, Rx } from '@effect-rx/rx-react';
|
|
2
|
+
import { Option } from 'effect';
|
|
3
|
+
import { Event } from '@dxos/async';
|
|
1
4
|
import { type MakeOptional } from '@dxos/util';
|
|
2
|
-
import { type
|
|
5
|
+
import { type NodeArg, type Node, type Relation, type Action, type ActionGroup } from './node';
|
|
6
|
+
/**
|
|
7
|
+
* Get the Graph a Node is currently associated with.
|
|
8
|
+
*/
|
|
3
9
|
export declare const getGraph: (node: Node) => Graph;
|
|
4
10
|
export declare const ROOT_ID = "root";
|
|
5
11
|
export declare const ROOT_TYPE = "dxos.org/type/GraphRoot";
|
|
6
12
|
export declare const ACTION_TYPE = "dxos.org/type/GraphAction";
|
|
7
13
|
export declare const ACTION_GROUP_TYPE = "dxos.org/type/GraphActionGroup";
|
|
8
|
-
export type NodesOptions<T = any, U extends Record<string, any> = Record<string, any>> = {
|
|
9
|
-
relation?: Relation;
|
|
10
|
-
filter?: NodeFilter<T, U>;
|
|
11
|
-
expansion?: boolean;
|
|
12
|
-
type?: string;
|
|
13
|
-
};
|
|
14
14
|
export type GraphTraversalOptions = {
|
|
15
15
|
/**
|
|
16
16
|
* A callback which is called for each node visited during traversal.
|
|
@@ -21,151 +21,244 @@ export type GraphTraversalOptions = {
|
|
|
21
21
|
/**
|
|
22
22
|
* The node to start traversing from.
|
|
23
23
|
*
|
|
24
|
-
* @default
|
|
24
|
+
* @default ROOT_ID
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
source?: string;
|
|
27
27
|
/**
|
|
28
28
|
* The relation to traverse graph edges.
|
|
29
29
|
*
|
|
30
30
|
* @default 'outbound'
|
|
31
31
|
*/
|
|
32
32
|
relation?: Relation;
|
|
33
|
-
/**
|
|
34
|
-
* Allow traversal to trigger expansion of the graph via `onInitialNodes`.
|
|
35
|
-
*/
|
|
36
|
-
expansion?: boolean;
|
|
37
33
|
};
|
|
38
34
|
export type GraphParams = {
|
|
35
|
+
registry?: Registry.Registry;
|
|
39
36
|
nodes?: MakeOptional<Node, 'data' | 'cacheable'>[];
|
|
40
|
-
edges?: Record<string,
|
|
41
|
-
|
|
42
|
-
onInitialNodes?: Graph['_onInitialNodes'];
|
|
37
|
+
edges?: Record<string, Edges>;
|
|
38
|
+
onExpand?: Graph['_onExpand'];
|
|
43
39
|
onRemoveNode?: Graph['_onRemoveNode'];
|
|
44
40
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
constructor({ nodes, edges, onInitialNode, onInitialNodes, onRemoveNode }?: GraphParams);
|
|
55
|
-
static from(pickle: string, options?: Omit<GraphParams, 'nodes' | 'edges'>): Graph;
|
|
41
|
+
export type Edge = {
|
|
42
|
+
source: string;
|
|
43
|
+
target: string;
|
|
44
|
+
};
|
|
45
|
+
export type Edges = {
|
|
46
|
+
inbound: string[];
|
|
47
|
+
outbound: string[];
|
|
48
|
+
};
|
|
49
|
+
export interface ReadableGraph {
|
|
56
50
|
/**
|
|
57
|
-
*
|
|
51
|
+
* Event emitted when a node is changed.
|
|
58
52
|
*/
|
|
59
|
-
|
|
53
|
+
onNodeChanged: Event<{
|
|
60
54
|
id: string;
|
|
61
|
-
|
|
62
|
-
cacheable?: string[];
|
|
63
|
-
properties: Readonly<Record<string, any>>;
|
|
64
|
-
data: any;
|
|
55
|
+
node: Option.Option<Node>;
|
|
65
56
|
}>;
|
|
66
57
|
/**
|
|
67
58
|
* Convert the graph to a JSON object.
|
|
68
59
|
*/
|
|
69
|
-
toJSON(
|
|
70
|
-
|
|
71
|
-
maxLength?: number;
|
|
72
|
-
}): any;
|
|
73
|
-
pickle(): string;
|
|
60
|
+
toJSON(id?: string): object;
|
|
61
|
+
json(id?: string): Rx.Rx<any>;
|
|
74
62
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* If a node is not found within the graph and an `onInitialNode` callback is provided,
|
|
78
|
-
* it is called with the id and type of the node, potentially initializing the node.
|
|
63
|
+
* Get the rx key for the node with the given id.
|
|
79
64
|
*/
|
|
80
|
-
|
|
65
|
+
node(id: string): Rx.Rx<Option.Option<Node>>;
|
|
81
66
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* If the node is already present in the graph, the promise resolves immediately.
|
|
85
|
-
*
|
|
86
|
-
* @param id The id of the node to wait for.
|
|
87
|
-
* @param timeout The time in milliseconds to wait for the node to be added.
|
|
67
|
+
* Get the rx key for the node with the given id.
|
|
88
68
|
*/
|
|
89
|
-
|
|
69
|
+
nodeOrThrow(id: string): Rx.Rx<Node>;
|
|
90
70
|
/**
|
|
91
|
-
*
|
|
71
|
+
* Get the rx key for the connections of the node with the given id.
|
|
92
72
|
*/
|
|
93
|
-
|
|
94
|
-
id: string;
|
|
95
|
-
type: string;
|
|
96
|
-
cacheable?: string[];
|
|
97
|
-
properties: Readonly<Record<string, any>>;
|
|
98
|
-
data: any;
|
|
99
|
-
}>[];
|
|
73
|
+
connections(id: string, relation?: Relation): Rx.Rx<Node[]>;
|
|
100
74
|
/**
|
|
101
|
-
*
|
|
75
|
+
* Get the rx key for the actions of the node with the given id.
|
|
102
76
|
*/
|
|
103
|
-
|
|
104
|
-
relation?: Relation;
|
|
105
|
-
}): string[];
|
|
77
|
+
actions(id: string): Rx.Rx<(Action | ActionGroup)[]>;
|
|
106
78
|
/**
|
|
107
|
-
*
|
|
79
|
+
* Get the rx key for the edges of the node with the given id.
|
|
108
80
|
*/
|
|
109
|
-
|
|
110
|
-
expansion?: boolean;
|
|
111
|
-
}): Readonly<{
|
|
112
|
-
id: string;
|
|
113
|
-
type: string;
|
|
114
|
-
cacheable?: string[];
|
|
115
|
-
properties: Readonly<Record<string, any>>;
|
|
116
|
-
data: any;
|
|
117
|
-
}>[];
|
|
118
|
-
expand(node: Node, relation?: Relation, type?: string): Promise<void>;
|
|
119
|
-
private _key;
|
|
81
|
+
edges(id: string): Rx.Rx<Edges>;
|
|
120
82
|
/**
|
|
121
|
-
*
|
|
83
|
+
* Alias for `getNodeOrThrow(ROOT_ID)`.
|
|
84
|
+
*/
|
|
85
|
+
get root(): Node;
|
|
86
|
+
/**
|
|
87
|
+
* Get the node with the given id from the graph's registry.
|
|
88
|
+
*/
|
|
89
|
+
getNode(id: string): Option.Option<Node>;
|
|
90
|
+
/**
|
|
91
|
+
* Get the node with the given id from the graph's registry.
|
|
122
92
|
*
|
|
123
|
-
* @
|
|
124
|
-
|
|
125
|
-
|
|
93
|
+
* @throws If the node is Option.none().
|
|
94
|
+
*/
|
|
95
|
+
getNodeOrThrow(id: string): Node;
|
|
96
|
+
/**
|
|
97
|
+
* Get all nodes connected to the node with the given id by the given relation from the graph's registry.
|
|
98
|
+
*/
|
|
99
|
+
getConnections(id: string, relation?: Relation): Node[];
|
|
100
|
+
/**
|
|
101
|
+
* Get all actions connected to the node with the given id from the graph's registry.
|
|
126
102
|
*/
|
|
127
|
-
|
|
103
|
+
getActions(id: string): Node[];
|
|
128
104
|
/**
|
|
129
|
-
*
|
|
105
|
+
* Get the edges from the node with the given id from the graph's registry.
|
|
106
|
+
*/
|
|
107
|
+
getEdges(id: string): Edges;
|
|
108
|
+
/**
|
|
109
|
+
* Recursive depth-first traversal of the graph.
|
|
130
110
|
*
|
|
131
111
|
* @param options.node The node to start traversing from.
|
|
132
112
|
* @param options.relation The relation to traverse graph edges.
|
|
133
113
|
* @param options.visitor A callback which is called for each node visited during traversal.
|
|
134
114
|
*/
|
|
135
|
-
|
|
115
|
+
traverse(options: GraphTraversalOptions, path?: string[]): void;
|
|
136
116
|
/**
|
|
137
117
|
* Get the path between two nodes in the graph.
|
|
138
118
|
*/
|
|
139
|
-
getPath(
|
|
119
|
+
getPath(params: {
|
|
140
120
|
source?: string;
|
|
141
121
|
target: string;
|
|
142
|
-
}): string[]
|
|
122
|
+
}): Option.Option<string[]>;
|
|
143
123
|
/**
|
|
144
124
|
* Wait for the path between two nodes in the graph to be established.
|
|
145
125
|
*/
|
|
146
126
|
waitForPath(params: {
|
|
147
127
|
source?: string;
|
|
148
128
|
target: string;
|
|
149
|
-
},
|
|
129
|
+
}, options?: {
|
|
150
130
|
timeout?: number;
|
|
151
131
|
interval?: number;
|
|
152
132
|
}): Promise<string[]>;
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
private _addEdge;
|
|
156
|
-
private _removeEdge;
|
|
133
|
+
}
|
|
134
|
+
export interface ExpandableGraph extends ReadableGraph {
|
|
157
135
|
/**
|
|
158
|
-
*
|
|
136
|
+
* Initialize a node in the graph.
|
|
159
137
|
*
|
|
160
|
-
*
|
|
138
|
+
* Fires the `onInitialize` callback to provide initial data for a node.
|
|
139
|
+
*/
|
|
140
|
+
/**
|
|
141
|
+
* Expand a node in the graph.
|
|
161
142
|
*
|
|
162
|
-
*
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
143
|
+
* Fires the `onExpand` callback to add connections to the node.
|
|
144
|
+
*/
|
|
145
|
+
expand(id: string, relation?: Relation): void;
|
|
146
|
+
/**
|
|
147
|
+
* Sort the edges of the node with the given id.
|
|
148
|
+
*/
|
|
149
|
+
sortEdges(id: string, relation: Relation, order: string[]): void;
|
|
150
|
+
}
|
|
151
|
+
export interface WritableGraph extends ExpandableGraph {
|
|
152
|
+
/**
|
|
153
|
+
* Add nodes to the graph.
|
|
154
|
+
*/
|
|
155
|
+
addNodes(nodes: NodeArg<any, Record<string, any>>[]): void;
|
|
156
|
+
/**
|
|
157
|
+
* Add a node to the graph.
|
|
158
|
+
*/
|
|
159
|
+
addNode(node: NodeArg<any, Record<string, any>>): void;
|
|
160
|
+
/**
|
|
161
|
+
* Remove nodes from the graph.
|
|
162
|
+
*/
|
|
163
|
+
removeNodes(ids: string[], edges?: boolean): void;
|
|
164
|
+
/**
|
|
165
|
+
* Remove a node from the graph.
|
|
166
|
+
*/
|
|
167
|
+
removeNode(id: string, edges?: boolean): void;
|
|
168
|
+
/**
|
|
169
|
+
* Add edges to the graph.
|
|
170
|
+
*/
|
|
171
|
+
addEdges(edges: Edge[]): void;
|
|
172
|
+
/**
|
|
173
|
+
* Add an edge to the graph.
|
|
174
|
+
*/
|
|
175
|
+
addEdge(edge: Edge): void;
|
|
176
|
+
/**
|
|
177
|
+
* Remove edges from the graph.
|
|
178
|
+
*/
|
|
179
|
+
removeEdges(edges: Edge[], removeOrphans?: boolean): void;
|
|
180
|
+
/**
|
|
181
|
+
* Remove an edge from the graph.
|
|
182
|
+
*/
|
|
183
|
+
removeEdge(edge: Edge, removeOrphans?: boolean): void;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* The Graph represents the user interface information architecture of the application constructed via plugins.
|
|
187
|
+
*/
|
|
188
|
+
export declare class Graph implements WritableGraph {
|
|
189
|
+
readonly onNodeChanged: Event<{
|
|
190
|
+
id: string;
|
|
191
|
+
node: Option.Option<Node>;
|
|
192
|
+
}>;
|
|
193
|
+
private readonly _onExpand?;
|
|
194
|
+
private readonly _onRemoveNode?;
|
|
195
|
+
private readonly _registry;
|
|
196
|
+
private readonly _expanded;
|
|
197
|
+
private readonly _initialized;
|
|
198
|
+
private readonly _initialEdges;
|
|
199
|
+
private readonly _initialNodes;
|
|
200
|
+
private readonly _nodeOrThrow;
|
|
201
|
+
private readonly _edges;
|
|
202
|
+
private readonly _connections;
|
|
203
|
+
private readonly _actions;
|
|
204
|
+
private readonly _json;
|
|
205
|
+
constructor({ registry, nodes, edges, onExpand, onRemoveNode }?: GraphParams);
|
|
206
|
+
toJSON(id?: string): any;
|
|
207
|
+
json(id?: string): Rx.Rx<any>;
|
|
208
|
+
node(id: string): Rx.Rx<Option.Option<Node>>;
|
|
209
|
+
nodeOrThrow(id: string): Rx.Rx<Node>;
|
|
210
|
+
connections(id: string, relation?: Relation): Rx.Rx<Node[]>;
|
|
211
|
+
actions(id: string): Rx.Rx<(Readonly<Omit<Readonly<{
|
|
212
|
+
id: string;
|
|
213
|
+
type: string;
|
|
214
|
+
cacheable?: string[];
|
|
215
|
+
properties: Readonly<Record<string, any>>;
|
|
216
|
+
data: import("./node").ActionData;
|
|
217
|
+
}>, "properties"> & {
|
|
218
|
+
properties: Readonly<Record<string, any>>;
|
|
219
|
+
}> | Readonly<Omit<Readonly<{
|
|
220
|
+
id: string;
|
|
221
|
+
type: string;
|
|
222
|
+
cacheable?: string[];
|
|
223
|
+
properties: Readonly<Record<string, any>>;
|
|
224
|
+
data: typeof import("./node").actionGroupSymbol;
|
|
225
|
+
}>, "properties"> & {
|
|
226
|
+
properties: Readonly<Record<string, any>>;
|
|
227
|
+
}>)[]>;
|
|
228
|
+
edges(id: string): Rx.Rx<Edges>;
|
|
229
|
+
get root(): Readonly<{
|
|
230
|
+
id: string;
|
|
231
|
+
type: string;
|
|
232
|
+
cacheable?: string[];
|
|
233
|
+
properties: Readonly<Record<string, any>>;
|
|
234
|
+
data: any;
|
|
235
|
+
}>;
|
|
236
|
+
getNode(id: string): Option.Option<Node>;
|
|
237
|
+
getNodeOrThrow(id: string): Node;
|
|
238
|
+
getConnections(id: string, relation?: Relation): Node[];
|
|
239
|
+
getActions(id: string): Node[];
|
|
240
|
+
getEdges(id: string): Edges;
|
|
241
|
+
expand(id: string, relation?: Relation): void;
|
|
242
|
+
addNodes(nodes: NodeArg<any, Record<string, any>>[]): void;
|
|
243
|
+
addNode({ nodes, edges, ...nodeArg }: NodeArg<any, Record<string, any>>): void;
|
|
244
|
+
removeNodes(ids: string[], edges?: boolean): void;
|
|
245
|
+
removeNode(id: string, edges?: boolean): void;
|
|
246
|
+
addEdges(edges: Edge[]): void;
|
|
247
|
+
addEdge(edgeArg: Edge): void;
|
|
248
|
+
removeEdges(edges: Edge[], removeOrphans?: boolean): void;
|
|
249
|
+
removeEdge(edgeArg: Edge, removeOrphans?: boolean): void;
|
|
250
|
+
sortEdges(id: string, relation: Relation, order: string[]): void;
|
|
251
|
+
traverse({ visitor, source, relation }: GraphTraversalOptions, path?: string[]): void;
|
|
252
|
+
getPath({ source, target }: {
|
|
253
|
+
source?: string;
|
|
254
|
+
target: string;
|
|
255
|
+
}): Option.Option<string[]>;
|
|
256
|
+
waitForPath(params: {
|
|
257
|
+
source?: string;
|
|
258
|
+
target: string;
|
|
259
|
+
}, { timeout, interval }?: {
|
|
260
|
+
timeout?: number;
|
|
261
|
+
interval?: number;
|
|
262
|
+
}): Promise<string[]>;
|
|
170
263
|
}
|
|
171
264
|
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../../src/graph.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../../src/graph.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAgB,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,KAAK,EAAW,MAAM,aAAa,CAAC;AAI7C,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAE9D,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,KAAK,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,QAAQ,CAAC;AAM/F;;GAEG;AACH,eAAO,MAAM,QAAQ,GAAI,MAAM,IAAI,KAAG,KAIrC,CAAC;AAEF,eAAO,MAAM,OAAO,SAAS,CAAC;AAC9B,eAAO,MAAM,SAAS,4BAA4B,CAAC;AACnD,eAAO,MAAM,WAAW,8BAA8B,CAAC;AACvD,eAAO,MAAM,iBAAiB,mCAAmC,CAAC;AAElE,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;;OAIG;IACH,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,OAAO,GAAG,IAAI,CAAC;IAExD;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;I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AAI,GAAE,MAAM,EAAO,GAAG,IAAI;IAiBhH,OAAO,CAAC,EAAE,MAAe,EAAE,MAAM,EAAE,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;IAuB5F,WAAW,CACf,MAAM,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAC3C,EAAE,OAAe,EAAE,QAAc,EAAE,GAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAO,GAChF,OAAO,CAAC,MAAM,EAAE,CAAC;CAqBrB"}
|
package/dist/types/src/node.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export type Node<TData = any, TProperties extends Record<string, any> = Record<s
|
|
|
26
26
|
*/
|
|
27
27
|
data: TData;
|
|
28
28
|
}>;
|
|
29
|
-
export type NodeFilter<
|
|
29
|
+
export type NodeFilter<TData = any, TProperties extends Record<string, any> = Record<string, any>> = (node: Node<unknown, Record<string, any>>, connectedNode: Node) => node is Node<TData, TProperties>;
|
|
30
30
|
export type Relation = 'outbound' | 'inbound';
|
|
31
31
|
export declare const isGraphNode: (data: unknown) => data is Node;
|
|
32
32
|
export type NodeArg<TData, TProperties extends Record<string, any> = Record<string, any>> = MakeOptional<Node<TData, TProperties>, 'data' | 'properties' | 'cacheable'> & {
|
|
@@ -37,10 +37,10 @@ export type NodeArg<TData, TProperties extends Record<string, any> = Record<stri
|
|
|
37
37
|
};
|
|
38
38
|
export type InvokeParams = {
|
|
39
39
|
/** Node the invoked action is connected to. */
|
|
40
|
-
|
|
40
|
+
parent?: Node;
|
|
41
41
|
caller?: string;
|
|
42
42
|
};
|
|
43
|
-
export type ActionData = (params
|
|
43
|
+
export type ActionData = (params?: InvokeParams) => MaybePromise<void>;
|
|
44
44
|
export type Action<TProperties extends Record<string, any> = Record<string, any>> = Readonly<Omit<Node<ActionData, TProperties>, 'properties'> & {
|
|
45
45
|
properties: Readonly<TProperties>;
|
|
46
46
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/node.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAElE;;GAEG;AAGH,MAAM,MAAM,IAAI,CAAC,KAAK,GAAG,GAAG,EAAE,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,QAAQ,CAAC;IACtG;;OAEG;IAEH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IAErB;;OAEG;IACH,UAAU,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IAElC;;OAEG;IAGH,IAAI,EAAE,KAAK,CAAC;CACb,CAAC,CAAC;AAEH,MAAM,MAAM,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/node.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAElE;;GAEG;AAGH,MAAM,MAAM,IAAI,CAAC,KAAK,GAAG,GAAG,EAAE,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,QAAQ,CAAC;IACtG;;OAEG;IAEH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IAErB;;OAEG;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S,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,QAAQ,CAC1F,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,EAAE,YAAY,CAAC,GAAG;IAClD,UAAU,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;CACnC,CACF,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,MAAM,OAAO,KAAG,IAAI,IAAI,MACY,CAAC;AAE9D,eAAO,MAAM,iBAAiB,eAAwB,CAAC;AAEvD,MAAM,MAAM,WAAW,CAAC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,QAAQ,CAC/F,IAAI,CAAC,IAAI,CAAC,OAAO,iBAAiB,EAAE,WAAW,CAAC,EAAE,YAAY,CAAC,GAAG;IAChE,UAAU,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;CACnC,CACF,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,MAAM,OAAO,KAAG,IAAI,IAAI,WACO,CAAC;AAE9D,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,WAAW,CAAC;AAE9C,eAAO,MAAM,YAAY,GAAI,MAAM,OAAO,KAAG,IAAI,IAAI,MAAM,GAAG,WAAoD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signals-integration.test.d.ts","sourceRoot":"","sources":["../../../src/signals-integration.test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EchoGraph.stories.d.ts","sourceRoot":"","sources":["../../../../src/stories/EchoGraph.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"EchoGraph.stories.d.ts","sourceRoot":"","sources":["../../../../src/stories/EchoGraph.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAKrB,OAAO,KAAuC,MAAM,OAAO,CAAC;;;;;;AAyO5D,wBAaE;AAEF,eAAO,MAAM,OAAO,IAAK,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Rx } from '@effect-rx/rx-react';
|
|
2
|
+
import { type QueryResult } from '@dxos/echo-db';
|
|
3
|
+
import { type BaseObject } from '@dxos/echo-schema';
|
|
4
|
+
export declare const rxFromQuery: <T extends BaseObject>(query: QueryResult<T>) => Rx.Rx<T[]>;
|
|
5
|
+
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../../src/testing.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AAEzC,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,UAAU,EAAE,OAAO,WAAW,CAAC,CAAC,CAAC,KAAG,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAUlF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"5.
|
|
1
|
+
{"version":"5.8.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/app-graph",
|
|
3
|
-
"version": "0.8.2
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "Constructs knowledge graphs for the purpose of building applications on top of",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -24,36 +24,43 @@
|
|
|
24
24
|
"src"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@preact/signals-core": "^1.
|
|
27
|
+
"@preact/signals-core": "^1.9.0",
|
|
28
28
|
"main-thread-scheduling": "^14.1.1",
|
|
29
|
-
"@dxos/
|
|
30
|
-
"@dxos/
|
|
31
|
-
"@dxos/
|
|
32
|
-
"@dxos/echo-signals": "0.8.2
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
29
|
+
"@dxos/async": "0.8.2",
|
|
30
|
+
"@dxos/debug": "0.8.2",
|
|
31
|
+
"@dxos/invariant": "0.8.2",
|
|
32
|
+
"@dxos/echo-signals": "0.8.2",
|
|
33
|
+
"@dxos/live-object": "0.8.2",
|
|
34
|
+
"@dxos/echo-schema": "0.8.2",
|
|
35
|
+
"@dxos/util": "0.8.2",
|
|
36
|
+
"@dxos/log": "0.8.2"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
+
"@effect-rx/rx-react": "^0.34.1",
|
|
40
|
+
"@effect/platform": "0.80.12",
|
|
39
41
|
"@phosphor-icons/react": "^2.1.5",
|
|
40
42
|
"@types/react": "~18.2.0",
|
|
41
43
|
"@types/react-dom": "~18.2.0",
|
|
44
|
+
"effect": "3.14.21",
|
|
42
45
|
"react": "~18.2.0",
|
|
43
46
|
"react-dom": "~18.2.0",
|
|
44
47
|
"vite": "5.4.7",
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/react-client": "0.8.2
|
|
47
|
-
"@dxos/react-ui": "0.8.2
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
48
|
+
"@dxos/echo-db": "0.8.2",
|
|
49
|
+
"@dxos/react-client": "0.8.2",
|
|
50
|
+
"@dxos/react-ui": "0.8.2",
|
|
51
|
+
"@dxos/random": "0.8.2",
|
|
52
|
+
"@dxos/react-ui-theme": "0.8.2",
|
|
53
|
+
"@dxos/storybook-utils": "0.8.2"
|
|
50
54
|
},
|
|
51
55
|
"peerDependencies": {
|
|
56
|
+
"@effect-rx/rx-react": "^0.34.1",
|
|
57
|
+
"@effect/platform": "0.80.12",
|
|
52
58
|
"@phosphor-icons/react": "^2.1.5",
|
|
59
|
+
"effect": "3.14.21",
|
|
53
60
|
"react": "~18.2.0",
|
|
54
61
|
"react-dom": "~18.2.0",
|
|
55
|
-
"@dxos/react-ui": "0.8.2
|
|
56
|
-
"@dxos/react-ui
|
|
62
|
+
"@dxos/react-ui-theme": "0.8.2",
|
|
63
|
+
"@dxos/react-ui": "0.8.2"
|
|
57
64
|
},
|
|
58
65
|
"publishConfig": {
|
|
59
66
|
"access": "public"
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
type Cb = () => void;
|
|
6
|
+
|
|
7
|
+
interface Query {
|
|
8
|
+
id?: string[];
|
|
9
|
+
typename?: string[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Lazy query result that can be executed.
|
|
14
|
+
* Does not run without the run function being called.
|
|
15
|
+
*/
|
|
16
|
+
interface QueryResult<T> {
|
|
17
|
+
/**
|
|
18
|
+
* Execute the query and subscribe to the result.
|
|
19
|
+
* @param next Called at least once with the first value (maybe synchronously) and then for every subsequent update.
|
|
20
|
+
* @param error Called on error. `next` is never called after that.
|
|
21
|
+
* @returns Function to dispose the query and unsubscribe.
|
|
22
|
+
*/
|
|
23
|
+
run(onData: (value?: T[]) => void, onError: (err: Error) => void): Cb;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const QueryResult = Object.freeze({
|
|
27
|
+
fromPromise: <T>(run: (onDispose: (cb: Cb) => void) => Promise<T[]>): QueryResult<T> => {
|
|
28
|
+
return {
|
|
29
|
+
run: (onData, onError) => {
|
|
30
|
+
const cbs: Cb[] = [];
|
|
31
|
+
let disposed = false;
|
|
32
|
+
const dispose = () => {
|
|
33
|
+
cbs.forEach((cb) => cb());
|
|
34
|
+
disposed = true;
|
|
35
|
+
};
|
|
36
|
+
run((cb) => (disposed ? cb() : cbs.push(cb))).then(
|
|
37
|
+
(data) => {
|
|
38
|
+
if (disposed) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
onData(data);
|
|
42
|
+
},
|
|
43
|
+
(err) => {
|
|
44
|
+
dispose();
|
|
45
|
+
onError(err);
|
|
46
|
+
},
|
|
47
|
+
);
|
|
48
|
+
return dispose;
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
interface _Resolver<T> {
|
|
55
|
+
query(query: Query): QueryResult<T>;
|
|
56
|
+
}
|