@nocobase/plugin-client 0.10.0-alpha.5 → 0.11.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.
- package/client.d.ts +3 -0
- package/client.js +1 -0
- package/lib/client/index.d.ts +5 -0
- package/lib/client/index.js +22 -0
- package/lib/{cronstrue.js → server/cronstrue.js} +1 -1
- package/lib/server/index.d.ts +1 -0
- package/lib/server/index.js +13 -0
- package/lib/{migrations → server/migrations}/20230620203216-admin-ui-schema-uid.js +1 -1
- package/lib/{server.js → server/server.js} +13 -13
- package/package.json +23 -5
- package/server.d.ts +3 -0
- package/server.js +1 -0
- package/src/client/index.ts +7 -0
- package/src/index.ts +1 -0
- package/src/server/antd.ts +9 -0
- package/src/server/cron.ts +16 -0
- package/src/server/cronstrue.ts +111 -0
- package/src/server/index.ts +1 -0
- package/src/server/locale/en-US.json +1289 -0
- package/src/server/locale/es-ES.json +1462 -0
- package/src/server/locale/index.ts +4 -0
- package/src/server/locale/pt-BR.json +1385 -0
- package/src/server/locale/uk-UA.json +1289 -0
- package/src/server/locale/zh-CN.json +1388 -0
- package/src/server/migrations/20230620203216-admin-ui-schema-uid.ts +26 -0
- package/src/server/moment-locale.ts +141 -0
- package/src/server/resource.ts +69 -0
- package/src/server/server.ts +277 -0
- /package/lib/{antd.d.ts → server/antd.d.ts} +0 -0
- /package/lib/{antd.js → server/antd.js} +0 -0
- /package/lib/{cron.d.ts → server/cron.d.ts} +0 -0
- /package/lib/{cron.js → server/cron.js} +0 -0
- /package/lib/{cronstrue.d.ts → server/cronstrue.d.ts} +0 -0
- /package/lib/{locale → server/locale}/en-US.json +0 -0
- /package/lib/{locale → server/locale}/es-ES.json +0 -0
- /package/lib/{locale → server/locale}/index.d.ts +0 -0
- /package/lib/{locale → server/locale}/index.js +0 -0
- /package/lib/{locale → server/locale}/pt-BR.json +0 -0
- /package/lib/{locale → server/locale}/uk-UA.json +0 -0
- /package/lib/{locale → server/locale}/zh-CN.json +0 -0
- /package/lib/{migrations → server/migrations}/20230620203216-admin-ui-schema-uid.d.ts +0 -0
- /package/lib/{moment-locale.d.ts → server/moment-locale.d.ts} +0 -0
- /package/lib/{moment-locale.js → server/moment-locale.js} +0 -0
- /package/lib/{resource.d.ts → server/resource.d.ts} +0 -0
- /package/lib/{resource.js → server/resource.js} +0 -0
- /package/lib/{server.d.ts → server/server.d.ts} +0 -0
package/client.d.ts
ADDED
package/client.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./lib/client/index.js');
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
function _client() {
|
|
8
|
+
const data = require("@nocobase/client");
|
|
9
|
+
_client = function _client() {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
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); } }
|
|
15
|
+
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); }); }; }
|
|
16
|
+
class ClientPlugin extends _client().Plugin {
|
|
17
|
+
load() {
|
|
18
|
+
return _asyncToGenerator(function* () {})();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
var _default = ClientPlugin;
|
|
22
|
+
exports.default = _default;
|
|
@@ -45,7 +45,7 @@ const getCronstrueLocale = lang => {
|
|
|
45
45
|
const lng = langs[lang] || 'en';
|
|
46
46
|
const Locale = require(`cronstrue/locales/${lng}`);
|
|
47
47
|
let locale;
|
|
48
|
-
if (Locale
|
|
48
|
+
if (Locale !== null && Locale !== void 0 && Locale.default) {
|
|
49
49
|
locale = Locale.default.locales[lng];
|
|
50
50
|
} else {
|
|
51
51
|
const L = Locale[lng];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './server';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _server.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _server = _interopRequireDefault(require("./server"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -46,7 +46,7 @@ class _default extends _server().Migration {
|
|
|
46
46
|
_iterator.f();
|
|
47
47
|
}
|
|
48
48
|
instance = yield systemSettings.findOne();
|
|
49
|
-
if (!((_instance = instance)
|
|
49
|
+
if (!((_instance = instance) !== null && _instance !== void 0 && (_instance$options = _instance.options) !== null && _instance$options !== void 0 && _instance$options.adminSchemaUid)) {
|
|
50
50
|
throw new Error('adminSchemaUid invalid');
|
|
51
51
|
}
|
|
52
52
|
_this.app.log.info('systemSettings.options', instance.toJSON());
|
|
@@ -11,6 +11,13 @@ function _server() {
|
|
|
11
11
|
};
|
|
12
12
|
return data;
|
|
13
13
|
}
|
|
14
|
+
function _utils() {
|
|
15
|
+
const data = require("@nocobase/utils");
|
|
16
|
+
_utils = function _utils() {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
14
21
|
function _fs() {
|
|
15
22
|
const data = _interopRequireDefault(require("fs"));
|
|
16
23
|
_fs = function _fs() {
|
|
@@ -32,13 +39,6 @@ function _koaStatic() {
|
|
|
32
39
|
};
|
|
33
40
|
return data;
|
|
34
41
|
}
|
|
35
|
-
function _isEmpty() {
|
|
36
|
-
const data = _interopRequireDefault(require("lodash/isEmpty"));
|
|
37
|
-
_isEmpty = function _isEmpty() {
|
|
38
|
-
return data;
|
|
39
|
-
};
|
|
40
|
-
return data;
|
|
41
|
-
}
|
|
42
42
|
function _path() {
|
|
43
43
|
const data = require("path");
|
|
44
44
|
_path = function _path() {
|
|
@@ -156,7 +156,7 @@ class ClientPlugin extends _server().Plugin {
|
|
|
156
156
|
const _ref2 = (options === null || options === void 0 ? void 0 : options.cliArgs) || [{}],
|
|
157
157
|
_ref3 = _slicedToArray(_ref2, 1),
|
|
158
158
|
opts = _ref3[0];
|
|
159
|
-
if (opts
|
|
159
|
+
if (opts !== null && opts !== void 0 && opts.importDemo) {
|
|
160
160
|
//
|
|
161
161
|
}
|
|
162
162
|
});
|
|
@@ -247,19 +247,19 @@ class ClientPlugin extends _server().Plugin {
|
|
|
247
247
|
getLang(ctx, next) {
|
|
248
248
|
return _asyncToGenerator(function* () {
|
|
249
249
|
const lang = yield getLang(ctx);
|
|
250
|
-
if ((
|
|
250
|
+
if (_utils().lodash.isEmpty(locales[lang])) {
|
|
251
251
|
locales[lang] = {};
|
|
252
252
|
}
|
|
253
|
-
if ((
|
|
253
|
+
if (_utils().lodash.isEmpty(locales[lang].resources)) {
|
|
254
254
|
locales[lang].resources = yield (0, _resource.getResourceLocale)(lang, ctx.db);
|
|
255
255
|
}
|
|
256
|
-
if ((
|
|
256
|
+
if (_utils().lodash.isEmpty(locales[lang].antd)) {
|
|
257
257
|
locales[lang].antd = (0, _antd.getAntdLocale)(lang);
|
|
258
258
|
}
|
|
259
|
-
if ((
|
|
259
|
+
if (_utils().lodash.isEmpty(locales[lang].cronstrue)) {
|
|
260
260
|
locales[lang].cronstrue = (0, _cronstrue.getCronstrueLocale)(lang);
|
|
261
261
|
}
|
|
262
|
-
if ((
|
|
262
|
+
if (_utils().lodash.isEmpty(locales[lang].cron)) {
|
|
263
263
|
locales[lang].cron = (0, _cron.getCronLocale)(lang);
|
|
264
264
|
}
|
|
265
265
|
ctx.body = _objectSpread({
|
package/package.json
CHANGED
|
@@ -4,14 +4,32 @@
|
|
|
4
4
|
"displayName.zh-CN": "客户端",
|
|
5
5
|
"description": "client",
|
|
6
6
|
"description.zh-CN": "客户端。",
|
|
7
|
-
"version": "0.
|
|
8
|
-
"main": "lib/index.js",
|
|
7
|
+
"version": "0.11.0-alpha.1",
|
|
8
|
+
"main": "./lib/server/index.js",
|
|
9
|
+
"files": [
|
|
10
|
+
"lib",
|
|
11
|
+
"src",
|
|
12
|
+
"README.md",
|
|
13
|
+
"README.zh-CN.md",
|
|
14
|
+
"CHANGELOG.md",
|
|
15
|
+
"server.js",
|
|
16
|
+
"server.d.ts",
|
|
17
|
+
"client.js",
|
|
18
|
+
"client.d.ts"
|
|
19
|
+
],
|
|
9
20
|
"license": "AGPL-3.0",
|
|
10
21
|
"dependencies": {
|
|
11
|
-
"
|
|
22
|
+
"antd": "^5.6.4",
|
|
23
|
+
"cronstrue": "^2.11.0",
|
|
24
|
+
"koa-send": "^5.0.1",
|
|
25
|
+
"koa-static": "^5.0.0"
|
|
12
26
|
},
|
|
13
27
|
"devDependencies": {
|
|
14
|
-
"@nocobase/
|
|
28
|
+
"@nocobase/client": "0.11.0-alpha.1",
|
|
29
|
+
"@nocobase/database": "0.11.0-alpha.1",
|
|
30
|
+
"@nocobase/server": "0.11.0-alpha.1",
|
|
31
|
+
"@nocobase/test": "0.11.0-alpha.1",
|
|
32
|
+
"@nocobase/utils": "0.11.0-alpha.1"
|
|
15
33
|
},
|
|
16
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "7581b6d3a3a54f09f06a9effb7e3e65328281b2b"
|
|
17
35
|
}
|
package/server.d.ts
ADDED
package/server.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./lib/server/index.js');
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './server';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const getCronLocale = (lang: string) => {
|
|
2
|
+
const packageName = '@nocobase/client';
|
|
3
|
+
let locale = null;
|
|
4
|
+
try {
|
|
5
|
+
const file = `${packageName}/src/locale`;
|
|
6
|
+
require.resolve(file);
|
|
7
|
+
locale = require(file).cron?.[lang];
|
|
8
|
+
} catch (error) {
|
|
9
|
+
try {
|
|
10
|
+
const file = `${packageName}/lib/locale`;
|
|
11
|
+
require.resolve(file);
|
|
12
|
+
locale = require(file).cron?.[lang];
|
|
13
|
+
} catch (error) {}
|
|
14
|
+
}
|
|
15
|
+
return locale;
|
|
16
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
const methods = [
|
|
2
|
+
'atX0SecondsPastTheMinuteGt20',
|
|
3
|
+
'atX0MinutesPastTheHourGt20',
|
|
4
|
+
'commaMonthX0ThroughMonthX1',
|
|
5
|
+
'commaYearX0ThroughYearX1',
|
|
6
|
+
'use24HourTimeFormatByDefault',
|
|
7
|
+
'anErrorOccuredWhenGeneratingTheExpressionD',
|
|
8
|
+
'everyMinute',
|
|
9
|
+
'everyHour',
|
|
10
|
+
'atSpace',
|
|
11
|
+
'everyMinuteBetweenX0AndX1',
|
|
12
|
+
'at',
|
|
13
|
+
'spaceAnd',
|
|
14
|
+
'everySecond',
|
|
15
|
+
'everyX0Seconds',
|
|
16
|
+
'secondsX0ThroughX1PastTheMinute',
|
|
17
|
+
'atX0SecondsPastTheMinute',
|
|
18
|
+
'everyX0Minutes',
|
|
19
|
+
'minutesX0ThroughX1PastTheHour',
|
|
20
|
+
'atX0MinutesPastTheHour',
|
|
21
|
+
'everyX0Hours',
|
|
22
|
+
'betweenX0AndX1',
|
|
23
|
+
'atX0',
|
|
24
|
+
'commaEveryDay',
|
|
25
|
+
'commaEveryX0DaysOfTheWeek',
|
|
26
|
+
'commaX0ThroughX1',
|
|
27
|
+
'commaAndX0ThroughX1',
|
|
28
|
+
'first',
|
|
29
|
+
'second',
|
|
30
|
+
'third',
|
|
31
|
+
'fourth',
|
|
32
|
+
'fifth',
|
|
33
|
+
'commaOnThe',
|
|
34
|
+
'spaceX0OfTheMonth',
|
|
35
|
+
'lastDay',
|
|
36
|
+
'commaOnTheLastX0OfTheMonth',
|
|
37
|
+
'commaOnlyOnX0',
|
|
38
|
+
'commaAndOnX0',
|
|
39
|
+
'commaEveryX0Months',
|
|
40
|
+
'commaOnlyInX0',
|
|
41
|
+
'commaOnTheLastDayOfTheMonth',
|
|
42
|
+
'commaOnTheLastWeekdayOfTheMonth',
|
|
43
|
+
'commaDaysBeforeTheLastDayOfTheMonth',
|
|
44
|
+
'firstWeekday',
|
|
45
|
+
'weekdayNearestDayX0',
|
|
46
|
+
'commaOnTheX0OfTheMonth',
|
|
47
|
+
'commaEveryX0Days',
|
|
48
|
+
'commaBetweenDayX0AndX1OfTheMonth',
|
|
49
|
+
'commaOnDayX0OfTheMonth',
|
|
50
|
+
'commaEveryHour',
|
|
51
|
+
'commaEveryX0Years',
|
|
52
|
+
'commaStartingX0',
|
|
53
|
+
'daysOfTheWeek',
|
|
54
|
+
'monthsOfTheYear',
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
const langs = {
|
|
58
|
+
af: 'af',
|
|
59
|
+
ar: 'ar',
|
|
60
|
+
be: 'be',
|
|
61
|
+
ca: 'ca',
|
|
62
|
+
cs: 'cs',
|
|
63
|
+
da: 'da',
|
|
64
|
+
de: 'de',
|
|
65
|
+
'en-US': 'en',
|
|
66
|
+
es: 'es',
|
|
67
|
+
fa: 'fa',
|
|
68
|
+
fi: 'fi',
|
|
69
|
+
fr: 'fr',
|
|
70
|
+
he: 'he',
|
|
71
|
+
hu: 'hu',
|
|
72
|
+
id: 'id',
|
|
73
|
+
it: 'it',
|
|
74
|
+
'ja-JP': 'ja',
|
|
75
|
+
ko: 'ko',
|
|
76
|
+
nb: 'nb',
|
|
77
|
+
nl: 'nl',
|
|
78
|
+
pl: 'pl',
|
|
79
|
+
pt_BR: 'pt_BR',
|
|
80
|
+
pt_PT: 'pt_PT',
|
|
81
|
+
ro: 'ro',
|
|
82
|
+
'ru-RU': 'ru',
|
|
83
|
+
sk: 'sk',
|
|
84
|
+
sl: 'sl',
|
|
85
|
+
sv: 'sv',
|
|
86
|
+
sw: 'sw',
|
|
87
|
+
'th-TH': 'th',
|
|
88
|
+
'tr-TR': 'tr',
|
|
89
|
+
uk: 'uk',
|
|
90
|
+
'zh-CN': 'zh_CN',
|
|
91
|
+
'zh-TW': 'zh_TW',
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const getCronstrueLocale = (lang) => {
|
|
95
|
+
const lng = langs[lang] || 'en';
|
|
96
|
+
const Locale = require(`cronstrue/locales/${lng}`);
|
|
97
|
+
let locale;
|
|
98
|
+
if (Locale?.default) {
|
|
99
|
+
locale = Locale.default.locales[lng];
|
|
100
|
+
} else {
|
|
101
|
+
const L = Locale[lng];
|
|
102
|
+
locale = new L();
|
|
103
|
+
}
|
|
104
|
+
const items = {};
|
|
105
|
+
for (const method of methods) {
|
|
106
|
+
try {
|
|
107
|
+
items[method] = locale[method]();
|
|
108
|
+
} catch (error) {}
|
|
109
|
+
}
|
|
110
|
+
return items;
|
|
111
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './server';
|