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