@nocobase/plugin-ui-schema-storage 0.9.3-alpha.1 → 0.9.4-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.
@@ -0,0 +1,4 @@
1
+ import { Migration } from '@nocobase/server';
2
+ export default class extends Migration {
3
+ up(): Promise<void>;
4
+ }
@@ -0,0 +1,78 @@
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.3-alpha.2');
24
+ if (!result) {
25
+ return;
26
+ }
27
+ const r = _this.db.getRepository('uiSchemas');
28
+ const items = yield r.find({
29
+ filter: {
30
+ 'schema.x-component': 'CollectionField'
31
+ }
32
+ });
33
+ console.log(items === null || items === void 0 ? void 0 : items.length);
34
+ yield _this.db.sequelize.transaction( /*#__PURE__*/function () {
35
+ var _ref = _asyncToGenerator(function* (transaction) {
36
+ var _iterator = _createForOfIteratorHelper(items),
37
+ _step;
38
+ try {
39
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
40
+ const item = _step.value;
41
+ const schema = item.schema;
42
+ if (!schema['x-collection-field']) {
43
+ continue;
44
+ }
45
+ if (schema['type'] === 'string') {
46
+ continue;
47
+ }
48
+ const field = _this.db.getFieldByPath(schema['x-collection-field']);
49
+ if (!field) {
50
+ continue;
51
+ }
52
+ console.log(schema['x-collection-field'], schema['type']);
53
+ if (['hasOne', 'belongsTo'].includes(field.type)) {
54
+ schema['type'] = 'string';
55
+ } else if (['hasMany', 'belongsToMany'].includes(field.type)) {
56
+ schema['type'] = 'string';
57
+ } else {
58
+ continue;
59
+ }
60
+ item.set('schema', schema);
61
+ yield item.save({
62
+ transaction
63
+ });
64
+ }
65
+ } catch (err) {
66
+ _iterator.e(err);
67
+ } finally {
68
+ _iterator.f();
69
+ }
70
+ });
71
+ return function (_x) {
72
+ return _ref.apply(this, arguments);
73
+ };
74
+ }());
75
+ })();
76
+ }
77
+ }
78
+ exports.default = _default;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-ui-schema-storage",
3
- "version": "0.9.3-alpha.1",
3
+ "version": "0.9.4-alpha.2",
4
4
  "description": "",
5
5
  "license": "AGPL-3.0",
6
6
  "main": "./lib/index.js",
7
7
  "types": "./lib/index.d.ts",
8
8
  "devDependencies": {
9
9
  "@formily/json-schema": "2.0.20",
10
- "@nocobase/test": "0.9.3-alpha.1"
10
+ "@nocobase/test": "0.9.4-alpha.2"
11
11
  },
12
- "gitHead": "24979bc561537c0b84469c161eeef1a6de4c4684"
12
+ "gitHead": "2bc19a85bf9425aa220b6c467315c8087f333a7e"
13
13
  }