@nocobase/plugin-ui-schema-storage 2.1.0-beta.9 → 2.2.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.
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client")):"function"==typeof define&&define.amd?define("@nocobase/plugin-ui-schema-storage",["@nocobase/client"],t):"object"==typeof exports?exports["@nocobase/plugin-ui-schema-storage"]=t(require("@nocobase/client")):e["@nocobase/plugin-ui-schema-storage"]=t(e["@nocobase/client"])}(self,function(e){return function(){"use strict";var t={772:function(t){t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var u=n[e]={exports:{}};return t[e](u,u.exports,r),u.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return!function(){r.r(o);var e=r(772);function t(e,t,n,r,o,u,i){try{var c=e[u](i),a=c.value}catch(e){n(e);return}c.done?t(a):Promise.resolve(a).then(r,o)}function n(e,t,r){return(n=a()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&i(o,n.prototype),o}).apply(null,arguments)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e){var t="function"==typeof Map?new Map:void 0;return(c=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return n(e,arguments,u(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),i(r,e)})(e)}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(a=function(){return!!e})()}o.default=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=u(e),function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,a()?Reflect.construct(e,t||[],u(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&i(r,e),n=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,u,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return u={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(u){return function(c){var a=[u,c];if(n)throw TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}}(this,function(e){return[2]})},function(){var n=this,r=arguments;return new Promise(function(o,u){var i=e.apply(n,r);function c(e){t(i,o,u,c,a,"next",e)}function a(e){t(i,o,u,c,a,"throw",e)}c(void 0)})})()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(r.prototype,n),r}(c(e.Plugin))}(),o}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client")):"function"==typeof define&&define.amd?define("@nocobase/plugin-ui-schema-storage",["@nocobase/client"],t):"object"==typeof exports?exports["@nocobase/plugin-ui-schema-storage"]=t(require("@nocobase/client")):e["@nocobase/plugin-ui-schema-storage"]=t(e["@nocobase/client"])}(self,function(e){return function(){"use strict";var t={342:function(t){t.exports=e}},r={};function n(e){var o=r[e];if(void 0!==o)return o.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.g.importScripts&&(o=n.g.location+"");var o,i=n.g.document;if(!o&&i&&(i.currentScript&&"SCRIPT"===i.currentScript.tagName.toUpperCase()&&(o=i.currentScript.src),!o)){var c=i.getElementsByTagName("script");if(c.length)for(var u=c.length-1;u>-1&&(!o||!/^http(s?):/.test(o));)o=c[u--].src}if(!o)throw Error("Automatic publicPath is not supported in this browser");n.p=o.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var a={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-ui-schema-storage/dist/client/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var c=window.location.pathname||"/",u=c.indexOf(i);e=u>=0?c.slice(0,u+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-ui-schema-storage/dist/client/"}n.p=e}(),!function(){n.r(a);var e=n(342);function t(e,t,r,n,o,i,c){try{var u=e[i](c),a=u.value}catch(e){r(e);return}u.done?t(a):Promise.resolve(a).then(n,o)}function r(e,t,n){return(r=u()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&i(o,r.prototype),o}).apply(null,arguments)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e){var t="function"==typeof Map?new Map:void 0;return(c=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return r(e,arguments,o(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),i(n,e)})(e)}function u(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(u=function(){return!!e})()}a.default=function(e){var r;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=o(e),function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,u()?Reflect.construct(e,t||[],o(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&i(n,e),r=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(c,"next",{value:a(0)}),u(c,"throw",{value:a(1)}),u(c,"return",{value:a(2)}),"function"==typeof Symbol&&u(c,Symbol.iterator,{value:function(){return this}}),c;function a(u){return function(a){var l=[u,a];if(r)throw TypeError("Generator is already executing.");for(;c&&(c=0,l[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,n=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(e){return[2]})},function(){var r=this,n=arguments;return new Promise(function(o,i){var c=e.apply(r,n);function u(e){t(c,o,i,u,a,"next",e)}function a(e){t(c,o,i,u,a,"throw",e)}u(void 0)})})()}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(n.prototype,r),n}(c(e.Plugin))}(),a}()});
@@ -8,14 +8,13 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.1.0-beta.9",
12
- "@nocobase/database": "2.1.0-beta.9",
13
- "@nocobase/cache": "2.1.0-beta.9",
14
- "@nocobase/utils": "2.1.0-beta.9",
15
- "lodash": "4.17.21",
16
- "@nocobase/plugin-localization": "2.1.0-beta.9",
17
- "@nocobase/server": "2.1.0-beta.9",
18
- "@nocobase/actions": "2.1.0-beta.9",
19
- "@nocobase/resourcer": "2.1.0-beta.9",
11
+ "@nocobase/client": "2.2.0-alpha.1",
12
+ "@nocobase/database": "2.2.0-alpha.1",
13
+ "@nocobase/cache": "2.2.0-alpha.1",
14
+ "@nocobase/utils": "2.2.0-alpha.1",
15
+ "lodash": "4.18.1",
16
+ "@nocobase/server": "2.2.0-alpha.1",
17
+ "@nocobase/actions": "2.2.0-alpha.1",
18
+ "@nocobase/resourcer": "2.2.0-alpha.1",
20
19
  "@formily/json-schema": "2.3.7"
21
20
  };
@@ -32,6 +32,7 @@ module.exports = __toCommonJS(uiButtonSchemasRoles_exports);
32
32
  var import_database = require("@nocobase/database");
33
33
  var uiButtonSchemasRoles_default = (0, import_database.defineCollection)({
34
34
  name: "uiButtonSchemasRoles",
35
+ dataCategory: "system",
35
36
  dumpRules: "required",
36
37
  autoGenId: false,
37
38
  migrationRules: ["overwrite", "schema-only"]
@@ -33,6 +33,7 @@ var uiSchemaServerHooks_default = {
33
33
  dumpRules: "required",
34
34
  migrationRules: ["overwrite", "schema-only"],
35
35
  name: "uiSchemaServerHooks",
36
+ dataCategory: "system",
36
37
  model: "ServerHookModel",
37
38
  // autoGenId: false,
38
39
  timestamps: false,
@@ -34,6 +34,7 @@ var uiSchemaTemplates_default = (0, import_database.defineCollection)({
34
34
  dumpRules: "required",
35
35
  migrationRules: ["overwrite", "schema-only"],
36
36
  name: "uiSchemaTemplates",
37
+ dataCategory: "system",
37
38
  autoGenId: false,
38
39
  fields: [
39
40
  {
@@ -33,6 +33,7 @@ var uiSchemaTreePath_default = {
33
33
  dumpRules: "required",
34
34
  migrationRules: ["overwrite", "schema-only"],
35
35
  name: "uiSchemaTreePath",
36
+ dataCategory: "system",
36
37
  autoGenId: false,
37
38
  timestamps: false,
38
39
  indexes: [
@@ -32,6 +32,7 @@ module.exports = __toCommonJS(uiSchemas_exports);
32
32
  var uiSchemas_default = {
33
33
  dumpRules: "required",
34
34
  name: "uiSchemas",
35
+ dataCategory: "system",
35
36
  migrationRules: ["overwrite", "schema-only"],
36
37
  autoGenId: false,
37
38
  timestamps: false,
@@ -82,7 +82,6 @@ class PluginUISchemaStorageServer extends import_server.Plugin {
82
82
  }
83
83
  async beforeLoad() {
84
84
  const db = this.app.db;
85
- const pm = this.app.pm;
86
85
  this.serverHooks = new import_server_hooks.ServerHooks(db);
87
86
  this.app.db.registerModels({ MagicAttributeModel: import_database.MagicAttributeModel, UiSchemaModel: import_model.UiSchemaModel, ServerHookModel: import_model2.ServerHookModel });
88
87
  this.registerRepository();
@@ -99,19 +98,7 @@ class PluginUISchemaStorageServer extends import_server.Plugin {
99
98
  model.set("name", (0, import_utils.uid)());
100
99
  }
101
100
  });
102
- db.on("uiSchemas.afterSave", async function setUid(model, options) {
103
- var _a;
104
- const localizationPlugin = pm.get("localization");
105
- const texts = [];
106
- const changedFields = extractFields(model.toJSON());
107
- if (!changedFields.length) {
108
- return;
109
- }
110
- changedFields.forEach((field) => {
111
- field && texts.push({ text: compile(field), module: `resources.ui-schema-storage` });
112
- });
113
- await ((_a = localizationPlugin == null ? void 0 : localizationPlugin.addNewTexts) == null ? void 0 : _a.call(localizationPlugin, texts, options));
114
- });
101
+ this.registerLocalizationSource();
115
102
  db.on("uiSchemas.afterCreate", async function insertSchema(model, options) {
116
103
  const { transaction } = options;
117
104
  const uiSchemaRepository = db.getCollection("uiSchemas").repository;
@@ -178,29 +165,14 @@ class PluginUISchemaStorageServer extends import_server.Plugin {
178
165
  await this.importCollections((0, import_path.resolve)(__dirname, "collections"));
179
166
  }
180
167
  registerLocalizationSource() {
181
- const localizationPlugin = this.app.pm.get("localization");
182
- if (!localizationPlugin) {
183
- return;
184
- }
185
- localizationPlugin.sourceManager.registerSource("ui-schema-storage", {
168
+ this.app.localeManager.registerSource("ui-schema-storage", {
186
169
  title: (0, import_utils.tval)("UiSchema"),
187
- sync: async (ctx) => {
188
- const uiSchemas = await ctx.db.getRepository("uiSchemas").find({
189
- raw: true
190
- });
191
- const resources = {};
192
- uiSchemas.forEach((route) => {
193
- const changedFields = extractFields(route.schema);
194
- if (changedFields.length) {
195
- changedFields.forEach((field) => {
196
- resources[field] = "";
197
- });
198
- }
199
- });
200
- return {
201
- "ui-schema-storage": resources
202
- };
203
- }
170
+ collections: [
171
+ {
172
+ collection: "uiSchemas",
173
+ getTexts: (model) => extractFields(model.toJSON()).map((field) => compile(field)).filter(Boolean).map((text) => ({ text, module: `resources.ui-schema-storage` }))
174
+ }
175
+ ]
204
176
  });
205
177
  }
206
178
  }
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description": "Provides centralized UI schema storage service.",
7
7
  "description.zh-CN": "提供中心化的 UI schema 存储服务。",
8
8
  "description.ru-RU": "Предоставляет централизованный сервис хранения UI схем.",
9
- "version": "2.1.0-beta.9",
9
+ "version": "2.2.0-alpha.1",
10
10
  "license": "Apache-2.0",
11
11
  "main": "./dist/server/index.js",
12
12
  "homepage": "https://docs.nocobase.com/handbook/ui-schema-storage",
@@ -26,7 +26,7 @@
26
26
  "@nocobase/test": "2.x",
27
27
  "@nocobase/utils": "2.x"
28
28
  },
29
- "gitHead": "c3a2875e4cbbb43b1f2361e6f9f5f84a7d3f3c3c",
29
+ "gitHead": "303663aba6c6eefa27e6a6435b4c0352074ec40f",
30
30
  "keywords": [
31
31
  "System & security"
32
32
  ]