@tachybase/plugin-i18n-editor 0.23.8
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/.turbo/turbo-build.log +14 -0
- package/README.md +35 -0
- package/client.d.ts +3 -0
- package/client.js +65 -0
- package/dist/client/Localization.d.ts +2 -0
- package/dist/client/index.d.ts +5 -0
- package/dist/client/index.js +1 -0
- package/dist/client/locale/index.d.ts +2 -0
- package/dist/client/schemas/localization.d.ts +2 -0
- package/dist/externalVersion.js +14 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +39 -0
- package/dist/locale/en-US.json +24 -0
- package/dist/locale/ko_KR.json +23 -0
- package/dist/locale/zh-CN.json +24 -0
- package/dist/node_modules/deepmerge/.editorconfig +7 -0
- package/dist/node_modules/deepmerge/.eslintcache +1 -0
- package/dist/node_modules/deepmerge/dist/cjs.js +1 -0
- package/dist/node_modules/deepmerge/dist/umd.js +139 -0
- package/dist/node_modules/deepmerge/index.d.ts +20 -0
- package/dist/node_modules/deepmerge/index.js +106 -0
- package/dist/node_modules/deepmerge/license.txt +21 -0
- package/dist/node_modules/deepmerge/package.json +1 -0
- package/dist/node_modules/deepmerge/rollup.config.js +22 -0
- package/dist/server/actions/localization.d.ts +11 -0
- package/dist/server/actions/localization.js +225 -0
- package/dist/server/actions/localizationTexts.d.ts +5 -0
- package/dist/server/actions/localizationTexts.js +130 -0
- package/dist/server/collections/localization-texts.d.ts +2 -0
- package/dist/server/collections/localization-texts.js +86 -0
- package/dist/server/collections/localization-translations.d.ts +2 -0
- package/dist/server/collections/localization-translations.js +84 -0
- package/dist/server/constans.d.ts +8 -0
- package/dist/server/constans.js +48 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +33 -0
- package/dist/server/migrations/20230706200900-roles-add-translation.d.ts +6 -0
- package/dist/server/migrations/20230706200900-roles-add-translation.js +50 -0
- package/dist/server/migrations/20231206161851-fix-module.d.ts +6 -0
- package/dist/server/migrations/20231206161851-fix-module.js +91 -0
- package/dist/server/plugin.d.ts +15 -0
- package/dist/server/plugin.js +162 -0
- package/dist/server/resources.d.ts +19 -0
- package/dist/server/resources.js +86 -0
- package/dist/server/utils.d.ts +3 -0
- package/dist/server/utils.js +79 -0
- package/dist/swagger/index.json +156 -0
- package/package.json +34 -0
- package/server.d.ts +3 -0
- package/server.js +65 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var localization_exports = {};
|
|
19
|
+
__export(localization_exports, {
|
|
20
|
+
default: () => localization_default,
|
|
21
|
+
getResources: () => getResources,
|
|
22
|
+
getTextsFromDB: () => getTextsFromDB,
|
|
23
|
+
getTextsFromMenu: () => getTextsFromMenu,
|
|
24
|
+
getUISchemas: () => getUISchemas
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(localization_exports);
|
|
27
|
+
var import_database = require("@tachybase/database");
|
|
28
|
+
var import_constans = require("../constans");
|
|
29
|
+
var import_utils = require("../utils");
|
|
30
|
+
const getResourcesInstance = async (ctx) => {
|
|
31
|
+
const plugin = ctx.app.getPlugin("localization-management");
|
|
32
|
+
return plugin.resources;
|
|
33
|
+
};
|
|
34
|
+
const getResources = async (ctx) => {
|
|
35
|
+
const resources = await ctx.app.localeManager.getCacheResources(ctx.get("X-Locale") || "en-US");
|
|
36
|
+
return { ...resources };
|
|
37
|
+
};
|
|
38
|
+
const getUISchemas = async (db) => {
|
|
39
|
+
const uiSchemas = await db.getModel("uiSchemas").findAll({
|
|
40
|
+
attributes: ["schema"],
|
|
41
|
+
where: {
|
|
42
|
+
[import_database.Op.or]: [
|
|
43
|
+
{
|
|
44
|
+
schema: {
|
|
45
|
+
title: {
|
|
46
|
+
[import_database.Op.ne]: null
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
schema: {
|
|
52
|
+
"x-component-props": {
|
|
53
|
+
title: {
|
|
54
|
+
[import_database.Op.ne]: null
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
schema: {
|
|
61
|
+
"x-decorator-props": {
|
|
62
|
+
title: {
|
|
63
|
+
[import_database.Op.ne]: null
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
schema: {
|
|
70
|
+
"x-data-templates": {
|
|
71
|
+
[import_database.Op.ne]: null
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return uiSchemas;
|
|
79
|
+
};
|
|
80
|
+
const getTextsFromUISchemas = async (db) => {
|
|
81
|
+
const result = {};
|
|
82
|
+
const schemas = await getUISchemas(db);
|
|
83
|
+
schemas.forEach((schema) => {
|
|
84
|
+
const texts = (0, import_utils.getTextsFromUISchema)(schema.schema);
|
|
85
|
+
texts.forEach((text) => result[text] = "");
|
|
86
|
+
});
|
|
87
|
+
return result;
|
|
88
|
+
};
|
|
89
|
+
const getTextsFromDB = async (db) => {
|
|
90
|
+
const result = {};
|
|
91
|
+
const collections = Array.from(db.collections.values());
|
|
92
|
+
for (const collection of collections) {
|
|
93
|
+
const fields = Array.from(collection.fields.values()).filter((field) => {
|
|
94
|
+
var _a;
|
|
95
|
+
return (_a = field.options) == null ? void 0 : _a.translation;
|
|
96
|
+
}).map((field) => field.name);
|
|
97
|
+
if (!fields.length) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const repo = db.getRepository(collection.name);
|
|
101
|
+
const records = await repo.find({ fields });
|
|
102
|
+
records.forEach((record) => {
|
|
103
|
+
const texts = (0, import_utils.getTextsFromDBRecord)(fields, record);
|
|
104
|
+
texts.forEach((text) => result[text] = "");
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return result;
|
|
108
|
+
};
|
|
109
|
+
const getSchemaUid = async (db, migrate = false) => {
|
|
110
|
+
if (migrate) {
|
|
111
|
+
const systemSettings = await db.getRepository("systemSettings").findOne();
|
|
112
|
+
const options = (systemSettings == null ? void 0 : systemSettings.options) || {};
|
|
113
|
+
const { adminSchemaUid, mobileSchemaUid } = options;
|
|
114
|
+
return { adminSchemaUid, mobileSchemaUid };
|
|
115
|
+
}
|
|
116
|
+
return { adminSchemaUid: "default-admin-menu", mobileSchemaUid: "default-admin-mobile" };
|
|
117
|
+
};
|
|
118
|
+
const getTextsFromMenu = async (db, migrate = false) => {
|
|
119
|
+
var _a, _b, _c, _d;
|
|
120
|
+
const result = {};
|
|
121
|
+
const { adminSchemaUid, mobileSchemaUid } = await getSchemaUid(db, migrate);
|
|
122
|
+
const repo = db.getRepository("uiSchemas");
|
|
123
|
+
if (adminSchemaUid) {
|
|
124
|
+
const schema = await repo.getProperties(adminSchemaUid);
|
|
125
|
+
const extractTitle = (schema2) => {
|
|
126
|
+
if (schema2 == null ? void 0 : schema2.properties) {
|
|
127
|
+
Object.values(schema2.properties).forEach((item) => {
|
|
128
|
+
if (item.title) {
|
|
129
|
+
result[item.title] = "";
|
|
130
|
+
}
|
|
131
|
+
extractTitle(item);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
extractTitle(schema);
|
|
136
|
+
}
|
|
137
|
+
if (mobileSchemaUid) {
|
|
138
|
+
const schema = await repo.getProperties(mobileSchemaUid);
|
|
139
|
+
if ((_b = (_a = schema == null ? void 0 : schema["properties"]) == null ? void 0 : _a.tabBar) == null ? void 0 : _b.properties) {
|
|
140
|
+
Object.values((_d = (_c = schema["properties"]) == null ? void 0 : _c.tabBar) == null ? void 0 : _d.properties).forEach((item) => {
|
|
141
|
+
var _a2;
|
|
142
|
+
const title = (_a2 = item["x-component-props"]) == null ? void 0 : _a2.title;
|
|
143
|
+
if (title) {
|
|
144
|
+
result[title] = "";
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return result;
|
|
150
|
+
};
|
|
151
|
+
const sync = async (ctx, next) => {
|
|
152
|
+
const startTime = Date.now();
|
|
153
|
+
ctx.logger.info("Start sync localization resources");
|
|
154
|
+
const resourcesInstance = await getResourcesInstance(ctx);
|
|
155
|
+
const locale = ctx.get("X-Locale") || "en-US";
|
|
156
|
+
const { type = [] } = ctx.action.params.values || {};
|
|
157
|
+
if (!type.length) {
|
|
158
|
+
ctx.throw(400, ctx.t("Please provide synchronization source."));
|
|
159
|
+
}
|
|
160
|
+
let resources = { client: {} };
|
|
161
|
+
if (type.includes("local")) {
|
|
162
|
+
resources = await getResources(ctx);
|
|
163
|
+
}
|
|
164
|
+
if (type.includes("menu")) {
|
|
165
|
+
const menuTexts = await getTextsFromMenu(ctx.db);
|
|
166
|
+
resources[import_constans.NAMESPACE_MENUS] = {
|
|
167
|
+
...menuTexts
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
if (type.includes("db")) {
|
|
171
|
+
const dbTexts = await getTextsFromDB(ctx.db);
|
|
172
|
+
resources[import_constans.NAMESPACE_COLLECTIONS] = {
|
|
173
|
+
...dbTexts
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
let textValues = [];
|
|
177
|
+
Object.entries(resources).forEach(([module2, resource]) => {
|
|
178
|
+
Object.keys(resource).forEach((text) => {
|
|
179
|
+
textValues.push({ module: `resources.${module2}`, text });
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
textValues = await resourcesInstance.filterExists(textValues);
|
|
183
|
+
await ctx.db.sequelize.transaction(async (t) => {
|
|
184
|
+
const newTexts = await ctx.db.getModel("localizationTexts").bulkCreate(textValues, {
|
|
185
|
+
transaction: t
|
|
186
|
+
});
|
|
187
|
+
const texts = await ctx.db.getModel("localizationTexts").findAll({
|
|
188
|
+
include: [{ association: "translations", where: { locale }, required: false }],
|
|
189
|
+
where: { "$translations.id$": null },
|
|
190
|
+
transaction: t
|
|
191
|
+
});
|
|
192
|
+
const translationValues = texts.filter((text) => {
|
|
193
|
+
var _a;
|
|
194
|
+
const module2 = text.module.replace("resources.", "");
|
|
195
|
+
return (_a = resources[module2]) == null ? void 0 : _a[text.text];
|
|
196
|
+
}).map((text) => {
|
|
197
|
+
var _a;
|
|
198
|
+
const module2 = text.module.replace("resources.", "");
|
|
199
|
+
return {
|
|
200
|
+
locale,
|
|
201
|
+
textId: text.id,
|
|
202
|
+
translation: (_a = resources[module2]) == null ? void 0 : _a[text.text]
|
|
203
|
+
};
|
|
204
|
+
});
|
|
205
|
+
await ctx.db.getModel("localizationTranslations").bulkCreate(translationValues, {
|
|
206
|
+
transaction: t
|
|
207
|
+
});
|
|
208
|
+
await resourcesInstance.updateCacheTexts(newTexts);
|
|
209
|
+
});
|
|
210
|
+
ctx.logger.info(`Sync localization resources done, ${Date.now() - startTime}ms`);
|
|
211
|
+
await next();
|
|
212
|
+
};
|
|
213
|
+
const publish = async (ctx, next) => {
|
|
214
|
+
const resources = await getResourcesInstance(ctx);
|
|
215
|
+
ctx.body = await resources.resetCache(ctx.get("X-Locale") || "en-US");
|
|
216
|
+
await next();
|
|
217
|
+
};
|
|
218
|
+
var localization_default = { publish, sync };
|
|
219
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
220
|
+
0 && (module.exports = {
|
|
221
|
+
getResources,
|
|
222
|
+
getTextsFromDB,
|
|
223
|
+
getTextsFromMenu,
|
|
224
|
+
getUISchemas
|
|
225
|
+
});
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var localizationTexts_exports = {};
|
|
19
|
+
__export(localizationTexts_exports, {
|
|
20
|
+
default: () => localizationTexts_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(localizationTexts_exports);
|
|
23
|
+
var import_actions = require("@tachybase/actions");
|
|
24
|
+
var import_database = require("@tachybase/database");
|
|
25
|
+
var import_constans = require("../constans");
|
|
26
|
+
const appendTranslations = async (db, rows, locale) => {
|
|
27
|
+
const texts = rows || [];
|
|
28
|
+
const textIds = texts.map((text) => text.id);
|
|
29
|
+
const textMp = texts.reduce((memo, text) => {
|
|
30
|
+
memo[text.id] = text;
|
|
31
|
+
return memo;
|
|
32
|
+
}, {});
|
|
33
|
+
const repo = db.getRepository("localizationTranslations");
|
|
34
|
+
const translations = await repo.find({
|
|
35
|
+
filter: {
|
|
36
|
+
locale,
|
|
37
|
+
textId: textIds
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
translations.forEach((translation) => {
|
|
41
|
+
const text = textMp[translation.textId];
|
|
42
|
+
if (text) {
|
|
43
|
+
text.set("translation", translation.translation, { raw: true });
|
|
44
|
+
text.set("translationId", translation.id, { raw: true });
|
|
45
|
+
textMp[translation.textId] = text;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return Object.values(textMp);
|
|
49
|
+
};
|
|
50
|
+
const listText = async (db, params) => {
|
|
51
|
+
const { module: module2, keyword, hasTranslation, locale, options } = params;
|
|
52
|
+
if (module2) {
|
|
53
|
+
options["filter"] = { module: `resources.${module2}` };
|
|
54
|
+
}
|
|
55
|
+
if (keyword || !hasTranslation) {
|
|
56
|
+
options["include"] = [{ association: "translations", where: { locale }, required: false }];
|
|
57
|
+
if (!hasTranslation) {
|
|
58
|
+
if (keyword) {
|
|
59
|
+
options["filter"] = {
|
|
60
|
+
...options["filter"],
|
|
61
|
+
text: {
|
|
62
|
+
$includes: keyword
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
options["where"] = {
|
|
67
|
+
"$translations.id$": null
|
|
68
|
+
};
|
|
69
|
+
} else {
|
|
70
|
+
options["where"] = {
|
|
71
|
+
[import_database.Op.or]: [
|
|
72
|
+
{ text: { [import_database.Op.like]: `%${keyword}%` } },
|
|
73
|
+
{ "$translations.translation$": { [import_database.Op.like]: `%${keyword}%` } }
|
|
74
|
+
]
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const [rows, count] = await db.getRepository("localizationTexts").findAndCount(options);
|
|
79
|
+
if (!hasTranslation) {
|
|
80
|
+
return [rows, count];
|
|
81
|
+
}
|
|
82
|
+
return [await appendTranslations(db, rows, locale), count];
|
|
83
|
+
};
|
|
84
|
+
const list = async (ctx, next) => {
|
|
85
|
+
const locale = ctx.get("X-Locale") || "en-US";
|
|
86
|
+
let { page = import_actions.DEFAULT_PAGE, pageSize = import_actions.DEFAULT_PER_PAGE, hasTranslation } = ctx.action.params;
|
|
87
|
+
page = parseInt(String(page));
|
|
88
|
+
pageSize = parseInt(String(pageSize));
|
|
89
|
+
hasTranslation = hasTranslation === "true" || hasTranslation === void 0;
|
|
90
|
+
const { keyword, module: module2 } = ctx.action.params;
|
|
91
|
+
const options = {
|
|
92
|
+
context: ctx,
|
|
93
|
+
offset: (page - 1) * pageSize,
|
|
94
|
+
limit: pageSize
|
|
95
|
+
};
|
|
96
|
+
const [rows, count] = await listText(ctx.db, { module: module2, keyword, hasTranslation, locale, options });
|
|
97
|
+
const cache = ctx.app.cache;
|
|
98
|
+
const pm = ctx.app.pm;
|
|
99
|
+
const plugins = await cache.wrap(`lm-plugins:${locale}`, () => pm.list({ locale }));
|
|
100
|
+
const modules = [
|
|
101
|
+
...import_constans.EXTEND_MODULES,
|
|
102
|
+
...plugins.map((plugin) => ({
|
|
103
|
+
value: plugin.alias || plugin.name,
|
|
104
|
+
label: plugin.displayName
|
|
105
|
+
}))
|
|
106
|
+
];
|
|
107
|
+
for (const row of rows) {
|
|
108
|
+
const moduleName = row.get("module").replace("resources.", "");
|
|
109
|
+
const module3 = modules.find((module4) => module4.value === moduleName);
|
|
110
|
+
if (module3) {
|
|
111
|
+
row.set("moduleTitle", module3.label, { raw: true });
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
ctx.body = {
|
|
115
|
+
count,
|
|
116
|
+
rows,
|
|
117
|
+
page,
|
|
118
|
+
pageSize,
|
|
119
|
+
totalPage: Math.ceil(count / pageSize),
|
|
120
|
+
modules: [
|
|
121
|
+
...import_constans.EXTEND_MODULES,
|
|
122
|
+
...plugins.map((plugin) => ({
|
|
123
|
+
value: plugin.alias || plugin.name,
|
|
124
|
+
label: plugin.displayName
|
|
125
|
+
}))
|
|
126
|
+
]
|
|
127
|
+
};
|
|
128
|
+
await next();
|
|
129
|
+
};
|
|
130
|
+
var localizationTexts_default = { list };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var localization_texts_exports = {};
|
|
19
|
+
__export(localization_texts_exports, {
|
|
20
|
+
default: () => localization_texts_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(localization_texts_exports);
|
|
23
|
+
var import_database = require("@tachybase/database");
|
|
24
|
+
var localization_texts_default = (0, import_database.defineCollection)({
|
|
25
|
+
dumpRules: {
|
|
26
|
+
group: "required"
|
|
27
|
+
},
|
|
28
|
+
name: "localizationTexts",
|
|
29
|
+
model: "LocalizationTextModel",
|
|
30
|
+
createdBy: true,
|
|
31
|
+
updatedBy: true,
|
|
32
|
+
logging: true,
|
|
33
|
+
shared: true,
|
|
34
|
+
fields: [
|
|
35
|
+
{
|
|
36
|
+
name: "id",
|
|
37
|
+
type: "bigInt",
|
|
38
|
+
autoIncrement: true,
|
|
39
|
+
primaryKey: true,
|
|
40
|
+
allowNull: false,
|
|
41
|
+
interface: "id"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
interface: "input",
|
|
45
|
+
type: "string",
|
|
46
|
+
name: "module",
|
|
47
|
+
allowNull: false,
|
|
48
|
+
uiSchema: {
|
|
49
|
+
type: "string",
|
|
50
|
+
title: '{{t("Module")}}',
|
|
51
|
+
"x-component": "Select",
|
|
52
|
+
required: true
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
interface: "input",
|
|
57
|
+
type: "text",
|
|
58
|
+
name: "text",
|
|
59
|
+
allowNull: false,
|
|
60
|
+
uiSchema: {
|
|
61
|
+
type: "string",
|
|
62
|
+
title: '{{t("Text")}}',
|
|
63
|
+
"x-component": "Input",
|
|
64
|
+
required: true
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "batch",
|
|
69
|
+
type: "string"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
interface: "o2m",
|
|
73
|
+
type: "hasMany",
|
|
74
|
+
name: "translations",
|
|
75
|
+
target: "localizationTranslations",
|
|
76
|
+
sourceKey: "id",
|
|
77
|
+
foreignKey: "textId",
|
|
78
|
+
onDelete: "CASCADE"
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
indexes: [
|
|
82
|
+
{
|
|
83
|
+
fields: ["batch"]
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var localization_translations_exports = {};
|
|
19
|
+
__export(localization_translations_exports, {
|
|
20
|
+
default: () => localization_translations_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(localization_translations_exports);
|
|
23
|
+
var import_database = require("@tachybase/database");
|
|
24
|
+
var localization_translations_default = (0, import_database.defineCollection)({
|
|
25
|
+
namespace: "localization.localization",
|
|
26
|
+
dumpRules: {
|
|
27
|
+
group: "required"
|
|
28
|
+
},
|
|
29
|
+
name: "localizationTranslations",
|
|
30
|
+
model: "LocalizationTranslationModel",
|
|
31
|
+
createdBy: true,
|
|
32
|
+
updatedBy: true,
|
|
33
|
+
logging: true,
|
|
34
|
+
shared: true,
|
|
35
|
+
fields: [
|
|
36
|
+
{
|
|
37
|
+
name: "id",
|
|
38
|
+
type: "bigInt",
|
|
39
|
+
autoIncrement: true,
|
|
40
|
+
primaryKey: true,
|
|
41
|
+
allowNull: false,
|
|
42
|
+
interface: "id"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
interface: "input",
|
|
46
|
+
type: "string",
|
|
47
|
+
name: "locale",
|
|
48
|
+
allowNull: false,
|
|
49
|
+
uiSchema: {
|
|
50
|
+
type: "string",
|
|
51
|
+
title: '{{t("Locale")}}',
|
|
52
|
+
"x-component": "Input",
|
|
53
|
+
required: true
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
interface: "input",
|
|
58
|
+
type: "text",
|
|
59
|
+
name: "translation",
|
|
60
|
+
allowNull: false,
|
|
61
|
+
defaultValue: "",
|
|
62
|
+
uiSchema: {
|
|
63
|
+
type: "string",
|
|
64
|
+
title: '{{t("Translation")}}',
|
|
65
|
+
"x-component": "Input",
|
|
66
|
+
required: true
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
interface: "m2o",
|
|
71
|
+
type: "belongsTo",
|
|
72
|
+
name: "text",
|
|
73
|
+
target: "localizationTexts",
|
|
74
|
+
targetKey: "id",
|
|
75
|
+
foreignKey: "textId"
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
indexes: [
|
|
79
|
+
{
|
|
80
|
+
fields: ["locale", "textId"],
|
|
81
|
+
unique: true
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const CACHE_KEY = "localization:texts";
|
|
2
|
+
export declare const NAMESPACE_PREFIX = "lm-";
|
|
3
|
+
export declare const NAMESPACE_MENUS = "lm-menus";
|
|
4
|
+
export declare const NAMESPACE_COLLECTIONS = "lm-collections";
|
|
5
|
+
export declare const EXTEND_MODULES: {
|
|
6
|
+
value: string;
|
|
7
|
+
label: string;
|
|
8
|
+
}[];
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var constans_exports = {};
|
|
19
|
+
__export(constans_exports, {
|
|
20
|
+
CACHE_KEY: () => CACHE_KEY,
|
|
21
|
+
EXTEND_MODULES: () => EXTEND_MODULES,
|
|
22
|
+
NAMESPACE_COLLECTIONS: () => NAMESPACE_COLLECTIONS,
|
|
23
|
+
NAMESPACE_MENUS: () => NAMESPACE_MENUS,
|
|
24
|
+
NAMESPACE_PREFIX: () => NAMESPACE_PREFIX
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(constans_exports);
|
|
27
|
+
const CACHE_KEY = "localization:texts";
|
|
28
|
+
const NAMESPACE_PREFIX = "lm-";
|
|
29
|
+
const NAMESPACE_MENUS = `${NAMESPACE_PREFIX}menus`;
|
|
30
|
+
const NAMESPACE_COLLECTIONS = `${NAMESPACE_PREFIX}collections`;
|
|
31
|
+
const EXTEND_MODULES = [
|
|
32
|
+
{
|
|
33
|
+
value: NAMESPACE_MENUS,
|
|
34
|
+
label: "Menu"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
value: NAMESPACE_COLLECTIONS,
|
|
38
|
+
label: "Collections & Fields"
|
|
39
|
+
}
|
|
40
|
+
];
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
CACHE_KEY,
|
|
44
|
+
EXTEND_MODULES,
|
|
45
|
+
NAMESPACE_COLLECTIONS,
|
|
46
|
+
NAMESPACE_MENUS,
|
|
47
|
+
NAMESPACE_PREFIX
|
|
48
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './plugin';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var server_exports = {};
|
|
29
|
+
__export(server_exports, {
|
|
30
|
+
default: () => import_plugin.default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(server_exports);
|
|
33
|
+
var import_plugin = __toESM(require("./plugin"));
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var roles_add_translation_exports = {};
|
|
19
|
+
__export(roles_add_translation_exports, {
|
|
20
|
+
default: () => AddTranslationToRoleTitleMigration
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(roles_add_translation_exports);
|
|
23
|
+
var import_server = require("@tachybase/server");
|
|
24
|
+
class AddTranslationToRoleTitleMigration extends import_server.Migration {
|
|
25
|
+
appVersion = "<0.11.1-alpha.1";
|
|
26
|
+
async up() {
|
|
27
|
+
const repo = this.context.db.getRepository("fields");
|
|
28
|
+
const field = await repo.findOne({
|
|
29
|
+
where: {
|
|
30
|
+
collectionName: "roles",
|
|
31
|
+
name: "title"
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
if (field) {
|
|
35
|
+
await repo.update({
|
|
36
|
+
filter: {
|
|
37
|
+
key: field.key
|
|
38
|
+
},
|
|
39
|
+
values: {
|
|
40
|
+
options: {
|
|
41
|
+
...field.options,
|
|
42
|
+
translation: true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async down() {
|
|
49
|
+
}
|
|
50
|
+
}
|