@aloudata/ink-lineage 0.0.1-beta.2 → 0.0.1-beta.21

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.
Files changed (50) hide show
  1. package/package.json +10 -7
  2. package/src/assets/big/dataSourceTypeIcon.ts +0 -65
  3. package/src/assets/big/entityType.ts +0 -1
  4. package/src/assets/big/index.ts +0 -5
  5. package/src/assets/big/lineageIcon.ts +0 -35
  6. package/src/assets/big/tableTypeIcon.ts +0 -17
  7. package/src/assets/big/tipIcon.ts +0 -1
  8. package/src/assets/index.ts +0 -14
  9. package/src/components/Edges/DefaultEdge.ts +0 -196
  10. package/src/components/Edges/FoldEdge.ts +0 -97
  11. package/src/components/Edges/LineageEdge.ts +0 -24
  12. package/src/components/Edges/index.ts +0 -3
  13. package/src/components/Nodes/AssetNode.ts +0 -438
  14. package/src/components/Nodes/ColumnNode.ts +0 -491
  15. package/src/components/Nodes/CustomNode.ts +0 -63
  16. package/src/components/Nodes/DefaultNode.ts +0 -74
  17. package/src/components/Nodes/DowngradeNode.ts +0 -115
  18. package/src/components/Nodes/TableNode.ts +0 -534
  19. package/src/components/Nodes/index.ts +0 -4
  20. package/src/components/index.ts +0 -2
  21. package/src/constant/index.ts +0 -1
  22. package/src/constant/nodeStyle.ts +0 -141
  23. package/src/index.ts +0 -6
  24. package/src/manager/BaseManager.ts +0 -20
  25. package/src/manager/DataProcessor.ts +0 -782
  26. package/src/manager/ExpandManager.ts +0 -93
  27. package/src/manager/FoldLineageManager.ts +0 -196
  28. package/src/manager/GraphEventManager.ts +0 -90
  29. package/src/manager/LineageManager.ts +0 -680
  30. package/src/manager/RightKeyMenuManager.ts +0 -114
  31. package/src/manager/SearchNodeManager.ts +0 -188
  32. package/src/manager/ToolbarManager.ts +0 -42
  33. package/src/manager/index.ts +0 -8
  34. package/src/manager/nodeManager/AssetEventManager.ts +0 -442
  35. package/src/manager/nodeManager/BaseEventManager.ts +0 -68
  36. package/src/manager/nodeManager/ColumnEventManager.ts +0 -467
  37. package/src/manager/nodeManager/CustomEventManager.ts +0 -11
  38. package/src/manager/nodeManager/TableEventManager.ts +0 -87
  39. package/src/manager/nodeManager/index.ts +0 -3
  40. package/src/types/NodeConfig.ts +0 -69
  41. package/src/types/eventEnum.ts +0 -58
  42. package/src/types/index.ts +0 -3
  43. package/src/types/manager.ts +0 -75
  44. package/src/types/node.ts +0 -246
  45. package/src/utils/downgradeNode.ts +0 -22
  46. package/src/utils/foldNode.ts +0 -345
  47. package/src/utils/getIconByType.ts +0 -104
  48. package/src/utils/index.ts +0 -3
  49. package/src/utils/node.ts +0 -294
  50. package/tsconfig.json +0 -30
@@ -1,442 +0,0 @@
1
-
2
- import { InkLineageManager } from '..';
3
- import _ from 'lodash';
4
- import { IParsedGraphData } from '../DataProcessor';
5
- import { BaseEventManager } from './BaseEventManager';
6
- import { AssetEventType, EEventEnum, EventEnumType } from '../../types';
7
- import { getOverviewType, groupNodesByEdgesAndDirection } from '../../utils';
8
- import {
9
- EElementType,
10
- IColumnConfig,
11
- IAssetNode,
12
- INode,
13
- IColResBase,
14
- INodeConfig,
15
- IEdgeConfig,
16
- TDataBase,
17
- EExpandType,
18
- EDirection,
19
- EEntityType,
20
- EDashType,
21
- } from '../../types';
22
-
23
- export class AssetEventManager<
24
- TTableData extends TDataBase<TColumnData>,
25
- TColumnData extends IColResBase,
26
- > extends BaseEventManager<TTableData, TColumnData> {
27
- declare eventsType: AssetEventType;
28
-
29
- constructor(lineageManager: InkLineageManager<TTableData, TColumnData>, eventsType: EventEnumType) {
30
- super(lineageManager, eventsType);
31
- }
32
-
33
- registerExtraEvents(): void {
34
- this.lineageManager.on(this.eventsType.HEADER_CLICK, (node: IAssetNode) => {
35
- this.onHeaderClick(node);
36
- });
37
- }
38
-
39
- hideSideIcon = (node) => {
40
- // hide all side expand & close icon
41
- node.leftIcon?.setAttribute('visibility', 'hidden');
42
- node.rightIcon?.setAttribute('visibility', 'hidden');
43
- };
44
-
45
- onHeaderClick(node) {
46
- const onlyShowRelated =
47
- !!this.lineageManager?.rightKeyMenuManager?.onlyShowRelated;
48
-
49
- // hide context menu
50
- this.lineageManager?.hideContextMenu();
51
-
52
- // show detail panel
53
- this.showDetailPanel(node);
54
-
55
- if (!onlyShowRelated) {
56
- // update active status
57
- this.lineageManager?.updateActiveNodes([node.config]);
58
-
59
- // update related nodes & edges
60
- this.lineageManager?.setRelatedNodesAndEdges(node.config);
61
- }
62
- }
63
-
64
- showDetailPanel = async (node) => {
65
- // 将data同步到atom,触发更新
66
- const { userClosed, visible } =
67
- this.lineageManager?.rightKeyMenuManager?.overviewState;
68
-
69
- this.lineageManager.setOverview({
70
- ...this.lineageManager?.rightKeyMenuManager?.overviewState,
71
- targetId: node.config.id,
72
- type: getOverviewType(node.config?.data?.type),
73
- visible: !(userClosed && !visible),
74
- initial: true,
75
- taskIsHighlight: false,
76
- });
77
- };
78
-
79
- onContextMenu(node) {
80
- const { isStartNode, id, data } = node.config;
81
- if (!data) return;
82
-
83
- const { name, typeCode, type } = data;
84
-
85
- // 任务血缘的临时表没有右键功能
86
- if (type === EEntityType.TEMP_TABLE) return;
87
-
88
- const { y } = (node as IAssetNode).headerName.style;
89
-
90
- const [translateX, translateY] = (
91
- node as IAssetNode
92
- ).headerName.getPosition();
93
- const left = 100 + translateX;
94
- const top = Number(y) + translateY - 10;
95
-
96
- this.lineageManager.showContextMenu({
97
- id,
98
- visible: true,
99
- x: left,
100
- y: top,
101
- type: EElementType.TABLE,
102
- typeCode,
103
- isStartNode,
104
- name,
105
- });
106
- }
107
-
108
- onLeftIconClick(node) {
109
- if (this.lineageManager.isExpanding) return;
110
-
111
- const iconType = (node.leftIcon as any).iconType as EExpandType;
112
- if (iconType === EExpandType.EXPAND) {
113
- this.handleExpand({
114
- direction: EDirection.INPUT,
115
- node,
116
- });
117
- }
118
-
119
- if (iconType === EExpandType.FOLD) {
120
- this.handleFold(EDirection.INPUT, node);
121
- }
122
- }
123
-
124
- onRightIconClick(node) {
125
- if (this.lineageManager.isExpanding) return;
126
-
127
- const iconType = (node.rightIcon as any).iconType as EExpandType;
128
- if (iconType === EExpandType.EXPAND) {
129
- this.handleExpand({
130
- direction: EDirection.OUTPUT,
131
- node,
132
- });
133
- }
134
-
135
- if (iconType === EExpandType.FOLD) {
136
- this.handleFold(EDirection.OUTPUT, node);
137
- }
138
- }
139
-
140
- handleFold(direction: EDirection, curNode) {
141
- this.lineageManager?.resetActiveNodes();
142
-
143
- const { nodes, edges } = this.lineageManager.parsedData;
144
-
145
- // find related nodes and edges
146
- const relatedNodesAndEdges = groupNodesByEdgesAndDirection<TTableData, TColumnData>(
147
- curNode.config,
148
- nodes,
149
- edges,
150
- direction,
151
- false,
152
- true,
153
- );
154
-
155
- if (!relatedNodesAndEdges) return;
156
-
157
- // update curr node config
158
- if (direction === EDirection.INPUT) {
159
- curNode.config.isFoldInput = true;
160
- } else {
161
- curNode.config.isFoldOutput = true;
162
- }
163
-
164
- const relatedNodesIds = Array.from(
165
- relatedNodesAndEdges.groupedNodes.keys(),
166
- );
167
-
168
- const needRemovedNode: INodeConfig<TTableData, TColumnData>[] = [];
169
- const needRemovedEdge: IEdgeConfig[] = [];
170
-
171
- relatedNodesIds.forEach((nodeId) => {
172
- // exclude curr node
173
- if (nodeId === curNode.config.id) return;
174
-
175
- // find all inputNodes
176
- const inputNodes: string[] = [];
177
- // find all outputNodes
178
- const outputNodes: string[] = [];
179
-
180
- edges.forEach((edge) => {
181
- if (
182
- edge.target === nodeId &&
183
- (edge.visible || edge.relationType === EDashType.INDIRECT)
184
- ) {
185
- inputNodes.push(edge.source);
186
- }
187
-
188
- if (
189
- edge.source === nodeId &&
190
- (edge.visible || edge.relationType === EDashType.INDIRECT)
191
- ) {
192
- outputNodes.push(edge.target);
193
- }
194
- });
195
-
196
- // exclude multi relation nodes
197
- if (
198
- inputNodes.length > 1 &&
199
- !inputNodes.every((id) => {
200
- // includes related columns
201
- const n = this.lineageManager.getNodeConfigById(id);
202
-
203
- return (
204
- relatedNodesIds.includes(id) ||
205
- relatedNodesIds.includes((n as IColumnConfig<TColumnData>)?.tableId)
206
- );
207
- })
208
- ) {
209
- return;
210
- }
211
-
212
- if (
213
- outputNodes.length > 1 &&
214
- !outputNodes.every((id) => {
215
- // includes related columns
216
- const n = this.lineageManager.getNodeConfigById(id);
217
- return (
218
- relatedNodesIds.includes(id) ||
219
- relatedNodesIds.includes((n as IColumnConfig<TColumnData>)?.tableId)
220
- );
221
- })
222
- ) {
223
- return;
224
- }
225
-
226
- const node = this.lineageManager.getNodeConfigById(nodeId) as INodeConfig<TTableData, TColumnData>;
227
- needRemovedNode.push(node);
228
- });
229
-
230
- relatedNodesAndEdges.relatedEdges.forEach((edgeCfg) => {
231
- needRemovedEdge.push(edgeCfg);
232
-
233
- let sourceNode: INodeConfig<TTableData, TColumnData>;
234
- let targetNode: INodeConfig<TTableData, TColumnData>;
235
-
236
- (this.lineageManager.parsedData.nodes as INodeConfig<TTableData, TColumnData>[]).forEach((n) => {
237
- if (n.id === edgeCfg.source) {
238
- sourceNode = n;
239
- }
240
- if (n.id === edgeCfg.target) {
241
- targetNode = n;
242
- }
243
- });
244
-
245
- const srcRelatedColumnsId =
246
- sourceNode?.relatedColumns?.map((col) => col.id) || [];
247
- const tgtRelatedColumnsId =
248
- targetNode?.relatedColumns?.map((col) => col.id) || [];
249
-
250
- const relatedColumnEdge = edges.filter(
251
- (edge) =>
252
- srcRelatedColumnsId.includes(edge.source) &&
253
- tgtRelatedColumnsId.includes(edge.target),
254
- );
255
-
256
- relatedColumnEdge.forEach((edge) => {
257
- needRemovedEdge.push(edge);
258
- });
259
- });
260
-
261
- this.lineageManager.setData({
262
- nodes: _.without(
263
- this.lineageManager.parsedData.nodes,
264
- ...needRemovedNode,
265
- ),
266
- edges: _.without(
267
- this.lineageManager.parsedData.edges,
268
- ...needRemovedEdge,
269
- ),
270
- });
271
-
272
- this.lineageManager?.resetRelatedNodes(false);
273
- this.lineageManager?.update();
274
- }
275
-
276
- async handleExpand({
277
- direction,
278
- depth = 1,
279
- node,
280
- }: {
281
- direction: EDirection;
282
- depth?: number;
283
- node: INode;
284
- }) {
285
- let needLayout = true;
286
-
287
- // reset related nodes
288
- this.lineageManager?.resetRelatedNodes();
289
-
290
- // update curr node config
291
- if (direction === EDirection.INPUT) {
292
- node.config.isFoldInput = false;
293
- } else {
294
- node.config.isFoldOutput = false;
295
- }
296
-
297
- // custom没有363这段判断
298
- if (
299
- (node.config.data as TDataBase<IColResBase>).isHotspot &&
300
- (node.config.data as any).hotspots?.some(
301
- (h) => h.direction === direction && h.candidateCnt > 20,
302
- )
303
- ) {
304
- // hotspot expand
305
- this.lineageManager.updateHotspotModalState({
306
- id: node.config.id,
307
- visible: true,
308
- direction,
309
- });
310
- } else {
311
- // normal expand
312
- // show expand loading
313
- this.lineageManager?.showExpandLoading(node, direction);
314
-
315
- // fetch data
316
- const params = {
317
- depth,
318
- direction,
319
- guid: node.config?.id,
320
- };
321
- const getNewDataPromise = new Promise<IParsedGraphData<TTableData, TColumnData>>((resolve) => {
322
- this.lineageManager.once(
323
- EEventEnum.TABLE_EXPAND_RESPONSE,
324
- (response: IParsedGraphData<TTableData, TColumnData>) => {
325
- resolve(response);
326
- },
327
- );
328
-
329
- this.lineageManager.emit(EEventEnum.TABLE_EXPAND, params);
330
- });
331
-
332
- // Wait for the response
333
- const newData = await getNewDataPromise;
334
-
335
- // hide expand loading
336
- this.lineageManager?.hideExpandLoading();
337
-
338
- if (!newData) return;
339
- const { nodes, edges } = newData;
340
-
341
- if (
342
- nodes.length > 0 &&
343
- nodes.some(
344
- (e) => e.id === node.config.id && e.data?.isHotspot,
345
- )
346
- ) {
347
- // hotspot expand
348
- this.lineageManager.updateHotspotModalState({
349
- id: node.config.id,
350
- visible: true,
351
- direction,
352
- });
353
-
354
- return;
355
- }
356
-
357
- if (
358
- nodes.length > 0 &&
359
- nodes.some((e) => e.data.isHotspot)
360
- ) {
361
- this.lineageManager.emit(EEventEnum.INDIRECT_TIPS, {
362
- message: '存在热点资产',
363
- description:
364
- '本次探索过程中存在热点资产,热点资产默认不继续探索,请手动探索后展开',
365
- position: 'top-center',
366
- });
367
- }
368
-
369
- // show no more linage
370
- if (edges.length <= 0) {
371
- if (direction === EDirection.INPUT) node.config.hasMoreInput = false;
372
- if (direction === EDirection.OUTPUT) node.config.hasMoreOutput = false;
373
-
374
- this.lineageManager.emit(EEventEnum.INDIRECT_TIPS, { message: `该节点无${direction === EDirection.INPUT ? '上游' : '下游'}血缘` });
375
- needLayout = false;
376
- } else {
377
- // show indirect warning
378
- if (
379
- edges
380
- .filter((e) =>
381
- direction === EDirection.INPUT
382
- ? e.target === node.id
383
- : e.source === node.id,
384
- )
385
- .every((e) => e.relationType === EDashType.INDIRECT) &&
386
- this.lineageManager?.rightKeyMenuManager?.edgeDashVisible ===
387
- EDashType.DIRECT
388
- ) {
389
- this.lineageManager.emit(EEventEnum.INDIRECT_TIPS, {
390
- message: '当前字段只有间接血缘,请打开间接血缘开关后查看',
391
- });
392
-
393
- needLayout = false;
394
- }
395
-
396
- const prevNodesConfig = this.lineageManager.parsedData.nodes;
397
- const prevEdgesConfig = this.lineageManager.parsedData.edges;
398
-
399
- const newNodesConfig = _.unionBy([...prevNodesConfig, ...nodes], 'id');
400
- const newEdgesConfig = _.unionBy([...prevEdgesConfig, ...edges], 'id');
401
-
402
- // 下面custom没有这段逻辑
403
- nodes.forEach((nodeCfg) => {
404
- const newNode = newNodesConfig.find((n) => n.id === nodeCfg.id);
405
- if (newNode && (nodeCfg.data as any).isHotspot) {
406
- (newNode.data as any).isHotspot = (nodeCfg.data as any).isHotspot;
407
- (newNode.data as any).hotspots = (nodeCfg.data as any).hotspots;
408
- }
409
- });
410
-
411
- this.lineageManager.setData({
412
- nodes: newNodesConfig,
413
- edges: newEdgesConfig,
414
- });
415
-
416
- this.graph?.render();
417
- }
418
- }
419
-
420
- const onlyShowRelated =
421
- !!this.lineageManager?.rightKeyMenuManager?.onlyShowRelated;
422
-
423
- if (!onlyShowRelated) {
424
- // highlight curr node flow
425
- this.lineageManager?.updateActiveNodes([node.config as INodeConfig<TTableData, TColumnData>]);
426
- // set related nodes & edges
427
- this.lineageManager?.setRelatedNodesAndEdges(node.config as INodeConfig<TTableData, TColumnData>);
428
- } else {
429
- // highlight curr node flow
430
- this.lineageManager?.updateActiveNodes([
431
- this.lineageManager.cachedRelatedNodeConfig,
432
- ]);
433
- // set related nodes & edges
434
- this.lineageManager?.setRelatedNodesAndEdges(
435
- this.lineageManager.cachedRelatedNodeConfig,
436
- );
437
- }
438
-
439
- // update
440
- this.lineageManager.update({ needLayout });
441
- }
442
- }
@@ -1,68 +0,0 @@
1
- import { IGraph } from '@aloudata/ink-graph-new';
2
- import { InkLineageManager } from '..';
3
- import { EDirection, EventEnumType, IColResBase, TDataBase } from '../../types';
4
- import { INode } from '../../types';
5
-
6
- export class BaseEventManager<
7
- TTableData extends TDataBase<TColumnData>,
8
- TColumnData extends IColResBase,
9
- > {
10
- lineageManager: InkLineageManager<TTableData, TColumnData>;
11
-
12
- graph: IGraph;
13
-
14
- eventsType: EventEnumType;
15
-
16
- constructor(
17
- lineageManager: InkLineageManager<TTableData, TColumnData>,
18
- eventType: EventEnumType,
19
- ) {
20
- this.lineageManager = lineageManager;
21
- this.graph = lineageManager.graph;
22
- this.eventsType = eventType;
23
-
24
- this.registerEvents(eventType);
25
- }
26
-
27
- registerEvents(eventType: EventEnumType) {
28
- // 左边icon
29
- this.lineageManager.on(eventType.LEFT_ICON_CLICK, (node: INode) => {
30
- this.onLeftIconClick(node);
31
- });
32
-
33
- // 右边icon
34
- this.lineageManager.on(eventType.RIGHT_ICON_CLICK, (node: INode) => {
35
- this.onRightIconClick(node);
36
- });
37
-
38
- // 右键菜单
39
- this.lineageManager.on(eventType.CONTEXT_MENU, (node: INode) => {
40
- this.onContextMenu(node);
41
- });
42
- // 表/列右键的扩展
43
- this.lineageManager.on(
44
- eventType.EXPAND,
45
- (data: { node: INode; direction: EDirection; depth?: number }) => {
46
- this.handleExpand({ ...data });
47
- },
48
- );
49
- }
50
-
51
- onClick(node: INode): void { }
52
-
53
- onLeftIconClick(node: INode): void { }
54
-
55
- onRightIconClick(node: INode): void { }
56
-
57
- onContextMenu(node: INode): void { }
58
-
59
- async handleExpand({
60
- direction,
61
- depth = 1,
62
- node,
63
- }: {
64
- direction: EDirection;
65
- depth?: number;
66
- node: INode;
67
- }) { }
68
- }