@nocobase/server 1.2.13-alpha → 1.3.0-alpha.20240710084543
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/package.json +14 -14
- package/lib/acl/available-action.d.ts +0 -13
- package/lib/acl/available-action.js +0 -71
- package/lib/acl/index.d.ts +0 -10
- package/lib/acl/index.js +0 -46
- package/lib/app-command.d.ts +0 -20
- package/lib/app-command.js +0 -82
- package/lib/app-supervisor.d.ts +0 -69
- package/lib/app-supervisor.js +0 -302
- package/lib/application.d.ts +0 -345
- package/lib/application.js +0 -876
- package/lib/cache/index.d.ts +0 -11
- package/lib/cache/index.js +0 -44
- package/lib/commands/console.d.ts +0 -11
- package/lib/commands/console.js +0 -48
- package/lib/commands/create-migration.d.ts +0 -11
- package/lib/commands/create-migration.js +0 -79
- package/lib/commands/db-auth.d.ts +0 -11
- package/lib/commands/db-auth.js +0 -38
- package/lib/commands/db-clean.d.ts +0 -11
- package/lib/commands/db-clean.js +0 -41
- package/lib/commands/db-sync.d.ts +0 -11
- package/lib/commands/db-sync.js +0 -50
- package/lib/commands/destroy.d.ts +0 -11
- package/lib/commands/destroy.js +0 -40
- package/lib/commands/index.d.ts +0 -10
- package/lib/commands/index.js +0 -82
- package/lib/commands/install.d.ts +0 -11
- package/lib/commands/install.js +0 -43
- package/lib/commands/migrator.d.ts +0 -11
- package/lib/commands/migrator.js +0 -41
- package/lib/commands/pm.d.ts +0 -11
- package/lib/commands/pm.js +0 -98
- package/lib/commands/refresh.d.ts +0 -11
- package/lib/commands/refresh.js +0 -41
- package/lib/commands/restart.d.ts +0 -11
- package/lib/commands/restart.js +0 -45
- package/lib/commands/start.d.ts +0 -11
- package/lib/commands/start.js +0 -85
- package/lib/commands/stop.d.ts +0 -11
- package/lib/commands/stop.js +0 -44
- package/lib/commands/upgrade.d.ts +0 -14
- package/lib/commands/upgrade.js +0 -39
- package/lib/cron/cron-job-manager.d.ts +0 -22
- package/lib/cron/cron-job-manager.js +0 -82
- package/lib/errors/application-not-install.d.ts +0 -12
- package/lib/errors/application-not-install.js +0 -45
- package/lib/errors/handler.d.ts +0 -11
- package/lib/errors/handler.js +0 -50
- package/lib/errors/plugin-command-error.d.ts +0 -10
- package/lib/errors/plugin-command-error.js +0 -40
- package/lib/errors/plugin-not-exist.d.ts +0 -10
- package/lib/errors/plugin-not-exist.js +0 -40
- package/lib/gateway/errors.d.ts +0 -30
- package/lib/gateway/errors.js +0 -154
- package/lib/gateway/index.d.ts +0 -79
- package/lib/gateway/index.js +0 -393
- package/lib/gateway/ipc-socket-client.d.ts +0 -27
- package/lib/gateway/ipc-socket-client.js +0 -110
- package/lib/gateway/ipc-socket-server.d.ts +0 -21
- package/lib/gateway/ipc-socket-server.js +0 -150
- package/lib/gateway/ws-server.d.ts +0 -36
- package/lib/gateway/ws-server.js +0 -196
- package/lib/helper.d.ts +0 -18
- package/lib/helper.js +0 -193
- package/lib/helpers/application-version.d.ts +0 -18
- package/lib/helpers/application-version.js +0 -88
- package/lib/index.d.ts +0 -17
- package/lib/index.js +0 -64
- package/lib/locale/index.d.ts +0 -9
- package/lib/locale/index.js +0 -30
- package/lib/locale/locale.d.ts +0 -38
- package/lib/locale/locale.js +0 -174
- package/lib/locale/resource.d.ts +0 -9
- package/lib/locale/resource.js +0 -87
- package/lib/main-data-source.d.ts +0 -12
- package/lib/main-data-source.js +0 -57
- package/lib/middlewares/data-template.d.ts +0 -10
- package/lib/middlewares/data-template.js +0 -146
- package/lib/middlewares/data-wrapping.d.ts +0 -11
- package/lib/middlewares/data-wrapping.js +0 -100
- package/lib/middlewares/i18n.d.ts +0 -9
- package/lib/middlewares/i18n.js +0 -53
- package/lib/middlewares/index.d.ts +0 -10
- package/lib/middlewares/index.js +0 -39
- package/lib/middlewares/parse-variables.d.ts +0 -9
- package/lib/middlewares/parse-variables.js +0 -95
- package/lib/middlewares/validate-filter-params.d.ts +0 -9
- package/lib/middlewares/validate-filter-params.js +0 -42
- package/lib/migration.d.ts +0 -20
- package/lib/migration.js +0 -54
- package/lib/migrations/20230912193824-package-name-unique.d.ts +0 -14
- package/lib/migrations/20230912193824-package-name-unique.js +0 -59
- package/lib/migrations/20230912294620-update-pkg.d.ts +0 -14
- package/lib/migrations/20230912294620-update-pkg.js +0 -65
- package/lib/migrations/20240106082756-update-plugins.d.ts +0 -14
- package/lib/migrations/20240106082756-update-plugins.js +0 -51
- package/lib/migrations/20240428235620-rename-plugins.d.ts +0 -14
- package/lib/migrations/20240428235620-rename-plugins.js +0 -49
- package/lib/plugin-manager/clientStaticUtils.d.ts +0 -31
- package/lib/plugin-manager/clientStaticUtils.js +0 -129
- package/lib/plugin-manager/constants.d.ts +0 -15
- package/lib/plugin-manager/constants.js +0 -135
- package/lib/plugin-manager/deps.d.ts +0 -10
- package/lib/plugin-manager/deps.js +0 -83
- package/lib/plugin-manager/index.d.ts +0 -10
- package/lib/plugin-manager/index.js +0 -32
- package/lib/plugin-manager/middleware.d.ts +0 -10
- package/lib/plugin-manager/middleware.js +0 -45
- package/lib/plugin-manager/options/collection.d.ts +0 -10
- package/lib/plugin-manager/options/collection.js +0 -47
- package/lib/plugin-manager/options/resource.d.ts +0 -23
- package/lib/plugin-manager/options/resource.js +0 -186
- package/lib/plugin-manager/plugin-manager-repository.d.ts +0 -36
- package/lib/plugin-manager/plugin-manager-repository.js +0 -158
- package/lib/plugin-manager/plugin-manager.d.ts +0 -206
- package/lib/plugin-manager/plugin-manager.js +0 -1100
- package/lib/plugin-manager/types.d.ts +0 -23
- package/lib/plugin-manager/types.js +0 -24
- package/lib/plugin-manager/utils.d.ts +0 -115
- package/lib/plugin-manager/utils.js +0 -568
- package/lib/plugin.d.ts +0 -99
- package/lib/plugin.js +0 -228
- package/lib/swagger/index.json +0 -1569
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __create = Object.create;
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
17
|
-
var __export = (target, all) => {
|
|
18
|
-
for (var name in all)
|
|
19
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
-
};
|
|
21
|
-
var __copyProps = (to, from, except, desc) => {
|
|
22
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
-
for (let key of __getOwnPropNames(from))
|
|
24
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
-
}
|
|
27
|
-
return to;
|
|
28
|
-
};
|
|
29
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
-
mod
|
|
36
|
-
));
|
|
37
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
-
var application_version_exports = {};
|
|
39
|
-
__export(application_version_exports, {
|
|
40
|
-
ApplicationVersion: () => ApplicationVersion
|
|
41
|
-
});
|
|
42
|
-
module.exports = __toCommonJS(application_version_exports);
|
|
43
|
-
var import_semver = __toESM(require("semver"));
|
|
44
|
-
const _ApplicationVersion = class _ApplicationVersion {
|
|
45
|
-
app;
|
|
46
|
-
collection;
|
|
47
|
-
constructor(app) {
|
|
48
|
-
this.app = app;
|
|
49
|
-
app.db.collection({
|
|
50
|
-
origin: "@nocobase/server",
|
|
51
|
-
name: "applicationVersion",
|
|
52
|
-
dataType: "meta",
|
|
53
|
-
timestamps: false,
|
|
54
|
-
dumpRules: "required",
|
|
55
|
-
fields: [{ name: "value", type: "string" }]
|
|
56
|
-
});
|
|
57
|
-
this.collection = this.app.db.getCollection("applicationVersion");
|
|
58
|
-
}
|
|
59
|
-
async get() {
|
|
60
|
-
const model = await this.collection.model.findOne();
|
|
61
|
-
if (!model) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
return model.get("value");
|
|
65
|
-
}
|
|
66
|
-
async update(version) {
|
|
67
|
-
await this.collection.model.destroy({
|
|
68
|
-
truncate: true
|
|
69
|
-
});
|
|
70
|
-
await this.collection.model.create({
|
|
71
|
-
value: version || this.app.getVersion()
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
async satisfies(range) {
|
|
75
|
-
const model = await this.collection.model.findOne();
|
|
76
|
-
const version = model == null ? void 0 : model.value;
|
|
77
|
-
if (!version) {
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
return import_semver.default.satisfies(version, range, { includePrerelease: true });
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
__name(_ApplicationVersion, "ApplicationVersion");
|
|
84
|
-
let ApplicationVersion = _ApplicationVersion;
|
|
85
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
86
|
-
0 && (module.exports = {
|
|
87
|
-
ApplicationVersion
|
|
88
|
-
});
|
package/lib/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
export * from './application';
|
|
10
|
-
export { Application as default } from './application';
|
|
11
|
-
export * as middlewares from './middlewares';
|
|
12
|
-
export * from './migration';
|
|
13
|
-
export * from './plugin';
|
|
14
|
-
export * from './plugin-manager';
|
|
15
|
-
export * from './gateway';
|
|
16
|
-
export * from './app-supervisor';
|
|
17
|
-
export declare const OFFICIAL_PLUGIN_PREFIX = "@nocobase/plugin-";
|
package/lib/index.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __create = Object.create;
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __export = (target, all) => {
|
|
17
|
-
for (var name in all)
|
|
18
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
-
};
|
|
20
|
-
var __copyProps = (to, from, except, desc) => {
|
|
21
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
-
for (let key of __getOwnPropNames(from))
|
|
23
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
-
}
|
|
26
|
-
return to;
|
|
27
|
-
};
|
|
28
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
29
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
-
mod
|
|
36
|
-
));
|
|
37
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
-
var src_exports = {};
|
|
39
|
-
__export(src_exports, {
|
|
40
|
-
OFFICIAL_PLUGIN_PREFIX: () => OFFICIAL_PLUGIN_PREFIX,
|
|
41
|
-
default: () => import_application.Application,
|
|
42
|
-
middlewares: () => middlewares
|
|
43
|
-
});
|
|
44
|
-
module.exports = __toCommonJS(src_exports);
|
|
45
|
-
__reExport(src_exports, require("./application"), module.exports);
|
|
46
|
-
var import_application = require("./application");
|
|
47
|
-
var middlewares = __toESM(require("./middlewares"));
|
|
48
|
-
__reExport(src_exports, require("./migration"), module.exports);
|
|
49
|
-
__reExport(src_exports, require("./plugin"), module.exports);
|
|
50
|
-
__reExport(src_exports, require("./plugin-manager"), module.exports);
|
|
51
|
-
__reExport(src_exports, require("./gateway"), module.exports);
|
|
52
|
-
__reExport(src_exports, require("./app-supervisor"), module.exports);
|
|
53
|
-
const OFFICIAL_PLUGIN_PREFIX = "@nocobase/plugin-";
|
|
54
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
-
0 && (module.exports = {
|
|
56
|
-
OFFICIAL_PLUGIN_PREFIX,
|
|
57
|
-
middlewares,
|
|
58
|
-
...require("./application"),
|
|
59
|
-
...require("./migration"),
|
|
60
|
-
...require("./plugin"),
|
|
61
|
-
...require("./plugin-manager"),
|
|
62
|
-
...require("./gateway"),
|
|
63
|
-
...require("./app-supervisor")
|
|
64
|
-
});
|
package/lib/locale/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
export * from './locale';
|
package/lib/locale/index.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __copyProps = (to, from, except, desc) => {
|
|
15
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
-
for (let key of __getOwnPropNames(from))
|
|
17
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
23
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
-
var locale_exports = {};
|
|
25
|
-
module.exports = __toCommonJS(locale_exports);
|
|
26
|
-
__reExport(locale_exports, require("./locale"), module.exports);
|
|
27
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
-
0 && (module.exports = {
|
|
29
|
-
...require("./locale")
|
|
30
|
-
});
|
package/lib/locale/locale.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import { Cache } from '@nocobase/cache';
|
|
10
|
-
import { Registry } from '@nocobase/utils';
|
|
11
|
-
import Application from '../application';
|
|
12
|
-
export interface ResourceStorer {
|
|
13
|
-
getResources(lang: string): Promise<{
|
|
14
|
-
[ns: string]: Record<string, string>;
|
|
15
|
-
}>;
|
|
16
|
-
}
|
|
17
|
-
export declare class Locale {
|
|
18
|
-
app: Application;
|
|
19
|
-
cache: Cache;
|
|
20
|
-
defaultLang: string;
|
|
21
|
-
localeFn: Map<any, any>;
|
|
22
|
-
resourceCached: Map<any, any>;
|
|
23
|
-
i18nInstances: Map<any, any>;
|
|
24
|
-
resourceStorers: Registry<ResourceStorer>;
|
|
25
|
-
constructor(app: Application);
|
|
26
|
-
load(): Promise<void>;
|
|
27
|
-
reload(): Promise<void>;
|
|
28
|
-
setLocaleFn(name: string, fn: (lang: string) => Promise<any>): void;
|
|
29
|
-
registerResourceStorer(name: string, storer: ResourceStorer): void;
|
|
30
|
-
get(lang: string): Promise<{
|
|
31
|
-
resources: any;
|
|
32
|
-
}>;
|
|
33
|
-
wrapCache(key: string, fn: () => any): Promise<any>;
|
|
34
|
-
loadResourcesByLang(lang: string): Promise<void>;
|
|
35
|
-
getCacheResources(lang: string): Promise<any>;
|
|
36
|
-
getResources(lang: string): Promise<{}>;
|
|
37
|
-
getI18nInstance(lang: string): Promise<any>;
|
|
38
|
-
}
|
package/lib/locale/locale.js
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __create = Object.create;
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
17
|
-
var __export = (target, all) => {
|
|
18
|
-
for (var name in all)
|
|
19
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
-
};
|
|
21
|
-
var __copyProps = (to, from, except, desc) => {
|
|
22
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
-
for (let key of __getOwnPropNames(from))
|
|
24
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
-
}
|
|
27
|
-
return to;
|
|
28
|
-
};
|
|
29
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
-
mod
|
|
36
|
-
));
|
|
37
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
-
var locale_exports = {};
|
|
39
|
-
__export(locale_exports, {
|
|
40
|
-
Locale: () => Locale
|
|
41
|
-
});
|
|
42
|
-
module.exports = __toCommonJS(locale_exports);
|
|
43
|
-
var import_utils = require("@nocobase/utils");
|
|
44
|
-
var import_resource = require("./resource");
|
|
45
|
-
var import__ = require("..");
|
|
46
|
-
var import_deepmerge = __toESM(require("deepmerge"));
|
|
47
|
-
const _Locale = class _Locale {
|
|
48
|
-
app;
|
|
49
|
-
cache;
|
|
50
|
-
defaultLang = "en-US";
|
|
51
|
-
localeFn = /* @__PURE__ */ new Map();
|
|
52
|
-
resourceCached = /* @__PURE__ */ new Map();
|
|
53
|
-
i18nInstances = /* @__PURE__ */ new Map();
|
|
54
|
-
resourceStorers = new import_utils.Registry();
|
|
55
|
-
constructor(app) {
|
|
56
|
-
this.app = app;
|
|
57
|
-
this.app.on("afterLoad", async () => {
|
|
58
|
-
this.app.log.debug("loading locale resource...", { submodule: "locale", method: "onAfterLoad" });
|
|
59
|
-
this.app.setMaintainingMessage("load locale resource");
|
|
60
|
-
await this.load();
|
|
61
|
-
this.app.log.debug("locale resource loaded", { submodule: "locale", method: "onAfterLoad" });
|
|
62
|
-
this.app.setMaintainingMessage("locale resource loaded");
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
async load() {
|
|
66
|
-
this.cache = await this.app.cacheManager.createCache({
|
|
67
|
-
name: "locale",
|
|
68
|
-
prefix: "locale",
|
|
69
|
-
store: "memory"
|
|
70
|
-
});
|
|
71
|
-
await this.get(this.defaultLang);
|
|
72
|
-
}
|
|
73
|
-
async reload() {
|
|
74
|
-
await this.cache.reset();
|
|
75
|
-
}
|
|
76
|
-
setLocaleFn(name, fn) {
|
|
77
|
-
this.localeFn.set(name, fn);
|
|
78
|
-
}
|
|
79
|
-
registerResourceStorer(name, storer) {
|
|
80
|
-
this.resourceStorers.register(name, storer);
|
|
81
|
-
}
|
|
82
|
-
async get(lang) {
|
|
83
|
-
const defaults = {
|
|
84
|
-
resources: await this.getCacheResources(lang)
|
|
85
|
-
};
|
|
86
|
-
for (const [name, fn] of this.localeFn) {
|
|
87
|
-
const result = await this.wrapCache(`${name}:${lang}`, async () => await fn(lang));
|
|
88
|
-
if (result) {
|
|
89
|
-
defaults[name] = result;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return defaults;
|
|
93
|
-
}
|
|
94
|
-
async wrapCache(key, fn) {
|
|
95
|
-
return await this.cache.wrapWithCondition(key, fn, {
|
|
96
|
-
isCacheable: (val) => !import_utils.lodash.isEmpty(val)
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
async loadResourcesByLang(lang) {
|
|
100
|
-
if (!this.cache) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
if (!this.resourceCached.has(lang)) {
|
|
104
|
-
await this.getCacheResources(lang);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
async getCacheResources(lang) {
|
|
108
|
-
this.resourceCached.set(lang, true);
|
|
109
|
-
if (process.env.APP_ENV !== "production") {
|
|
110
|
-
await this.reload();
|
|
111
|
-
}
|
|
112
|
-
return await this.wrapCache(`resources:${lang}`, () => this.getResources(lang));
|
|
113
|
-
}
|
|
114
|
-
async getResources(lang) {
|
|
115
|
-
var _a;
|
|
116
|
-
const resources = {};
|
|
117
|
-
const names = this.app.pm.getPlugins().keys();
|
|
118
|
-
for (const name of names) {
|
|
119
|
-
try {
|
|
120
|
-
const p = this.app.pm.get(name);
|
|
121
|
-
if (!p) {
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
const packageName = (_a = p.options) == null ? void 0 : _a.packageName;
|
|
125
|
-
if (!packageName) {
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
const res = (0, import_resource.getResource)(packageName, lang);
|
|
129
|
-
if (res) {
|
|
130
|
-
resources[packageName] = { ...res };
|
|
131
|
-
if (packageName.includes(import__.OFFICIAL_PLUGIN_PREFIX)) {
|
|
132
|
-
resources[packageName.substring(import__.OFFICIAL_PLUGIN_PREFIX.length)] = { ...res };
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
} catch (err) {
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
const storers = this.resourceStorers.getValues();
|
|
139
|
-
for (const storer of storers) {
|
|
140
|
-
const custom = await storer.getResources(lang);
|
|
141
|
-
Object.keys(custom).forEach((key) => {
|
|
142
|
-
const module2 = key.replace("resources.", "");
|
|
143
|
-
const resource = resources[module2];
|
|
144
|
-
const customResource = custom[key];
|
|
145
|
-
resources[module2] = resource ? (0, import_deepmerge.default)(resource, customResource) : customResource;
|
|
146
|
-
const pkgName = `${import__.OFFICIAL_PLUGIN_PREFIX}${module2}`;
|
|
147
|
-
if (resources[pkgName]) {
|
|
148
|
-
resources[pkgName] = { ...resources[module2] };
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
Object.keys(resources).forEach((name) => {
|
|
153
|
-
this.app.i18n.addResources(lang, name, resources[name]);
|
|
154
|
-
});
|
|
155
|
-
return resources;
|
|
156
|
-
}
|
|
157
|
-
async getI18nInstance(lang) {
|
|
158
|
-
if (lang === "*" || !lang) {
|
|
159
|
-
return this.app.i18n.cloneInstance({ initImmediate: false });
|
|
160
|
-
}
|
|
161
|
-
let instance = this.i18nInstances.get(lang);
|
|
162
|
-
if (!instance) {
|
|
163
|
-
instance = this.app.i18n.cloneInstance({ initImmediate: false });
|
|
164
|
-
this.i18nInstances.set(lang, instance);
|
|
165
|
-
}
|
|
166
|
-
return instance;
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
__name(_Locale, "Locale");
|
|
170
|
-
let Locale = _Locale;
|
|
171
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
172
|
-
0 && (module.exports = {
|
|
173
|
-
Locale
|
|
174
|
-
});
|
package/lib/locale/resource.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
export declare const getResource: (packageName: string, lang: string, isPlugin?: boolean) => any;
|
package/lib/locale/resource.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __create = Object.create;
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
17
|
-
var __export = (target, all) => {
|
|
18
|
-
for (var name in all)
|
|
19
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
-
};
|
|
21
|
-
var __copyProps = (to, from, except, desc) => {
|
|
22
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
-
for (let key of __getOwnPropNames(from))
|
|
24
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
-
}
|
|
27
|
-
return to;
|
|
28
|
-
};
|
|
29
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
-
mod
|
|
36
|
-
));
|
|
37
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
-
var resource_exports = {};
|
|
39
|
-
__export(resource_exports, {
|
|
40
|
-
getResource: () => getResource
|
|
41
|
-
});
|
|
42
|
-
module.exports = __toCommonJS(resource_exports);
|
|
43
|
-
var import_utils = require("@nocobase/utils");
|
|
44
|
-
const arr2obj = /* @__PURE__ */ __name((items) => {
|
|
45
|
-
const obj = {};
|
|
46
|
-
for (const item of items) {
|
|
47
|
-
Object.assign(obj, item);
|
|
48
|
-
}
|
|
49
|
-
return obj;
|
|
50
|
-
}, "arr2obj");
|
|
51
|
-
const getResource = /* @__PURE__ */ __name((packageName, lang, isPlugin = true) => {
|
|
52
|
-
const resources = [];
|
|
53
|
-
const prefixes = [isPlugin ? "dist" : "lib"];
|
|
54
|
-
if (process.env.APP_ENV !== "production") {
|
|
55
|
-
try {
|
|
56
|
-
require.resolve("@nocobase/client/src");
|
|
57
|
-
if (packageName === "@nocobase/plugin-client") {
|
|
58
|
-
packageName = "@nocobase/client";
|
|
59
|
-
}
|
|
60
|
-
} catch (error) {
|
|
61
|
-
}
|
|
62
|
-
prefixes.unshift("src");
|
|
63
|
-
}
|
|
64
|
-
for (const prefix of prefixes) {
|
|
65
|
-
try {
|
|
66
|
-
const file = `${packageName}/${prefix}/locale/${lang}`;
|
|
67
|
-
const f = require.resolve(file);
|
|
68
|
-
if (process.env.APP_ENV !== "production") {
|
|
69
|
-
delete require.cache[f];
|
|
70
|
-
}
|
|
71
|
-
const resource = (0, import_utils.requireModule)(file);
|
|
72
|
-
resources.push(resource);
|
|
73
|
-
} catch (error) {
|
|
74
|
-
}
|
|
75
|
-
if (resources.length) {
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (resources.length === 0 && lang.replace("-", "_") !== lang) {
|
|
80
|
-
return getResource(packageName, lang.replace("-", "_"));
|
|
81
|
-
}
|
|
82
|
-
return arr2obj(resources);
|
|
83
|
-
}, "getResource");
|
|
84
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
85
|
-
0 && (module.exports = {
|
|
86
|
-
getResource
|
|
87
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import { DataSourceOptions, SequelizeDataSource } from '@nocobase/data-source-manager';
|
|
10
|
-
export declare class MainDataSource extends SequelizeDataSource {
|
|
11
|
-
init(options?: DataSourceOptions): void;
|
|
12
|
-
}
|
package/lib/main-data-source.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
15
|
-
var __export = (target, all) => {
|
|
16
|
-
for (var name in all)
|
|
17
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
18
|
-
};
|
|
19
|
-
var __copyProps = (to, from, except, desc) => {
|
|
20
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
-
for (let key of __getOwnPropNames(from))
|
|
22
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
23
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
|
-
}
|
|
25
|
-
return to;
|
|
26
|
-
};
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var main_data_source_exports = {};
|
|
29
|
-
__export(main_data_source_exports, {
|
|
30
|
-
MainDataSource: () => MainDataSource
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(main_data_source_exports);
|
|
33
|
-
var import_data_source_manager = require("@nocobase/data-source-manager");
|
|
34
|
-
const _MainDataSource = class _MainDataSource extends import_data_source_manager.SequelizeDataSource {
|
|
35
|
-
init(options = {}) {
|
|
36
|
-
const { acl, resourceManager, database } = options;
|
|
37
|
-
this.acl = acl;
|
|
38
|
-
this.resourceManager = resourceManager;
|
|
39
|
-
this.collectionManager = this.createCollectionManager({
|
|
40
|
-
collectionManager: {
|
|
41
|
-
database,
|
|
42
|
-
collectionsFilter: (collection) => {
|
|
43
|
-
return collection.options.loadedFromCollectionManager;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
if (options.useACL !== false) {
|
|
48
|
-
this.resourceManager.use(this.acl.middleware(), { group: "acl", after: "auth" });
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
__name(_MainDataSource, "MainDataSource");
|
|
53
|
-
let MainDataSource = _MainDataSource;
|
|
54
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
-
0 && (module.exports = {
|
|
56
|
-
MainDataSource
|
|
57
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import { Context } from '@nocobase/actions';
|
|
10
|
-
export declare const dataTemplate: (ctx: Context, next: any) => Promise<void>;
|