@clairejs/server 3.0.2 → 3.0.3
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 +448 -443
- package/dist/common/constants.d.ts +1 -1
- package/dist/database/adapter/AbstractDatabaseAdapter.d.ts +19 -19
- package/dist/database/adapter/AbstractQuery.d.ts +43 -43
- package/dist/database/adapter/DefaultSqlDatabaseAdapter.d.ts +18 -18
- package/dist/database/adapter/IQuery.d.ts +40 -40
- package/dist/database/adapter/IQueryProvider.d.ts +9 -9
- 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 +26 -26
- 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 +8 -8
- 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 +58 -63
- package/dist/http/controller/CrudService.d.ts +36 -36
- package/dist/http/controller/DefaultHttpRequestHandler.d.ts +19 -19
- package/dist/http/controller/EndpointMetadata.d.ts +36 -35
- package/dist/http/controller/HttpEndpoint.d.ts +12 -12
- package/dist/http/controller/MountedEndpointInfo.d.ts +6 -6
- package/dist/http/decorators.d.ts +26 -22
- package/dist/http/security/AbstractAccessCondition.d.ts +8 -8
- package/dist/http/security/AbstractHttpAuthorizationProvider.d.ts +7 -7
- package/dist/http/security/FilterModelFieldAccessCondition.d.ts +4 -4
- package/dist/http/security/IPrincipal.d.ts +3 -3
- package/dist/http/security/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 +5 -5
- 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 +7 -7
- package/package.json +58 -58
|
@@ -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,43 +1,43 @@
|
|
|
1
|
-
import { AbstractModel, ModelMetadata, OrderDirection, Constructor, QueryCondition } from "@clairejs/core";
|
|
2
|
-
import { IQuery } from "./IQuery";
|
|
3
|
-
export declare abstract class AbstractQuery<T extends AbstractModel> implements IQuery<T> {
|
|
4
|
-
protected readonly metadata: ModelMetadata;
|
|
5
|
-
protected readonly model: Constructor<T>;
|
|
6
|
-
protected constructor(model: Constructor<AbstractModel>);
|
|
7
|
-
abstract getOne(queries?: QueryCondition<T>): Promise<T | undefined>;
|
|
8
|
-
abstract getMany<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
9
|
-
order?: [keyof T, OrderDirection][];
|
|
10
|
-
projection?: K[];
|
|
11
|
-
limit?: number;
|
|
12
|
-
page?: number;
|
|
13
|
-
}, includes?: {
|
|
14
|
-
modelId: string;
|
|
15
|
-
queries: QueryCondition<any>;
|
|
16
|
-
}[]): Promise<{
|
|
17
|
-
total: number;
|
|
18
|
-
records: Pick<T, K>[];
|
|
19
|
-
}>;
|
|
20
|
-
abstract getRecords<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
21
|
-
order?: [keyof T, OrderDirection][];
|
|
22
|
-
projection?: K[];
|
|
23
|
-
limit?: number;
|
|
24
|
-
}, includes?: {
|
|
25
|
-
modelId: string;
|
|
26
|
-
queries: QueryCondition<any>;
|
|
27
|
-
}[]): Promise<Pick<T, K>[]>;
|
|
28
|
-
abstract createOne(modelInstance: Partial<T>): Promise<T>;
|
|
29
|
-
abstract count(queries?: QueryCondition<T>, options?: {
|
|
30
|
-
distinct?: keyof T;
|
|
31
|
-
}, includes?: {
|
|
32
|
-
modelId: string;
|
|
33
|
-
queries: QueryCondition<any>;
|
|
34
|
-
}[]): Promise<number>;
|
|
35
|
-
abstract createMany(modelInstances: Partial<T>[]): Promise<T[]>;
|
|
36
|
-
abstract updateOne(modelInstance: T): Promise<T>;
|
|
37
|
-
abstract updateMany(queries: QueryCondition<T>, update: Partial<T>, returning?: boolean): Promise<number[]>;
|
|
38
|
-
abstract deleteOne(modelInstance: T): Promise<T>;
|
|
39
|
-
abstract deleteMany(queries: QueryCondition<T>, returning?: boolean): Promise<number[]>;
|
|
40
|
-
abstract rawQuery(...args: any[]): Promise<any>;
|
|
41
|
-
protected convertToLogicObjects<K extends keyof T>(dataObjects: T[], projection?: K[]): Pick<T, K>[];
|
|
42
|
-
protected convertToDataObjects(modelInstances: Partial<T>[]): any[];
|
|
43
|
-
}
|
|
1
|
+
import { AbstractModel, ModelMetadata, OrderDirection, Constructor, QueryCondition } from "@clairejs/core";
|
|
2
|
+
import { IQuery } from "./IQuery";
|
|
3
|
+
export declare abstract class AbstractQuery<T extends AbstractModel> implements IQuery<T> {
|
|
4
|
+
protected readonly metadata: ModelMetadata;
|
|
5
|
+
protected readonly model: Constructor<T>;
|
|
6
|
+
protected constructor(model: Constructor<AbstractModel>);
|
|
7
|
+
abstract getOne(queries?: QueryCondition<T>): Promise<T | undefined>;
|
|
8
|
+
abstract getMany<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
9
|
+
order?: [keyof T, OrderDirection][];
|
|
10
|
+
projection?: K[];
|
|
11
|
+
limit?: number;
|
|
12
|
+
page?: number;
|
|
13
|
+
}, includes?: {
|
|
14
|
+
modelId: string;
|
|
15
|
+
queries: QueryCondition<any>;
|
|
16
|
+
}[]): Promise<{
|
|
17
|
+
total: number;
|
|
18
|
+
records: Pick<T, K>[];
|
|
19
|
+
}>;
|
|
20
|
+
abstract getRecords<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
21
|
+
order?: [keyof T, OrderDirection][];
|
|
22
|
+
projection?: K[];
|
|
23
|
+
limit?: number;
|
|
24
|
+
}, includes?: {
|
|
25
|
+
modelId: string;
|
|
26
|
+
queries: QueryCondition<any>;
|
|
27
|
+
}[]): Promise<Pick<T, K>[]>;
|
|
28
|
+
abstract createOne(modelInstance: Partial<T>): Promise<T>;
|
|
29
|
+
abstract count(queries?: QueryCondition<T>, options?: {
|
|
30
|
+
distinct?: keyof T;
|
|
31
|
+
}, includes?: {
|
|
32
|
+
modelId: string;
|
|
33
|
+
queries: QueryCondition<any>;
|
|
34
|
+
}[]): Promise<number>;
|
|
35
|
+
abstract createMany(modelInstances: Partial<T>[]): Promise<T[]>;
|
|
36
|
+
abstract updateOne(modelInstance: T): Promise<T>;
|
|
37
|
+
abstract updateMany(queries: QueryCondition<T>, update: Partial<T>, returning?: boolean): Promise<number[]>;
|
|
38
|
+
abstract deleteOne(modelInstance: T): Promise<T>;
|
|
39
|
+
abstract deleteMany(queries: QueryCondition<T>, returning?: boolean): Promise<number[]>;
|
|
40
|
+
abstract rawQuery(...args: any[]): Promise<any>;
|
|
41
|
+
protected convertToLogicObjects<K extends keyof T>(dataObjects: T[], projection?: K[]): Pick<T, K>[];
|
|
42
|
+
protected convertToDataObjects(modelInstances: Partial<T>[]): any[];
|
|
43
|
+
}
|
|
@@ -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,40 +1,40 @@
|
|
|
1
|
-
import { OrderDirection, QueryCondition } from "@clairejs/core";
|
|
2
|
-
/**
|
|
3
|
-
* Query condition based on a interface/class.
|
|
4
|
-
*/
|
|
5
|
-
export interface IQuery<T> {
|
|
6
|
-
getOne(queries?: QueryCondition<T>): Promise<T | undefined>;
|
|
7
|
-
count(queries?: QueryCondition<T>, options?: {
|
|
8
|
-
distinct?: keyof T;
|
|
9
|
-
}, includes?: {
|
|
10
|
-
modelId: string;
|
|
11
|
-
queries: QueryCondition<any>;
|
|
12
|
-
}[]): Promise<number>;
|
|
13
|
-
getMany<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
14
|
-
order?: [keyof T, OrderDirection][];
|
|
15
|
-
projection?: K[];
|
|
16
|
-
limit?: number;
|
|
17
|
-
page?: number;
|
|
18
|
-
}, includes?: {
|
|
19
|
-
modelId: string;
|
|
20
|
-
queries: QueryCondition<any>;
|
|
21
|
-
}[]): Promise<{
|
|
22
|
-
total: number;
|
|
23
|
-
records: Pick<T, K>[];
|
|
24
|
-
}>;
|
|
25
|
-
getRecords<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
26
|
-
order?: [keyof T, OrderDirection][];
|
|
27
|
-
projection?: K[];
|
|
28
|
-
limit?: number;
|
|
29
|
-
}, includes?: {
|
|
30
|
-
modelId: string;
|
|
31
|
-
queries: QueryCondition<any>;
|
|
32
|
-
}[]): Promise<Pick<T, K>[]>;
|
|
33
|
-
createOne(modelInstance: Partial<T>): Promise<T>;
|
|
34
|
-
createMany(modelInstances: Partial<T>[]): Promise<T[]>;
|
|
35
|
-
updateOne(modelInstance: T): Promise<T>;
|
|
36
|
-
updateMany(queries: QueryCondition<T> | undefined, update: Partial<T>, returning?: boolean): Promise<number[]>;
|
|
37
|
-
deleteOne(modelInstance: T): Promise<T>;
|
|
38
|
-
deleteMany(queries?: QueryCondition<T>, returning?: boolean): Promise<number[]>;
|
|
39
|
-
rawQuery(...args: any[]): Promise<any>;
|
|
40
|
-
}
|
|
1
|
+
import { OrderDirection, QueryCondition } from "@clairejs/core";
|
|
2
|
+
/**
|
|
3
|
+
* Query condition based on a interface/class.
|
|
4
|
+
*/
|
|
5
|
+
export interface IQuery<T> {
|
|
6
|
+
getOne(queries?: QueryCondition<T>): Promise<T | undefined>;
|
|
7
|
+
count(queries?: QueryCondition<T>, options?: {
|
|
8
|
+
distinct?: keyof T;
|
|
9
|
+
}, includes?: {
|
|
10
|
+
modelId: string;
|
|
11
|
+
queries: QueryCondition<any>;
|
|
12
|
+
}[]): Promise<number>;
|
|
13
|
+
getMany<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
14
|
+
order?: [keyof T, OrderDirection][];
|
|
15
|
+
projection?: K[];
|
|
16
|
+
limit?: number;
|
|
17
|
+
page?: number;
|
|
18
|
+
}, includes?: {
|
|
19
|
+
modelId: string;
|
|
20
|
+
queries: QueryCondition<any>;
|
|
21
|
+
}[]): Promise<{
|
|
22
|
+
total: number;
|
|
23
|
+
records: Pick<T, K>[];
|
|
24
|
+
}>;
|
|
25
|
+
getRecords<K extends keyof T>(queries?: QueryCondition<T>, options?: {
|
|
26
|
+
order?: [keyof T, OrderDirection][];
|
|
27
|
+
projection?: K[];
|
|
28
|
+
limit?: number;
|
|
29
|
+
}, includes?: {
|
|
30
|
+
modelId: string;
|
|
31
|
+
queries: QueryCondition<any>;
|
|
32
|
+
}[]): Promise<Pick<T, K>[]>;
|
|
33
|
+
createOne(modelInstance: Partial<T>): Promise<T>;
|
|
34
|
+
createMany(modelInstances: Partial<T>[]): Promise<T[]>;
|
|
35
|
+
updateOne(modelInstance: T): Promise<T>;
|
|
36
|
+
updateMany(queries: QueryCondition<T> | undefined, update: Partial<T>, returning?: boolean): Promise<number[]>;
|
|
37
|
+
deleteOne(modelInstance: T): Promise<T>;
|
|
38
|
+
deleteMany(queries?: QueryCondition<T>, returning?: boolean): Promise<number[]>;
|
|
39
|
+
rawQuery(...args: any[]): Promise<any>;
|
|
40
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { AbstractModel } 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: new () => T): IQuery<T>;
|
|
9
|
-
}
|
|
1
|
+
import { AbstractModel } 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: new () => T): IQuery<T>;
|
|
9
|
+
}
|
|
@@ -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,26 +1,26 @@
|
|
|
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 logger: AbstractLogger;
|
|
6
|
-
private static readonly COMMENT_BLOCK_REGEX_PATTERN;
|
|
7
|
-
private static readonly MIGRATION_TEMPLATE;
|
|
8
|
-
private readonly injector;
|
|
9
|
-
private readonly databaseURL;
|
|
10
|
-
private readonly cliPath;
|
|
11
|
-
private readonly modelMetadata;
|
|
12
|
-
constructor(cliPath: string, sqlProvider: SqlProvider, connectionString: string, logger: AbstractLogger);
|
|
13
|
-
init(): Promise<void>;
|
|
14
|
-
exit(): void;
|
|
15
|
-
private getUniqueConstraintGroups;
|
|
16
|
-
private generateFieldPropertiesQuery;
|
|
17
|
-
private getUniqueConstraintUpDown;
|
|
18
|
-
private getSqlCascadeAction;
|
|
19
|
-
private getForeignKeyConstraintUpDown;
|
|
20
|
-
private getAddColumnUpDown;
|
|
21
|
-
private generateCreateTableQuery;
|
|
22
|
-
private isBooleanDiff;
|
|
23
|
-
private runProcess;
|
|
24
|
-
rollback(migrationDirectory: string): Promise<void>;
|
|
25
|
-
migrate(migrationDirectory: string): Promise<void>;
|
|
26
|
-
}
|
|
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 logger: AbstractLogger;
|
|
6
|
+
private static readonly COMMENT_BLOCK_REGEX_PATTERN;
|
|
7
|
+
private static readonly MIGRATION_TEMPLATE;
|
|
8
|
+
private readonly injector;
|
|
9
|
+
private readonly databaseURL;
|
|
10
|
+
private readonly cliPath;
|
|
11
|
+
private readonly modelMetadata;
|
|
12
|
+
constructor(cliPath: string, sqlProvider: SqlProvider, connectionString: string, logger: AbstractLogger);
|
|
13
|
+
init(): Promise<void>;
|
|
14
|
+
exit(): void;
|
|
15
|
+
private getUniqueConstraintGroups;
|
|
16
|
+
private generateFieldPropertiesQuery;
|
|
17
|
+
private getUniqueConstraintUpDown;
|
|
18
|
+
private getSqlCascadeAction;
|
|
19
|
+
private getForeignKeyConstraintUpDown;
|
|
20
|
+
private getAddColumnUpDown;
|
|
21
|
+
private generateCreateTableQuery;
|
|
22
|
+
private isBooleanDiff;
|
|
23
|
+
private runProcess;
|
|
24
|
+
rollback(migrationDirectory: string): Promise<void>;
|
|
25
|
+
migrate(migrationDirectory: string): Promise<void>;
|
|
26
|
+
}
|
|
@@ -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 {};
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { HttpMethod, SocketMethod } from "@clairejs/core";
|
|
2
|
-
import { EndpointMetadata } from "../controller/EndpointMetadata";
|
|
3
|
-
import { IServerSocket } from "../../socket/IServerSocket";
|
|
4
|
-
import { IPrincipal } from "../security/IPrincipal";
|
|
5
|
-
export declare class HttpRequest {
|
|
6
|
-
private valueHolder;
|
|
7
|
-
private method;
|
|
8
|
-
private pathName;
|
|
9
|
-
private headers;
|
|
10
|
-
private params;
|
|
11
|
-
private query;
|
|
12
|
-
private body;
|
|
13
|
-
private hash;
|
|
14
|
-
private socket?;
|
|
15
|
-
private authInfo?;
|
|
16
|
-
constructor(options: {
|
|
17
|
-
method: HttpMethod | SocketMethod;
|
|
18
|
-
pathName: string;
|
|
19
|
-
headers?: any;
|
|
20
|
-
hash?: string;
|
|
21
|
-
query?: any;
|
|
22
|
-
params?: any;
|
|
23
|
-
body?: any;
|
|
24
|
-
socket?: IServerSocket;
|
|
25
|
-
}, endpointMetadata?: EndpointMetadata);
|
|
26
|
-
private jsonParsing;
|
|
27
|
-
getAuthInfo(): IPrincipal | undefined;
|
|
28
|
-
setAuthInfo(authInfo?: IPrincipal): void;
|
|
29
|
-
getHeaders(): any;
|
|
30
|
-
getMethod(): HttpMethod | SocketMethod;
|
|
31
|
-
getHash(): string;
|
|
32
|
-
getPathName(): string;
|
|
33
|
-
getValue<T extends any>(key: string): T;
|
|
34
|
-
setValue<T extends any>(key: string, value: T): void;
|
|
35
|
-
getParams<T extends any>(): T;
|
|
36
|
-
getQuery<T extends any>(): T;
|
|
37
|
-
getBody<T extends any>(): T;
|
|
38
|
-
getSocket(): IServerSocket;
|
|
39
|
-
}
|
|
1
|
+
import { HttpMethod, SocketMethod } from "@clairejs/core";
|
|
2
|
+
import { EndpointMetadata } from "../controller/EndpointMetadata";
|
|
3
|
+
import { IServerSocket } from "../../socket/IServerSocket";
|
|
4
|
+
import { IPrincipal } from "../security/IPrincipal";
|
|
5
|
+
export declare class HttpRequest {
|
|
6
|
+
private valueHolder;
|
|
7
|
+
private method;
|
|
8
|
+
private pathName;
|
|
9
|
+
private headers;
|
|
10
|
+
private params;
|
|
11
|
+
private query;
|
|
12
|
+
private body;
|
|
13
|
+
private hash;
|
|
14
|
+
private socket?;
|
|
15
|
+
private authInfo?;
|
|
16
|
+
constructor(options: {
|
|
17
|
+
method: HttpMethod | SocketMethod;
|
|
18
|
+
pathName: string;
|
|
19
|
+
headers?: any;
|
|
20
|
+
hash?: string;
|
|
21
|
+
query?: any;
|
|
22
|
+
params?: any;
|
|
23
|
+
body?: any;
|
|
24
|
+
socket?: IServerSocket;
|
|
25
|
+
}, endpointMetadata?: EndpointMetadata);
|
|
26
|
+
private jsonParsing;
|
|
27
|
+
getAuthInfo(): IPrincipal | undefined;
|
|
28
|
+
setAuthInfo(authInfo?: IPrincipal): void;
|
|
29
|
+
getHeaders(): any;
|
|
30
|
+
getMethod(): HttpMethod | SocketMethod;
|
|
31
|
+
getHash(): string;
|
|
32
|
+
getPathName(): string;
|
|
33
|
+
getValue<T extends any>(key: string): T;
|
|
34
|
+
setValue<T extends any>(key: string, value: T): void;
|
|
35
|
+
getParams<T extends any>(): T;
|
|
36
|
+
getQuery<T extends any>(): T;
|
|
37
|
+
getBody<T extends any>(): T;
|
|
38
|
+
getSocket(): IServerSocket;
|
|
39
|
+
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
declare type Dict = {
|
|
3
|
-
[key: string]: string;
|
|
4
|
-
};
|
|
5
|
-
export declare class HttpResponse<T> {
|
|
6
|
-
value?: T;
|
|
7
|
-
code: number;
|
|
8
|
-
headers: Dict;
|
|
9
|
-
cookies: Dict;
|
|
10
|
-
}
|
|
11
|
-
export declare class ResponseBuilder<T> {
|
|
12
|
-
response: HttpResponse<T>;
|
|
13
|
-
protected constructor();
|
|
14
|
-
status(code: number): this;
|
|
15
|
-
header(name: string, value: string): this;
|
|
16
|
-
cookie(name: string, value: string): this;
|
|
17
|
-
get(): HttpResponse<T>;
|
|
18
|
-
static json<T>(jsonValue?: T): ResponseBuilder<T>;
|
|
19
|
-
static html(htmlValue?: string): ResponseBuilder<unknown>;
|
|
20
|
-
static binary(buffer?: Buffer): ResponseBuilder<unknown>;
|
|
21
|
-
static success(): HttpResponse<unknown>;
|
|
22
|
-
static notFound(data?: any): HttpResponse<unknown>;
|
|
23
|
-
static accessDenied(data?: any): HttpResponse<unknown>;
|
|
24
|
-
}
|
|
25
|
-
export {};
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
declare type Dict = {
|
|
3
|
+
[key: string]: string;
|
|
4
|
+
};
|
|
5
|
+
export declare class HttpResponse<T> {
|
|
6
|
+
value?: T;
|
|
7
|
+
code: number;
|
|
8
|
+
headers: Dict;
|
|
9
|
+
cookies: Dict;
|
|
10
|
+
}
|
|
11
|
+
export declare class ResponseBuilder<T> {
|
|
12
|
+
response: HttpResponse<T>;
|
|
13
|
+
protected constructor();
|
|
14
|
+
status(code: number): this;
|
|
15
|
+
header(name: string, value: string): this;
|
|
16
|
+
cookie(name: string, value: string): this;
|
|
17
|
+
get(): HttpResponse<T>;
|
|
18
|
+
static json<T>(jsonValue?: T): ResponseBuilder<T>;
|
|
19
|
+
static html(htmlValue?: string): ResponseBuilder<unknown>;
|
|
20
|
+
static binary(buffer?: Buffer): ResponseBuilder<unknown>;
|
|
21
|
+
static success(): HttpResponse<unknown>;
|
|
22
|
+
static notFound(data?: any): HttpResponse<unknown>;
|
|
23
|
+
static accessDenied(data?: any): HttpResponse<unknown>;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { HttpMethod, SocketMethod } from "@clairejs/core";
|
|
2
|
-
import { IServerSocket } from "../../socket/IServerSocket";
|
|
3
|
-
export interface RequestOptions {
|
|
4
|
-
method: HttpMethod | SocketMethod;
|
|
5
|
-
rawPath: string;
|
|
6
|
-
headers?: any;
|
|
7
|
-
body?: any;
|
|
8
|
-
socket?: IServerSocket;
|
|
9
|
-
}
|
|
1
|
+
import { HttpMethod, SocketMethod } from "@clairejs/core";
|
|
2
|
+
import { IServerSocket } from "../../socket/IServerSocket";
|
|
3
|
+
export interface RequestOptions {
|
|
4
|
+
method: HttpMethod | SocketMethod;
|
|
5
|
+
rawPath: string;
|
|
6
|
+
headers?: any;
|
|
7
|
+
body?: any;
|
|
8
|
+
socket?: IServerSocket;
|
|
9
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export interface ResponseValues {
|
|
2
|
-
headers?: {
|
|
3
|
-
[key: string]: string;
|
|
4
|
-
};
|
|
5
|
-
body?: any;
|
|
6
|
-
code: number;
|
|
7
|
-
cookies?: {
|
|
8
|
-
[key: string]: string;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
1
|
+
export interface ResponseValues {
|
|
2
|
+
headers?: {
|
|
3
|
+
[key: string]: string;
|
|
4
|
+
};
|
|
5
|
+
body?: any;
|
|
6
|
+
code: number;
|
|
7
|
+
cookies?: {
|
|
8
|
+
[key: string]: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare type RequestDataSource = "body" | "params" | "queries" | "headers" | "raw";
|
|
1
|
+
export declare type RequestDataSource = "body" | "params" | "queries" | "headers" | "raw";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { EndpointMetadata } from "./EndpointMetadata";
|
|
2
|
-
import { ITransaction } from "../../database/transaction/ITransaction";
|
|
3
|
-
import { ITransactionProvider } from "../../database/transaction/ITransactionProvider";
|
|
4
|
-
export declare abstract class AbstractHttpController implements ITransactionProvider {
|
|
5
|
-
private isEndpoint;
|
|
6
|
-
getCurrentTransaction(): Promise<ITransaction>;
|
|
7
|
-
getEndpointMetadata(): Readonly<EndpointMetadata>[];
|
|
8
|
-
}
|
|
1
|
+
import { EndpointMetadata } from "./EndpointMetadata";
|
|
2
|
+
import { ITransaction } from "../../database/transaction/ITransaction";
|
|
3
|
+
import { ITransactionProvider } from "../../database/transaction/ITransactionProvider";
|
|
4
|
+
export declare abstract class AbstractHttpController implements ITransactionProvider {
|
|
5
|
+
private isEndpoint;
|
|
6
|
+
getCurrentTransaction(): Promise<ITransaction>;
|
|
7
|
+
getEndpointMetadata(): Readonly<EndpointMetadata>[];
|
|
8
|
+
}
|