@nocobase/server 2.1.29 → 2.1.31
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/event-queue.d.ts +3 -2
- package/lib/event-queue.js +19 -12
- package/lib/helper.d.ts +1 -0
- package/lib/helper.js +3 -1
- package/package.json +17 -17
package/lib/event-queue.d.ts
CHANGED
|
@@ -53,17 +53,18 @@ export interface EventQueueOptions {
|
|
|
53
53
|
export declare class MemoryEventQueueAdapter implements IEventQueueAdapter {
|
|
54
54
|
private options;
|
|
55
55
|
private connected;
|
|
56
|
-
private emitter;
|
|
57
56
|
private reading;
|
|
57
|
+
private scheduledChannels;
|
|
58
58
|
protected events: Map<string, QueueEventOptions>;
|
|
59
59
|
protected queues: Map<string, {
|
|
60
60
|
id: string;
|
|
61
61
|
content: any;
|
|
62
62
|
options?: QueueMessageOptions;
|
|
63
63
|
}[]>;
|
|
64
|
-
get processing(): Promise<
|
|
64
|
+
get processing(): Promise<void[]>;
|
|
65
65
|
private get storagePath();
|
|
66
66
|
listen: (channel: string) => void;
|
|
67
|
+
private scheduleListen;
|
|
67
68
|
constructor(options: {
|
|
68
69
|
appName: string;
|
|
69
70
|
logger: SystemLogger;
|
package/lib/event-queue.js
CHANGED
|
@@ -46,7 +46,6 @@ __export(event_queue_exports, {
|
|
|
46
46
|
});
|
|
47
47
|
module.exports = __toCommonJS(event_queue_exports);
|
|
48
48
|
var import_crypto = require("crypto");
|
|
49
|
-
var import_events = require("events");
|
|
50
49
|
var import_path = __toESM(require("path"));
|
|
51
50
|
var import_promises = __toESM(require("fs/promises"));
|
|
52
51
|
var import_utils = require("@nocobase/utils");
|
|
@@ -56,15 +55,14 @@ const QUEUE_DEFAULT_ACK_TIMEOUT = 15e3;
|
|
|
56
55
|
const _MemoryEventQueueAdapter = class _MemoryEventQueueAdapter {
|
|
57
56
|
constructor(options) {
|
|
58
57
|
this.options = options;
|
|
59
|
-
this.emitter.setMaxListeners(0);
|
|
60
58
|
}
|
|
61
59
|
connected = false;
|
|
62
|
-
emitter = new import_events.EventEmitter();
|
|
63
60
|
reading = /* @__PURE__ */ new Map();
|
|
61
|
+
scheduledChannels = /* @__PURE__ */ new Set();
|
|
64
62
|
events = /* @__PURE__ */ new Map();
|
|
65
63
|
queues = /* @__PURE__ */ new Map();
|
|
66
64
|
get processing() {
|
|
67
|
-
const processing = Array.from(this.reading.values());
|
|
65
|
+
const processing = Array.from(this.reading.values()).flat();
|
|
68
66
|
if (processing.length > 0) {
|
|
69
67
|
return Promise.all(processing);
|
|
70
68
|
}
|
|
@@ -80,7 +78,6 @@ const _MemoryEventQueueAdapter = class _MemoryEventQueueAdapter {
|
|
|
80
78
|
const { logger } = this.options;
|
|
81
79
|
const event = this.events.get(channel);
|
|
82
80
|
if (!event) {
|
|
83
|
-
logger.warn(`memory queue (${channel}) not found, skipping...`);
|
|
84
81
|
return;
|
|
85
82
|
}
|
|
86
83
|
if (!event.idle()) {
|
|
@@ -99,10 +96,24 @@ const _MemoryEventQueueAdapter = class _MemoryEventQueueAdapter {
|
|
|
99
96
|
if (index > -1) {
|
|
100
97
|
reading.splice(index, 1);
|
|
101
98
|
}
|
|
99
|
+
this.scheduleListen(channel);
|
|
102
100
|
});
|
|
103
101
|
});
|
|
104
102
|
this.reading.set(channel, reading);
|
|
105
103
|
}, "listen");
|
|
104
|
+
scheduleListen(channel) {
|
|
105
|
+
if (this.scheduledChannels.has(channel)) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
this.scheduledChannels.add(channel);
|
|
109
|
+
setImmediate(() => {
|
|
110
|
+
this.scheduledChannels.delete(channel);
|
|
111
|
+
if (!this.events.has(channel)) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
this.listen(channel);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
106
117
|
isConnected() {
|
|
107
118
|
return this.connected;
|
|
108
119
|
}
|
|
@@ -181,7 +192,6 @@ const _MemoryEventQueueAdapter = class _MemoryEventQueueAdapter {
|
|
|
181
192
|
if (!this.queues.has(channel)) {
|
|
182
193
|
this.queues.set(channel, []);
|
|
183
194
|
}
|
|
184
|
-
this.emitter.on(channel, this.listen);
|
|
185
195
|
if (this.connected) {
|
|
186
196
|
this.consume(channel);
|
|
187
197
|
}
|
|
@@ -191,12 +201,12 @@ const _MemoryEventQueueAdapter = class _MemoryEventQueueAdapter {
|
|
|
191
201
|
return;
|
|
192
202
|
}
|
|
193
203
|
this.events.delete(channel);
|
|
194
|
-
this.emitter.off(channel, this.listen);
|
|
195
204
|
}
|
|
196
205
|
publish(channel, content, options = { timestamp: Date.now() }) {
|
|
206
|
+
const { logger } = this.options;
|
|
197
207
|
const event = this.events.get(channel);
|
|
198
208
|
if (!event) {
|
|
199
|
-
|
|
209
|
+
logger.debug(`memory queue (${channel}) not subscribed, skip`);
|
|
200
210
|
return;
|
|
201
211
|
}
|
|
202
212
|
if (!this.queues.get(channel)) {
|
|
@@ -205,11 +215,8 @@ const _MemoryEventQueueAdapter = class _MemoryEventQueueAdapter {
|
|
|
205
215
|
const queue = this.queues.get(channel);
|
|
206
216
|
const message = { id: (0, import_crypto.randomUUID)(), content, options };
|
|
207
217
|
queue.push(message);
|
|
208
|
-
const { logger } = this.options;
|
|
209
218
|
logger.debug(`memory queue (${channel}) published message`, content);
|
|
210
|
-
|
|
211
|
-
this.emitter.emit(channel, channel);
|
|
212
|
-
});
|
|
219
|
+
this.scheduleListen(channel);
|
|
213
220
|
}
|
|
214
221
|
async consume(channel, once = false) {
|
|
215
222
|
while (this.connected && this.events.get(channel)) {
|
package/lib/helper.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { Command } from 'commander';
|
|
|
11
11
|
import Application, { ApplicationOptions } from './application';
|
|
12
12
|
export declare function createI18n(options: ApplicationOptions): import("i18next").i18n;
|
|
13
13
|
export declare function createResourcer(options: ApplicationOptions): Resourcer;
|
|
14
|
+
export declare function resolveCorsOrigin(ctx: any): any;
|
|
14
15
|
export declare function registerMiddlewares(app: Application, options: ApplicationOptions): void;
|
|
15
16
|
export declare const createAppProxy: (app: Application) => Application<import("./application").DefaultState, import("./application").DefaultContext>;
|
|
16
17
|
export declare const getCommandFullName: (command: Command) => string;
|
package/lib/helper.js
CHANGED
|
@@ -45,6 +45,7 @@ __export(helper_exports, {
|
|
|
45
45
|
getBodyLimit: () => getBodyLimit,
|
|
46
46
|
getCommandFullName: () => getCommandFullName,
|
|
47
47
|
registerMiddlewares: () => registerMiddlewares,
|
|
48
|
+
resolveCorsOrigin: () => resolveCorsOrigin,
|
|
48
49
|
tsxRerunning: () => tsxRerunning
|
|
49
50
|
});
|
|
50
51
|
module.exports = __toCommonJS(helper_exports);
|
|
@@ -89,7 +90,7 @@ function resolveCorsOrigin(ctx) {
|
|
|
89
90
|
const whitelist = new Set(
|
|
90
91
|
whitelistString.split(",").map((item) => item.trim()).filter(Boolean)
|
|
91
92
|
);
|
|
92
|
-
if (whitelist.has(origin)) {
|
|
93
|
+
if (whitelist.has("*") || whitelist.has(origin)) {
|
|
93
94
|
return origin;
|
|
94
95
|
}
|
|
95
96
|
return false;
|
|
@@ -309,5 +310,6 @@ __name(createContextVariablesScope, "createContextVariablesScope");
|
|
|
309
310
|
getBodyLimit,
|
|
310
311
|
getCommandFullName,
|
|
311
312
|
registerMiddlewares,
|
|
313
|
+
resolveCorsOrigin,
|
|
312
314
|
tsxRerunning
|
|
313
315
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/server",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.31",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -10,21 +10,21 @@
|
|
|
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.1.
|
|
14
|
-
"@nocobase/actions": "2.1.
|
|
15
|
-
"@nocobase/ai": "2.1.
|
|
16
|
-
"@nocobase/auth": "2.1.
|
|
17
|
-
"@nocobase/cache": "2.1.
|
|
18
|
-
"@nocobase/data-source-manager": "2.1.
|
|
19
|
-
"@nocobase/database": "2.1.
|
|
20
|
-
"@nocobase/evaluators": "2.1.
|
|
21
|
-
"@nocobase/lock-manager": "2.1.
|
|
22
|
-
"@nocobase/logger": "2.1.
|
|
23
|
-
"@nocobase/resourcer": "2.1.
|
|
24
|
-
"@nocobase/sdk": "2.1.
|
|
25
|
-
"@nocobase/snowflake-id": "2.1.
|
|
26
|
-
"@nocobase/telemetry": "2.1.
|
|
27
|
-
"@nocobase/utils": "2.1.
|
|
13
|
+
"@nocobase/acl": "2.1.31",
|
|
14
|
+
"@nocobase/actions": "2.1.31",
|
|
15
|
+
"@nocobase/ai": "2.1.31",
|
|
16
|
+
"@nocobase/auth": "2.1.31",
|
|
17
|
+
"@nocobase/cache": "2.1.31",
|
|
18
|
+
"@nocobase/data-source-manager": "2.1.31",
|
|
19
|
+
"@nocobase/database": "2.1.31",
|
|
20
|
+
"@nocobase/evaluators": "2.1.31",
|
|
21
|
+
"@nocobase/lock-manager": "2.1.31",
|
|
22
|
+
"@nocobase/logger": "2.1.31",
|
|
23
|
+
"@nocobase/resourcer": "2.1.31",
|
|
24
|
+
"@nocobase/sdk": "2.1.31",
|
|
25
|
+
"@nocobase/snowflake-id": "2.1.31",
|
|
26
|
+
"@nocobase/telemetry": "2.1.31",
|
|
27
|
+
"@nocobase/utils": "2.1.31",
|
|
28
28
|
"@types/decompress": "4.2.7",
|
|
29
29
|
"@types/ini": "^1.3.31",
|
|
30
30
|
"@types/koa-send": "^4.1.3",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"@types/serve-handler": "^6.1.1",
|
|
62
62
|
"@types/ws": "^8.5.5"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "b5d46b76adb72b4fa736dd0e6c89d8a0bc83bfe8"
|
|
65
65
|
}
|