@clairejs/server 3.6.19 → 3.6.22
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 +677 -675
- package/dist/common/FileOperation.d.ts +5 -5
- package/dist/common/ServerModelMetadata.d.ts +10 -10
- 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/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 +6 -6
- package/dist/common/request/SocketData.d.ts +1 -1
- package/dist/common/request/types.d.ts +1 -1
- package/dist/http/auth/AbstractHttpAuthorizationProvider.d.ts +9 -9
- package/dist/http/auth/AbstractRbacAuthProvider.d.ts +18 -18
- package/dist/http/auth/RedisRbacAuthProvider.d.ts +23 -23
- package/dist/http/auth/SocketRbacAuthProvider.d.ts +25 -25
- package/dist/http/auth/rbac.d.ts +34 -34
- package/dist/http/common/HttpRequest.d.ts +37 -37
- package/dist/http/common/HttpResponse.d.ts +25 -25
- package/dist/http/controller/AbstractHttpController.d.ts +9 -9
- package/dist/http/controller/AbstractHttpMiddleware.d.ts +5 -5
- package/dist/http/controller/AbstractHttpRequestHandler.d.ts +16 -16
- package/dist/http/controller/ControllerMetadata.d.ts +6 -6
- package/dist/http/controller/CrudHttpController.d.ts +55 -55
- package/dist/http/controller/DefaultHttpRequestHandler.d.ts +19 -19
- package/dist/http/decorators.d.ts +32 -32
- package/dist/http/file-upload/AbstractFileUploadHandler.d.ts +6 -6
- package/dist/http/file-upload/FileUploadHandler.d.ts +10 -10
- package/dist/http/file-upload/types.d.ts +3 -3
- 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/index.d.ts +55 -55
- package/dist/index.js +1 -1
- package/dist/job/AbstractJobController.d.ts +4 -4
- package/dist/job/AbstractJobExecutor.d.ts +10 -10
- package/dist/job/AbstractJobScheduler.d.ts +8 -8
- package/dist/job/AwsJobExecutor.d.ts +8 -8
- package/dist/job/AwsJobScheduler.d.ts +5 -5
- package/dist/job/LocalJobExecutor.d.ts +8 -8
- package/dist/job/LocalJobScheduler.d.ts +21 -21
- package/dist/job/decorators.d.ts +4 -4
- package/dist/job/interfaces.d.ts +16 -16
- package/dist/logging/FileLogMedium.d.ts +13 -13
- package/dist/service/AbstractCacheService.d.ts +22 -22
- package/dist/service/AbstractFileService.d.ts +8 -8
- package/dist/service/AbstractService.d.ts +7 -7
- 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 +17 -17
- package/dist/system/LambdaWrapper.d.ts +19 -19
- package/dist/system/ServerGlobalStore.d.ts +5 -5
- package/dist/system/errors.d.ts +14 -14
- package/dist/system/lamba-request-mapper.d.ts +12 -12
- package/package.json +59 -59
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { JobInfo } from "./interfaces";
|
|
2
|
-
export declare abstract class AbstractJobExecutor {
|
|
3
|
-
private _allJobs;
|
|
4
|
-
init(): Promise<void>;
|
|
5
|
-
protected getAllJobs(): Promise<{
|
|
6
|
-
jobName: string;
|
|
7
|
-
handlerFn: (jobInfo?: JobInfo | undefined) => Promise<void>;
|
|
8
|
-
}[]>;
|
|
9
|
-
abstract executeJob(jobInfo: JobInfo, schedulerInterval: number): Promise<void>;
|
|
10
|
-
}
|
|
1
|
+
import { JobInfo } from "./interfaces";
|
|
2
|
+
export declare abstract class AbstractJobExecutor {
|
|
3
|
+
private _allJobs;
|
|
4
|
+
init(): Promise<void>;
|
|
5
|
+
protected getAllJobs(): Promise<{
|
|
6
|
+
jobName: string;
|
|
7
|
+
handlerFn: (jobInfo?: JobInfo | undefined) => Promise<void>;
|
|
8
|
+
}[]>;
|
|
9
|
+
abstract executeJob(jobInfo: JobInfo, schedulerInterval: number): Promise<void>;
|
|
10
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AbstractLogger } from "@clairejs/core";
|
|
2
|
-
import { JobInfo } from "./interfaces";
|
|
3
|
-
export declare abstract class AbstractJobScheduler {
|
|
4
|
-
readonly logger: AbstractLogger;
|
|
5
|
-
constructor(logger: AbstractLogger);
|
|
6
|
-
schedule(): Promise<void>;
|
|
7
|
-
abstract scheduleJob(jobInfo: JobInfo): void;
|
|
8
|
-
}
|
|
1
|
+
import { AbstractLogger } from "@clairejs/core";
|
|
2
|
+
import { JobInfo } from "./interfaces";
|
|
3
|
+
export declare abstract class AbstractJobScheduler {
|
|
4
|
+
readonly logger: AbstractLogger;
|
|
5
|
+
constructor(logger: AbstractLogger);
|
|
6
|
+
schedule(): Promise<void>;
|
|
7
|
+
abstract scheduleJob(jobInfo: JobInfo): void;
|
|
8
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AbstractLogger } from "@clairejs/core";
|
|
2
|
-
import { AbstractJobExecutor } from "./AbstractJobExecutor";
|
|
3
|
-
import { JobInfo } from "./interfaces";
|
|
4
|
-
export declare class AwsJobExecutor extends AbstractJobExecutor {
|
|
5
|
-
readonly logger: AbstractLogger;
|
|
6
|
-
constructor(logger: AbstractLogger);
|
|
7
|
-
executeJob(jobInfo: JobInfo, schedulerInterval: number): Promise<void>;
|
|
8
|
-
}
|
|
1
|
+
import { AbstractLogger } from "@clairejs/core";
|
|
2
|
+
import { AbstractJobExecutor } from "./AbstractJobExecutor";
|
|
3
|
+
import { JobInfo } from "./interfaces";
|
|
4
|
+
export declare class AwsJobExecutor extends AbstractJobExecutor {
|
|
5
|
+
readonly logger: AbstractLogger;
|
|
6
|
+
constructor(logger: AbstractLogger);
|
|
7
|
+
executeJob(jobInfo: JobInfo, schedulerInterval: number): Promise<void>;
|
|
8
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbstractJobScheduler } from "./AbstractJobScheduler";
|
|
2
|
-
import { JobInfo } from "./interfaces";
|
|
3
|
-
export declare class AwsJobScheduler extends AbstractJobScheduler {
|
|
4
|
-
scheduleJob(jobInfo: JobInfo): void;
|
|
5
|
-
}
|
|
1
|
+
import { AbstractJobScheduler } from "./AbstractJobScheduler";
|
|
2
|
+
import { JobInfo } from "./interfaces";
|
|
3
|
+
export declare class AwsJobScheduler extends AbstractJobScheduler {
|
|
4
|
+
scheduleJob(jobInfo: JobInfo): void;
|
|
5
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AbstractLogger } from "@clairejs/core";
|
|
2
|
-
import { AbstractJobExecutor } from "./AbstractJobExecutor";
|
|
3
|
-
import { JobInfo } from "./interfaces";
|
|
4
|
-
export declare class LocalJobExecutor extends AbstractJobExecutor {
|
|
5
|
-
readonly logger: AbstractLogger;
|
|
6
|
-
constructor(logger: AbstractLogger);
|
|
7
|
-
executeJob(jobInfo: JobInfo, schedulerInterval: number): Promise<void>;
|
|
8
|
-
}
|
|
1
|
+
import { AbstractLogger } from "@clairejs/core";
|
|
2
|
+
import { AbstractJobExecutor } from "./AbstractJobExecutor";
|
|
3
|
+
import { JobInfo } from "./interfaces";
|
|
4
|
+
export declare class LocalJobExecutor extends AbstractJobExecutor {
|
|
5
|
+
readonly logger: AbstractLogger;
|
|
6
|
+
constructor(logger: AbstractLogger);
|
|
7
|
+
executeJob(jobInfo: JobInfo, schedulerInterval: number): Promise<void>;
|
|
8
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { AbstractLogger, IInit } from "@clairejs/core";
|
|
2
|
-
import { AbstractJobExecutor } from "./AbstractJobExecutor";
|
|
3
|
-
import { AbstractJobScheduler } from "./AbstractJobScheduler";
|
|
4
|
-
import { JobInfo } from "./interfaces";
|
|
5
|
-
export declare class LocalJobScheduler extends AbstractJobScheduler implements IInit {
|
|
6
|
-
readonly logger: AbstractLogger;
|
|
7
|
-
readonly jobExecutor: AbstractJobExecutor;
|
|
8
|
-
readonly redisServerUrl: string;
|
|
9
|
-
readonly lockMutexKey: string;
|
|
10
|
-
readonly holdMutexKey: string;
|
|
11
|
-
readonly keyRetentionDurationSecond: number;
|
|
12
|
-
protected intervals: any[];
|
|
13
|
-
private mutexHoldInterval?;
|
|
14
|
-
private redisClient?;
|
|
15
|
-
constructor(logger: AbstractLogger, jobExecutor: AbstractJobExecutor, redisServerUrl: string, lockMutexKey: string, holdMutexKey: string, keyRetentionDurationSecond?: number);
|
|
16
|
-
init(): Promise<void>;
|
|
17
|
-
exit(): void;
|
|
18
|
-
private extendMutexKey;
|
|
19
|
-
schedule(): Promise<void>;
|
|
20
|
-
scheduleJob(jobInfo: JobInfo): void;
|
|
21
|
-
}
|
|
1
|
+
import { AbstractLogger, IInit } from "@clairejs/core";
|
|
2
|
+
import { AbstractJobExecutor } from "./AbstractJobExecutor";
|
|
3
|
+
import { AbstractJobScheduler } from "./AbstractJobScheduler";
|
|
4
|
+
import { JobInfo } from "./interfaces";
|
|
5
|
+
export declare class LocalJobScheduler extends AbstractJobScheduler implements IInit {
|
|
6
|
+
readonly logger: AbstractLogger;
|
|
7
|
+
readonly jobExecutor: AbstractJobExecutor;
|
|
8
|
+
readonly redisServerUrl: string;
|
|
9
|
+
readonly lockMutexKey: string;
|
|
10
|
+
readonly holdMutexKey: string;
|
|
11
|
+
readonly keyRetentionDurationSecond: number;
|
|
12
|
+
protected intervals: any[];
|
|
13
|
+
private mutexHoldInterval?;
|
|
14
|
+
private redisClient?;
|
|
15
|
+
constructor(logger: AbstractLogger, jobExecutor: AbstractJobExecutor, redisServerUrl: string, lockMutexKey: string, holdMutexKey: string, keyRetentionDurationSecond?: number);
|
|
16
|
+
init(): Promise<void>;
|
|
17
|
+
exit(): void;
|
|
18
|
+
private extendMutexKey;
|
|
19
|
+
schedule(): Promise<void>;
|
|
20
|
+
scheduleJob(jobInfo: JobInfo): void;
|
|
21
|
+
}
|
package/dist/job/decorators.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbstractJobController } from "./AbstractJobController";
|
|
2
|
-
export declare const IntervalJob: (jobName: string, intervalSecond: number) => <T extends AbstractJobController>(prototype: T, propertyKey: keyof T) => void;
|
|
3
|
-
export declare const CronJob: (jobName: string, cron: string) => <T extends AbstractJobController>(prototype: T, propertyKey: keyof T) => void;
|
|
4
|
-
export declare const CustomJob: (jobName: string) => <T extends AbstractJobController>(prototype: T, propertyKey: keyof T) => void;
|
|
1
|
+
import { AbstractJobController } from "./AbstractJobController";
|
|
2
|
+
export declare const IntervalJob: (jobName: string, intervalSecond: number) => <T extends AbstractJobController>(prototype: T, propertyKey: keyof T) => void;
|
|
3
|
+
export declare const CronJob: (jobName: string, cron: string) => <T extends AbstractJobController>(prototype: T, propertyKey: keyof T) => void;
|
|
4
|
+
export declare const CustomJob: (jobName: string) => <T extends AbstractJobController>(prototype: T, propertyKey: keyof T) => void;
|
package/dist/job/interfaces.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { ObjectMetadata } from "@clairejs/core";
|
|
2
|
-
export interface JobInfoMetadata {
|
|
3
|
-
jobName: string;
|
|
4
|
-
interval?: number;
|
|
5
|
-
cron?: string;
|
|
6
|
-
handlerName: string;
|
|
7
|
-
}
|
|
8
|
-
export interface JobInfo {
|
|
9
|
-
jobName: string;
|
|
10
|
-
interval?: number;
|
|
11
|
-
cron?: string;
|
|
12
|
-
params?: any[];
|
|
13
|
-
}
|
|
14
|
-
export interface JobControllerMetadata extends ObjectMetadata {
|
|
15
|
-
jobs?: JobInfoMetadata[];
|
|
16
|
-
}
|
|
1
|
+
import { ObjectMetadata } from "@clairejs/core";
|
|
2
|
+
export interface JobInfoMetadata {
|
|
3
|
+
jobName: string;
|
|
4
|
+
interval?: number;
|
|
5
|
+
cron?: string;
|
|
6
|
+
handlerName: string;
|
|
7
|
+
}
|
|
8
|
+
export interface JobInfo {
|
|
9
|
+
jobName: string;
|
|
10
|
+
interval?: number;
|
|
11
|
+
cron?: string;
|
|
12
|
+
params?: any[];
|
|
13
|
+
}
|
|
14
|
+
export interface JobControllerMetadata extends ObjectMetadata {
|
|
15
|
+
jobs?: JobInfoMetadata[];
|
|
16
|
+
}
|
|
@@ -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): 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): 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,8 +1,8 @@
|
|
|
1
|
-
import { FileOperation } from "../common/FileOperation";
|
|
2
|
-
export declare abstract class AbstractFileService {
|
|
3
|
-
abstract getFileSize(objectKey: string): Promise<number>;
|
|
4
|
-
abstract getAccessUrl(objectKey: string, isPublic: boolean): string;
|
|
5
|
-
abstract getPresignedUrl(operation: FileOperation, objectKey: string): string;
|
|
6
|
-
abstract moveObject(fromObjectKey: string, toObjectKey: string): Promise<void>;
|
|
7
|
-
abstract removeObject(objectKey: string): Promise<void>;
|
|
8
|
-
}
|
|
1
|
+
import { FileOperation } from "../common/FileOperation";
|
|
2
|
+
export declare abstract class AbstractFileService {
|
|
3
|
+
abstract getFileSize(objectKey: string): Promise<number>;
|
|
4
|
+
abstract getAccessUrl(objectKey: string, isPublic: boolean): string;
|
|
5
|
+
abstract getPresignedUrl(operation: FileOperation, objectKey: string): string;
|
|
6
|
+
abstract moveObject(fromObjectKey: string, toObjectKey: string): Promise<void>;
|
|
7
|
+
abstract removeObject(objectKey: string): Promise<void>;
|
|
8
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ITransactionFactory, ITransactionProvider } from "@clairejs/orm";
|
|
2
|
-
export declare abstract class AbstractService implements ITransactionProvider, ITransactionFactory {
|
|
3
|
-
protected readonly databaseAdapter: ITransactionFactory;
|
|
4
|
-
constructor(databaseAdapter: ITransactionFactory);
|
|
5
|
-
createTransaction(): Promise<import("@clairejs/orm").ITransaction>;
|
|
6
|
-
getCurrentTransaction(): Promise<import("@clairejs/orm").ITransaction>;
|
|
7
|
-
}
|
|
1
|
+
import { ITransactionFactory, ITransactionProvider } from "@clairejs/orm";
|
|
2
|
+
export declare abstract class AbstractService implements ITransactionProvider, ITransactionFactory {
|
|
3
|
+
protected readonly databaseAdapter: ITransactionFactory;
|
|
4
|
+
constructor(databaseAdapter: ITransactionFactory);
|
|
5
|
+
createTransaction(): Promise<import("@clairejs/orm").ITransaction>;
|
|
6
|
+
getCurrentTransaction(): Promise<import("@clairejs/orm").ITransaction>;
|
|
7
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { SocketMessage } from "@clairejs/core";
|
|
2
|
-
import { IPrincipal } from "../common/auth/IPrincipal";
|
|
3
|
-
import { IServerSocket } from "./IServerSocket";
|
|
4
|
-
import { ChannelInfo, ServerSocketInfo } from "./AbstractServerSocketManager";
|
|
5
|
-
export declare abstract class AbstractServerSocket implements IServerSocket {
|
|
6
|
-
readonly socketInfo: ServerSocketInfo;
|
|
7
|
-
constructor(socketInfo: ServerSocketInfo);
|
|
8
|
-
getId(): string;
|
|
9
|
-
getAuthInfo(): IPrincipal | undefined;
|
|
10
|
-
send(data: any, channel?: string): Promise<void>;
|
|
11
|
-
sendRaw(data: SocketMessage): Promise<void>;
|
|
12
|
-
removeChannels(channels: string[]): void;
|
|
13
|
-
addChannels(channelInfos: ChannelInfo[]): void;
|
|
14
|
-
getChannelsInfo(): ChannelInfo[];
|
|
15
|
-
abstract disconnect(err?: any): Promise<void>;
|
|
16
|
-
abstract physicSend(data: any): Promise<void>;
|
|
17
|
-
abstract saveSocketInfo(): Promise<void>;
|
|
18
|
-
}
|
|
1
|
+
import { SocketMessage } from "@clairejs/core";
|
|
2
|
+
import { IPrincipal } from "../common/auth/IPrincipal";
|
|
3
|
+
import { IServerSocket } from "./IServerSocket";
|
|
4
|
+
import { ChannelInfo, ServerSocketInfo } from "./AbstractServerSocketManager";
|
|
5
|
+
export declare abstract class AbstractServerSocket implements IServerSocket {
|
|
6
|
+
readonly socketInfo: ServerSocketInfo;
|
|
7
|
+
constructor(socketInfo: ServerSocketInfo);
|
|
8
|
+
getId(): string;
|
|
9
|
+
getAuthInfo(): IPrincipal | undefined;
|
|
10
|
+
send(data: any, channel?: string): Promise<void>;
|
|
11
|
+
sendRaw(data: SocketMessage): Promise<void>;
|
|
12
|
+
removeChannels(channels: string[]): void;
|
|
13
|
+
addChannels(channelInfos: ChannelInfo[]): void;
|
|
14
|
+
getChannelsInfo(): ChannelInfo[];
|
|
15
|
+
abstract disconnect(err?: any): Promise<void>;
|
|
16
|
+
abstract physicSend(data: any): Promise<void>;
|
|
17
|
+
abstract saveSocketInfo(): Promise<void>;
|
|
18
|
+
}
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { AbstractLogger, SocketMessage } from "@clairejs/core";
|
|
2
|
-
import Client from "ioredis";
|
|
3
|
-
import { SocketData } from "../common/request/SocketData";
|
|
4
|
-
import { AbstractSocketConnectionHandler } from "./AbstractSocketConnectionHandler";
|
|
5
|
-
import { IPrincipal } from "../common/auth/IPrincipal";
|
|
6
|
-
import { AbstractServerSocket } from "./AbstractServerSocket";
|
|
7
|
-
import { MountedEndpointInfo } from "../common/request/MountedEndpointInfo";
|
|
8
|
-
import { AbstractHttpAuthorizationProvider } from "../http/auth/AbstractHttpAuthorizationProvider";
|
|
9
|
-
import { IServerSocket } from "./IServerSocket";
|
|
10
|
-
export interface ChannelInfo {
|
|
11
|
-
name: string;
|
|
12
|
-
clientToServerAllowed: boolean;
|
|
13
|
-
serverToClientAllowed: boolean;
|
|
14
|
-
}
|
|
15
|
-
export interface ServerSocketInfo {
|
|
16
|
-
id: string;
|
|
17
|
-
createdAt: number;
|
|
18
|
-
channels: ChannelInfo[];
|
|
19
|
-
authInfo?: IPrincipal;
|
|
20
|
-
}
|
|
21
|
-
export declare abstract class AbstractServerSocketManager {
|
|
22
|
-
protected readonly requireAuthentication: boolean;
|
|
23
|
-
protected readonly logger: AbstractLogger;
|
|
24
|
-
protected readonly redisServerUrl: string;
|
|
25
|
-
protected readonly authProvider: AbstractHttpAuthorizationProvider;
|
|
26
|
-
protected readonly authResolver: (queries?: any) => any;
|
|
27
|
-
private mountedEndpointInfo?;
|
|
28
|
-
private _connectionHandler?;
|
|
29
|
-
protected redisClient: Client;
|
|
30
|
-
protected constructor(requireAuthentication: boolean, logger: AbstractLogger, redisServerUrl: string, authProvider: AbstractHttpAuthorizationProvider, authResolver: (queries?: any) => any);
|
|
31
|
-
abstract configure(data?: any): void;
|
|
32
|
-
protected getUniqueChannelPrefix(): string;
|
|
33
|
-
protected getSocketInfoHashKey(): string;
|
|
34
|
-
protected getConnectionHandler(): Promise<AbstractSocketConnectionHandler | undefined>;
|
|
35
|
-
protected formatBroadcastData(channel: string, data: any): SocketMessage;
|
|
36
|
-
protected getUniqueChannelName(channel: string): string;
|
|
37
|
-
protected getSocketIdsOfChannel(channel: string): Promise<string[]>;
|
|
38
|
-
addSocketToChannel(socketId: string, channelInfos: ChannelInfo[]): Promise<AbstractServerSocket | undefined>;
|
|
39
|
-
removeSocketFromChannel(socketId: string, channels: string[], persist?: boolean): Promise<void>;
|
|
40
|
-
abstract getSocketsByChannel(channel: string): Promise<IServerSocket[]>;
|
|
41
|
-
abstract broadcastToChannel(channel: string, data: any): Promise<void>;
|
|
42
|
-
removeSocket(socketId: string, physicRemove?: boolean): Promise<void>;
|
|
43
|
-
abstract getById(socketId: string): Promise<AbstractServerSocket | undefined>;
|
|
44
|
-
handle(socketData: SocketData): Promise<void>;
|
|
45
|
-
getMountedEndpointInfo(): Promise<MountedEndpointInfo[]>;
|
|
46
|
-
}
|
|
1
|
+
import { AbstractLogger, SocketMessage } from "@clairejs/core";
|
|
2
|
+
import Client from "ioredis";
|
|
3
|
+
import { SocketData } from "../common/request/SocketData";
|
|
4
|
+
import { AbstractSocketConnectionHandler } from "./AbstractSocketConnectionHandler";
|
|
5
|
+
import { IPrincipal } from "../common/auth/IPrincipal";
|
|
6
|
+
import { AbstractServerSocket } from "./AbstractServerSocket";
|
|
7
|
+
import { MountedEndpointInfo } from "../common/request/MountedEndpointInfo";
|
|
8
|
+
import { AbstractHttpAuthorizationProvider } from "../http/auth/AbstractHttpAuthorizationProvider";
|
|
9
|
+
import { IServerSocket } from "./IServerSocket";
|
|
10
|
+
export interface ChannelInfo {
|
|
11
|
+
name: string;
|
|
12
|
+
clientToServerAllowed: boolean;
|
|
13
|
+
serverToClientAllowed: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface ServerSocketInfo {
|
|
16
|
+
id: string;
|
|
17
|
+
createdAt: number;
|
|
18
|
+
channels: ChannelInfo[];
|
|
19
|
+
authInfo?: IPrincipal;
|
|
20
|
+
}
|
|
21
|
+
export declare abstract class AbstractServerSocketManager {
|
|
22
|
+
protected readonly requireAuthentication: boolean;
|
|
23
|
+
protected readonly logger: AbstractLogger;
|
|
24
|
+
protected readonly redisServerUrl: string;
|
|
25
|
+
protected readonly authProvider: AbstractHttpAuthorizationProvider;
|
|
26
|
+
protected readonly authResolver: (queries?: any) => any;
|
|
27
|
+
private mountedEndpointInfo?;
|
|
28
|
+
private _connectionHandler?;
|
|
29
|
+
protected redisClient: Client;
|
|
30
|
+
protected constructor(requireAuthentication: boolean, logger: AbstractLogger, redisServerUrl: string, authProvider: AbstractHttpAuthorizationProvider, authResolver: (queries?: any) => any);
|
|
31
|
+
abstract configure(data?: any): void;
|
|
32
|
+
protected getUniqueChannelPrefix(): string;
|
|
33
|
+
protected getSocketInfoHashKey(): string;
|
|
34
|
+
protected getConnectionHandler(): Promise<AbstractSocketConnectionHandler | undefined>;
|
|
35
|
+
protected formatBroadcastData(channel: string, data: any): SocketMessage;
|
|
36
|
+
protected getUniqueChannelName(channel: string): string;
|
|
37
|
+
protected getSocketIdsOfChannel(channel: string): Promise<string[]>;
|
|
38
|
+
addSocketToChannel(socketId: string, channelInfos: ChannelInfo[]): Promise<AbstractServerSocket | undefined>;
|
|
39
|
+
removeSocketFromChannel(socketId: string, channels: string[], persist?: boolean): Promise<void>;
|
|
40
|
+
abstract getSocketsByChannel(channel: string): Promise<IServerSocket[]>;
|
|
41
|
+
abstract broadcastToChannel(channel: string, data: any): Promise<void>;
|
|
42
|
+
removeSocket(socketId: string, physicRemove?: boolean): Promise<void>;
|
|
43
|
+
abstract getById(socketId: string): Promise<AbstractServerSocket | undefined>;
|
|
44
|
+
handle(socketData: SocketData): Promise<void>;
|
|
45
|
+
getMountedEndpointInfo(): Promise<MountedEndpointInfo[]>;
|
|
46
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IServerSocket } from "./IServerSocket";
|
|
2
|
-
export declare abstract class AbstractSocketConnectionHandler {
|
|
3
|
-
abstract onSocketConnect(socket: IServerSocket): Promise<void>;
|
|
4
|
-
abstract onSocketDisconnect(socket: IServerSocket): Promise<void>;
|
|
5
|
-
abstract onMessage(socket: IServerSocket, message: any, channel?: string): Promise<void>;
|
|
6
|
-
}
|
|
1
|
+
import { IServerSocket } from "./IServerSocket";
|
|
2
|
+
export declare abstract class AbstractSocketConnectionHandler {
|
|
3
|
+
abstract onSocketConnect(socket: IServerSocket): Promise<void>;
|
|
4
|
+
abstract onSocketDisconnect(socket: IServerSocket): Promise<void>;
|
|
5
|
+
abstract onMessage(socket: IServerSocket, message: any, channel?: string): Promise<void>;
|
|
6
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { IServerSocket } from "./IServerSocket";
|
|
2
|
-
export declare abstract class AbstractSocketController {
|
|
3
|
-
readonly channel: string;
|
|
4
|
-
constructor(channel: string);
|
|
5
|
-
onChannelJoin(socket: IServerSocket): Promise<void>;
|
|
6
|
-
onChannelLeave(socket: IServerSocket): Promise<void>;
|
|
7
|
-
/**
|
|
8
|
-
* Handle the message sent to this channel
|
|
9
|
-
* @param socket the socket sending message
|
|
10
|
-
* @param data the data payload being sent
|
|
11
|
-
* @returns return false to prevent message broadcast
|
|
12
|
-
*/
|
|
13
|
-
onMessage(socket: IServerSocket, message: any): Promise<boolean | void>;
|
|
14
|
-
}
|
|
1
|
+
import { IServerSocket } from "./IServerSocket";
|
|
2
|
+
export declare abstract class AbstractSocketController {
|
|
3
|
+
readonly channel: string;
|
|
4
|
+
constructor(channel: string);
|
|
5
|
+
onChannelJoin(socket: IServerSocket): Promise<void>;
|
|
6
|
+
onChannelLeave(socket: IServerSocket): Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Handle the message sent to this channel
|
|
9
|
+
* @param socket the socket sending message
|
|
10
|
+
* @param data the data payload being sent
|
|
11
|
+
* @returns return false to prevent message broadcast
|
|
12
|
+
*/
|
|
13
|
+
onMessage(socket: IServerSocket, message: any): Promise<boolean | void>;
|
|
14
|
+
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { AbstractLogger, IInit } from "@clairejs/core";
|
|
2
|
-
import { AbstractHttpRequestHandler } from "../http/controller/AbstractHttpRequestHandler";
|
|
3
|
-
import { AbstractServerSocketManager, ServerSocketInfo } from "./AbstractServerSocketManager";
|
|
4
|
-
import { AbstractServerSocket } from "./AbstractServerSocket";
|
|
5
|
-
import { AbstractHttpAuthorizationProvider } from "../http/auth/AbstractHttpAuthorizationProvider";
|
|
6
|
-
import { IPrincipal } from "../common/auth/IPrincipal";
|
|
7
|
-
import { IServerSocket } from "./IServerSocket";
|
|
8
|
-
export declare class AwsSocketManager extends AbstractServerSocketManager implements IInit {
|
|
9
|
-
protected readonly authenticationRequired: boolean;
|
|
10
|
-
protected readonly region: string;
|
|
11
|
-
protected readonly socketDomainUrl: string;
|
|
12
|
-
protected readonly redisServerUrl: string;
|
|
13
|
-
protected readonly httpRequestHandler: AbstractHttpRequestHandler;
|
|
14
|
-
protected readonly authorizationProvider: AbstractHttpAuthorizationProvider<IPrincipal>;
|
|
15
|
-
protected readonly authResolver: (queries?: any) => any;
|
|
16
|
-
protected readonly logger: AbstractLogger;
|
|
17
|
-
private readonly apiGatewayManagement;
|
|
18
|
-
constructor(authenticationRequired: boolean, region: string, socketDomainUrl: string, redisServerUrl: string, httpRequestHandler: AbstractHttpRequestHandler, authorizationProvider: AbstractHttpAuthorizationProvider<IPrincipal>, authResolver: (queries?: any) => any, logger: AbstractLogger);
|
|
19
|
-
init(): Promise<void>;
|
|
20
|
-
exit(): void;
|
|
21
|
-
removeSocketFromRedis(socketId: string): Promise<void>;
|
|
22
|
-
physicSend(socketId: string, data: any): Promise<void>;
|
|
23
|
-
configure(data?: any): void;
|
|
24
|
-
getSocketsByChannel(channel: string): Promise<IServerSocket[]>;
|
|
25
|
-
broadcastToChannel(channel: string, data: any): Promise<void>;
|
|
26
|
-
addSocket(socketInfo: ServerSocketInfo, data: any): Promise<AbstractServerSocket>;
|
|
27
|
-
removeSocket(socketId: string, physicRemove?: boolean): Promise<void>;
|
|
28
|
-
private getSocketBySerialized;
|
|
29
|
-
getById(socketId: string): Promise<AbstractServerSocket | undefined>;
|
|
30
|
-
}
|
|
1
|
+
import { AbstractLogger, IInit } from "@clairejs/core";
|
|
2
|
+
import { AbstractHttpRequestHandler } from "../http/controller/AbstractHttpRequestHandler";
|
|
3
|
+
import { AbstractServerSocketManager, ServerSocketInfo } from "./AbstractServerSocketManager";
|
|
4
|
+
import { AbstractServerSocket } from "./AbstractServerSocket";
|
|
5
|
+
import { AbstractHttpAuthorizationProvider } from "../http/auth/AbstractHttpAuthorizationProvider";
|
|
6
|
+
import { IPrincipal } from "../common/auth/IPrincipal";
|
|
7
|
+
import { IServerSocket } from "./IServerSocket";
|
|
8
|
+
export declare class AwsSocketManager extends AbstractServerSocketManager implements IInit {
|
|
9
|
+
protected readonly authenticationRequired: boolean;
|
|
10
|
+
protected readonly region: string;
|
|
11
|
+
protected readonly socketDomainUrl: string;
|
|
12
|
+
protected readonly redisServerUrl: string;
|
|
13
|
+
protected readonly httpRequestHandler: AbstractHttpRequestHandler;
|
|
14
|
+
protected readonly authorizationProvider: AbstractHttpAuthorizationProvider<IPrincipal>;
|
|
15
|
+
protected readonly authResolver: (queries?: any) => any;
|
|
16
|
+
protected readonly logger: AbstractLogger;
|
|
17
|
+
private readonly apiGatewayManagement;
|
|
18
|
+
constructor(authenticationRequired: boolean, region: string, socketDomainUrl: string, redisServerUrl: string, httpRequestHandler: AbstractHttpRequestHandler, authorizationProvider: AbstractHttpAuthorizationProvider<IPrincipal>, authResolver: (queries?: any) => any, logger: AbstractLogger);
|
|
19
|
+
init(): Promise<void>;
|
|
20
|
+
exit(): void;
|
|
21
|
+
removeSocketFromRedis(socketId: string): Promise<void>;
|
|
22
|
+
physicSend(socketId: string, data: any): Promise<void>;
|
|
23
|
+
configure(data?: any): void;
|
|
24
|
+
getSocketsByChannel(channel: string): Promise<IServerSocket[]>;
|
|
25
|
+
broadcastToChannel(channel: string, data: any): Promise<void>;
|
|
26
|
+
addSocket(socketInfo: ServerSocketInfo, data: any): Promise<AbstractServerSocket>;
|
|
27
|
+
removeSocket(socketId: string, physicRemove?: boolean): Promise<void>;
|
|
28
|
+
private getSocketBySerialized;
|
|
29
|
+
getById(socketId: string): Promise<AbstractServerSocket | undefined>;
|
|
30
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { IPrincipal } from "../common/auth/IPrincipal";
|
|
2
|
-
export interface IServerSocket {
|
|
3
|
-
getId(): string;
|
|
4
|
-
getAuthInfo(): IPrincipal | undefined;
|
|
5
|
-
/**
|
|
6
|
-
* Send back data to client
|
|
7
|
-
* @param data The data to send, will be serialized using JSON.stringify
|
|
8
|
-
*/
|
|
9
|
-
send(data: any, channel?: string): Promise<void>;
|
|
10
|
-
/**
|
|
11
|
-
* Disconnect the socket and optionally provide the error which cause the disconnection.
|
|
12
|
-
* The client socket will treat this error as intended reason for socket termination.
|
|
13
|
-
* @param err The error which cause the disconnection
|
|
14
|
-
*/
|
|
15
|
-
disconnect(err?: any): Promise<void>;
|
|
16
|
-
}
|
|
1
|
+
import { IPrincipal } from "../common/auth/IPrincipal";
|
|
2
|
+
export interface IServerSocket {
|
|
3
|
+
getId(): string;
|
|
4
|
+
getAuthInfo(): IPrincipal | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Send back data to client
|
|
7
|
+
* @param data The data to send, will be serialized using JSON.stringify
|
|
8
|
+
*/
|
|
9
|
+
send(data: any, channel?: string): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Disconnect the socket and optionally provide the error which cause the disconnection.
|
|
12
|
+
* The client socket will treat this error as intended reason for socket termination.
|
|
13
|
+
* @param err The error which cause the disconnection
|
|
14
|
+
*/
|
|
15
|
+
disconnect(err?: any): Promise<void>;
|
|
16
|
+
}
|