koatty_schedule 2.0.0 → 2.1.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.
- package/.rollup.config.js +48 -51
- package/CHANGELOG.md +25 -0
- package/dist/index.d.ts +50 -24
- package/dist/index.js +718 -228
- package/dist/index.mjs +718 -213
- package/dist/package.json +26 -18
- package/package.json +26 -18
package/.rollup.config.js
CHANGED
|
@@ -3,61 +3,58 @@
|
|
|
3
3
|
* @Usage:
|
|
4
4
|
* @Author: richen
|
|
5
5
|
* @Date: 2021-12-17 10:20:44
|
|
6
|
-
* @LastEditTime:
|
|
6
|
+
* @LastEditTime: 2024-11-04 22:04:45
|
|
7
7
|
*/
|
|
8
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
8
9
|
import json from "@rollup/plugin-json";
|
|
10
|
+
import resolve from '@rollup/plugin-node-resolve';
|
|
11
|
+
import { builtinModules } from 'module';
|
|
12
|
+
import del from "rollup-plugin-delete";
|
|
9
13
|
import typescript from 'rollup-plugin-typescript2';
|
|
10
14
|
// import babel from '@rollup/plugin-babel';
|
|
15
|
+
const pkg = require('./package.json');
|
|
11
16
|
|
|
12
17
|
export default [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
declaration: false,
|
|
56
|
-
declarationMap: false,
|
|
57
|
-
module: "ESNext"
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
|
-
]
|
|
62
|
-
}
|
|
18
|
+
{
|
|
19
|
+
input: './src/index.ts',
|
|
20
|
+
output: [
|
|
21
|
+
{
|
|
22
|
+
format: 'cjs',
|
|
23
|
+
file: './dist/index.js',
|
|
24
|
+
banner: require('./scripts/copyright'),
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
format: 'es',
|
|
28
|
+
file: './dist/index.mjs',
|
|
29
|
+
banner: require('./scripts/copyright'),
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
plugins: [
|
|
33
|
+
del({ targets: ["dist/*", "temp/*", "docs/api"] }),
|
|
34
|
+
// babel({
|
|
35
|
+
// babelHelpers: "runtime",
|
|
36
|
+
// configFile: './babel.config.js',
|
|
37
|
+
// exclude: 'node_modules/**',
|
|
38
|
+
// }),
|
|
39
|
+
json(),
|
|
40
|
+
resolve({
|
|
41
|
+
preferBuiltins: true, // 优先选择内置模块
|
|
42
|
+
}),
|
|
43
|
+
commonjs(),
|
|
44
|
+
typescript({
|
|
45
|
+
tsconfigOverride: {
|
|
46
|
+
compilerOptions: {
|
|
47
|
+
declaration: false,
|
|
48
|
+
declarationMap: false,
|
|
49
|
+
module: "ESNext"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
],
|
|
54
|
+
external: [
|
|
55
|
+
...builtinModules, // 排除 Node.js 内置模块
|
|
56
|
+
...Object.keys(pkg.dependencies || {}), // 排除 package.json 中的外部依赖
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
|
|
63
60
|
]
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
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
4
|
|
|
5
|
+
### [2.1.1](https://github.com/thinkkoa/koatty_schedule/compare/v2.1.0...v2.1.1) (2025-06-09)
|
|
6
|
+
|
|
7
|
+
### [1.6.2](https://github.com/thinkkoa/koatty_schedule/compare/v2.0.1...v1.6.2) (2024-11-07)
|
|
8
|
+
|
|
9
|
+
## [2.1.0](https://github.com/thinkkoa/koatty_schedule/compare/v2.0.1...v2.1.0) (2025-06-09)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* add schedule and redlock decorators with config management ([c1b5359](https://github.com/thinkkoa/koatty_schedule/commit/c1b535940df2b8a3403bf024137519246945870e))
|
|
15
|
+
* enhance ConfigManager with singleton pattern, environment config loading ([00db6eb](https://github.com/thinkkoa/koatty_schedule/commit/00db6eb97bdae226aaf433b23c770704b33d05e8))
|
|
16
|
+
* introduce DecoratorType enum, refactor decorator management system, ([e58e718](https://github.com/thinkkoa/koatty_schedule/commit/e58e718975e663820778352bedb6421e6852ba9f))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* simplify error handling in ConfigManager and RedLocker ([7be75fc](https://github.com/thinkkoa/koatty_schedule/commit/7be75fc7f4160094b57ca64905df4c81f77adb51))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Refactor
|
|
25
|
+
|
|
26
|
+
* use MethodDecoratorManager ([ff077c7](https://github.com/thinkkoa/koatty_schedule/commit/ff077c7211bb6cf258c6885e1d7dcbdacde90ef1))
|
|
27
|
+
|
|
28
|
+
### [2.0.1](https://github.com/thinkkoa/koatty_schedule/compare/v2.0.0...v2.0.1) (2024-01-17)
|
|
29
|
+
|
|
5
30
|
## [2.0.0](https://github.com/thinkkoa/koatty_schedule/compare/v1.6.0...v2.0.0) (2024-01-17)
|
|
6
31
|
|
|
7
32
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,49 +1,55 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @Author: richen
|
|
3
|
-
* @Date:
|
|
3
|
+
* @Date: 2025-06-10 01:38:16
|
|
4
4
|
* @License: BSD (3-Clause)
|
|
5
5
|
* @Copyright (c) - <richenlin(at)gmail.com>
|
|
6
6
|
* @HomePage: https://koatty.org/
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import { Settings } from '@sesamecare-oss/redlock';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Decorator types supported by the system
|
|
12
|
+
*/
|
|
13
|
+
export declare enum DecoratorType {
|
|
14
|
+
SCHEDULED = "SCHEDULED",
|
|
15
|
+
REDLOCK = "REDLOCK"
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Redis-based distributed lock decorator with optimized preprocessing
|
|
12
20
|
*
|
|
13
21
|
* @export
|
|
14
|
-
* @param {string} [name] The locker name. If name is duplicated, lock sharing contention will result.
|
|
15
|
-
* @param {
|
|
16
|
-
*
|
|
22
|
+
* @param {string} [name] - The locker name. If name is duplicated, lock sharing contention will result.
|
|
23
|
+
* @param {RedLockOptions} [options] - RedLock configuration options
|
|
24
|
+
*
|
|
25
|
+
* Options:
|
|
26
|
+
* - lockTimeOut?: number - Lock timeout in milliseconds (default: 10000)
|
|
27
|
+
* - retryCount?: number - The max number of times Redlock will attempt to lock a resource (default: 3)
|
|
28
|
+
* - RedisOptions: RedisOptions - Redis connection configuration
|
|
17
29
|
*
|
|
18
30
|
* @returns {MethodDecorator}
|
|
31
|
+
* @throws {Error} When decorator is used on wrong class type or invalid configuration
|
|
19
32
|
*/
|
|
20
|
-
export declare function RedLock(
|
|
33
|
+
export declare function RedLock(lockName?: string, options?: RedLockOptions): MethodDecorator;
|
|
21
34
|
|
|
22
35
|
/**
|
|
23
|
-
*
|
|
24
|
-
* @return {*}
|
|
36
|
+
* Configuration options for RedLock
|
|
25
37
|
*/
|
|
26
|
-
declare interface RedLockOptions {
|
|
27
|
-
/**
|
|
28
|
-
* lock a resource times
|
|
29
|
-
*/
|
|
38
|
+
export declare interface RedLockOptions extends Partial<Settings> {
|
|
30
39
|
lockTimeOut?: number;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
retryCount?: number;
|
|
35
|
-
/**
|
|
36
|
-
* redis config
|
|
37
|
-
*/
|
|
38
|
-
RedisOptions: RedisOptions;
|
|
40
|
+
clockDriftFactor?: number;
|
|
41
|
+
maxRetries?: number;
|
|
42
|
+
retryDelayMs?: number;
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
/**
|
|
42
|
-
* Schedule task
|
|
46
|
+
* Schedule task decorator with optimized preprocessing
|
|
43
47
|
*
|
|
44
48
|
* @export
|
|
45
|
-
* @param {string} cron
|
|
46
|
-
* @param {string} timezone
|
|
49
|
+
* @param {string} cron - Cron expression for task scheduling
|
|
50
|
+
* @param {string} [timezone='Asia/Beijing'] - Timezone for the schedule
|
|
51
|
+
*
|
|
52
|
+
* Cron expression format:
|
|
47
53
|
* * Seconds: 0-59
|
|
48
54
|
* * Minutes: 0-59
|
|
49
55
|
* * Hours: 0-23
|
|
@@ -52,7 +58,27 @@ declare interface RedLockOptions {
|
|
|
52
58
|
* * Day of Week: 1-7 (Sun-Sat)
|
|
53
59
|
*
|
|
54
60
|
* @returns {MethodDecorator}
|
|
61
|
+
* @throws {Error} When cron expression is invalid or decorator is used on wrong class type
|
|
55
62
|
*/
|
|
56
63
|
export declare function Scheduled(cron: string, timezone?: string): MethodDecorator;
|
|
57
64
|
|
|
65
|
+
/**
|
|
66
|
+
* @deprecated Use RedLock instead. This will be removed in v3.0.0
|
|
67
|
+
*/
|
|
68
|
+
export declare const SchedulerLock: typeof RedLock;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Validate cron expression format
|
|
72
|
+
* @param cron - Cron expression to validate
|
|
73
|
+
* @throws {Error} When cron expression is invalid
|
|
74
|
+
*/
|
|
75
|
+
export declare function validateCronExpression(cron: string): void;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Validate RedLock options
|
|
79
|
+
* @param options - RedLock options to validate
|
|
80
|
+
* @throws {Error} When options are invalid
|
|
81
|
+
*/
|
|
82
|
+
export declare function validateRedLockOptions(options: RedLockOptions): void;
|
|
83
|
+
|
|
58
84
|
export { }
|