@nocobase/server 1.9.0-beta.1 → 1.9.0-beta.10

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/index.d.ts CHANGED
@@ -19,6 +19,8 @@ export * from './plugin-manager';
19
19
  export * from './pub-sub-manager';
20
20
  export * from './event-queue';
21
21
  export * from './background-job-manager';
22
+ export * from './worker-id-allocator';
23
+ export * from './redis-connection-manager';
22
24
  export declare const OFFICIAL_PLUGIN_PREFIX = "@nocobase/plugin-";
23
25
  export { appendToBuiltInPlugins, findAllPlugins, findBuiltInPlugins, findLocalPlugins, packageNameTrim, } from './plugin-manager/findPackageNames';
24
26
  export { runPluginStaticImports } from './run-plugin-static-imports';
package/lib/index.js CHANGED
@@ -61,6 +61,8 @@ __reExport(src_exports, require("./plugin-manager"), module.exports);
61
61
  __reExport(src_exports, require("./pub-sub-manager"), module.exports);
62
62
  __reExport(src_exports, require("./event-queue"), module.exports);
63
63
  __reExport(src_exports, require("./background-job-manager"), module.exports);
64
+ __reExport(src_exports, require("./worker-id-allocator"), module.exports);
65
+ __reExport(src_exports, require("./redis-connection-manager"), module.exports);
64
66
  var import_findPackageNames = require("./plugin-manager/findPackageNames");
65
67
  var import_run_plugin_static_imports = require("./run-plugin-static-imports");
66
68
  const OFFICIAL_PLUGIN_PREFIX = "@nocobase/plugin-";
@@ -84,5 +86,7 @@ const OFFICIAL_PLUGIN_PREFIX = "@nocobase/plugin-";
84
86
  ...require("./plugin-manager"),
85
87
  ...require("./pub-sub-manager"),
86
88
  ...require("./event-queue"),
87
- ...require("./background-job-manager")
89
+ ...require("./background-job-manager"),
90
+ ...require("./worker-id-allocator"),
91
+ ...require("./redis-connection-manager")
88
92
  });
@@ -46,7 +46,7 @@ const traverseHasMany = /* @__PURE__ */ __name((arr, { collection, exclude = [],
46
46
  if (!arr) {
47
47
  return arr;
48
48
  }
49
- return arr.map((item) => traverseJSON(item, { collection, exclude, include }));
49
+ return arr.map((item) => traverseJSON(item, { collection, exclude, include, isHasManyField: true }));
50
50
  }, "traverseHasMany");
51
51
  const traverseBelongsToMany = /* @__PURE__ */ __name((arr, { collection, exclude = [], through }) => {
52
52
  if (!arr) {
@@ -107,7 +107,10 @@ const traverseJSON = /* @__PURE__ */ __name((data, options) => {
107
107
  if (field.options.isForeignKey) {
108
108
  continue;
109
109
  }
110
- if (["sort", "password", "sequence"].includes(field.type)) {
110
+ if (!options.isHasManyField && ["sort"].includes(field.type)) {
111
+ continue;
112
+ }
113
+ if (["password", "sequence"].includes(field.type)) {
111
114
  continue;
112
115
  }
113
116
  if (field.type === "hasOne") {
@@ -0,0 +1,14 @@
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 { Migration } from '../migration';
10
+ export default class extends Migration {
11
+ on: string;
12
+ appVersion: string;
13
+ up(): Promise<void>;
14
+ }
@@ -0,0 +1,126 @@
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 update_primary_keys_exports = {};
29
+ __export(update_primary_keys_exports, {
30
+ default: () => update_primary_keys_default
31
+ });
32
+ module.exports = __toCommonJS(update_primary_keys_exports);
33
+ var import_sequelize = require("sequelize");
34
+ var import_migration = require("../migration");
35
+ const collections = [
36
+ "departments",
37
+ "desktopRoutes",
38
+ "mobileRoutes",
39
+ "collectionCategories",
40
+ "dataSourcesRolesResources",
41
+ "dataSourcesRolesResourcesActions",
42
+ "dataSourcesRolesResourcesScopes",
43
+ "storages",
44
+ "workflows",
45
+ "flow_nodes",
46
+ "executions",
47
+ "userWokrflowTasks",
48
+ "workflowCategories",
49
+ "approvalExecutions",
50
+ "approvalRecords",
51
+ "approvals",
52
+ "workflowManualTasks",
53
+ "workflowCcTasks",
54
+ "approvalMsgTpls",
55
+ "mailAccounts",
56
+ "mailSettings"
57
+ ];
58
+ const _update_primary_keys_default = class _update_primary_keys_default extends import_migration.Migration {
59
+ on = "afterLoad";
60
+ // 'beforeLoad' or 'afterLoad'
61
+ appVersion = "<1.9.0";
62
+ async up() {
63
+ const repo = this.db.getRepository("fields");
64
+ if (!repo) {
65
+ return;
66
+ }
67
+ const queryInterface = this.db.sequelize.getQueryInterface();
68
+ for (const collectionName of collections) {
69
+ const collection = this.db.getCollection(collectionName);
70
+ if (collection) {
71
+ const tableName = collection.getTableNameWithSchema();
72
+ if (this.db.isPostgresCompatibleDialect()) {
73
+ await this.db.sequelize.transaction(async (transaction) => {
74
+ const schema = collection.collectionSchema();
75
+ const table = collection.model.tableName;
76
+ const seqName = `"${schema}"."${table}_id_seq"`;
77
+ await this.db.sequelize.query(`ALTER TABLE "${schema}"."${table}" ALTER COLUMN id DROP DEFAULT;`, {
78
+ transaction
79
+ });
80
+ await this.db.sequelize.query(`DROP SEQUENCE IF EXISTS ${seqName} CASCADE;`, { transaction });
81
+ });
82
+ } else {
83
+ await queryInterface.changeColumn(tableName, "id", {
84
+ type: import_sequelize.DataTypes.BIGINT,
85
+ primaryKey: true,
86
+ allowNull: false,
87
+ autoIncrement: false
88
+ });
89
+ }
90
+ }
91
+ const field = await repo.findOne({
92
+ filter: {
93
+ collectionName,
94
+ name: "id"
95
+ }
96
+ });
97
+ if (field) {
98
+ const options = { ...field.options };
99
+ delete options["autoIncrement"];
100
+ await repo.update({
101
+ filter: { key: field.key },
102
+ values: {
103
+ type: "snowflakeId",
104
+ options
105
+ }
106
+ });
107
+ }
108
+ }
109
+ const treeCollections = [...this.db.collections.values()].filter((collection) => collection.options.tree);
110
+ for (const collection of treeCollections) {
111
+ const pathCollection = this.db.getCollection(`main_${collection.name}_path`);
112
+ if (pathCollection) {
113
+ const nodePk = pathCollection.getField("nodePk").columnName();
114
+ await queryInterface.changeColumn(pathCollection.getTableNameWithSchema(), nodePk, {
115
+ type: import_sequelize.DataTypes.BIGINT
116
+ });
117
+ const rootPk = pathCollection.getField("rootPk").columnName();
118
+ await queryInterface.changeColumn(pathCollection.getTableNameWithSchema(), rootPk, {
119
+ type: import_sequelize.DataTypes.BIGINT
120
+ });
121
+ }
122
+ }
123
+ }
124
+ };
125
+ __name(_update_primary_keys_default, "default");
126
+ let update_primary_keys_default = _update_primary_keys_default;
@@ -75,6 +75,7 @@ const deps = {
75
75
  ahooks: "3.x",
76
76
  lodash: "4.x",
77
77
  "china-division": "2.x",
78
- cronstrue: "2.x"
78
+ cronstrue: "2.x",
79
+ "@nocobase/license-kit": "0.2.x"
79
80
  };
80
81
  var deps_default = deps;
@@ -11,11 +11,12 @@ import { HandlerManager } from './handler-manager';
11
11
  import { PubSubCallback, type IPubSubAdapter, type PubSubManagerOptions, type PubSubManagerPublishOptions, type PubSubManagerSubscribeOptions } from './types';
12
12
  export declare const createPubSubManager: (app: Application, options: PubSubManagerOptions) => PubSubManager;
13
13
  export declare class PubSubManager {
14
+ protected app: Application;
14
15
  protected options: PubSubManagerOptions;
15
16
  protected publisherId: string;
16
17
  protected adapter: IPubSubAdapter;
17
18
  protected handlerManager: HandlerManager;
18
- constructor(options?: PubSubManagerOptions);
19
+ constructor(app: Application, options?: PubSubManagerOptions);
19
20
  get channelPrefix(): string;
20
21
  setAdapter(adapter: IPubSubAdapter): void;
21
22
  isConnected(): Promise<boolean>;
@@ -23,5 +24,5 @@ export declare class PubSubManager {
23
24
  close(): Promise<any>;
24
25
  subscribe(channel: string, callback: PubSubCallback, options?: PubSubManagerSubscribeOptions): Promise<void>;
25
26
  unsubscribe(channel: string, callback: PubSubCallback): Promise<any>;
26
- publish(channel: string, message: any, options?: PubSubManagerPublishOptions): Promise<any>;
27
+ publish(channel: string, message: any, options?: PubSubManagerPublishOptions): Promise<void>;
27
28
  }
@@ -34,17 +34,20 @@ module.exports = __toCommonJS(pub_sub_manager_exports);
34
34
  var import_utils = require("@nocobase/utils");
35
35
  var import_handler_manager = require("./handler-manager");
36
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
- });
37
+ const pubSubManager = new PubSubManager(app, options);
38
+ if (app.serving()) {
39
+ app.on("afterStart", async () => {
40
+ await pubSubManager.connect();
41
+ });
42
+ app.on("afterStop", async () => {
43
+ await pubSubManager.close();
44
+ });
45
+ }
44
46
  return pubSubManager;
45
47
  }, "createPubSubManager");
46
48
  const _PubSubManager = class _PubSubManager {
47
- constructor(options = {}) {
49
+ constructor(app, options = {}) {
50
+ this.app = app;
48
51
  this.options = options;
49
52
  this.publisherId = (0, import_utils.uid)();
50
53
  this.handlerManager = new import_handler_manager.HandlerManager(this.publisherId);
@@ -69,8 +72,13 @@ const _PubSubManager = class _PubSubManager {
69
72
  if (!this.adapter) {
70
73
  return;
71
74
  }
75
+ if (!this.app.serving()) {
76
+ this.app.logger.warn("app is not serving, will not connect to event queue");
77
+ return;
78
+ }
72
79
  await this.adapter.connect();
73
80
  await this.handlerManager.each(async (channel, headler) => {
81
+ this.app.logger.debug(`[PubSubManager] subscribe ${channel} added before connected`);
74
82
  await this.adapter.subscribe(`${this.channelPrefix}${channel}`, headler);
75
83
  });
76
84
  }
@@ -84,6 +92,7 @@ const _PubSubManager = class _PubSubManager {
84
92
  await this.unsubscribe(channel, callback);
85
93
  const handler = this.handlerManager.set(channel, callback, options);
86
94
  if (await this.isConnected()) {
95
+ this.app.logger.debug(`[PubSubManager] subscribe ${channel} added after connected`);
87
96
  await this.adapter.subscribe(`${this.channelPrefix}${channel}`, handler);
88
97
  }
89
98
  }
@@ -97,6 +106,9 @@ const _PubSubManager = class _PubSubManager {
97
106
  async publish(channel, message, options) {
98
107
  var _a;
99
108
  if (!((_a = this.adapter) == null ? void 0 : _a.isConnected())) {
109
+ this.app.logger.warn(
110
+ `[PubSubManager] adapter is not exist or not connected, cannot publish message to channel ${channel}`
111
+ );
100
112
  return;
101
113
  }
102
114
  const wrappedMessage = JSON.stringify({
@@ -104,7 +116,8 @@ const _PubSubManager = class _PubSubManager {
104
116
  ...options,
105
117
  message
106
118
  });
107
- return this.adapter.publish(`${this.channelPrefix}${channel}`, wrappedMessage);
119
+ await this.adapter.publish(`${this.channelPrefix}${channel}`, wrappedMessage);
120
+ this.app.logger.trace(`[PubSubManager] published message to channel ${channel}`);
108
121
  }
109
122
  };
110
123
  __name(_PubSubManager, "PubSubManager");
@@ -0,0 +1,28 @@
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 Redis from 'ioredis';
10
+ import { Logger } from '@nocobase/logger';
11
+ export { Redis };
12
+ export interface RedisConfig {
13
+ connectionString: string;
14
+ }
15
+ export declare class RedisConnectionManager {
16
+ private logger;
17
+ private config;
18
+ private connections;
19
+ constructor(config: {
20
+ redisConfig: RedisConfig;
21
+ logger: Logger;
22
+ });
23
+ private bindEvents;
24
+ private getClient;
25
+ getConnection(key?: string, config?: RedisConfig): Redis | null;
26
+ getConnectionSync(key?: string, config?: RedisConfig): Promise<Redis>;
27
+ close(): Promise<void>;
28
+ }
@@ -0,0 +1,119 @@
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 redis_connection_manager_exports = {};
39
+ __export(redis_connection_manager_exports, {
40
+ Redis: () => import_ioredis.default,
41
+ RedisConnectionManager: () => RedisConnectionManager
42
+ });
43
+ module.exports = __toCommonJS(redis_connection_manager_exports);
44
+ var import_ioredis = __toESM(require("ioredis"));
45
+ const _RedisConnectionManager = class _RedisConnectionManager {
46
+ logger;
47
+ config;
48
+ connections = /* @__PURE__ */ new Map();
49
+ constructor(config) {
50
+ this.config = config.redisConfig;
51
+ this.logger = config.logger;
52
+ }
53
+ bindEvents(conn, key, config) {
54
+ conn.on("connect", () => {
55
+ this.logger.info(`Redis connected`, {
56
+ method: "getConnection",
57
+ key,
58
+ config
59
+ });
60
+ });
61
+ conn.on("error", (err) => {
62
+ this.logger.error(err.message, {
63
+ err,
64
+ method: "getConnection",
65
+ key,
66
+ config
67
+ });
68
+ });
69
+ conn.on("close", () => {
70
+ this.logger.trace(`Redis closed`, {
71
+ method: "getConnection",
72
+ key,
73
+ config
74
+ });
75
+ });
76
+ }
77
+ getClient(key = "default", config) {
78
+ let conn = this.connections.get(key);
79
+ if (conn) {
80
+ return conn;
81
+ }
82
+ const cfg = config || this.config;
83
+ if (!cfg.connectionString) {
84
+ return null;
85
+ }
86
+ conn = new import_ioredis.default(cfg.connectionString);
87
+ this.connections.set(key, conn);
88
+ this.bindEvents(conn, key, cfg);
89
+ return conn;
90
+ }
91
+ getConnection(key = "default", config) {
92
+ return this.getClient(key, config);
93
+ }
94
+ async getConnectionSync(key = "default", config) {
95
+ return new Promise((resolve, reject) => {
96
+ const conn = this.getClient(key, config);
97
+ if (!conn) {
98
+ return reject(new Error("Redis connect string is missing"));
99
+ }
100
+ conn.once("connect", () => resolve(conn));
101
+ conn.once("error", reject);
102
+ });
103
+ }
104
+ async close() {
105
+ for (const conn of this.connections.values()) {
106
+ if (!(conn == null ? void 0 : conn.status) || conn.status === "close" || conn.status === "end") {
107
+ continue;
108
+ }
109
+ await conn.quit();
110
+ }
111
+ }
112
+ };
113
+ __name(_RedisConnectionManager, "RedisConnectionManager");
114
+ let RedisConnectionManager = _RedisConnectionManager;
115
+ // Annotate the CommonJS export names for ESM import in node:
116
+ 0 && (module.exports = {
117
+ Redis,
118
+ RedisConnectionManager
119
+ });
@@ -0,0 +1,10 @@
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
+ export declare function setupSnowflakeIdField(app: Application): void;
@@ -0,0 +1,48 @@
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 snowflake_id_field_exports = {};
29
+ __export(snowflake_id_field_exports, {
30
+ setupSnowflakeIdField: () => setupSnowflakeIdField
31
+ });
32
+ module.exports = __toCommonJS(snowflake_id_field_exports);
33
+ var import_database = require("@nocobase/database");
34
+ function setupSnowflakeIdField(app) {
35
+ const _SnowflakeIdField = class _SnowflakeIdField extends import_database.SnowflakeIdField {
36
+ };
37
+ __name(_SnowflakeIdField, "SnowflakeIdField");
38
+ let SnowflakeIdField = _SnowflakeIdField;
39
+ SnowflakeIdField.setApp(app);
40
+ app.db.registerFieldTypes({
41
+ snowflakeId: SnowflakeIdField
42
+ });
43
+ }
44
+ __name(setupSnowflakeIdField, "setupSnowflakeIdField");
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ setupSnowflakeIdField
48
+ });
@@ -16,7 +16,7 @@ export declare class SyncMessageManager {
16
16
  protected pubSubManager: PubSubManager;
17
17
  constructor(app: Application, options?: any);
18
18
  get debounce(): any;
19
- publish(channel: string, message: any, options?: PubSubManagerPublishOptions & Transactionable): Promise<any>;
19
+ publish(channel: string, message: any, options?: PubSubManagerPublishOptions & Transactionable): Promise<unknown>;
20
20
  subscribe(channel: string, callback: PubSubCallback): Promise<void>;
21
21
  unsubscribe(channel: string, callback: PubSubCallback): Promise<any>;
22
22
  sync(): Promise<void>;
@@ -0,0 +1,18 @@
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 WorkerIdAllocatorAdapter {
10
+ getWorkerId(): Promise<number>;
11
+ release(): Promise<void>;
12
+ }
13
+ export declare class WorkerIdAllocator {
14
+ private adapter;
15
+ setAdapter(adapter: WorkerIdAllocatorAdapter): void;
16
+ getWorkerId(): Promise<number>;
17
+ release(): Promise<void>;
18
+ }
@@ -0,0 +1,56 @@
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 worker_id_allocator_exports = {};
29
+ __export(worker_id_allocator_exports, {
30
+ WorkerIdAllocator: () => WorkerIdAllocator
31
+ });
32
+ module.exports = __toCommonJS(worker_id_allocator_exports);
33
+ const _WorkerIdAllocator = class _WorkerIdAllocator {
34
+ adapter;
35
+ setAdapter(adapter) {
36
+ this.adapter = adapter;
37
+ }
38
+ async getWorkerId() {
39
+ if (this.adapter) {
40
+ return this.adapter.getWorkerId();
41
+ }
42
+ return Math.floor(Math.random() * 32);
43
+ }
44
+ async release() {
45
+ if (this.adapter) {
46
+ return this.adapter.release();
47
+ }
48
+ return;
49
+ }
50
+ };
51
+ __name(_WorkerIdAllocator, "WorkerIdAllocator");
52
+ let WorkerIdAllocator = _WorkerIdAllocator;
53
+ // Annotate the CommonJS export names for ESM import in node:
54
+ 0 && (module.exports = {
55
+ WorkerIdAllocator
56
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/server",
3
- "version": "1.9.0-beta.1",
3
+ "version": "1.9.0-beta.10",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "license": "AGPL-3.0",
@@ -10,19 +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.0-beta.1",
14
- "@nocobase/actions": "1.9.0-beta.1",
15
- "@nocobase/auth": "1.9.0-beta.1",
16
- "@nocobase/cache": "1.9.0-beta.1",
17
- "@nocobase/data-source-manager": "1.9.0-beta.1",
18
- "@nocobase/database": "1.9.0-beta.1",
19
- "@nocobase/evaluators": "1.9.0-beta.1",
20
- "@nocobase/lock-manager": "1.9.0-beta.1",
21
- "@nocobase/logger": "1.9.0-beta.1",
22
- "@nocobase/resourcer": "1.9.0-beta.1",
23
- "@nocobase/sdk": "1.9.0-beta.1",
24
- "@nocobase/telemetry": "1.9.0-beta.1",
25
- "@nocobase/utils": "1.9.0-beta.1",
13
+ "@nocobase/acl": "1.9.0-beta.10",
14
+ "@nocobase/actions": "1.9.0-beta.10",
15
+ "@nocobase/auth": "1.9.0-beta.10",
16
+ "@nocobase/cache": "1.9.0-beta.10",
17
+ "@nocobase/data-source-manager": "1.9.0-beta.10",
18
+ "@nocobase/database": "1.9.0-beta.10",
19
+ "@nocobase/evaluators": "1.9.0-beta.10",
20
+ "@nocobase/lock-manager": "1.9.0-beta.10",
21
+ "@nocobase/logger": "1.9.0-beta.10",
22
+ "@nocobase/resourcer": "1.9.0-beta.10",
23
+ "@nocobase/sdk": "1.9.0-beta.10",
24
+ "@nocobase/snowflake-id": "1.9.0-beta.10",
25
+ "@nocobase/telemetry": "1.9.0-beta.10",
26
+ "@nocobase/utils": "1.9.0-beta.10",
26
27
  "@types/decompress": "4.2.7",
27
28
  "@types/ini": "^1.3.31",
28
29
  "@types/koa-send": "^4.1.3",
@@ -40,6 +41,7 @@
40
41
  "fs-extra": "^11.1.1",
41
42
  "i18next": "^22.4.9",
42
43
  "ini": "^4.1.1",
44
+ "ioredis": "^5.7.0",
43
45
  "koa": "^2.15.4",
44
46
  "koa-bodyparser": "^4.3.0",
45
47
  "koa-send": "^5.0.1",
@@ -57,5 +59,5 @@
57
59
  "@types/serve-handler": "^6.1.1",
58
60
  "@types/ws": "^8.5.5"
59
61
  },
60
- "gitHead": "e0597219574e23bbf15b57848cb9b0fb4953634f"
62
+ "gitHead": "a4a5180d8e9b6bebe9df1a931c2c0f8b5c5d26e6"
61
63
  }