@nocobase/server 1.6.0-alpha.14 → 1.6.0-alpha.15

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.
@@ -45,6 +45,7 @@ export declare class WSServer extends EventEmitter {
45
45
  tagName: string;
46
46
  tagValue: string;
47
47
  }>, sendMessage: object): void;
48
+ sendToClient(clientId: string, sendMessage: object): void;
48
49
  loopThroughConnections(callback: (client: WebSocketClient) => void): void;
49
50
  close(): void;
50
51
  }
@@ -172,6 +172,9 @@ const _WSServer = class _WSServer extends import_events.default {
172
172
  message
173
173
  );
174
174
  });
175
+ app.on("ws:sendToClient", ({ clientId, message }) => {
176
+ this.sendToClient(clientId, message);
177
+ });
175
178
  app.on("ws:sendToCurrentApp", ({ message }) => {
176
179
  this.sendToConnectionsByTag("app", app.name, message);
177
180
  });
@@ -179,13 +182,7 @@ const _WSServer = class _WSServer extends import_events.default {
179
182
  this.sendToConnectionsByTags(tags, message);
180
183
  });
181
184
  app.on("ws:authorized", ({ clientId, userId }) => {
182
- this.sendToConnectionsByTags(
183
- [
184
- { tagName: "userId", tagValue: userId },
185
- { tagName: "app", tagValue: app.name }
186
- ],
187
- { type: "authorized" }
188
- );
185
+ this.sendToClient(clientId, { type: "authorized" });
189
186
  });
190
187
  }
191
188
  addNewConnection(ws, request) {
@@ -254,6 +251,12 @@ const _WSServer = class _WSServer extends import_events.default {
254
251
  }
255
252
  });
256
253
  }
254
+ sendToClient(clientId, sendMessage) {
255
+ const client = this.webSocketClients.get(clientId);
256
+ if (client) {
257
+ this.sendMessageToConnection(client, sendMessage);
258
+ }
259
+ }
257
260
  loopThroughConnections(callback) {
258
261
  this.webSocketClients.forEach((client) => {
259
262
  callback(client);
@@ -89,9 +89,9 @@ export declare class PluginManager {
89
89
  addPreset(plugin: string | typeof Plugin, options?: any): void;
90
90
  getPlugins(): Map<typeof Plugin, Plugin<any>>;
91
91
  getAliases(): IterableIterator<string>;
92
- get(name: string | typeof Plugin): Plugin<any>;
92
+ get<T extends Plugin>(name: string | typeof Plugin | (new () => T)): T;
93
93
  has(name: string | typeof Plugin): boolean;
94
- del(name: string | typeof Plugin): void;
94
+ del(name: any): void;
95
95
  create(pluginName: string, options?: {
96
96
  forceRecreate?: boolean;
97
97
  }): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/server",
3
- "version": "1.6.0-alpha.14",
3
+ "version": "1.6.0-alpha.15",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "license": "AGPL-3.0",
@@ -10,19 +10,19 @@
10
10
  "@koa/cors": "^3.1.0",
11
11
  "@koa/multer": "^3.0.2",
12
12
  "@koa/router": "^9.4.0",
13
- "@nocobase/acl": "1.6.0-alpha.14",
14
- "@nocobase/actions": "1.6.0-alpha.14",
15
- "@nocobase/auth": "1.6.0-alpha.14",
16
- "@nocobase/cache": "1.6.0-alpha.14",
17
- "@nocobase/data-source-manager": "1.6.0-alpha.14",
18
- "@nocobase/database": "1.6.0-alpha.14",
19
- "@nocobase/evaluators": "1.6.0-alpha.14",
20
- "@nocobase/lock-manager": "1.6.0-alpha.14",
21
- "@nocobase/logger": "1.6.0-alpha.14",
22
- "@nocobase/resourcer": "1.6.0-alpha.14",
23
- "@nocobase/sdk": "1.6.0-alpha.14",
24
- "@nocobase/telemetry": "1.6.0-alpha.14",
25
- "@nocobase/utils": "1.6.0-alpha.14",
13
+ "@nocobase/acl": "1.6.0-alpha.15",
14
+ "@nocobase/actions": "1.6.0-alpha.15",
15
+ "@nocobase/auth": "1.6.0-alpha.15",
16
+ "@nocobase/cache": "1.6.0-alpha.15",
17
+ "@nocobase/data-source-manager": "1.6.0-alpha.15",
18
+ "@nocobase/database": "1.6.0-alpha.15",
19
+ "@nocobase/evaluators": "1.6.0-alpha.15",
20
+ "@nocobase/lock-manager": "1.6.0-alpha.15",
21
+ "@nocobase/logger": "1.6.0-alpha.15",
22
+ "@nocobase/resourcer": "1.6.0-alpha.15",
23
+ "@nocobase/sdk": "1.6.0-alpha.15",
24
+ "@nocobase/telemetry": "1.6.0-alpha.15",
25
+ "@nocobase/utils": "1.6.0-alpha.15",
26
26
  "@types/decompress": "4.2.7",
27
27
  "@types/ini": "^1.3.31",
28
28
  "@types/koa-send": "^4.1.3",
@@ -56,5 +56,5 @@
56
56
  "@types/serve-handler": "^6.1.1",
57
57
  "@types/ws": "^8.5.5"
58
58
  },
59
- "gitHead": "1bf7648d7cf62fadef4e31535b4907046a952b4a"
59
+ "gitHead": "4005cfd4876717aad16e0528513ee682a32d920a"
60
60
  }