@clairejs/server 3.12.11 → 3.12.13
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/.prettierrc +8 -8
- package/README.md +824 -818
- package/dist/common/AbstractController.d.ts +3 -0
- package/dist/{http/controller → common}/ControllerMetadata.d.ts +6 -6
- package/dist/common/FileOperation.d.ts +5 -5
- package/dist/common/ServerModelMetadata.d.ts +10 -10
- package/dist/common/Transactionable.d.ts +7 -7
- package/dist/common/auth/AbstractPrincipalResolver.d.ts +4 -4
- package/dist/common/auth/IPrincipal.d.ts +4 -4
- package/dist/common/constants.d.ts +1 -1
- package/dist/common/decorator.d.ts +5 -0
- package/dist/common/request/EndpointMetadata.d.ts +40 -40
- package/dist/common/request/HttpData.d.ts +1 -1
- package/dist/common/request/HttpEndpoint.d.ts +8 -8
- package/dist/common/request/JobData.d.ts +1 -1
- package/dist/common/request/MountedEndpointInfo.d.ts +6 -6
- package/dist/common/request/RequestOptions.d.ts +8 -8
- package/dist/common/request/SocketData.d.ts +1 -1
- package/dist/common/request/types.d.ts +1 -1
- package/dist/controllers/FileManageController.d.ts +14 -14
- package/dist/controllers/FileUploadController.d.ts +13 -13
- package/dist/controllers/dto/permissions.d.ts +20 -20
- package/dist/controllers/dto/system.d.ts +12 -12
- package/dist/controllers/dto/upload.d.ts +40 -40
- package/dist/controllers/models/SystemSetting.d.ts +5 -5
- package/dist/http/auth/AbstractHttpAuthorizer.d.ts +9 -9
- package/dist/http/auth/AbstractRbacHttpAuthorizer.d.ts +18 -18
- package/dist/http/auth/RedisRbacHttpAuthorizer.d.ts +24 -24
- package/dist/http/auth/SocketRbacHttpAuthorizer.d.ts +25 -25
- package/dist/http/auth/rbac.d.ts +34 -34
- package/dist/http/common/HttpRequest.d.ts +40 -40
- package/dist/http/common/HttpResponse.d.ts +34 -34
- package/dist/http/controller/AbstractHttpController.d.ts +8 -8
- package/dist/http/controller/AbstractHttpMiddleware.d.ts +10 -10
- package/dist/http/controller/AbstractHttpRequestHandler.d.ts +18 -18
- package/dist/http/controller/CrudHttpController.d.ts +41 -41
- package/dist/http/controller/DefaultHttpRequestHandler.d.ts +21 -21
- package/dist/http/decorators.d.ts +33 -36
- package/dist/http/file-upload/AbstractFileUploadHandler.d.ts +7 -7
- package/dist/http/file-upload/FileUploadHandler.d.ts +11 -11
- package/dist/http/file-upload/types.d.ts +1 -1
- package/dist/http/repository/AbstractRepository.d.ts +10 -10
- package/dist/http/repository/DtoRepository.d.ts +58 -58
- package/dist/http/repository/ICrudRepository.d.ts +27 -27
- package/dist/http/repository/ModelRepository.d.ts +37 -37
- package/dist/http/security/AbstractAccessCondition.d.ts +7 -7
- package/dist/http/security/access-conditions/DtoFieldValidation.d.ts +4 -4
- package/dist/http/security/access-conditions/FilterModelFieldAccessCondition.d.ts +4 -4
- package/dist/http/security/access-conditions/MaximumQueryLimit.d.ts +8 -8
- package/dist/http/security/cors.d.ts +6 -6
- package/dist/index.d.ts +74 -71
- package/dist/index.js +1 -1
- package/dist/job/AbstractJobController.d.ts +5 -5
- package/dist/job/AbstractJobRepository.d.ts +17 -17
- package/dist/job/AbstractJobScheduler.d.ts +38 -38
- package/dist/job/AwsJobScheduler.d.ts +48 -48
- package/dist/job/LocalJobScheduler.d.ts +88 -88
- package/dist/job/decorators.d.ts +5 -5
- package/dist/job/interfaces.d.ts +50 -50
- package/dist/logging/FileLogMedium.d.ts +13 -13
- package/dist/services/AbstractCacheService.d.ts +22 -22
- package/dist/services/AbstractFileService.d.ts +15 -15
- package/dist/services/AbstractMailService.d.ts +31 -31
- package/dist/services/AbstractService.d.ts +3 -3
- package/dist/services/AbstractSmsService.d.ts +12 -12
- package/dist/services/LocalFileService.d.ts +21 -21
- package/dist/services/ProxyFileService.d.ts +20 -20
- package/dist/services/RedisCacheService.d.ts +25 -25
- package/dist/services/S3FileService.d.ts +36 -36
- package/dist/services/SystemService.d.ts +15 -15
- package/dist/socket/AbstractServerSocket.d.ts +18 -18
- package/dist/socket/AbstractServerSocketManager.d.ts +46 -46
- package/dist/socket/AbstractSocketConnectionHandler.d.ts +6 -6
- package/dist/socket/AbstractSocketController.d.ts +14 -14
- package/dist/socket/AwsSocketManager.d.ts +30 -30
- package/dist/socket/IServerSocket.d.ts +16 -16
- package/dist/socket/LocalSocketManager.d.ts +47 -47
- package/dist/system/ClaireServer.d.ts +13 -13
- package/dist/system/ExpressWrapper.d.ts +19 -19
- package/dist/system/LambdaWrapper.d.ts +25 -25
- package/dist/system/ServerGlobalStore.d.ts +5 -5
- package/dist/system/errors.d.ts +14 -14
- package/dist/system/lamba-request-mapper.d.ts +2 -2
- package/dist/system/locale/LocaleEntry.d.ts +3 -3
- package/dist/system/locale/LocaleTranslation.d.ts +6 -6
- package/dist/system/locale/decorators.d.ts +2 -2
- package/package.json +67 -67
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Transactionable } from "../common/Transactionable";
|
|
2
|
-
import { JobInfoMetadata } from "./interfaces";
|
|
3
|
-
export declare abstract class AbstractJobController extends Transactionable {
|
|
4
|
-
getAllJobs(): JobInfoMetadata[];
|
|
5
|
-
}
|
|
1
|
+
import { Transactionable } from "../common/Transactionable";
|
|
2
|
+
import { JobInfoMetadata } from "./interfaces";
|
|
3
|
+
export declare abstract class AbstractJobController extends Transactionable {
|
|
4
|
+
getAllJobs(): JobInfoMetadata[];
|
|
5
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { CustomJobInfo } from "./interfaces";
|
|
2
|
-
export declare abstract class AbstractJobRepository {
|
|
3
|
-
/**
|
|
4
|
-
* Return all persisted jobs
|
|
5
|
-
*/
|
|
6
|
-
abstract getJobs(): Promise<CustomJobInfo[]>;
|
|
7
|
-
/**
|
|
8
|
-
* Save the job info and return a unique id
|
|
9
|
-
* @param jobInfo The custom job info to save
|
|
10
|
-
*/
|
|
11
|
-
abstract saveJob(jobInfo: CustomJobInfo): Promise<string>;
|
|
12
|
-
/**
|
|
13
|
-
* Remove job info by id
|
|
14
|
-
* @param jobId Unique id of job
|
|
15
|
-
*/
|
|
16
|
-
abstract removeJobById(jobId: string): Promise<void>;
|
|
17
|
-
}
|
|
1
|
+
import { CustomJobInfo } from "./interfaces";
|
|
2
|
+
export declare abstract class AbstractJobRepository {
|
|
3
|
+
/**
|
|
4
|
+
* Return all persisted jobs
|
|
5
|
+
*/
|
|
6
|
+
abstract getJobs(): Promise<CustomJobInfo[]>;
|
|
7
|
+
/**
|
|
8
|
+
* Save the job info and return a unique id
|
|
9
|
+
* @param jobInfo The custom job info to save
|
|
10
|
+
*/
|
|
11
|
+
abstract saveJob(jobInfo: CustomJobInfo): Promise<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Remove job info by id
|
|
14
|
+
* @param jobId Unique id of job
|
|
15
|
+
*/
|
|
16
|
+
abstract removeJobById(jobId: string): Promise<void>;
|
|
17
|
+
}
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { AbstractLogger } from "@clairejs/core";
|
|
2
|
-
import { CustomJobInfo, JobInfo, JobInfoMetadata, ScheduledJob } from "./interfaces";
|
|
3
|
-
interface JobHandlerMetadata extends JobInfoMetadata {
|
|
4
|
-
handlerFn: (params?: any[]) => Promise<void>;
|
|
5
|
-
}
|
|
6
|
-
export declare abstract class AbstractJobScheduler {
|
|
7
|
-
readonly logger: AbstractLogger;
|
|
8
|
-
protected abstract isActiveScheduler(): boolean;
|
|
9
|
-
private _jobs;
|
|
10
|
-
constructor(logger: AbstractLogger);
|
|
11
|
-
protected getAvailableJobInfo(): Promise<JobHandlerMetadata[]>;
|
|
12
|
-
abstract getAllScheduledJobs(): Promise<ScheduledJob[]>;
|
|
13
|
-
/**
|
|
14
|
-
* Return unique job id which can then be used to cancel the job
|
|
15
|
-
* @param jobInfo the necessary info to launch the job
|
|
16
|
-
*/
|
|
17
|
-
protected abstract scheduleJob(jobInfo: JobInfo): Promise<string>;
|
|
18
|
-
/**
|
|
19
|
-
* Sync all jobs to running state. This should be called only at init time.
|
|
20
|
-
*/
|
|
21
|
-
abstract syncJobs(): Promise<void>;
|
|
22
|
-
/**
|
|
23
|
-
* Return unique job id which can then be used to cancel the job
|
|
24
|
-
* @param jobInfo the necessary info to launch the job
|
|
25
|
-
*/
|
|
26
|
-
scheduleJobAt(jobInfo: CustomJobInfo): Promise<string>;
|
|
27
|
-
/**
|
|
28
|
-
* Remove the scheduled job and prevent if from running in the future
|
|
29
|
-
* @param jobId The job id returned from scheduleJobAt function
|
|
30
|
-
*/
|
|
31
|
-
abstract removeJob(jobId: string): Promise<void>;
|
|
32
|
-
/**
|
|
33
|
-
* Execute the scheduled job
|
|
34
|
-
* @param job The schedled job info to execute
|
|
35
|
-
*/
|
|
36
|
-
protected executeJob(job: ScheduledJob): Promise<void>;
|
|
37
|
-
}
|
|
38
|
-
export {};
|
|
1
|
+
import { AbstractLogger } from "@clairejs/core";
|
|
2
|
+
import { CustomJobInfo, JobInfo, JobInfoMetadata, ScheduledJob } from "./interfaces";
|
|
3
|
+
interface JobHandlerMetadata extends JobInfoMetadata {
|
|
4
|
+
handlerFn: (params?: any[]) => Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
export declare abstract class AbstractJobScheduler {
|
|
7
|
+
readonly logger: AbstractLogger;
|
|
8
|
+
protected abstract isActiveScheduler(): boolean;
|
|
9
|
+
private _jobs;
|
|
10
|
+
constructor(logger: AbstractLogger);
|
|
11
|
+
protected getAvailableJobInfo(): Promise<JobHandlerMetadata[]>;
|
|
12
|
+
abstract getAllScheduledJobs(): Promise<ScheduledJob[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Return unique job id which can then be used to cancel the job
|
|
15
|
+
* @param jobInfo the necessary info to launch the job
|
|
16
|
+
*/
|
|
17
|
+
protected abstract scheduleJob(jobInfo: JobInfo): Promise<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Sync all jobs to running state. This should be called only at init time.
|
|
20
|
+
*/
|
|
21
|
+
abstract syncJobs(): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Return unique job id which can then be used to cancel the job
|
|
24
|
+
* @param jobInfo the necessary info to launch the job
|
|
25
|
+
*/
|
|
26
|
+
scheduleJobAt(jobInfo: CustomJobInfo): Promise<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Remove the scheduled job and prevent if from running in the future
|
|
29
|
+
* @param jobId The job id returned from scheduleJobAt function
|
|
30
|
+
*/
|
|
31
|
+
abstract removeJob(jobId: string): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Execute the scheduled job
|
|
34
|
+
* @param job The schedled job info to execute
|
|
35
|
+
*/
|
|
36
|
+
protected executeJob(job: ScheduledJob): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { AbstractLogger, IInit } from "@clairejs/core";
|
|
2
|
-
import { AbstractJobScheduler } from "./AbstractJobScheduler";
|
|
3
|
-
import { JobInfo, ScheduledJob } from "./interfaces";
|
|
4
|
-
export declare class AwsJobScheduler extends AbstractJobScheduler implements IInit {
|
|
5
|
-
readonly logger: AbstractLogger;
|
|
6
|
-
readonly redisServerUrl: string;
|
|
7
|
-
readonly uniqueIdKey: string;
|
|
8
|
-
readonly apiLambdaFunctionArn: string;
|
|
9
|
-
readonly stepFunctionName: string;
|
|
10
|
-
/**
|
|
11
|
-
* This IAM role must have following permissions:
|
|
12
|
-
* - trigger any state machine (for one minute rule - as we don't now the state machine ARN until auto creation)
|
|
13
|
-
* - trigger lambda function specified in apiLambdaFunctionArn (so state machine can trigger API)
|
|
14
|
-
*
|
|
15
|
-
* In addition, the role which this API server assumes must have following permissions:
|
|
16
|
-
* - create event bridge rules, describe rules, remove rule, list and create rule targets
|
|
17
|
-
* - create state machines, list state machines
|
|
18
|
-
*/
|
|
19
|
-
readonly iamRoleArn: string;
|
|
20
|
-
readonly eventBusName: string;
|
|
21
|
-
readonly jobNamePrefix: string;
|
|
22
|
-
readonly oneMinuteRule: string;
|
|
23
|
-
private eventbridge;
|
|
24
|
-
private stepfunctions;
|
|
25
|
-
private redisClient;
|
|
26
|
-
constructor(logger: AbstractLogger, redisServerUrl: string, uniqueIdKey: string, apiLambdaFunctionArn: string, stepFunctionName: string,
|
|
27
|
-
/**
|
|
28
|
-
* This IAM role must have following permissions:
|
|
29
|
-
* - trigger any state machine (for one minute rule - as we don't now the state machine ARN until auto creation)
|
|
30
|
-
* - trigger lambda function specified in apiLambdaFunctionArn (so state machine can trigger API)
|
|
31
|
-
*
|
|
32
|
-
* In addition, the role which this API server assumes must have following permissions:
|
|
33
|
-
* - create event bridge rules, describe rules, remove rule, list and create rule targets
|
|
34
|
-
* - create state machines, list state machines
|
|
35
|
-
*/
|
|
36
|
-
iamRoleArn: string, eventBusName?: string, jobNamePrefix?: string, oneMinuteRule?: string);
|
|
37
|
-
init(): Promise<void>;
|
|
38
|
-
exit(): void;
|
|
39
|
-
handleInterval(interval: number): Promise<void>;
|
|
40
|
-
handleCron(jobInfo: ScheduledJob): Promise<void>;
|
|
41
|
-
private generateCronFromTimestamp;
|
|
42
|
-
protected isActiveScheduler(): boolean;
|
|
43
|
-
getAllScheduledJobs(): Promise<ScheduledJob[]>;
|
|
44
|
-
protected scheduleJob(jobInfo: JobInfo): Promise<string>;
|
|
45
|
-
syncJobs(): Promise<void>;
|
|
46
|
-
removeJob(jobId: string): Promise<void>;
|
|
47
|
-
private checkIntervalScheduler;
|
|
48
|
-
}
|
|
1
|
+
import { AbstractLogger, IInit } from "@clairejs/core";
|
|
2
|
+
import { AbstractJobScheduler } from "./AbstractJobScheduler";
|
|
3
|
+
import { JobInfo, ScheduledJob } from "./interfaces";
|
|
4
|
+
export declare class AwsJobScheduler extends AbstractJobScheduler implements IInit {
|
|
5
|
+
readonly logger: AbstractLogger;
|
|
6
|
+
readonly redisServerUrl: string;
|
|
7
|
+
readonly uniqueIdKey: string;
|
|
8
|
+
readonly apiLambdaFunctionArn: string;
|
|
9
|
+
readonly stepFunctionName: string;
|
|
10
|
+
/**
|
|
11
|
+
* This IAM role must have following permissions:
|
|
12
|
+
* - trigger any state machine (for one minute rule - as we don't now the state machine ARN until auto creation)
|
|
13
|
+
* - trigger lambda function specified in apiLambdaFunctionArn (so state machine can trigger API)
|
|
14
|
+
*
|
|
15
|
+
* In addition, the role which this API server assumes must have following permissions:
|
|
16
|
+
* - create event bridge rules, describe rules, remove rule, list and create rule targets
|
|
17
|
+
* - create state machines, list state machines
|
|
18
|
+
*/
|
|
19
|
+
readonly iamRoleArn: string;
|
|
20
|
+
readonly eventBusName: string;
|
|
21
|
+
readonly jobNamePrefix: string;
|
|
22
|
+
readonly oneMinuteRule: string;
|
|
23
|
+
private eventbridge;
|
|
24
|
+
private stepfunctions;
|
|
25
|
+
private redisClient;
|
|
26
|
+
constructor(logger: AbstractLogger, redisServerUrl: string, uniqueIdKey: string, apiLambdaFunctionArn: string, stepFunctionName: string,
|
|
27
|
+
/**
|
|
28
|
+
* This IAM role must have following permissions:
|
|
29
|
+
* - trigger any state machine (for one minute rule - as we don't now the state machine ARN until auto creation)
|
|
30
|
+
* - trigger lambda function specified in apiLambdaFunctionArn (so state machine can trigger API)
|
|
31
|
+
*
|
|
32
|
+
* In addition, the role which this API server assumes must have following permissions:
|
|
33
|
+
* - create event bridge rules, describe rules, remove rule, list and create rule targets
|
|
34
|
+
* - create state machines, list state machines
|
|
35
|
+
*/
|
|
36
|
+
iamRoleArn: string, eventBusName?: string, jobNamePrefix?: string, oneMinuteRule?: string);
|
|
37
|
+
init(): Promise<void>;
|
|
38
|
+
exit(): void;
|
|
39
|
+
handleInterval(interval: number): Promise<void>;
|
|
40
|
+
handleCron(jobInfo: ScheduledJob): Promise<void>;
|
|
41
|
+
private generateCronFromTimestamp;
|
|
42
|
+
protected isActiveScheduler(): boolean;
|
|
43
|
+
getAllScheduledJobs(): Promise<ScheduledJob[]>;
|
|
44
|
+
protected scheduleJob(jobInfo: JobInfo): Promise<string>;
|
|
45
|
+
syncJobs(): Promise<void>;
|
|
46
|
+
removeJob(jobId: string): Promise<void>;
|
|
47
|
+
private checkIntervalScheduler;
|
|
48
|
+
}
|
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
import { AbstractLogger, IInit } from "@clairejs/core";
|
|
2
|
-
import { AbstractJobScheduler } from "./AbstractJobScheduler";
|
|
3
|
-
import { JobInfo, ScheduledJob } from "./interfaces";
|
|
4
|
-
import { AbstractJobRepository } from "./AbstractJobRepository";
|
|
5
|
-
export declare class LocalJobScheduler extends AbstractJobScheduler implements IInit {
|
|
6
|
-
/**
|
|
7
|
-
* Logger
|
|
8
|
-
*/
|
|
9
|
-
readonly logger: AbstractLogger;
|
|
10
|
-
/**
|
|
11
|
-
* The job repository
|
|
12
|
-
*/
|
|
13
|
-
readonly jobRepo: AbstractJobRepository;
|
|
14
|
-
/**
|
|
15
|
-
* Redis server connection string
|
|
16
|
-
*/
|
|
17
|
-
readonly redisServerUrl: string;
|
|
18
|
-
/**
|
|
19
|
-
* Redus lock key to select active scheduler
|
|
20
|
-
*/
|
|
21
|
-
readonly lockMutexKey: string;
|
|
22
|
-
/**
|
|
23
|
-
* Redis key to hold active scheduler role
|
|
24
|
-
*/
|
|
25
|
-
readonly holdMutexKey: string;
|
|
26
|
-
/**
|
|
27
|
-
* Redis key to get unique incremental id
|
|
28
|
-
*/
|
|
29
|
-
readonly uniqueIdKey: string;
|
|
30
|
-
/**
|
|
31
|
-
* The channel for communication between passive and active schedulers
|
|
32
|
-
*/
|
|
33
|
-
readonly multiClientChannel: string;
|
|
34
|
-
/**
|
|
35
|
-
* The time to lock active scheduler
|
|
36
|
-
*/
|
|
37
|
-
readonly keyRetentionDurationSecond: number;
|
|
38
|
-
protected intervals: any[];
|
|
39
|
-
private mutexHoldInterval?;
|
|
40
|
-
private redisClient;
|
|
41
|
-
private subscribeClient;
|
|
42
|
-
private isActive;
|
|
43
|
-
private notifyResolver;
|
|
44
|
-
private jobHolder;
|
|
45
|
-
constructor(
|
|
46
|
-
/**
|
|
47
|
-
* Logger
|
|
48
|
-
*/
|
|
49
|
-
logger: AbstractLogger,
|
|
50
|
-
/**
|
|
51
|
-
* The job repository
|
|
52
|
-
*/
|
|
53
|
-
jobRepo: AbstractJobRepository,
|
|
54
|
-
/**
|
|
55
|
-
* Redis server connection string
|
|
56
|
-
*/
|
|
57
|
-
redisServerUrl: string,
|
|
58
|
-
/**
|
|
59
|
-
* Redus lock key to select active scheduler
|
|
60
|
-
*/
|
|
61
|
-
lockMutexKey: string,
|
|
62
|
-
/**
|
|
63
|
-
* Redis key to hold active scheduler role
|
|
64
|
-
*/
|
|
65
|
-
holdMutexKey: string,
|
|
66
|
-
/**
|
|
67
|
-
* Redis key to get unique incremental id
|
|
68
|
-
*/
|
|
69
|
-
uniqueIdKey: string,
|
|
70
|
-
/**
|
|
71
|
-
* The channel for communication between passive and active schedulers
|
|
72
|
-
*/
|
|
73
|
-
multiClientChannel: string,
|
|
74
|
-
/**
|
|
75
|
-
* The time to lock active scheduler
|
|
76
|
-
*/
|
|
77
|
-
keyRetentionDurationSecond?: number);
|
|
78
|
-
private sendJob;
|
|
79
|
-
private processMessage;
|
|
80
|
-
private extendMutexKey;
|
|
81
|
-
init(): Promise<void>;
|
|
82
|
-
exit(): void;
|
|
83
|
-
protected isActiveScheduler(): boolean;
|
|
84
|
-
getAllScheduledJobs(): Promise<ScheduledJob[]>;
|
|
85
|
-
syncJobs(): Promise<void>;
|
|
86
|
-
protected scheduleJob(jobInfo: JobInfo): Promise<string>;
|
|
87
|
-
removeJob(jobId: string): Promise<void>;
|
|
88
|
-
}
|
|
1
|
+
import { AbstractLogger, IInit } from "@clairejs/core";
|
|
2
|
+
import { AbstractJobScheduler } from "./AbstractJobScheduler";
|
|
3
|
+
import { JobInfo, ScheduledJob } from "./interfaces";
|
|
4
|
+
import { AbstractJobRepository } from "./AbstractJobRepository";
|
|
5
|
+
export declare class LocalJobScheduler extends AbstractJobScheduler implements IInit {
|
|
6
|
+
/**
|
|
7
|
+
* Logger
|
|
8
|
+
*/
|
|
9
|
+
readonly logger: AbstractLogger;
|
|
10
|
+
/**
|
|
11
|
+
* The job repository
|
|
12
|
+
*/
|
|
13
|
+
readonly jobRepo: AbstractJobRepository;
|
|
14
|
+
/**
|
|
15
|
+
* Redis server connection string
|
|
16
|
+
*/
|
|
17
|
+
readonly redisServerUrl: string;
|
|
18
|
+
/**
|
|
19
|
+
* Redus lock key to select active scheduler
|
|
20
|
+
*/
|
|
21
|
+
readonly lockMutexKey: string;
|
|
22
|
+
/**
|
|
23
|
+
* Redis key to hold active scheduler role
|
|
24
|
+
*/
|
|
25
|
+
readonly holdMutexKey: string;
|
|
26
|
+
/**
|
|
27
|
+
* Redis key to get unique incremental id
|
|
28
|
+
*/
|
|
29
|
+
readonly uniqueIdKey: string;
|
|
30
|
+
/**
|
|
31
|
+
* The channel for communication between passive and active schedulers
|
|
32
|
+
*/
|
|
33
|
+
readonly multiClientChannel: string;
|
|
34
|
+
/**
|
|
35
|
+
* The time to lock active scheduler
|
|
36
|
+
*/
|
|
37
|
+
readonly keyRetentionDurationSecond: number;
|
|
38
|
+
protected intervals: any[];
|
|
39
|
+
private mutexHoldInterval?;
|
|
40
|
+
private redisClient;
|
|
41
|
+
private subscribeClient;
|
|
42
|
+
private isActive;
|
|
43
|
+
private notifyResolver;
|
|
44
|
+
private jobHolder;
|
|
45
|
+
constructor(
|
|
46
|
+
/**
|
|
47
|
+
* Logger
|
|
48
|
+
*/
|
|
49
|
+
logger: AbstractLogger,
|
|
50
|
+
/**
|
|
51
|
+
* The job repository
|
|
52
|
+
*/
|
|
53
|
+
jobRepo: AbstractJobRepository,
|
|
54
|
+
/**
|
|
55
|
+
* Redis server connection string
|
|
56
|
+
*/
|
|
57
|
+
redisServerUrl: string,
|
|
58
|
+
/**
|
|
59
|
+
* Redus lock key to select active scheduler
|
|
60
|
+
*/
|
|
61
|
+
lockMutexKey: string,
|
|
62
|
+
/**
|
|
63
|
+
* Redis key to hold active scheduler role
|
|
64
|
+
*/
|
|
65
|
+
holdMutexKey: string,
|
|
66
|
+
/**
|
|
67
|
+
* Redis key to get unique incremental id
|
|
68
|
+
*/
|
|
69
|
+
uniqueIdKey: string,
|
|
70
|
+
/**
|
|
71
|
+
* The channel for communication between passive and active schedulers
|
|
72
|
+
*/
|
|
73
|
+
multiClientChannel: string,
|
|
74
|
+
/**
|
|
75
|
+
* The time to lock active scheduler
|
|
76
|
+
*/
|
|
77
|
+
keyRetentionDurationSecond?: number);
|
|
78
|
+
private sendJob;
|
|
79
|
+
private processMessage;
|
|
80
|
+
private extendMutexKey;
|
|
81
|
+
init(): Promise<void>;
|
|
82
|
+
exit(): void;
|
|
83
|
+
protected isActiveScheduler(): boolean;
|
|
84
|
+
getAllScheduledJobs(): Promise<ScheduledJob[]>;
|
|
85
|
+
syncJobs(): Promise<void>;
|
|
86
|
+
protected scheduleJob(jobInfo: JobInfo): Promise<string>;
|
|
87
|
+
removeJob(jobId: string): Promise<void>;
|
|
88
|
+
}
|
package/dist/job/decorators.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbstractJobController } from "./AbstractJobController";
|
|
2
|
-
import { JobInterval } from "./interfaces";
|
|
3
|
-
export declare const IntervalJob: (jobName: string, interval: JobInterval) => <T extends AbstractJobController>(prototype: T, propertyKey: keyof T) => void;
|
|
4
|
-
export declare const CronJob: (jobName: string, cron: string) => <T extends AbstractJobController>(prototype: T, propertyKey: keyof T) => void;
|
|
5
|
-
export declare const CustomJob: (jobName: string) => <T extends AbstractJobController>(prototype: T, propertyKey: keyof T) => void;
|
|
1
|
+
import { AbstractJobController } from "./AbstractJobController";
|
|
2
|
+
import { JobInterval } from "./interfaces";
|
|
3
|
+
export declare const IntervalJob: (jobName: string, interval: JobInterval) => <T extends AbstractJobController>(prototype: T, propertyKey: keyof T) => void;
|
|
4
|
+
export declare const CronJob: (jobName: string, cron: string) => <T extends AbstractJobController>(prototype: T, propertyKey: keyof T) => void;
|
|
5
|
+
export declare const CustomJob: (jobName: string) => <T extends AbstractJobController>(prototype: T, propertyKey: keyof T) => void;
|
package/dist/job/interfaces.d.ts
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { ObjectMetadata } from "@clairejs/core";
|
|
2
|
-
export declare const INTERVAL_REQUEST_METHOD = "interval";
|
|
3
|
-
export declare const CRON_REQUEST_METHOD = "cron";
|
|
4
|
-
export declare enum JobInterval {
|
|
5
|
-
EVERY_5S = 5,
|
|
6
|
-
EVERY_10S = 10,
|
|
7
|
-
EVERY_15S = 15,
|
|
8
|
-
EVERY_20S = 20,
|
|
9
|
-
EVERY_30S = 30
|
|
10
|
-
}
|
|
11
|
-
export interface JobInfoMetadata {
|
|
12
|
-
/**
|
|
13
|
-
* Unique name of job
|
|
14
|
-
*/
|
|
15
|
-
jobName: string;
|
|
16
|
-
/**
|
|
17
|
-
* Interval in seconds
|
|
18
|
-
*/
|
|
19
|
-
interval?: JobInterval;
|
|
20
|
-
/**
|
|
21
|
-
* Run with cron expression, does not support seconds precision
|
|
22
|
-
*/
|
|
23
|
-
cron?: string;
|
|
24
|
-
/**
|
|
25
|
-
* Run at specific timestamp, does not support seconds precision
|
|
26
|
-
*/
|
|
27
|
-
at?: number;
|
|
28
|
-
/**
|
|
29
|
-
* Name of the function handle
|
|
30
|
-
*/
|
|
31
|
-
handlerName: string;
|
|
32
|
-
}
|
|
33
|
-
export interface JobControllerMetadata extends ObjectMetadata {
|
|
34
|
-
jobs?: JobInfoMetadata[];
|
|
35
|
-
}
|
|
36
|
-
export interface CustomJobInfo {
|
|
37
|
-
jobName: string;
|
|
38
|
-
at: number;
|
|
39
|
-
params?: any[];
|
|
40
|
-
}
|
|
41
|
-
export interface JobInfo {
|
|
42
|
-
jobName: string;
|
|
43
|
-
params?: any[];
|
|
44
|
-
at?: number;
|
|
45
|
-
interval?: JobInterval;
|
|
46
|
-
cron?: string;
|
|
47
|
-
}
|
|
48
|
-
export interface ScheduledJob extends JobInfo {
|
|
49
|
-
jobId: string;
|
|
50
|
-
}
|
|
1
|
+
import { ObjectMetadata } from "@clairejs/core";
|
|
2
|
+
export declare const INTERVAL_REQUEST_METHOD = "interval";
|
|
3
|
+
export declare const CRON_REQUEST_METHOD = "cron";
|
|
4
|
+
export declare enum JobInterval {
|
|
5
|
+
EVERY_5S = 5,
|
|
6
|
+
EVERY_10S = 10,
|
|
7
|
+
EVERY_15S = 15,
|
|
8
|
+
EVERY_20S = 20,
|
|
9
|
+
EVERY_30S = 30
|
|
10
|
+
}
|
|
11
|
+
export interface JobInfoMetadata {
|
|
12
|
+
/**
|
|
13
|
+
* Unique name of job
|
|
14
|
+
*/
|
|
15
|
+
jobName: string;
|
|
16
|
+
/**
|
|
17
|
+
* Interval in seconds
|
|
18
|
+
*/
|
|
19
|
+
interval?: JobInterval;
|
|
20
|
+
/**
|
|
21
|
+
* Run with cron expression, does not support seconds precision
|
|
22
|
+
*/
|
|
23
|
+
cron?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Run at specific timestamp, does not support seconds precision
|
|
26
|
+
*/
|
|
27
|
+
at?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Name of the function handle
|
|
30
|
+
*/
|
|
31
|
+
handlerName: string;
|
|
32
|
+
}
|
|
33
|
+
export interface JobControllerMetadata extends ObjectMetadata {
|
|
34
|
+
jobs?: JobInfoMetadata[];
|
|
35
|
+
}
|
|
36
|
+
export interface CustomJobInfo {
|
|
37
|
+
jobName: string;
|
|
38
|
+
at: number;
|
|
39
|
+
params?: any[];
|
|
40
|
+
}
|
|
41
|
+
export interface JobInfo {
|
|
42
|
+
jobName: string;
|
|
43
|
+
params?: any[];
|
|
44
|
+
at?: number;
|
|
45
|
+
interval?: JobInterval;
|
|
46
|
+
cron?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface ScheduledJob extends JobInfo {
|
|
49
|
+
jobId: string;
|
|
50
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { LogLevel, ILogMedium } from "@clairejs/core";
|
|
2
|
-
export declare class FileLogMedium implements ILogMedium {
|
|
3
|
-
private static readonly levels;
|
|
4
|
-
private readonly destination;
|
|
5
|
-
private readonly separated;
|
|
6
|
-
constructor(config: {
|
|
7
|
-
destination: string;
|
|
8
|
-
separated?: boolean;
|
|
9
|
-
});
|
|
10
|
-
init(): Promise<void>;
|
|
11
|
-
exit(): void;
|
|
12
|
-
write(level: LogLevel, content: string): void;
|
|
13
|
-
}
|
|
1
|
+
import { LogLevel, ILogMedium } from "@clairejs/core";
|
|
2
|
+
export declare class FileLogMedium implements ILogMedium {
|
|
3
|
+
private static readonly levels;
|
|
4
|
+
private readonly destination;
|
|
5
|
+
private readonly separated;
|
|
6
|
+
constructor(config: {
|
|
7
|
+
destination: string;
|
|
8
|
+
separated?: boolean;
|
|
9
|
+
});
|
|
10
|
+
init(): Promise<void>;
|
|
11
|
+
exit(): void;
|
|
12
|
+
write(level: LogLevel, content: string): void;
|
|
13
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
export interface MutexLock {
|
|
2
|
-
unlock(): Promise<void>;
|
|
3
|
-
}
|
|
4
|
-
export interface ICacheTransaction {
|
|
5
|
-
hset(hash: string, key: string, value: any): void;
|
|
6
|
-
set(key: string, value: any): void;
|
|
7
|
-
del(key: string): void;
|
|
8
|
-
hdel(hash: string, key: string): void;
|
|
9
|
-
exec(): Promise<any[]>;
|
|
10
|
-
}
|
|
11
|
-
export declare abstract class AbstractCacheService {
|
|
12
|
-
abstract hget<T>(hash: string, key: string): Promise<T | undefined>;
|
|
13
|
-
abstract hset<T>(hash: string, key: string, value: T): Promise<void>;
|
|
14
|
-
abstract hkeys(hash: string): Promise<string[]>;
|
|
15
|
-
abstract get<T>(key: string): Promise<T | undefined>;
|
|
16
|
-
abstract set<T>(key: string, value: T, expiredSeconds?: number): Promise<void>;
|
|
17
|
-
abstract del(key: string): Promise<void>;
|
|
18
|
-
abstract hdel(hash: string, key: string): Promise<void>;
|
|
19
|
-
abstract flush(): Promise<void>;
|
|
20
|
-
abstract lock(key: string, durationMs: number, timeoutMs?: number): Promise<MutexLock>;
|
|
21
|
-
abstract createTransaction(): ICacheTransaction;
|
|
22
|
-
}
|
|
1
|
+
export interface MutexLock {
|
|
2
|
+
unlock(): Promise<void>;
|
|
3
|
+
}
|
|
4
|
+
export interface ICacheTransaction {
|
|
5
|
+
hset(hash: string, key: string, value: any): void;
|
|
6
|
+
set(key: string, value: any): void;
|
|
7
|
+
del(key: string): void;
|
|
8
|
+
hdel(hash: string, key: string): void;
|
|
9
|
+
exec(): Promise<any[]>;
|
|
10
|
+
}
|
|
11
|
+
export declare abstract class AbstractCacheService {
|
|
12
|
+
abstract hget<T>(hash: string, key: string): Promise<T | undefined>;
|
|
13
|
+
abstract hset<T>(hash: string, key: string, value: T): Promise<void>;
|
|
14
|
+
abstract hkeys(hash: string): Promise<string[]>;
|
|
15
|
+
abstract get<T>(key: string): Promise<T | undefined>;
|
|
16
|
+
abstract set<T>(key: string, value: T, expiredSeconds?: number): Promise<void>;
|
|
17
|
+
abstract del(key: string): Promise<void>;
|
|
18
|
+
abstract hdel(hash: string, key: string): Promise<void>;
|
|
19
|
+
abstract flush(): Promise<void>;
|
|
20
|
+
abstract lock(key: string, durationMs: number, timeoutMs?: number): Promise<MutexLock>;
|
|
21
|
+
abstract createTransaction(): ICacheTransaction;
|
|
22
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { FileOperation } from "../common/FileOperation";
|
|
2
|
-
export declare abstract class AbstractFileService {
|
|
3
|
-
abstract getFileSize(objectKeys: string[]): Promise<number[]>;
|
|
4
|
-
abstract getAccessUrls(uris: string[], isPublic: boolean): Promise<string[]>;
|
|
5
|
-
abstract getPresignedUrl(operation: FileOperation, uris: string[]): Promise<string[]>;
|
|
6
|
-
abstract moveObject(uris: {
|
|
7
|
-
fromURI: string;
|
|
8
|
-
toURI: string;
|
|
9
|
-
}[]): Promise<void>;
|
|
10
|
-
abstract copyObject(uris: {
|
|
11
|
-
fromURI: string;
|
|
12
|
-
toURI: string;
|
|
13
|
-
}[]): Promise<void>;
|
|
14
|
-
abstract removeObject(uris: string[]): Promise<void>;
|
|
15
|
-
}
|
|
1
|
+
import { FileOperation } from "../common/FileOperation";
|
|
2
|
+
export declare abstract class AbstractFileService {
|
|
3
|
+
abstract getFileSize(objectKeys: string[]): Promise<number[]>;
|
|
4
|
+
abstract getAccessUrls(uris: string[], isPublic: boolean): Promise<string[]>;
|
|
5
|
+
abstract getPresignedUrl(operation: FileOperation, uris: string[]): Promise<string[]>;
|
|
6
|
+
abstract moveObject(uris: {
|
|
7
|
+
fromURI: string;
|
|
8
|
+
toURI: string;
|
|
9
|
+
}[]): Promise<void>;
|
|
10
|
+
abstract copyObject(uris: {
|
|
11
|
+
fromURI: string;
|
|
12
|
+
toURI: string;
|
|
13
|
+
}[]): Promise<void>;
|
|
14
|
+
abstract removeObject(uris: string[]): Promise<void>;
|
|
15
|
+
}
|