@nocobase/server 0.11.1-alpha.5 → 0.12.0-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.
@@ -4,11 +4,11 @@ export declare class Locale {
4
4
  app: Application;
5
5
  cache: Cache;
6
6
  defaultLang: string;
7
+ localeFn: Map<any, any>;
7
8
  constructor(app: Application);
8
9
  load(): void;
10
+ setLocaleFn(name: string, fn: (lang: string) => Promise<any>): void;
9
11
  get(lang: string): Promise<{
10
- antd: any;
11
- cronstrue: any;
12
12
  resources: any;
13
13
  }>;
14
14
  wrapCache(key: string, fn: () => any): Promise<any>;
@@ -19,15 +19,17 @@ function _utils() {
19
19
  return data;
20
20
  }
21
21
  var _pluginManager = require("../plugin-manager");
22
- var _antd = require("./antd");
23
- var _cronstrue = require("./cronstrue");
24
22
  var _resource = require("./resource");
25
23
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
26
24
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
27
25
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
28
26
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
29
27
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
30
- 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; } } }; }
28
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
29
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
30
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
31
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
32
+ 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(_e2) { throw _e2; }, 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(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
31
33
  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); }
32
34
  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; }
33
35
  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); } }
@@ -37,6 +39,7 @@ class Locale {
37
39
  this.app = void 0;
38
40
  this.cache = void 0;
39
41
  this.defaultLang = 'en-US';
42
+ this.localeFn = new Map();
40
43
  this.app = app;
41
44
  this.cache = (0, _cache().createCache)();
42
45
  this.app.on('afterLoad', () => this.load());
@@ -44,14 +47,35 @@ class Locale {
44
47
  load() {
45
48
  this.getCacheResources(this.defaultLang);
46
49
  }
50
+ setLocaleFn(name, fn) {
51
+ this.localeFn.set(name, fn);
52
+ }
47
53
  get(lang) {
48
54
  var _this = this;
49
55
  return _asyncToGenerator(function* () {
50
- return {
51
- antd: yield _this.wrapCache(`locale:antd:${lang}`, () => (0, _antd.getAntdLocale)(lang)),
52
- cronstrue: yield _this.wrapCache(`locale:cronstrue:${lang}`, () => (0, _cronstrue.getCronstrueLocale)(lang)),
56
+ const defaults = {
53
57
  resources: yield _this.getCacheResources(lang)
54
58
  };
59
+ var _iterator = _createForOfIteratorHelper(_this.localeFn),
60
+ _step;
61
+ try {
62
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
63
+ const _step$value = _slicedToArray(_step.value, 2),
64
+ name = _step$value[0],
65
+ fn = _step$value[1];
66
+ const result = yield _this.wrapCache(`locale:${name}:${lang}`, /*#__PURE__*/_asyncToGenerator(function* () {
67
+ return yield fn(lang);
68
+ }));
69
+ if (result) {
70
+ defaults[name] = result;
71
+ }
72
+ }
73
+ } catch (err) {
74
+ _iterator.e(err);
75
+ } finally {
76
+ _iterator.f();
77
+ }
78
+ return defaults;
55
79
  })();
56
80
  }
57
81
  wrapCache(key, fn) {
@@ -78,25 +102,27 @@ class Locale {
78
102
  getResources(lang) {
79
103
  const resources = {};
80
104
  const plugins = this.app.pm.getPlugins();
81
- var _iterator = _createForOfIteratorHelper(plugins.keys()),
82
- _step;
105
+ var _iterator2 = _createForOfIteratorHelper(plugins.keys()),
106
+ _step2;
83
107
  try {
84
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
85
- const name = _step.value;
108
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
109
+ const name = _step2.value;
86
110
  try {
87
111
  const packageName = _pluginManager.PluginManager.getPackageName(name);
88
112
  const res = (0, _resource.getResource)(packageName, lang);
89
113
  if (res) {
90
114
  resources[name] = _objectSpread({}, res);
91
115
  }
92
- } catch (err) {}
116
+ } catch (err) {
117
+ // empty
118
+ }
93
119
  }
94
120
  } catch (err) {
95
- _iterator.e(err);
121
+ _iterator2.e(err);
96
122
  } finally {
97
- _iterator.f();
123
+ _iterator2.f();
98
124
  }
99
- const res = (0, _resource.getResource)('@nocobase/client', lang);
125
+ const res = (0, _resource.getResource)('@nocobase/client', lang, false);
100
126
  if (res) {
101
127
  resources['client'] = _objectSpread(_objectSpread({}, resources['client'] || {}), res);
102
128
  }
@@ -1 +1 @@
1
- export declare const getResource: (packageName: string, lang: string) => any;
1
+ export declare const getResource: (packageName: string, lang: string, isPlugin?: boolean) => any;
@@ -4,6 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getResource = void 0;
7
+ function _utils() {
8
+ const data = require("@nocobase/utils");
9
+ _utils = function _utils() {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
7
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; } } }; }
8
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); }
9
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; }
@@ -23,17 +30,22 @@ const arr2obj = items => {
23
30
  }
24
31
  return obj;
25
32
  };
26
- const getResource = (packageName, lang) => {
33
+ const getResource = (packageName, lang, isPlugin = true) => {
27
34
  const resources = [];
28
- const prefixes = ['src', 'lib'];
35
+ const prefixes = [isPlugin ? 'dist' : 'lib'];
36
+ if (process.env.APP_ENV !== 'production') {
37
+ prefixes.unshift('src');
38
+ }
29
39
  for (var _i = 0, _prefixes = prefixes; _i < _prefixes.length; _i++) {
30
40
  const prefix = _prefixes[_i];
31
41
  try {
32
42
  const file = `${packageName}/${prefix}/locale/${lang}`;
33
43
  require.resolve(file);
34
- const resource = require(file).default;
44
+ const resource = (0, _utils().requireModule)(file);
35
45
  resources.push(resource);
36
- } catch (error) {}
46
+ } catch (error) {
47
+ // empty
48
+ }
37
49
  if (resources.length) {
38
50
  break;
39
51
  }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * get plugin client static file url
3
+ *
4
+ * @example
5
+ * @nocobase/plugin-acl, index.js => /api/plugins/client/@nocobase/plugin-acl/index.js
6
+ * my-plugin, README.md => /api/plugins/client/my-plugin/README.md
7
+ */
8
+ export declare const getPackageClientStaticUrl: (packageName: string, filePath: string) => string;
9
+ /**
10
+ * send plugin client static file to browser.
11
+ *
12
+ * such as:
13
+ * /api/plugins/client/@nocobase/plugin-xxx/index.js
14
+ * /api/plugins/client/xxx/README.md
15
+ */
16
+ export declare const clientStaticMiddleware: (ctx: any, next: any) => Promise<void>;
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getPackageClientStaticUrl = exports.clientStaticMiddleware = void 0;
7
+ function _fs() {
8
+ const data = _interopRequireDefault(require("fs"));
9
+ _fs = function _fs() {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _koaSend() {
15
+ const data = _interopRequireDefault(require("koa-send"));
16
+ _koaSend = function _koaSend() {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _path() {
22
+ const data = _interopRequireDefault(require("path"));
23
+ _path = function _path() {
24
+ return data;
25
+ };
26
+ return data;
27
+ }
28
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
+ 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); } }
30
+ 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); }); }; }
31
+ const PREFIX = '/api/plugins/client/';
32
+ const cwd = process.cwd();
33
+ const NODE_MODULES = _path().default.join(cwd, 'node_modules');
34
+ /**
35
+ * get plugin client static file url
36
+ *
37
+ * @example
38
+ * @nocobase/plugin-acl, index.js => /api/plugins/client/@nocobase/plugin-acl/index.js
39
+ * my-plugin, README.md => /api/plugins/client/my-plugin/README.md
40
+ */
41
+ const getPackageClientStaticUrl = (packageName, filePath) => {
42
+ return `${PREFIX}${packageName}/${filePath}`;
43
+ };
44
+ exports.getPackageClientStaticUrl = getPackageClientStaticUrl;
45
+ const isMatchClientStaticUrl = url => {
46
+ return url.startsWith(PREFIX);
47
+ };
48
+ /**
49
+ * get package name from url
50
+ *
51
+ * @example
52
+ * /api/plugins/client/@nocobase/plugin-acl/index.js => @nocobase/plugin-acl
53
+ * /api/plugins/client/my-plugin/README.md => my-plugin
54
+ */
55
+ const getPackageName = url => {
56
+ const urlArr = url.split('/');
57
+ return urlArr[4].startsWith('@') ? `${urlArr[4]}/${urlArr[5]}` : urlArr[4];
58
+ };
59
+ /**
60
+ * get plugin client static file real path
61
+ *
62
+ * @example
63
+ * /api/plugins/client/@nocobase/plugin-acl/index.js => /node_modules/@nocobase/plugin-acl/dist/client/index.js
64
+ * /api/plugins/client/my-plugin/README.md => /node_modules/my-plugin/dist/client/README.md
65
+ */
66
+ const getRealPath = (packageName, url) => {
67
+ const ext = _path().default.extname(url);
68
+ const filePath = url.replace(`${PREFIX}${packageName}/`, '');
69
+ if (ext.toLowerCase() === '.md') {
70
+ return _path().default.join(NODE_MODULES, packageName, filePath);
71
+ } else {
72
+ return _path().default.join(NODE_MODULES, packageName, 'dist', 'client', filePath);
73
+ }
74
+ };
75
+ /**
76
+ * send plugin client static file to browser.
77
+ *
78
+ * such as:
79
+ * /api/plugins/client/@nocobase/plugin-xxx/index.js
80
+ * /api/plugins/client/xxx/README.md
81
+ */
82
+ const clientStaticMiddleware = /*#__PURE__*/function () {
83
+ var _ref = _asyncToGenerator(function* (ctx, next) {
84
+ if (isMatchClientStaticUrl(ctx.path)) {
85
+ // TODO: check packageName in plugins
86
+ const packageName = getPackageName(ctx.path);
87
+ const realPath = getRealPath(packageName, ctx.path);
88
+ // get file stats
89
+ const stats = yield _fs().default.promises.stat(realPath);
90
+ const ifModifiedSince = ctx.get('If-Modified-Since');
91
+ const lastModified = stats.mtime.toUTCString();
92
+ // check cache headers
93
+ if (ifModifiedSince === lastModified) {
94
+ ctx.status = 304;
95
+ return;
96
+ }
97
+ // `send` only accept relative path
98
+ const relativePath = _path().default.relative(cwd, realPath);
99
+ yield (0, _koaSend().default)(ctx, relativePath, {
100
+ setHeaders: res => {
101
+ res.setHeader('Last-Modified', lastModified);
102
+ }
103
+ });
104
+ }
105
+ yield next();
106
+ });
107
+ return function clientStaticMiddleware(_x, _x2) {
108
+ return _ref.apply(this, arguments);
109
+ };
110
+ }();
111
+ exports.clientStaticMiddleware = clientStaticMiddleware;
@@ -1 +1,2 @@
1
+ export * from './clientStaticMiddleware';
1
2
  export * from './plugin-manager';
@@ -3,6 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ var _clientStaticMiddleware = require("./clientStaticMiddleware");
7
+ Object.keys(_clientStaticMiddleware).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _clientStaticMiddleware[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function get() {
13
+ return _clientStaticMiddleware[key];
14
+ }
15
+ });
16
+ });
6
17
  var _pluginManager = require("./plugin-manager");
7
18
  Object.keys(_pluginManager).forEach(function (key) {
8
19
  if (key === "default" || key === "__esModule") return;
@@ -31,7 +31,6 @@ export declare class PluginManager {
31
31
  create(name: string | string[]): Promise<void>;
32
32
  clone(): PluginManager;
33
33
  addStatic(plugin?: any, options?: any): any;
34
- generateClientFile(plugin: string, packageName: string): Promise<void>;
35
34
  add(plugin: any, options?: any, transaction?: any): Promise<any>;
36
35
  load(options?: any): Promise<void>;
37
36
  install(options?: InstallOptions): Promise<void>;
@@ -46,6 +46,7 @@ function _xpipe() {
46
46
  };
47
47
  return data;
48
48
  }
49
+ var _clientStaticMiddleware = require("./clientStaticMiddleware");
49
50
  var _collection = _interopRequireDefault(require("./options/collection"));
50
51
  var _resource = _interopRequireDefault(require("./options/resource"));
51
52
  var _pluginManagerRepository = require("./plugin-manager-repository");
@@ -87,6 +88,7 @@ class PluginManager {
87
88
  this.repository = this.collection.repository;
88
89
  this.repository.setPluginManager(this);
89
90
  this.app.resourcer.define(_resource.default);
91
+ this.app.use(_clientStaticMiddleware.clientStaticMiddleware);
90
92
  this.app.resourcer.use( /*#__PURE__*/function () {
91
93
  var _ref = _asyncToGenerator(function* (ctx, next) {
92
94
  yield next();
@@ -295,20 +297,6 @@ class PluginManager {
295
297
  this.plugins.set(pluginName, instance);
296
298
  return instance;
297
299
  }
298
- generateClientFile(plugin, packageName) {
299
- return _asyncToGenerator(function* () {
300
- const file = (0, _path().resolve)(process.cwd(), 'packages', process.env.APP_PACKAGE_ROOT || 'app', 'client/src/plugins', `${plugin}.ts`);
301
- if (!_fs().default.existsSync(file)) {
302
- try {
303
- require.resolve(`${packageName}/client`);
304
- yield _fs().default.promises.writeFile(file, `export { default } from '${packageName}/client';`);
305
- const _require3 = require('@nocobase/cli/src/util'),
306
- run = _require3.run;
307
- yield run('yarn', ['nocobase', 'postinstall']);
308
- } catch (error) {}
309
- }
310
- })();
311
- }
312
300
  add(plugin, options = {}, transaction) {
313
301
  var _this4 = this;
314
302
  return _asyncToGenerator(function* () {
@@ -336,7 +324,6 @@ class PluginManager {
336
324
  }
337
325
  }
338
326
  const packageName = yield PluginManager.findPackage(plugin);
339
- yield _this4.generateClientFile(plugin, packageName);
340
327
  const instance = _this4.addStatic(plugin, _objectSpread(_objectSpread({}, options), {}, {
341
328
  async: true
342
329
  }));
package/package.json CHANGED
@@ -1,34 +1,45 @@
1
1
  {
2
2
  "name": "@nocobase/server",
3
- "version": "0.11.1-alpha.5",
3
+ "version": "0.12.0-alpha.2",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "license": "Apache-2.0",
7
7
  "dependencies": {
8
+ "@formily/json-schema": "2.2.27",
8
9
  "@hapi/topo": "^6.0.0",
9
10
  "@koa/cors": "^3.1.0",
11
+ "@koa/multer": "^3.0.2",
10
12
  "@koa/router": "^9.4.0",
11
- "@nocobase/acl": "0.11.1-alpha.5",
12
- "@nocobase/actions": "0.11.1-alpha.5",
13
- "@nocobase/auth": "0.11.1-alpha.5",
14
- "@nocobase/database": "0.11.1-alpha.5",
15
- "@nocobase/logger": "0.11.1-alpha.5",
16
- "@nocobase/resourcer": "0.11.1-alpha.5",
17
- "@nocobase/utils": "0.11.1-alpha.5",
13
+ "@nocobase/acl": "0.12.0-alpha.2",
14
+ "@nocobase/actions": "0.12.0-alpha.2",
15
+ "@nocobase/auth": "0.12.0-alpha.2",
16
+ "@nocobase/cache": "0.12.0-alpha.2",
17
+ "@nocobase/database": "0.12.0-alpha.2",
18
+ "@nocobase/evaluators": "0.12.0-alpha.2",
19
+ "@nocobase/logger": "0.12.0-alpha.2",
20
+ "@nocobase/resourcer": "0.12.0-alpha.2",
21
+ "@nocobase/sdk": "0.12.0-alpha.2",
22
+ "@nocobase/utils": "0.12.0-alpha.2",
23
+ "@types/koa-send": "^4.1.3",
24
+ "@types/multer": "^1.4.5",
25
+ "axios": "^0.26.1",
18
26
  "chalk": "^4.1.1",
19
27
  "commander": "^9.2.0",
28
+ "cronstrue": "^2.11.0",
20
29
  "dayjs": "^1.11.8",
21
30
  "find-package-json": "^1.2.0",
22
31
  "i18next": "^22.4.9",
23
32
  "koa": "^2.13.4",
24
33
  "koa-bodyparser": "^4.3.0",
34
+ "koa-send": "^5.0.1",
25
35
  "koa-static": "^5.0.0",
26
36
  "lodash": "^4.17.21",
37
+ "multer": "^1.4.2",
27
38
  "semver": "^7.3.7",
28
39
  "xpipe": "^1.0.5"
29
40
  },
30
41
  "devDependencies": {
31
42
  "@types/semver": "^7.3.9"
32
43
  },
33
- "gitHead": "1dcfd15a7d95a40b0a2f60e1de19ec574066fb20"
44
+ "gitHead": "a95e9e2666f0318c955113a4735bc005a2c9a767"
34
45
  }
@@ -1 +0,0 @@
1
- export declare const getAntdLocale: (lang: any) => any;
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getAntdLocale = void 0;
7
- const getAntdLocale = lang => {
8
- const lng = lang.replace('-', '_');
9
- try {
10
- require.resolve(`antd/lib/locale/${lng}`);
11
- return require(`antd/lib/locale/${lng}`).default;
12
- } catch (error) {
13
- return require(`antd/lib/locale/en_US`).default;
14
- }
15
- };
16
- exports.getAntdLocale = getAntdLocale;
@@ -1 +0,0 @@
1
- export declare const getCronLocale: (lang: string) => any;
@@ -1,25 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getCronLocale = void 0;
7
- const getCronLocale = lang => {
8
- const packageName = '@nocobase/client';
9
- let locale = null;
10
- try {
11
- var _require$cron;
12
- const file = `${packageName}/src/locale`;
13
- require.resolve(file);
14
- locale = (_require$cron = require(file).cron) === null || _require$cron === void 0 ? void 0 : _require$cron[lang];
15
- } catch (error) {
16
- try {
17
- var _require$cron2;
18
- const file = `${packageName}/lib/locale`;
19
- require.resolve(file);
20
- locale = (_require$cron2 = require(file).cron) === null || _require$cron2 === void 0 ? void 0 : _require$cron2[lang];
21
- } catch (error) {}
22
- }
23
- return locale;
24
- };
25
- exports.getCronLocale = getCronLocale;
@@ -1 +0,0 @@
1
- export declare const getCronstrueLocale: (lang: any) => {};
@@ -1,63 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getCronstrueLocale = void 0;
7
- const methods = ['atX0SecondsPastTheMinuteGt20', 'atX0MinutesPastTheHourGt20', 'commaMonthX0ThroughMonthX1', 'commaYearX0ThroughYearX1', 'use24HourTimeFormatByDefault', 'anErrorOccuredWhenGeneratingTheExpressionD', 'everyMinute', 'everyHour', 'atSpace', 'everyMinuteBetweenX0AndX1', 'at', 'spaceAnd', 'everySecond', 'everyX0Seconds', 'secondsX0ThroughX1PastTheMinute', 'atX0SecondsPastTheMinute', 'everyX0Minutes', 'minutesX0ThroughX1PastTheHour', 'atX0MinutesPastTheHour', 'everyX0Hours', 'betweenX0AndX1', 'atX0', 'commaEveryDay', 'commaEveryX0DaysOfTheWeek', 'commaX0ThroughX1', 'commaAndX0ThroughX1', 'first', 'second', 'third', 'fourth', 'fifth', 'commaOnThe', 'spaceX0OfTheMonth', 'lastDay', 'commaOnTheLastX0OfTheMonth', 'commaOnlyOnX0', 'commaAndOnX0', 'commaEveryX0Months', 'commaOnlyInX0', 'commaOnTheLastDayOfTheMonth', 'commaOnTheLastWeekdayOfTheMonth', 'commaDaysBeforeTheLastDayOfTheMonth', 'firstWeekday', 'weekdayNearestDayX0', 'commaOnTheX0OfTheMonth', 'commaEveryX0Days', 'commaBetweenDayX0AndX1OfTheMonth', 'commaOnDayX0OfTheMonth', 'commaEveryHour', 'commaEveryX0Years', 'commaStartingX0', 'daysOfTheWeek', 'monthsOfTheYear'];
8
- const langs = {
9
- af: 'af',
10
- ar: 'ar',
11
- be: 'be',
12
- ca: 'ca',
13
- cs: 'cs',
14
- da: 'da',
15
- de: 'de',
16
- 'en-US': 'en',
17
- es: 'es',
18
- fa: 'fa',
19
- fi: 'fi',
20
- fr: 'fr',
21
- he: 'he',
22
- hu: 'hu',
23
- id: 'id',
24
- it: 'it',
25
- 'ja-JP': 'ja',
26
- ko: 'ko',
27
- nb: 'nb',
28
- nl: 'nl',
29
- pl: 'pl',
30
- pt_BR: 'pt_BR',
31
- pt_PT: 'pt_PT',
32
- ro: 'ro',
33
- 'ru-RU': 'ru',
34
- sk: 'sk',
35
- sl: 'sl',
36
- sv: 'sv',
37
- sw: 'sw',
38
- 'th-TH': 'th',
39
- 'tr-TR': 'tr',
40
- uk: 'uk',
41
- 'zh-CN': 'zh_CN',
42
- 'zh-TW': 'zh_TW'
43
- };
44
- const getCronstrueLocale = lang => {
45
- const lng = langs[lang] || 'en';
46
- const Locale = require(`cronstrue/locales/${lng}`);
47
- let locale;
48
- if (Locale !== null && Locale !== void 0 && Locale.default) {
49
- locale = Locale.default.locales[lng];
50
- } else {
51
- const L = Locale[lng];
52
- locale = new L();
53
- }
54
- const items = {};
55
- for (var _i = 0, _methods = methods; _i < _methods.length; _i++) {
56
- const method = _methods[_i];
57
- try {
58
- items[method] = locale[method]();
59
- } catch (error) {}
60
- }
61
- return items;
62
- };
63
- exports.getCronstrueLocale = getCronstrueLocale;