@nocobase/plugin-graph-collection-manager 0.9.1-alpha.2 → 0.9.2-alpha.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.
@@ -21,11 +21,7 @@ Object.defineProperty(exports, "zhCN", {
21
21
  return _zhCN.default;
22
22
  }
23
23
  });
24
-
25
24
  var _enUS = _interopRequireDefault(require("./en-US"));
26
-
27
25
  var _zhCN = _interopRequireDefault(require("./zh-CN"));
28
-
29
26
  var _jaJP = _interopRequireDefault(require("./ja-JP"));
30
-
31
27
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,16 @@
1
+ declare const _default: {
2
+ 'Graph Collection': string;
3
+ 'Collection List': string;
4
+ 'Full Screen': string;
5
+ 'Collection Search': string;
6
+ 'Create Collection': string;
7
+ 'All Fields': string;
8
+ 'Association Fields': string;
9
+ 'Optional fields': string;
10
+ 'All relationships': string;
11
+ 'Entity relationship only': string;
12
+ 'Inheritance relationship only': string;
13
+ 'Graphical interface': string;
14
+ Selection: string;
15
+ };
16
+ export default _default;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = {
8
+ 'Graph Collection': 'Coleção de Gráficos',
9
+ 'Collection List': 'Lista de Coleções',
10
+ 'Full Screen': 'Tela Cheia',
11
+ 'Collection Search': 'Busca de Coleção',
12
+ 'Create Collection': 'Criar Coleção',
13
+ 'All Fields': 'Todos os Campos',
14
+ 'Association Fields': 'Campos de Associação',
15
+ 'Optional fields': 'Campos Opcionais',
16
+ 'All relationships': 'Todos os relacionamentos',
17
+ 'Entity relationship only': 'Somente relação de Entidade',
18
+ 'Inheritance relationship only': 'Somente relação de Herança',
19
+ 'Graphical interface': 'Interface Gráfica',
20
+ 'Selection': 'Seleção'
21
+ };
22
+ exports.default = _default;
@@ -6,6 +6,7 @@ declare const _default: {
6
6
  'Create Collection': string;
7
7
  'All Fields': string;
8
8
  'Association Fields': string;
9
+ 'Optional fields': string;
9
10
  'All relationships': string;
10
11
  'Entity relationship only': string;
11
12
  'Inheritance relationship only': string;
@@ -12,6 +12,7 @@ var _default = {
12
12
  'Create Collection': '创建数据表',
13
13
  'All Fields': '全部',
14
14
  'Association Fields': '关系字段',
15
+ 'Optional fields': '可选字段',
15
16
  'All relationships': '所有关系',
16
17
  'Entity relationship only': '实体关系',
17
18
  'Inheritance relationship only': '继承关系',
@@ -4,17 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.tableNameClass = exports.tableBtnClass = exports.nodeSubtreeClass = exports.headClass = exports.graphCollectionContainerClass = exports.entityContainer = exports.collectionListClass = exports.collectiionPopoverClass = exports.addButtonClass = void 0;
7
-
8
7
  function _css() {
9
8
  const data = require("@emotion/css");
10
-
11
9
  _css = function _css() {
12
10
  return data;
13
11
  };
14
-
15
12
  return data;
16
13
  }
17
-
18
14
  const nodeSubtreeClass = (0, _css().css)`
19
15
  display: flex;
20
16
  flex-direction: column-reverse;
@@ -6,7 +6,7 @@ export declare const formatData: (data: any) => {
6
6
  edgesData: any[];
7
7
  inheritEdges: any[];
8
8
  };
9
- export declare const formatPortData: (ports: any) => import("lodash").Dictionary<[any, ...any[]]>;
9
+ export declare const formatPortData: (ports: any) => import("lodash").Dictionary<any[]>;
10
10
  export declare const formatInheritEdgeData: (collections: any) => any[];
11
11
  export declare const getDiffNode: (newNodes: any, oldNodes: any) => any[];
12
12
  export declare const getDiffEdge: (newEdges: any, oldEdges: any) => any[];
@@ -4,53 +4,39 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.useGCMTranslation = exports.getInheritCollections = exports.getDiffNode = exports.getDiffEdge = exports.getChildrenCollections = exports.formatPortData = exports.formatInheritEdgeData = exports.formatData = void 0;
7
-
8
7
  function _lodash() {
9
8
  const data = require("lodash");
10
-
11
9
  _lodash = function _lodash() {
12
10
  return data;
13
11
  };
14
-
15
12
  return data;
16
13
  }
17
-
18
14
  function _reactI18next() {
19
15
  const data = require("react-i18next");
20
-
21
16
  _reactI18next = function _reactI18next() {
22
17
  return data;
23
18
  };
24
-
25
19
  return data;
26
20
  }
27
-
28
21
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
29
-
30
22
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
31
-
32
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
33
-
23
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
24
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
25
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
34
26
  const shape = {
35
27
  ER: 'er-rect',
36
28
  EDGE: 'edge'
37
29
  };
38
-
39
30
  const useGCMTranslation = () => {
40
31
  return (0, _reactI18next().useTranslation)('graph-collection-manager');
41
32
  };
42
-
43
33
  exports.useGCMTranslation = useGCMTranslation;
44
-
45
34
  const getInheritCollections = (collections, name) => {
46
35
  const parents = [];
47
-
48
36
  const getParents = name => {
49
37
  const collection = collections === null || collections === void 0 ? void 0 : collections.find(collection => collection.name === name);
50
-
51
38
  if (collection) {
52
39
  const inherits = collection.inherits;
53
-
54
40
  if (inherits) {
55
41
  for (let index = 0; index < inherits.length; index++) {
56
42
  const collectionKey = inherits[index];
@@ -59,22 +45,16 @@ const getInheritCollections = (collections, name) => {
59
45
  }
60
46
  }
61
47
  }
62
-
63
48
  return (0, _lodash().uniq)(parents);
64
49
  };
65
-
66
50
  return getParents(name);
67
51
  };
68
-
69
52
  exports.getInheritCollections = getInheritCollections;
70
-
71
53
  const getChildrenCollections = (collections, name) => {
72
54
  const childrens = [];
73
-
74
55
  const getChildrens = name => {
75
56
  const inheritCollections = collections.filter(v => {
76
57
  var _v$inherits;
77
-
78
58
  return (_v$inherits = v.inherits) === null || _v$inherits === void 0 ? void 0 : _v$inherits.includes(name);
79
59
  });
80
60
  inheritCollections.forEach(v => {
@@ -84,12 +64,9 @@ const getChildrenCollections = (collections, name) => {
84
64
  });
85
65
  return childrens;
86
66
  };
87
-
88
67
  return getChildrens(name);
89
68
  };
90
-
91
69
  exports.getChildrenCollections = getChildrenCollections;
92
-
93
70
  const formatData = data => {
94
71
  const edgeData = [];
95
72
  const targetTablekeys = [];
@@ -99,7 +76,6 @@ const formatData = data => {
99
76
  const inheritCollections = getInheritCollections(data, item.name);
100
77
  const inheritedFields = (0, _lodash().reduce)(inheritCollections, (result, value) => {
101
78
  var _data$find;
102
-
103
79
  const arr = result;
104
80
  const parentFields = (_data$find = data.find(k => k.name === value)) === null || _data$find === void 0 ? void 0 : _data$find.fields.map(v => {
105
81
  return _objectSpread(_objectSpread({}, v), {}, {
@@ -136,9 +112,7 @@ const formatData = data => {
136
112
  inheritEdges
137
113
  };
138
114
  };
139
-
140
115
  exports.formatData = formatData;
141
-
142
116
  const formatPortData = ports => {
143
117
  const portsData = (0, _lodash().groupBy)(ports, v => {
144
118
  if (v.isForeignKey || v.primaryKey || ['obo', 'oho', 'o2o', 'o2m', 'm2o', 'm2m', 'linkTo', 'id'].includes(v.interface)) {
@@ -149,9 +123,7 @@ const formatPortData = ports => {
149
123
  });
150
124
  return portsData;
151
125
  };
152
-
153
126
  exports.formatPortData = formatPortData;
154
-
155
127
  const formatInheritEdgeData = collections => {
156
128
  const commonAttrs = {
157
129
  attrs: {
@@ -160,10 +132,11 @@ const formatInheritEdgeData = collections => {
160
132
  textAnchor: 'middle',
161
133
  textVerticalAnchor: 'middle',
162
134
  stroke: '#ddd',
163
- sourceMarker: null // targetMarker: null,
164
-
135
+ sourceMarker: null
136
+ // targetMarker: null,
165
137
  }
166
138
  },
139
+
167
140
  router: {
168
141
  name: 'smooth',
169
142
  args: {
@@ -210,7 +183,6 @@ const formatInheritEdgeData = collections => {
210
183
  const inheritEdges = [];
211
184
  collections.forEach(v => {
212
185
  const parentCollectonKeys = v.inherits || [];
213
-
214
186
  if (parentCollectonKeys.length) {
215
187
  parentCollectonKeys.forEach(k => {
216
188
  inheritEdges.push(_objectSpread({
@@ -231,12 +203,9 @@ const formatInheritEdgeData = collections => {
231
203
  });
232
204
  return inheritEdges;
233
205
  };
234
-
235
206
  exports.formatInheritEdgeData = formatInheritEdgeData;
236
-
237
207
  const formatEdgeData = (data, targetTables, tableData) => {
238
208
  const edges = [];
239
-
240
209
  for (let i = 0; i < data.length; i++) {
241
210
  if (targetTables.includes(data[i].target)) {
242
211
  const targetTable = tableData.find(v => v.name === data[i].target);
@@ -343,24 +312,18 @@ const formatEdgeData = (data, targetTables, tableData) => {
343
312
  }
344
313
  }]
345
314
  };
346
-
347
315
  const isuniq = id => {
348
316
  const targetEdge = edges.find(v => v.id === id);
349
-
350
317
  if (targetEdge) {
351
318
  targetEdge.associated.push(data[i].name);
352
319
  return false;
353
320
  }
354
-
355
321
  return true;
356
322
  };
357
-
358
323
  if (['m2m', 'linkTo'].includes(data[i].interface)) {
359
324
  const throughTable = tableData.find(v => v.name === data[i].through);
360
-
361
325
  if (throughTable) {
362
326
  var _sourceTable$ports$fi, _throughTable$ports$f, _targetTable$ports$fi, _throughTable$ports$f2;
363
-
364
327
  const sCellId1 = sourceTable.id;
365
328
  const tCellId1 = throughTable.id;
366
329
  const sPortId1 = (_sourceTable$ports$fi = sourceTable.ports.find(v => v.name === data[i].sourceKey)) === null || _sourceTable$ports$fi === void 0 ? void 0 : _sourceTable$ports$fi.id;
@@ -412,7 +375,6 @@ const formatEdgeData = (data, targetTables, tableData) => {
412
375
  }
413
376
  } else {
414
377
  var _targetTable$ports$fi2, _sourceTable$ports$fi2, _targetTable$ports$fi3;
415
-
416
378
  const isLegalEdge = tableData.find(v => v.name == (data[i].sourceCollectionName || data[i].collectionName)).ports.find(v => v.name === data[i].foreignKey);
417
379
  const sCellId1 = sourceTable.id;
418
380
  const tCellId1 = targetTable.id;
@@ -463,36 +425,28 @@ const formatEdgeData = (data, targetTables, tableData) => {
463
425
  }
464
426
  }
465
427
  }
466
-
467
428
  return (0, _lodash().uniqBy)(edges, 'id');
468
429
  };
469
-
470
430
  const getRelationship = relatioship => {
471
431
  switch (relatioship) {
472
432
  case 'm2m':
473
433
  case 'linkTo':
474
434
  return ['1', 'N'];
475
-
476
435
  case 'o2m':
477
436
  return ['1', 'N'];
478
-
479
437
  case 'm2o':
480
438
  return ['N', '1'];
481
-
482
439
  case 'obo':
483
440
  case 'oho':
484
441
  return ['1', '1'];
485
-
486
442
  default:
487
443
  return [];
488
444
  }
489
445
  };
490
-
491
446
  const getDiffNode = (newNodes, oldNodes) => {
492
447
  let arr = [];
493
448
  const length1 = newNodes.length;
494
449
  const length2 = oldNodes.length;
495
-
496
450
  for (let i = 0; i < length1; i++) {
497
451
  if (!oldNodes.find(v => v.id === newNodes[i].id)) {
498
452
  arr.push({
@@ -503,7 +457,6 @@ const getDiffNode = (newNodes, oldNodes) => {
503
457
  const oldNode = oldNodes.find(v => v.id === newNodes[i].id);
504
458
  const oldPorts = oldNode === null || oldNode === void 0 ? void 0 : oldNode.ports.items;
505
459
  const newPorts = newNodes[i].ports;
506
-
507
460
  if (oldNode) {
508
461
  for (let h = 0; h < newPorts.length; h++) {
509
462
  if (!oldPorts.find(v => v.id === newPorts[h].id)) {
@@ -517,7 +470,6 @@ const getDiffNode = (newNodes, oldNodes) => {
517
470
  });
518
471
  }
519
472
  }
520
-
521
473
  for (let k = 0; k < oldPorts.length; k++) {
522
474
  if (!newPorts.find(v => v.id === oldPorts[k].id)) {
523
475
  arr.push({
@@ -527,7 +479,6 @@ const getDiffNode = (newNodes, oldNodes) => {
527
479
  });
528
480
  }
529
481
  }
530
-
531
482
  if (oldNode.title !== newNodes[i].title) {
532
483
  arr.push({
533
484
  status: 'updateNode',
@@ -537,7 +488,6 @@ const getDiffNode = (newNodes, oldNodes) => {
537
488
  }
538
489
  }
539
490
  }
540
-
541
491
  for (let i = 0; i < length2; i++) {
542
492
  if (!newNodes.find(v => v.id === oldNodes[i].id)) {
543
493
  arr.push({
@@ -546,17 +496,13 @@ const getDiffNode = (newNodes, oldNodes) => {
546
496
  });
547
497
  }
548
498
  }
549
-
550
499
  return arr;
551
500
  };
552
-
553
501
  exports.getDiffNode = getDiffNode;
554
-
555
502
  const getDiffEdge = (newEdges, oldEdges) => {
556
503
  const length1 = newEdges.length;
557
504
  const length2 = oldEdges === null || oldEdges === void 0 ? void 0 : oldEdges.length;
558
505
  const edges = [];
559
-
560
506
  for (let i = 0; i < length1; i++) {
561
507
  if (!oldEdges.find(v => v.id === newEdges[i].id)) {
562
508
  edges.push({
@@ -565,7 +511,6 @@ const getDiffEdge = (newEdges, oldEdges) => {
565
511
  });
566
512
  }
567
513
  }
568
-
569
514
  for (let i = 0; i < length2; i++) {
570
515
  if (!newEdges.find(v => v.id === oldEdges[i].id)) {
571
516
  edges.push({
@@ -574,8 +519,6 @@ const getDiffEdge = (newEdges, oldEdges) => {
574
519
  });
575
520
  }
576
521
  }
577
-
578
522
  return edges;
579
523
  };
580
-
581
524
  exports.getDiffEdge = getDiffEdge;
package/lib/index.js CHANGED
@@ -9,7 +9,5 @@ Object.defineProperty(exports, "default", {
9
9
  return _server.default;
10
10
  }
11
11
  });
12
-
13
12
  var _server = _interopRequireDefault(require("./server"));
14
-
15
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -4,19 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  function _database() {
9
8
  const data = require("@nocobase/database");
10
-
11
9
  _database = function _database() {
12
10
  return data;
13
11
  };
14
-
15
12
  return data;
16
13
  }
17
-
18
14
  var _default = (0, _database().defineCollection)({
19
- namespace: 'graph-collection-manager',
15
+ namespace: 'graph-collection-manager.graphCollectionPositions',
20
16
  duplicator: 'required',
21
17
  name: 'graphPositions',
22
18
  fields: [{
@@ -31,5 +27,4 @@ var _default = (0, _database().defineCollection)({
31
27
  name: 'y'
32
28
  }]
33
29
  });
34
-
35
30
  exports.default = _default;
@@ -4,48 +4,34 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = exports.GraphCollectionManagerPlugin = void 0;
7
-
8
7
  function _server() {
9
8
  const data = require("@nocobase/server");
10
-
11
9
  _server = function _server() {
12
10
  return data;
13
11
  };
14
-
15
12
  return data;
16
13
  }
17
-
18
14
  function _path() {
19
15
  const data = _interopRequireDefault(require("path"));
20
-
21
16
  _path = function _path() {
22
17
  return data;
23
18
  };
24
-
25
19
  return data;
26
20
  }
27
-
28
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
-
30
22
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
31
-
32
23
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
33
-
34
24
  class GraphCollectionManagerPlugin extends _server().Plugin {
35
25
  load() {
36
26
  var _this = this;
37
-
38
27
  return _asyncToGenerator(function* () {
39
28
  yield _this.db.import({
40
29
  directory: _path().default.resolve(__dirname, 'collections')
41
30
  });
42
-
43
31
  _this.app.acl.allow('graphPositions', '*');
44
32
  })();
45
33
  }
46
-
47
34
  }
48
-
49
35
  exports.GraphCollectionManagerPlugin = GraphCollectionManagerPlugin;
50
36
  var _default = GraphCollectionManagerPlugin;
51
37
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-graph-collection-manager",
3
- "version": "0.9.1-alpha.2",
3
+ "version": "0.9.2-alpha.2",
4
4
  "description": "",
5
5
  "license": "AGPL-3.0",
6
6
  "main": "./lib/index.js",
@@ -11,8 +11,8 @@
11
11
  "dagre": "^0.8.5"
12
12
  },
13
13
  "devDependencies": {
14
- "@nocobase/client": "0.9.1-alpha.2",
15
- "@nocobase/test": "0.9.1-alpha.2"
14
+ "@nocobase/client": "0.9.2-alpha.2",
15
+ "@nocobase/test": "0.9.2-alpha.2"
16
16
  },
17
- "gitHead": "d588a68eca4feed4642a4cb317301011266fe5c9"
17
+ "gitHead": "1a0de6908b2b1854bdf434fcafa8909cb65bb8a3"
18
18
  }