@nocobase/plugin-ui-schema-storage 0.9.1-alpha.2 → 0.9.2-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.
- package/lib/actions/ui-schema-action.js +18 -44
- package/lib/collections/uiSchemaServerHooks.js +1 -1
- package/lib/collections/uiSchemaTemplates.js +1 -6
- package/lib/collections/uiSchemaTreePath.js +1 -1
- package/lib/collections/uiSchemas.js +1 -1
- package/lib/dao/ui_schema_dao.js +0 -3
- package/lib/dao/ui_schema_node_dao.js +0 -3
- package/lib/index.js +0 -6
- package/lib/migrations/20230330214649-filter-form-block.d.ts +4 -0
- package/lib/migrations/20230330214649-filter-form-block.js +62 -0
- package/lib/model.js +0 -6
- package/lib/repository.js +123 -343
- package/lib/server-hooks/hooks/bind-menu-to-role.js +1 -10
- package/lib/server-hooks/hooks/factory.js +0 -1
- package/lib/server-hooks/hooks/index.js +0 -5
- package/lib/server-hooks/hooks/remove-parents-if-no-children.js +1 -5
- package/lib/server-hooks/hooks/remove-schema.js +0 -5
- package/lib/server-hooks/index.js +5 -46
- package/lib/server-hooks/model.js +0 -5
- package/lib/server.js +10 -43
- package/package.json +3 -3
|
@@ -4,40 +4,30 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.uiSchemaActions = void 0;
|
|
7
|
-
|
|
8
7
|
function _lodash() {
|
|
9
8
|
const data = _interopRequireDefault(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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
15
|
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; }
|
|
21
|
-
|
|
22
16
|
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; }
|
|
23
|
-
|
|
24
|
-
function
|
|
25
|
-
|
|
17
|
+
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; }
|
|
18
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
19
|
+
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); }
|
|
26
20
|
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); } }
|
|
27
|
-
|
|
28
21
|
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); }); }; }
|
|
29
|
-
|
|
30
22
|
const getRepositoryFromCtx = ctx => {
|
|
31
23
|
const repo = ctx.db.getCollection('uiSchemas').repository;
|
|
32
24
|
repo.setCache(ctx.cache);
|
|
33
25
|
return repo;
|
|
34
26
|
};
|
|
35
|
-
|
|
36
27
|
const callRepositoryMethod = (method, paramsKey, optionsBuilder) => {
|
|
37
28
|
return /*#__PURE__*/function () {
|
|
38
29
|
var _ref = _asyncToGenerator(function* (ctx, next) {
|
|
39
30
|
const params = _lodash().default.get(ctx.action.params, paramsKey);
|
|
40
|
-
|
|
41
31
|
const options = optionsBuilder ? optionsBuilder(ctx.action.params) : {};
|
|
42
32
|
const repository = getRepositoryFromCtx(ctx);
|
|
43
33
|
const returnValue = yield repository[method](params, options);
|
|
@@ -46,24 +36,20 @@ const callRepositoryMethod = (method, paramsKey, optionsBuilder) => {
|
|
|
46
36
|
};
|
|
47
37
|
yield next();
|
|
48
38
|
});
|
|
49
|
-
|
|
50
39
|
return function (_x, _x2) {
|
|
51
40
|
return _ref.apply(this, arguments);
|
|
52
41
|
};
|
|
53
42
|
}();
|
|
54
43
|
};
|
|
55
|
-
|
|
56
44
|
function parseInsertAdjacentValues(values) {
|
|
57
45
|
if (_lodash().default.has(values, 'schema')) {
|
|
58
46
|
return values;
|
|
59
47
|
}
|
|
60
|
-
|
|
61
48
|
return {
|
|
62
49
|
schema: values,
|
|
63
50
|
wrap: null
|
|
64
51
|
};
|
|
65
52
|
}
|
|
66
|
-
|
|
67
53
|
const uiSchemaActions = {
|
|
68
54
|
getJsonSchema: callRepositoryMethod('getJsonSchema', 'resourceIndex', params => {
|
|
69
55
|
const includeAsyncNode = params === null || params === void 0 ? void 0 : params.includeAsyncNode;
|
|
@@ -81,21 +67,18 @@ const uiSchemaActions = {
|
|
|
81
67
|
patch: callRepositoryMethod('patch', 'values'),
|
|
82
68
|
batchPatch: callRepositoryMethod('batchPatch', 'values'),
|
|
83
69
|
clearAncestor: callRepositoryMethod('clearAncestor', 'resourceIndex'),
|
|
84
|
-
|
|
85
70
|
insertAdjacent(ctx, next) {
|
|
86
71
|
return _asyncToGenerator(function* () {
|
|
87
72
|
const _ctx$action$params = ctx.action.params,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
73
|
+
resourceIndex = _ctx$action$params.resourceIndex,
|
|
74
|
+
position = _ctx$action$params.position,
|
|
75
|
+
values = _ctx$action$params.values,
|
|
76
|
+
removeParentsIfNoChildren = _ctx$action$params.removeParentsIfNoChildren,
|
|
77
|
+
breakRemoveOn = _ctx$action$params.breakRemoveOn;
|
|
93
78
|
const repository = getRepositoryFromCtx(ctx);
|
|
94
|
-
|
|
95
79
|
const _parseInsertAdjacentV = parseInsertAdjacentValues(values),
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
80
|
+
schema = _parseInsertAdjacentV.schema,
|
|
81
|
+
wrap = _parseInsertAdjacentV.wrap;
|
|
99
82
|
ctx.body = yield repository.insertAdjacent(position, resourceIndex, schema, {
|
|
100
83
|
removeParentsIfNoChildren,
|
|
101
84
|
breakRemoveOn,
|
|
@@ -104,20 +87,17 @@ const uiSchemaActions = {
|
|
|
104
87
|
yield next();
|
|
105
88
|
})();
|
|
106
89
|
},
|
|
107
|
-
|
|
108
90
|
insertBeforeBegin: insertPositionActionBuilder('beforeBegin'),
|
|
109
91
|
insertAfterBegin: insertPositionActionBuilder('afterBegin'),
|
|
110
92
|
insertBeforeEnd: insertPositionActionBuilder('beforeEnd'),
|
|
111
93
|
insertAfterEnd: insertPositionActionBuilder('afterEnd'),
|
|
112
|
-
|
|
113
94
|
saveAsTemplate(ctx, next) {
|
|
114
95
|
return _asyncToGenerator(function* () {
|
|
115
96
|
const _ctx$action$params2 = ctx.action.params,
|
|
116
|
-
|
|
117
|
-
|
|
97
|
+
filterByTk = _ctx$action$params2.filterByTk,
|
|
98
|
+
values = _ctx$action$params2.values;
|
|
118
99
|
const db = ctx.db;
|
|
119
100
|
const transaction = yield db.sequelize.transaction();
|
|
120
|
-
|
|
121
101
|
try {
|
|
122
102
|
yield db.getRepository('uiSchemaTemplates').create({
|
|
123
103
|
values: _objectSpread(_objectSpread({}, values), {}, {
|
|
@@ -136,28 +116,23 @@ const uiSchemaActions = {
|
|
|
136
116
|
yield transaction.rollback();
|
|
137
117
|
throw error;
|
|
138
118
|
}
|
|
139
|
-
|
|
140
119
|
yield next();
|
|
141
120
|
})();
|
|
142
121
|
}
|
|
143
|
-
|
|
144
122
|
};
|
|
145
123
|
exports.uiSchemaActions = uiSchemaActions;
|
|
146
|
-
|
|
147
124
|
function insertPositionActionBuilder(position) {
|
|
148
125
|
return /*#__PURE__*/function () {
|
|
149
126
|
var _ref2 = _asyncToGenerator(function* (ctx, next) {
|
|
150
127
|
const _ctx$action$params3 = ctx.action.params,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
128
|
+
resourceIndex = _ctx$action$params3.resourceIndex,
|
|
129
|
+
values = _ctx$action$params3.values,
|
|
130
|
+
removeParentsIfNoChildren = _ctx$action$params3.removeParentsIfNoChildren,
|
|
131
|
+
breakRemoveOn = _ctx$action$params3.breakRemoveOn;
|
|
155
132
|
const repository = getRepositoryFromCtx(ctx);
|
|
156
|
-
|
|
157
133
|
const _parseInsertAdjacentV2 = parseInsertAdjacentValues(values),
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
134
|
+
schema = _parseInsertAdjacentV2.schema,
|
|
135
|
+
wrap = _parseInsertAdjacentV2.wrap;
|
|
161
136
|
ctx.body = yield repository.insertAdjacent(position, resourceIndex, schema, {
|
|
162
137
|
removeParentsIfNoChildren,
|
|
163
138
|
breakRemoveOn,
|
|
@@ -165,7 +140,6 @@ function insertPositionActionBuilder(position) {
|
|
|
165
140
|
});
|
|
166
141
|
yield next();
|
|
167
142
|
});
|
|
168
|
-
|
|
169
143
|
return function (_x3, _x4) {
|
|
170
144
|
return _ref2.apply(this, arguments);
|
|
171
145
|
};
|
|
@@ -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: 'ui-schema-storage',
|
|
15
|
+
namespace: 'ui-schema-storage.uiSchemas',
|
|
20
16
|
duplicator: 'required',
|
|
21
17
|
name: 'uiSchemaTemplates',
|
|
22
18
|
autoGenId: false,
|
|
@@ -50,5 +46,4 @@ var _default = (0, _database().defineCollection)({
|
|
|
50
46
|
onDelete: 'CASCADE'
|
|
51
47
|
}]
|
|
52
48
|
});
|
|
53
|
-
|
|
54
49
|
exports.default = _default;
|
package/lib/dao/ui_schema_dao.js
CHANGED
|
@@ -4,12 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.UiSchemaDAO = void 0;
|
|
7
|
-
|
|
8
7
|
class UiSchemaDAO {
|
|
9
8
|
constructor(schema) {
|
|
10
9
|
this.nodeKeys = ['properties', 'patternProperties', 'additionalProperties'];
|
|
11
10
|
}
|
|
12
|
-
|
|
13
11
|
}
|
|
14
|
-
|
|
15
12
|
exports.UiSchemaDAO = UiSchemaDAO;
|
|
@@ -4,13 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.UiSchemaNodeDAO = void 0;
|
|
7
|
-
|
|
8
7
|
class UiSchemaNodeDAO {
|
|
9
8
|
constructor(schemaNode) {
|
|
10
9
|
this.schemaNode = void 0;
|
|
11
10
|
this.schemaNode = schemaNode;
|
|
12
11
|
}
|
|
13
|
-
|
|
14
12
|
}
|
|
15
|
-
|
|
16
13
|
exports.UiSchemaNodeDAO = UiSchemaNodeDAO;
|
package/lib/index.js
CHANGED
|
@@ -10,9 +10,7 @@ Object.defineProperty(exports, "default", {
|
|
|
10
10
|
return _server.default;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
-
|
|
14
13
|
var _repository = require("./repository");
|
|
15
|
-
|
|
16
14
|
Object.keys(_repository).forEach(function (key) {
|
|
17
15
|
if (key === "default" || key === "__esModule") return;
|
|
18
16
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -24,9 +22,7 @@ Object.keys(_repository).forEach(function (key) {
|
|
|
24
22
|
}
|
|
25
23
|
});
|
|
26
24
|
});
|
|
27
|
-
|
|
28
25
|
var _server = _interopRequireWildcard(require("./server"));
|
|
29
|
-
|
|
30
26
|
Object.keys(_server).forEach(function (key) {
|
|
31
27
|
if (key === "default" || key === "__esModule") return;
|
|
32
28
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -38,7 +34,5 @@ Object.keys(_server).forEach(function (key) {
|
|
|
38
34
|
}
|
|
39
35
|
});
|
|
40
36
|
});
|
|
41
|
-
|
|
42
37
|
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); }
|
|
43
|
-
|
|
44
38
|
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; }
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
function _server() {
|
|
8
|
+
const data = require("@nocobase/server");
|
|
9
|
+
_server = function _server() {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
15
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
16
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
17
|
+
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); } }
|
|
18
|
+
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); }); }; }
|
|
19
|
+
class _default extends _server().Migration {
|
|
20
|
+
up() {
|
|
21
|
+
var _this = this;
|
|
22
|
+
return _asyncToGenerator(function* () {
|
|
23
|
+
const result = yield _this.app.version.satisfies('<0.9.1-alpha.3');
|
|
24
|
+
if (!result) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const r = _this.db.getRepository('uiSchemas');
|
|
28
|
+
const items = yield r.find({
|
|
29
|
+
filter: {
|
|
30
|
+
'schema.x-designer': 'FormV2.FilterDesigner'
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
yield _this.db.sequelize.transaction( /*#__PURE__*/function () {
|
|
34
|
+
var _ref = _asyncToGenerator(function* (transaction) {
|
|
35
|
+
var _iterator = _createForOfIteratorHelper(items),
|
|
36
|
+
_step;
|
|
37
|
+
try {
|
|
38
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
39
|
+
const item = _step.value;
|
|
40
|
+
const schema = item.schema;
|
|
41
|
+
const decorator = schema['x-decorator'];
|
|
42
|
+
schema['x-decorator'] = 'FilterFormBlockProvider';
|
|
43
|
+
item.set('schema', schema);
|
|
44
|
+
console.log(item['x-uid'], decorator, schema['x-decorator']);
|
|
45
|
+
yield item.save({
|
|
46
|
+
transaction
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
} catch (err) {
|
|
50
|
+
_iterator.e(err);
|
|
51
|
+
} finally {
|
|
52
|
+
_iterator.f();
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return function (_x) {
|
|
56
|
+
return _ref.apply(this, arguments);
|
|
57
|
+
};
|
|
58
|
+
}());
|
|
59
|
+
})();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.default = _default;
|
package/lib/model.js
CHANGED
|
@@ -4,23 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.UiSchemaModel = 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
|
class UiSchemaModel extends _database().MagicAttributeModel {
|
|
19
15
|
getServerHooksByType(type) {
|
|
20
16
|
const hooks = this.get('x-server-hooks') || [];
|
|
21
17
|
return hooks.filter(hook => hook.type === type);
|
|
22
18
|
}
|
|
23
|
-
|
|
24
19
|
}
|
|
25
|
-
|
|
26
20
|
exports.UiSchemaModel = UiSchemaModel;
|