koatty_schedule 3.3.3 → 3.3.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.
@@ -0,0 +1,75 @@
1
+
2
+ > koatty_schedule@3.3.4 build /Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-schedule
3
+ > npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp
4
+
5
+
6
+ > koatty_schedule@3.3.4 build:js
7
+ > npx rollup --bundleConfigAsCjs -c .rollup.config.js
8
+
9
+ 
10
+ ./src/index.ts → ./dist/index.js, ./dist/index.mjs...
11
+ created ./dist/index.js, ./dist/index.mjs in 1.1s
12
+
13
+ > koatty_schedule@3.3.4 build:dts
14
+ > npx tsc && npx api-extractor run --local --verbose
15
+
16
+
17
+ api-extractor 7.55.2  - https://api-extractor.com/
18
+ 
19
+ Using configuration from ./api-extractor.json
20
+ Analysis will use the bundled TypeScript version 5.8.2
21
+ *** The target project appears to use TypeScript 5.9.3 which is newer than the bundled compiler engine; consider upgrading API Extractor.
22
+ Writing: /Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-schedule/temp/koatty_schedule.api.json
23
+ Writing package typings: /Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-schedule/dist/index.d.ts
24
+ Warning: src/decorator/redlock.ts:18:4 - (tsdoc-undefined-tag) The TSDoc tag "@export" is not defined in this configuration
25
+ Warning: src/decorator/redlock.ts:19:20 - (tsdoc-param-tag-with-invalid-optional-name) The @param should not include a JSDoc-style optional name; it must not be enclosed in '[ ]' brackets.
26
+ Warning: src/decorator/redlock.ts:19:11 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
27
+ Warning: src/decorator/redlock.ts:22:34 - (tsdoc-param-tag-with-invalid-optional-name) The @param should not include a JSDoc-style optional name; it must not be enclosed in '[ ]' brackets.
28
+ Warning: src/decorator/redlock.ts:22:11 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
29
+ Warning: src/decorator/redlock.ts:24:29 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
30
+ Warning: src/decorator/redlock.ts:24:13 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
31
+ Warning: src/decorator/redlock.ts:25:18 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
32
+ Warning: src/decorator/redlock.ts:25:12 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
33
+ Warning: src/decorator/redlock.ts:42:1 - (ae-forgotten-export) The symbol "RedLockMethodOptions" needs to be exported by the entry point index.d.ts
34
+ Warning: src/decorator/scheduled.ts:18:4 - (tsdoc-undefined-tag) The TSDoc tag "@export" is not defined in this configuration
35
+ Warning: src/decorator/scheduled.ts:19:11 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
36
+ Warning: src/decorator/scheduled.ts:20:20 - (tsdoc-param-tag-with-invalid-optional-name) The @param should not include a JSDoc-style optional name; it must not be enclosed in '[ ]' brackets.
37
+ Warning: src/decorator/scheduled.ts:20:11 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
38
+ Warning: src/decorator/scheduled.ts:30:29 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
39
+ Warning: src/decorator/scheduled.ts:30:13 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
40
+ Warning: src/decorator/scheduled.ts:31:18 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
41
+ Warning: src/decorator/scheduled.ts:31:12 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
42
+ Warning: src/index.ts:62:1 - (ae-forgotten-export) The symbol "ScheduledOptions" needs to be exported by the entry point index.d.ts
43
+ Warning: src/locker/interface.ts:50:1 - (ae-forgotten-export) The symbol "BaseRedisConfig" needs to be exported by the entry point index.d.ts
44
+ Warning: src/locker/redlock.ts:79:6 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration
45
+ Warning: src/locker/redlock.ts:96:6 - (tsdoc-undefined-tag) The TSDoc tag "@static" is not defined in this configuration
46
+ Warning: src/locker/redlock.ts:132:6 - (tsdoc-undefined-tag) The TSDoc tag "@static" is not defined in this configuration
47
+ Warning: src/locker/redlock.ts:146:6 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration
48
+ Warning: src/locker/redlock.ts:177:6 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration
49
+
50
+ API Extractor completed successfully
51
+
52
+ > koatty_schedule@3.3.4 build:doc
53
+ > npx api-documenter markdown --input temp --output docs/api
54
+
55
+
56
+ api-documenter 7.28.2  - https://api-extractor.com/
57
+ 
58
+ Reading koatty_schedule.api.json
59
+
60
+ Deleting old output from docs/api
61
+ Writing koatty_schedule package
62
+ Unsupported block tag: @export
63
+ Unsupported block tag: @static
64
+ Unsupported block tag: @private
65
+ Unsupported block tag: @static
66
+ Unsupported block tag: @static
67
+ Unsupported block tag: @private
68
+ Unsupported block tag: @static
69
+ Unsupported block tag: @export
70
+ Unsupported block tag: @export
71
+ Unsupported block tag: @export
72
+
73
+ > koatty_schedule@3.3.4 build:cp
74
+ > node scripts/postBuild && npx copyfiles package.json LICENSE README.md dist/
75
+
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.3.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - koatty_lib@1.4.2
9
+ - koatty_container@1.17.1
10
+ - koatty_core@2.0.11
11
+ - koatty_logger@2.3.1
12
+ - koatty_store@1.9.1
13
+
3
14
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
15
 
5
16
  ### [3.3.3](https://github.com/thinkkoa/koatty_schedule/compare/v3.3.2...v3.3.3) (2025-10-31)
@@ -8,27 +19,24 @@ All notable changes to this project will be documented in this file. See [standa
8
19
 
9
20
  ### [3.3.1](https://github.com/thinkkoa/koatty_schedule/compare/v3.3.0...v3.3.1) (2025-06-22)
10
21
 
11
-
12
22
  ### Bug Fixes
13
23
 
14
- * unify component type constant to 'COMPONENT' string literal in IOCContainer registration ([7098c7e](https://github.com/thinkkoa/koatty_schedule/commit/7098c7e2c326a6461b6b8b5c84d07a3ced75de5f))
24
+ - unify component type constant to 'COMPONENT' string literal in IOCContainer registration ([7098c7e](https://github.com/thinkkoa/koatty_schedule/commit/7098c7e2c326a6461b6b8b5c84d07a3ced75de5f))
15
25
 
16
26
  ## [3.3.0](https://github.com/thinkkoa/koatty_schedule/compare/v3.2.0...v3.3.0) (2025-06-22)
17
27
 
18
-
19
28
  ### Features
20
29
 
21
- * enhance distributed locking and scheduling system with global configuration management and improved validation ([79a10f5](https://github.com/thinkkoa/koatty_schedule/commit/79a10f5a1ac66958aa44d3ea9151a65826748724))
22
- * improve RedLock singleton management with thread-safe initialization and lock renewal enhancements ([ec426aa](https://github.com/thinkkoa/koatty_schedule/commit/ec426aae3cd0d824661b1b94ae8043bf66ace606))
23
- * introduce component-specific metadata keys for scheduled and redlock decorators ([173e79a](https://github.com/thinkkoa/koatty_schedule/commit/173e79ac916c13b20c93d2efac7e69009cc5cf32))
24
- * refactor RedLock configuration and remove deprecated ScheduleConfig ([7bd4667](https://github.com/thinkkoa/koatty_schedule/commit/7bd4667242c6fd07cfd58a4322d93f4c4548100a))
25
- * update decorator types to support symbol property keys and improve IOC container integration ([f7b6382](https://github.com/thinkkoa/koatty_schedule/commit/f7b6382e855914176c130b10a769b03cc74c0f23))
26
- * use dynamic componentType instead of hardcoded constants for IOCContainer registration ([42ca073](https://github.com/thinkkoa/koatty_schedule/commit/42ca07353a8082b1af9e49d43914497d41cddd27))
27
-
30
+ - enhance distributed locking and scheduling system with global configuration management and improved validation ([79a10f5](https://github.com/thinkkoa/koatty_schedule/commit/79a10f5a1ac66958aa44d3ea9151a65826748724))
31
+ - improve RedLock singleton management with thread-safe initialization and lock renewal enhancements ([ec426aa](https://github.com/thinkkoa/koatty_schedule/commit/ec426aae3cd0d824661b1b94ae8043bf66ace606))
32
+ - introduce component-specific metadata keys for scheduled and redlock decorators ([173e79a](https://github.com/thinkkoa/koatty_schedule/commit/173e79ac916c13b20c93d2efac7e69009cc5cf32))
33
+ - refactor RedLock configuration and remove deprecated ScheduleConfig ([7bd4667](https://github.com/thinkkoa/koatty_schedule/commit/7bd4667242c6fd07cfd58a4322d93f4c4548100a))
34
+ - update decorator types to support symbol property keys and improve IOC container integration ([f7b6382](https://github.com/thinkkoa/koatty_schedule/commit/f7b6382e855914176c130b10a769b03cc74c0f23))
35
+ - use dynamic componentType instead of hardcoded constants for IOCContainer registration ([42ca073](https://github.com/thinkkoa/koatty_schedule/commit/42ca07353a8082b1af9e49d43914497d41cddd27))
28
36
 
29
37
  ### Bug Fixes
30
38
 
31
- * 修复IOC容器元数据键格式不匹配问题 ([644714f](https://github.com/thinkkoa/koatty_schedule/commit/644714f20497196fb705e551880a9ef527257cb7))
39
+ - 修复 IOC 容器元数据键格式不匹配问题 ([644714f](https://github.com/thinkkoa/koatty_schedule/commit/644714f20497196fb705e551880a9ef527257cb7))
32
40
 
33
41
  ### [2.1.1](https://github.com/thinkkoa/koatty_schedule/compare/v2.1.0...v2.1.1) (2025-06-09)
34
42
 
@@ -36,60 +44,52 @@ All notable changes to this project will be documented in this file. See [standa
36
44
 
37
45
  ## [3.2.0](https://github.com/thinkkoa/koatty_schedule/compare/v3.1.0...v3.2.0) (2025-06-22)
38
46
 
39
-
40
47
  ### Features
41
48
 
42
- * introduce component-specific metadata keys for scheduled and redlock decorators ([803b350](https://github.com/thinkkoa/koatty_schedule/commit/803b3503489c02ab138b3f9f14cb520dd6c7fec4))
43
-
49
+ - introduce component-specific metadata keys for scheduled and redlock decorators ([803b350](https://github.com/thinkkoa/koatty_schedule/commit/803b3503489c02ab138b3f9f14cb520dd6c7fec4))
44
50
 
45
51
  ### Bug Fixes
46
52
 
47
- * 修复IOC容器元数据键格式不匹配问题 ([065d456](https://github.com/thinkkoa/koatty_schedule/commit/065d456fc65004e25eb19838da96bf0a52cb2af1))
53
+ - 修复 IOC 容器元数据键格式不匹配问题 ([065d456](https://github.com/thinkkoa/koatty_schedule/commit/065d456fc65004e25eb19838da96bf0a52cb2af1))
48
54
 
49
55
  ## [3.1.0](https://github.com/thinkkoa/koatty_schedule/compare/v3.0.0...v3.1.0) (2025-06-21)
50
56
 
51
-
52
57
  ### Features
53
58
 
54
- * update decorator types to support symbol property keys and improve IOC container integration ([a60ef3e](https://github.com/thinkkoa/koatty_schedule/commit/a60ef3e361b245f97ba0d6ee51d42efd437a1252))
59
+ - update decorator types to support symbol property keys and improve IOC container integration ([a60ef3e](https://github.com/thinkkoa/koatty_schedule/commit/a60ef3e361b245f97ba0d6ee51d42efd437a1252))
55
60
 
56
61
  ## [3.0.0](https://github.com/thinkkoa/koatty_schedule/compare/v2.1.0...v3.0.0) (2025-06-21)
57
62
 
58
-
59
63
  ### Features
60
64
 
61
- * enhance distributed locking and scheduling system with global configuration management and improved validation ([cf3924c](https://github.com/thinkkoa/koatty_schedule/commit/cf3924cf6bccf951f070c68e33483ae935828382))
62
- * improve RedLock singleton management with thread-safe initialization and lock renewal enhancements ([4e381cd](https://github.com/thinkkoa/koatty_schedule/commit/4e381cd8eec6aa366a6db813918f213f07b02921))
63
- * refactor RedLock configuration and remove deprecated ScheduleConfig ([bb10ac7](https://github.com/thinkkoa/koatty_schedule/commit/bb10ac7dab67d32ca75a43db92c587a662bc1b9f))
65
+ - enhance distributed locking and scheduling system with global configuration management and improved validation ([cf3924c](https://github.com/thinkkoa/koatty_schedule/commit/cf3924cf6bccf951f070c68e33483ae935828382))
66
+ - improve RedLock singleton management with thread-safe initialization and lock renewal enhancements ([4e381cd](https://github.com/thinkkoa/koatty_schedule/commit/4e381cd8eec6aa366a6db813918f213f07b02921))
67
+ - refactor RedLock configuration and remove deprecated ScheduleConfig ([bb10ac7](https://github.com/thinkkoa/koatty_schedule/commit/bb10ac7dab67d32ca75a43db92c587a662bc1b9f))
64
68
 
65
69
  ## [2.1.0](https://github.com/thinkkoa/koatty_schedule/compare/v2.0.1...v2.1.0) (2025-06-09)
66
70
 
67
-
68
71
  ### Features
69
72
 
70
- * add schedule and redlock decorators with config management ([c1b5359](https://github.com/thinkkoa/koatty_schedule/commit/c1b535940df2b8a3403bf024137519246945870e))
71
- * enhance ConfigManager with singleton pattern, environment config loading ([00db6eb](https://github.com/thinkkoa/koatty_schedule/commit/00db6eb97bdae226aaf433b23c770704b33d05e8))
72
- * introduce DecoratorType enum, refactor decorator management system, ([e58e718](https://github.com/thinkkoa/koatty_schedule/commit/e58e718975e663820778352bedb6421e6852ba9f))
73
-
73
+ - add schedule and redlock decorators with config management ([c1b5359](https://github.com/thinkkoa/koatty_schedule/commit/c1b535940df2b8a3403bf024137519246945870e))
74
+ - enhance ConfigManager with singleton pattern, environment config loading ([00db6eb](https://github.com/thinkkoa/koatty_schedule/commit/00db6eb97bdae226aaf433b23c770704b33d05e8))
75
+ - introduce DecoratorType enum, refactor decorator management system, ([e58e718](https://github.com/thinkkoa/koatty_schedule/commit/e58e718975e663820778352bedb6421e6852ba9f))
74
76
 
75
77
  ### Bug Fixes
76
78
 
77
- * simplify error handling in ConfigManager and RedLocker ([7be75fc](https://github.com/thinkkoa/koatty_schedule/commit/7be75fc7f4160094b57ca64905df4c81f77adb51))
78
-
79
+ - simplify error handling in ConfigManager and RedLocker ([7be75fc](https://github.com/thinkkoa/koatty_schedule/commit/7be75fc7f4160094b57ca64905df4c81f77adb51))
79
80
 
80
81
  ### Refactor
81
82
 
82
- * use MethodDecoratorManager ([ff077c7](https://github.com/thinkkoa/koatty_schedule/commit/ff077c7211bb6cf258c6885e1d7dcbdacde90ef1))
83
+ - use MethodDecoratorManager ([ff077c7](https://github.com/thinkkoa/koatty_schedule/commit/ff077c7211bb6cf258c6885e1d7dcbdacde90ef1))
83
84
 
84
85
  ### [2.0.1](https://github.com/thinkkoa/koatty_schedule/compare/v2.0.0...v2.0.1) (2024-01-17)
85
86
 
86
87
  ## [2.0.0](https://github.com/thinkkoa/koatty_schedule/compare/v1.6.0...v2.0.0) (2024-01-17)
87
88
 
88
-
89
89
  ### Refactor
90
90
 
91
- * redlock ([beb7cd9](https://github.com/thinkkoa/koatty_schedule/commit/beb7cd90878319cb1c480f4ad11b2632c184872b))
92
- * redlock ([ea29337](https://github.com/thinkkoa/koatty_schedule/commit/ea29337052aee081322918914876a95923d314ae))
91
+ - redlock ([beb7cd9](https://github.com/thinkkoa/koatty_schedule/commit/beb7cd90878319cb1c480f4ad11b2632c184872b))
92
+ - redlock ([ea29337](https://github.com/thinkkoa/koatty_schedule/commit/ea29337052aee081322918914876a95923d314ae))
93
93
 
94
94
  ## [1.6.0](https://github.com/thinkkoa/koatty_schedule/compare/v1.5.11...v1.6.0) (2023-12-20)
95
95
 
@@ -101,11 +101,10 @@ All notable changes to this project will be documented in this file. See [standa
101
101
 
102
102
  ### [1.5.7](https://github.com/thinkkoa/koatty_schedule/compare/v1.5.6...v1.5.7) (2022-09-05)
103
103
 
104
-
105
104
  ### Bug Fixes
106
105
 
107
- * update ([8eb40be](https://github.com/thinkkoa/koatty_schedule/commit/8eb40be4f0778d218a2a8b9a9370ffbe26c9e884))
108
- * upgrade deps ([51a68af](https://github.com/thinkkoa/koatty_schedule/commit/51a68af12437a08e3a5468b27b57ae597f66695d))
106
+ - update ([8eb40be](https://github.com/thinkkoa/koatty_schedule/commit/8eb40be4f0778d218a2a8b9a9370ffbe26c9e884))
107
+ - upgrade deps ([51a68af](https://github.com/thinkkoa/koatty_schedule/commit/51a68af12437a08e3a5468b27b57ae597f66695d))
109
108
 
110
109
  ### [1.5.6](https://github.com/thinkkoa/koatty_schedule/compare/v1.5.5...v1.5.6) (2022-05-27)
111
110
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2025-10-31 17:51:00
3
+ * @Date: 2026-01-28 13:35:34
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2025-10-31 17:50:55
3
+ * @Date: 2026-01-28 13:35:25
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
@@ -197,10 +197,10 @@ function getEffectiveTimezone(options, userTimezone) {
197
197
  function getEffectiveRedLockOptions(methodOptions) {
198
198
  const globalOptions = getGlobalScheduledOptions();
199
199
  return {
200
- lockTimeOut: methodOptions?.lockTimeOut || globalOptions.lockTimeOut || 10000,
201
- clockDriftFactor: methodOptions?.clockDriftFactor || globalOptions.clockDriftFactor || 0.01,
202
- maxRetries: methodOptions?.maxRetries || globalOptions.maxRetries || 3,
203
- retryDelayMs: methodOptions?.retryDelayMs || globalOptions.retryDelayMs || 200
200
+ lockTimeOut: (methodOptions === null || methodOptions === void 0 ? void 0 : methodOptions.lockTimeOut) || globalOptions.lockTimeOut || 10000,
201
+ clockDriftFactor: (methodOptions === null || methodOptions === void 0 ? void 0 : methodOptions.clockDriftFactor) || globalOptions.clockDriftFactor || 0.01,
202
+ maxRetries: (methodOptions === null || methodOptions === void 0 ? void 0 : methodOptions.maxRetries) || globalOptions.maxRetries || 3,
203
+ retryDelayMs: (methodOptions === null || methodOptions === void 0 ? void 0 : methodOptions.retryDelayMs) || globalOptions.retryDelayMs || 200
204
204
  };
205
205
  }
206
206
 
@@ -237,7 +237,6 @@ exports.RedisMode = void 0;
237
237
  * Wraps ioredis client to provide unified interface
238
238
  */
239
239
  class RedisClientAdapter {
240
- client;
241
240
  constructor(client) {
242
241
  this.client = client;
243
242
  }
@@ -374,11 +373,12 @@ class RedisFactory {
374
373
  * @param config - Cluster configuration
375
374
  */
376
375
  static createClusterClient(config) {
376
+ var _a, _b;
377
377
  koatty_logger.DefaultLogger.Debug(`Creating cluster Redis client with ${config.nodes.length} nodes`);
378
378
  const clusterOptions = {
379
379
  redisOptions: {
380
- password: config.redisOptions?.password || config.password || undefined,
381
- db: config.redisOptions?.db || config.db || 0,
380
+ password: ((_a = config.redisOptions) === null || _a === void 0 ? void 0 : _a.password) || config.password || undefined,
381
+ db: ((_b = config.redisOptions) === null || _b === void 0 ? void 0 : _b.db) || config.db || 0,
382
382
  keyPrefix: config.keyPrefix || '',
383
383
  connectTimeout: config.connectTimeout || 10000,
384
384
  commandTimeout: config.commandTimeout || 5000,
@@ -491,15 +491,12 @@ const defaultRedlockSettings = {
491
491
  * Implements IDistributedLock interface for abstraction
492
492
  */
493
493
  class RedLocker {
494
- static instance = null;
495
- static instanceLock = Symbol('RedLocker.instanceLock');
496
- redlock = null;
497
- redisClient = null;
498
- config;
499
- isInitialized = false;
500
- initializationPromise = null;
501
494
  // 私有构造函数防止外部直接实例化
502
495
  constructor(options) {
496
+ this.redlock = null;
497
+ this.redisClient = null;
498
+ this.isInitialized = false;
499
+ this.initializationPromise = null;
503
500
  this.config = { ...defaultRedLockConfig, ...options };
504
501
  // Register this instance in IOC container
505
502
  this.registerInContainer();
@@ -815,16 +812,17 @@ class RedLocker {
815
812
  * @returns Health status
816
813
  */
817
814
  async healthCheck() {
815
+ var _a, _b;
818
816
  try {
819
817
  await this.initialize();
820
- const redisStatus = this.redisClient?.status || 'unknown';
818
+ const redisStatus = ((_a = this.redisClient) === null || _a === void 0 ? void 0 : _a.status) || 'unknown';
821
819
  const isReady = this.isReady();
822
820
  return {
823
821
  status: isReady ? 'healthy' : 'unhealthy',
824
822
  details: {
825
823
  initialized: this.isInitialized,
826
824
  redisStatus,
827
- redisMode: this.config.redisConfig?.mode || 'unknown',
825
+ redisMode: ((_b = this.config.redisConfig) === null || _b === void 0 ? void 0 : _b.mode) || 'unknown',
828
826
  redlockReady: !!this.redlock,
829
827
  containerRegistered: this.getContainerInfo().registered
830
828
  }
@@ -841,6 +839,8 @@ class RedLocker {
841
839
  }
842
840
  }
843
841
  }
842
+ RedLocker.instance = null;
843
+ RedLocker.instanceLock = Symbol('RedLocker.instanceLock');
844
844
 
845
845
  /*
846
846
  * @Description:
@@ -890,21 +890,19 @@ async function initRedLock(options, app) {
890
890
  koatty_logger.DefaultLogger.Warn(`RedLock initialization skipped: Koatty app not available or not initialized`);
891
891
  return;
892
892
  }
893
- app.once("appReady", async function () {
894
- try {
895
- if (koatty_lib.Helper.isEmpty(options)) {
896
- throw Error(`Missing RedLock configuration. Please write a configuration item with the key name 'RedLock' in the db.ts file.`);
897
- }
898
- // 获取RedLocker实例,在首次使用时自动初始化
899
- const redLocker = RedLocker.getInstance(options);
900
- await redLocker.initialize();
901
- koatty_logger.DefaultLogger.Info('RedLock initialized successfully');
902
- }
903
- catch (error) {
904
- koatty_logger.DefaultLogger.Error('Failed to initialize RedLock:', error);
905
- throw error;
893
+ try {
894
+ if (koatty_lib.Helper.isEmpty(options)) {
895
+ throw Error(`Missing RedLock configuration. Please write a configuration item with the key name 'RedLock' in the db.ts file.`);
906
896
  }
907
- });
897
+ // 获取RedLocker实例,在首次使用时自动初始化
898
+ const redLocker = RedLocker.getInstance(options);
899
+ await redLocker.initialize();
900
+ koatty_logger.DefaultLogger.Info('RedLock initialized successfully');
901
+ }
902
+ catch (error) {
903
+ koatty_logger.DefaultLogger.Error('Failed to initialize RedLock:', error);
904
+ throw error;
905
+ }
908
906
  }
909
907
  /**
910
908
  * Create redLocker Descriptor with improved error handling and type safety
@@ -1021,6 +1019,7 @@ function redLockerDescriptor(descriptor, name, method, methodOptions) {
1021
1019
  * Generate lock name for RedLock decorator
1022
1020
  */
1023
1021
  function generateLockName(configName, methodName, target) {
1022
+ var _a;
1024
1023
  if (configName) {
1025
1024
  return configName;
1026
1025
  }
@@ -1035,7 +1034,7 @@ function generateLockName(configName, methodName, target) {
1035
1034
  // Fallback if IOC container is not available
1036
1035
  }
1037
1036
  const targetWithConstructor = target;
1038
- const className = targetWithConstructor.constructor?.name || 'Unknown';
1037
+ const className = ((_a = targetWithConstructor.constructor) === null || _a === void 0 ? void 0 : _a.name) || 'Unknown';
1039
1038
  return `${className}_${methodName}`;
1040
1039
  }
1041
1040
 
@@ -1199,16 +1198,14 @@ async function initSchedule(options, app) {
1199
1198
  koatty_logger.DefaultLogger.Warn(`Schedule initialization skipped: Koatty app not available or not initialized`);
1200
1199
  return;
1201
1200
  }
1202
- app.once("appReady", async function () {
1203
- try {
1204
- await injectSchedule(options);
1205
- koatty_logger.DefaultLogger.Info('Schedule system initialized successfully');
1206
- }
1207
- catch (error) {
1208
- koatty_logger.DefaultLogger.Error('Failed to initialize Schedule system:', error);
1209
- throw error;
1210
- }
1211
- });
1201
+ try {
1202
+ await injectSchedule(options);
1203
+ koatty_logger.DefaultLogger.Info('Schedule system initialized successfully');
1204
+ }
1205
+ catch (error) {
1206
+ koatty_logger.DefaultLogger.Error('Failed to initialize Schedule system:', error);
1207
+ throw error;
1208
+ }
1212
1209
  }
1213
1210
  /**
1214
1211
  * Inject schedule job with enhanced error handling and validation
@@ -1312,10 +1309,12 @@ const defaultOptions = {
1312
1309
  */
1313
1310
  async function KoattyScheduled(options, app) {
1314
1311
  options = { ...defaultOptions, ...options };
1315
- // 初始化RedLock(appReady时触发,确保所有依赖就绪)
1316
- await initRedLock(options, app);
1317
- // 初始化调度任务系统(appReady时触发,确保所有组件都已初始化)
1318
- await initSchedule(options, app);
1312
+ app.once("appReady", async function () {
1313
+ // 初始化RedLock
1314
+ await initRedLock(options, app);
1315
+ // 初始化调度任务系统
1316
+ await initSchedule(options, app);
1317
+ });
1319
1318
  }
1320
1319
 
1321
1320
  exports.KoattyScheduled = KoattyScheduled;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2025-10-31 17:50:55
3
+ * @Date: 2026-01-28 13:35:25
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
@@ -195,10 +195,10 @@ function getEffectiveTimezone(options, userTimezone) {
195
195
  function getEffectiveRedLockOptions(methodOptions) {
196
196
  const globalOptions = getGlobalScheduledOptions();
197
197
  return {
198
- lockTimeOut: methodOptions?.lockTimeOut || globalOptions.lockTimeOut || 10000,
199
- clockDriftFactor: methodOptions?.clockDriftFactor || globalOptions.clockDriftFactor || 0.01,
200
- maxRetries: methodOptions?.maxRetries || globalOptions.maxRetries || 3,
201
- retryDelayMs: methodOptions?.retryDelayMs || globalOptions.retryDelayMs || 200
198
+ lockTimeOut: (methodOptions === null || methodOptions === void 0 ? void 0 : methodOptions.lockTimeOut) || globalOptions.lockTimeOut || 10000,
199
+ clockDriftFactor: (methodOptions === null || methodOptions === void 0 ? void 0 : methodOptions.clockDriftFactor) || globalOptions.clockDriftFactor || 0.01,
200
+ maxRetries: (methodOptions === null || methodOptions === void 0 ? void 0 : methodOptions.maxRetries) || globalOptions.maxRetries || 3,
201
+ retryDelayMs: (methodOptions === null || methodOptions === void 0 ? void 0 : methodOptions.retryDelayMs) || globalOptions.retryDelayMs || 200
202
202
  };
203
203
  }
204
204
 
@@ -235,7 +235,6 @@ var RedisMode;
235
235
  * Wraps ioredis client to provide unified interface
236
236
  */
237
237
  class RedisClientAdapter {
238
- client;
239
238
  constructor(client) {
240
239
  this.client = client;
241
240
  }
@@ -372,11 +371,12 @@ class RedisFactory {
372
371
  * @param config - Cluster configuration
373
372
  */
374
373
  static createClusterClient(config) {
374
+ var _a, _b;
375
375
  DefaultLogger.Debug(`Creating cluster Redis client with ${config.nodes.length} nodes`);
376
376
  const clusterOptions = {
377
377
  redisOptions: {
378
- password: config.redisOptions?.password || config.password || undefined,
379
- db: config.redisOptions?.db || config.db || 0,
378
+ password: ((_a = config.redisOptions) === null || _a === void 0 ? void 0 : _a.password) || config.password || undefined,
379
+ db: ((_b = config.redisOptions) === null || _b === void 0 ? void 0 : _b.db) || config.db || 0,
380
380
  keyPrefix: config.keyPrefix || '',
381
381
  connectTimeout: config.connectTimeout || 10000,
382
382
  commandTimeout: config.commandTimeout || 5000,
@@ -489,15 +489,12 @@ const defaultRedlockSettings = {
489
489
  * Implements IDistributedLock interface for abstraction
490
490
  */
491
491
  class RedLocker {
492
- static instance = null;
493
- static instanceLock = Symbol('RedLocker.instanceLock');
494
- redlock = null;
495
- redisClient = null;
496
- config;
497
- isInitialized = false;
498
- initializationPromise = null;
499
492
  // 私有构造函数防止外部直接实例化
500
493
  constructor(options) {
494
+ this.redlock = null;
495
+ this.redisClient = null;
496
+ this.isInitialized = false;
497
+ this.initializationPromise = null;
501
498
  this.config = { ...defaultRedLockConfig, ...options };
502
499
  // Register this instance in IOC container
503
500
  this.registerInContainer();
@@ -813,16 +810,17 @@ class RedLocker {
813
810
  * @returns Health status
814
811
  */
815
812
  async healthCheck() {
813
+ var _a, _b;
816
814
  try {
817
815
  await this.initialize();
818
- const redisStatus = this.redisClient?.status || 'unknown';
816
+ const redisStatus = ((_a = this.redisClient) === null || _a === void 0 ? void 0 : _a.status) || 'unknown';
819
817
  const isReady = this.isReady();
820
818
  return {
821
819
  status: isReady ? 'healthy' : 'unhealthy',
822
820
  details: {
823
821
  initialized: this.isInitialized,
824
822
  redisStatus,
825
- redisMode: this.config.redisConfig?.mode || 'unknown',
823
+ redisMode: ((_b = this.config.redisConfig) === null || _b === void 0 ? void 0 : _b.mode) || 'unknown',
826
824
  redlockReady: !!this.redlock,
827
825
  containerRegistered: this.getContainerInfo().registered
828
826
  }
@@ -839,6 +837,8 @@ class RedLocker {
839
837
  }
840
838
  }
841
839
  }
840
+ RedLocker.instance = null;
841
+ RedLocker.instanceLock = Symbol('RedLocker.instanceLock');
842
842
 
843
843
  /*
844
844
  * @Description:
@@ -888,21 +888,19 @@ async function initRedLock(options, app) {
888
888
  DefaultLogger.Warn(`RedLock initialization skipped: Koatty app not available or not initialized`);
889
889
  return;
890
890
  }
891
- app.once("appReady", async function () {
892
- try {
893
- if (Helper.isEmpty(options)) {
894
- throw Error(`Missing RedLock configuration. Please write a configuration item with the key name 'RedLock' in the db.ts file.`);
895
- }
896
- // 获取RedLocker实例,在首次使用时自动初始化
897
- const redLocker = RedLocker.getInstance(options);
898
- await redLocker.initialize();
899
- DefaultLogger.Info('RedLock initialized successfully');
900
- }
901
- catch (error) {
902
- DefaultLogger.Error('Failed to initialize RedLock:', error);
903
- throw error;
891
+ try {
892
+ if (Helper.isEmpty(options)) {
893
+ throw Error(`Missing RedLock configuration. Please write a configuration item with the key name 'RedLock' in the db.ts file.`);
904
894
  }
905
- });
895
+ // 获取RedLocker实例,在首次使用时自动初始化
896
+ const redLocker = RedLocker.getInstance(options);
897
+ await redLocker.initialize();
898
+ DefaultLogger.Info('RedLock initialized successfully');
899
+ }
900
+ catch (error) {
901
+ DefaultLogger.Error('Failed to initialize RedLock:', error);
902
+ throw error;
903
+ }
906
904
  }
907
905
  /**
908
906
  * Create redLocker Descriptor with improved error handling and type safety
@@ -1019,6 +1017,7 @@ function redLockerDescriptor(descriptor, name, method, methodOptions) {
1019
1017
  * Generate lock name for RedLock decorator
1020
1018
  */
1021
1019
  function generateLockName(configName, methodName, target) {
1020
+ var _a;
1022
1021
  if (configName) {
1023
1022
  return configName;
1024
1023
  }
@@ -1033,7 +1032,7 @@ function generateLockName(configName, methodName, target) {
1033
1032
  // Fallback if IOC container is not available
1034
1033
  }
1035
1034
  const targetWithConstructor = target;
1036
- const className = targetWithConstructor.constructor?.name || 'Unknown';
1035
+ const className = ((_a = targetWithConstructor.constructor) === null || _a === void 0 ? void 0 : _a.name) || 'Unknown';
1037
1036
  return `${className}_${methodName}`;
1038
1037
  }
1039
1038
 
@@ -1197,16 +1196,14 @@ async function initSchedule(options, app) {
1197
1196
  DefaultLogger.Warn(`Schedule initialization skipped: Koatty app not available or not initialized`);
1198
1197
  return;
1199
1198
  }
1200
- app.once("appReady", async function () {
1201
- try {
1202
- await injectSchedule(options);
1203
- DefaultLogger.Info('Schedule system initialized successfully');
1204
- }
1205
- catch (error) {
1206
- DefaultLogger.Error('Failed to initialize Schedule system:', error);
1207
- throw error;
1208
- }
1209
- });
1199
+ try {
1200
+ await injectSchedule(options);
1201
+ DefaultLogger.Info('Schedule system initialized successfully');
1202
+ }
1203
+ catch (error) {
1204
+ DefaultLogger.Error('Failed to initialize Schedule system:', error);
1205
+ throw error;
1206
+ }
1210
1207
  }
1211
1208
  /**
1212
1209
  * Inject schedule job with enhanced error handling and validation
@@ -1310,10 +1307,12 @@ const defaultOptions = {
1310
1307
  */
1311
1308
  async function KoattyScheduled(options, app) {
1312
1309
  options = { ...defaultOptions, ...options };
1313
- // 初始化RedLock(appReady时触发,确保所有依赖就绪)
1314
- await initRedLock(options, app);
1315
- // 初始化调度任务系统(appReady时触发,确保所有组件都已初始化)
1316
- await initSchedule(options, app);
1310
+ app.once("appReady", async function () {
1311
+ // 初始化RedLock
1312
+ await initRedLock(options, app);
1313
+ // 初始化调度任务系统
1314
+ await initSchedule(options, app);
1315
+ });
1317
1316
  }
1318
1317
 
1319
1318
  export { KoattyScheduled, RedLock, RedLocker, RedisClientAdapter, RedisFactory, RedisMode, Scheduled, SchedulerLock };
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koatty_schedule",
3
- "version": "3.3.3",
3
+ "version": "3.3.4",
4
4
  "description": "Schedule for koatty.",
5
5
  "scripts": {
6
6
  "build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
@@ -12,13 +12,8 @@
12
12
  "lock": "npm i --package-lock-only",
13
13
  "prepublishOnly": "npm test && npm run build && git push --follow-tags origin master",
14
14
  "prerelease": "npm test && npm run build",
15
- "release:minor": "npm run release -- --release-as minor",
16
- "release:major": "npm run release -- --release-as major",
17
- "release": "standard-version",
18
- "release:pre": "npm run release -- --prerelease",
19
15
  "test": "npm run eslint && jest --passWithNoTests",
20
- "test:cov": "jest --collectCoverage --detectOpenHandles",
21
- "version": "conventional-changelog -p angular -i CHANGELOG.md -s"
16
+ "test:cov": "jest --collectCoverage --detectOpenHandles"
22
17
  },
23
18
  "main": "./dist/index.js",
24
19
  "exports": {
@@ -89,18 +84,18 @@
89
84
  },
90
85
  "dependencies": {
91
86
  "@sesamecare-oss/redlock": "^1.4.0",
92
- "cron": "^4.3.3",
93
- "ioredis": "^5.8.2",
94
- "koatty_container": "^1.x.x",
95
- "koatty_core": "2.0.8-0",
96
- "koatty_lib": "^1.x.x",
97
- "koatty_logger": "^2.x.x",
98
- "koatty_store": "^1.x.x"
87
+ "cron": "^4.4.0",
88
+ "ioredis": "^5.9.2",
89
+ "koatty_container": "workspace:*",
90
+ "koatty_core": "workspace:*",
91
+ "koatty_lib": "workspace:*",
92
+ "koatty_logger": "workspace:*",
93
+ "koatty_store": "workspace:*"
99
94
  },
100
95
  "peerDependencies": {
101
- "koatty_container": "^1.x.x",
102
- "koatty_core": "^1.x.x",
103
- "koatty_lib": "^1.x.x",
104
- "koatty_logger": "^2.x.x"
96
+ "koatty_container": "workspace:*",
97
+ "koatty_core": "workspace:*",
98
+ "koatty_lib": "workspace:*",
99
+ "koatty_logger": "workspace:*"
105
100
  }
106
- }
101
+ }
package/package.json CHANGED
@@ -1,25 +1,7 @@
1
1
  {
2
2
  "name": "koatty_schedule",
3
- "version": "3.3.3",
3
+ "version": "3.3.4",
4
4
  "description": "Schedule for koatty.",
5
- "scripts": {
6
- "build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
7
- "build:cp": "node scripts/postBuild && npx copyfiles package.json LICENSE README.md dist/",
8
- "build:js": "npx rollup --bundleConfigAsCjs -c .rollup.config.js",
9
- "build:doc": "npx api-documenter markdown --input temp --output docs/api",
10
- "build:dts": "npx tsc && npx api-extractor run --local --verbose",
11
- "eslint": "eslint --ext .ts,.js ./",
12
- "lock": "npm i --package-lock-only",
13
- "prepublishOnly": "npm test && npm run build && git push --follow-tags origin master",
14
- "prerelease": "npm test && npm run build",
15
- "release:minor": "npm run release -- --release-as minor",
16
- "release:major": "npm run release -- --release-as major",
17
- "release": "standard-version",
18
- "release:pre": "npm run release -- --prerelease",
19
- "test": "npm run eslint && jest --passWithNoTests",
20
- "test:cov": "jest --collectCoverage --detectOpenHandles",
21
- "version": "conventional-changelog -p angular -i CHANGELOG.md -s"
22
- },
23
5
  "main": "./dist/index.js",
24
6
  "exports": {
25
7
  "require": "./dist/index.js",
@@ -89,18 +71,30 @@
89
71
  },
90
72
  "dependencies": {
91
73
  "@sesamecare-oss/redlock": "^1.4.0",
92
- "cron": "^4.3.3",
93
- "ioredis": "^5.8.2",
94
- "koatty_container": "^1.x.x",
74
+ "cron": "^4.4.0",
75
+ "ioredis": "^5.9.2",
76
+ "koatty_container": "1.18.0",
95
77
  "koatty_core": "2.0.8-0",
96
- "koatty_lib": "^1.x.x",
97
- "koatty_logger": "^2.x.x",
98
- "koatty_store": "^1.x.x"
78
+ "koatty_logger": "2.8.1",
79
+ "koatty_lib": "1.4.3",
80
+ "koatty_store": "1.9.0"
99
81
  },
100
82
  "peerDependencies": {
101
- "koatty_container": "^1.x.x",
102
- "koatty_core": "^1.x.x",
103
- "koatty_lib": "^1.x.x",
104
- "koatty_logger": "^2.x.x"
83
+ "koatty_lib": "1.4.3",
84
+ "koatty_core": "2.0.8-0",
85
+ "koatty_container": "1.18.0",
86
+ "koatty_logger": "2.8.1"
87
+ },
88
+ "scripts": {
89
+ "build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
90
+ "build:cp": "node scripts/postBuild && npx copyfiles package.json LICENSE README.md dist/",
91
+ "build:js": "npx rollup --bundleConfigAsCjs -c .rollup.config.js",
92
+ "build:doc": "npx api-documenter markdown --input temp --output docs/api",
93
+ "build:dts": "npx tsc && npx api-extractor run --local --verbose",
94
+ "eslint": "eslint --ext .ts,.js ./",
95
+ "lock": "npm i --package-lock-only",
96
+ "prerelease": "npm test && npm run build",
97
+ "test": "npm run eslint && jest --passWithNoTests",
98
+ "test:cov": "jest --collectCoverage --detectOpenHandles"
105
99
  }
106
- }
100
+ }
@@ -0,0 +1,67 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var commonjs = require('@rollup/plugin-commonjs');
6
+ var json = require('@rollup/plugin-json');
7
+ var resolve = require('@rollup/plugin-node-resolve');
8
+ var module$1 = require('module');
9
+ var del = require('rollup-plugin-delete');
10
+ var typescript = require('rollup-plugin-typescript2');
11
+
12
+ /*
13
+ * @Description:
14
+ * @Usage:
15
+ * @Author: richen
16
+ * @Date: 2021-12-17 10:20:44
17
+ * @LastEditTime: 2024-11-04 22:04:45
18
+ */
19
+ // import babel from '@rollup/plugin-babel';
20
+ const pkg = require('./package.json');
21
+
22
+ var _rollup_config = [
23
+ {
24
+ input: './src/index.ts',
25
+ output: [
26
+ {
27
+ format: 'cjs',
28
+ file: './dist/index.js',
29
+ banner: require('./scripts/copyright'),
30
+ },
31
+ {
32
+ format: 'es',
33
+ file: './dist/index.mjs',
34
+ banner: require('./scripts/copyright'),
35
+ },
36
+ ],
37
+ plugins: [
38
+ del({ targets: ["dist/*", "temp/*", "docs/api"] }),
39
+ // babel({
40
+ // babelHelpers: "runtime",
41
+ // configFile: './babel.config.js',
42
+ // exclude: 'node_modules/**',
43
+ // }),
44
+ json(),
45
+ resolve({
46
+ preferBuiltins: true, // 优先选择内置模块
47
+ }),
48
+ commonjs(),
49
+ typescript({
50
+ tsconfigOverride: {
51
+ compilerOptions: {
52
+ declaration: false,
53
+ declarationMap: false,
54
+ module: "ESNext"
55
+ }
56
+ }
57
+ })
58
+ ],
59
+ external: [
60
+ ...module$1.builtinModules, // 排除 Node.js 内置模块
61
+ ...Object.keys(pkg.dependencies || {}), // 排除 package.json 中的外部依赖
62
+ ],
63
+ },
64
+
65
+ ];
66
+
67
+ exports.default = _rollup_config;