@tego/core 1.3.44
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/LICENSE +201 -0
- package/lib/acl/available-action.d.ts +5 -0
- package/lib/acl/available-action.js +62 -0
- package/lib/acl/index.d.ts +2 -0
- package/lib/acl/index.js +49 -0
- package/lib/aes-encryptor.d.ts +11 -0
- package/lib/aes-encryptor.js +116 -0
- package/lib/app-command.d.ts +12 -0
- package/lib/app-command.js +76 -0
- package/lib/app-supervisor.d.ts +61 -0
- package/lib/app-supervisor.js +299 -0
- package/lib/application.d.ts +354 -0
- package/lib/application.js +878 -0
- package/lib/cache/index.d.ts +3 -0
- package/lib/cache/index.js +35 -0
- package/lib/commands/console.d.ts +3 -0
- package/lib/commands/console.js +48 -0
- package/lib/commands/create-migration.d.ts +3 -0
- package/lib/commands/create-migration.js +80 -0
- package/lib/commands/db-auth.d.ts +3 -0
- package/lib/commands/db-auth.js +28 -0
- package/lib/commands/db-clean.d.ts +3 -0
- package/lib/commands/db-clean.js +31 -0
- package/lib/commands/db-sync.d.ts +3 -0
- package/lib/commands/db-sync.js +40 -0
- package/lib/commands/destroy.d.ts +3 -0
- package/lib/commands/destroy.js +30 -0
- package/lib/commands/index.d.ts +2 -0
- package/lib/commands/index.js +71 -0
- package/lib/commands/install.d.ts +3 -0
- package/lib/commands/install.js +33 -0
- package/lib/commands/migrator.d.ts +3 -0
- package/lib/commands/migrator.js +31 -0
- package/lib/commands/pm.d.ts +3 -0
- package/lib/commands/pm.js +75 -0
- package/lib/commands/refresh.d.ts +3 -0
- package/lib/commands/refresh.js +31 -0
- package/lib/commands/restart.d.ts +3 -0
- package/lib/commands/restart.js +35 -0
- package/lib/commands/start.d.ts +3 -0
- package/lib/commands/start.js +74 -0
- package/lib/commands/stop.d.ts +3 -0
- package/lib/commands/stop.js +34 -0
- package/lib/commands/upgrade.d.ts +3 -0
- package/lib/commands/upgrade.js +29 -0
- package/lib/cron/cron-job-manager.d.ts +25 -0
- package/lib/cron/cron-job-manager.js +89 -0
- package/lib/environment.d.ts +10 -0
- package/lib/environment.js +73 -0
- package/lib/errors/application-not-install.d.ts +4 -0
- package/lib/errors/application-not-install.js +35 -0
- package/lib/errors/handler.d.ts +3 -0
- package/lib/errors/handler.js +41 -0
- package/lib/errors/plugin-command-error.d.ts +2 -0
- package/lib/errors/plugin-command-error.js +31 -0
- package/lib/errors/plugin-not-exist.d.ts +2 -0
- package/lib/errors/plugin-not-exist.js +31 -0
- package/lib/gateway/errors.d.ts +22 -0
- package/lib/gateway/errors.js +138 -0
- package/lib/gateway/gateway.d.ts +56 -0
- package/lib/gateway/gateway.js +408 -0
- package/lib/gateway/index.d.ts +2 -0
- package/lib/gateway/index.js +30 -0
- package/lib/gateway/ipc-socket-client.d.ts +17 -0
- package/lib/gateway/ipc-socket-client.js +99 -0
- package/lib/gateway/ipc-socket-server.d.ts +12 -0
- package/lib/gateway/ipc-socket-server.js +140 -0
- package/lib/gateway/types.d.ts +25 -0
- package/lib/gateway/types.js +15 -0
- package/lib/gateway/ws-server.d.ts +63 -0
- package/lib/gateway/ws-server.js +335 -0
- package/lib/helper.d.ts +11 -0
- package/lib/helper.js +193 -0
- package/lib/helpers/application-version.d.ts +10 -0
- package/lib/helpers/application-version.js +77 -0
- package/lib/helpers/multiple-instance-manager.d.ts +6 -0
- package/lib/helpers/multiple-instance-manager.js +40 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.js +57 -0
- package/lib/locale/index.d.ts +1 -0
- package/lib/locale/index.js +21 -0
- package/lib/locale/locale.d.ts +22 -0
- package/lib/locale/locale.js +166 -0
- package/lib/locale/resource.d.ts +1 -0
- package/lib/locale/resource.js +74 -0
- package/lib/main-data-source.d.ts +4 -0
- package/lib/main-data-source.js +45 -0
- package/lib/middlewares/data-template.d.ts +2 -0
- package/lib/middlewares/data-template.js +39 -0
- package/lib/middlewares/data-wrapping.d.ts +3 -0
- package/lib/middlewares/data-wrapping.js +90 -0
- package/lib/middlewares/db2resource.d.ts +6 -0
- package/lib/middlewares/db2resource.js +76 -0
- package/lib/middlewares/extract-client-ip.d.ts +2 -0
- package/lib/middlewares/extract-client-ip.js +37 -0
- package/lib/middlewares/i18n.d.ts +1 -0
- package/lib/middlewares/i18n.js +44 -0
- package/lib/middlewares/index.d.ts +3 -0
- package/lib/middlewares/index.js +32 -0
- package/lib/middlewares/parse-variables.d.ts +1 -0
- package/lib/middlewares/parse-variables.js +84 -0
- package/lib/migration.d.ts +12 -0
- package/lib/migration.js +47 -0
- package/lib/migrations/20230912193824-package-name-unique.d.ts +6 -0
- package/lib/migrations/20230912193824-package-name-unique.js +52 -0
- package/lib/migrations/20230912294620-update-pkg.d.ts +6 -0
- package/lib/migrations/20230912294620-update-pkg.js +58 -0
- package/lib/migrations/20240106082756-update-plugins.d.ts +6 -0
- package/lib/migrations/20240106082756-update-plugins.js +44 -0
- package/lib/migrations/20240705000001-remove-pkgs-approval.d.ts +6 -0
- package/lib/migrations/20240705000001-remove-pkgs-approval.js +47 -0
- package/lib/notice/index.d.ts +25 -0
- package/lib/notice/index.js +91 -0
- package/lib/plugin-manager/clientStaticUtils.d.ts +24 -0
- package/lib/plugin-manager/clientStaticUtils.js +156 -0
- package/lib/plugin-manager/constants.d.ts +7 -0
- package/lib/plugin-manager/constants.js +120 -0
- package/lib/plugin-manager/deps.d.ts +2 -0
- package/lib/plugin-manager/deps.js +68 -0
- package/lib/plugin-manager/index.d.ts +2 -0
- package/lib/plugin-manager/index.js +23 -0
- package/lib/plugin-manager/middleware.d.ts +2 -0
- package/lib/plugin-manager/middleware.js +36 -0
- package/lib/plugin-manager/options/collection.d.ts +2 -0
- package/lib/plugin-manager/options/collection.js +39 -0
- package/lib/plugin-manager/options/resource.d.ts +15 -0
- package/lib/plugin-manager/options/resource.js +185 -0
- package/lib/plugin-manager/plugin-manager-repository.d.ts +27 -0
- package/lib/plugin-manager/plugin-manager-repository.js +136 -0
- package/lib/plugin-manager/plugin-manager.d.ts +205 -0
- package/lib/plugin-manager/plugin-manager.js +1032 -0
- package/lib/plugin-manager/types.d.ts +15 -0
- package/lib/plugin-manager/types.js +15 -0
- package/lib/plugin-manager/utils.d.ts +101 -0
- package/lib/plugin-manager/utils.js +513 -0
- package/lib/plugin-manager/web-service.d.ts +6 -0
- package/lib/plugin-manager/web-service.js +116 -0
- package/lib/plugin.d.ts +125 -0
- package/lib/plugin.js +359 -0
- package/lib/pub-sub-manager/handler-manager.d.ts +28 -0
- package/lib/pub-sub-manager/handler-manager.js +149 -0
- package/lib/pub-sub-manager/index.d.ts +3 -0
- package/lib/pub-sub-manager/index.js +25 -0
- package/lib/pub-sub-manager/memory-pub-sub-adapter.d.ts +21 -0
- package/lib/pub-sub-manager/memory-pub-sub-adapter.js +82 -0
- package/lib/pub-sub-manager/pub-sub-manager.d.ts +19 -0
- package/lib/pub-sub-manager/pub-sub-manager.js +108 -0
- package/lib/pub-sub-manager/types.d.ts +20 -0
- package/lib/pub-sub-manager/types.js +15 -0
- package/lib/sync-message-manager.d.ts +16 -0
- package/lib/sync-message-manager.js +112 -0
- package/package.json +58 -0
|
@@ -0,0 +1,68 @@
|
|
|
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 deps_exports = {};
|
|
19
|
+
__export(deps_exports, {
|
|
20
|
+
default: () => deps_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(deps_exports);
|
|
23
|
+
var import_package = require("../../package.json");
|
|
24
|
+
const deps = {
|
|
25
|
+
"@tachybase": `${import_package.version.split(".").slice(0, 2).join(".")}.x`,
|
|
26
|
+
"@tego": `${import_package.version.split(".").slice(0, 2).join(".")}.x`,
|
|
27
|
+
jsonwebtoken: "8.x",
|
|
28
|
+
"cache-manager": "5.x",
|
|
29
|
+
sequelize: "6.x",
|
|
30
|
+
umzug: "3.x",
|
|
31
|
+
"async-mutex": "0.5.x",
|
|
32
|
+
"@formulajs/formulajs": "4.x",
|
|
33
|
+
winston: "3.x",
|
|
34
|
+
"winston-daily-rotate-file": "5.x",
|
|
35
|
+
koa: "2.x",
|
|
36
|
+
"@koa/cors": "3.x",
|
|
37
|
+
multer: "2.x",
|
|
38
|
+
"@koa/multer": "3.x",
|
|
39
|
+
"koa-bodyparser": "4.x",
|
|
40
|
+
react: "18.x",
|
|
41
|
+
"react-dom": "18.x",
|
|
42
|
+
"react-router": "6.x",
|
|
43
|
+
"react-router-dom": "6.x",
|
|
44
|
+
antd: "5.x",
|
|
45
|
+
"antd-style": "3.x",
|
|
46
|
+
"@ant-design/icons": "5.x",
|
|
47
|
+
"@ant-design/cssinjs": "1.x",
|
|
48
|
+
i18next: "23.x",
|
|
49
|
+
"react-i18next": "15.x",
|
|
50
|
+
"@dnd-kit/accessibility": "3.x",
|
|
51
|
+
"@dnd-kit/core": "6.x",
|
|
52
|
+
"@dnd-kit/modifiers": "7.x",
|
|
53
|
+
"@dnd-kit/sortable": "8.x",
|
|
54
|
+
"@dnd-kit/utilities": "3.x",
|
|
55
|
+
dayjs: "1.x",
|
|
56
|
+
mysql2: "3.x",
|
|
57
|
+
pg: "8.x",
|
|
58
|
+
"pg-hstore": "2.x",
|
|
59
|
+
sqlite3: "5.x",
|
|
60
|
+
supertest: "6.x",
|
|
61
|
+
axios: "1.x",
|
|
62
|
+
"@emotion/css": "11.x",
|
|
63
|
+
ahooks: "3.x",
|
|
64
|
+
lodash: "4.x",
|
|
65
|
+
"china-division": "2.x",
|
|
66
|
+
cronstrue: "2.x"
|
|
67
|
+
};
|
|
68
|
+
var deps_default = deps;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var plugin_manager_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(plugin_manager_exports);
|
|
17
|
+
__reExport(plugin_manager_exports, require("./clientStaticUtils"), module.exports);
|
|
18
|
+
__reExport(plugin_manager_exports, require("./plugin-manager"), module.exports);
|
|
19
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
20
|
+
0 && (module.exports = {
|
|
21
|
+
...require("./clientStaticUtils"),
|
|
22
|
+
...require("./plugin-manager")
|
|
23
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var middleware_exports = {};
|
|
20
|
+
__export(middleware_exports, {
|
|
21
|
+
uploadMiddleware: () => uploadMiddleware
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(middleware_exports);
|
|
24
|
+
var import_utils = require("@tachybase/utils");
|
|
25
|
+
async function uploadMiddleware(ctx, next) {
|
|
26
|
+
if (ctx.action.resourceName === "pm" && ["add", "update"].includes(ctx.action.actionName)) {
|
|
27
|
+
const upload = (0, import_utils.koaMulter)().single("file");
|
|
28
|
+
return upload(ctx, next);
|
|
29
|
+
}
|
|
30
|
+
return next();
|
|
31
|
+
}
|
|
32
|
+
__name(uploadMiddleware, "uploadMiddleware");
|
|
33
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
+
0 && (module.exports = {
|
|
35
|
+
uploadMiddleware
|
|
36
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
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 collection_exports = {};
|
|
19
|
+
__export(collection_exports, {
|
|
20
|
+
default: () => collection_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(collection_exports);
|
|
23
|
+
var import_database = require("@tachybase/database");
|
|
24
|
+
var collection_default = (0, import_database.defineCollection)({
|
|
25
|
+
name: "applicationPlugins",
|
|
26
|
+
dumpRules: "required",
|
|
27
|
+
repository: "PluginManagerRepository",
|
|
28
|
+
origin: "@tego/core",
|
|
29
|
+
fields: [
|
|
30
|
+
{ type: "string", name: "name", unique: true },
|
|
31
|
+
{ type: "string", name: "packageName", unique: true },
|
|
32
|
+
{ type: "string", name: "version" },
|
|
33
|
+
{ type: "boolean", name: "enabled" },
|
|
34
|
+
{ type: "boolean", name: "installed" },
|
|
35
|
+
{ type: "boolean", name: "builtIn" },
|
|
36
|
+
{ type: "json", name: "options" },
|
|
37
|
+
{ type: "boolean", name: "subView", defaultValue: true }
|
|
38
|
+
]
|
|
39
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
name: string;
|
|
3
|
+
actions: {
|
|
4
|
+
add(ctx: any, next: any): Promise<void>;
|
|
5
|
+
update(ctx: any, next: any): Promise<void>;
|
|
6
|
+
npmVersionList(ctx: any, next: any): Promise<void>;
|
|
7
|
+
enable(ctx: any, next: any): Promise<void>;
|
|
8
|
+
disable(ctx: any, next: any): Promise<void>;
|
|
9
|
+
remove(ctx: any, next: any): Promise<void>;
|
|
10
|
+
list(ctx: any, next: any): Promise<void>;
|
|
11
|
+
listEnabled(ctx: any, next: any): Promise<void>;
|
|
12
|
+
get(ctx: any, next: any): Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,185 @@
|
|
|
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 resource_exports = {};
|
|
29
|
+
__export(resource_exports, {
|
|
30
|
+
default: () => resource_default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(resource_exports);
|
|
33
|
+
var import_node_fs = __toESM(require("node:fs"));
|
|
34
|
+
var import_node_path = __toESM(require("node:path"));
|
|
35
|
+
var import_utils = require("@tachybase/utils");
|
|
36
|
+
var import_clientStaticUtils = require("../clientStaticUtils");
|
|
37
|
+
var resource_default = {
|
|
38
|
+
name: "pm",
|
|
39
|
+
actions: {
|
|
40
|
+
async add(ctx, next) {
|
|
41
|
+
const app = ctx.app;
|
|
42
|
+
const { values = {} } = ctx.action.params;
|
|
43
|
+
if (values == null ? void 0 : values.packageName) {
|
|
44
|
+
const args = [];
|
|
45
|
+
if (values.registry) {
|
|
46
|
+
args.push("--registry=" + values.registry);
|
|
47
|
+
}
|
|
48
|
+
if (values.version) {
|
|
49
|
+
args.push("--version=" + values.version);
|
|
50
|
+
}
|
|
51
|
+
if (values.authToken) {
|
|
52
|
+
args.push("--auth-token=" + values.authToken);
|
|
53
|
+
}
|
|
54
|
+
app.runAsCLI(["pm", "add", values.packageName, ...args], { from: "user" });
|
|
55
|
+
} else if (ctx.file) {
|
|
56
|
+
const tmpDir = import_node_path.default.resolve(process.cwd(), "storage", "tmp");
|
|
57
|
+
try {
|
|
58
|
+
await import_node_fs.default.promises.mkdir(tmpDir, { recursive: true });
|
|
59
|
+
} catch (error) {
|
|
60
|
+
}
|
|
61
|
+
const tempFile = import_node_path.default.join(process.cwd(), "storage/tmp", (0, import_utils.uid)() + import_node_path.default.extname(ctx.file.originalname));
|
|
62
|
+
await import_node_fs.default.promises.writeFile(tempFile, ctx.file.buffer, "binary");
|
|
63
|
+
app.runAsCLI(["pm", "add", tempFile], { from: "user" });
|
|
64
|
+
} else if (values.compressedFileUrl) {
|
|
65
|
+
app.runAsCLI(["pm", "add", values.compressedFileUrl], { from: "user" });
|
|
66
|
+
}
|
|
67
|
+
ctx.body = "ok";
|
|
68
|
+
await next();
|
|
69
|
+
},
|
|
70
|
+
async update(ctx, next) {
|
|
71
|
+
const app = ctx.app;
|
|
72
|
+
const values = ctx.action.params.values || {};
|
|
73
|
+
const args = [];
|
|
74
|
+
if (values.registry) {
|
|
75
|
+
args.push("--registry=" + values.registry);
|
|
76
|
+
}
|
|
77
|
+
if (values.version) {
|
|
78
|
+
args.push("--version=" + values.version);
|
|
79
|
+
}
|
|
80
|
+
if (values.authToken) {
|
|
81
|
+
args.push("--auth-token=" + values.authToken);
|
|
82
|
+
}
|
|
83
|
+
if (values.compressedFileUrl) {
|
|
84
|
+
args.push("--url=" + values.compressedFileUrl);
|
|
85
|
+
}
|
|
86
|
+
if (ctx.file) {
|
|
87
|
+
values.packageName = ctx.request.body.packageName;
|
|
88
|
+
const tmpDir = import_node_path.default.resolve(process.cwd(), "storage", "tmp");
|
|
89
|
+
try {
|
|
90
|
+
await import_node_fs.default.promises.mkdir(tmpDir, { recursive: true });
|
|
91
|
+
} catch (error) {
|
|
92
|
+
}
|
|
93
|
+
const tempFile = import_node_path.default.join(process.cwd(), "storage/tmp", (0, import_utils.uid)() + import_node_path.default.extname(ctx.file.originalname));
|
|
94
|
+
await import_node_fs.default.promises.writeFile(tempFile, ctx.file.buffer, "binary");
|
|
95
|
+
args.push(`--url=${tempFile}`);
|
|
96
|
+
}
|
|
97
|
+
app.runAsCLI(["pm", "update", values.packageName, ...args], { from: "user" });
|
|
98
|
+
ctx.body = "ok";
|
|
99
|
+
await next();
|
|
100
|
+
},
|
|
101
|
+
async npmVersionList(ctx, next) {
|
|
102
|
+
const { filterByTk } = ctx.action.params;
|
|
103
|
+
if (!filterByTk) {
|
|
104
|
+
ctx.throw(400, "plugin name invalid");
|
|
105
|
+
}
|
|
106
|
+
const pm = ctx.app.pm;
|
|
107
|
+
ctx.body = await pm.getNpmVersionList(filterByTk);
|
|
108
|
+
await next();
|
|
109
|
+
},
|
|
110
|
+
async enable(ctx, next) {
|
|
111
|
+
const { filterByTk } = ctx.action.params;
|
|
112
|
+
const app = ctx.app;
|
|
113
|
+
if (!filterByTk) {
|
|
114
|
+
ctx.throw(400, "plugin name invalid");
|
|
115
|
+
}
|
|
116
|
+
app.runAsCLI(["pm", "enable", filterByTk], { from: "user" });
|
|
117
|
+
ctx.body = filterByTk;
|
|
118
|
+
await next();
|
|
119
|
+
},
|
|
120
|
+
async disable(ctx, next) {
|
|
121
|
+
const { filterByTk } = ctx.action.params;
|
|
122
|
+
if (!filterByTk) {
|
|
123
|
+
ctx.throw(400, "plugin name invalid");
|
|
124
|
+
}
|
|
125
|
+
const app = ctx.app;
|
|
126
|
+
app.runAsCLI(["pm", "disable", filterByTk], { from: "user" });
|
|
127
|
+
ctx.body = filterByTk;
|
|
128
|
+
await next();
|
|
129
|
+
},
|
|
130
|
+
async remove(ctx, next) {
|
|
131
|
+
const { filterByTk } = ctx.action.params;
|
|
132
|
+
if (!filterByTk) {
|
|
133
|
+
ctx.throw(400, "plugin name invalid");
|
|
134
|
+
}
|
|
135
|
+
const app = ctx.app;
|
|
136
|
+
app.runAsCLI(["pm", "remove", filterByTk], { from: "user" });
|
|
137
|
+
ctx.body = filterByTk;
|
|
138
|
+
await next();
|
|
139
|
+
},
|
|
140
|
+
async list(ctx, next) {
|
|
141
|
+
const locale = ctx.getCurrentLocale();
|
|
142
|
+
const pm = ctx.app.pm;
|
|
143
|
+
if (ctx.app.name === "main") {
|
|
144
|
+
ctx.body = await pm.list({ locale, isPreset: false });
|
|
145
|
+
} else {
|
|
146
|
+
ctx.body = await pm.list({ locale, isPreset: false, subView: true });
|
|
147
|
+
}
|
|
148
|
+
await next();
|
|
149
|
+
},
|
|
150
|
+
async listEnabled(ctx, next) {
|
|
151
|
+
const pm = ctx.db.getRepository("applicationPlugins");
|
|
152
|
+
const PLUGIN_CLIENT_ENTRY_FILE = "dist/client/index.js";
|
|
153
|
+
const items = await pm.find({
|
|
154
|
+
filter: {
|
|
155
|
+
enabled: true,
|
|
156
|
+
subView: true
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
ctx.body = items.map((item) => {
|
|
160
|
+
try {
|
|
161
|
+
return {
|
|
162
|
+
...item.toJSON(),
|
|
163
|
+
url: `${process.env.APP_SERVER_BASE_URL}${(0, import_clientStaticUtils.getExposeUrl)(
|
|
164
|
+
item.packageName,
|
|
165
|
+
PLUGIN_CLIENT_ENTRY_FILE
|
|
166
|
+
)}?version=${item.version}`
|
|
167
|
+
};
|
|
168
|
+
} catch {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
}).filter(Boolean);
|
|
172
|
+
await next();
|
|
173
|
+
},
|
|
174
|
+
async get(ctx, next) {
|
|
175
|
+
const locale = ctx.getCurrentLocale();
|
|
176
|
+
const pm = ctx.app.pm;
|
|
177
|
+
const { filterByTk } = ctx.action.params;
|
|
178
|
+
if (!filterByTk) {
|
|
179
|
+
ctx.throw(400, "plugin name invalid");
|
|
180
|
+
}
|
|
181
|
+
ctx.body = await pm.get(filterByTk).toJSON({ locale });
|
|
182
|
+
await next();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Repository } from '@tachybase/database';
|
|
2
|
+
import { PluginManager } from './plugin-manager';
|
|
3
|
+
export declare class PluginManagerRepository extends Repository {
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
pm: PluginManager;
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
setPluginManager(pm: PluginManager): void;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated
|
|
14
|
+
*/
|
|
15
|
+
remove(name: string | string[]): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated
|
|
18
|
+
*/
|
|
19
|
+
enable(name: string | string[]): Promise<string[]>;
|
|
20
|
+
updateVersions(): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated
|
|
23
|
+
*/
|
|
24
|
+
disable(name: string | string[]): Promise<string[]>;
|
|
25
|
+
getItems(): Promise<any>;
|
|
26
|
+
init(): Promise<void>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var plugin_manager_repository_exports = {};
|
|
30
|
+
__export(plugin_manager_repository_exports, {
|
|
31
|
+
PluginManagerRepository: () => PluginManagerRepository
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(plugin_manager_repository_exports);
|
|
34
|
+
var import_database = require("@tachybase/database");
|
|
35
|
+
var import_lodash = __toESM(require("lodash"));
|
|
36
|
+
var import_plugin_manager = require("./plugin-manager");
|
|
37
|
+
const _PluginManagerRepository = class _PluginManagerRepository extends import_database.Repository {
|
|
38
|
+
/**
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
setPluginManager(pm) {
|
|
42
|
+
this.pm = pm;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated
|
|
46
|
+
*/
|
|
47
|
+
async remove(name) {
|
|
48
|
+
await this.destroy({
|
|
49
|
+
filter: {
|
|
50
|
+
name
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* @deprecated
|
|
56
|
+
*/
|
|
57
|
+
async enable(name) {
|
|
58
|
+
const pluginNames = import_lodash.default.castArray(name);
|
|
59
|
+
const plugins = pluginNames.map((name2) => this.pm.get(name2));
|
|
60
|
+
for (const plugin of plugins) {
|
|
61
|
+
const requiredPlugins = plugin.requiredPlugins();
|
|
62
|
+
for (const requiredPluginName of requiredPlugins) {
|
|
63
|
+
const requiredPlugin = this.pm.get(requiredPluginName);
|
|
64
|
+
if (!requiredPlugin.enabled) {
|
|
65
|
+
throw new Error(`${plugin.name} plugin need ${requiredPluginName} plugin enabled`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
for (const plugin of plugins) {
|
|
70
|
+
await plugin.beforeEnable();
|
|
71
|
+
}
|
|
72
|
+
await this.update({
|
|
73
|
+
filter: {
|
|
74
|
+
name
|
|
75
|
+
},
|
|
76
|
+
values: {
|
|
77
|
+
enabled: true,
|
|
78
|
+
installed: true
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
return pluginNames;
|
|
82
|
+
}
|
|
83
|
+
async updateVersions() {
|
|
84
|
+
const items = await this.find();
|
|
85
|
+
for (const item of items) {
|
|
86
|
+
const json = await import_plugin_manager.PluginManager.getPackageJson(item.packageName);
|
|
87
|
+
item.set("version", json.version);
|
|
88
|
+
await item.save();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* @deprecated
|
|
93
|
+
*/
|
|
94
|
+
async disable(name) {
|
|
95
|
+
name = import_lodash.default.cloneDeep(name);
|
|
96
|
+
const pluginNames = import_lodash.default.castArray(name);
|
|
97
|
+
console.log(`disable ${name}, ${pluginNames}`);
|
|
98
|
+
const filter = {
|
|
99
|
+
name
|
|
100
|
+
};
|
|
101
|
+
console.log(JSON.stringify(filter, null, 2));
|
|
102
|
+
await this.update({
|
|
103
|
+
filter,
|
|
104
|
+
values: {
|
|
105
|
+
enabled: false,
|
|
106
|
+
installed: false
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
return pluginNames;
|
|
110
|
+
}
|
|
111
|
+
async getItems() {
|
|
112
|
+
const exists = await this.collection.existsInDb();
|
|
113
|
+
if (!exists) {
|
|
114
|
+
return [];
|
|
115
|
+
}
|
|
116
|
+
return await this.find({
|
|
117
|
+
sort: "id"
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
async init() {
|
|
121
|
+
const items = await this.getItems();
|
|
122
|
+
for (const item of items) {
|
|
123
|
+
const { options, ...others } = item.toJSON();
|
|
124
|
+
await this.pm.add(item.get("name"), {
|
|
125
|
+
...others,
|
|
126
|
+
...options
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
__name(_PluginManagerRepository, "PluginManagerRepository");
|
|
132
|
+
let PluginManagerRepository = _PluginManagerRepository;
|
|
133
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
134
|
+
0 && (module.exports = {
|
|
135
|
+
PluginManagerRepository
|
|
136
|
+
});
|