@nocobase/plugin-ui-schema-storage 2.1.0-beta.29 → 2.1.0-beta.32

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.
@@ -8,14 +8,13 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.1.0-beta.29",
12
- "@nocobase/database": "2.1.0-beta.29",
13
- "@nocobase/cache": "2.1.0-beta.29",
14
- "@nocobase/utils": "2.1.0-beta.29",
11
+ "@nocobase/client": "2.1.0-beta.32",
12
+ "@nocobase/database": "2.1.0-beta.32",
13
+ "@nocobase/cache": "2.1.0-beta.32",
14
+ "@nocobase/utils": "2.1.0-beta.32",
15
15
  "lodash": "4.18.1",
16
- "@nocobase/plugin-localization": "2.1.0-beta.29",
17
- "@nocobase/server": "2.1.0-beta.29",
18
- "@nocobase/actions": "2.1.0-beta.29",
19
- "@nocobase/resourcer": "2.1.0-beta.29",
16
+ "@nocobase/server": "2.1.0-beta.32",
17
+ "@nocobase/actions": "2.1.0-beta.32",
18
+ "@nocobase/resourcer": "2.1.0-beta.32",
20
19
  "@formily/json-schema": "2.3.7"
21
20
  };
@@ -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.29",
9
+ "version": "2.1.0-beta.32",
10
10
  "license": "Apache-2.0",
11
11
  "main": "./dist/server/index.js",
12
12
  "homepage": "https://docs.nocobase.com/handbook/ui-schema-storage",
@@ -21,13 +21,12 @@
21
21
  "@nocobase/client": "2.x",
22
22
  "@nocobase/database": "2.x",
23
23
  "@nocobase/plugin-error-handler": "2.x",
24
- "@nocobase/plugin-localization": "2.x",
25
24
  "@nocobase/resourcer": "2.x",
26
25
  "@nocobase/server": "2.x",
27
26
  "@nocobase/test": "2.x",
28
27
  "@nocobase/utils": "2.x"
29
28
  },
30
- "gitHead": "86c41be29dcbcac6fd6aa46b4a137ef07a27c1d0",
29
+ "gitHead": "659c5efe992da7118d33c768bbd9e837a2c4716f",
31
30
  "keywords": [
32
31
  "System & security"
33
32
  ]