@nest-omni/core 4.1.3-1 → 4.1.3-11
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/audit/audit.module.d.ts +10 -0
- package/audit/audit.module.js +39 -1
- package/audit/controllers/audit.controller.d.ts +24 -0
- package/audit/controllers/audit.controller.js +24 -0
- package/audit/decorators/audit-controller.decorator.d.ts +9 -1
- package/audit/decorators/audit-controller.decorator.js +11 -2
- package/audit/decorators/audit-operation.decorator.d.ts +45 -0
- package/audit/decorators/audit-operation.decorator.js +49 -0
- package/audit/decorators/entity-audit.decorator.d.ts +76 -1
- package/audit/decorators/entity-audit.decorator.js +135 -3
- package/audit/decorators/index.d.ts +1 -0
- package/audit/decorators/index.js +1 -0
- package/audit/dto/audit-log-query.dto.d.ts +3 -0
- package/audit/dto/audit-log-query.dto.js +3 -0
- package/audit/dto/begin-transaction.dto.d.ts +3 -0
- package/audit/dto/begin-transaction.dto.js +3 -0
- package/audit/dto/compare-entities.dto.d.ts +3 -0
- package/audit/dto/compare-entities.dto.js +3 -0
- package/audit/dto/pre-check-restore.dto.d.ts +3 -0
- package/audit/dto/pre-check-restore.dto.js +3 -0
- package/audit/dto/restore-entity.dto.d.ts +3 -0
- package/audit/dto/restore-entity.dto.js +3 -0
- package/audit/entities/entity-audit-log.entity.d.ts +8 -0
- package/audit/entities/entity-audit-log.entity.js +33 -1
- package/audit/entities/entity-transaction.entity.d.ts +10 -0
- package/audit/entities/entity-transaction.entity.js +33 -1
- package/audit/entities/index.d.ts +2 -0
- package/audit/entities/index.js +2 -0
- package/audit/entities/manual-operation-log.entity.d.ts +4 -0
- package/audit/entities/manual-operation-log.entity.js +4 -0
- package/audit/entities/operation-template.entity.d.ts +4 -0
- package/audit/entities/operation-template.entity.js +4 -0
- package/audit/enums/audit.enums.d.ts +45 -5
- package/audit/enums/audit.enums.js +47 -4
- package/audit/index.d.ts +3 -1
- package/audit/index.js +30 -1
- package/audit/interceptors/audit.interceptor.d.ts +15 -0
- package/audit/interceptors/audit.interceptor.js +23 -1
- package/audit/interfaces/audit.interfaces.d.ts +182 -2
- package/audit/services/audit-context.service.d.ts +15 -0
- package/audit/services/audit-context.service.js +15 -0
- package/audit/services/audit-strategy.service.d.ts +6 -0
- package/audit/services/audit-strategy.service.js +13 -0
- package/audit/services/entity-audit.service.d.ts +129 -3
- package/audit/services/entity-audit.service.js +301 -6
- package/audit/services/index.d.ts +2 -0
- package/audit/services/index.js +2 -0
- package/audit/services/manual-audit-log.service.d.ts +124 -0
- package/audit/services/manual-audit-log.service.js +138 -0
- package/audit/services/multi-database.service.d.ts +12 -0
- package/audit/services/multi-database.service.js +12 -0
- package/audit/services/operation-description.service.d.ts +59 -0
- package/audit/services/operation-description.service.js +76 -2
- package/audit/services/transaction-audit.service.d.ts +30 -0
- package/audit/services/transaction-audit.service.js +47 -0
- package/audit/subscribers/entity-audit.subscriber.d.ts +15 -0
- package/audit/subscribers/entity-audit.subscriber.js +29 -1
- package/cache/cache-metrics.service.d.ts +67 -0
- package/cache/cache-metrics.service.js +68 -4
- package/cache/cache-serialization.service.d.ts +31 -0
- package/cache/cache-serialization.service.js +25 -0
- package/cache/cache.constants.d.ts +9 -0
- package/cache/cache.constants.js +9 -0
- package/cache/cache.health.d.ts +26 -0
- package/cache/cache.health.js +30 -0
- package/cache/cache.module.d.ts +86 -0
- package/cache/cache.module.js +71 -0
- package/cache/cache.service.d.ts +140 -0
- package/cache/cache.service.js +157 -0
- package/cache/cache.warmup.service.d.ts +39 -0
- package/cache/cache.warmup.service.js +32 -0
- package/cache/decorators/cache-evict.decorator.d.ts +47 -0
- package/cache/decorators/cache-evict.decorator.js +56 -0
- package/cache/decorators/cache-put.decorator.d.ts +34 -0
- package/cache/decorators/cache-put.decorator.js +39 -0
- package/cache/decorators/cacheable.decorator.d.ts +40 -0
- package/cache/decorators/cacheable.decorator.js +55 -0
- package/cache/dependencies/callback.dependency.d.ts +33 -0
- package/cache/dependencies/callback.dependency.js +39 -1
- package/cache/dependencies/chain.dependency.d.ts +28 -0
- package/cache/dependencies/chain.dependency.js +34 -0
- package/cache/dependencies/db.dependency.d.ts +45 -0
- package/cache/dependencies/db.dependency.js +48 -1
- package/cache/dependencies/file.dependency.d.ts +32 -0
- package/cache/dependencies/file.dependency.js +34 -0
- package/cache/dependencies/tag.dependency.d.ts +36 -0
- package/cache/dependencies/tag.dependency.js +36 -0
- package/cache/dependencies/time.dependency.d.ts +43 -0
- package/cache/dependencies/time.dependency.js +43 -0
- package/cache/examples/basic-usage.d.ts +15 -0
- package/cache/examples/basic-usage.js +62 -8
- package/cache/index.js +9 -0
- package/cache/interfaces/cache-dependency.interface.d.ts +53 -0
- package/cache/interfaces/cache-options.interface.d.ts +81 -0
- package/cache/interfaces/cache-options.interface.js +6 -0
- package/cache/interfaces/cache-provider.interface.d.ts +78 -0
- package/cache/providers/base-cache.provider.d.ts +14 -0
- package/cache/providers/base-cache.provider.js +16 -0
- package/cache/providers/cls-cache.provider.d.ts +20 -0
- package/cache/providers/cls-cache.provider.js +28 -0
- package/cache/providers/memory-cache.provider.d.ts +23 -0
- package/cache/providers/memory-cache.provider.js +26 -0
- package/cache/providers/redis-cache.provider.d.ts +26 -0
- package/cache/providers/redis-cache.provider.js +29 -0
- package/cache/utils/dependency-manager.util.d.ts +52 -0
- package/cache/utils/dependency-manager.util.js +59 -0
- package/cache/utils/key-generator.util.d.ts +42 -0
- package/cache/utils/key-generator.util.js +53 -1
- package/common/abstract.entity.d.ts +14 -0
- package/common/abstract.entity.js +14 -0
- package/common/boilerplate.polyfill.d.ts +142 -4
- package/common/boilerplate.polyfill.js +24 -100
- package/common/dto/dto-container.d.ts +16 -0
- package/common/dto/dto-container.js +20 -0
- package/common/dto/dto-decorators.d.ts +18 -0
- package/common/dto/dto-decorators.js +14 -0
- package/common/dto/dto-extensions.d.ts +11 -0
- package/common/dto/dto-extensions.js +9 -0
- package/common/dto/dto-service-accessor.d.ts +17 -0
- package/common/dto/dto-service-accessor.js +18 -0
- package/common/dto/dto-transformer.d.ts +12 -0
- package/common/dto/dto-transformer.js +9 -0
- package/common/dto/index.js +2 -0
- package/common/examples/paginate-and-map.example.d.ts +6 -0
- package/common/examples/paginate-and-map.example.js +26 -0
- package/common/utils.d.ts +15 -0
- package/common/utils.js +15 -0
- package/constants/language-code.js +1 -0
- package/decorators/field.decorators.js +8 -1
- package/decorators/property.decorators.js +1 -0
- package/decorators/public-route.decorator.js +1 -0
- package/decorators/transform.decorators.d.ts +27 -0
- package/decorators/transform.decorators.js +29 -0
- package/decorators/translate.decorator.js +1 -0
- package/decorators/user.decorator.js +1 -0
- package/decorators/validator.decorators.d.ts +8 -18
- package/decorators/validator.decorators.js +22 -190
- package/filters/constraint-errors.js +1 -0
- package/helpers/common.helper.d.ts +13 -0
- package/helpers/common.helper.js +13 -0
- package/http-client/config/http-client.config.d.ts +15 -0
- package/http-client/config/http-client.config.js +25 -9
- package/http-client/decorators/http-client.decorators.d.ts +63 -0
- package/http-client/decorators/http-client.decorators.js +71 -3
- package/http-client/entities/http-log.entity.d.ts +229 -0
- package/http-client/entities/http-log.entity.js +6 -1
- package/http-client/errors/http-client.errors.d.ts +57 -0
- package/http-client/errors/http-client.errors.js +58 -0
- package/http-client/examples/advanced-usage.example.d.ts +41 -0
- package/http-client/examples/advanced-usage.example.js +68 -24
- package/http-client/examples/auth-with-waiting-lock.example.d.ts +31 -0
- package/http-client/examples/auth-with-waiting-lock.example.js +52 -5
- package/http-client/examples/basic-usage.example.d.ts +60 -0
- package/http-client/examples/basic-usage.example.js +60 -0
- package/http-client/examples/multi-api-configuration.example.d.ts +60 -0
- package/http-client/examples/multi-api-configuration.example.js +76 -5
- package/http-client/http-client.module.d.ts +13 -0
- package/http-client/http-client.module.js +20 -5
- package/http-client/index.js +8 -0
- package/http-client/interfaces/api-client-config.interface.d.ts +125 -0
- package/http-client/interfaces/api-client-config.interface.js +3 -0
- package/http-client/interfaces/http-client-config.interface.d.ts +60 -0
- package/http-client/services/api-client-registry.service.d.ts +57 -0
- package/http-client/services/api-client-registry.service.js +84 -1
- package/http-client/services/cache.service.d.ts +52 -0
- package/http-client/services/cache.service.js +72 -3
- package/http-client/services/circuit-breaker.service.d.ts +46 -0
- package/http-client/services/circuit-breaker.service.js +52 -0
- package/http-client/services/http-client.service.d.ts +67 -0
- package/http-client/services/http-client.service.js +105 -4
- package/http-client/services/http-log-query.service.d.ts +83 -0
- package/http-client/services/http-log-query.service.js +122 -1
- package/http-client/services/http-replay.service.d.ts +101 -0
- package/http-client/services/http-replay.service.js +86 -0
- package/http-client/services/log-cleanup.service.d.ts +63 -0
- package/http-client/services/log-cleanup.service.js +54 -2
- package/http-client/services/logging.service.d.ts +40 -0
- package/http-client/services/logging.service.js +53 -0
- package/http-client/utils/call-stack-extractor.util.d.ts +37 -0
- package/http-client/utils/call-stack-extractor.util.js +48 -0
- package/http-client/utils/context-extractor.util.d.ts +49 -0
- package/http-client/utils/context-extractor.util.js +52 -0
- package/http-client/utils/curl-generator.util.d.ts +21 -0
- package/http-client/utils/curl-generator.util.js +44 -3
- package/http-client/utils/request-id.util.d.ts +18 -0
- package/http-client/utils/request-id.util.js +20 -0
- package/http-client/utils/retry-recorder.util.d.ts +42 -0
- package/http-client/utils/retry-recorder.util.js +44 -0
- package/i18n/en_US/validation.json +2 -1
- package/i18n/zh_CN/validation.json +2 -1
- package/index.js +8 -0
- package/interceptors/translation-interceptor.service.js +5 -0
- package/package.json +1 -1
- package/providers/context.provider.js +2 -0
- package/providers/generator.provider.d.ts +4 -0
- package/providers/generator.provider.js +4 -0
- package/redis-lock/comprehensive-lock-cleanup.service.d.ts +94 -0
- package/redis-lock/comprehensive-lock-cleanup.service.js +253 -0
- package/redis-lock/examples/lock-strategy.examples.d.ts +89 -0
- package/redis-lock/examples/lock-strategy.examples.js +130 -15
- package/redis-lock/index.d.ts +2 -0
- package/redis-lock/index.js +8 -1
- package/redis-lock/lock-heartbeat.service.d.ts +78 -0
- package/redis-lock/lock-heartbeat.service.js +222 -0
- package/redis-lock/redis-lock.decorator.d.ts +101 -0
- package/redis-lock/redis-lock.decorator.js +120 -0
- package/redis-lock/redis-lock.module.d.ts +66 -0
- package/redis-lock/redis-lock.module.js +175 -70
- package/redis-lock/redis-lock.service.d.ts +278 -0
- package/redis-lock/redis-lock.service.js +282 -12
- package/setup/bootstrap.setup.js +20 -0
- package/setup/mode.setup.d.ts +44 -0
- package/setup/mode.setup.js +44 -0
- package/setup/schedule.decorator.d.ts +227 -0
- package/setup/schedule.decorator.js +235 -12
- package/setup/worker.decorator.d.ts +86 -0
- package/setup/worker.decorator.js +88 -0
- package/shared/serviceRegistryModule.js +27 -14
- package/shared/services/api-config.service.d.ts +3 -0
- package/shared/services/api-config.service.js +20 -9
- package/validator-json/decorators.d.ts +17 -0
- package/validator-json/decorators.js +17 -2
- package/validator-json/default.d.ts +6 -0
- package/validator-json/default.js +30 -2
- package/validator-json/defaultConverters.js +1 -0
- package/validator-json/options.d.ts +23 -0
- package/validators/common-validators.d.ts +143 -0
- package/validators/common-validators.js +249 -0
- package/validators/custom-validate.examples.d.ts +96 -0
- package/validators/custom-validate.examples.js +400 -0
- package/validators/custom-validate.validator.d.ts +134 -0
- package/validators/custom-validate.validator.js +214 -0
- package/validators/index.d.ts +2 -0
- package/validators/index.js +2 -0
- package/validators/is-exists.validator.d.ts +18 -4
- package/validators/is-exists.validator.js +67 -6
- package/validators/is-unique.validator.d.ts +32 -5
- package/validators/is-unique.validator.js +99 -17
- package/validators/skip-empty.validator.d.ts +5 -0
- package/validators/skip-empty.validator.js +5 -0
- package/vault/interfaces/vault-options.interface.d.ts +9 -0
- package/vault/vault-config.loader.d.ts +30 -0
- package/vault/vault-config.loader.js +48 -1
- package/vault/vault-config.service.d.ts +53 -0
- package/vault/vault-config.service.js +57 -0
- package/vault/vault.module.d.ts +4 -0
- package/vault/vault.module.js +4 -0
- package/decorators/examples/validation-decorators.example.d.ts +0 -69
- package/decorators/examples/validation-decorators.example.js +0 -331
package/setup/mode.setup.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Application Mode Detection and Management System
|
|
4
|
+
*
|
|
5
|
+
* This module provides utilities for detecting and managing different application modes:
|
|
6
|
+
* - HTTP: Only HTTP server (no workers/schedulers)
|
|
7
|
+
* - WORKER: Only background workers and schedulers (no HTTP server)
|
|
8
|
+
* - HYBRID: Both HTTP server and workers (default)
|
|
9
|
+
*/
|
|
2
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
11
|
exports.ApplicationMode = void 0;
|
|
4
12
|
exports.getApplicationMode = getApplicationMode;
|
|
@@ -14,6 +22,12 @@ var ApplicationMode;
|
|
|
14
22
|
ApplicationMode["WORKER"] = "worker";
|
|
15
23
|
ApplicationMode["HYBRID"] = "hybrid";
|
|
16
24
|
})(ApplicationMode || (exports.ApplicationMode = ApplicationMode = {}));
|
|
25
|
+
/**
|
|
26
|
+
* Get the current application mode from environment variables
|
|
27
|
+
* Supports both APP_MODE and MODE environment variables
|
|
28
|
+
*
|
|
29
|
+
* @returns The current application mode
|
|
30
|
+
*/
|
|
17
31
|
function getApplicationMode() {
|
|
18
32
|
const mode = (process.env.APP_MODE || process.env.MODE || 'hybrid')
|
|
19
33
|
.toLowerCase()
|
|
@@ -28,23 +42,53 @@ function getApplicationMode() {
|
|
|
28
42
|
return ApplicationMode.HYBRID;
|
|
29
43
|
}
|
|
30
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Check if the current mode should process queues and scheduled tasks
|
|
47
|
+
*
|
|
48
|
+
* @returns True if workers should be registered
|
|
49
|
+
*/
|
|
31
50
|
function shouldProcessQueues() {
|
|
32
51
|
const mode = getApplicationMode();
|
|
33
52
|
return mode === ApplicationMode.WORKER || mode === ApplicationMode.HYBRID;
|
|
34
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Check if the current mode should start HTTP server
|
|
56
|
+
*
|
|
57
|
+
* @returns True if HTTP server should be started
|
|
58
|
+
*/
|
|
35
59
|
function shouldStartHttpServer() {
|
|
36
60
|
const mode = getApplicationMode();
|
|
37
61
|
return mode === ApplicationMode.HTTP || mode === ApplicationMode.HYBRID;
|
|
38
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Check if running in HTTP-only mode
|
|
65
|
+
*
|
|
66
|
+
* @returns True if running in HTTP-only mode
|
|
67
|
+
*/
|
|
39
68
|
function isHttpMode() {
|
|
40
69
|
return getApplicationMode() === ApplicationMode.HTTP;
|
|
41
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Check if running in Worker-only mode
|
|
73
|
+
*
|
|
74
|
+
* @returns True if running in Worker-only mode
|
|
75
|
+
*/
|
|
42
76
|
function isWorkerMode() {
|
|
43
77
|
return getApplicationMode() === ApplicationMode.WORKER;
|
|
44
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Check if running in Hybrid mode
|
|
81
|
+
*
|
|
82
|
+
* @returns True if running in Hybrid mode
|
|
83
|
+
*/
|
|
45
84
|
function isHybridMode() {
|
|
46
85
|
return getApplicationMode() === ApplicationMode.HYBRID;
|
|
47
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Get a human-readable description of the current mode
|
|
89
|
+
*
|
|
90
|
+
* @returns Description of the current mode
|
|
91
|
+
*/
|
|
48
92
|
function getModeDescription() {
|
|
49
93
|
const mode = getApplicationMode();
|
|
50
94
|
switch (mode) {
|
|
@@ -1,23 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced Schedule Decorators for Worker Mode
|
|
3
|
+
*
|
|
4
|
+
* This module provides decorators for scheduled tasks that:
|
|
5
|
+
* - Only run in Worker or Hybrid mode (not in HTTP-only mode)
|
|
6
|
+
* - Support distributed locking via Redis
|
|
7
|
+
* - Support retry logic for failed tasks
|
|
8
|
+
* - Provide automatic lock key generation
|
|
9
|
+
* - Support task execution logging and error handling
|
|
10
|
+
*/
|
|
1
11
|
import type { CronOptions } from '@nestjs/schedule';
|
|
12
|
+
/**
|
|
13
|
+
* Options for schedule decorators with lock support
|
|
14
|
+
*/
|
|
2
15
|
export interface ScheduleWithLockOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Lock TTL in milliseconds
|
|
18
|
+
* For Cron: defaults to 3600000 (1 hour)
|
|
19
|
+
* For Interval: defaults to 80% of interval duration
|
|
20
|
+
* For Timeout: defaults to 300000 (5 minutes)
|
|
21
|
+
*/
|
|
3
22
|
lockTtl?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Number of retry attempts if task fails
|
|
25
|
+
* @default 0
|
|
26
|
+
*/
|
|
4
27
|
retryCount?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Delay between retry attempts in milliseconds
|
|
30
|
+
* @default 1000
|
|
31
|
+
*/
|
|
5
32
|
retryDelay?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Whether to use exponential backoff for retries
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
6
37
|
useExponentialBackoff?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Maximum retry delay in milliseconds (for exponential backoff)
|
|
40
|
+
* @default 60000 (1 minute)
|
|
41
|
+
*/
|
|
7
42
|
maxRetryDelay?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Whether to log task execution
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
8
47
|
logExecution?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Custom lock key prefix
|
|
50
|
+
* @default 'schedule'
|
|
51
|
+
*/
|
|
9
52
|
lockKeyPrefix?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Automatic lock extension interval in milliseconds
|
|
55
|
+
* If set, the lock will be automatically extended at this interval
|
|
56
|
+
* @default 0 (no automatic extension)
|
|
57
|
+
*/
|
|
10
58
|
autoExtendLock?: number;
|
|
59
|
+
/**
|
|
60
|
+
* Callback function when task execution succeeds
|
|
61
|
+
*/
|
|
11
62
|
onSuccess?: (duration: number) => void | Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Callback function when task execution fails
|
|
65
|
+
*/
|
|
12
66
|
onError?: (error: Error) => void | Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Whether to skip execution if lock cannot be acquired
|
|
69
|
+
* @default true
|
|
70
|
+
*/
|
|
13
71
|
skipIfLocked?: boolean;
|
|
14
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Cron decorator that only executes in Worker or Hybrid mode
|
|
75
|
+
*
|
|
76
|
+
* @param cronTime - Cron expression
|
|
77
|
+
* @param options - Cron options
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* @WorkerCron('0 0 * * *') // Run daily at midnight
|
|
82
|
+
* async dailyTask() {
|
|
83
|
+
* // Task logic
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
15
87
|
export declare function WorkerCron(cronTime: string | Date, options?: CronOptions): MethodDecorator;
|
|
88
|
+
/**
|
|
89
|
+
* Interval decorator that only executes in Worker or Hybrid mode
|
|
90
|
+
*
|
|
91
|
+
* @param timeout - Interval in milliseconds
|
|
92
|
+
* @param name - Optional name for the interval
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* @WorkerInterval(60000) // Run every minute
|
|
97
|
+
* async minutelyTask() {
|
|
98
|
+
* // Task logic
|
|
99
|
+
* }
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
16
102
|
export declare function WorkerInterval(timeout: number, name?: string): MethodDecorator;
|
|
103
|
+
/**
|
|
104
|
+
* Timeout decorator that only executes in Worker or Hybrid mode
|
|
105
|
+
*
|
|
106
|
+
* @param timeout - Timeout in milliseconds
|
|
107
|
+
* @param name - Optional name for the timeout
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* @WorkerTimeout(5000) // Run once after 5 seconds
|
|
112
|
+
* async startupTask() {
|
|
113
|
+
* // Task logic
|
|
114
|
+
* }
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
17
117
|
export declare function WorkerTimeout(timeout: number, name?: string): MethodDecorator;
|
|
118
|
+
/**
|
|
119
|
+
* Cron decorator with distributed lock support
|
|
120
|
+
* Automatically generates lock key from class and method name
|
|
121
|
+
*
|
|
122
|
+
* @param cronTime - Cron expression
|
|
123
|
+
* @param lockKeyOrOptions - Lock key (string) or options object
|
|
124
|
+
* @param lockTtl - Lock TTL in milliseconds (only if lockKeyOrOptions is a string)
|
|
125
|
+
*
|
|
126
|
+
* @param cronOptions
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* // Using string lock key
|
|
130
|
+
* @WorkerCronWithLock('0 * * * *', 'hourly-task', 3600000)
|
|
131
|
+
* async hourlyTask() {
|
|
132
|
+
* // Task logic
|
|
133
|
+
* }
|
|
134
|
+
*
|
|
135
|
+
* // Using options object (auto-generates lock key)
|
|
136
|
+
* @WorkerCronWithLock('0 * * * *', { lockTtl: 3600000, retryCount: 3 })
|
|
137
|
+
* async hourlyTask() {
|
|
138
|
+
* // Task logic
|
|
139
|
+
* }
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
18
142
|
export declare function WorkerCronWithLock(cronTime: string | Date, lockKeyOrOptions: string | ScheduleWithLockOptions, lockTtl?: number, cronOptions?: CronOptions): MethodDecorator;
|
|
143
|
+
/**
|
|
144
|
+
* Interval decorator with distributed lock support
|
|
145
|
+
*
|
|
146
|
+
* @param timeout - Interval in milliseconds
|
|
147
|
+
* @param lockKeyOrOptions - Lock key (string) or options object
|
|
148
|
+
* @param lockTtl - Lock TTL in milliseconds (only if lockKeyOrOptions is a string)
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```typescript
|
|
152
|
+
* // Using string lock key
|
|
153
|
+
* @WorkerIntervalWithLock(60000, 'status-check', 50000)
|
|
154
|
+
* async checkStatus() {
|
|
155
|
+
* // Task logic
|
|
156
|
+
* }
|
|
157
|
+
*
|
|
158
|
+
* // Using options object (auto-generates lock key)
|
|
159
|
+
* @WorkerIntervalWithLock(60000, { retryCount: 2 })
|
|
160
|
+
* async checkStatus() {
|
|
161
|
+
* // Task logic
|
|
162
|
+
* }
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
19
165
|
export declare function WorkerIntervalWithLock(timeout: number, lockKeyOrOptions: string | ScheduleWithLockOptions, lockTtl?: number): MethodDecorator;
|
|
166
|
+
/**
|
|
167
|
+
* Timeout decorator with distributed lock support
|
|
168
|
+
*
|
|
169
|
+
* @param timeout - Timeout in milliseconds
|
|
170
|
+
* @param lockKeyOrOptions - Lock key (string) or options object
|
|
171
|
+
* @param lockTtl - Lock TTL in milliseconds (only if lockKeyOrOptions is a string)
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```typescript
|
|
175
|
+
* // Using string lock key
|
|
176
|
+
* @WorkerTimeoutWithLock(5000, 'init-task', 10000)
|
|
177
|
+
* async initializeSystem() {
|
|
178
|
+
* // Task logic
|
|
179
|
+
* }
|
|
180
|
+
*
|
|
181
|
+
* // Using options object (auto-generates lock key)
|
|
182
|
+
* @WorkerTimeoutWithLock(5000, { lockTtl: 10000 })
|
|
183
|
+
* async initializeSystem() {
|
|
184
|
+
* // Task logic
|
|
185
|
+
* }
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
20
188
|
export declare function WorkerTimeoutWithLock(timeout: number, lockKeyOrOptions: string | ScheduleWithLockOptions, lockTtl?: number): MethodDecorator;
|
|
189
|
+
/**
|
|
190
|
+
* Smart Cron decorator with auto-generated lock key and intelligent defaults
|
|
191
|
+
* Recommended for most use cases
|
|
192
|
+
*
|
|
193
|
+
* @param cronTime - Cron expression
|
|
194
|
+
* @param options - Schedule options
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```typescript
|
|
198
|
+
* @WorkerCronSmart('0 * * * *') // Run hourly with auto-generated lock key
|
|
199
|
+
* async hourlyTask() {
|
|
200
|
+
* // Task logic
|
|
201
|
+
* }
|
|
202
|
+
*
|
|
203
|
+
* @WorkerCronSmart('0 0 * * *', {
|
|
204
|
+
* lockTtl: 7200000, // 2 hours
|
|
205
|
+
* retryCount: 3,
|
|
206
|
+
* onError: (error) => console.error('Task failed:', error),
|
|
207
|
+
* })
|
|
208
|
+
* async dailyTask() {
|
|
209
|
+
* // Task logic
|
|
210
|
+
* }
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
21
213
|
export declare function WorkerCronSmart(cronTime: string | Date, options?: ScheduleWithLockOptions, cronOptions?: CronOptions): MethodDecorator;
|
|
214
|
+
/**
|
|
215
|
+
* Smart Interval decorator with auto-generated lock key and intelligent defaults
|
|
216
|
+
* Lock TTL is automatically set to 80% of interval duration
|
|
217
|
+
*
|
|
218
|
+
* @param timeout - Interval in milliseconds
|
|
219
|
+
* @param options - Schedule options
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```typescript
|
|
223
|
+
* @WorkerIntervalSmart(120000) // Run every 2 minutes, lock for ~1.6 minutes
|
|
224
|
+
* async checkStatus() {
|
|
225
|
+
* // Task logic
|
|
226
|
+
* }
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
22
229
|
export declare function WorkerIntervalSmart(timeout: number, options?: ScheduleWithLockOptions): MethodDecorator;
|
|
230
|
+
/**
|
|
231
|
+
* Advanced Cron decorator with full control
|
|
232
|
+
* Alias for WorkerCronSmart with explicit lock key parameter
|
|
233
|
+
*
|
|
234
|
+
* @param cronTime - Cron expression
|
|
235
|
+
* @param lockKeyOrOptions - Lock key (string) or options object
|
|
236
|
+
* @param options - Schedule options (only if lockKeyOrOptions is a string)
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ```typescript
|
|
240
|
+
* @WorkerCronAdvanced('0 0 * * *', 'daily-report', {
|
|
241
|
+
* lockTtl: 7200000,
|
|
242
|
+
* retryCount: 5,
|
|
243
|
+
* useExponentialBackoff: true,
|
|
244
|
+
* })
|
|
245
|
+
* async generateDailyReport() {
|
|
246
|
+
* // Task logic
|
|
247
|
+
* }
|
|
248
|
+
* ```
|
|
249
|
+
*/
|
|
23
250
|
export declare function WorkerCronAdvanced(cronTime: string | Date, lockKeyOrOptions: string | ScheduleWithLockOptions, options?: ScheduleWithLockOptions, cronOptions?: CronOptions): MethodDecorator;
|