@nocobase/server 1.4.0-alpha.9 → 1.5.0-alpha.1

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.
@@ -16,6 +16,7 @@ import { Logger, LoggerOptions, RequestLoggerOptions, SystemLogger, SystemLogger
16
16
  import { ResourceOptions, Resourcer } from '@nocobase/resourcer';
17
17
  import { Telemetry, TelemetryOptions } from '@nocobase/telemetry';
18
18
  import { AsyncEmitter, ToposortOptions } from '@nocobase/utils';
19
+ import { LockManager, LockManagerOptions } from '@nocobase/lock-manager';
19
20
  import { Command, CommandOptions, ParseOptions } from 'commander';
20
21
  import { IncomingMessage, ServerResponse } from 'http';
21
22
  import { i18n, InitOptions } from 'i18next';
@@ -28,7 +29,8 @@ import { ApplicationVersion } from './helpers/application-version';
28
29
  import { Locale } from './locale';
29
30
  import { Plugin } from './plugin';
30
31
  import { InstallOptions, PluginManager } from './plugin-manager';
31
- import { SyncManager } from './sync-manager';
32
+ import { PubSubManager, PubSubManagerOptions } from './pub-sub-manager';
33
+ import { SyncMessageManager } from './sync-message-manager';
32
34
  export type PluginType = string | typeof Plugin;
33
35
  export type PluginConfiguration = PluginType | [PluginType, any];
34
36
  export interface ResourceManagerOptions {
@@ -58,6 +60,8 @@ export interface ApplicationOptions {
58
60
  */
59
61
  resourcer?: ResourceManagerOptions;
60
62
  resourceManager?: ResourceManagerOptions;
63
+ pubSubManager?: PubSubManagerOptions;
64
+ syncMessageManager?: any;
61
65
  bodyParser?: any;
62
66
  cors?: any;
63
67
  dataWrapping?: boolean;
@@ -72,6 +76,7 @@ export interface ApplicationOptions {
72
76
  pmSock?: string;
73
77
  name?: string;
74
78
  authManager?: AuthManagerOptions;
79
+ lockManager?: LockManagerOptions;
75
80
  /**
76
81
  * @internal
77
82
  */
@@ -152,7 +157,8 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
152
157
  /**
153
158
  * @internal
154
159
  */
155
- syncManager: SyncManager;
160
+ pubSubManager: PubSubManager;
161
+ syncMessageManager: SyncMessageManager;
156
162
  requestLogger: Logger;
157
163
  protected plugins: Map<string, Plugin<any>>;
158
164
  protected _appSupervisor: AppSupervisor;
@@ -161,6 +167,7 @@ export declare class Application<StateT = DefaultState, ContextT = DefaultContex
161
167
  private _maintainingCommandStatus;
162
168
  private _maintainingStatusBeforeCommand;
163
169
  private _actionCommand;
170
+ lockManager: LockManager;
164
171
  constructor(options: ApplicationOptions);
165
172
  private static staticCommands;
166
173
  static addCommand(callback: (app: Application) => void): void;
@@ -50,6 +50,7 @@ var import_database = __toESM(require("@nocobase/database"));
50
50
  var import_logger = require("@nocobase/logger");
51
51
  var import_telemetry = require("@nocobase/telemetry");
52
52
  var import_utils = require("@nocobase/utils");
53
+ var import_lock_manager = require("@nocobase/lock-manager");
53
54
  var import_crypto = require("crypto");
54
55
  var import_glob = __toESM(require("glob"));
55
56
  var import_koa = __toESM(require("koa"));
@@ -72,7 +73,8 @@ var import_middlewares = require("./middlewares");
72
73
  var import_data_template = require("./middlewares/data-template");
73
74
  var import_validate_filter_params = __toESM(require("./middlewares/validate-filter-params"));
74
75
  var import_plugin_manager = require("./plugin-manager");
75
- var import_sync_manager = require("./sync-manager");
76
+ var import_pub_sub_manager = require("./pub-sub-manager");
77
+ var import_sync_message_manager = require("./sync-message-manager");
76
78
  var import_package = __toESM(require("../package.json"));
77
79
  const _Application = class _Application extends import_koa.default {
78
80
  constructor(options) {
@@ -112,7 +114,8 @@ const _Application = class _Application extends import_koa.default {
112
114
  /**
113
115
  * @internal
114
116
  */
115
- syncManager;
117
+ pubSubManager;
118
+ syncMessageManager;
116
119
  requestLogger;
117
120
  plugins = /* @__PURE__ */ new Map();
118
121
  _appSupervisor = import_app_supervisor.AppSupervisor.getInstance();
@@ -121,6 +124,7 @@ const _Application = class _Application extends import_koa.default {
121
124
  _maintainingCommandStatus;
122
125
  _maintainingStatusBeforeCommand;
123
126
  _actionCommand;
127
+ lockManager;
124
128
  static addCommand(callback) {
125
129
  this.staticCommands.push(callback);
126
130
  }
@@ -346,6 +350,9 @@ const _Application = class _Application extends import_koa.default {
346
350
  if (this.cacheManager) {
347
351
  await this.cacheManager.close();
348
352
  }
353
+ if (this.pubSubManager) {
354
+ await this.pubSubManager.close();
355
+ }
349
356
  if (this.telemetry.started) {
350
357
  await this.telemetry.shutdown();
351
358
  }
@@ -820,7 +827,12 @@ const _Application = class _Application extends import_koa.default {
820
827
  this._cronJobManager = new import_cron_job_manager.CronJobManager(this);
821
828
  this._cli = this.createCLI();
822
829
  this._i18n = (0, import_helper.createI18n)(options);
823
- this.syncManager = new import_sync_manager.SyncManager(this);
830
+ this.pubSubManager = (0, import_pub_sub_manager.createPubSubManager)(this, options.pubSubManager);
831
+ this.syncMessageManager = new import_sync_message_manager.SyncMessageManager(this, options.syncMessageManager);
832
+ this.lockManager = new import_lock_manager.LockManager({
833
+ defaultAdapter: process.env.LOCK_ADAPTER_DEFAULT,
834
+ ...options.lockManager
835
+ });
824
836
  this.context.db = this.db;
825
837
  this.context.resourcer = this.resourceManager;
826
838
  this.context.resourceManager = this.resourceManager;
package/lib/index.d.ts CHANGED
@@ -14,7 +14,7 @@ export * as middlewares from './middlewares';
14
14
  export * from './migration';
15
15
  export * from './plugin';
16
16
  export * from './plugin-manager';
17
- export * from './sync-manager';
17
+ export * from './pub-sub-manager';
18
18
  export declare const OFFICIAL_PLUGIN_PREFIX = "@nocobase/plugin-";
19
19
  export { appendToBuiltInPlugins, findAllPlugins, findBuiltInPlugins, findLocalPlugins, packageNameTrim, } from './plugin-manager/findPackageNames';
20
20
  export { runPluginStaticImports } from './run-plugin-static-imports';
package/lib/index.js CHANGED
@@ -56,7 +56,7 @@ var middlewares = __toESM(require("./middlewares"));
56
56
  __reExport(src_exports, require("./migration"), module.exports);
57
57
  __reExport(src_exports, require("./plugin"), module.exports);
58
58
  __reExport(src_exports, require("./plugin-manager"), module.exports);
59
- __reExport(src_exports, require("./sync-manager"), module.exports);
59
+ __reExport(src_exports, require("./pub-sub-manager"), module.exports);
60
60
  var import_findPackageNames = require("./plugin-manager/findPackageNames");
61
61
  var import_run_plugin_static_imports = require("./run-plugin-static-imports");
62
62
  const OFFICIAL_PLUGIN_PREFIX = "@nocobase/plugin-";
@@ -76,5 +76,5 @@ const OFFICIAL_PLUGIN_PREFIX = "@nocobase/plugin-";
76
76
  ...require("./migration"),
77
77
  ...require("./plugin"),
78
78
  ...require("./plugin-manager"),
79
- ...require("./sync-manager")
79
+ ...require("./pub-sub-manager")
80
80
  });
@@ -25,6 +25,7 @@ export declare class Locale {
25
25
  resourceStorers: Registry<ResourceStorer>;
26
26
  constructor(app: Application);
27
27
  load(): Promise<void>;
28
+ reset(): Promise<void>;
28
29
  reload(): Promise<void>;
29
30
  setLocaleFn(name: string, fn: (lang: string) => Promise<any>): void;
30
31
  registerResourceStorer(name: string, storer: ResourceStorer): void;
@@ -61,6 +61,13 @@ const _Locale = class _Locale {
61
61
  this.app.log.debug("locale resource loaded", { submodule: "locale", method: "onAfterLoad" });
62
62
  this.app.setMaintainingMessage("locale resource loaded");
63
63
  });
64
+ this.app.syncMessageManager.subscribe("localeManager", async (message) => {
65
+ switch (message.type) {
66
+ case "reload":
67
+ await this.reset();
68
+ return;
69
+ }
70
+ });
64
71
  }
65
72
  async load() {
66
73
  this.cache = await this.app.cacheManager.createCache({
@@ -70,11 +77,15 @@ const _Locale = class _Locale {
70
77
  });
71
78
  await this.get(this.defaultLang);
72
79
  }
73
- async reload() {
80
+ async reset() {
74
81
  const storers = Array.from(this.resourceStorers.getValues());
75
82
  const promises = storers.map((storer) => storer.reset());
76
83
  await Promise.all([this.cache.reset(), ...promises]);
77
84
  }
85
+ async reload() {
86
+ await this.reset();
87
+ this.app.syncMessageManager.publish("localeManager", { type: "reload" });
88
+ }
78
89
  setLocaleFn(name, fn) {
79
90
  this.localeFn.set(name, fn);
80
91
  }
@@ -39,7 +39,7 @@ const deps = {
39
39
  "cache-manager": "5.x",
40
40
  sequelize: "6.x",
41
41
  umzug: "3.x",
42
- "async-mutex": "0.3.x",
42
+ "async-mutex": "0.5.x",
43
43
  "@formulajs/formulajs": "4.x",
44
44
  mathjs: "10.x",
45
45
  winston: "3.x",
package/lib/plugin.d.ts CHANGED
@@ -6,12 +6,11 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
- import { Model } from '@nocobase/database';
9
+ import { Model, Transactionable } from '@nocobase/database';
10
10
  import { LoggerOptions } from '@nocobase/logger';
11
11
  import type { TFuncKey, TOptions } from 'i18next';
12
12
  import { Application } from './application';
13
13
  import { InstallOptions } from './plugin-manager';
14
- import { SyncMessageData } from './sync-manager';
15
14
  export interface PluginInterface {
16
15
  beforeLoad?: () => void;
17
16
  load(): any;
@@ -66,16 +65,8 @@ export declare abstract class Plugin<O = any> implements PluginInterface {
66
65
  afterDisable(): Promise<void>;
67
66
  beforeRemove(): Promise<void>;
68
67
  afterRemove(): Promise<void>;
69
- /**
70
- * Fired when a sync message is received.
71
- * @experimental
72
- */
73
- onSync(message?: SyncMessageData): Promise<void> | void;
74
- /**
75
- * Publish a sync message.
76
- * @experimental
77
- */
78
- sync(message?: SyncMessageData): void;
68
+ handleSyncMessage(message: any): Promise<void>;
69
+ sendSyncMessage(message: any, options?: Transactionable): Promise<void>;
79
70
  /**
80
71
  * @deprecated
81
72
  */
@@ -92,7 +83,6 @@ export declare abstract class Plugin<O = any> implements PluginInterface {
92
83
  afterSync: any[];
93
84
  afterLoad: any[];
94
85
  }>;
95
- private getPluginBasePath;
96
86
  /**
97
87
  * @internal
98
88
  */
@@ -106,5 +96,6 @@ export declare abstract class Plugin<O = any> implements PluginInterface {
106
96
  * @experimental
107
97
  */
108
98
  toJSON(options?: any): Promise<any>;
99
+ private getPluginBasePath;
109
100
  }
110
101
  export default Plugin;
package/lib/plugin.js CHANGED
@@ -124,18 +124,13 @@ const _Plugin = class _Plugin {
124
124
  }
125
125
  async afterRemove() {
126
126
  }
127
- /**
128
- * Fired when a sync message is received.
129
- * @experimental
130
- */
131
- onSync(message = {}) {
127
+ async handleSyncMessage(message) {
132
128
  }
133
- /**
134
- * Publish a sync message.
135
- * @experimental
136
- */
137
- sync(message) {
138
- this.app.syncManager.publish(this.name, message);
129
+ async sendSyncMessage(message, options) {
130
+ if (!this.name) {
131
+ throw new Error(`plugin name invalid`);
132
+ }
133
+ await this.app.syncMessageManager.publish(this.name, message, options);
139
134
  }
140
135
  /**
141
136
  * @deprecated
@@ -166,12 +161,6 @@ const _Plugin = class _Plugin {
166
161
  }
167
162
  });
168
163
  }
169
- async getPluginBasePath() {
170
- if (!this.options.packageName) {
171
- return;
172
- }
173
- return (0, import_utils2.getPluginBasePath)(this.options.packageName);
174
- }
175
164
  /**
176
165
  * @internal
177
166
  */
@@ -231,6 +220,12 @@ const _Plugin = class _Plugin {
231
220
  }
232
221
  return results;
233
222
  }
223
+ async getPluginBasePath() {
224
+ if (!this.options.packageName) {
225
+ return;
226
+ }
227
+ return (0, import_utils2.getPluginBasePath)(this.options.packageName);
228
+ }
234
229
  };
235
230
  __name(_Plugin, "Plugin");
236
231
  let Plugin = _Plugin;
@@ -0,0 +1,34 @@
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 { type PubSubManagerSubscribeOptions } from './types';
10
+ export declare class HandlerManager {
11
+ protected publisherId: string;
12
+ handlers: Map<any, any>;
13
+ uniqueMessageHandlers: Map<any, any>;
14
+ constructor(publisherId: string);
15
+ protected getMessageHash(message: any): Promise<string>;
16
+ protected verifyMessage({ onlySelf, skipSelf, publisherId }: {
17
+ onlySelf: any;
18
+ skipSelf: any;
19
+ publisherId: any;
20
+ }): boolean;
21
+ protected debounce(func: any, wait: number): any;
22
+ handleMessage({ channel, message, callback, debounce }: {
23
+ channel: any;
24
+ message: any;
25
+ callback: any;
26
+ debounce: any;
27
+ }): Promise<void>;
28
+ wrapper(channel: any, callback: any, options: any): (wrappedMessage: any) => Promise<void>;
29
+ set(channel: string, callback: any, options: PubSubManagerSubscribeOptions): (wrappedMessage: any) => Promise<void>;
30
+ get(channel: string, callback: any): any;
31
+ delete(channel: string, callback: any): any;
32
+ reset(): void;
33
+ each(callback: any): Promise<void>;
34
+ }
@@ -0,0 +1,149 @@
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 handler_manager_exports = {};
39
+ __export(handler_manager_exports, {
40
+ HandlerManager: () => HandlerManager
41
+ });
42
+ module.exports = __toCommonJS(handler_manager_exports);
43
+ var import_node_crypto = __toESM(require("node:crypto"));
44
+ var import_lodash = __toESM(require("lodash"));
45
+ const _HandlerManager = class _HandlerManager {
46
+ constructor(publisherId) {
47
+ this.publisherId = publisherId;
48
+ this.reset();
49
+ }
50
+ handlers;
51
+ uniqueMessageHandlers;
52
+ async getMessageHash(message) {
53
+ const encoder = new TextEncoder();
54
+ const data = encoder.encode(JSON.stringify(message));
55
+ const hashBuffer = await import_node_crypto.default.subtle.digest("SHA-256", data);
56
+ const hashArray = Array.from(new Uint8Array(hashBuffer));
57
+ const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
58
+ return hashHex;
59
+ }
60
+ verifyMessage({ onlySelf, skipSelf, publisherId }) {
61
+ if (onlySelf && publisherId !== this.publisherId) {
62
+ return;
63
+ } else if (!onlySelf && skipSelf && publisherId === this.publisherId) {
64
+ return;
65
+ }
66
+ return true;
67
+ }
68
+ debounce(func, wait) {
69
+ if (wait) {
70
+ return import_lodash.default.debounce(func, wait);
71
+ }
72
+ return func;
73
+ }
74
+ async handleMessage({ channel, message, callback, debounce }) {
75
+ if (!debounce) {
76
+ await callback(message);
77
+ return;
78
+ }
79
+ const messageHash = channel + await this.getMessageHash(message);
80
+ if (!this.uniqueMessageHandlers.has(messageHash)) {
81
+ this.uniqueMessageHandlers.set(messageHash, this.debounce(callback, debounce));
82
+ }
83
+ const handler = this.uniqueMessageHandlers.get(messageHash);
84
+ try {
85
+ await handler(message);
86
+ setTimeout(() => {
87
+ this.uniqueMessageHandlers.delete(messageHash);
88
+ }, debounce);
89
+ } catch (error) {
90
+ this.uniqueMessageHandlers.delete(messageHash);
91
+ throw error;
92
+ }
93
+ }
94
+ wrapper(channel, callback, options) {
95
+ const { debounce = 0 } = options;
96
+ return async (wrappedMessage) => {
97
+ const json = JSON.parse(wrappedMessage);
98
+ if (!this.verifyMessage(json)) {
99
+ return;
100
+ }
101
+ await this.handleMessage({ channel, message: json.message, debounce, callback });
102
+ };
103
+ }
104
+ set(channel, callback, options) {
105
+ if (!this.handlers.has(channel)) {
106
+ this.handlers.set(channel, /* @__PURE__ */ new Map());
107
+ }
108
+ const headlerMap = this.handlers.get(channel);
109
+ const headler = this.wrapper(channel, callback, options);
110
+ headlerMap.set(callback, headler);
111
+ return headler;
112
+ }
113
+ get(channel, callback) {
114
+ const headlerMap = this.handlers.get(channel);
115
+ if (!headlerMap) {
116
+ return;
117
+ }
118
+ return headlerMap.get(callback);
119
+ }
120
+ delete(channel, callback) {
121
+ if (!callback) {
122
+ return;
123
+ }
124
+ const headlerMap = this.handlers.get(channel);
125
+ if (!headlerMap) {
126
+ return;
127
+ }
128
+ const headler = headlerMap.get(callback);
129
+ headlerMap.delete(callback);
130
+ return headler;
131
+ }
132
+ reset() {
133
+ this.handlers = /* @__PURE__ */ new Map();
134
+ this.uniqueMessageHandlers = /* @__PURE__ */ new Map();
135
+ }
136
+ async each(callback) {
137
+ for (const [channel, headlerMap] of this.handlers) {
138
+ for (const headler of headlerMap.values()) {
139
+ await callback(channel, headler);
140
+ }
141
+ }
142
+ }
143
+ };
144
+ __name(_HandlerManager, "HandlerManager");
145
+ let HandlerManager = _HandlerManager;
146
+ // Annotate the CommonJS export names for ESM import in node:
147
+ 0 && (module.exports = {
148
+ HandlerManager
149
+ });
@@ -0,0 +1,11 @@
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 './handler-manager';
10
+ export * from './pub-sub-manager';
11
+ export * from './types';
@@ -0,0 +1,34 @@
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 pub_sub_manager_exports = {};
25
+ module.exports = __toCommonJS(pub_sub_manager_exports);
26
+ __reExport(pub_sub_manager_exports, require("./handler-manager"), module.exports);
27
+ __reExport(pub_sub_manager_exports, require("./pub-sub-manager"), module.exports);
28
+ __reExport(pub_sub_manager_exports, require("./types"), module.exports);
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ ...require("./handler-manager"),
32
+ ...require("./pub-sub-manager"),
33
+ ...require("./types")
34
+ });
@@ -0,0 +1,27 @@
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 { HandlerManager } from './handler-manager';
11
+ import { PubSubCallback, type IPubSubAdapter, type PubSubManagerOptions, type PubSubManagerPublishOptions, type PubSubManagerSubscribeOptions } from './types';
12
+ export declare const createPubSubManager: (app: Application, options: PubSubManagerOptions) => PubSubManager;
13
+ export declare class PubSubManager {
14
+ protected options: PubSubManagerOptions;
15
+ protected publisherId: string;
16
+ protected adapter: IPubSubAdapter;
17
+ protected handlerManager: HandlerManager;
18
+ constructor(options?: PubSubManagerOptions);
19
+ get channelPrefix(): string;
20
+ setAdapter(adapter: IPubSubAdapter): void;
21
+ isConnected(): Promise<boolean>;
22
+ connect(): Promise<void>;
23
+ close(): Promise<any>;
24
+ subscribe(channel: string, callback: PubSubCallback, options?: PubSubManagerSubscribeOptions): Promise<void>;
25
+ unsubscribe(channel: string, callback: PubSubCallback): Promise<any>;
26
+ publish(channel: string, message: any, options?: PubSubManagerPublishOptions): Promise<any>;
27
+ }
@@ -0,0 +1,116 @@
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 pub_sub_manager_exports = {};
29
+ __export(pub_sub_manager_exports, {
30
+ PubSubManager: () => PubSubManager,
31
+ createPubSubManager: () => createPubSubManager
32
+ });
33
+ module.exports = __toCommonJS(pub_sub_manager_exports);
34
+ var import_utils = require("@nocobase/utils");
35
+ var import_handler_manager = require("./handler-manager");
36
+ const createPubSubManager = /* @__PURE__ */ __name((app, options) => {
37
+ const pubSubManager = new PubSubManager(options);
38
+ app.on("afterStart", async () => {
39
+ await pubSubManager.connect();
40
+ });
41
+ app.on("afterStop", async () => {
42
+ await pubSubManager.close();
43
+ });
44
+ return pubSubManager;
45
+ }, "createPubSubManager");
46
+ const _PubSubManager = class _PubSubManager {
47
+ constructor(options = {}) {
48
+ this.options = options;
49
+ this.publisherId = (0, import_utils.uid)();
50
+ this.handlerManager = new import_handler_manager.HandlerManager(this.publisherId);
51
+ }
52
+ publisherId;
53
+ adapter;
54
+ handlerManager;
55
+ get channelPrefix() {
56
+ var _a;
57
+ return ((_a = this.options) == null ? void 0 : _a.channelPrefix) ? `${this.options.channelPrefix}.` : "";
58
+ }
59
+ setAdapter(adapter) {
60
+ this.adapter = adapter;
61
+ }
62
+ async isConnected() {
63
+ if (this.adapter) {
64
+ return this.adapter.isConnected();
65
+ }
66
+ return false;
67
+ }
68
+ async connect() {
69
+ if (!this.adapter) {
70
+ return;
71
+ }
72
+ await this.adapter.connect();
73
+ await this.handlerManager.each(async (channel, headler) => {
74
+ await this.adapter.subscribe(`${this.channelPrefix}${channel}`, headler);
75
+ });
76
+ }
77
+ async close() {
78
+ if (!this.adapter) {
79
+ return;
80
+ }
81
+ return await this.adapter.close();
82
+ }
83
+ async subscribe(channel, callback, options = {}) {
84
+ await this.unsubscribe(channel, callback);
85
+ const handler = this.handlerManager.set(channel, callback, options);
86
+ if (await this.isConnected()) {
87
+ await this.adapter.subscribe(`${this.channelPrefix}${channel}`, handler);
88
+ }
89
+ }
90
+ async unsubscribe(channel, callback) {
91
+ const handler = this.handlerManager.delete(channel, callback);
92
+ if (!this.adapter || !handler) {
93
+ return;
94
+ }
95
+ return this.adapter.unsubscribe(`${this.channelPrefix}${channel}`, handler);
96
+ }
97
+ async publish(channel, message, options) {
98
+ var _a;
99
+ if (!((_a = this.adapter) == null ? void 0 : _a.isConnected())) {
100
+ return;
101
+ }
102
+ const wrappedMessage = JSON.stringify({
103
+ publisherId: this.publisherId,
104
+ ...options,
105
+ message
106
+ });
107
+ return this.adapter.publish(`${this.channelPrefix}${channel}`, wrappedMessage);
108
+ }
109
+ };
110
+ __name(_PubSubManager, "PubSubManager");
111
+ let PubSubManager = _PubSubManager;
112
+ // Annotate the CommonJS export names for ESM import in node:
113
+ 0 && (module.exports = {
114
+ PubSubManager,
115
+ createPubSubManager
116
+ });
@@ -0,0 +1,27 @@
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 interface PubSubManagerOptions {
10
+ channelPrefix?: string;
11
+ }
12
+ export interface PubSubManagerPublishOptions {
13
+ skipSelf?: boolean;
14
+ onlySelf?: boolean;
15
+ }
16
+ export interface PubSubManagerSubscribeOptions {
17
+ debounce?: number;
18
+ }
19
+ export type PubSubCallback = (message: any) => Promise<void>;
20
+ export interface IPubSubAdapter {
21
+ isConnected(): Promise<boolean> | boolean;
22
+ connect(): Promise<any>;
23
+ close(): Promise<any>;
24
+ subscribe(channel: string, callback: PubSubCallback): Promise<any>;
25
+ unsubscribe(channel: string, callback: PubSubCallback): Promise<any>;
26
+ publish(channel: string, message: string): Promise<any>;
27
+ }
@@ -0,0 +1,24 @@
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
+ var types_exports = {};
24
+ module.exports = __toCommonJS(types_exports);
@@ -0,0 +1,25 @@
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 { Transactionable } from '@nocobase/database';
10
+ import Application from './application';
11
+ import { PubSubCallback, PubSubManager, PubSubManagerPublishOptions } from './pub-sub-manager';
12
+ export declare class SyncMessageManager {
13
+ protected app: Application;
14
+ protected options: any;
15
+ protected versionManager: SyncMessageVersionManager;
16
+ protected pubSubManager: PubSubManager;
17
+ constructor(app: Application, options?: any);
18
+ get debounce(): any;
19
+ publish(channel: string, message: any, options?: PubSubManagerPublishOptions & Transactionable): Promise<any>;
20
+ subscribe(channel: string, callback: PubSubCallback): Promise<void>;
21
+ unsubscribe(channel: string, callback: PubSubCallback): Promise<any>;
22
+ sync(): Promise<void>;
23
+ }
24
+ export declare class SyncMessageVersionManager {
25
+ }
@@ -0,0 +1,105 @@
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 sync_message_manager_exports = {};
29
+ __export(sync_message_manager_exports, {
30
+ SyncMessageManager: () => SyncMessageManager,
31
+ SyncMessageVersionManager: () => SyncMessageVersionManager
32
+ });
33
+ module.exports = __toCommonJS(sync_message_manager_exports);
34
+ const _SyncMessageManager = class _SyncMessageManager {
35
+ constructor(app, options = {}) {
36
+ this.app = app;
37
+ this.options = options;
38
+ this.versionManager = new SyncMessageVersionManager();
39
+ app.on("beforeLoadPlugin", async (plugin) => {
40
+ if (!plugin.name) {
41
+ return;
42
+ }
43
+ await this.subscribe(plugin.name, plugin.handleSyncMessage.bind(plugin));
44
+ });
45
+ }
46
+ versionManager;
47
+ pubSubManager;
48
+ get debounce() {
49
+ return this.options.debounce || 1e3;
50
+ }
51
+ async publish(channel, message, options) {
52
+ const { transaction, ...others } = options || {};
53
+ if (transaction) {
54
+ return await new Promise((resolve, reject) => {
55
+ const timer = setTimeout(() => {
56
+ reject(
57
+ new Error(
58
+ `Publish message to ${channel} timeout, channel: ${channel}, message: ${JSON.stringify(message)}`
59
+ )
60
+ );
61
+ }, 5e4);
62
+ transaction.afterCommit(async () => {
63
+ try {
64
+ const r = await this.app.pubSubManager.publish(`${this.app.name}.sync.${channel}`, message, {
65
+ skipSelf: true,
66
+ ...others
67
+ });
68
+ resolve(r);
69
+ } catch (error) {
70
+ reject(error);
71
+ } finally {
72
+ clearTimeout(timer);
73
+ }
74
+ });
75
+ });
76
+ } else {
77
+ return await this.app.pubSubManager.publish(`${this.app.name}.sync.${channel}`, message, {
78
+ skipSelf: true,
79
+ ...options
80
+ });
81
+ }
82
+ }
83
+ async subscribe(channel, callback) {
84
+ return await this.app.pubSubManager.subscribe(`${this.app.name}.sync.${channel}`, callback, {
85
+ debounce: this.debounce
86
+ });
87
+ }
88
+ async unsubscribe(channel, callback) {
89
+ return this.app.pubSubManager.unsubscribe(`${this.app.name}.sync.${channel}`, callback);
90
+ }
91
+ async sync() {
92
+ }
93
+ };
94
+ __name(_SyncMessageManager, "SyncMessageManager");
95
+ let SyncMessageManager = _SyncMessageManager;
96
+ const _SyncMessageVersionManager = class _SyncMessageVersionManager {
97
+ // TODO
98
+ };
99
+ __name(_SyncMessageVersionManager, "SyncMessageVersionManager");
100
+ let SyncMessageVersionManager = _SyncMessageVersionManager;
101
+ // Annotate the CommonJS export names for ESM import in node:
102
+ 0 && (module.exports = {
103
+ SyncMessageManager,
104
+ SyncMessageVersionManager
105
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/server",
3
- "version": "1.4.0-alpha.9",
3
+ "version": "1.5.0-alpha.1",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "license": "AGPL-3.0",
@@ -10,22 +10,23 @@
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.4.0-alpha.9",
14
- "@nocobase/actions": "1.4.0-alpha.9",
15
- "@nocobase/auth": "1.4.0-alpha.9",
16
- "@nocobase/cache": "1.4.0-alpha.9",
17
- "@nocobase/data-source-manager": "1.4.0-alpha.9",
18
- "@nocobase/database": "1.4.0-alpha.9",
19
- "@nocobase/evaluators": "1.4.0-alpha.9",
20
- "@nocobase/logger": "1.4.0-alpha.9",
21
- "@nocobase/resourcer": "1.4.0-alpha.9",
22
- "@nocobase/sdk": "1.4.0-alpha.9",
23
- "@nocobase/telemetry": "1.4.0-alpha.9",
24
- "@nocobase/utils": "1.4.0-alpha.9",
13
+ "@nocobase/acl": "1.5.0-alpha.1",
14
+ "@nocobase/actions": "1.5.0-alpha.1",
15
+ "@nocobase/auth": "1.5.0-alpha.1",
16
+ "@nocobase/cache": "1.5.0-alpha.1",
17
+ "@nocobase/data-source-manager": "1.5.0-alpha.1",
18
+ "@nocobase/database": "1.5.0-alpha.1",
19
+ "@nocobase/evaluators": "1.5.0-alpha.1",
20
+ "@nocobase/logger": "1.5.0-alpha.1",
21
+ "@nocobase/resourcer": "1.5.0-alpha.1",
22
+ "@nocobase/sdk": "1.5.0-alpha.1",
23
+ "@nocobase/telemetry": "1.5.0-alpha.1",
24
+ "@nocobase/utils": "1.5.0-alpha.1",
25
25
  "@types/decompress": "4.2.7",
26
26
  "@types/ini": "^1.3.31",
27
27
  "@types/koa-send": "^4.1.3",
28
28
  "@types/multer": "^1.4.5",
29
+ "async-mutex": "^0.5.0",
29
30
  "axios": "^1.7.0",
30
31
  "chalk": "^4.1.1",
31
32
  "commander": "^9.2.0",
@@ -54,5 +55,5 @@
54
55
  "@types/serve-handler": "^6.1.1",
55
56
  "@types/ws": "^8.5.5"
56
57
  },
57
- "gitHead": "af26b630a5b590f986e21231f0db289c65dd7f70"
58
+ "gitHead": "abe58fad69534a13c2502a47da86425a597c3ba3"
58
59
  }
@@ -1,46 +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
- /// <reference types="node" />
10
- import EventEmitter from 'node:events';
11
- import Application from './application';
12
- export declare abstract class SyncAdapter extends EventEmitter {
13
- abstract get ready(): boolean;
14
- abstract publish(data: SyncMessage): void | Promise<void>;
15
- }
16
- export type SyncMessageData = Record<string, string>;
17
- export type SyncEventCallback = (message: SyncMessageData) => void;
18
- export type SyncMessage = {
19
- namespace: string;
20
- nodeId: string;
21
- appName: string;
22
- } & SyncMessageData;
23
- /**
24
- * @experimental
25
- */
26
- export declare class SyncManager {
27
- private app;
28
- private nodeId;
29
- private eventEmitter;
30
- private adapter;
31
- private incomingBuffer;
32
- private outgoingBuffer;
33
- private flushTimer;
34
- get available(): boolean;
35
- private onMessage;
36
- private onSync;
37
- private onReady;
38
- constructor(app: Application);
39
- init(adapter: SyncAdapter): void;
40
- subscribe(namespace: string, callback: SyncEventCallback): void;
41
- unsubscribe(namespace: string, callback: SyncEventCallback): void;
42
- /**
43
- * Publish a message to the sync manager
44
- */
45
- publish(namespace: string, data?: SyncMessageData): void | Promise<void>;
46
- }
@@ -1,137 +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 sync_manager_exports = {};
39
- __export(sync_manager_exports, {
40
- SyncAdapter: () => SyncAdapter,
41
- SyncManager: () => SyncManager
42
- });
43
- module.exports = __toCommonJS(sync_manager_exports);
44
- var import_node_crypto = require("node:crypto");
45
- var import_node_events = __toESM(require("node:events"));
46
- var import_lodash = require("lodash");
47
- const _SyncAdapter = class _SyncAdapter extends import_node_events.default {
48
- };
49
- __name(_SyncAdapter, "SyncAdapter");
50
- let SyncAdapter = _SyncAdapter;
51
- const _SyncManager = class _SyncManager {
52
- constructor(app) {
53
- this.app = app;
54
- this.nodeId = `${process.env.NODE_ID || (0, import_node_crypto.randomUUID)()}-${process.pid}`;
55
- }
56
- nodeId;
57
- eventEmitter = new import_node_events.default();
58
- adapter = null;
59
- incomingBuffer = [];
60
- outgoingBuffer = [];
61
- flushTimer = null;
62
- get available() {
63
- return this.adapter ? this.adapter.ready : false;
64
- }
65
- onMessage(namespace, message) {
66
- this.app.logger.info(`emit sync event in namespace ${namespace}`);
67
- this.eventEmitter.emit(namespace, message);
68
- const pluginInstance = this.app.pm.get(namespace);
69
- pluginInstance.onSync(message);
70
- }
71
- onSync = /* @__PURE__ */ __name((messages) => {
72
- this.app.logger.info("sync messages received, save into buffer:", messages);
73
- if (this.flushTimer) {
74
- clearTimeout(this.flushTimer);
75
- this.flushTimer = null;
76
- }
77
- this.incomingBuffer = (0, import_lodash.uniqWith)(
78
- this.incomingBuffer.concat(
79
- messages.filter((item) => item.nodeId !== this.nodeId && item.appName === this.app.name).map(({ nodeId, appName, ...message }) => message)
80
- ),
81
- import_lodash.isEqual
82
- );
83
- this.flushTimer = setTimeout(() => {
84
- this.incomingBuffer.forEach(({ namespace, ...message }) => {
85
- this.onMessage(namespace, message);
86
- });
87
- this.incomingBuffer = [];
88
- }, 1e3);
89
- }, "onSync");
90
- onReady = /* @__PURE__ */ __name(() => {
91
- while (this.outgoingBuffer.length) {
92
- const [namespace, data] = this.outgoingBuffer.shift();
93
- this.publish(namespace, data);
94
- }
95
- }, "onReady");
96
- init(adapter) {
97
- if (this.adapter) {
98
- throw new Error("sync adapter is already exists");
99
- }
100
- if (!adapter) {
101
- return;
102
- }
103
- this.adapter = adapter;
104
- this.adapter.on("message", this.onSync);
105
- this.adapter.on("ready", this.onReady);
106
- }
107
- subscribe(namespace, callback) {
108
- this.eventEmitter.on(namespace, callback);
109
- }
110
- unsubscribe(namespace, callback) {
111
- this.eventEmitter.off(namespace, callback);
112
- }
113
- /**
114
- * Publish a message to the sync manager
115
- */
116
- publish(namespace, data = {}) {
117
- if (!this.adapter) {
118
- return;
119
- }
120
- if (!this.adapter.ready) {
121
- this.outgoingBuffer.push([namespace, data]);
122
- this.app.logger.warn(`sync adapter is not ready for now, message will be send when it is ready`);
123
- return;
124
- }
125
- this.app.logger.info(`publishing sync message from #${this.nodeId} (${this.app.name}) in namespace ${namespace}:`, {
126
- data
127
- });
128
- return this.adapter.publish({ ...data, nodeId: this.nodeId, appName: this.app.name, namespace });
129
- }
130
- };
131
- __name(_SyncManager, "SyncManager");
132
- let SyncManager = _SyncManager;
133
- // Annotate the CommonJS export names for ESM import in node:
134
- 0 && (module.exports = {
135
- SyncAdapter,
136
- SyncManager
137
- });