@nocobase/plugin-graph-collection-manager 0.9.0-alpha.1

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 (54) hide show
  1. package/LICENSE +661 -0
  2. package/client.d.ts +4 -0
  3. package/client.js +30 -0
  4. package/lib/client/GraphCollectionProvider.d.ts +2 -0
  5. package/lib/client/GraphCollectionProvider.js +97 -0
  6. package/lib/client/GraphCollectionShortcut.d.ts +2 -0
  7. package/lib/client/GraphCollectionShortcut.js +236 -0
  8. package/lib/client/GraphDrawPage.d.ts +13 -0
  9. package/lib/client/GraphDrawPage.js +1746 -0
  10. package/lib/client/action-hooks.d.ts +44 -0
  11. package/lib/client/action-hooks.js +402 -0
  12. package/lib/client/components/AddCollectionAction.d.ts +3 -0
  13. package/lib/client/components/AddCollectionAction.js +73 -0
  14. package/lib/client/components/AddFieldAction.d.ts +3 -0
  15. package/lib/client/components/AddFieldAction.js +85 -0
  16. package/lib/client/components/CollectionNodeProvder.d.ts +10 -0
  17. package/lib/client/components/CollectionNodeProvder.js +42 -0
  18. package/lib/client/components/EditCollectionAction.d.ts +3 -0
  19. package/lib/client/components/EditCollectionAction.js +78 -0
  20. package/lib/client/components/EditFieldAction.d.ts +3 -0
  21. package/lib/client/components/EditFieldAction.js +81 -0
  22. package/lib/client/components/Entity.d.ts +8 -0
  23. package/lib/client/components/Entity.js +603 -0
  24. package/lib/client/components/FieldSummary.d.ts +2 -0
  25. package/lib/client/components/FieldSummary.js +98 -0
  26. package/lib/client/components/OverrideFieldAction.d.ts +3 -0
  27. package/lib/client/components/OverrideFieldAction.js +83 -0
  28. package/lib/client/components/ViewFieldAction.d.ts +3 -0
  29. package/lib/client/components/ViewFieldAction.js +57 -0
  30. package/lib/client/components/ViewNode.d.ts +5 -0
  31. package/lib/client/components/ViewNode.js +40 -0
  32. package/lib/client/index.d.ts +1 -0
  33. package/lib/client/index.js +13 -0
  34. package/lib/client/locale/en-US.d.ts +15 -0
  35. package/lib/client/locale/en-US.js +21 -0
  36. package/lib/client/locale/index.d.ts +3 -0
  37. package/lib/client/locale/index.js +31 -0
  38. package/lib/client/locale/ja-JP.d.ts +14 -0
  39. package/lib/client/locale/ja-JP.js +20 -0
  40. package/lib/client/locale/zh-CN.d.ts +16 -0
  41. package/lib/client/locale/zh-CN.js +22 -0
  42. package/lib/client/style.d.ts +9 -0
  43. package/lib/client/style.js +222 -0
  44. package/lib/client/utils.d.ts +11 -0
  45. package/lib/client/utils.js +565 -0
  46. package/lib/index.d.ts +1 -0
  47. package/lib/index.js +15 -0
  48. package/lib/server/collections/graphPositions.d.ts +2 -0
  49. package/lib/server/collections/graphPositions.js +33 -0
  50. package/lib/server/index.d.ts +5 -0
  51. package/lib/server/index.js +51 -0
  52. package/package.json +18 -0
  53. package/server.d.ts +4 -0
  54. package/server.js +30 -0
package/client.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
4
+
5
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
6
+
7
+ var _index = _interopRequireWildcard(require("./lib/client"));
8
+
9
+ Object.defineProperty(exports, "__esModule", {
10
+ value: true
11
+ });
12
+ var _exportNames = {};
13
+ Object.defineProperty(exports, "default", {
14
+ enumerable: true,
15
+ get: function get() {
16
+ return _index.default;
17
+ }
18
+ });
19
+
20
+ Object.keys(_index).forEach(function (key) {
21
+ if (key === "default" || key === "__esModule") return;
22
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
23
+ if (key in exports && exports[key] === _index[key]) return;
24
+ Object.defineProperty(exports, key, {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _index[key];
28
+ }
29
+ });
30
+ });
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const GraphCollectionProvider: React.NamedExoticComponent<object>;
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.GraphCollectionProvider = void 0;
7
+
8
+ function _client() {
9
+ const data = require("@nocobase/client");
10
+
11
+ _client = function _client() {
12
+ return data;
13
+ };
14
+
15
+ return data;
16
+ }
17
+
18
+ function _react() {
19
+ const data = _interopRequireWildcard(require("react"));
20
+
21
+ _react = function _react() {
22
+ return data;
23
+ };
24
+
25
+ return data;
26
+ }
27
+
28
+ function _reactI18next() {
29
+ const data = require("react-i18next");
30
+
31
+ _reactI18next = function _reactI18next() {
32
+ return data;
33
+ };
34
+
35
+ return data;
36
+ }
37
+
38
+ var _GraphCollectionShortcut = require("./GraphCollectionShortcut");
39
+
40
+ var _locale = require("./locale");
41
+
42
+ const _excluded = ["routes", "components"];
43
+
44
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
45
+
46
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
47
+
48
+ 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; }
49
+
50
+ 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; }
51
+
52
+ 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; }
53
+
54
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
55
+
56
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
57
+
58
+ const GraphCollectionProvider = _react().default.memo(props => {
59
+ const ctx = (0, _react().useContext)(_client().PluginManagerContext);
60
+
61
+ const _useContext = (0, _react().useContext)(_client().RouteSwitchContext),
62
+ routes = _useContext.routes,
63
+ components = _useContext.components,
64
+ others = _objectWithoutProperties(_useContext, _excluded);
65
+
66
+ _client().i18n.addResources('en-US', 'graphPositions', _locale.enUS);
67
+
68
+ _client().i18n.addResources('ja-JP', 'graphPositions', _locale.jaJP);
69
+
70
+ _client().i18n.addResources('zh-CN', 'graphPositions', _locale.zhCN);
71
+
72
+ const _useTranslation = (0, _reactI18next().useTranslation)('graphPositions'),
73
+ t = _useTranslation.t;
74
+
75
+ const items = (0, _react().useContext)(_client().SettingsCenterContext);
76
+ items['collection-manager']['tabs']['graph'] = {
77
+ title: t("Graphical interface"),
78
+ component: _GraphCollectionShortcut.GraphCollectionPane
79
+ };
80
+ return _react().default.createElement(_client().SettingsCenterProvider, {
81
+ settings: items
82
+ }, _react().default.createElement(_client().PluginManagerContext.Provider, {
83
+ value: {
84
+ components: _objectSpread(_objectSpread({}, ctx === null || ctx === void 0 ? void 0 : ctx.components), {}, {
85
+ GraphCollectionShortcut: _GraphCollectionShortcut.GraphCollectionShortcut
86
+ })
87
+ }
88
+ }, _react().default.createElement(_client().RouteSwitchContext.Provider, {
89
+ value: _objectSpread(_objectSpread({
90
+ components: _objectSpread({}, components)
91
+ }, others), {}, {
92
+ routes
93
+ })
94
+ }, props.children)));
95
+ });
96
+
97
+ exports.GraphCollectionProvider = GraphCollectionProvider;
@@ -0,0 +1,2 @@
1
+ export declare const GraphCollectionPane: () => JSX.Element;
2
+ export declare const GraphCollectionShortcut: () => JSX.Element;
@@ -0,0 +1,236 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.GraphCollectionShortcut = exports.GraphCollectionPane = void 0;
7
+
8
+ function _icons() {
9
+ const data = require("@ant-design/icons");
10
+
11
+ _icons = function _icons() {
12
+ return data;
13
+ };
14
+
15
+ return data;
16
+ }
17
+
18
+ function _shared() {
19
+ const data = require("@formily/shared");
20
+
21
+ _shared = function _shared() {
22
+ return data;
23
+ };
24
+
25
+ return data;
26
+ }
27
+
28
+ function _client() {
29
+ const data = require("@nocobase/client");
30
+
31
+ _client = function _client() {
32
+ return data;
33
+ };
34
+
35
+ return data;
36
+ }
37
+
38
+ function _react() {
39
+ const data = _interopRequireWildcard(require("react"));
40
+
41
+ _react = function _react() {
42
+ return data;
43
+ };
44
+
45
+ return data;
46
+ }
47
+
48
+ function _css() {
49
+ const data = require("@emotion/css");
50
+
51
+ _css = function _css() {
52
+ return data;
53
+ };
54
+
55
+ return data;
56
+ }
57
+
58
+ function _reactI18next() {
59
+ const data = require("react-i18next");
60
+
61
+ _reactI18next = function _reactI18next() {
62
+ return data;
63
+ };
64
+
65
+ return data;
66
+ }
67
+
68
+ function _reactRouterDom() {
69
+ const data = require("react-router-dom");
70
+
71
+ _reactRouterDom = function _reactRouterDom() {
72
+ return data;
73
+ };
74
+
75
+ return data;
76
+ }
77
+
78
+ var _actionHooks = require("./action-hooks");
79
+
80
+ var _GraphDrawPage = require("./GraphDrawPage");
81
+
82
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
83
+
84
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
85
+
86
+ 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; }
87
+
88
+ 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; }
89
+
90
+ 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; }
91
+
92
+ const useCollectionValues = options => {
93
+ const _useActionContext = (0, _client().useActionContext)(),
94
+ visible = _useActionContext.visible;
95
+
96
+ const result = (0, _client().useRequest)(() => Promise.resolve({
97
+ data: {
98
+ name: `t_${(0, _shared().uid)()}`,
99
+ createdBy: true,
100
+ updatedBy: true,
101
+ sortable: true,
102
+ logging: true,
103
+ fields: [{
104
+ name: 'id',
105
+ type: 'integer',
106
+ autoIncrement: true,
107
+ primaryKey: true,
108
+ allowNull: false,
109
+ uiSchema: {
110
+ type: 'number',
111
+ title: '{{t("ID")}}',
112
+ 'x-component': 'InputNumber',
113
+ 'x-read-pretty': true
114
+ },
115
+ interface: 'id'
116
+ }, {
117
+ interface: 'createdAt',
118
+ type: 'date',
119
+ field: 'createdAt',
120
+ name: 'createdAt',
121
+ uiSchema: {
122
+ type: 'datetime',
123
+ title: '{{t("Created at")}}',
124
+ 'x-component': 'DatePicker',
125
+ 'x-component-props': {},
126
+ 'x-read-pretty': true
127
+ }
128
+ }, {
129
+ interface: 'createdBy',
130
+ type: 'belongsTo',
131
+ target: 'users',
132
+ foreignKey: 'createdById',
133
+ name: 'createdBy',
134
+ uiSchema: {
135
+ type: 'object',
136
+ title: '{{t("Created by")}}',
137
+ 'x-component': 'RecordPicker',
138
+ 'x-component-props': {
139
+ fieldNames: {
140
+ value: 'id',
141
+ label: 'nickname'
142
+ }
143
+ },
144
+ 'x-read-pretty': true
145
+ }
146
+ }, {
147
+ type: 'date',
148
+ field: 'updatedAt',
149
+ name: 'updatedAt',
150
+ interface: 'updatedAt',
151
+ uiSchema: {
152
+ type: 'string',
153
+ title: '{{t("Last updated at")}}',
154
+ 'x-component': 'DatePicker',
155
+ 'x-component-props': {},
156
+ 'x-read-pretty': true
157
+ }
158
+ }, {
159
+ type: 'belongsTo',
160
+ target: 'users',
161
+ foreignKey: 'updatedById',
162
+ name: 'updatedBy',
163
+ interface: 'updatedBy',
164
+ uiSchema: {
165
+ type: 'object',
166
+ title: '{{t("Last updated by")}}',
167
+ 'x-component': 'RecordPicker',
168
+ 'x-component-props': {
169
+ fieldNames: {
170
+ value: 'id',
171
+ label: 'nickname'
172
+ }
173
+ },
174
+ 'x-read-pretty': true
175
+ }
176
+ }]
177
+ }
178
+ }), _objectSpread(_objectSpread({}, options), {}, {
179
+ manual: true
180
+ }));
181
+ (0, _react().useEffect)(() => {
182
+ if (visible) {
183
+ result.run();
184
+ }
185
+ }, [visible]);
186
+ return result;
187
+ };
188
+
189
+ const GraphCollectionPane = () => {
190
+ return _react().default.createElement("div", {
191
+ className: (0, _css().css)`
192
+ height: calc(100vh - 160px);
193
+ overflow: auto;
194
+ margin: -24px;
195
+ position: relative;
196
+ `,
197
+ id: "graph_container"
198
+ }, _react().default.createElement(_client().SchemaComponent, {
199
+ schema: {
200
+ type: 'void',
201
+ 'x-component': 'div',
202
+ properties: {
203
+ editor: {
204
+ type: 'void',
205
+ 'x-component': 'GraphDrawPage'
206
+ }
207
+ }
208
+ },
209
+ components: {
210
+ GraphDrawPage: _GraphDrawPage.GraphDrawPage,
211
+ DeleteOutlined: _icons().DeleteOutlined
212
+ },
213
+ scope: {
214
+ useCollectionValues,
215
+ useCreateActionAndRefreshCM: _actionHooks.useCreateActionAndRefreshCM
216
+ }
217
+ }));
218
+ };
219
+
220
+ exports.GraphCollectionPane = GraphCollectionPane;
221
+
222
+ const GraphCollectionShortcut = () => {
223
+ const _useTranslation = (0, _reactI18next().useTranslation)('graphPositions'),
224
+ t = _useTranslation.t;
225
+
226
+ const history = (0, _reactRouterDom().useHistory)();
227
+ return _react().default.createElement(_client().PluginManager.Toolbar.Item, {
228
+ icon: _react().default.createElement(_icons().PartitionOutlined, null),
229
+ title: t('Graph Collection'),
230
+ onClick: () => {
231
+ history.push('/admin/settings/graph/collections');
232
+ }
233
+ });
234
+ };
235
+
236
+ exports.GraphCollectionShortcut = GraphCollectionShortcut;
@@ -0,0 +1,13 @@
1
+ import '@antv/x6-react-shape';
2
+ import React from 'react';
3
+ export declare enum DirectionType {
4
+ Both = "both",
5
+ Target = "target",
6
+ Source = "source"
7
+ }
8
+ export declare enum ConnectionType {
9
+ Both = "both",
10
+ Inherit = "inherited",
11
+ Entity = "entity"
12
+ }
13
+ export declare const GraphDrawPage: React.MemoExoticComponent<() => JSX.Element>;