@clairejs/server 3.5.2 → 3.6.0
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 +659 -654
- 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 -10
- 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 -56
- 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 -60
- package/dist/http/repository/ICrudRepository.d.ts +27 -29
- package/dist/http/repository/ModelRepository.d.ts +37 -39
- 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 +56 -70
- 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 -8
- package/dist/socket/AbstractServerSocket.d.ts +19 -19
- package/dist/socket/AbstractServerSocketManager.d.ts +44 -44
- package/dist/socket/AbstractSocketConnectionHandler.d.ts +6 -6
- package/dist/socket/AbstractSocketController.d.ts +14 -14
- package/dist/socket/AwsSocketManager.d.ts +31 -31
- package/dist/socket/IServerSocket.d.ts +16 -16
- package/dist/socket/LocalSocketManager.d.ts +48 -48
- 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 +61 -61
- package/dist/database/QueryOperator.d.ts +0 -15
- package/dist/database/adapter/AbstractDatabaseAdapter.d.ts +0 -20
- package/dist/database/adapter/AbstractQuery.d.ts +0 -53
- package/dist/database/adapter/DefaultSqlDatabaseAdapter.d.ts +0 -17
- package/dist/database/adapter/IQuery.d.ts +0 -77
- package/dist/database/adapter/IQueryProvider.d.ts +0 -9
- package/dist/database/adapter/aggregators.d.ts +0 -21
- package/dist/database/adapter/providers.d.ts +0 -8
- package/dist/database/decorators.d.ts +0 -2
- package/dist/database/migrator/AbstractDatabaseMigrator.d.ts +0 -4
- package/dist/database/migrator/DefaultSqlDatabaseMigrator.d.ts +0 -27
- package/dist/database/transaction/ITransaction.d.ts +0 -10
- package/dist/database/transaction/ITransactionFactory.d.ts +0 -4
- package/dist/database/transaction/ITransactionProvider.d.ts +0 -4
- package/dist/database/transaction/TransactionLink.d.ts +0 -14
- package/dist/database/transaction/TransactionObjectMetadata.d.ts +0 -4
- package/dist/database/transaction/TransactionState.d.ts +0 -5
- package/dist/database/util/transaction-provider.d.ts +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { AbstractLogger, ClaireApp } from "@clairejs/core";
|
|
2
|
-
import { AbstractHttpRequestHandler } from "../http/controller/AbstractHttpRequestHandler";
|
|
3
|
-
import { AbstractServerSocketManager } from "../socket/AbstractServerSocketManager";
|
|
4
|
-
export declare class ClaireServer extends ClaireApp {
|
|
5
|
-
readonly logger: AbstractLogger;
|
|
6
|
-
readonly httpRequestHandler: AbstractHttpRequestHandler | undefined;
|
|
7
|
-
readonly socketManager: AbstractServerSocketManager | undefined;
|
|
8
|
-
private booted;
|
|
9
|
-
constructor(logger: AbstractLogger, httpRequestHandler: AbstractHttpRequestHandler | undefined, socketManager: AbstractServerSocketManager | undefined);
|
|
10
|
-
init(): Promise<void>;
|
|
11
|
-
exit(): void;
|
|
12
|
-
private stop;
|
|
13
|
-
}
|
|
1
|
+
import { AbstractLogger, ClaireApp } from "@clairejs/core";
|
|
2
|
+
import { AbstractHttpRequestHandler } from "../http/controller/AbstractHttpRequestHandler";
|
|
3
|
+
import { AbstractServerSocketManager } from "../socket/AbstractServerSocketManager";
|
|
4
|
+
export declare class ClaireServer extends ClaireApp {
|
|
5
|
+
readonly logger: AbstractLogger;
|
|
6
|
+
readonly httpRequestHandler: AbstractHttpRequestHandler | undefined;
|
|
7
|
+
readonly socketManager: AbstractServerSocketManager | undefined;
|
|
8
|
+
private booted;
|
|
9
|
+
constructor(logger: AbstractLogger, httpRequestHandler: AbstractHttpRequestHandler | undefined, socketManager: AbstractServerSocketManager | undefined);
|
|
10
|
+
init(): Promise<void>;
|
|
11
|
+
exit(): void;
|
|
12
|
+
private stop;
|
|
13
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { ClaireServer } from "./ClaireServer";
|
|
2
|
-
interface ExpressWrapperConfig {
|
|
3
|
-
maxBodySizeKB?: number;
|
|
4
|
-
}
|
|
5
|
-
export declare class ExpressWrapper {
|
|
6
|
-
private readonly injector;
|
|
7
|
-
private readonly socketManager?;
|
|
8
|
-
private readonly logger;
|
|
9
|
-
private readonly server;
|
|
10
|
-
private readonly config?;
|
|
11
|
-
private readonly httpRequestHandler?;
|
|
12
|
-
private httpServer?;
|
|
13
|
-
constructor(server: ClaireServer, config?: ExpressWrapperConfig);
|
|
14
|
-
close(): void;
|
|
15
|
-
listen(listenPort: number): Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
export {};
|
|
1
|
+
import { ClaireServer } from "./ClaireServer";
|
|
2
|
+
interface ExpressWrapperConfig {
|
|
3
|
+
maxBodySizeKB?: number;
|
|
4
|
+
}
|
|
5
|
+
export declare class ExpressWrapper {
|
|
6
|
+
private readonly injector;
|
|
7
|
+
private readonly socketManager?;
|
|
8
|
+
private readonly logger;
|
|
9
|
+
private readonly server;
|
|
10
|
+
private readonly config?;
|
|
11
|
+
private readonly httpRequestHandler?;
|
|
12
|
+
private httpServer?;
|
|
13
|
+
constructor(server: ClaireServer, config?: ExpressWrapperConfig);
|
|
14
|
+
close(): void;
|
|
15
|
+
listen(listenPort: number): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { RequestOptions } from "../common/request/RequestOptions";
|
|
2
|
-
import { ClaireServer } from "./ClaireServer";
|
|
3
|
-
interface LambdaResponse {
|
|
4
|
-
statusCode: number;
|
|
5
|
-
body: string;
|
|
6
|
-
headers: any;
|
|
7
|
-
}
|
|
8
|
-
export declare class LambdaWrapper {
|
|
9
|
-
readonly serverFactory: () => Promise<ClaireServer>;
|
|
10
|
-
readonly requestMapper: (event: any) => RequestOptions | undefined;
|
|
11
|
-
private readonly injector;
|
|
12
|
-
private readonly httpRequestHandler?;
|
|
13
|
-
private readonly socketManager?;
|
|
14
|
-
private _server?;
|
|
15
|
-
constructor(serverFactory: () => Promise<ClaireServer>, requestMapper: (event: any) => RequestOptions | undefined);
|
|
16
|
-
private bootServer;
|
|
17
|
-
handler(event: any): Promise<LambdaResponse>;
|
|
18
|
-
}
|
|
19
|
-
export {};
|
|
1
|
+
import { RequestOptions } from "../common/request/RequestOptions";
|
|
2
|
+
import { ClaireServer } from "./ClaireServer";
|
|
3
|
+
interface LambdaResponse {
|
|
4
|
+
statusCode: number;
|
|
5
|
+
body: string;
|
|
6
|
+
headers: any;
|
|
7
|
+
}
|
|
8
|
+
export declare class LambdaWrapper {
|
|
9
|
+
readonly serverFactory: () => Promise<ClaireServer>;
|
|
10
|
+
readonly requestMapper: (event: any) => RequestOptions | undefined;
|
|
11
|
+
private readonly injector;
|
|
12
|
+
private readonly httpRequestHandler?;
|
|
13
|
+
private readonly socketManager?;
|
|
14
|
+
private _server?;
|
|
15
|
+
constructor(serverFactory: () => Promise<ClaireServer>, requestMapper: (event: any) => RequestOptions | undefined);
|
|
16
|
+
private bootServer;
|
|
17
|
+
handler(event: any): Promise<LambdaResponse>;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CoreGlobalStore } from "@clairejs/core";
|
|
2
|
-
import { MountedEndpointInfo } from "../common/request/MountedEndpointInfo";
|
|
3
|
-
export interface ServerGlobalStore extends CoreGlobalStore {
|
|
4
|
-
mountedEndpointInfo?: MountedEndpointInfo[];
|
|
5
|
-
}
|
|
1
|
+
import { CoreGlobalStore } from "@clairejs/core";
|
|
2
|
+
import { MountedEndpointInfo } from "../common/request/MountedEndpointInfo";
|
|
3
|
+
export interface ServerGlobalStore extends CoreGlobalStore {
|
|
4
|
+
mountedEndpointInfo?: MountedEndpointInfo[];
|
|
5
|
+
}
|
package/dist/system/errors.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export declare const Errors: {
|
|
2
|
-
TFA_REQUIRED: string;
|
|
3
|
-
SYSTEM_ERROR: string;
|
|
4
|
-
HTTP_REQUEST_ERROR: string;
|
|
5
|
-
SESSION_EXPIRED: string;
|
|
6
|
-
ACCESS_DENIED: string;
|
|
7
|
-
AUTHENTICATION_ERROR: string;
|
|
8
|
-
NOT_FOUND: string;
|
|
9
|
-
VALIDATION_ERROR: string;
|
|
10
|
-
BAD_STATE: string;
|
|
11
|
-
QUERY_ERROR: string;
|
|
12
|
-
REQUEST_RATE_LIMIT: string;
|
|
13
|
-
CANNOT_LOCK: string;
|
|
14
|
-
};
|
|
1
|
+
export declare const Errors: {
|
|
2
|
+
TFA_REQUIRED: string;
|
|
3
|
+
SYSTEM_ERROR: string;
|
|
4
|
+
HTTP_REQUEST_ERROR: string;
|
|
5
|
+
SESSION_EXPIRED: string;
|
|
6
|
+
ACCESS_DENIED: string;
|
|
7
|
+
AUTHENTICATION_ERROR: string;
|
|
8
|
+
NOT_FOUND: string;
|
|
9
|
+
VALIDATION_ERROR: string;
|
|
10
|
+
BAD_STATE: string;
|
|
11
|
+
QUERY_ERROR: string;
|
|
12
|
+
REQUEST_RATE_LIMIT: string;
|
|
13
|
+
CANNOT_LOCK: string;
|
|
14
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { HttpMethod, SocketMethod } from "@clairejs/core";
|
|
2
|
-
export declare const lambdaRequestMapper: (event: any) => {
|
|
3
|
-
method: SocketMethod;
|
|
4
|
-
rawPath: any;
|
|
5
|
-
body: any;
|
|
6
|
-
headers?: undefined;
|
|
7
|
-
} | {
|
|
8
|
-
method: HttpMethod;
|
|
9
|
-
rawPath: string;
|
|
10
|
-
body: any;
|
|
11
|
-
headers: any;
|
|
12
|
-
};
|
|
1
|
+
import { HttpMethod, SocketMethod } from "@clairejs/core";
|
|
2
|
+
export declare const lambdaRequestMapper: (event: any) => {
|
|
3
|
+
method: SocketMethod;
|
|
4
|
+
rawPath: any;
|
|
5
|
+
body: any;
|
|
6
|
+
headers?: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
method: HttpMethod;
|
|
9
|
+
rawPath: string;
|
|
10
|
+
body: any;
|
|
11
|
+
headers: any;
|
|
12
|
+
};
|
package/package.json
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@clairejs/server",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "Claire server NodeJs framework written in Typescript.",
|
|
5
|
-
"types": "dist/index.d.ts",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test-
|
|
9
|
-
"test-
|
|
10
|
-
"test
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"express": "^
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"pg": "^
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"sequelize": "^6.
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"@clairejs/
|
|
38
|
-
},
|
|
39
|
-
"devDependencies": {
|
|
40
|
-
"@types/body-parser": "^1.19.0",
|
|
41
|
-
"@types/cors": "^2.8.9",
|
|
42
|
-
"@types/express": "^4.17.11",
|
|
43
|
-
"@types/express-fileupload": "^1.1.6",
|
|
44
|
-
"@types/mocha": "^8.2.2",
|
|
45
|
-
"@types/node": "^14.14.25",
|
|
46
|
-
"@types/parseurl": "^1.3.1",
|
|
47
|
-
"@types/validator": "^13.1.3",
|
|
48
|
-
"@types/webpack-env": "^1.16.0",
|
|
49
|
-
"@types/ws": "^7.4.0",
|
|
50
|
-
"axios": "^0.21.1",
|
|
51
|
-
"mocha": "^8.3.2",
|
|
52
|
-
"terser-webpack-plugin": "^4.2.3",
|
|
53
|
-
"ts-loader": "^8.4.0",
|
|
54
|
-
"ts-node": "^10.8.1",
|
|
55
|
-
"tslib": "^2.1.0",
|
|
56
|
-
"typescript": "^4.4.4",
|
|
57
|
-
"webpack": "^5.73.0",
|
|
58
|
-
"webpack-cli": "^4.10.0",
|
|
59
|
-
"webpack-node-externals": "^2.5.1"
|
|
60
|
-
}
|
|
61
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@clairejs/server",
|
|
3
|
+
"version": "3.6.0",
|
|
4
|
+
"description": "Claire server NodeJs framework written in Typescript.",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test-http": "mocha -r ts-node/register ./test/e2e/e2e.test.ts",
|
|
9
|
+
"test-socket": "mocha -r ts-node/register ./test/socket/socket.test.ts",
|
|
10
|
+
"test": "npm run test-http && npm run test-socket",
|
|
11
|
+
"build": "rm -rf ./dist && webpack --mode production",
|
|
12
|
+
"push": "npm run build && npm test && npm publish && git push"
|
|
13
|
+
},
|
|
14
|
+
"author": "immort",
|
|
15
|
+
"license": "ISC",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"aws-sdk": "^2.841.0",
|
|
18
|
+
"cors": "^2.8.5",
|
|
19
|
+
"express": "^4.17.1",
|
|
20
|
+
"express-fileupload": "^1.2.1",
|
|
21
|
+
"ioredis": "^5.2.0",
|
|
22
|
+
"mysql2": "^2.2.5",
|
|
23
|
+
"node-cron": "^3.0.1",
|
|
24
|
+
"parseurl": "^1.3.3",
|
|
25
|
+
"path-to-regexp": "^6.2.0",
|
|
26
|
+
"pg": "^8.5.1",
|
|
27
|
+
"pg-hstore": "^2.3.4",
|
|
28
|
+
"query-string": "^6.14.0",
|
|
29
|
+
"redlock": "^5.0.0-beta.2",
|
|
30
|
+
"reflect-metadata": "^0.1.13",
|
|
31
|
+
"sequelize": "^6.5.0",
|
|
32
|
+
"sequelize-cli": "^6.2.0",
|
|
33
|
+
"ws": "^7.5.5"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@clairejs/core": "^3.1.9",
|
|
37
|
+
"@clairejs/orm": "^3.0.2"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/body-parser": "^1.19.0",
|
|
41
|
+
"@types/cors": "^2.8.9",
|
|
42
|
+
"@types/express": "^4.17.11",
|
|
43
|
+
"@types/express-fileupload": "^1.1.6",
|
|
44
|
+
"@types/mocha": "^8.2.2",
|
|
45
|
+
"@types/node": "^14.14.25",
|
|
46
|
+
"@types/parseurl": "^1.3.1",
|
|
47
|
+
"@types/validator": "^13.1.3",
|
|
48
|
+
"@types/webpack-env": "^1.16.0",
|
|
49
|
+
"@types/ws": "^7.4.0",
|
|
50
|
+
"axios": "^0.21.1",
|
|
51
|
+
"mocha": "^8.3.2",
|
|
52
|
+
"terser-webpack-plugin": "^4.2.3",
|
|
53
|
+
"ts-loader": "^8.4.0",
|
|
54
|
+
"ts-node": "^10.8.1",
|
|
55
|
+
"tslib": "^2.1.0",
|
|
56
|
+
"typescript": "^4.4.4",
|
|
57
|
+
"webpack": "^5.73.0",
|
|
58
|
+
"webpack-cli": "^4.10.0",
|
|
59
|
+
"webpack-node-externals": "^2.5.1"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare type MultiOperandOps = "_and" | "_or";
|
|
2
|
-
export declare type Op = "_eq" | "_neq" | "_in"
|
|
3
|
-
/**
|
|
4
|
-
* Does not belong to array
|
|
5
|
-
*/
|
|
6
|
-
| "_nin" | "_sub" | "_isub" | "_usub" | "_iusub" | "_regex" | "_gt" | "_lt" | "_gte" | "_lte" | MultiOperandOps;
|
|
7
|
-
export declare type SingleOperator<T> = {
|
|
8
|
-
[key in Exclude<Op, MultiOperandOps>]?: {
|
|
9
|
-
[name in keyof T]?: any;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
export declare type MultileOperator<T> = {
|
|
13
|
-
[key in MultiOperandOps]?: (SingleOperator<T> | MultileOperator<T>)[];
|
|
14
|
-
};
|
|
15
|
-
export declare type QueryCondition<T> = SingleOperator<T> | MultileOperator<T>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ModelMetadata, AbstractModel, IInit, Constructor } from "@clairejs/core";
|
|
2
|
-
import { IQueryProvider } from "./IQueryProvider";
|
|
3
|
-
import { IQuery } from "./IQuery";
|
|
4
|
-
import { ITransaction } from "../transaction/ITransaction";
|
|
5
|
-
import { ITransactionFactory } from "../transaction/ITransactionFactory";
|
|
6
|
-
export declare type ConnectionHolder<T> = {
|
|
7
|
-
connection: T;
|
|
8
|
-
};
|
|
9
|
-
export declare abstract class AbstractDatabaseAdapter implements IInit, IQueryProvider, ITransactionFactory {
|
|
10
|
-
protected modelMetadata: ModelMetadata[];
|
|
11
|
-
protected models: Constructor<AbstractModel>[];
|
|
12
|
-
protected modelConnections: {
|
|
13
|
-
[key: string]: ConnectionHolder<any>;
|
|
14
|
-
};
|
|
15
|
-
protected constructor();
|
|
16
|
-
abstract createTransaction(): Promise<ITransaction>;
|
|
17
|
-
abstract use<T extends AbstractModel>(model: Constructor<T>): IQuery<T>;
|
|
18
|
-
init(): Promise<void>;
|
|
19
|
-
exit(): void;
|
|
20
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { AbstractModel, ModelMetadata, Constructor } from "@clairejs/core";
|
|
2
|
-
import { QueryCondition } from "../QueryOperator";
|
|
3
|
-
import { IGroupBy, IJoin, IQuery, ISelect, IWhere, JoinMode, OrderDirective } from "./IQuery";
|
|
4
|
-
export declare abstract class AbstractQuery<T extends AbstractModel> implements IQuery<T> {
|
|
5
|
-
readonly metadata: ModelMetadata;
|
|
6
|
-
readonly model: Constructor<T>;
|
|
7
|
-
protected constructor(model: Constructor<AbstractModel>);
|
|
8
|
-
abstract join<K extends AbstractModel>(model: Constructor<K>, leftField: keyof T, rightField: keyof K, joinMode?: JoinMode): IJoin<T & K> & IWhere<T & K> & IGroupBy<T & K> & ISelect<T & K>;
|
|
9
|
-
abstract getById<K extends keyof T>(id: number, options?: {
|
|
10
|
-
projection?: K[];
|
|
11
|
-
}): Promise<Pick<T, K> | undefined>;
|
|
12
|
-
abstract getByIds<K extends keyof T>(ids: number[], options?: {
|
|
13
|
-
projection?: K[];
|
|
14
|
-
}): Promise<Pick<T, K>[]>;
|
|
15
|
-
abstract getOne<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
16
|
-
projection?: K[];
|
|
17
|
-
}): Promise<Pick<T, K> | undefined>;
|
|
18
|
-
abstract getMany<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
19
|
-
order?: OrderDirective<T>;
|
|
20
|
-
projection?: K[];
|
|
21
|
-
limit?: number;
|
|
22
|
-
page?: number;
|
|
23
|
-
}, includes?: {
|
|
24
|
-
modelId: string;
|
|
25
|
-
queries: QueryCondition<any>;
|
|
26
|
-
}[]): Promise<{
|
|
27
|
-
total: number;
|
|
28
|
-
records: Pick<T, K>[];
|
|
29
|
-
}>;
|
|
30
|
-
abstract getRecords<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
31
|
-
order?: OrderDirective<T>;
|
|
32
|
-
projection?: K[];
|
|
33
|
-
limit?: number;
|
|
34
|
-
}, includes?: {
|
|
35
|
-
modelId: string;
|
|
36
|
-
queries: QueryCondition<any>;
|
|
37
|
-
}[]): Promise<Pick<T, K>[]>;
|
|
38
|
-
abstract createOne(modelInstance: Partial<T>): Promise<T>;
|
|
39
|
-
abstract count(queries?: QueryCondition<T>, options?: {
|
|
40
|
-
distinct?: keyof T;
|
|
41
|
-
}, includes?: {
|
|
42
|
-
modelId: string;
|
|
43
|
-
queries: QueryCondition<any>;
|
|
44
|
-
}[]): Promise<number>;
|
|
45
|
-
abstract createMany(modelInstances: Partial<T>[]): Promise<T[]>;
|
|
46
|
-
abstract updateOne(modelInstance: T): Promise<T>;
|
|
47
|
-
abstract updateMany(queries: QueryCondition<T>, update: Partial<T>, returning?: boolean): Promise<number[]>;
|
|
48
|
-
abstract deleteOne(modelInstance: T): Promise<T>;
|
|
49
|
-
abstract deleteMany(queries: QueryCondition<T>, returning?: boolean): Promise<T[]>;
|
|
50
|
-
abstract rawQuery(...args: any[]): Promise<any>;
|
|
51
|
-
protected convertToLogicObjects<K extends keyof T>(dataObjects: T[], projection?: K[]): Pick<T, K>[];
|
|
52
|
-
protected convertToDataObjects(modelInstances: Partial<T>[], forUpdate?: boolean): any[];
|
|
53
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { AbstractModel, AbstractLogger, Constructor } from "@clairejs/core";
|
|
2
|
-
import { ITransaction } from "../transaction/ITransaction";
|
|
3
|
-
import { AbstractDatabaseAdapter } from "./AbstractDatabaseAdapter";
|
|
4
|
-
import { IQuery } from "./IQuery";
|
|
5
|
-
import { SqlProvider } from "./providers";
|
|
6
|
-
export declare class DefaultSqlDatabaseAdapter extends AbstractDatabaseAdapter {
|
|
7
|
-
readonly logger: AbstractLogger;
|
|
8
|
-
private readonly sqlProvider;
|
|
9
|
-
private readonly dbConnection;
|
|
10
|
-
private readonly modelAdapters;
|
|
11
|
-
constructor(sqlProvider: SqlProvider, connectionString: string, logger: AbstractLogger);
|
|
12
|
-
createTransaction(): Promise<ITransaction>;
|
|
13
|
-
init(): Promise<void>;
|
|
14
|
-
exit(): number;
|
|
15
|
-
use<T extends AbstractModel>(model: Constructor<T>): IQuery<T>;
|
|
16
|
-
private generateSchemaObject;
|
|
17
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { AbstractModel, Constructor, OrderDirection } from "@clairejs/core";
|
|
2
|
-
import { QueryCondition } from "../QueryOperator";
|
|
3
|
-
import { Aggregator, HavingCondition } from "./aggregators";
|
|
4
|
-
/**
|
|
5
|
-
* Query condition based on a interface/class.
|
|
6
|
-
*/
|
|
7
|
-
export declare type JoinMode = "inner" | "left" | "right";
|
|
8
|
-
export declare type OrderDirective<K> = [keyof K, OrderDirection][] | "random";
|
|
9
|
-
export interface ISelect<T> {
|
|
10
|
-
count(): Promise<number>;
|
|
11
|
-
rows<K>(mapping: {
|
|
12
|
-
[field in keyof K]: Aggregator<T>;
|
|
13
|
-
}, options?: {
|
|
14
|
-
order?: OrderDirective<T>;
|
|
15
|
-
limit?: number;
|
|
16
|
-
page?: number;
|
|
17
|
-
}): Promise<{
|
|
18
|
-
total: number;
|
|
19
|
-
records: K[];
|
|
20
|
-
}>;
|
|
21
|
-
}
|
|
22
|
-
export interface IHaving<T> {
|
|
23
|
-
having(conditions: HavingCondition<T>): ISelect<T>;
|
|
24
|
-
}
|
|
25
|
-
export interface IGroupBy<T> {
|
|
26
|
-
groupBy(fields: (keyof T)[]): IHaving<T> & ISelect<T>;
|
|
27
|
-
}
|
|
28
|
-
export interface IWhere<T> {
|
|
29
|
-
where(queries?: QueryCondition<T>): IGroupBy<T> & ISelect<T>;
|
|
30
|
-
}
|
|
31
|
-
export interface IJoin<T extends AbstractModel> {
|
|
32
|
-
join<K extends AbstractModel>(model: Constructor<K>, leftField: keyof T, rightField: keyof K, joinMode?: JoinMode): IJoin<T & K> & IWhere<T & K> & IGroupBy<T & K> & ISelect<T & K>;
|
|
33
|
-
}
|
|
34
|
-
export interface IQuery<T extends AbstractModel> extends IJoin<T> {
|
|
35
|
-
createOne(modelInstance: Partial<T>): Promise<T>;
|
|
36
|
-
getById<K extends keyof T>(id: number, options?: {
|
|
37
|
-
projection?: K[];
|
|
38
|
-
}): Promise<Pick<T, K> | undefined>;
|
|
39
|
-
getByIds<K extends keyof T>(ids: number[], options?: {
|
|
40
|
-
projection?: K[];
|
|
41
|
-
}): Promise<Pick<T, K>[]>;
|
|
42
|
-
getOne<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
43
|
-
projection?: K[];
|
|
44
|
-
}): Promise<Pick<T, K> | undefined>;
|
|
45
|
-
count(queries?: QueryCondition<T>, options?: {
|
|
46
|
-
distinct?: keyof T;
|
|
47
|
-
}, includes?: {
|
|
48
|
-
modelId: string;
|
|
49
|
-
queries: QueryCondition<any>;
|
|
50
|
-
}[]): Promise<number>;
|
|
51
|
-
getMany<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
52
|
-
order?: OrderDirective<T>;
|
|
53
|
-
projection?: K[];
|
|
54
|
-
limit?: number;
|
|
55
|
-
page?: number;
|
|
56
|
-
}, includes?: {
|
|
57
|
-
modelId: string;
|
|
58
|
-
queries: QueryCondition<any>;
|
|
59
|
-
}[]): Promise<{
|
|
60
|
-
total: number;
|
|
61
|
-
records: Pick<T, K>[];
|
|
62
|
-
}>;
|
|
63
|
-
getRecords<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
64
|
-
order?: OrderDirective<T>;
|
|
65
|
-
projection?: K[];
|
|
66
|
-
limit?: number;
|
|
67
|
-
}, includes?: {
|
|
68
|
-
modelId: string;
|
|
69
|
-
queries: QueryCondition<any>;
|
|
70
|
-
}[]): Promise<Pick<T, K>[]>;
|
|
71
|
-
createMany(modelInstances: Partial<T>[]): Promise<T[]>;
|
|
72
|
-
updateOne(modelInstance: T): Promise<T>;
|
|
73
|
-
updateMany(queries: QueryCondition<T> | undefined, update: Partial<T>, returning?: boolean): Promise<number[]>;
|
|
74
|
-
deleteOne(modelInstance: T): Promise<T>;
|
|
75
|
-
deleteMany(queries?: QueryCondition<T>, returning?: boolean): Promise<T[]>;
|
|
76
|
-
rawQuery(...args: any[]): Promise<any>;
|
|
77
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AbstractModel, Constructor } from "@clairejs/core";
|
|
2
|
-
import { IQuery } from "./IQuery";
|
|
3
|
-
export interface IQueryProvider {
|
|
4
|
-
/**
|
|
5
|
-
* Use a model to provide the query interface for this model.
|
|
6
|
-
* @param model the model to get query interface
|
|
7
|
-
*/
|
|
8
|
-
use<T extends AbstractModel>(model: Constructor<T>): IQuery<T>;
|
|
9
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { MultiOperandOps, Op } from "../QueryOperator";
|
|
2
|
-
export declare type AggregatorFn = "count" | "sum" | "avg" | "min" | "max" | "join" | "is";
|
|
3
|
-
export interface Aggregator<T> {
|
|
4
|
-
fn: AggregatorFn;
|
|
5
|
-
field: keyof T;
|
|
6
|
-
args?: any;
|
|
7
|
-
}
|
|
8
|
-
export declare type SingleHaving<T> = {
|
|
9
|
-
[key in Exclude<Op, MultiOperandOps>]?: [Aggregator<T>, any];
|
|
10
|
-
};
|
|
11
|
-
export declare type MultileHaving<T> = {
|
|
12
|
-
[key in MultiOperandOps]?: (SingleHaving<T> | MultileHaving<T>)[];
|
|
13
|
-
};
|
|
14
|
-
export declare type HavingCondition<T> = SingleHaving<T> | MultileHaving<T>;
|
|
15
|
-
export declare const _count: <T>(field: keyof T, distinct?: boolean | undefined) => Aggregator<T>;
|
|
16
|
-
export declare const _sum: <T>(field: keyof T) => Aggregator<T>;
|
|
17
|
-
export declare const _avg: <T>(field: keyof T) => Aggregator<T>;
|
|
18
|
-
export declare const _min: <T>(field: keyof T) => Aggregator<T>;
|
|
19
|
-
export declare const _max: <T>(field: keyof T) => Aggregator<T>;
|
|
20
|
-
export declare const _join: <T>(field: keyof T, symbol: string) => Aggregator<T>;
|
|
21
|
-
export declare const _is: <T>(field: keyof T) => Aggregator<T>;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { AbstractLogger } from "@clairejs/core";
|
|
2
|
-
import { SqlProvider } from "../adapter/providers";
|
|
3
|
-
import { AbstractDatabaseMigrator } from "./AbstractDatabaseMigrator";
|
|
4
|
-
export declare class DefaultSqlDatabaseMigrator extends AbstractDatabaseMigrator {
|
|
5
|
-
readonly cliPath: string;
|
|
6
|
-
readonly sqlProvider: SqlProvider;
|
|
7
|
-
readonly connectionString: string;
|
|
8
|
-
readonly logger: AbstractLogger;
|
|
9
|
-
private static readonly COMMENT_BLOCK_REGEX_PATTERN;
|
|
10
|
-
private static readonly MIGRATION_TEMPLATE;
|
|
11
|
-
private readonly databaseURL;
|
|
12
|
-
private readonly modelMetadata;
|
|
13
|
-
constructor(cliPath: string, sqlProvider: SqlProvider, connectionString: string, logger: AbstractLogger);
|
|
14
|
-
private getUniqueConstraintGroups;
|
|
15
|
-
private generateFieldPropertiesQuery;
|
|
16
|
-
private getUniqueConstraintUpDown;
|
|
17
|
-
private getSqlCascadeAction;
|
|
18
|
-
private getForeignKeyConstraintUpDown;
|
|
19
|
-
private getAddColumnUpDown;
|
|
20
|
-
private generateCreateTableQuery;
|
|
21
|
-
private isBooleanDiff;
|
|
22
|
-
private runProcess;
|
|
23
|
-
rollback(migrationDirectory: string): Promise<void>;
|
|
24
|
-
migrate(migrationDirectory: string): Promise<void>;
|
|
25
|
-
private remove;
|
|
26
|
-
private getLeanModelMetadata;
|
|
27
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { AbstractModel } from "@clairejs/core";
|
|
2
|
-
import { IQuery } from "../adapter/IQuery";
|
|
3
|
-
import { IQueryProvider } from "../adapter/IQueryProvider";
|
|
4
|
-
import { TransactionState } from "./TransactionState";
|
|
5
|
-
export interface ITransaction extends IQueryProvider {
|
|
6
|
-
getState(): TransactionState;
|
|
7
|
-
use<T extends AbstractModel>(model: new (...args: any[]) => T): IQuery<T>;
|
|
8
|
-
commit(): Promise<void>;
|
|
9
|
-
rollback(): Promise<void>;
|
|
10
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare enum TransactionLink {
|
|
2
|
-
/**
|
|
3
|
-
* Create new transaction when executing the handler function.
|
|
4
|
-
*/
|
|
5
|
-
CREATE_NEW = "create_new",
|
|
6
|
-
/**
|
|
7
|
-
* Inherit the transaction from the caller function and create if not exist.
|
|
8
|
-
*/
|
|
9
|
-
INHERIT_OR_CREATE = "inherit_or_create",
|
|
10
|
-
/**
|
|
11
|
-
* Inherit the transaction from the caller function and throw error if not existed.
|
|
12
|
-
*/
|
|
13
|
-
INHERIT_OR_THROW = "inherit_or_throw"
|
|
14
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|