@nocobase/server 2.0.0-alpha.9 → 2.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/acl/available-action.js +1 -1
- package/lib/aes-encryptor.js +4 -0
- package/lib/app-command.d.ts +1 -0
- package/lib/app-command.js +3 -0
- package/lib/app-supervisor.d.ts +7 -2
- package/lib/app-supervisor.js +54 -15
- package/lib/application.d.ts +9 -6
- package/lib/application.js +24 -12
- package/lib/commands/index.js +2 -0
- package/lib/commands/pm.js +11 -0
- package/lib/commands/repair.d.ts +11 -0
- package/lib/commands/repair.js +43 -0
- package/lib/commands/start.js +1 -1
- package/lib/event-queue.d.ts +7 -1
- package/lib/event-queue.js +23 -21
- package/lib/gateway/errors.js +50 -12
- package/lib/gateway/index.d.ts +8 -0
- package/lib/gateway/index.js +26 -2
- package/lib/gateway/ws-server.js +3 -0
- package/lib/helper.d.ts +359 -0
- package/lib/helper.js +58 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +6 -3
- package/lib/locale/locale.js +1 -1
- package/lib/locale/resource.js +6 -9
- package/lib/main-data-source.d.ts +11 -0
- package/lib/main-data-source.js +128 -0
- package/lib/middlewares/data-template.js +1 -6
- package/lib/middlewares/parse-variables.js +2 -49
- package/lib/plugin-manager/deps.js +1 -1
- package/lib/plugin-manager/options/resource.js +48 -25
- package/lib/plugin-manager/plugin-manager.d.ts +1 -0
- package/lib/plugin-manager/plugin-manager.js +36 -1
- package/lib/pub-sub-manager/pub-sub-manager.d.ts +1 -1
- package/lib/pub-sub-manager/pub-sub-manager.js +14 -20
- package/lib/snowflake-id-field.d.ts +2 -1
- package/lib/snowflake-id-field.js +2 -2
- package/package.json +17 -16
- package/lib/background-job-manager.d.ts +0 -40
- package/lib/background-job-manager.js +0 -111
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/server",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-beta.2",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -10,20 +10,20 @@
|
|
|
10
10
|
"@koa/cors": "^5.0.0",
|
|
11
11
|
"@koa/multer": "^3.1.0",
|
|
12
12
|
"@koa/router": "^13.1.0",
|
|
13
|
-
"@nocobase/acl": "2.0.0-
|
|
14
|
-
"@nocobase/actions": "2.0.0-
|
|
15
|
-
"@nocobase/auth": "2.0.0-
|
|
16
|
-
"@nocobase/cache": "2.0.0-
|
|
17
|
-
"@nocobase/data-source-manager": "2.0.0-
|
|
18
|
-
"@nocobase/database": "2.0.0-
|
|
19
|
-
"@nocobase/evaluators": "2.0.0-
|
|
20
|
-
"@nocobase/lock-manager": "2.0.0-
|
|
21
|
-
"@nocobase/logger": "2.0.0-
|
|
22
|
-
"@nocobase/resourcer": "2.0.0-
|
|
23
|
-
"@nocobase/sdk": "2.0.0-
|
|
24
|
-
"@nocobase/snowflake-id": "2.0.0-
|
|
25
|
-
"@nocobase/telemetry": "2.0.0-
|
|
26
|
-
"@nocobase/utils": "2.0.0-
|
|
13
|
+
"@nocobase/acl": "2.0.0-beta.2",
|
|
14
|
+
"@nocobase/actions": "2.0.0-beta.2",
|
|
15
|
+
"@nocobase/auth": "2.0.0-beta.2",
|
|
16
|
+
"@nocobase/cache": "2.0.0-beta.2",
|
|
17
|
+
"@nocobase/data-source-manager": "2.0.0-beta.2",
|
|
18
|
+
"@nocobase/database": "2.0.0-beta.2",
|
|
19
|
+
"@nocobase/evaluators": "2.0.0-beta.2",
|
|
20
|
+
"@nocobase/lock-manager": "2.0.0-beta.2",
|
|
21
|
+
"@nocobase/logger": "2.0.0-beta.2",
|
|
22
|
+
"@nocobase/resourcer": "2.0.0-beta.2",
|
|
23
|
+
"@nocobase/sdk": "2.0.0-beta.2",
|
|
24
|
+
"@nocobase/snowflake-id": "2.0.0-beta.2",
|
|
25
|
+
"@nocobase/telemetry": "2.0.0-beta.2",
|
|
26
|
+
"@nocobase/utils": "2.0.0-beta.2",
|
|
27
27
|
"@types/decompress": "4.2.7",
|
|
28
28
|
"@types/ini": "^1.3.31",
|
|
29
29
|
"@types/koa-send": "^4.1.3",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"lodash": "^4.17.21",
|
|
50
50
|
"multer": "^1.4.5-lts.2",
|
|
51
51
|
"nanoid": "^3.3.11",
|
|
52
|
+
"p-queue": "^6.6.2",
|
|
52
53
|
"semver": "^7.7.1",
|
|
53
54
|
"serve-handler": "^6.1.6",
|
|
54
55
|
"ws": "^8.13.0",
|
|
@@ -59,5 +60,5 @@
|
|
|
59
60
|
"@types/serve-handler": "^6.1.1",
|
|
60
61
|
"@types/ws": "^8.5.5"
|
|
61
62
|
},
|
|
62
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "b77a33ee933ae6e09d2d5dce017ca15d8552d57b"
|
|
63
64
|
}
|
|
@@ -1,40 +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 Application from './application';
|
|
10
|
-
import { QueueEventOptions, QueueMessageOptions } from './event-queue';
|
|
11
|
-
export interface BackgroundJobManagerOptions {
|
|
12
|
-
channel?: string;
|
|
13
|
-
}
|
|
14
|
-
type BackgroundJobEventOptions = Pick<QueueEventOptions, 'process' | 'idle'>;
|
|
15
|
-
declare class BackgroundJobManager {
|
|
16
|
-
private app;
|
|
17
|
-
private options;
|
|
18
|
-
static DEFAULT_CHANNEL: string;
|
|
19
|
-
private subscriptions;
|
|
20
|
-
private processing;
|
|
21
|
-
private get channel();
|
|
22
|
-
private onAfterStart;
|
|
23
|
-
private onBeforeStop;
|
|
24
|
-
private process;
|
|
25
|
-
constructor(app: Application, options?: BackgroundJobManagerOptions);
|
|
26
|
-
private get idle();
|
|
27
|
-
/**
|
|
28
|
-
* 订阅指定主题的任务处理器
|
|
29
|
-
* @param options 订阅选项
|
|
30
|
-
*/
|
|
31
|
-
subscribe(topic: string, options: BackgroundJobEventOptions): void;
|
|
32
|
-
/**
|
|
33
|
-
* 取消订阅指定主题
|
|
34
|
-
* @param topic 主题名称
|
|
35
|
-
*/
|
|
36
|
-
unsubscribe(topic: string): void;
|
|
37
|
-
publish(topic: string, payload: any, options?: QueueMessageOptions): Promise<void>;
|
|
38
|
-
}
|
|
39
|
-
export { BackgroundJobManager };
|
|
40
|
-
export default BackgroundJobManager;
|
|
@@ -1,111 +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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
15
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
30
|
-
var background_job_manager_exports = {};
|
|
31
|
-
__export(background_job_manager_exports, {
|
|
32
|
-
BackgroundJobManager: () => BackgroundJobManager,
|
|
33
|
-
default: () => background_job_manager_default
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(background_job_manager_exports);
|
|
36
|
-
const _BackgroundJobManager = class _BackgroundJobManager {
|
|
37
|
-
constructor(app, options = {}) {
|
|
38
|
-
this.app = app;
|
|
39
|
-
this.options = options;
|
|
40
|
-
this.app.on("afterStart", this.onAfterStart);
|
|
41
|
-
this.app.on("beforeStop", this.onBeforeStop);
|
|
42
|
-
}
|
|
43
|
-
subscriptions = /* @__PURE__ */ new Map();
|
|
44
|
-
// topic -> handler
|
|
45
|
-
processing = null;
|
|
46
|
-
get channel() {
|
|
47
|
-
return this.options.channel ?? _BackgroundJobManager.DEFAULT_CHANNEL;
|
|
48
|
-
}
|
|
49
|
-
onAfterStart = /* @__PURE__ */ __name(() => {
|
|
50
|
-
this.app.eventQueue.subscribe(this.channel, {
|
|
51
|
-
idle: /* @__PURE__ */ __name(() => this.idle, "idle"),
|
|
52
|
-
process: this.process
|
|
53
|
-
});
|
|
54
|
-
}, "onAfterStart");
|
|
55
|
-
onBeforeStop = /* @__PURE__ */ __name(() => {
|
|
56
|
-
this.app.eventQueue.unsubscribe(this.channel);
|
|
57
|
-
}, "onBeforeStop");
|
|
58
|
-
process = /* @__PURE__ */ __name(async ({ topic, payload }, options) => {
|
|
59
|
-
const event = this.subscriptions.get(topic);
|
|
60
|
-
if (!event) {
|
|
61
|
-
this.app.logger.warn(`No handler found for topic: ${topic}, event skipped.`);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
this.processing = event.process(payload, options);
|
|
65
|
-
try {
|
|
66
|
-
await this.processing;
|
|
67
|
-
this.app.logger.debug(`Completed background job ${topic}:${options.id}`);
|
|
68
|
-
} catch (error) {
|
|
69
|
-
this.app.logger.error(`Failed to process background job ${topic}:${options.id}`, error);
|
|
70
|
-
throw error;
|
|
71
|
-
} finally {
|
|
72
|
-
this.processing = null;
|
|
73
|
-
}
|
|
74
|
-
}, "process");
|
|
75
|
-
get idle() {
|
|
76
|
-
return !this.processing && [...this.subscriptions.values()].every((event) => event.idle());
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* 订阅指定主题的任务处理器
|
|
80
|
-
* @param options 订阅选项
|
|
81
|
-
*/
|
|
82
|
-
subscribe(topic, options) {
|
|
83
|
-
if (this.subscriptions.has(topic)) {
|
|
84
|
-
this.app.logger.warn(`Topic "${topic}" already has a handler, skip...`);
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
this.subscriptions.set(topic, options);
|
|
88
|
-
this.app.logger.debug(`Subscribed to background job topic: ${topic}`);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* 取消订阅指定主题
|
|
92
|
-
* @param topic 主题名称
|
|
93
|
-
*/
|
|
94
|
-
unsubscribe(topic) {
|
|
95
|
-
if (this.subscriptions.has(topic)) {
|
|
96
|
-
this.subscriptions.delete(topic);
|
|
97
|
-
this.app.logger.debug(`Unsubscribed from background job topic: ${topic}`);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
async publish(topic, payload, options) {
|
|
101
|
-
await this.app.eventQueue.publish(this.channel, { topic, payload }, options);
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
__name(_BackgroundJobManager, "BackgroundJobManager");
|
|
105
|
-
__publicField(_BackgroundJobManager, "DEFAULT_CHANNEL", "background-jobs");
|
|
106
|
-
let BackgroundJobManager = _BackgroundJobManager;
|
|
107
|
-
var background_job_manager_default = BackgroundJobManager;
|
|
108
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
109
|
-
0 && (module.exports = {
|
|
110
|
-
BackgroundJobManager
|
|
111
|
-
});
|