@nocobase/server 1.9.2 → 1.9.4

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.
@@ -56,7 +56,7 @@ const availableActions = {
56
56
  update: {
57
57
  displayName: '{{t("Edit")}}',
58
58
  type: "old-data",
59
- aliases: ["update", "move", "add", "set", "remove", "toggle"],
59
+ aliases: ["update", "move"],
60
60
  allowConfigureFields: true
61
61
  },
62
62
  destroy: {
@@ -300,13 +300,13 @@ const _EventQueue = class _EventQueue {
300
300
  return this.adapter.isConnected();
301
301
  }
302
302
  async connect() {
303
- if (!this.adapter) {
304
- throw new Error("no adapter set, cannot connect");
305
- }
306
303
  if (!this.app.serving()) {
307
304
  this.app.logger.warn("app is not serving, will not connect to event queue");
308
305
  return;
309
306
  }
307
+ if (!this.adapter) {
308
+ throw new Error("no adapter set, cannot connect");
309
+ }
310
310
  await this.adapter.connect();
311
311
  this.app.logger.debug(`connected to adapter, using memory? ${this.adapter instanceof MemoryEventQueueAdapter}`);
312
312
  for (const [channel, event] of this.events.entries()) {
@@ -342,6 +342,10 @@ const _EventQueue = class _EventQueue {
342
342
  }
343
343
  }
344
344
  async publish(channel, message, options = {}) {
345
+ if (!this.app.serving()) {
346
+ this.app.logger.warn("app is not serving, will not publish message to event queue");
347
+ return;
348
+ }
345
349
  if (!this.adapter) {
346
350
  throw new Error("no adapter set, cannot publish");
347
351
  }
@@ -17,8 +17,8 @@ export declare class PubSubManager {
17
17
  protected adapter: IPubSubAdapter;
18
18
  protected handlerManager: HandlerManager;
19
19
  constructor(app: Application, options?: PubSubManagerOptions);
20
- get channelPrefix(): string;
21
20
  setAdapter(adapter: IPubSubAdapter): void;
21
+ getFullChannel(channel: string): string;
22
22
  isConnected(): Promise<boolean>;
23
23
  connect(): Promise<void>;
24
24
  close(): Promise<any>;
@@ -55,13 +55,13 @@ const _PubSubManager = class _PubSubManager {
55
55
  publisherId;
56
56
  adapter;
57
57
  handlerManager;
58
- get channelPrefix() {
59
- var _a;
60
- return ((_a = this.options) == null ? void 0 : _a.channelPrefix) ? `${this.options.channelPrefix}.` : "";
61
- }
62
58
  setAdapter(adapter) {
63
59
  this.adapter = adapter;
64
60
  }
61
+ getFullChannel(channel) {
62
+ var _a;
63
+ return [this.app.name, (_a = this.options) == null ? void 0 : _a.channelPrefix, channel].filter(Boolean).join(".");
64
+ }
65
65
  async isConnected() {
66
66
  if (this.adapter) {
67
67
  return this.adapter.isConnected();
@@ -79,7 +79,7 @@ const _PubSubManager = class _PubSubManager {
79
79
  await this.adapter.connect();
80
80
  await this.handlerManager.each(async (channel, headler) => {
81
81
  this.app.logger.debug(`[PubSubManager] subscribe ${channel} added before connected`);
82
- await this.adapter.subscribe(`${this.channelPrefix}${channel}`, headler);
82
+ await this.adapter.subscribe(this.getFullChannel(channel), headler);
83
83
  });
84
84
  }
85
85
  async close() {
@@ -93,7 +93,7 @@ const _PubSubManager = class _PubSubManager {
93
93
  const handler = this.handlerManager.set(channel, callback, options);
94
94
  if (await this.isConnected()) {
95
95
  this.app.logger.debug(`[PubSubManager] subscribe ${channel} added after connected`);
96
- await this.adapter.subscribe(`${this.channelPrefix}${channel}`, handler);
96
+ await this.adapter.subscribe(this.getFullChannel(channel), handler);
97
97
  }
98
98
  }
99
99
  async unsubscribe(channel, callback) {
@@ -101,7 +101,7 @@ const _PubSubManager = class _PubSubManager {
101
101
  if (!this.adapter || !handler) {
102
102
  return;
103
103
  }
104
- return this.adapter.unsubscribe(`${this.channelPrefix}${channel}`, handler);
104
+ return this.adapter.unsubscribe(this.getFullChannel(channel), handler);
105
105
  }
106
106
  async publish(channel, message, options) {
107
107
  var _a;
@@ -116,7 +116,7 @@ const _PubSubManager = class _PubSubManager {
116
116
  ...options,
117
117
  message
118
118
  });
119
- await this.adapter.publish(`${this.channelPrefix}${channel}`, wrappedMessage);
119
+ await this.adapter.publish(this.getFullChannel(channel), wrappedMessage);
120
120
  this.app.logger.trace(`[PubSubManager] published message to channel ${channel}`);
121
121
  }
122
122
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/server",
3
- "version": "1.9.2",
3
+ "version": "1.9.4",
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": "1.9.2",
14
- "@nocobase/actions": "1.9.2",
15
- "@nocobase/auth": "1.9.2",
16
- "@nocobase/cache": "1.9.2",
17
- "@nocobase/data-source-manager": "1.9.2",
18
- "@nocobase/database": "1.9.2",
19
- "@nocobase/evaluators": "1.9.2",
20
- "@nocobase/lock-manager": "1.9.2",
21
- "@nocobase/logger": "1.9.2",
22
- "@nocobase/resourcer": "1.9.2",
23
- "@nocobase/sdk": "1.9.2",
24
- "@nocobase/snowflake-id": "1.9.2",
25
- "@nocobase/telemetry": "1.9.2",
26
- "@nocobase/utils": "1.9.2",
13
+ "@nocobase/acl": "1.9.4",
14
+ "@nocobase/actions": "1.9.4",
15
+ "@nocobase/auth": "1.9.4",
16
+ "@nocobase/cache": "1.9.4",
17
+ "@nocobase/data-source-manager": "1.9.4",
18
+ "@nocobase/database": "1.9.4",
19
+ "@nocobase/evaluators": "1.9.4",
20
+ "@nocobase/lock-manager": "1.9.4",
21
+ "@nocobase/logger": "1.9.4",
22
+ "@nocobase/resourcer": "1.9.4",
23
+ "@nocobase/sdk": "1.9.4",
24
+ "@nocobase/snowflake-id": "1.9.4",
25
+ "@nocobase/telemetry": "1.9.4",
26
+ "@nocobase/utils": "1.9.4",
27
27
  "@types/decompress": "4.2.7",
28
28
  "@types/ini": "^1.3.31",
29
29
  "@types/koa-send": "^4.1.3",
@@ -59,5 +59,5 @@
59
59
  "@types/serve-handler": "^6.1.1",
60
60
  "@types/ws": "^8.5.5"
61
61
  },
62
- "gitHead": "2a511560ce123d02a20b2a7757133e25ac664614"
62
+ "gitHead": "7431e8b3b3b9e06c21b05dc0af68349f7cfbe04f"
63
63
  }