@dxos/app-graph 0.7.4 → 0.7.5-labs.35b4b42
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 +67 -19
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +66 -17
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +67 -19
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/graph-builder.d.ts +19 -3
- package/dist/types/src/graph-builder.d.ts.map +1 -1
- package/dist/types/src/graph.d.ts.map +1 -1
- package/dist/types/src/node.d.ts +2 -2
- package/dist/types/src/node.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +16 -16
- package/src/graph-builder.test.ts +36 -0
- package/src/graph-builder.ts +53 -18
- package/src/graph.ts +1 -2
- package/src/node.ts +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../../src/graph.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,YAAY,EAAqB,MAAM,YAAY,CAAC;AAElE,OAAO,EAAE,KAAK,IAAI,EAAgB,KAAK,UAAU,EAAE,KAAK,QAAQ,EAAmC,MAAM,QAAQ,CAAC;AAMlH,eAAO,MAAM,QAAQ,SAAU,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,YAAY,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,M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AAM,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;IA6BnF,OAAO,CAAC,QAAQ;IAgEhB,OAAO,CAAC,WAAW;IAwCnB,OAAO,CAAC,QAAQ;IA6BhB,OAAO,CAAC,WAAW;IAiCnB;;;;;;;;;OASG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE;IAa9D,OAAO,CAAC,cAAc,CAEpB;IAEF,OAAO,CAAC,SAAS;CAyBlB"}
|
package/dist/types/src/node.d.ts
CHANGED
|
@@ -46,8 +46,8 @@ export type Action<TProperties extends Record<string, any> = Record<string, any>
|
|
|
46
46
|
}>;
|
|
47
47
|
export declare const isAction: (data: unknown) => data is Action;
|
|
48
48
|
export declare const actionGroupSymbol: unique symbol;
|
|
49
|
-
export type ActionGroup = Readonly<Omit<Node<typeof actionGroupSymbol,
|
|
50
|
-
properties: Readonly<
|
|
49
|
+
export type ActionGroup<TProperties extends Record<string, any> = Record<string, any>> = Readonly<Omit<Node<typeof actionGroupSymbol, TProperties>, 'properties'> & {
|
|
50
|
+
properties: Readonly<TProperties>;
|
|
51
51
|
}>;
|
|
52
52
|
export declare const isActionGroup: (data: unknown) => data is ActionGroup;
|
|
53
53
|
export type ActionLike = Action | ActionGroup;
|
|
@@ -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,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AAQ,CAAC,WAAW,CAAC,CAAC;CACnC,CACF,CAAC;AAEF,eAAO,MAAM,QAAQ,SAAU,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,SAAU,OAAO,KAAG,IAAI,IAAI,WACO,CAAC;AAE9D,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,WAAW,CAAC;AAE9C,eAAO,MAAM,YAAY,SAAU,OAAO,KAAG,IAAI,IAAI,MAAM,GAAG,WAAoD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"5.7.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/app-graph",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5-labs.35b4b42",
|
|
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",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@preact/signals-core": "^1.6.0",
|
|
27
27
|
"main-thread-scheduling": "^14.1.1",
|
|
28
|
-
"@dxos/
|
|
29
|
-
"@dxos/
|
|
30
|
-
"@dxos/
|
|
31
|
-
"@dxos/echo-signals": "0.7.
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/
|
|
28
|
+
"@dxos/async": "0.7.5-labs.35b4b42",
|
|
29
|
+
"@dxos/echo-schema": "0.7.5-labs.35b4b42",
|
|
30
|
+
"@dxos/debug": "0.7.5-labs.35b4b42",
|
|
31
|
+
"@dxos/echo-signals": "0.7.5-labs.35b4b42",
|
|
32
|
+
"@dxos/live-object": "0.7.5-labs.35b4b42",
|
|
33
|
+
"@dxos/util": "0.7.5-labs.35b4b42",
|
|
34
|
+
"@dxos/invariant": "0.7.5-labs.35b4b42",
|
|
35
|
+
"@dxos/log": "0.7.5-labs.35b4b42"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@phosphor-icons/react": "^2.1.5",
|
|
@@ -41,18 +41,18 @@
|
|
|
41
41
|
"react": "~18.2.0",
|
|
42
42
|
"react-dom": "~18.2.0",
|
|
43
43
|
"vite": "5.4.7",
|
|
44
|
-
"@dxos/random": "0.7.
|
|
45
|
-
"@dxos/react-client": "0.7.
|
|
46
|
-
"@dxos/react-ui
|
|
47
|
-
"@dxos/react-ui": "0.7.
|
|
48
|
-
"@dxos/storybook-utils": "0.7.
|
|
44
|
+
"@dxos/random": "0.7.5-labs.35b4b42",
|
|
45
|
+
"@dxos/react-client": "0.7.5-labs.35b4b42",
|
|
46
|
+
"@dxos/react-ui": "0.7.5-labs.35b4b42",
|
|
47
|
+
"@dxos/react-ui-theme": "0.7.5-labs.35b4b42",
|
|
48
|
+
"@dxos/storybook-utils": "0.7.5-labs.35b4b42"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@phosphor-icons/react": "^2.1.5",
|
|
52
52
|
"react": "~18.2.0",
|
|
53
53
|
"react-dom": "~18.2.0",
|
|
54
|
-
"@dxos/react-ui": "0.7.
|
|
55
|
-
"@dxos/react-ui-theme": "0.7.
|
|
54
|
+
"@dxos/react-ui": "0.7.5-labs.35b4b42",
|
|
55
|
+
"@dxos/react-ui-theme": "0.7.5-labs.35b4b42"
|
|
56
56
|
},
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public"
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
import { batch, signal } from '@preact/signals-core';
|
|
6
6
|
import { describe, expect, test } from 'vitest';
|
|
7
7
|
|
|
8
|
+
import { updateCounter } from '@dxos/echo-schema/testing';
|
|
9
|
+
|
|
8
10
|
import { ACTION_TYPE, ROOT_ID, ROOT_TYPE } from './graph';
|
|
9
11
|
import { GraphBuilder, createExtension, memoize } from './graph-builder';
|
|
10
12
|
import { type Node } from './node';
|
|
@@ -175,6 +177,40 @@ describe('GraphBuilder', () => {
|
|
|
175
177
|
expect(node.properties.label).to.equal('updated');
|
|
176
178
|
});
|
|
177
179
|
|
|
180
|
+
test('updates with new extensions', async () => {
|
|
181
|
+
const name = signal('default');
|
|
182
|
+
const builder = new GraphBuilder();
|
|
183
|
+
builder.addExtension(
|
|
184
|
+
createExtension({
|
|
185
|
+
id: 'connector',
|
|
186
|
+
connector: () => [{ id: EXAMPLE_ID, type: EXAMPLE_TYPE, data: name, properties: { label: name.value } }],
|
|
187
|
+
}),
|
|
188
|
+
);
|
|
189
|
+
const graph = builder.graph;
|
|
190
|
+
await graph.expand(graph.root);
|
|
191
|
+
|
|
192
|
+
let nodes: Node[] = [];
|
|
193
|
+
using updates = updateCounter(() => {
|
|
194
|
+
nodes = graph.nodes(graph.root);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
expect(updates.count).to.equal(0);
|
|
198
|
+
expect(nodes).has.length(1);
|
|
199
|
+
expect(nodes[0].id).to.equal(EXAMPLE_ID);
|
|
200
|
+
|
|
201
|
+
builder.addExtension(
|
|
202
|
+
createExtension({
|
|
203
|
+
id: 'connector-2',
|
|
204
|
+
connector: () => [{ id: exampleId(2), type: EXAMPLE_TYPE, data: 0 }],
|
|
205
|
+
}),
|
|
206
|
+
);
|
|
207
|
+
|
|
208
|
+
expect(updates.count).to.equal(1);
|
|
209
|
+
expect(nodes).has.length(2);
|
|
210
|
+
expect(nodes[0].id).to.equal(EXAMPLE_ID);
|
|
211
|
+
expect(nodes[1].id).to.equal(exampleId(2));
|
|
212
|
+
});
|
|
213
|
+
|
|
178
214
|
test('removes', async () => {
|
|
179
215
|
const nodes = signal([
|
|
180
216
|
{ id: exampleId(1), type: EXAMPLE_TYPE, data: 1 },
|
package/src/graph-builder.ts
CHANGED
|
@@ -2,17 +2,19 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { effect, type Signal, signal } from '@preact/signals-core';
|
|
5
|
+
import { effect, type Signal, signal, untracked } from '@preact/signals-core';
|
|
6
6
|
|
|
7
7
|
import { Trigger, type UnsubscribeCallback } from '@dxos/async';
|
|
8
8
|
import { invariant } from '@dxos/invariant';
|
|
9
9
|
import { create } from '@dxos/live-object';
|
|
10
10
|
import { log } from '@dxos/log';
|
|
11
|
-
import { isNode, type MaybePromise, nonNullable } from '@dxos/util';
|
|
11
|
+
import { byPosition, type Position, isNode, type MaybePromise, nonNullable } from '@dxos/util';
|
|
12
12
|
|
|
13
13
|
import { ACTION_GROUP_TYPE, ACTION_TYPE, Graph, ROOT_ID, type GraphParams } from './graph';
|
|
14
14
|
import { type ActionData, actionGroupSymbol, type Node, type NodeArg, type Relation } from './node';
|
|
15
15
|
|
|
16
|
+
const NODE_RESOLVER_TIMEOUT = 1_000;
|
|
17
|
+
|
|
16
18
|
/**
|
|
17
19
|
* Graph builder extension for adding nodes to the graph based on just the node id.
|
|
18
20
|
* This is useful for creating the first node in a graph or for hydrating cached nodes with data.
|
|
@@ -50,6 +52,7 @@ type GuardedNodeType<T> = T extends (value: any) => value is infer N ? (N extend
|
|
|
50
52
|
* @param params.id The unique id of the extension.
|
|
51
53
|
* @param params.relation The relation the graph is being expanded from the existing node.
|
|
52
54
|
* @param params.type If provided, all nodes returned are expected to have this type.
|
|
55
|
+
* @param params.disposition Affects the order the extensions are processed in.
|
|
53
56
|
* @param params.filter A filter function to determine if an extension should act on a node.
|
|
54
57
|
* @param params.resolver A function to add nodes to the graph based on just the node id.
|
|
55
58
|
* @param params.connector A function to add nodes to the graph based on a connection to an existing node.
|
|
@@ -60,6 +63,7 @@ export type CreateExtensionOptions<T = any> = {
|
|
|
60
63
|
id: string;
|
|
61
64
|
relation?: Relation;
|
|
62
65
|
type?: string;
|
|
66
|
+
position?: Position;
|
|
63
67
|
filter?: (node: Node) => node is Node<T>;
|
|
64
68
|
resolver?: ResolverExtension;
|
|
65
69
|
connector?: ConnectorExtension<GuardedNodeType<CreateExtensionOptions<T>['filter']>>;
|
|
@@ -71,15 +75,16 @@ export type CreateExtensionOptions<T = any> = {
|
|
|
71
75
|
* Create a graph builder extension.
|
|
72
76
|
*/
|
|
73
77
|
export const createExtension = <T = any>(extension: CreateExtensionOptions<T>): BuilderExtension[] => {
|
|
74
|
-
const { id, resolver, connector, actions, actionGroups, ...rest } = extension;
|
|
78
|
+
const { id, position = 'static', resolver, connector, actions, actionGroups, ...rest } = extension;
|
|
75
79
|
const getId = (key: string) => `${id}/${key}`;
|
|
76
80
|
return [
|
|
77
|
-
resolver ? { id: getId('resolver'), resolver } : undefined,
|
|
78
|
-
connector ? { ...rest, id: getId('connector'), connector } : undefined,
|
|
81
|
+
resolver ? { id: getId('resolver'), position, resolver } : undefined,
|
|
82
|
+
connector ? { ...rest, id: getId('connector'), position, connector } : undefined,
|
|
79
83
|
actionGroups
|
|
80
84
|
? ({
|
|
81
85
|
...rest,
|
|
82
86
|
id: getId('actionGroups'),
|
|
87
|
+
position,
|
|
83
88
|
type: ACTION_GROUP_TYPE,
|
|
84
89
|
relation: 'outbound',
|
|
85
90
|
connector: ({ node }) =>
|
|
@@ -90,6 +95,7 @@ export const createExtension = <T = any>(extension: CreateExtensionOptions<T>):
|
|
|
90
95
|
? ({
|
|
91
96
|
...rest,
|
|
92
97
|
id: getId('actions'),
|
|
98
|
+
position,
|
|
93
99
|
type: ACTION_TYPE,
|
|
94
100
|
relation: 'outbound',
|
|
95
101
|
connector: ({ node }) => actions({ node })?.map((arg) => ({ ...arg, type: ACTION_TYPE })),
|
|
@@ -166,18 +172,27 @@ export const toSignal = <T>(
|
|
|
166
172
|
return thisSignal.value;
|
|
167
173
|
};
|
|
168
174
|
|
|
169
|
-
export type BuilderExtension = {
|
|
175
|
+
export type BuilderExtension = Readonly<{
|
|
170
176
|
id: string;
|
|
177
|
+
position: Position;
|
|
171
178
|
resolver?: ResolverExtension;
|
|
172
179
|
connector?: ConnectorExtension;
|
|
173
180
|
// Only for connector.
|
|
174
181
|
relation?: Relation;
|
|
175
182
|
type?: string;
|
|
176
183
|
filter?: (node: Node) => boolean;
|
|
177
|
-
}
|
|
184
|
+
}>;
|
|
178
185
|
|
|
179
186
|
type ExtensionArg = BuilderExtension | BuilderExtension[] | ExtensionArg[];
|
|
180
187
|
|
|
188
|
+
export const flattenExtensions = (extension: ExtensionArg, acc: BuilderExtension[] = []): BuilderExtension[] => {
|
|
189
|
+
if (Array.isArray(extension)) {
|
|
190
|
+
return [...acc, ...extension.flatMap((ext) => flattenExtensions(ext, acc))];
|
|
191
|
+
} else {
|
|
192
|
+
return [...acc, extension];
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
181
196
|
/**
|
|
182
197
|
* The builder provides an extensible way to compose the construction of the graph.
|
|
183
198
|
*/
|
|
@@ -221,24 +236,40 @@ export class GraphBuilder {
|
|
|
221
236
|
.filter((id) => id !== ROOT_ID)
|
|
222
237
|
.forEach((id) => (this._initialized[id] = new Trigger()));
|
|
223
238
|
Object.keys(this._graph._nodes).forEach((id) => this._onInitialNode(id));
|
|
224
|
-
await Promise.all(
|
|
239
|
+
await Promise.all(
|
|
240
|
+
Object.entries(this._initialized).map(async ([id, trigger]) => {
|
|
241
|
+
try {
|
|
242
|
+
await trigger.wait({ timeout: NODE_RESOLVER_TIMEOUT });
|
|
243
|
+
} catch {
|
|
244
|
+
log.error('node resolver timeout', { id });
|
|
245
|
+
this.graph._removeNodes([id]);
|
|
246
|
+
}
|
|
247
|
+
}),
|
|
248
|
+
);
|
|
225
249
|
}
|
|
226
250
|
|
|
227
251
|
get graph() {
|
|
228
252
|
return this._graph;
|
|
229
253
|
}
|
|
230
254
|
|
|
255
|
+
/**
|
|
256
|
+
* @reactive
|
|
257
|
+
*/
|
|
258
|
+
get extensions() {
|
|
259
|
+
return Object.values(this._extensions);
|
|
260
|
+
}
|
|
261
|
+
|
|
231
262
|
/**
|
|
232
263
|
* Register a node builder which will be called in order to construct the graph.
|
|
233
264
|
*/
|
|
234
265
|
addExtension(extension: ExtensionArg): GraphBuilder {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
266
|
+
const extensions = flattenExtensions(extension);
|
|
267
|
+
untracked(() => {
|
|
268
|
+
extensions.forEach((extension) => {
|
|
269
|
+
this._dispatcher.state[extension.id] = [];
|
|
270
|
+
this._extensions[extension.id] = extension;
|
|
271
|
+
});
|
|
272
|
+
});
|
|
242
273
|
return this;
|
|
243
274
|
}
|
|
244
275
|
|
|
@@ -246,7 +277,9 @@ export class GraphBuilder {
|
|
|
246
277
|
* Remove a node builder from the graph builder.
|
|
247
278
|
*/
|
|
248
279
|
removeExtension(id: string): GraphBuilder {
|
|
249
|
-
|
|
280
|
+
untracked(() => {
|
|
281
|
+
delete this._extensions[id];
|
|
282
|
+
});
|
|
250
283
|
return this;
|
|
251
284
|
}
|
|
252
285
|
|
|
@@ -310,7 +343,8 @@ export class GraphBuilder {
|
|
|
310
343
|
this._resolverSubscriptions.set(
|
|
311
344
|
nodeId,
|
|
312
345
|
effect(() => {
|
|
313
|
-
|
|
346
|
+
const extensions = Object.values(this._extensions).toSorted(byPosition);
|
|
347
|
+
for (const { id, resolver } of extensions) {
|
|
314
348
|
if (!resolver) {
|
|
315
349
|
continue;
|
|
316
350
|
}
|
|
@@ -367,7 +401,8 @@ export class GraphBuilder {
|
|
|
367
401
|
|
|
368
402
|
// TODO(wittjosiah): Consider allowing extensions to collaborate on the same node by merging their results.
|
|
369
403
|
const nodes: NodeArg<any>[] = [];
|
|
370
|
-
|
|
404
|
+
const extensions = Object.values(this._extensions).toSorted(byPosition);
|
|
405
|
+
for (const { id, connector, filter, type, relation = 'outbound' } of extensions) {
|
|
371
406
|
if (
|
|
372
407
|
!connector ||
|
|
373
408
|
relation !== nodesRelation ||
|
package/src/graph.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { type MakeOptional, nonNullable, pick } from '@dxos/util';
|
|
|
13
13
|
import { type Node, type NodeArg, type NodeFilter, type Relation, actionGroupSymbol, isActionLike } from './node';
|
|
14
14
|
|
|
15
15
|
const graphSymbol = Symbol('graph');
|
|
16
|
-
type DeepWriteable<T> = { -readonly [K in keyof T]: DeepWriteable<T[K]> };
|
|
16
|
+
type DeepWriteable<T> = { -readonly [K in keyof T]: T[K] extends object ? DeepWriteable<T[K]> : T[K] };
|
|
17
17
|
type NodeInternal = DeepWriteable<Node> & { [graphSymbol]: Graph };
|
|
18
18
|
|
|
19
19
|
export const getGraph = (node: Node): Graph => {
|
|
@@ -319,7 +319,6 @@ export class Graph {
|
|
|
319
319
|
|
|
320
320
|
const nodes = this._getNodes({ node, relation, expansion });
|
|
321
321
|
const nodeSubscriptions = nodes.map((n) => this.subscribeTraverse({ node: n, visitor, expansion }, path));
|
|
322
|
-
|
|
323
322
|
return () => {
|
|
324
323
|
nodeSubscriptions.forEach((unsubscribe) => unsubscribe());
|
|
325
324
|
};
|
package/src/node.ts
CHANGED
|
@@ -87,9 +87,9 @@ export const isAction = (data: unknown): data is Action =>
|
|
|
87
87
|
|
|
88
88
|
export const actionGroupSymbol = Symbol('ActionGroup');
|
|
89
89
|
|
|
90
|
-
export type ActionGroup = Readonly<
|
|
91
|
-
Omit<Node<typeof actionGroupSymbol,
|
|
92
|
-
properties: Readonly<
|
|
90
|
+
export type ActionGroup<TProperties extends Record<string, any> = Record<string, any>> = Readonly<
|
|
91
|
+
Omit<Node<typeof actionGroupSymbol, TProperties>, 'properties'> & {
|
|
92
|
+
properties: Readonly<TProperties>;
|
|
93
93
|
}
|
|
94
94
|
>;
|
|
95
95
|
|