@decaf-ts/core 0.3.32 → 0.3.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/LICENSE.md +157 -21
- package/README.md +0 -0
- package/dist/core.bundle.min.js +1 -1
- package/dist/core.bundle.min.js.LICENSE.txt +0 -0
- package/dist/esm/core.bundle.min.esm.js +1 -1
- package/dist/esm/core.bundle.min.esm.js.LICENSE.txt +0 -0
- package/dist/lib/identity/decorators.d.ts +24 -0
- package/dist/lib/identity/index.d.ts +2 -0
- package/dist/lib/identity/utils.d.ts +3 -0
- package/dist/lib/index.d.ts +25 -0
- package/dist/lib/interfaces/Builder.d.ts +16 -0
- package/dist/lib/interfaces/Executor.d.ts +19 -0
- package/dist/lib/interfaces/Observable.d.ts +31 -0
- package/dist/lib/interfaces/Observer.d.ts +16 -0
- package/dist/lib/interfaces/Paginatable.d.ts +4 -0
- package/dist/lib/interfaces/Queriable.d.ts +6 -0
- package/dist/lib/interfaces/RawExecutor.d.ts +20 -0
- package/dist/lib/interfaces/SequenceOptions.d.ts +19 -0
- package/dist/lib/interfaces/index.d.ts +7 -0
- package/dist/lib/model/BaseModel.d.ts +6 -0
- package/dist/lib/model/IdentifiedBaseModel.d.ts +7 -0
- package/dist/lib/model/User.d.ts +8 -0
- package/dist/lib/model/construction.d.ts +15 -0
- package/dist/lib/model/decorators.d.ts +75 -0
- package/dist/lib/model/index.d.ts +4 -0
- package/dist/lib/model/types.d.ts +6 -0
- package/dist/lib/persistence/Adapter.d.ts +86 -0
- package/dist/lib/persistence/Sequence.d.ts +22 -0
- package/dist/lib/persistence/constants.d.ts +22 -0
- package/dist/lib/persistence/decorators.d.ts +1 -0
- package/dist/lib/persistence/errors.d.ts +7 -0
- package/dist/lib/persistence/index.d.ts +5 -0
- package/dist/lib/query/Clause.d.ts +50 -0
- package/dist/lib/query/ClauseFactory.d.ts +71 -0
- package/dist/lib/query/Condition.d.ts +75 -0
- package/dist/lib/query/Paginator.d.ts +22 -0
- package/dist/lib/query/Query.d.ts +43 -0
- package/dist/lib/query/Statement.d.ts +55 -0
- package/dist/lib/query/clauses/FromClause.d.ts +45 -0
- package/dist/lib/query/clauses/GroupByClause.d.ts +21 -0
- package/dist/lib/query/clauses/InsertClause.d.ts +37 -0
- package/dist/lib/query/clauses/LimitClause.d.ts +29 -0
- package/dist/lib/query/clauses/OffsetClause.d.ts +21 -0
- package/dist/lib/query/clauses/OrderByClause.d.ts +37 -0
- package/dist/lib/query/clauses/SelectClause.d.ts +47 -0
- package/dist/lib/query/clauses/SelectorBasedClause.d.ts +25 -0
- package/dist/lib/query/clauses/ValuesClause.d.ts +21 -0
- package/dist/lib/query/clauses/WhereClause.d.ts +46 -0
- package/dist/lib/query/clauses/index.d.ts +10 -0
- package/dist/lib/query/constants.d.ts +79 -0
- package/dist/lib/query/errors.d.ts +7 -0
- package/dist/lib/query/index.d.ts +12 -0
- package/dist/lib/query/options.d.ts +372 -0
- package/dist/lib/query/selectors.d.ts +38 -0
- package/dist/lib/query/types.d.ts +2 -0
- package/dist/lib/repository/Context.d.ts +10 -0
- package/dist/lib/repository/Repository.d.ts +70 -0
- package/dist/lib/repository/constants.d.ts +25 -0
- package/dist/lib/repository/decorators.d.ts +2 -0
- package/dist/lib/repository/errors.d.ts +12 -0
- package/dist/lib/repository/index.d.ts +8 -0
- package/dist/lib/repository/injectables.d.ts +5 -0
- package/dist/lib/repository/types.d.ts +15 -0
- package/dist/lib/repository/utils.d.ts +3 -0
- package/dist/lib/validators/ClauseSequenceValidator.d.ts +28 -0
- package/dist/lib/validators/decorators.d.ts +10 -0
- package/dist/lib/validators/index.d.ts +2 -0
- package/lib/esm/identity/decorators.d.ts +0 -0
- package/lib/esm/identity/decorators.js +1 -1
- package/lib/esm/identity/index.d.ts +0 -0
- package/lib/esm/identity/index.js +1 -1
- package/lib/esm/identity/utils.d.ts +0 -0
- package/lib/esm/identity/utils.js +1 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +2 -2
- package/lib/esm/interfaces/Builder.d.ts +0 -0
- package/lib/esm/interfaces/Builder.js +1 -1
- package/lib/esm/interfaces/Executor.d.ts +0 -0
- package/lib/esm/interfaces/Executor.js +1 -1
- package/lib/esm/interfaces/Observable.d.ts +0 -0
- package/lib/esm/interfaces/Observable.js +1 -1
- package/lib/esm/interfaces/Observer.d.ts +0 -0
- package/lib/esm/interfaces/Observer.js +1 -1
- package/lib/esm/interfaces/Paginatable.d.ts +0 -0
- package/lib/esm/interfaces/Paginatable.js +1 -1
- package/lib/esm/interfaces/Queriable.d.ts +0 -0
- package/lib/esm/interfaces/Queriable.js +1 -1
- package/lib/esm/interfaces/RawExecutor.d.ts +0 -0
- package/lib/esm/interfaces/RawExecutor.js +1 -1
- package/lib/esm/interfaces/SequenceOptions.d.ts +0 -0
- package/lib/esm/interfaces/SequenceOptions.js +1 -1
- package/lib/esm/interfaces/index.d.ts +0 -0
- package/lib/esm/interfaces/index.js +1 -1
- package/lib/esm/model/BaseModel.d.ts +0 -0
- package/lib/esm/model/BaseModel.js +1 -1
- package/lib/esm/model/IdentifiedBaseModel.d.ts +0 -0
- package/lib/esm/model/IdentifiedBaseModel.js +1 -1
- package/lib/esm/model/User.d.ts +0 -0
- package/lib/esm/model/User.js +1 -1
- package/lib/esm/model/construction.d.ts +0 -0
- package/lib/esm/model/construction.js +1 -1
- package/lib/esm/model/decorators.d.ts +0 -0
- package/lib/esm/model/decorators.js +1 -1
- package/lib/esm/model/index.d.ts +0 -0
- package/lib/esm/model/index.js +1 -1
- package/lib/esm/model/types.d.ts +0 -0
- package/lib/esm/model/types.js +1 -1
- package/lib/esm/persistence/Adapter.d.ts +0 -0
- package/lib/esm/persistence/Adapter.js +1 -1
- package/lib/esm/persistence/Sequence.d.ts +0 -0
- package/lib/esm/persistence/Sequence.js +1 -1
- package/lib/esm/persistence/constants.d.ts +0 -0
- package/lib/esm/persistence/constants.js +1 -1
- package/lib/esm/persistence/decorators.d.ts +0 -0
- package/lib/esm/persistence/decorators.js +1 -1
- package/lib/esm/persistence/errors.d.ts +0 -0
- package/lib/esm/persistence/errors.js +1 -1
- package/lib/esm/persistence/index.d.ts +0 -0
- package/lib/esm/persistence/index.js +1 -1
- package/lib/esm/query/Clause.d.ts +0 -0
- package/lib/esm/query/Clause.js +1 -1
- package/lib/esm/query/ClauseFactory.d.ts +0 -0
- package/lib/esm/query/ClauseFactory.js +1 -1
- package/lib/esm/query/Condition.d.ts +0 -0
- package/lib/esm/query/Condition.js +1 -1
- package/lib/esm/query/Paginator.d.ts +0 -0
- package/lib/esm/query/Paginator.js +1 -1
- package/lib/esm/query/Query.d.ts +0 -0
- package/lib/esm/query/Query.js +1 -1
- package/lib/esm/query/Statement.d.ts +0 -0
- package/lib/esm/query/Statement.js +1 -1
- package/lib/esm/query/clauses/FromClause.d.ts +0 -0
- package/lib/esm/query/clauses/FromClause.js +1 -1
- package/lib/esm/query/clauses/GroupByClause.d.ts +0 -0
- package/lib/esm/query/clauses/GroupByClause.js +1 -1
- package/lib/esm/query/clauses/InsertClause.d.ts +0 -0
- package/lib/esm/query/clauses/InsertClause.js +1 -1
- package/lib/esm/query/clauses/LimitClause.d.ts +0 -0
- package/lib/esm/query/clauses/LimitClause.js +1 -1
- package/lib/esm/query/clauses/OffsetClause.d.ts +0 -0
- package/lib/esm/query/clauses/OffsetClause.js +1 -1
- package/lib/esm/query/clauses/OrderByClause.d.ts +0 -0
- package/lib/esm/query/clauses/OrderByClause.js +1 -1
- package/lib/esm/query/clauses/SelectClause.d.ts +0 -0
- package/lib/esm/query/clauses/SelectClause.js +1 -1
- package/lib/esm/query/clauses/SelectorBasedClause.d.ts +0 -0
- package/lib/esm/query/clauses/SelectorBasedClause.js +1 -1
- package/lib/esm/query/clauses/ValuesClause.d.ts +0 -0
- package/lib/esm/query/clauses/ValuesClause.js +1 -1
- package/lib/esm/query/clauses/WhereClause.d.ts +0 -0
- package/lib/esm/query/clauses/index.d.ts +0 -0
- package/lib/esm/query/constants.d.ts +0 -0
- package/lib/esm/query/constants.js +1 -1
- package/lib/esm/query/errors.d.ts +0 -0
- package/lib/esm/query/errors.js +1 -1
- package/lib/esm/query/index.d.ts +0 -0
- package/lib/esm/query/index.js +1 -1
- package/lib/esm/query/options.d.ts +0 -0
- package/lib/esm/query/options.js +1 -1
- package/lib/esm/query/selectors.d.ts +0 -0
- package/lib/esm/query/selectors.js +1 -1
- package/lib/esm/query/types.d.ts +0 -0
- package/lib/esm/query/types.js +1 -1
- package/lib/esm/repository/Context.d.ts +0 -0
- package/lib/esm/repository/Context.js +1 -1
- package/lib/esm/repository/Repository.d.ts +0 -0
- package/lib/esm/repository/Repository.js +1 -1
- package/lib/esm/repository/constants.d.ts +0 -0
- package/lib/esm/repository/constants.js +1 -1
- package/lib/esm/repository/decorators.d.ts +0 -0
- package/lib/esm/repository/decorators.js +1 -1
- package/lib/esm/repository/errors.d.ts +0 -0
- package/lib/esm/repository/errors.js +1 -1
- package/lib/esm/repository/index.d.ts +0 -0
- package/lib/esm/repository/index.js +1 -1
- package/lib/esm/repository/injectables.d.ts +0 -0
- package/lib/esm/repository/injectables.js +1 -1
- package/lib/esm/repository/types.d.ts +0 -0
- package/lib/esm/repository/types.js +1 -1
- package/lib/esm/repository/utils.d.ts +0 -0
- package/lib/esm/repository/utils.js +1 -1
- package/lib/esm/validators/ClauseSequenceValidator.d.ts +0 -0
- package/lib/esm/validators/ClauseSequenceValidator.js +1 -1
- package/lib/esm/validators/decorators.d.ts +0 -0
- package/lib/esm/validators/decorators.js +1 -1
- package/lib/esm/validators/index.d.ts +0 -0
- package/lib/esm/validators/index.js +1 -1
- package/lib/identity/decorators.cjs +0 -2
- package/lib/identity/decorators.d.ts +0 -0
- package/lib/identity/index.cjs +0 -2
- package/lib/identity/index.d.ts +0 -0
- package/lib/identity/utils.cjs +0 -2
- package/lib/identity/utils.d.ts +0 -0
- package/lib/index.cjs +1 -3
- package/lib/index.d.ts +1 -1
- package/lib/interfaces/Builder.cjs +0 -2
- package/lib/interfaces/Builder.d.ts +0 -0
- package/lib/interfaces/Executor.cjs +0 -2
- package/lib/interfaces/Executor.d.ts +0 -0
- package/lib/interfaces/Observable.cjs +0 -2
- package/lib/interfaces/Observable.d.ts +0 -0
- package/lib/interfaces/Observer.cjs +0 -2
- package/lib/interfaces/Observer.d.ts +0 -0
- package/lib/interfaces/Paginatable.cjs +0 -2
- package/lib/interfaces/Paginatable.d.ts +0 -0
- package/lib/interfaces/Queriable.cjs +0 -2
- package/lib/interfaces/Queriable.d.ts +0 -0
- package/lib/interfaces/RawExecutor.cjs +0 -2
- package/lib/interfaces/RawExecutor.d.ts +0 -0
- package/lib/interfaces/SequenceOptions.cjs +0 -2
- package/lib/interfaces/SequenceOptions.d.ts +0 -0
- package/lib/interfaces/index.cjs +0 -2
- package/lib/interfaces/index.d.ts +0 -0
- package/lib/model/BaseModel.cjs +0 -2
- package/lib/model/BaseModel.d.ts +0 -0
- package/lib/model/IdentifiedBaseModel.cjs +0 -2
- package/lib/model/IdentifiedBaseModel.d.ts +0 -0
- package/lib/model/User.cjs +0 -2
- package/lib/model/User.d.ts +0 -0
- package/lib/model/construction.cjs +0 -2
- package/lib/model/construction.d.ts +0 -0
- package/lib/model/decorators.cjs +0 -2
- package/lib/model/decorators.d.ts +0 -0
- package/lib/model/index.cjs +0 -2
- package/lib/model/index.d.ts +0 -0
- package/lib/model/types.cjs +0 -2
- package/lib/model/types.d.ts +0 -0
- package/lib/persistence/Adapter.cjs +0 -2
- package/lib/persistence/Adapter.d.ts +0 -0
- package/lib/persistence/Sequence.cjs +0 -2
- package/lib/persistence/Sequence.d.ts +0 -0
- package/lib/persistence/constants.cjs +0 -2
- package/lib/persistence/constants.d.ts +0 -0
- package/lib/persistence/decorators.cjs +0 -2
- package/lib/persistence/decorators.d.ts +0 -0
- package/lib/persistence/errors.cjs +0 -2
- package/lib/persistence/errors.d.ts +0 -0
- package/lib/persistence/index.cjs +0 -2
- package/lib/persistence/index.d.ts +0 -0
- package/lib/query/Clause.cjs +0 -2
- package/lib/query/Clause.d.ts +0 -0
- package/lib/query/ClauseFactory.cjs +0 -2
- package/lib/query/ClauseFactory.d.ts +0 -0
- package/lib/query/Condition.cjs +0 -2
- package/lib/query/Condition.d.ts +0 -0
- package/lib/query/Paginator.cjs +0 -2
- package/lib/query/Paginator.d.ts +0 -0
- package/lib/query/Query.cjs +0 -2
- package/lib/query/Query.d.ts +0 -0
- package/lib/query/Statement.cjs +0 -2
- package/lib/query/Statement.d.ts +0 -0
- package/lib/query/clauses/FromClause.cjs +0 -2
- package/lib/query/clauses/FromClause.d.ts +0 -0
- package/lib/query/clauses/GroupByClause.cjs +0 -2
- package/lib/query/clauses/GroupByClause.d.ts +0 -0
- package/lib/query/clauses/InsertClause.cjs +0 -2
- package/lib/query/clauses/InsertClause.d.ts +0 -0
- package/lib/query/clauses/LimitClause.cjs +0 -2
- package/lib/query/clauses/LimitClause.d.ts +0 -0
- package/lib/query/clauses/OffsetClause.cjs +0 -2
- package/lib/query/clauses/OffsetClause.d.ts +0 -0
- package/lib/query/clauses/OrderByClause.cjs +0 -2
- package/lib/query/clauses/OrderByClause.d.ts +0 -0
- package/lib/query/clauses/SelectClause.cjs +0 -2
- package/lib/query/clauses/SelectClause.d.ts +0 -0
- package/lib/query/clauses/SelectorBasedClause.cjs +0 -2
- package/lib/query/clauses/SelectorBasedClause.d.ts +0 -0
- package/lib/query/clauses/ValuesClause.cjs +0 -2
- package/lib/query/clauses/ValuesClause.d.ts +0 -0
- package/lib/query/clauses/WhereClause.cjs +0 -2
- package/lib/query/clauses/WhereClause.d.ts +0 -0
- package/lib/query/clauses/index.cjs +0 -2
- package/lib/query/clauses/index.d.ts +0 -0
- package/lib/query/constants.cjs +0 -2
- package/lib/query/constants.d.ts +0 -0
- package/lib/query/errors.cjs +0 -2
- package/lib/query/errors.d.ts +0 -0
- package/lib/query/index.cjs +0 -2
- package/lib/query/index.d.ts +0 -0
- package/lib/query/options.cjs +0 -2
- package/lib/query/options.d.ts +0 -0
- package/lib/query/selectors.cjs +0 -2
- package/lib/query/selectors.d.ts +0 -0
- package/lib/query/types.cjs +0 -2
- package/lib/query/types.d.ts +0 -0
- package/lib/repository/Context.cjs +0 -2
- package/lib/repository/Context.d.ts +0 -0
- package/lib/repository/Repository.cjs +0 -2
- package/lib/repository/Repository.d.ts +0 -0
- package/lib/repository/constants.cjs +0 -2
- package/lib/repository/constants.d.ts +0 -0
- package/lib/repository/decorators.cjs +0 -2
- package/lib/repository/decorators.d.ts +0 -0
- package/lib/repository/errors.cjs +0 -2
- package/lib/repository/errors.d.ts +0 -0
- package/lib/repository/index.cjs +0 -2
- package/lib/repository/index.d.ts +0 -0
- package/lib/repository/injectables.cjs +0 -2
- package/lib/repository/injectables.d.ts +0 -0
- package/lib/repository/types.cjs +0 -2
- package/lib/repository/types.d.ts +0 -0
- package/lib/repository/utils.cjs +0 -2
- package/lib/repository/utils.d.ts +0 -0
- package/lib/validators/ClauseSequenceValidator.cjs +0 -2
- package/lib/validators/ClauseSequenceValidator.d.ts +0 -0
- package/lib/validators/decorators.cjs +0 -2
- package/lib/validators/decorators.d.ts +0 -0
- package/lib/validators/index.cjs +0 -2
- package/lib/validators/index.d.ts +0 -0
- package/package.json +17 -17
- package/lib/esm/query/clauses/WhereClause.js +0 -72
- package/lib/esm/query/clauses/index.js +0 -12
@@ -0,0 +1,75 @@
|
|
1
|
+
import { AttributeOption, ConditionBuilderOption } from "./options";
|
2
|
+
import { Model, ModelErrorDefinition } from "@decaf-ts/decorator-validation";
|
3
|
+
import { GroupOperator, Operator } from "./constants";
|
4
|
+
/**
|
5
|
+
* @summary Condition Class
|
6
|
+
* @description Represents a logical condition
|
7
|
+
*
|
8
|
+
* @param {string | Condition} attr1
|
9
|
+
* @param {Operator | GroupOperator} operator
|
10
|
+
* @param {string | Condition} comparison
|
11
|
+
*
|
12
|
+
* @class Condition
|
13
|
+
* @implements Executor
|
14
|
+
*
|
15
|
+
* @category Query
|
16
|
+
* @subcategory Conditions
|
17
|
+
*/
|
18
|
+
export declare class Condition extends Model {
|
19
|
+
protected attr1?: string | Condition;
|
20
|
+
protected operator?: Operator | GroupOperator;
|
21
|
+
protected comparison?: any;
|
22
|
+
private constructor();
|
23
|
+
/**
|
24
|
+
* @summary Joins 2 {@link Condition}s on an {@link Operator#AND} operation
|
25
|
+
* @param {Condition} condition
|
26
|
+
*/
|
27
|
+
and(condition: Condition): Condition;
|
28
|
+
/**
|
29
|
+
* @summary Joins 2 {@link Condition}s on an {@link Operator#OR} operation
|
30
|
+
* @param {Condition} condition
|
31
|
+
*/
|
32
|
+
or(condition: Condition): Condition;
|
33
|
+
/**
|
34
|
+
* @summary excludes a valut from the result
|
35
|
+
* @param val
|
36
|
+
*/
|
37
|
+
not(val: any): Condition;
|
38
|
+
/**
|
39
|
+
* @inheritDoc
|
40
|
+
*/
|
41
|
+
hasErrors(...exceptions: string[]): ModelErrorDefinition | undefined;
|
42
|
+
/**
|
43
|
+
* @summary Joins 2 {@link Condition}s on an {@link Operator#AND} operation
|
44
|
+
* @param {Condition} condition1
|
45
|
+
* @param {Condition} condition2
|
46
|
+
*/
|
47
|
+
static and(condition1: Condition, condition2: Condition): Condition;
|
48
|
+
/**
|
49
|
+
* @summary Joins 2 {@link Condition}s on an {@link Operator#OR} operation
|
50
|
+
* @param {Condition} condition1
|
51
|
+
* @param {Condition} condition2
|
52
|
+
*/
|
53
|
+
static or(condition1: Condition, condition2: Condition): Condition;
|
54
|
+
/**
|
55
|
+
* @summary Groups 2 {@link Condition}s by the specified {@link GroupOperator}
|
56
|
+
* @param {Condition} condition1
|
57
|
+
* @param {GroupOperator} operator
|
58
|
+
* @param {Condition} condition2
|
59
|
+
*/
|
60
|
+
private static group;
|
61
|
+
static attribute(attr: string): AttributeOption;
|
62
|
+
/**
|
63
|
+
* @summary Condition Builder Class
|
64
|
+
* @description provides a simple API to build {@link Condition}s
|
65
|
+
*
|
66
|
+
* @class ConditionBuilder
|
67
|
+
* @implements Builder
|
68
|
+
* @implements AttributeOption
|
69
|
+
*
|
70
|
+
* @category Query
|
71
|
+
* @subcategory Conditions
|
72
|
+
*/
|
73
|
+
private static Builder;
|
74
|
+
static get builder(): ConditionBuilderOption;
|
75
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { Statement } from "./Statement";
|
2
|
+
export declare abstract class Paginator<V, Q> {
|
3
|
+
protected stat: Statement<Q>;
|
4
|
+
readonly size: number;
|
5
|
+
protected readonly _rawStatement: Q;
|
6
|
+
protected _currentPage: number;
|
7
|
+
protected _totalPages: number;
|
8
|
+
protected _recordCount: number;
|
9
|
+
protected limit: number;
|
10
|
+
private _statement?;
|
11
|
+
get current(): number;
|
12
|
+
get total(): number;
|
13
|
+
get count(): number;
|
14
|
+
get statement(): Q;
|
15
|
+
protected get adapter(): import("..").Adapter<any, Q>;
|
16
|
+
protected constructor(stat: Statement<Q>, size: number, _rawStatement: Q);
|
17
|
+
protected abstract prepare(rawStatement: Q): Q;
|
18
|
+
next(): Promise<V[]>;
|
19
|
+
previous(): Promise<V[]>;
|
20
|
+
protected validatePage(page: number): void;
|
21
|
+
abstract page(page?: number, ...args: any[]): Promise<V[]>;
|
22
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import { CountOption, DistinctOption, InsertOption, MaxOption, MinOption, SelectOption } from "./options";
|
2
|
+
import { SelectSelector } from "./selectors";
|
3
|
+
import { Adapter } from "../persistence";
|
4
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
5
|
+
/**
|
6
|
+
* @summary Helper Class to build queries
|
7
|
+
*
|
8
|
+
* @param {Database} db
|
9
|
+
*
|
10
|
+
* @class Query
|
11
|
+
*
|
12
|
+
* @category Query
|
13
|
+
*/
|
14
|
+
export declare class Query<Q, M extends Model> {
|
15
|
+
private adapter;
|
16
|
+
constructor(adapter: Adapter<any, Q>);
|
17
|
+
/**
|
18
|
+
* @summary Creates a Select Clause
|
19
|
+
* @param {SelectSelector} [selector]
|
20
|
+
*/
|
21
|
+
select(selector?: SelectSelector): SelectOption<M>;
|
22
|
+
/**
|
23
|
+
* @summary Creates a Min Clause
|
24
|
+
* @param {SelectSelector} selector
|
25
|
+
*/
|
26
|
+
min(selector: SelectSelector): MinOption<M>;
|
27
|
+
/**
|
28
|
+
* @summary Creates a Max Clause
|
29
|
+
* @param {SelectSelector} selector
|
30
|
+
*/
|
31
|
+
max(selector: SelectSelector): MaxOption<M>;
|
32
|
+
/**
|
33
|
+
* @summary Creates a Distinct Clause
|
34
|
+
* @param {SelectSelector} selector
|
35
|
+
*/
|
36
|
+
distinct(selector: SelectSelector): DistinctOption<M>;
|
37
|
+
/**
|
38
|
+
* @summary Creates a Count Clause
|
39
|
+
* @param {SelectSelector} selector
|
40
|
+
*/
|
41
|
+
count(selector?: SelectSelector): CountOption<M>;
|
42
|
+
insert(): InsertOption<M>;
|
43
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import { Constructor, Model, ModelErrorDefinition } from "@decaf-ts/decorator-validation";
|
2
|
+
import { Executor, RawExecutor } from "../interfaces";
|
3
|
+
import { StatementType } from "./constants";
|
4
|
+
import { Clause } from "./Clause";
|
5
|
+
import { Adapter } from "../persistence";
|
6
|
+
import { Paginator } from "./Paginator";
|
7
|
+
/**
|
8
|
+
* @summary Statement Class
|
9
|
+
* @description holds all the clauses until they can be processed
|
10
|
+
*
|
11
|
+
* @param {ModelArg} [statement]
|
12
|
+
*
|
13
|
+
* @class Statement
|
14
|
+
* @extends Model
|
15
|
+
* @implements Executor
|
16
|
+
* @implements RawExecutor
|
17
|
+
*
|
18
|
+
* @category Query
|
19
|
+
*/
|
20
|
+
export declare abstract class Statement<Q> extends Model implements Executor, RawExecutor<Q> {
|
21
|
+
protected clauses?: Clause<any>[];
|
22
|
+
protected adapter: Adapter<any, Q>;
|
23
|
+
protected target?: Constructor<any>;
|
24
|
+
protected fullRecord: boolean;
|
25
|
+
protected type?: string;
|
26
|
+
protected constructor(db: Adapter<any, Q>);
|
27
|
+
protected build(): Q;
|
28
|
+
/**
|
29
|
+
* @inheritDoc
|
30
|
+
*/
|
31
|
+
execute<Y>(): Promise<Y>;
|
32
|
+
/**
|
33
|
+
* @inheritDoc
|
34
|
+
*/
|
35
|
+
abstract paginate<Y>(size: number): Promise<Paginator<Y, Q>>;
|
36
|
+
raw<R>(rawInput: Q, ...args: any[]): Promise<R>;
|
37
|
+
/**
|
38
|
+
* @inheritDoc
|
39
|
+
*/
|
40
|
+
hasErrors(...exceptions: string[]): ModelErrorDefinition | undefined;
|
41
|
+
/**
|
42
|
+
* @summary Adds a clause to the Statement
|
43
|
+
* @param {Clause} clause
|
44
|
+
*/
|
45
|
+
addClause(clause: Clause<Q>): void;
|
46
|
+
getAdapter(): Adapter<any, Q>;
|
47
|
+
/**
|
48
|
+
* @summary Defines the output class (when existing)
|
49
|
+
* @param {Constructor} clazz
|
50
|
+
*/
|
51
|
+
setTarget(clazz: Constructor<any>): void;
|
52
|
+
getTarget(): Constructor<any>;
|
53
|
+
setFullRecord(): void;
|
54
|
+
setMode(type: StatementType): void;
|
55
|
+
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import { FromSelector, GroupBySelector, LimitSelector, OffsetSelector, OrderBySelector } from "../selectors";
|
2
|
+
import { LimitOption, OffsetOption, OrderAndGroupOption, WhereOption } from "../options";
|
3
|
+
import { SelectorBasedClause } from "./SelectorBasedClause";
|
4
|
+
import { Executor } from "../../interfaces";
|
5
|
+
import { Condition } from "../Condition";
|
6
|
+
import { Model, ModelArg } from "@decaf-ts/decorator-validation";
|
7
|
+
/**
|
8
|
+
* @summary The FROM clause
|
9
|
+
*
|
10
|
+
* @param {ModelArg} [clause]
|
11
|
+
*
|
12
|
+
* @class FromClause
|
13
|
+
* @extends SelectorBasedClause
|
14
|
+
* @implements WhereOption
|
15
|
+
*
|
16
|
+
* @category Query
|
17
|
+
* @subcategory Clauses
|
18
|
+
*/
|
19
|
+
export declare abstract class FromClause<Q, M extends Model> extends SelectorBasedClause<Q, FromSelector<M>> implements WhereOption {
|
20
|
+
protected constructor(clause?: ModelArg<FromClause<Q, M>>);
|
21
|
+
/**
|
22
|
+
* @inheritDoc
|
23
|
+
*/
|
24
|
+
abstract build(query: Q): Q;
|
25
|
+
/**
|
26
|
+
* @inheritDoc
|
27
|
+
*/
|
28
|
+
where(condition: Condition): OrderAndGroupOption;
|
29
|
+
/**
|
30
|
+
* @inheritDoc
|
31
|
+
*/
|
32
|
+
orderBy(...selector: OrderBySelector[]): LimitOption & OffsetOption;
|
33
|
+
/**
|
34
|
+
* @inheritDoc
|
35
|
+
*/
|
36
|
+
groupBy(selector: GroupBySelector): Executor;
|
37
|
+
/**
|
38
|
+
* @inheritDoc
|
39
|
+
*/
|
40
|
+
limit(selector: LimitSelector): OffsetOption;
|
41
|
+
/**
|
42
|
+
* @inheritDoc
|
43
|
+
*/
|
44
|
+
offset(selector: OffsetSelector): Executor;
|
45
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { ModelArg } from "@decaf-ts/decorator-validation";
|
2
|
+
import { GroupBySelector } from "../selectors";
|
3
|
+
import { SelectorBasedClause } from "./SelectorBasedClause";
|
4
|
+
/**
|
5
|
+
* @summary The GROUP BY clause
|
6
|
+
*
|
7
|
+
* @param {ClauseArg} [clause]
|
8
|
+
*
|
9
|
+
* @class GroupByClause
|
10
|
+
* @extends SelectorBasedClause
|
11
|
+
*
|
12
|
+
* @category Query
|
13
|
+
* @subcategory Clauses
|
14
|
+
*/
|
15
|
+
export declare abstract class GroupByClause<Q> extends SelectorBasedClause<Q, GroupBySelector> {
|
16
|
+
protected constructor(clause?: ModelArg<GroupByClause<Q>>);
|
17
|
+
/**
|
18
|
+
* @inheritDoc
|
19
|
+
*/
|
20
|
+
abstract build(query: Q): Q;
|
21
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { Condition } from "../Condition";
|
2
|
+
import { InsertOption, IntoOption, OrderAndGroupOption } from "../options";
|
3
|
+
import { Clause } from "../Clause";
|
4
|
+
import { Constructor, Model, ModelArg } from "@decaf-ts/decorator-validation";
|
5
|
+
import { Executor } from "../../interfaces";
|
6
|
+
/**
|
7
|
+
* @summary The INSERT/INTO clause
|
8
|
+
*
|
9
|
+
* @param {ClauseArg} [clause]
|
10
|
+
*
|
11
|
+
* @class FromClause
|
12
|
+
* @extends Clause
|
13
|
+
* @implements IntoOption
|
14
|
+
*
|
15
|
+
* @category Query
|
16
|
+
* @subcategory Clauses
|
17
|
+
*/
|
18
|
+
export declare abstract class InsertClause<Q, M extends Model> extends Clause<Q> implements InsertOption<M>, IntoOption<M> {
|
19
|
+
protected table?: string;
|
20
|
+
protected constructor(clause?: ModelArg<InsertClause<Q, M>>);
|
21
|
+
/**
|
22
|
+
* @inheritDoc
|
23
|
+
*/
|
24
|
+
abstract build(query: Q): Q;
|
25
|
+
/**
|
26
|
+
* @inheritDoc
|
27
|
+
*/
|
28
|
+
into(table: Constructor<M>): IntoOption<M>;
|
29
|
+
/**
|
30
|
+
* @inheritDoc
|
31
|
+
*/
|
32
|
+
values(...models: M[]): Executor;
|
33
|
+
/**
|
34
|
+
* @inheritDoc
|
35
|
+
*/
|
36
|
+
where(condition: Condition): OrderAndGroupOption;
|
37
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { SelectorBasedClause } from "./SelectorBasedClause";
|
2
|
+
import { OffsetOption } from "../options";
|
3
|
+
import { Executor } from "../../interfaces";
|
4
|
+
import { LimitSelector, OffsetSelector } from "../selectors";
|
5
|
+
import { ModelArg } from "@decaf-ts/decorator-validation";
|
6
|
+
/**
|
7
|
+
* @summary Limit Clause
|
8
|
+
* @description Limits the results
|
9
|
+
*
|
10
|
+
* @param {ClauseArg} [clause]
|
11
|
+
*
|
12
|
+
* @class LimitClause
|
13
|
+
* @extends SelectorBasedClause<T>
|
14
|
+
* @implements OffsetOption<T>
|
15
|
+
*
|
16
|
+
* @category Query
|
17
|
+
* @subcategory Clauses
|
18
|
+
*/
|
19
|
+
export declare abstract class LimitClause<Q> extends SelectorBasedClause<Q, LimitSelector> implements OffsetOption {
|
20
|
+
protected constructor(clause?: ModelArg<LimitClause<Q>>);
|
21
|
+
/**
|
22
|
+
* @inheritDoc
|
23
|
+
*/
|
24
|
+
abstract build(query: Q): Q;
|
25
|
+
/**
|
26
|
+
* @inheritDoc
|
27
|
+
*/
|
28
|
+
offset(selector: OffsetSelector): Executor;
|
29
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { SelectorBasedClause } from "./SelectorBasedClause";
|
2
|
+
import { OffsetSelector } from "../selectors";
|
3
|
+
import { ModelArg } from "@decaf-ts/decorator-validation";
|
4
|
+
/**
|
5
|
+
* @summary The OFFSET clause
|
6
|
+
*
|
7
|
+
* @param {ClauseArg} [clause]
|
8
|
+
*
|
9
|
+
* @class FromClause
|
10
|
+
* @extends SelectorBasedClause
|
11
|
+
*
|
12
|
+
* @category Query
|
13
|
+
* @subcategory Clauses
|
14
|
+
*/
|
15
|
+
export declare abstract class OffsetClause<Q> extends SelectorBasedClause<Q, OffsetSelector> {
|
16
|
+
protected constructor(clause?: ModelArg<OffsetClause<Q>>);
|
17
|
+
/**
|
18
|
+
* @inheritDoc
|
19
|
+
*/
|
20
|
+
abstract build(query: Q): Q;
|
21
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { SelectorBasedClause } from "./SelectorBasedClause";
|
2
|
+
import { GroupBySelector, LimitSelector, OffsetSelector, OrderBySelector } from "../selectors";
|
3
|
+
import { LimitOption, OffsetOption } from "../options";
|
4
|
+
import { Executor } from "../../interfaces";
|
5
|
+
import { ModelArg } from "@decaf-ts/decorator-validation";
|
6
|
+
/**
|
7
|
+
* @summary The ORDER BY clause
|
8
|
+
*
|
9
|
+
* @param {ClauseArg} [clause]
|
10
|
+
*
|
11
|
+
* @class OrderByClause
|
12
|
+
* @extends SelectorBasedClause
|
13
|
+
* @implements LimitOption
|
14
|
+
* @implements OffsetOption
|
15
|
+
*
|
16
|
+
* @category Query
|
17
|
+
* @subcategory Clauses
|
18
|
+
*/
|
19
|
+
export declare abstract class OrderByClause<Q> extends SelectorBasedClause<Q, OrderBySelector[]> implements LimitOption, OffsetOption {
|
20
|
+
protected constructor(clause?: ModelArg<OrderByClause<Q>>);
|
21
|
+
/**
|
22
|
+
* @inheritDoc
|
23
|
+
*/
|
24
|
+
abstract build(query: Q): Q;
|
25
|
+
/**
|
26
|
+
* @inheritDoc
|
27
|
+
*/
|
28
|
+
groupBy(selector: GroupBySelector): Executor;
|
29
|
+
/**
|
30
|
+
* @inheritDoc
|
31
|
+
*/
|
32
|
+
limit(selector: LimitSelector): OffsetOption;
|
33
|
+
/**
|
34
|
+
* @inheritDoc
|
35
|
+
*/
|
36
|
+
offset(selector: OffsetSelector): Executor;
|
37
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import { SelectorBasedClause } from "./SelectorBasedClause";
|
2
|
+
import { CountOption, DistinctOption, MaxOption, MinOption, SelectOption, WhereOption } from "../options";
|
3
|
+
import { Constructor, ModelArg, Model } from "@decaf-ts/decorator-validation";
|
4
|
+
import { SelectSelector } from "../selectors";
|
5
|
+
/**
|
6
|
+
* @summary The SELECT clause
|
7
|
+
*
|
8
|
+
* @param {ClauseArg} [clause]
|
9
|
+
*
|
10
|
+
* @class SelectClause
|
11
|
+
* @extends SelectorBasedClause
|
12
|
+
* @implements SelectOption
|
13
|
+
*
|
14
|
+
* @category Query
|
15
|
+
* @subcategory Clauses
|
16
|
+
*/
|
17
|
+
export declare abstract class SelectClause<Q, M extends Model> extends SelectorBasedClause<Q, SelectSelector> implements SelectOption<M> {
|
18
|
+
private isDistinct;
|
19
|
+
private isCount;
|
20
|
+
private isMax;
|
21
|
+
private isMin;
|
22
|
+
protected constructor(clause?: ModelArg<SelectClause<Q, M>>);
|
23
|
+
/**
|
24
|
+
* @inheritDoc
|
25
|
+
*/
|
26
|
+
abstract build(query: Q): Q;
|
27
|
+
/**
|
28
|
+
* @inheritDoc
|
29
|
+
*/
|
30
|
+
distinct(selector: SelectSelector): DistinctOption<M>;
|
31
|
+
/**
|
32
|
+
* @inheritDoc
|
33
|
+
*/
|
34
|
+
count(selector: SelectSelector): CountOption<M>;
|
35
|
+
/**
|
36
|
+
* @inheritDoc
|
37
|
+
*/
|
38
|
+
min(selector: SelectSelector): MinOption<M>;
|
39
|
+
/**
|
40
|
+
* @inheritDoc
|
41
|
+
*/
|
42
|
+
max(selector: SelectSelector): MaxOption<M>;
|
43
|
+
/**
|
44
|
+
* @inheritDoc
|
45
|
+
*/
|
46
|
+
from(tableName: Constructor<M>): WhereOption;
|
47
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { Clause } from "../Clause";
|
2
|
+
import { ModelArg } from "@decaf-ts/decorator-validation";
|
3
|
+
/**
|
4
|
+
* @summary The base Selector based clause
|
5
|
+
*
|
6
|
+
* @param {ClauseArg} [clause]
|
7
|
+
*
|
8
|
+
* @class SelectorBasedClause
|
9
|
+
* @extends Clause
|
10
|
+
* @abstract
|
11
|
+
*
|
12
|
+
* @category Query
|
13
|
+
* @subcategory Clauses
|
14
|
+
*/
|
15
|
+
export declare abstract class SelectorBasedClause<Q, S> extends Clause<Q> {
|
16
|
+
/**
|
17
|
+
* @summary Stores the selector
|
18
|
+
*
|
19
|
+
* @prop selector
|
20
|
+
* @protected
|
21
|
+
*/
|
22
|
+
protected selector?: S;
|
23
|
+
protected constructor(clause?: ModelArg<SelectorBasedClause<Q, S>>);
|
24
|
+
toString(): string;
|
25
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { Clause } from "../Clause";
|
2
|
+
import { ModelArg } from "@decaf-ts/decorator-validation";
|
3
|
+
/**
|
4
|
+
* @summary The VALUES clause
|
5
|
+
*
|
6
|
+
* @param {ClauseArg} [clause]
|
7
|
+
*
|
8
|
+
* @class ValuesClause
|
9
|
+
* @extends Clause
|
10
|
+
*
|
11
|
+
* @category Query
|
12
|
+
* @subcategory Clauses
|
13
|
+
*/
|
14
|
+
export declare abstract class ValuesClause<Q, M> extends Clause<Q> {
|
15
|
+
models?: M[];
|
16
|
+
protected constructor(clause?: ModelArg<ValuesClause<Q, M>>);
|
17
|
+
/**
|
18
|
+
* @inheritDoc
|
19
|
+
*/
|
20
|
+
abstract build(query: Q): Q;
|
21
|
+
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import { Clause } from "../Clause";
|
2
|
+
import { Condition } from "../Condition";
|
3
|
+
import { ModelArg, ModelErrorDefinition } from "@decaf-ts/decorator-validation";
|
4
|
+
import { LimitOption, OffsetOption, OrderAndGroupOption } from "../options";
|
5
|
+
import { GroupBySelector, LimitSelector, OffsetSelector, OrderBySelector } from "../selectors";
|
6
|
+
import { Executor } from "../../interfaces";
|
7
|
+
/**
|
8
|
+
* @summary The WHERE clause
|
9
|
+
*
|
10
|
+
* @param {ClauseArg} [clause]
|
11
|
+
*
|
12
|
+
* @class WhereClause
|
13
|
+
* @extends Clause
|
14
|
+
* @implements OrderAndGroupOption
|
15
|
+
*
|
16
|
+
* @category Query
|
17
|
+
* @subcategory Clauses
|
18
|
+
*/
|
19
|
+
export declare abstract class WhereClause<Q> extends Clause<Q> implements OrderAndGroupOption {
|
20
|
+
condition?: Condition;
|
21
|
+
protected constructor(clause?: ModelArg<WhereClause<Q>>);
|
22
|
+
/**
|
23
|
+
* @inheritDoc
|
24
|
+
*/
|
25
|
+
abstract build(query: Q): Q;
|
26
|
+
/**
|
27
|
+
* @inheritDoc
|
28
|
+
*/
|
29
|
+
orderBy(...selector: OrderBySelector[]): LimitOption & OffsetOption;
|
30
|
+
/**
|
31
|
+
* @inheritDoc
|
32
|
+
*/
|
33
|
+
groupBy(selector: GroupBySelector): Executor;
|
34
|
+
/**
|
35
|
+
* @inheritDoc
|
36
|
+
*/
|
37
|
+
limit(selector: LimitSelector): OffsetOption;
|
38
|
+
/**
|
39
|
+
* @inheritDoc
|
40
|
+
*/
|
41
|
+
offset(selector: OffsetSelector): Executor;
|
42
|
+
/**
|
43
|
+
* @inheritDoc
|
44
|
+
*/
|
45
|
+
hasErrors(...exceptions: string[]): ModelErrorDefinition | undefined;
|
46
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
export * from "./FromClause";
|
2
|
+
export * from "./GroupByClause";
|
3
|
+
export * from "./InsertClause";
|
4
|
+
export * from "./LimitClause";
|
5
|
+
export * from "./OffsetClause";
|
6
|
+
export * from "./OrderByClause";
|
7
|
+
export * from "./SelectClause";
|
8
|
+
export * from "./SelectorBasedClause";
|
9
|
+
export * from "./ValuesClause";
|
10
|
+
export * from "./WhereClause";
|
@@ -0,0 +1,79 @@
|
|
1
|
+
export declare enum Operator {
|
2
|
+
EQUAL = "EQUAL",
|
3
|
+
DIFFERENT = "DIFFERENT",
|
4
|
+
BIGGER = "BIGGER",
|
5
|
+
BIGGER_EQ = "BIGGER_EQ",
|
6
|
+
SMALLER = "SMALLER",
|
7
|
+
SMALLER_EQ = "SMALLER_EQ",
|
8
|
+
NOT = "NOT",
|
9
|
+
IN = "IN",
|
10
|
+
REGEXP = "REGEXP"
|
11
|
+
}
|
12
|
+
export declare enum GroupOperator {
|
13
|
+
AND = "AND",
|
14
|
+
OR = "OR"
|
15
|
+
}
|
16
|
+
export declare enum Const {
|
17
|
+
NULL = "NULL",
|
18
|
+
FULL_RECORD = "*"
|
19
|
+
}
|
20
|
+
/**
|
21
|
+
* @summary Defines execution order of Clauses in statements as defined in SQL.
|
22
|
+
*
|
23
|
+
* @description sub priorities where defined to better organize clauses within statements, eg From and Join Clauses
|
24
|
+
*
|
25
|
+
* @const Priority
|
26
|
+
*
|
27
|
+
* @category Clauses
|
28
|
+
* @subcategory Constants
|
29
|
+
*/
|
30
|
+
export declare enum Priority {
|
31
|
+
/**
|
32
|
+
* @summary Defines the priority for the FROM Clause
|
33
|
+
* @description From Clause in SELECT Statements.
|
34
|
+
* Values Clause in INSERT Statements
|
35
|
+
*
|
36
|
+
* @prop FROM
|
37
|
+
*/
|
38
|
+
FROM = 1,
|
39
|
+
/**
|
40
|
+
* @summary Defines the priority for the JOIN Clause
|
41
|
+
*
|
42
|
+
* @property {number} JOIN
|
43
|
+
*/
|
44
|
+
JOIN = 1.1,
|
45
|
+
/**
|
46
|
+
* Where Clause
|
47
|
+
*/
|
48
|
+
WHERE = 2,
|
49
|
+
/**
|
50
|
+
* Group By Clause
|
51
|
+
*/
|
52
|
+
GROUP_BY = 3,
|
53
|
+
/**
|
54
|
+
* Having Clause
|
55
|
+
*/
|
56
|
+
HAVING = 4,
|
57
|
+
/**
|
58
|
+
* Select Clause in SELECT Statements
|
59
|
+
* Insert Clause in INSERT Statements
|
60
|
+
*/
|
61
|
+
SELECT = 5,
|
62
|
+
/**
|
63
|
+
* Order By Clause
|
64
|
+
*/
|
65
|
+
ORDER_BY = 6,
|
66
|
+
/**
|
67
|
+
* Limit Clause
|
68
|
+
*/
|
69
|
+
LIMIT = 7,
|
70
|
+
/**
|
71
|
+
* Offset Clause
|
72
|
+
*/
|
73
|
+
OFFSET = 7.1
|
74
|
+
}
|
75
|
+
export declare const MandatoryPriorities: Priority[];
|
76
|
+
export declare enum StatementType {
|
77
|
+
QUERY = "query",
|
78
|
+
TRANSACTION = "transaction"
|
79
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
export * from "./clauses";
|
2
|
+
export * from "./Clause";
|
3
|
+
export * from "./ClauseFactory";
|
4
|
+
export * from "./Condition";
|
5
|
+
export * from "./constants";
|
6
|
+
export * from "./errors";
|
7
|
+
export * from "./options";
|
8
|
+
export * from "./Paginator";
|
9
|
+
export * from "./Query";
|
10
|
+
export * from "./selectors";
|
11
|
+
export * from "./Statement";
|
12
|
+
export * from "./types";
|