@knotx/core 0.2.10 → 0.2.11

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.
@@ -1,4 +1,4 @@
1
1
  import 'jsonschema';
2
2
  import 'rxjs';
3
- export { C as Container, E as EdgeData, r as EdgeOperation, p as EdgeOperationPipe, t as EdgeOperatorFunction, l as EdgeProps, d as EdgeRenderType, H as HorizontalAlignment, I as IEngineRuntime, a as IPlugin, g as IPluginInfo, h as IPluginToolInfo, b as Layer, L as LayerComponent, N as NodeData, j as NodeMeasured, q as NodeOperation, o as NodeOperationPipe, s as NodeOperatorFunction, i as NodePosition, k as NodeProps, c as NodeRenderType, P as Plugin, n as PluginConfigs, e as PluginData, f as PluginTools, m as Position, R as RenderType, V as VerticalAlignment } from './shared/core.BUBec6Va.cjs';
3
+ export { C as Container, E as Edge, s as EdgeOperation, q as EdgeOperationPipe, u as EdgeOperatorFunction, m as EdgeProps, e as EdgeRenderType, H as HorizontalAlignment, a as IEngineRuntime, b as IPlugin, h as IPluginInfo, i as IPluginToolInfo, I as IRecord, c as Layer, L as LayerComponent, N as Node, k as NodeMeasured, r as NodeOperation, p as NodeOperationPipe, t as NodeOperatorFunction, j as NodePosition, l as NodeProps, d as NodeRenderType, P as Plugin, o as PluginConfigs, f as PluginData, g as PluginTools, n as Position, R as RenderType, V as VerticalAlignment } from './shared/core.CgVCXkyd.cjs';
4
4
  import '@knotx/data';
@@ -1,4 +1,4 @@
1
1
  import 'jsonschema';
2
2
  import 'rxjs';
3
- export { C as Container, E as EdgeData, r as EdgeOperation, p as EdgeOperationPipe, t as EdgeOperatorFunction, l as EdgeProps, d as EdgeRenderType, H as HorizontalAlignment, I as IEngineRuntime, a as IPlugin, g as IPluginInfo, h as IPluginToolInfo, b as Layer, L as LayerComponent, N as NodeData, j as NodeMeasured, q as NodeOperation, o as NodeOperationPipe, s as NodeOperatorFunction, i as NodePosition, k as NodeProps, c as NodeRenderType, P as Plugin, n as PluginConfigs, e as PluginData, f as PluginTools, m as Position, R as RenderType, V as VerticalAlignment } from './shared/core.BUBec6Va.mjs';
3
+ export { C as Container, E as Edge, s as EdgeOperation, q as EdgeOperationPipe, u as EdgeOperatorFunction, m as EdgeProps, e as EdgeRenderType, H as HorizontalAlignment, a as IEngineRuntime, b as IPlugin, h as IPluginInfo, i as IPluginToolInfo, I as IRecord, c as Layer, L as LayerComponent, N as Node, k as NodeMeasured, r as NodeOperation, p as NodeOperationPipe, t as NodeOperatorFunction, j as NodePosition, l as NodeProps, d as NodeRenderType, P as Plugin, o as PluginConfigs, f as PluginData, g as PluginTools, n as Position, R as RenderType, V as VerticalAlignment } from './shared/core.CgVCXkyd.mjs';
4
4
  import '@knotx/data';
@@ -1,4 +1,4 @@
1
1
  import 'jsonschema';
2
2
  import 'rxjs';
3
- export { C as Container, E as EdgeData, r as EdgeOperation, p as EdgeOperationPipe, t as EdgeOperatorFunction, l as EdgeProps, d as EdgeRenderType, H as HorizontalAlignment, I as IEngineRuntime, a as IPlugin, g as IPluginInfo, h as IPluginToolInfo, b as Layer, L as LayerComponent, N as NodeData, j as NodeMeasured, q as NodeOperation, o as NodeOperationPipe, s as NodeOperatorFunction, i as NodePosition, k as NodeProps, c as NodeRenderType, P as Plugin, n as PluginConfigs, e as PluginData, f as PluginTools, m as Position, R as RenderType, V as VerticalAlignment } from './shared/core.BUBec6Va.js';
3
+ export { C as Container, E as Edge, s as EdgeOperation, q as EdgeOperationPipe, u as EdgeOperatorFunction, m as EdgeProps, e as EdgeRenderType, H as HorizontalAlignment, a as IEngineRuntime, b as IPlugin, h as IPluginInfo, i as IPluginToolInfo, I as IRecord, c as Layer, L as LayerComponent, N as Node, k as NodeMeasured, r as NodeOperation, p as NodeOperationPipe, t as NodeOperatorFunction, j as NodePosition, l as NodeProps, d as NodeRenderType, P as Plugin, o as PluginConfigs, f as PluginData, g as PluginTools, n as Position, R as RenderType, V as VerticalAlignment } from './shared/core.CgVCXkyd.js';
4
4
  import '@knotx/data';
package/dist/index.cjs CHANGED
@@ -303,12 +303,13 @@ class Engine {
303
303
  endInteraction(pluginId, type) {
304
304
  this.interactionManager.endInteraction(pluginId, type);
305
305
  }
306
- callTool(pluginName, toolName, params) {
306
+ callTool(pluginName, toolName, ...args) {
307
307
  const toolDefinition = lodashEs.get(this, ["_pluginToolsContainer", pluginName, toolName]);
308
308
  const tool = toolDefinition == null ? void 0 : toolDefinition.func;
309
309
  if (!tool || typeof tool !== "function") {
310
310
  throw new Error(`Tool ${String(toolName)} not found in plugin ${pluginName}`);
311
311
  }
312
+ const params = args[0];
312
313
  const validator = this.toolParamsValidator.validate(params, toolDefinition.params);
313
314
  if (validator.errors.length > 0) {
314
315
  throw new Error(`Invalid tool params: ${validator.errors.map((e) => e.stack).join(", ")}`);
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as Container, P as Plugin, N as NodeData, E as EdgeData, I as IEngineRuntime, R as RenderType, L as LayerComponent, a as IPlugin, b as Layer, c as NodeRenderType, d as EdgeRenderType, e as PluginData, f as PluginTools, g as IPluginInfo, h as IPluginToolInfo } from './shared/core.BUBec6Va.cjs';
2
- export { B as BasePlugin, r as EdgeOperation, p as EdgeOperationPipe, t as EdgeOperatorFunction, l as EdgeProps, H as HorizontalAlignment, j as NodeMeasured, q as NodeOperation, o as NodeOperationPipe, s as NodeOperatorFunction, i as NodePosition, k as NodeProps, n as PluginConfigs, m as Position, V as VerticalAlignment } from './shared/core.BUBec6Va.cjs';
1
+ import { I as IRecord, C as Container, P as Plugin, N as Node, E as Edge, a as IEngineRuntime, R as RenderType, L as LayerComponent, b as IPlugin, c as Layer, d as NodeRenderType, e as EdgeRenderType, f as PluginData, g as PluginTools, h as IPluginInfo, i as IPluginToolInfo } from './shared/core.CgVCXkyd.cjs';
2
+ export { B as BasePlugin, s as EdgeOperation, q as EdgeOperationPipe, u as EdgeOperatorFunction, m as EdgeProps, H as HorizontalAlignment, k as NodeMeasured, r as NodeOperation, p as NodeOperationPipe, t as NodeOperatorFunction, j as NodePosition, l as NodeProps, o as PluginConfigs, n as Position, V as VerticalAlignment } from './shared/core.CgVCXkyd.cjs';
3
3
  import { Schema } from 'jsonschema';
4
4
  import { BehaviorSubject } from 'rxjs';
5
5
  import { DataManager, DataOperationPipe, DataOperation } from '@knotx/data';
@@ -85,19 +85,19 @@ declare class InteractionManager {
85
85
  private updateActive;
86
86
  }
87
87
 
88
- interface EngineOptions {
88
+ interface EngineOptions<TNode extends IRecord = IRecord, TEdge extends IRecord = IRecord> {
89
89
  container: Container;
90
90
  plugins?: Plugin[];
91
- pluginConfig?: Record<string, any>;
92
- nodes?: NodeData[];
93
- edges?: EdgeData[];
91
+ pluginConfig?: IRecord;
92
+ nodes?: Node<TNode>[];
93
+ edges?: Edge<TEdge>[];
94
94
  runtime?: IEngineRuntime;
95
95
  }
96
- declare class Engine<TRenderType extends RenderType = RenderType> {
96
+ declare class Engine<TRenderType extends RenderType = RenderType, TNode extends IRecord = IRecord, TEdge extends IRecord = IRecord> {
97
97
  readonly runtime: IEngineRuntime;
98
98
  readonly interactionManager: InteractionManager;
99
- readonly nodesManager: DataManager<NodeData>;
100
- readonly edgesManager: DataManager<EdgeData>;
99
+ readonly nodesManager: DataManager<Node<TNode>>;
100
+ readonly edgesManager: DataManager<Edge<TEdge>>;
101
101
  private container$;
102
102
  private nodes$;
103
103
  private edges$;
@@ -110,26 +110,26 @@ declare class Engine<TRenderType extends RenderType = RenderType> {
110
110
  private toolParamsValidator;
111
111
  get container(): Container;
112
112
  set container(value: Container);
113
- get nodes(): NodeData<any>[];
114
- get edges(): EdgeData<any>[];
113
+ get nodes(): Node<TNode>[];
114
+ get edges(): Edge<TEdge>[];
115
115
  get layers(): Map<number, LayerComponent<TRenderType>[]>;
116
116
  get plugins(): IPlugin<string, any, RenderType>[];
117
- constructor(options: EngineOptions);
117
+ constructor(options: EngineOptions<TNode, TEdge>);
118
118
  private init;
119
119
  getLayerComponents(layer: Layer): LayerComponent<TRenderType>[];
120
- addNodePipe(pipe: DataOperationPipe<NodeData>): () => void;
121
- addEdgePipe(pipe: DataOperationPipe<EdgeData>): () => void;
122
- changePluginConfig(pluginName: string, config: Record<string, any>): void;
123
- dispatchNodeOperation(operation: DataOperation<NodeData>): void;
124
- dispatchEdgeOperation(operation: DataOperation<EdgeData>): void;
120
+ addNodePipe(pipe: DataOperationPipe<Node<TNode>>): () => void;
121
+ addEdgePipe(pipe: DataOperationPipe<Edge<TEdge>>): () => void;
122
+ changePluginConfig(pluginName: string, config: IRecord): void;
123
+ dispatchNodeOperation(operation: DataOperation<Node<TNode>>): void;
124
+ dispatchEdgeOperation(operation: DataOperation<Edge<TEdge>>): void;
125
125
  getPlugin<TPlugin extends IPlugin>(pluginName: TPlugin['name']): TPlugin | undefined;
126
- getNode(id: string): NodeData | undefined;
127
- getNodeDraft(id: string): NodeData | undefined;
128
- getNodes(): NodeData[];
126
+ getNode(id: string): Node<TNode> | undefined;
127
+ getNodeDraft(id: string): Node<TNode> | undefined;
128
+ getNodes(): Node<TNode>[];
129
129
  getNodeRenderer(type: string): NodeRenderType | undefined;
130
- getEdge(id: string): EdgeData | undefined;
131
- getEdgeDraft(id: string): EdgeData | undefined;
132
- getEdges(): EdgeData[];
130
+ getEdge(id: string): Edge<TEdge> | undefined;
131
+ getEdgeDraft(id: string): Edge<TEdge> | undefined;
132
+ getEdges(): Edge<TEdge>[];
133
133
  getEdgeRenderer(type: string): EdgeRenderType | undefined;
134
134
  registerPluginData<T extends keyof PluginData, TP extends keyof PluginData[T]>(pluginName: T, property: TP, data: BehaviorSubject<PluginData[T][TP]>): void;
135
135
  resetPluginData<T extends keyof PluginData>(pluginName: T): void;
@@ -144,7 +144,7 @@ declare class Engine<TRenderType extends RenderType = RenderType> {
144
144
  canInteract(pluginId: string, type: string, autoStartPriority?: InteractionPriority): boolean;
145
145
  startInteraction(pluginId: string, type: string, priority: InteractionPriority): void;
146
146
  endInteraction(pluginId: string, type: string): void;
147
- callTool<T extends keyof PluginTools, TP extends keyof PluginTools[T]>(pluginName: T, toolName: TP, params: any): any;
147
+ callTool<T extends keyof PluginTools, TP extends keyof PluginTools[T]>(pluginName: T, toolName: TP, ...args: Parameters<PluginTools[T][TP]>): any;
148
148
  listPlugins(): IPluginInfo[];
149
149
  listPluginTools(pluginName: string): IPluginToolInfo[];
150
150
  listEngineTools(): IPluginToolInfo[];
@@ -214,4 +214,4 @@ declare function use<T, TContext>(hook: () => {
214
214
  __contextValue__: TContext;
215
215
  }, context: TContext): T;
216
216
 
217
- export { Container, EdgeData, EdgeRenderType, Engine, type EngineOptions, IEngineRuntime, IPlugin, IPluginInfo, IPluginToolInfo, type Interaction, InteractionManager, InteractionPriority, Layer, LayerComponent, NodeData, NodeRenderType, Plugin, PluginData, PluginTools, RenderType, Runtime, getLayerRenders, use };
217
+ export { Container, Edge, EdgeRenderType, Engine, type EngineOptions, IEngineRuntime, IPlugin, IPluginInfo, IPluginToolInfo, IRecord, type Interaction, InteractionManager, InteractionPriority, Layer, LayerComponent, Node, NodeRenderType, Plugin, PluginData, PluginTools, RenderType, Runtime, getLayerRenders, use };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as Container, P as Plugin, N as NodeData, E as EdgeData, I as IEngineRuntime, R as RenderType, L as LayerComponent, a as IPlugin, b as Layer, c as NodeRenderType, d as EdgeRenderType, e as PluginData, f as PluginTools, g as IPluginInfo, h as IPluginToolInfo } from './shared/core.BUBec6Va.mjs';
2
- export { B as BasePlugin, r as EdgeOperation, p as EdgeOperationPipe, t as EdgeOperatorFunction, l as EdgeProps, H as HorizontalAlignment, j as NodeMeasured, q as NodeOperation, o as NodeOperationPipe, s as NodeOperatorFunction, i as NodePosition, k as NodeProps, n as PluginConfigs, m as Position, V as VerticalAlignment } from './shared/core.BUBec6Va.mjs';
1
+ import { I as IRecord, C as Container, P as Plugin, N as Node, E as Edge, a as IEngineRuntime, R as RenderType, L as LayerComponent, b as IPlugin, c as Layer, d as NodeRenderType, e as EdgeRenderType, f as PluginData, g as PluginTools, h as IPluginInfo, i as IPluginToolInfo } from './shared/core.CgVCXkyd.mjs';
2
+ export { B as BasePlugin, s as EdgeOperation, q as EdgeOperationPipe, u as EdgeOperatorFunction, m as EdgeProps, H as HorizontalAlignment, k as NodeMeasured, r as NodeOperation, p as NodeOperationPipe, t as NodeOperatorFunction, j as NodePosition, l as NodeProps, o as PluginConfigs, n as Position, V as VerticalAlignment } from './shared/core.CgVCXkyd.mjs';
3
3
  import { Schema } from 'jsonschema';
4
4
  import { BehaviorSubject } from 'rxjs';
5
5
  import { DataManager, DataOperationPipe, DataOperation } from '@knotx/data';
@@ -85,19 +85,19 @@ declare class InteractionManager {
85
85
  private updateActive;
86
86
  }
87
87
 
88
- interface EngineOptions {
88
+ interface EngineOptions<TNode extends IRecord = IRecord, TEdge extends IRecord = IRecord> {
89
89
  container: Container;
90
90
  plugins?: Plugin[];
91
- pluginConfig?: Record<string, any>;
92
- nodes?: NodeData[];
93
- edges?: EdgeData[];
91
+ pluginConfig?: IRecord;
92
+ nodes?: Node<TNode>[];
93
+ edges?: Edge<TEdge>[];
94
94
  runtime?: IEngineRuntime;
95
95
  }
96
- declare class Engine<TRenderType extends RenderType = RenderType> {
96
+ declare class Engine<TRenderType extends RenderType = RenderType, TNode extends IRecord = IRecord, TEdge extends IRecord = IRecord> {
97
97
  readonly runtime: IEngineRuntime;
98
98
  readonly interactionManager: InteractionManager;
99
- readonly nodesManager: DataManager<NodeData>;
100
- readonly edgesManager: DataManager<EdgeData>;
99
+ readonly nodesManager: DataManager<Node<TNode>>;
100
+ readonly edgesManager: DataManager<Edge<TEdge>>;
101
101
  private container$;
102
102
  private nodes$;
103
103
  private edges$;
@@ -110,26 +110,26 @@ declare class Engine<TRenderType extends RenderType = RenderType> {
110
110
  private toolParamsValidator;
111
111
  get container(): Container;
112
112
  set container(value: Container);
113
- get nodes(): NodeData<any>[];
114
- get edges(): EdgeData<any>[];
113
+ get nodes(): Node<TNode>[];
114
+ get edges(): Edge<TEdge>[];
115
115
  get layers(): Map<number, LayerComponent<TRenderType>[]>;
116
116
  get plugins(): IPlugin<string, any, RenderType>[];
117
- constructor(options: EngineOptions);
117
+ constructor(options: EngineOptions<TNode, TEdge>);
118
118
  private init;
119
119
  getLayerComponents(layer: Layer): LayerComponent<TRenderType>[];
120
- addNodePipe(pipe: DataOperationPipe<NodeData>): () => void;
121
- addEdgePipe(pipe: DataOperationPipe<EdgeData>): () => void;
122
- changePluginConfig(pluginName: string, config: Record<string, any>): void;
123
- dispatchNodeOperation(operation: DataOperation<NodeData>): void;
124
- dispatchEdgeOperation(operation: DataOperation<EdgeData>): void;
120
+ addNodePipe(pipe: DataOperationPipe<Node<TNode>>): () => void;
121
+ addEdgePipe(pipe: DataOperationPipe<Edge<TEdge>>): () => void;
122
+ changePluginConfig(pluginName: string, config: IRecord): void;
123
+ dispatchNodeOperation(operation: DataOperation<Node<TNode>>): void;
124
+ dispatchEdgeOperation(operation: DataOperation<Edge<TEdge>>): void;
125
125
  getPlugin<TPlugin extends IPlugin>(pluginName: TPlugin['name']): TPlugin | undefined;
126
- getNode(id: string): NodeData | undefined;
127
- getNodeDraft(id: string): NodeData | undefined;
128
- getNodes(): NodeData[];
126
+ getNode(id: string): Node<TNode> | undefined;
127
+ getNodeDraft(id: string): Node<TNode> | undefined;
128
+ getNodes(): Node<TNode>[];
129
129
  getNodeRenderer(type: string): NodeRenderType | undefined;
130
- getEdge(id: string): EdgeData | undefined;
131
- getEdgeDraft(id: string): EdgeData | undefined;
132
- getEdges(): EdgeData[];
130
+ getEdge(id: string): Edge<TEdge> | undefined;
131
+ getEdgeDraft(id: string): Edge<TEdge> | undefined;
132
+ getEdges(): Edge<TEdge>[];
133
133
  getEdgeRenderer(type: string): EdgeRenderType | undefined;
134
134
  registerPluginData<T extends keyof PluginData, TP extends keyof PluginData[T]>(pluginName: T, property: TP, data: BehaviorSubject<PluginData[T][TP]>): void;
135
135
  resetPluginData<T extends keyof PluginData>(pluginName: T): void;
@@ -144,7 +144,7 @@ declare class Engine<TRenderType extends RenderType = RenderType> {
144
144
  canInteract(pluginId: string, type: string, autoStartPriority?: InteractionPriority): boolean;
145
145
  startInteraction(pluginId: string, type: string, priority: InteractionPriority): void;
146
146
  endInteraction(pluginId: string, type: string): void;
147
- callTool<T extends keyof PluginTools, TP extends keyof PluginTools[T]>(pluginName: T, toolName: TP, params: any): any;
147
+ callTool<T extends keyof PluginTools, TP extends keyof PluginTools[T]>(pluginName: T, toolName: TP, ...args: Parameters<PluginTools[T][TP]>): any;
148
148
  listPlugins(): IPluginInfo[];
149
149
  listPluginTools(pluginName: string): IPluginToolInfo[];
150
150
  listEngineTools(): IPluginToolInfo[];
@@ -214,4 +214,4 @@ declare function use<T, TContext>(hook: () => {
214
214
  __contextValue__: TContext;
215
215
  }, context: TContext): T;
216
216
 
217
- export { Container, EdgeData, EdgeRenderType, Engine, type EngineOptions, IEngineRuntime, IPlugin, IPluginInfo, IPluginToolInfo, type Interaction, InteractionManager, InteractionPriority, Layer, LayerComponent, NodeData, NodeRenderType, Plugin, PluginData, PluginTools, RenderType, Runtime, getLayerRenders, use };
217
+ export { Container, Edge, EdgeRenderType, Engine, type EngineOptions, IEngineRuntime, IPlugin, IPluginInfo, IPluginToolInfo, IRecord, type Interaction, InteractionManager, InteractionPriority, Layer, LayerComponent, Node, NodeRenderType, Plugin, PluginData, PluginTools, RenderType, Runtime, getLayerRenders, use };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as Container, P as Plugin, N as NodeData, E as EdgeData, I as IEngineRuntime, R as RenderType, L as LayerComponent, a as IPlugin, b as Layer, c as NodeRenderType, d as EdgeRenderType, e as PluginData, f as PluginTools, g as IPluginInfo, h as IPluginToolInfo } from './shared/core.BUBec6Va.js';
2
- export { B as BasePlugin, r as EdgeOperation, p as EdgeOperationPipe, t as EdgeOperatorFunction, l as EdgeProps, H as HorizontalAlignment, j as NodeMeasured, q as NodeOperation, o as NodeOperationPipe, s as NodeOperatorFunction, i as NodePosition, k as NodeProps, n as PluginConfigs, m as Position, V as VerticalAlignment } from './shared/core.BUBec6Va.js';
1
+ import { I as IRecord, C as Container, P as Plugin, N as Node, E as Edge, a as IEngineRuntime, R as RenderType, L as LayerComponent, b as IPlugin, c as Layer, d as NodeRenderType, e as EdgeRenderType, f as PluginData, g as PluginTools, h as IPluginInfo, i as IPluginToolInfo } from './shared/core.CgVCXkyd.js';
2
+ export { B as BasePlugin, s as EdgeOperation, q as EdgeOperationPipe, u as EdgeOperatorFunction, m as EdgeProps, H as HorizontalAlignment, k as NodeMeasured, r as NodeOperation, p as NodeOperationPipe, t as NodeOperatorFunction, j as NodePosition, l as NodeProps, o as PluginConfigs, n as Position, V as VerticalAlignment } from './shared/core.CgVCXkyd.js';
3
3
  import { Schema } from 'jsonschema';
4
4
  import { BehaviorSubject } from 'rxjs';
5
5
  import { DataManager, DataOperationPipe, DataOperation } from '@knotx/data';
@@ -85,19 +85,19 @@ declare class InteractionManager {
85
85
  private updateActive;
86
86
  }
87
87
 
88
- interface EngineOptions {
88
+ interface EngineOptions<TNode extends IRecord = IRecord, TEdge extends IRecord = IRecord> {
89
89
  container: Container;
90
90
  plugins?: Plugin[];
91
- pluginConfig?: Record<string, any>;
92
- nodes?: NodeData[];
93
- edges?: EdgeData[];
91
+ pluginConfig?: IRecord;
92
+ nodes?: Node<TNode>[];
93
+ edges?: Edge<TEdge>[];
94
94
  runtime?: IEngineRuntime;
95
95
  }
96
- declare class Engine<TRenderType extends RenderType = RenderType> {
96
+ declare class Engine<TRenderType extends RenderType = RenderType, TNode extends IRecord = IRecord, TEdge extends IRecord = IRecord> {
97
97
  readonly runtime: IEngineRuntime;
98
98
  readonly interactionManager: InteractionManager;
99
- readonly nodesManager: DataManager<NodeData>;
100
- readonly edgesManager: DataManager<EdgeData>;
99
+ readonly nodesManager: DataManager<Node<TNode>>;
100
+ readonly edgesManager: DataManager<Edge<TEdge>>;
101
101
  private container$;
102
102
  private nodes$;
103
103
  private edges$;
@@ -110,26 +110,26 @@ declare class Engine<TRenderType extends RenderType = RenderType> {
110
110
  private toolParamsValidator;
111
111
  get container(): Container;
112
112
  set container(value: Container);
113
- get nodes(): NodeData<any>[];
114
- get edges(): EdgeData<any>[];
113
+ get nodes(): Node<TNode>[];
114
+ get edges(): Edge<TEdge>[];
115
115
  get layers(): Map<number, LayerComponent<TRenderType>[]>;
116
116
  get plugins(): IPlugin<string, any, RenderType>[];
117
- constructor(options: EngineOptions);
117
+ constructor(options: EngineOptions<TNode, TEdge>);
118
118
  private init;
119
119
  getLayerComponents(layer: Layer): LayerComponent<TRenderType>[];
120
- addNodePipe(pipe: DataOperationPipe<NodeData>): () => void;
121
- addEdgePipe(pipe: DataOperationPipe<EdgeData>): () => void;
122
- changePluginConfig(pluginName: string, config: Record<string, any>): void;
123
- dispatchNodeOperation(operation: DataOperation<NodeData>): void;
124
- dispatchEdgeOperation(operation: DataOperation<EdgeData>): void;
120
+ addNodePipe(pipe: DataOperationPipe<Node<TNode>>): () => void;
121
+ addEdgePipe(pipe: DataOperationPipe<Edge<TEdge>>): () => void;
122
+ changePluginConfig(pluginName: string, config: IRecord): void;
123
+ dispatchNodeOperation(operation: DataOperation<Node<TNode>>): void;
124
+ dispatchEdgeOperation(operation: DataOperation<Edge<TEdge>>): void;
125
125
  getPlugin<TPlugin extends IPlugin>(pluginName: TPlugin['name']): TPlugin | undefined;
126
- getNode(id: string): NodeData | undefined;
127
- getNodeDraft(id: string): NodeData | undefined;
128
- getNodes(): NodeData[];
126
+ getNode(id: string): Node<TNode> | undefined;
127
+ getNodeDraft(id: string): Node<TNode> | undefined;
128
+ getNodes(): Node<TNode>[];
129
129
  getNodeRenderer(type: string): NodeRenderType | undefined;
130
- getEdge(id: string): EdgeData | undefined;
131
- getEdgeDraft(id: string): EdgeData | undefined;
132
- getEdges(): EdgeData[];
130
+ getEdge(id: string): Edge<TEdge> | undefined;
131
+ getEdgeDraft(id: string): Edge<TEdge> | undefined;
132
+ getEdges(): Edge<TEdge>[];
133
133
  getEdgeRenderer(type: string): EdgeRenderType | undefined;
134
134
  registerPluginData<T extends keyof PluginData, TP extends keyof PluginData[T]>(pluginName: T, property: TP, data: BehaviorSubject<PluginData[T][TP]>): void;
135
135
  resetPluginData<T extends keyof PluginData>(pluginName: T): void;
@@ -144,7 +144,7 @@ declare class Engine<TRenderType extends RenderType = RenderType> {
144
144
  canInteract(pluginId: string, type: string, autoStartPriority?: InteractionPriority): boolean;
145
145
  startInteraction(pluginId: string, type: string, priority: InteractionPriority): void;
146
146
  endInteraction(pluginId: string, type: string): void;
147
- callTool<T extends keyof PluginTools, TP extends keyof PluginTools[T]>(pluginName: T, toolName: TP, params: any): any;
147
+ callTool<T extends keyof PluginTools, TP extends keyof PluginTools[T]>(pluginName: T, toolName: TP, ...args: Parameters<PluginTools[T][TP]>): any;
148
148
  listPlugins(): IPluginInfo[];
149
149
  listPluginTools(pluginName: string): IPluginToolInfo[];
150
150
  listEngineTools(): IPluginToolInfo[];
@@ -214,4 +214,4 @@ declare function use<T, TContext>(hook: () => {
214
214
  __contextValue__: TContext;
215
215
  }, context: TContext): T;
216
216
 
217
- export { Container, EdgeData, EdgeRenderType, Engine, type EngineOptions, IEngineRuntime, IPlugin, IPluginInfo, IPluginToolInfo, type Interaction, InteractionManager, InteractionPriority, Layer, LayerComponent, NodeData, NodeRenderType, Plugin, PluginData, PluginTools, RenderType, Runtime, getLayerRenders, use };
217
+ export { Container, Edge, EdgeRenderType, Engine, type EngineOptions, IEngineRuntime, IPlugin, IPluginInfo, IPluginToolInfo, IRecord, type Interaction, InteractionManager, InteractionPriority, Layer, LayerComponent, Node, NodeRenderType, Plugin, PluginData, PluginTools, RenderType, Runtime, getLayerRenders, use };
package/dist/index.js CHANGED
@@ -303,12 +303,13 @@ class Engine {
303
303
  endInteraction(pluginId, type) {
304
304
  this.interactionManager.endInteraction(pluginId, type);
305
305
  }
306
- callTool(pluginName, toolName, params) {
306
+ callTool(pluginName, toolName, ...args) {
307
307
  const toolDefinition = get(this, ["_pluginToolsContainer", pluginName, toolName]);
308
308
  const tool = toolDefinition == null ? void 0 : toolDefinition.func;
309
309
  if (!tool || typeof tool !== "function") {
310
310
  throw new Error(`Tool ${String(toolName)} not found in plugin ${pluginName}`);
311
311
  }
312
+ const params = args[0];
312
313
  const validator = this.toolParamsValidator.validate(params, toolDefinition.params);
313
314
  if (validator.errors.length > 0) {
314
315
  throw new Error(`Invalid tool params: ${validator.errors.map((e) => e.stack).join(", ")}`);
@@ -2,7 +2,7 @@ import { Schema } from 'jsonschema';
2
2
  import { SubscriptionLike, BehaviorSubject } from 'rxjs';
3
3
  import { DataOperationPipe, DataOperation } from '@knotx/data';
4
4
 
5
- declare abstract class BasePlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = undefined, TRenderType extends RenderType = RenderType> implements IPlugin<TPluginName, TPluginConfig, TRenderType> {
5
+ declare abstract class BasePlugin<TPluginName extends string = string, TPluginConfig extends IRecord | undefined = undefined, TRenderType extends RenderType = RenderType> implements IPlugin<TPluginName, TPluginConfig, TRenderType> {
6
6
  abstract name: TPluginName;
7
7
  constructor(__: TPluginConfig);
8
8
  private static _instanceId;
@@ -18,6 +18,7 @@ declare abstract class BasePlugin<TPluginName extends string = string, TPluginCo
18
18
 
19
19
  type HorizontalAlignment = 'left' | 'right';
20
20
  type VerticalAlignment = 'top' | 'bottom';
21
+ type IRecord = Record<string, any>;
21
22
  interface NodePosition {
22
23
  x: number;
23
24
  y: number;
@@ -26,25 +27,25 @@ interface NodeMeasured {
26
27
  width: number;
27
28
  height: number;
28
29
  }
29
- interface NodeData<TData = any> {
30
+ interface Node<TData extends IRecord = IRecord> {
30
31
  id: string;
31
32
  type?: string;
32
33
  position: NodePosition;
33
34
  measured?: NodeMeasured;
34
35
  data: TData;
35
36
  }
36
- interface NodeProps<T = any> {
37
- node: NodeData<T>;
37
+ interface NodeProps<TData extends IRecord = IRecord> {
38
+ node: Node<TData>;
38
39
  }
39
- interface EdgeData<TData = any> {
40
+ interface Edge<TData extends IRecord = IRecord> {
40
41
  id: string;
41
42
  source: string;
42
43
  target: string;
43
44
  type?: string;
44
45
  data?: TData;
45
46
  }
46
- interface EdgeProps<T = any> {
47
- edge: EdgeData<T>;
47
+ interface EdgeProps<TData extends IRecord = IRecord> {
48
+ edge: Edge<TData>;
48
49
  sourceX: number;
49
50
  sourceY: number;
50
51
  targetX: number;
@@ -56,8 +57,8 @@ interface Container {
56
57
  }
57
58
  type Position = 'top' | 'right' | 'bottom' | 'left';
58
59
  type RenderType = (...args: any[]) => any;
59
- type NodeRenderType<TD extends Record<string, any> = any, TR = any> = (props: NodeProps<TD>) => TR;
60
- type EdgeRenderType<TD extends Record<string, any> = any, TR = any> = (props: EdgeProps<TD>) => TR;
60
+ type NodeRenderType<TD extends IRecord = any, TR = any> = (props: NodeProps<TD>) => TR;
61
+ type EdgeRenderType<TD extends IRecord = any, TR = any> = (props: EdgeProps<TD>) => TR;
61
62
  declare enum Layer {
62
63
  Canvas = 0,
63
64
  Background = 4,
@@ -77,7 +78,7 @@ interface LayerComponent<TRenderType> {
77
78
  */
78
79
  offset?: number;
79
80
  }
80
- interface IPlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> {
81
+ interface IPlugin<TPluginName extends string = string, TPluginConfig extends IRecord | undefined = any, TRenderType extends RenderType = RenderType> {
81
82
  name: TPluginName;
82
83
  pluginId: string;
83
84
  description?: string;
@@ -86,7 +87,7 @@ interface IPlugin<TPluginName extends string = string, TPluginConfig extends Rec
86
87
  onDestroy?: () => void;
87
88
  render?: (...args: Parameters<TRenderType>) => ReturnType<TRenderType>;
88
89
  }
89
- type Plugin<TName extends string = string, TConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> = new (__: TConfig) => BasePlugin<TName, TConfig, TRenderType>;
90
+ type Plugin<TName extends string = string, TConfig extends IRecord | undefined = any, TRenderType extends RenderType = RenderType> = new (__: TConfig) => BasePlugin<TName, TConfig, TRenderType>;
90
91
  type PluginConfigs<TPlugins extends Plugin[]> = ((TPlugins[number] extends Plugin<infer T> ? {
91
92
  [TName in T as Extract<TPlugins[number], Plugin<TName>> extends Plugin<TName, undefined> ? never : TName]: Extract<TPlugins[number], Plugin<TName>> extends infer T ? T extends Plugin<TName, infer TConfig> ? TConfig : never : never;
92
93
  } : {}));
@@ -126,12 +127,12 @@ interface IPluginToolInfo {
126
127
  description: string;
127
128
  parameters: Schema;
128
129
  }
129
- type NodeOperationPipe<T = any> = DataOperationPipe<NodeData<T>>;
130
- type EdgeOperationPipe<T = any> = DataOperationPipe<EdgeData<T>>;
131
- type NodeOperation<T = any> = DataOperation<NodeData<T>>;
132
- type EdgeOperation<T = any> = DataOperation<EdgeData<T>>;
133
- type NodeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => NodeOperation<T>[];
134
- type EdgeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => EdgeOperation<T>[];
130
+ type NodeOperationPipe<T extends IRecord = IRecord> = DataOperationPipe<Node<T>>;
131
+ type EdgeOperationPipe<T extends IRecord = IRecord> = DataOperationPipe<Edge<T>>;
132
+ type NodeOperation<T extends IRecord = IRecord> = DataOperation<Node<T>>;
133
+ type EdgeOperation<T extends IRecord = IRecord> = DataOperation<Edge<T>>;
134
+ type NodeOperatorFunction<T extends IRecord = IRecord, TArgs extends any[] = any[]> = (...args: TArgs) => NodeOperation<T>[];
135
+ type EdgeOperatorFunction<T extends IRecord = IRecord, TArgs extends any[] = any[]> = (...args: TArgs) => EdgeOperation<T>[];
135
136
  interface IEngineRuntime {
136
137
  render?: {
137
138
  getValue: <T, R = T>(value: BehaviorSubject<T> | T, options: {
@@ -142,4 +143,4 @@ interface IEngineRuntime {
142
143
  };
143
144
  }
144
145
 
145
- export { BasePlugin as B, type Container as C, type EdgeData as E, type HorizontalAlignment as H, type IEngineRuntime as I, type LayerComponent as L, type NodeData as N, type Plugin as P, type RenderType as R, type VerticalAlignment as V, type IPlugin as a, Layer as b, type NodeRenderType as c, type EdgeRenderType as d, type PluginData as e, type PluginTools as f, type IPluginInfo as g, type IPluginToolInfo as h, type NodePosition as i, type NodeMeasured as j, type NodeProps as k, type EdgeProps as l, type Position as m, type PluginConfigs as n, type NodeOperationPipe as o, type EdgeOperationPipe as p, type NodeOperation as q, type EdgeOperation as r, type NodeOperatorFunction as s, type EdgeOperatorFunction as t };
146
+ export { BasePlugin as B, type Container as C, type Edge as E, type HorizontalAlignment as H, type IRecord as I, type LayerComponent as L, type Node as N, type Plugin as P, type RenderType as R, type VerticalAlignment as V, type IEngineRuntime as a, type IPlugin as b, Layer as c, type NodeRenderType as d, type EdgeRenderType as e, type PluginData as f, type PluginTools as g, type IPluginInfo as h, type IPluginToolInfo as i, type NodePosition as j, type NodeMeasured as k, type NodeProps as l, type EdgeProps as m, type Position as n, type PluginConfigs as o, type NodeOperationPipe as p, type EdgeOperationPipe as q, type NodeOperation as r, type EdgeOperation as s, type NodeOperatorFunction as t, type EdgeOperatorFunction as u };
@@ -2,7 +2,7 @@ import { Schema } from 'jsonschema';
2
2
  import { SubscriptionLike, BehaviorSubject } from 'rxjs';
3
3
  import { DataOperationPipe, DataOperation } from '@knotx/data';
4
4
 
5
- declare abstract class BasePlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = undefined, TRenderType extends RenderType = RenderType> implements IPlugin<TPluginName, TPluginConfig, TRenderType> {
5
+ declare abstract class BasePlugin<TPluginName extends string = string, TPluginConfig extends IRecord | undefined = undefined, TRenderType extends RenderType = RenderType> implements IPlugin<TPluginName, TPluginConfig, TRenderType> {
6
6
  abstract name: TPluginName;
7
7
  constructor(__: TPluginConfig);
8
8
  private static _instanceId;
@@ -18,6 +18,7 @@ declare abstract class BasePlugin<TPluginName extends string = string, TPluginCo
18
18
 
19
19
  type HorizontalAlignment = 'left' | 'right';
20
20
  type VerticalAlignment = 'top' | 'bottom';
21
+ type IRecord = Record<string, any>;
21
22
  interface NodePosition {
22
23
  x: number;
23
24
  y: number;
@@ -26,25 +27,25 @@ interface NodeMeasured {
26
27
  width: number;
27
28
  height: number;
28
29
  }
29
- interface NodeData<TData = any> {
30
+ interface Node<TData extends IRecord = IRecord> {
30
31
  id: string;
31
32
  type?: string;
32
33
  position: NodePosition;
33
34
  measured?: NodeMeasured;
34
35
  data: TData;
35
36
  }
36
- interface NodeProps<T = any> {
37
- node: NodeData<T>;
37
+ interface NodeProps<TData extends IRecord = IRecord> {
38
+ node: Node<TData>;
38
39
  }
39
- interface EdgeData<TData = any> {
40
+ interface Edge<TData extends IRecord = IRecord> {
40
41
  id: string;
41
42
  source: string;
42
43
  target: string;
43
44
  type?: string;
44
45
  data?: TData;
45
46
  }
46
- interface EdgeProps<T = any> {
47
- edge: EdgeData<T>;
47
+ interface EdgeProps<TData extends IRecord = IRecord> {
48
+ edge: Edge<TData>;
48
49
  sourceX: number;
49
50
  sourceY: number;
50
51
  targetX: number;
@@ -56,8 +57,8 @@ interface Container {
56
57
  }
57
58
  type Position = 'top' | 'right' | 'bottom' | 'left';
58
59
  type RenderType = (...args: any[]) => any;
59
- type NodeRenderType<TD extends Record<string, any> = any, TR = any> = (props: NodeProps<TD>) => TR;
60
- type EdgeRenderType<TD extends Record<string, any> = any, TR = any> = (props: EdgeProps<TD>) => TR;
60
+ type NodeRenderType<TD extends IRecord = any, TR = any> = (props: NodeProps<TD>) => TR;
61
+ type EdgeRenderType<TD extends IRecord = any, TR = any> = (props: EdgeProps<TD>) => TR;
61
62
  declare enum Layer {
62
63
  Canvas = 0,
63
64
  Background = 4,
@@ -77,7 +78,7 @@ interface LayerComponent<TRenderType> {
77
78
  */
78
79
  offset?: number;
79
80
  }
80
- interface IPlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> {
81
+ interface IPlugin<TPluginName extends string = string, TPluginConfig extends IRecord | undefined = any, TRenderType extends RenderType = RenderType> {
81
82
  name: TPluginName;
82
83
  pluginId: string;
83
84
  description?: string;
@@ -86,7 +87,7 @@ interface IPlugin<TPluginName extends string = string, TPluginConfig extends Rec
86
87
  onDestroy?: () => void;
87
88
  render?: (...args: Parameters<TRenderType>) => ReturnType<TRenderType>;
88
89
  }
89
- type Plugin<TName extends string = string, TConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> = new (__: TConfig) => BasePlugin<TName, TConfig, TRenderType>;
90
+ type Plugin<TName extends string = string, TConfig extends IRecord | undefined = any, TRenderType extends RenderType = RenderType> = new (__: TConfig) => BasePlugin<TName, TConfig, TRenderType>;
90
91
  type PluginConfigs<TPlugins extends Plugin[]> = ((TPlugins[number] extends Plugin<infer T> ? {
91
92
  [TName in T as Extract<TPlugins[number], Plugin<TName>> extends Plugin<TName, undefined> ? never : TName]: Extract<TPlugins[number], Plugin<TName>> extends infer T ? T extends Plugin<TName, infer TConfig> ? TConfig : never : never;
92
93
  } : {}));
@@ -126,12 +127,12 @@ interface IPluginToolInfo {
126
127
  description: string;
127
128
  parameters: Schema;
128
129
  }
129
- type NodeOperationPipe<T = any> = DataOperationPipe<NodeData<T>>;
130
- type EdgeOperationPipe<T = any> = DataOperationPipe<EdgeData<T>>;
131
- type NodeOperation<T = any> = DataOperation<NodeData<T>>;
132
- type EdgeOperation<T = any> = DataOperation<EdgeData<T>>;
133
- type NodeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => NodeOperation<T>[];
134
- type EdgeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => EdgeOperation<T>[];
130
+ type NodeOperationPipe<T extends IRecord = IRecord> = DataOperationPipe<Node<T>>;
131
+ type EdgeOperationPipe<T extends IRecord = IRecord> = DataOperationPipe<Edge<T>>;
132
+ type NodeOperation<T extends IRecord = IRecord> = DataOperation<Node<T>>;
133
+ type EdgeOperation<T extends IRecord = IRecord> = DataOperation<Edge<T>>;
134
+ type NodeOperatorFunction<T extends IRecord = IRecord, TArgs extends any[] = any[]> = (...args: TArgs) => NodeOperation<T>[];
135
+ type EdgeOperatorFunction<T extends IRecord = IRecord, TArgs extends any[] = any[]> = (...args: TArgs) => EdgeOperation<T>[];
135
136
  interface IEngineRuntime {
136
137
  render?: {
137
138
  getValue: <T, R = T>(value: BehaviorSubject<T> | T, options: {
@@ -142,4 +143,4 @@ interface IEngineRuntime {
142
143
  };
143
144
  }
144
145
 
145
- export { BasePlugin as B, type Container as C, type EdgeData as E, type HorizontalAlignment as H, type IEngineRuntime as I, type LayerComponent as L, type NodeData as N, type Plugin as P, type RenderType as R, type VerticalAlignment as V, type IPlugin as a, Layer as b, type NodeRenderType as c, type EdgeRenderType as d, type PluginData as e, type PluginTools as f, type IPluginInfo as g, type IPluginToolInfo as h, type NodePosition as i, type NodeMeasured as j, type NodeProps as k, type EdgeProps as l, type Position as m, type PluginConfigs as n, type NodeOperationPipe as o, type EdgeOperationPipe as p, type NodeOperation as q, type EdgeOperation as r, type NodeOperatorFunction as s, type EdgeOperatorFunction as t };
146
+ export { BasePlugin as B, type Container as C, type Edge as E, type HorizontalAlignment as H, type IRecord as I, type LayerComponent as L, type Node as N, type Plugin as P, type RenderType as R, type VerticalAlignment as V, type IEngineRuntime as a, type IPlugin as b, Layer as c, type NodeRenderType as d, type EdgeRenderType as e, type PluginData as f, type PluginTools as g, type IPluginInfo as h, type IPluginToolInfo as i, type NodePosition as j, type NodeMeasured as k, type NodeProps as l, type EdgeProps as m, type Position as n, type PluginConfigs as o, type NodeOperationPipe as p, type EdgeOperationPipe as q, type NodeOperation as r, type EdgeOperation as s, type NodeOperatorFunction as t, type EdgeOperatorFunction as u };
@@ -2,7 +2,7 @@ import { Schema } from 'jsonschema';
2
2
  import { SubscriptionLike, BehaviorSubject } from 'rxjs';
3
3
  import { DataOperationPipe, DataOperation } from '@knotx/data';
4
4
 
5
- declare abstract class BasePlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = undefined, TRenderType extends RenderType = RenderType> implements IPlugin<TPluginName, TPluginConfig, TRenderType> {
5
+ declare abstract class BasePlugin<TPluginName extends string = string, TPluginConfig extends IRecord | undefined = undefined, TRenderType extends RenderType = RenderType> implements IPlugin<TPluginName, TPluginConfig, TRenderType> {
6
6
  abstract name: TPluginName;
7
7
  constructor(__: TPluginConfig);
8
8
  private static _instanceId;
@@ -18,6 +18,7 @@ declare abstract class BasePlugin<TPluginName extends string = string, TPluginCo
18
18
 
19
19
  type HorizontalAlignment = 'left' | 'right';
20
20
  type VerticalAlignment = 'top' | 'bottom';
21
+ type IRecord = Record<string, any>;
21
22
  interface NodePosition {
22
23
  x: number;
23
24
  y: number;
@@ -26,25 +27,25 @@ interface NodeMeasured {
26
27
  width: number;
27
28
  height: number;
28
29
  }
29
- interface NodeData<TData = any> {
30
+ interface Node<TData extends IRecord = IRecord> {
30
31
  id: string;
31
32
  type?: string;
32
33
  position: NodePosition;
33
34
  measured?: NodeMeasured;
34
35
  data: TData;
35
36
  }
36
- interface NodeProps<T = any> {
37
- node: NodeData<T>;
37
+ interface NodeProps<TData extends IRecord = IRecord> {
38
+ node: Node<TData>;
38
39
  }
39
- interface EdgeData<TData = any> {
40
+ interface Edge<TData extends IRecord = IRecord> {
40
41
  id: string;
41
42
  source: string;
42
43
  target: string;
43
44
  type?: string;
44
45
  data?: TData;
45
46
  }
46
- interface EdgeProps<T = any> {
47
- edge: EdgeData<T>;
47
+ interface EdgeProps<TData extends IRecord = IRecord> {
48
+ edge: Edge<TData>;
48
49
  sourceX: number;
49
50
  sourceY: number;
50
51
  targetX: number;
@@ -56,8 +57,8 @@ interface Container {
56
57
  }
57
58
  type Position = 'top' | 'right' | 'bottom' | 'left';
58
59
  type RenderType = (...args: any[]) => any;
59
- type NodeRenderType<TD extends Record<string, any> = any, TR = any> = (props: NodeProps<TD>) => TR;
60
- type EdgeRenderType<TD extends Record<string, any> = any, TR = any> = (props: EdgeProps<TD>) => TR;
60
+ type NodeRenderType<TD extends IRecord = any, TR = any> = (props: NodeProps<TD>) => TR;
61
+ type EdgeRenderType<TD extends IRecord = any, TR = any> = (props: EdgeProps<TD>) => TR;
61
62
  declare enum Layer {
62
63
  Canvas = 0,
63
64
  Background = 4,
@@ -77,7 +78,7 @@ interface LayerComponent<TRenderType> {
77
78
  */
78
79
  offset?: number;
79
80
  }
80
- interface IPlugin<TPluginName extends string = string, TPluginConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> {
81
+ interface IPlugin<TPluginName extends string = string, TPluginConfig extends IRecord | undefined = any, TRenderType extends RenderType = RenderType> {
81
82
  name: TPluginName;
82
83
  pluginId: string;
83
84
  description?: string;
@@ -86,7 +87,7 @@ interface IPlugin<TPluginName extends string = string, TPluginConfig extends Rec
86
87
  onDestroy?: () => void;
87
88
  render?: (...args: Parameters<TRenderType>) => ReturnType<TRenderType>;
88
89
  }
89
- type Plugin<TName extends string = string, TConfig extends Record<string, any> | undefined = any, TRenderType extends RenderType = RenderType> = new (__: TConfig) => BasePlugin<TName, TConfig, TRenderType>;
90
+ type Plugin<TName extends string = string, TConfig extends IRecord | undefined = any, TRenderType extends RenderType = RenderType> = new (__: TConfig) => BasePlugin<TName, TConfig, TRenderType>;
90
91
  type PluginConfigs<TPlugins extends Plugin[]> = ((TPlugins[number] extends Plugin<infer T> ? {
91
92
  [TName in T as Extract<TPlugins[number], Plugin<TName>> extends Plugin<TName, undefined> ? never : TName]: Extract<TPlugins[number], Plugin<TName>> extends infer T ? T extends Plugin<TName, infer TConfig> ? TConfig : never : never;
92
93
  } : {}));
@@ -126,12 +127,12 @@ interface IPluginToolInfo {
126
127
  description: string;
127
128
  parameters: Schema;
128
129
  }
129
- type NodeOperationPipe<T = any> = DataOperationPipe<NodeData<T>>;
130
- type EdgeOperationPipe<T = any> = DataOperationPipe<EdgeData<T>>;
131
- type NodeOperation<T = any> = DataOperation<NodeData<T>>;
132
- type EdgeOperation<T = any> = DataOperation<EdgeData<T>>;
133
- type NodeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => NodeOperation<T>[];
134
- type EdgeOperatorFunction<T = any, Args extends any[] = any[]> = (...args: Args) => EdgeOperation<T>[];
130
+ type NodeOperationPipe<T extends IRecord = IRecord> = DataOperationPipe<Node<T>>;
131
+ type EdgeOperationPipe<T extends IRecord = IRecord> = DataOperationPipe<Edge<T>>;
132
+ type NodeOperation<T extends IRecord = IRecord> = DataOperation<Node<T>>;
133
+ type EdgeOperation<T extends IRecord = IRecord> = DataOperation<Edge<T>>;
134
+ type NodeOperatorFunction<T extends IRecord = IRecord, TArgs extends any[] = any[]> = (...args: TArgs) => NodeOperation<T>[];
135
+ type EdgeOperatorFunction<T extends IRecord = IRecord, TArgs extends any[] = any[]> = (...args: TArgs) => EdgeOperation<T>[];
135
136
  interface IEngineRuntime {
136
137
  render?: {
137
138
  getValue: <T, R = T>(value: BehaviorSubject<T> | T, options: {
@@ -142,4 +143,4 @@ interface IEngineRuntime {
142
143
  };
143
144
  }
144
145
 
145
- export { BasePlugin as B, type Container as C, type EdgeData as E, type HorizontalAlignment as H, type IEngineRuntime as I, type LayerComponent as L, type NodeData as N, type Plugin as P, type RenderType as R, type VerticalAlignment as V, type IPlugin as a, Layer as b, type NodeRenderType as c, type EdgeRenderType as d, type PluginData as e, type PluginTools as f, type IPluginInfo as g, type IPluginToolInfo as h, type NodePosition as i, type NodeMeasured as j, type NodeProps as k, type EdgeProps as l, type Position as m, type PluginConfigs as n, type NodeOperationPipe as o, type EdgeOperationPipe as p, type NodeOperation as q, type EdgeOperation as r, type NodeOperatorFunction as s, type EdgeOperatorFunction as t };
146
+ export { BasePlugin as B, type Container as C, type Edge as E, type HorizontalAlignment as H, type IRecord as I, type LayerComponent as L, type Node as N, type Plugin as P, type RenderType as R, type VerticalAlignment as V, type IEngineRuntime as a, type IPlugin as b, Layer as c, type NodeRenderType as d, type EdgeRenderType as e, type PluginData as f, type PluginTools as g, type IPluginInfo as h, type IPluginToolInfo as i, type NodePosition as j, type NodeMeasured as k, type NodeProps as l, type EdgeProps as m, type Position as n, type PluginConfigs as o, type NodeOperationPipe as p, type EdgeOperationPipe as q, type NodeOperation as r, type EdgeOperation as s, type NodeOperatorFunction as t, type EdgeOperatorFunction as u };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knotx/core",
3
- "version": "0.2.10",
3
+ "version": "0.2.11",
4
4
  "description": "Core for Knotx",
5
5
  "author": "boenfu",
6
6
  "license": "MIT",
@@ -46,14 +46,14 @@
46
46
  "jsonschema": "^1.5.0",
47
47
  "lodash-es": "^4.17.21",
48
48
  "rxjs": "^7.8.1",
49
- "@knotx/data": "0.2.10",
50
- "@knotx/utils": "0.2.10"
49
+ "@knotx/data": "0.2.11",
50
+ "@knotx/utils": "0.2.11"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/lodash-es": "^4.17.12",
54
- "@knotx/build-config": "0.2.10",
55
- "@knotx/eslint-config": "0.2.10",
56
- "@knotx/typescript-config": "0.2.10"
54
+ "@knotx/build-config": "0.2.11",
55
+ "@knotx/eslint-config": "0.2.11",
56
+ "@knotx/typescript-config": "0.2.11"
57
57
  },
58
58
  "scripts": {
59
59
  "build": "unbuild",