@clairejs/server 3.0.31 → 3.0.34
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/README.md +514 -513
- package/dist/common/constants.d.ts +1 -1
- package/dist/database/adapter/AbstractDatabaseAdapter.d.ts +19 -19
- package/dist/database/adapter/AbstractQuery.d.ts +52 -52
- package/dist/database/adapter/DefaultSqlDatabaseAdapter.d.ts +18 -18
- package/dist/database/adapter/IDatabaseProvider.d.ts +4 -4
- package/dist/database/adapter/IQuery.d.ts +75 -75
- package/dist/database/adapter/IQueryProvider.d.ts +9 -9
- package/dist/database/adapter/aggregators.d.ts +21 -21
- package/dist/database/adapter/providers.d.ts +8 -8
- package/dist/database/decorators.d.ts +2 -2
- package/dist/database/migrator/AbstractDatabaseMigrator.d.ts +4 -4
- package/dist/database/migrator/DefaultSqlDatabaseMigrator.d.ts +28 -28
- package/dist/database/transaction/ITransaction.d.ts +10 -10
- package/dist/database/transaction/ITransactionProvider.d.ts +4 -4
- package/dist/database/transaction/TransactionLink.d.ts +14 -14
- package/dist/database/transaction/TransactionObjectMetadata.d.ts +4 -4
- package/dist/database/transaction/TransactionState.d.ts +5 -5
- package/dist/database/util/transaction-provider.d.ts +1 -1
- package/dist/http/common/HttpRequest.d.ts +39 -39
- package/dist/http/common/HttpResponse.d.ts +25 -25
- package/dist/http/common/RequestOptions.d.ts +9 -9
- package/dist/http/common/ResponseValues.d.ts +10 -10
- package/dist/http/common/types.d.ts +1 -1
- package/dist/http/controller/AbstractHttpController.d.ts +12 -12
- package/dist/http/controller/AbstractHttpMiddleware.d.ts +5 -5
- package/dist/http/controller/AbstractHttpRequestHandler.d.ts +10 -10
- package/dist/http/controller/ControllerMetadata.d.ts +6 -6
- package/dist/http/controller/CrudHttpController.d.ts +53 -53
- package/dist/http/controller/DefaultHttpRequestHandler.d.ts +19 -19
- package/dist/http/controller/EndpointMetadata.d.ts +36 -36
- package/dist/http/controller/HttpEndpoint.d.ts +12 -12
- package/dist/http/controller/ModelRepository.d.ts +36 -36
- package/dist/http/controller/MountedEndpointInfo.d.ts +6 -6
- package/dist/http/decorators.d.ts +28 -27
- package/dist/http/security/AbstractAccessCondition.d.ts +7 -7
- package/dist/http/security/AbstractHttpAuthorizationProvider.d.ts +7 -7
- package/dist/http/security/IPrincipal.d.ts +3 -3
- package/dist/http/security/access-conditions/FilterModelFieldAccessCondition.d.ts +4 -4
- package/dist/http/security/access-conditions/OwnedResourceAccessCondition.d.ts +5 -5
- package/dist/index.d.ts +38 -38
- package/dist/index.js +1 -1
- package/dist/logging/FileLogMedium.d.ts +13 -13
- package/dist/service/AbstractService.d.ts +9 -9
- package/dist/socket/AbstractServerSocket.d.ts +36 -36
- package/dist/socket/AbstractServerSocketManager.d.ts +19 -19
- package/dist/socket/AwsSocketManager.d.ts +46 -46
- package/dist/socket/IServerSocket.d.ts +9 -9
- package/dist/socket/LocalSocketManager.d.ts +23 -23
- package/dist/socket/ServerSocket.d.ts +14 -14
- package/dist/system/AbstractFileUploadHandler.d.ts +6 -6
- package/dist/system/ClaireServer.d.ts +10 -10
- package/dist/system/ExpressWrapper.d.ts +17 -17
- package/dist/system/IRequestHandler.d.ts +5 -5
- package/dist/system/LambdaWrapper.d.ts +17 -17
- package/dist/system/ServerGlobalStore.d.ts +5 -5
- package/package.json +59 -59
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { ModelMetadata, AbstractModel, IInit, Constructor } from "@clairejs/core";
|
|
2
|
-
import { ITransaction } from "../transaction/ITransaction";
|
|
3
|
-
import { IQueryProvider } from "./IQueryProvider";
|
|
4
|
-
import { IQuery } from "./IQuery";
|
|
5
|
-
export declare type ConnectionHolder<T> = {
|
|
6
|
-
connection: T;
|
|
7
|
-
};
|
|
8
|
-
export declare abstract class AbstractDatabaseAdapter implements IInit, IQueryProvider {
|
|
9
|
-
protected modelMetadata: ModelMetadata[];
|
|
10
|
-
protected models: Constructor<AbstractModel>[];
|
|
11
|
-
protected modelConnections: {
|
|
12
|
-
[key: string]: ConnectionHolder<any>;
|
|
13
|
-
};
|
|
14
|
-
protected constructor();
|
|
15
|
-
init(): Promise<void>;
|
|
16
|
-
exit(): void;
|
|
17
|
-
abstract createTransaction(): Promise<ITransaction>;
|
|
18
|
-
abstract use<T extends AbstractModel>(model: Constructor<T>): IQuery<T>;
|
|
19
|
-
}
|
|
1
|
+
import { ModelMetadata, AbstractModel, IInit, Constructor } from "@clairejs/core";
|
|
2
|
+
import { ITransaction } from "../transaction/ITransaction";
|
|
3
|
+
import { IQueryProvider } from "./IQueryProvider";
|
|
4
|
+
import { IQuery } from "./IQuery";
|
|
5
|
+
export declare type ConnectionHolder<T> = {
|
|
6
|
+
connection: T;
|
|
7
|
+
};
|
|
8
|
+
export declare abstract class AbstractDatabaseAdapter implements IInit, IQueryProvider {
|
|
9
|
+
protected modelMetadata: ModelMetadata[];
|
|
10
|
+
protected models: Constructor<AbstractModel>[];
|
|
11
|
+
protected modelConnections: {
|
|
12
|
+
[key: string]: ConnectionHolder<any>;
|
|
13
|
+
};
|
|
14
|
+
protected constructor();
|
|
15
|
+
init(): Promise<void>;
|
|
16
|
+
exit(): void;
|
|
17
|
+
abstract createTransaction(): Promise<ITransaction>;
|
|
18
|
+
abstract use<T extends AbstractModel>(model: Constructor<T>): IQuery<T>;
|
|
19
|
+
}
|
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
import { AbstractModel, ModelMetadata, OrderDirection, Constructor, QueryCondition } from "@clairejs/core";
|
|
2
|
-
import { IGroupBy, IJoin, IQuery, ISelect, IWhere, JoinMode } from "./IQuery";
|
|
3
|
-
export declare abstract class AbstractQuery<T extends AbstractModel> implements IQuery<T> {
|
|
4
|
-
readonly metadata: ModelMetadata;
|
|
5
|
-
readonly model: Constructor<T>;
|
|
6
|
-
protected constructor(model: Constructor<AbstractModel>);
|
|
7
|
-
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>;
|
|
8
|
-
abstract getById<K extends keyof T>(id: number, options?: {
|
|
9
|
-
projection?: K[];
|
|
10
|
-
}): Promise<Pick<T, K> | undefined>;
|
|
11
|
-
abstract getByIds<K extends keyof T>(ids: number[], options?: {
|
|
12
|
-
projection?: K[];
|
|
13
|
-
}): Promise<Pick<T, K>[]>;
|
|
14
|
-
abstract getOne<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
15
|
-
projection?: K[];
|
|
16
|
-
}): Promise<Pick<T, K> | undefined>;
|
|
17
|
-
abstract getMany<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
18
|
-
order?: [keyof T, OrderDirection][];
|
|
19
|
-
projection?: K[];
|
|
20
|
-
limit?: number;
|
|
21
|
-
page?: number;
|
|
22
|
-
}, includes?: {
|
|
23
|
-
modelId: string;
|
|
24
|
-
queries: QueryCondition<any>;
|
|
25
|
-
}[]): Promise<{
|
|
26
|
-
total: number;
|
|
27
|
-
records: Pick<T, K>[];
|
|
28
|
-
}>;
|
|
29
|
-
abstract getRecords<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
30
|
-
order?: [keyof T, OrderDirection][];
|
|
31
|
-
projection?: K[];
|
|
32
|
-
limit?: number;
|
|
33
|
-
}, includes?: {
|
|
34
|
-
modelId: string;
|
|
35
|
-
queries: QueryCondition<any>;
|
|
36
|
-
}[]): Promise<Pick<T, K>[]>;
|
|
37
|
-
abstract createOne(modelInstance: Partial<T>): Promise<T>;
|
|
38
|
-
abstract count(queries?: QueryCondition<T>, options?: {
|
|
39
|
-
distinct?: keyof T;
|
|
40
|
-
}, includes?: {
|
|
41
|
-
modelId: string;
|
|
42
|
-
queries: QueryCondition<any>;
|
|
43
|
-
}[]): Promise<number>;
|
|
44
|
-
abstract createMany(modelInstances: Partial<T>[]): Promise<T[]>;
|
|
45
|
-
abstract updateOne(modelInstance: T): Promise<T>;
|
|
46
|
-
abstract updateMany(queries: QueryCondition<T>, update: Partial<T>, returning?: boolean): Promise<number[]>;
|
|
47
|
-
abstract deleteOne(modelInstance: T): Promise<T>;
|
|
48
|
-
abstract deleteMany(queries: QueryCondition<T>, returning?: boolean): Promise<T[]>;
|
|
49
|
-
abstract rawQuery(...args: any[]): Promise<any>;
|
|
50
|
-
protected convertToLogicObjects<K extends keyof T>(dataObjects: T[], projection?: K[]): Pick<T, K>[];
|
|
51
|
-
protected convertToDataObjects(modelInstances: Partial<T>[], forUpdate?: boolean): any[];
|
|
52
|
-
}
|
|
1
|
+
import { AbstractModel, ModelMetadata, OrderDirection, Constructor, QueryCondition } from "@clairejs/core";
|
|
2
|
+
import { IGroupBy, IJoin, IQuery, ISelect, IWhere, JoinMode } from "./IQuery";
|
|
3
|
+
export declare abstract class AbstractQuery<T extends AbstractModel> implements IQuery<T> {
|
|
4
|
+
readonly metadata: ModelMetadata;
|
|
5
|
+
readonly model: Constructor<T>;
|
|
6
|
+
protected constructor(model: Constructor<AbstractModel>);
|
|
7
|
+
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>;
|
|
8
|
+
abstract getById<K extends keyof T>(id: number, options?: {
|
|
9
|
+
projection?: K[];
|
|
10
|
+
}): Promise<Pick<T, K> | undefined>;
|
|
11
|
+
abstract getByIds<K extends keyof T>(ids: number[], options?: {
|
|
12
|
+
projection?: K[];
|
|
13
|
+
}): Promise<Pick<T, K>[]>;
|
|
14
|
+
abstract getOne<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
15
|
+
projection?: K[];
|
|
16
|
+
}): Promise<Pick<T, K> | undefined>;
|
|
17
|
+
abstract getMany<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
18
|
+
order?: [keyof T, OrderDirection][];
|
|
19
|
+
projection?: K[];
|
|
20
|
+
limit?: number;
|
|
21
|
+
page?: number;
|
|
22
|
+
}, includes?: {
|
|
23
|
+
modelId: string;
|
|
24
|
+
queries: QueryCondition<any>;
|
|
25
|
+
}[]): Promise<{
|
|
26
|
+
total: number;
|
|
27
|
+
records: Pick<T, K>[];
|
|
28
|
+
}>;
|
|
29
|
+
abstract getRecords<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
30
|
+
order?: [keyof T, OrderDirection][];
|
|
31
|
+
projection?: K[];
|
|
32
|
+
limit?: number;
|
|
33
|
+
}, includes?: {
|
|
34
|
+
modelId: string;
|
|
35
|
+
queries: QueryCondition<any>;
|
|
36
|
+
}[]): Promise<Pick<T, K>[]>;
|
|
37
|
+
abstract createOne(modelInstance: Partial<T>): Promise<T>;
|
|
38
|
+
abstract count(queries?: QueryCondition<T>, options?: {
|
|
39
|
+
distinct?: keyof T;
|
|
40
|
+
}, includes?: {
|
|
41
|
+
modelId: string;
|
|
42
|
+
queries: QueryCondition<any>;
|
|
43
|
+
}[]): Promise<number>;
|
|
44
|
+
abstract createMany(modelInstances: Partial<T>[]): Promise<T[]>;
|
|
45
|
+
abstract updateOne(modelInstance: T): Promise<T>;
|
|
46
|
+
abstract updateMany(queries: QueryCondition<T>, update: Partial<T>, returning?: boolean): Promise<number[]>;
|
|
47
|
+
abstract deleteOne(modelInstance: T): Promise<T>;
|
|
48
|
+
abstract deleteMany(queries: QueryCondition<T>, returning?: boolean): Promise<T[]>;
|
|
49
|
+
abstract rawQuery(...args: any[]): Promise<any>;
|
|
50
|
+
protected convertToLogicObjects<K extends keyof T>(dataObjects: T[], projection?: K[]): Pick<T, K>[];
|
|
51
|
+
protected convertToDataObjects(modelInstances: Partial<T>[], forUpdate?: boolean): any[];
|
|
52
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
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 injector;
|
|
9
|
-
private readonly sqlProvider;
|
|
10
|
-
private readonly dbConnection;
|
|
11
|
-
private readonly modelAdapters;
|
|
12
|
-
constructor(sqlProvider: SqlProvider, connectionString: string, logger: AbstractLogger);
|
|
13
|
-
createTransaction(): Promise<ITransaction>;
|
|
14
|
-
init(): Promise<void>;
|
|
15
|
-
exit(): number;
|
|
16
|
-
use<T extends AbstractModel>(model: Constructor<T>): IQuery<T>;
|
|
17
|
-
private generateSchemaObject;
|
|
18
|
-
}
|
|
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 injector;
|
|
9
|
+
private readonly sqlProvider;
|
|
10
|
+
private readonly dbConnection;
|
|
11
|
+
private readonly modelAdapters;
|
|
12
|
+
constructor(sqlProvider: SqlProvider, connectionString: string, logger: AbstractLogger);
|
|
13
|
+
createTransaction(): Promise<ITransaction>;
|
|
14
|
+
init(): Promise<void>;
|
|
15
|
+
exit(): number;
|
|
16
|
+
use<T extends AbstractModel>(model: Constructor<T>): IQuery<T>;
|
|
17
|
+
private generateSchemaObject;
|
|
18
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AbstractDatabaseAdapter } from "./AbstractDatabaseAdapter";
|
|
2
|
-
export interface IDatabaseProvider {
|
|
3
|
-
getCurrentDatabaseAdapter(): Promise<AbstractDatabaseAdapter>;
|
|
4
|
-
}
|
|
1
|
+
import { AbstractDatabaseAdapter } from "./AbstractDatabaseAdapter";
|
|
2
|
+
export interface IDatabaseProvider {
|
|
3
|
+
getCurrentDatabaseAdapter(): Promise<AbstractDatabaseAdapter>;
|
|
4
|
+
}
|
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
import { AbstractModel, Constructor, OrderDirection, QueryCondition } from "@clairejs/core";
|
|
2
|
-
import { Aggregator, HavingCondition } from "./aggregators";
|
|
3
|
-
/**
|
|
4
|
-
* Query condition based on a interface/class.
|
|
5
|
-
*/
|
|
6
|
-
export declare type JoinMode = "inner" | "left";
|
|
7
|
-
export interface ISelect<T> {
|
|
8
|
-
count(): Promise<number>;
|
|
9
|
-
rows<K>(mapping: {
|
|
10
|
-
[field in keyof K]: Aggregator<T>;
|
|
11
|
-
}, options?: {
|
|
12
|
-
order?: [keyof K, OrderDirection][];
|
|
13
|
-
limit?: number;
|
|
14
|
-
page?: number;
|
|
15
|
-
}): Promise<{
|
|
16
|
-
total: number;
|
|
17
|
-
records: K[];
|
|
18
|
-
}>;
|
|
19
|
-
}
|
|
20
|
-
export interface IHaving<T> {
|
|
21
|
-
having(conditions: HavingCondition<T>): ISelect<T>;
|
|
22
|
-
}
|
|
23
|
-
export interface IGroupBy<T> {
|
|
24
|
-
groupBy(fields: (keyof T)[]): IHaving<T> & ISelect<T>;
|
|
25
|
-
}
|
|
26
|
-
export interface IWhere<T> {
|
|
27
|
-
where(queries?: QueryCondition<T>): IGroupBy<T> & ISelect<T>;
|
|
28
|
-
}
|
|
29
|
-
export interface IJoin<T extends AbstractModel> {
|
|
30
|
-
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>;
|
|
31
|
-
}
|
|
32
|
-
export interface IQuery<T extends AbstractModel> extends IJoin<T> {
|
|
33
|
-
createOne(modelInstance: Partial<T>): Promise<T>;
|
|
34
|
-
getById<K extends keyof T>(id: number, options?: {
|
|
35
|
-
projection?: K[];
|
|
36
|
-
}): Promise<Pick<T, K> | undefined>;
|
|
37
|
-
getByIds<K extends keyof T>(ids: number[], options?: {
|
|
38
|
-
projection?: K[];
|
|
39
|
-
}): Promise<Pick<T, K>[]>;
|
|
40
|
-
getOne<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
41
|
-
projection?: K[];
|
|
42
|
-
}): Promise<Pick<T, K> | undefined>;
|
|
43
|
-
count(queries?: QueryCondition<T>, options?: {
|
|
44
|
-
distinct?: keyof T;
|
|
45
|
-
}, includes?: {
|
|
46
|
-
modelId: string;
|
|
47
|
-
queries: QueryCondition<any>;
|
|
48
|
-
}[]): Promise<number>;
|
|
49
|
-
getMany<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
50
|
-
order?: [keyof T, OrderDirection][];
|
|
51
|
-
projection?: K[];
|
|
52
|
-
limit?: number;
|
|
53
|
-
page?: number;
|
|
54
|
-
}, includes?: {
|
|
55
|
-
modelId: string;
|
|
56
|
-
queries: QueryCondition<any>;
|
|
57
|
-
}[]): Promise<{
|
|
58
|
-
total: number;
|
|
59
|
-
records: Pick<T, K>[];
|
|
60
|
-
}>;
|
|
61
|
-
getRecords<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
62
|
-
order?: [keyof T, OrderDirection][];
|
|
63
|
-
projection?: K[];
|
|
64
|
-
limit?: number;
|
|
65
|
-
}, includes?: {
|
|
66
|
-
modelId: string;
|
|
67
|
-
queries: QueryCondition<any>;
|
|
68
|
-
}[]): Promise<Pick<T, K>[]>;
|
|
69
|
-
createMany(modelInstances: Partial<T>[]): Promise<T[]>;
|
|
70
|
-
updateOne(modelInstance: T): Promise<T>;
|
|
71
|
-
updateMany(queries: QueryCondition<T> | undefined, update: Partial<T>, returning?: boolean): Promise<number[]>;
|
|
72
|
-
deleteOne(modelInstance: T): Promise<T>;
|
|
73
|
-
deleteMany(queries?: QueryCondition<T>, returning?: boolean): Promise<T[]>;
|
|
74
|
-
rawQuery(...args: any[]): Promise<any>;
|
|
75
|
-
}
|
|
1
|
+
import { AbstractModel, Constructor, OrderDirection, QueryCondition } from "@clairejs/core";
|
|
2
|
+
import { Aggregator, HavingCondition } from "./aggregators";
|
|
3
|
+
/**
|
|
4
|
+
* Query condition based on a interface/class.
|
|
5
|
+
*/
|
|
6
|
+
export declare type JoinMode = "inner" | "left";
|
|
7
|
+
export interface ISelect<T> {
|
|
8
|
+
count(): Promise<number>;
|
|
9
|
+
rows<K>(mapping: {
|
|
10
|
+
[field in keyof K]: Aggregator<T>;
|
|
11
|
+
}, options?: {
|
|
12
|
+
order?: [keyof K, OrderDirection][];
|
|
13
|
+
limit?: number;
|
|
14
|
+
page?: number;
|
|
15
|
+
}): Promise<{
|
|
16
|
+
total: number;
|
|
17
|
+
records: K[];
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
export interface IHaving<T> {
|
|
21
|
+
having(conditions: HavingCondition<T>): ISelect<T>;
|
|
22
|
+
}
|
|
23
|
+
export interface IGroupBy<T> {
|
|
24
|
+
groupBy(fields: (keyof T)[]): IHaving<T> & ISelect<T>;
|
|
25
|
+
}
|
|
26
|
+
export interface IWhere<T> {
|
|
27
|
+
where(queries?: QueryCondition<T>): IGroupBy<T> & ISelect<T>;
|
|
28
|
+
}
|
|
29
|
+
export interface IJoin<T extends AbstractModel> {
|
|
30
|
+
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>;
|
|
31
|
+
}
|
|
32
|
+
export interface IQuery<T extends AbstractModel> extends IJoin<T> {
|
|
33
|
+
createOne(modelInstance: Partial<T>): Promise<T>;
|
|
34
|
+
getById<K extends keyof T>(id: number, options?: {
|
|
35
|
+
projection?: K[];
|
|
36
|
+
}): Promise<Pick<T, K> | undefined>;
|
|
37
|
+
getByIds<K extends keyof T>(ids: number[], options?: {
|
|
38
|
+
projection?: K[];
|
|
39
|
+
}): Promise<Pick<T, K>[]>;
|
|
40
|
+
getOne<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
41
|
+
projection?: K[];
|
|
42
|
+
}): Promise<Pick<T, K> | undefined>;
|
|
43
|
+
count(queries?: QueryCondition<T>, options?: {
|
|
44
|
+
distinct?: keyof T;
|
|
45
|
+
}, includes?: {
|
|
46
|
+
modelId: string;
|
|
47
|
+
queries: QueryCondition<any>;
|
|
48
|
+
}[]): Promise<number>;
|
|
49
|
+
getMany<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
50
|
+
order?: [keyof T, OrderDirection][];
|
|
51
|
+
projection?: K[];
|
|
52
|
+
limit?: number;
|
|
53
|
+
page?: number;
|
|
54
|
+
}, includes?: {
|
|
55
|
+
modelId: string;
|
|
56
|
+
queries: QueryCondition<any>;
|
|
57
|
+
}[]): Promise<{
|
|
58
|
+
total: number;
|
|
59
|
+
records: Pick<T, K>[];
|
|
60
|
+
}>;
|
|
61
|
+
getRecords<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
62
|
+
order?: [keyof T, OrderDirection][];
|
|
63
|
+
projection?: K[];
|
|
64
|
+
limit?: number;
|
|
65
|
+
}, includes?: {
|
|
66
|
+
modelId: string;
|
|
67
|
+
queries: QueryCondition<any>;
|
|
68
|
+
}[]): Promise<Pick<T, K>[]>;
|
|
69
|
+
createMany(modelInstances: Partial<T>[]): Promise<T[]>;
|
|
70
|
+
updateOne(modelInstance: T): Promise<T>;
|
|
71
|
+
updateMany(queries: QueryCondition<T> | undefined, update: Partial<T>, returning?: boolean): Promise<number[]>;
|
|
72
|
+
deleteOne(modelInstance: T): Promise<T>;
|
|
73
|
+
deleteMany(queries?: QueryCondition<T>, returning?: boolean): Promise<T[]>;
|
|
74
|
+
rawQuery(...args: any[]): Promise<any>;
|
|
75
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
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
|
+
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 +1,21 @@
|
|
|
1
|
-
import { Op, MultiOperandOps } from "@clairejs/core";
|
|
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
|
+
import { Op, MultiOperandOps } from "@clairejs/core";
|
|
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,8 +1,8 @@
|
|
|
1
|
-
export declare enum NoSqlProvider {
|
|
2
|
-
MONGODB = "mongodb",
|
|
3
|
-
DYNAMODB = "dynamodb"
|
|
4
|
-
}
|
|
5
|
-
export declare enum SqlProvider {
|
|
6
|
-
MYSQL = "mysql",
|
|
7
|
-
POSTGRES = "postgres"
|
|
8
|
-
}
|
|
1
|
+
export declare enum NoSqlProvider {
|
|
2
|
+
MONGODB = "mongodb",
|
|
3
|
+
DYNAMODB = "dynamodb"
|
|
4
|
+
}
|
|
5
|
+
export declare enum SqlProvider {
|
|
6
|
+
MYSQL = "mysql",
|
|
7
|
+
POSTGRES = "postgres"
|
|
8
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TransactionLink } from "./transaction/TransactionLink";
|
|
2
|
-
export declare const Transactional: (link: TransactionLink) => (prototype: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
1
|
+
import { TransactionLink } from "./transaction/TransactionLink";
|
|
2
|
+
export declare const Transactional: (link: TransactionLink) => (prototype: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare abstract class AbstractDatabaseMigrator {
|
|
2
|
-
abstract migrate(migrationDirectory: string): Promise<void>;
|
|
3
|
-
abstract rollback(migrationDirectory: string): Promise<void>;
|
|
4
|
-
}
|
|
1
|
+
export declare abstract class AbstractDatabaseMigrator {
|
|
2
|
+
abstract migrate(migrationDirectory: string): Promise<void>;
|
|
3
|
+
abstract rollback(migrationDirectory: string): Promise<void>;
|
|
4
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { AbstractLogger, IInit } from "@clairejs/core";
|
|
2
|
-
import { SqlProvider } from "../adapter/providers";
|
|
3
|
-
import { AbstractDatabaseMigrator } from "./AbstractDatabaseMigrator";
|
|
4
|
-
export declare class DefaultSqlDatabaseMigrator extends AbstractDatabaseMigrator implements IInit {
|
|
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 injector;
|
|
12
|
-
private readonly databaseURL;
|
|
13
|
-
private readonly modelMetadata;
|
|
14
|
-
constructor(cliPath: string, sqlProvider: SqlProvider, connectionString: string, logger: AbstractLogger);
|
|
15
|
-
init(): Promise<void>;
|
|
16
|
-
exit(): void;
|
|
17
|
-
private getUniqueConstraintGroups;
|
|
18
|
-
private generateFieldPropertiesQuery;
|
|
19
|
-
private getUniqueConstraintUpDown;
|
|
20
|
-
private getSqlCascadeAction;
|
|
21
|
-
private getForeignKeyConstraintUpDown;
|
|
22
|
-
private getAddColumnUpDown;
|
|
23
|
-
private generateCreateTableQuery;
|
|
24
|
-
private isBooleanDiff;
|
|
25
|
-
private runProcess;
|
|
26
|
-
rollback(migrationDirectory: string): Promise<void>;
|
|
27
|
-
migrate(migrationDirectory: string): Promise<void>;
|
|
28
|
-
}
|
|
1
|
+
import { AbstractLogger, IInit } from "@clairejs/core";
|
|
2
|
+
import { SqlProvider } from "../adapter/providers";
|
|
3
|
+
import { AbstractDatabaseMigrator } from "./AbstractDatabaseMigrator";
|
|
4
|
+
export declare class DefaultSqlDatabaseMigrator extends AbstractDatabaseMigrator implements IInit {
|
|
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 injector;
|
|
12
|
+
private readonly databaseURL;
|
|
13
|
+
private readonly modelMetadata;
|
|
14
|
+
constructor(cliPath: string, sqlProvider: SqlProvider, connectionString: string, logger: AbstractLogger);
|
|
15
|
+
init(): Promise<void>;
|
|
16
|
+
exit(): void;
|
|
17
|
+
private getUniqueConstraintGroups;
|
|
18
|
+
private generateFieldPropertiesQuery;
|
|
19
|
+
private getUniqueConstraintUpDown;
|
|
20
|
+
private getSqlCascadeAction;
|
|
21
|
+
private getForeignKeyConstraintUpDown;
|
|
22
|
+
private getAddColumnUpDown;
|
|
23
|
+
private generateCreateTableQuery;
|
|
24
|
+
private isBooleanDiff;
|
|
25
|
+
private runProcess;
|
|
26
|
+
rollback(migrationDirectory: string): Promise<void>;
|
|
27
|
+
migrate(migrationDirectory: string): Promise<void>;
|
|
28
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
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
|
+
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,4 +1,4 @@
|
|
|
1
|
-
import { ITransaction } from "./ITransaction";
|
|
2
|
-
export interface ITransactionProvider {
|
|
3
|
-
getCurrentTransaction(): Promise<ITransaction>;
|
|
4
|
-
}
|
|
1
|
+
import { ITransaction } from "./ITransaction";
|
|
2
|
+
export interface ITransactionProvider {
|
|
3
|
+
getCurrentTransaction(): Promise<ITransaction>;
|
|
4
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
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
|
+
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,4 +1,4 @@
|
|
|
1
|
-
import { ObjectMetadata } from "@clairejs/core";
|
|
2
|
-
export interface TransactionObjectMetadata extends ObjectMetadata {
|
|
3
|
-
transactional?: boolean;
|
|
4
|
-
}
|
|
1
|
+
import { ObjectMetadata } from "@clairejs/core";
|
|
2
|
+
export interface TransactionObjectMetadata extends ObjectMetadata {
|
|
3
|
+
transactional?: boolean;
|
|
4
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare enum TransactionState {
|
|
2
|
-
EXECUTING = "executing",
|
|
3
|
-
COMMITTED = "commited",
|
|
4
|
-
ROLLED_BACK = "rolled_back"
|
|
5
|
-
}
|
|
1
|
+
export declare enum TransactionState {
|
|
2
|
+
EXECUTING = "executing",
|
|
3
|
+
COMMITTED = "commited",
|
|
4
|
+
ROLLED_BACK = "rolled_back"
|
|
5
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|