@decaf-ts/core 0.5.1 → 0.5.2
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 +21 -157
- package/README.md +652 -15
- package/dist/core.cjs +2110 -132
- package/dist/core.esm.cjs +2111 -133
- package/lib/esm/identity/decorators.d.ts +52 -7
- package/lib/esm/identity/decorators.js +53 -8
- package/lib/esm/identity/utils.d.ts +19 -0
- package/lib/esm/identity/utils.js +20 -1
- package/lib/esm/index.d.ts +9 -2
- package/lib/esm/index.js +10 -3
- package/lib/esm/interfaces/ErrorParser.d.ts +12 -0
- package/lib/esm/interfaces/ErrorParser.js +1 -1
- package/lib/esm/interfaces/Executor.d.ts +13 -0
- package/lib/esm/interfaces/Executor.js +1 -1
- package/lib/esm/interfaces/Observable.d.ts +27 -0
- package/lib/esm/interfaces/Observable.js +1 -1
- package/lib/esm/interfaces/Observer.d.ts +12 -0
- package/lib/esm/interfaces/Observer.js +1 -1
- package/lib/esm/interfaces/Paginatable.d.ts +15 -0
- package/lib/esm/interfaces/Paginatable.js +1 -1
- package/lib/esm/interfaces/Queriable.d.ts +34 -9
- package/lib/esm/interfaces/Queriable.js +1 -1
- package/lib/esm/interfaces/RawExecutor.d.ts +14 -0
- package/lib/esm/interfaces/RawExecutor.js +1 -1
- package/lib/esm/interfaces/SequenceOptions.d.ts +52 -0
- package/lib/esm/interfaces/SequenceOptions.js +19 -1
- package/lib/esm/model/BaseModel.d.ts +31 -0
- package/lib/esm/model/BaseModel.js +24 -1
- package/lib/esm/model/construction.d.ts +433 -0
- package/lib/esm/model/construction.js +441 -2
- package/lib/esm/model/decorators.d.ts +159 -29
- package/lib/esm/model/decorators.js +160 -30
- package/lib/esm/model/types.d.ts +9 -0
- package/lib/esm/model/types.js +1 -1
- package/lib/esm/persistence/Adapter.d.ts +358 -17
- package/lib/esm/persistence/Adapter.js +287 -19
- package/lib/esm/persistence/Dispatch.d.ts +114 -1
- package/lib/esm/persistence/Dispatch.js +102 -4
- package/lib/esm/persistence/ObserverHandler.d.ts +95 -0
- package/lib/esm/persistence/ObserverHandler.js +96 -1
- package/lib/esm/persistence/Sequence.d.ts +89 -0
- package/lib/esm/persistence/Sequence.js +70 -1
- package/lib/esm/persistence/constants.d.ts +22 -0
- package/lib/esm/persistence/constants.js +23 -1
- package/lib/esm/persistence/decorators.d.ts +10 -0
- package/lib/esm/persistence/decorators.js +11 -1
- package/lib/esm/persistence/errors.d.ts +23 -0
- package/lib/esm/persistence/errors.js +24 -1
- package/lib/esm/persistence/types.d.ts +18 -0
- package/lib/esm/persistence/types.js +1 -1
- package/lib/esm/query/Condition.d.ts +78 -31
- package/lib/esm/query/Condition.js +132 -53
- package/lib/esm/query/Paginator.d.ts +56 -0
- package/lib/esm/query/Paginator.js +57 -1
- package/lib/esm/query/Statement.d.ts +51 -0
- package/lib/esm/query/Statement.js +52 -1
- package/lib/esm/query/constants.d.ts +25 -0
- package/lib/esm/query/constants.js +26 -1
- package/lib/esm/query/errors.d.ts +14 -0
- package/lib/esm/query/errors.js +15 -1
- package/lib/esm/query/options.d.ts +21 -3
- package/lib/esm/query/options.js +1 -1
- package/lib/esm/query/selectors.d.ts +26 -0
- package/lib/esm/query/selectors.js +1 -1
- package/lib/esm/ram/RamAdapter.d.ts +311 -0
- package/lib/esm/ram/RamAdapter.js +312 -1
- package/lib/esm/ram/RamContext.d.ts +16 -1
- package/lib/esm/ram/RamContext.js +18 -3
- package/lib/esm/ram/RamPaginator.d.ts +43 -0
- package/lib/esm/ram/RamPaginator.js +54 -2
- package/lib/esm/ram/RamSequence.d.ts +61 -0
- package/lib/esm/ram/RamSequence.js +63 -2
- package/lib/esm/ram/RamStatement.d.ts +74 -0
- package/lib/esm/ram/RamStatement.js +75 -1
- package/lib/esm/ram/constants.d.ts +8 -0
- package/lib/esm/ram/constants.js +9 -1
- package/lib/esm/ram/handlers.d.ts +19 -0
- package/lib/esm/ram/handlers.js +20 -1
- package/lib/esm/ram/model/RamSequence.d.ts +25 -0
- package/lib/esm/ram/model/RamSequence.js +19 -1
- package/lib/esm/ram/types.d.ts +42 -0
- package/lib/esm/ram/types.js +1 -1
- package/lib/esm/repository/Repository.d.ts +363 -8
- package/lib/esm/repository/Repository.js +361 -16
- package/lib/esm/repository/constants.d.ts +25 -0
- package/lib/esm/repository/constants.js +26 -1
- package/lib/esm/repository/decorators.d.ts +27 -0
- package/lib/esm/repository/decorators.js +28 -1
- package/lib/esm/repository/errors.d.ts +12 -5
- package/lib/esm/repository/errors.js +13 -6
- package/lib/esm/repository/injectables.d.ts +18 -0
- package/lib/esm/repository/injectables.js +19 -1
- package/lib/esm/repository/types.d.ts +15 -0
- package/lib/esm/repository/types.js +1 -1
- package/lib/esm/repository/utils.d.ts +11 -0
- package/lib/esm/repository/utils.js +12 -1
- package/lib/esm/utils/decorators.d.ts +8 -0
- package/lib/esm/utils/decorators.js +9 -1
- package/lib/esm/utils/errors.d.ts +46 -0
- package/lib/esm/utils/errors.js +47 -1
- package/lib/identity/decorators.cjs +53 -8
- package/lib/identity/decorators.d.ts +52 -7
- package/lib/identity/utils.cjs +20 -1
- package/lib/identity/utils.d.ts +19 -0
- package/lib/index.cjs +10 -3
- package/lib/index.d.ts +9 -2
- package/lib/interfaces/ErrorParser.cjs +1 -1
- package/lib/interfaces/ErrorParser.d.ts +12 -0
- package/lib/interfaces/Executor.cjs +1 -1
- package/lib/interfaces/Executor.d.ts +13 -0
- package/lib/interfaces/Observable.cjs +1 -1
- package/lib/interfaces/Observable.d.ts +27 -0
- package/lib/interfaces/Observer.cjs +1 -1
- package/lib/interfaces/Observer.d.ts +12 -0
- package/lib/interfaces/Paginatable.cjs +1 -1
- package/lib/interfaces/Paginatable.d.ts +15 -0
- package/lib/interfaces/Queriable.cjs +1 -1
- package/lib/interfaces/Queriable.d.ts +34 -9
- package/lib/interfaces/RawExecutor.cjs +1 -1
- package/lib/interfaces/RawExecutor.d.ts +14 -0
- package/lib/interfaces/SequenceOptions.cjs +19 -1
- package/lib/interfaces/SequenceOptions.d.ts +52 -0
- package/lib/model/BaseModel.cjs +24 -1
- package/lib/model/BaseModel.d.ts +31 -0
- package/lib/model/construction.cjs +441 -2
- package/lib/model/construction.d.ts +433 -0
- package/lib/model/decorators.cjs +160 -30
- package/lib/model/decorators.d.ts +159 -29
- package/lib/model/types.cjs +1 -1
- package/lib/model/types.d.ts +9 -0
- package/lib/persistence/Adapter.cjs +287 -19
- package/lib/persistence/Adapter.d.ts +358 -17
- package/lib/persistence/Dispatch.cjs +102 -4
- package/lib/persistence/Dispatch.d.ts +114 -1
- package/lib/persistence/ObserverHandler.cjs +96 -1
- package/lib/persistence/ObserverHandler.d.ts +95 -0
- package/lib/persistence/Sequence.cjs +70 -1
- package/lib/persistence/Sequence.d.ts +89 -0
- package/lib/persistence/constants.cjs +23 -1
- package/lib/persistence/constants.d.ts +22 -0
- package/lib/persistence/decorators.cjs +11 -1
- package/lib/persistence/decorators.d.ts +10 -0
- package/lib/persistence/errors.cjs +24 -1
- package/lib/persistence/errors.d.ts +23 -0
- package/lib/persistence/types.cjs +1 -1
- package/lib/persistence/types.d.ts +18 -0
- package/lib/query/Condition.cjs +132 -53
- package/lib/query/Condition.d.ts +78 -31
- package/lib/query/Paginator.cjs +57 -1
- package/lib/query/Paginator.d.ts +56 -0
- package/lib/query/Statement.cjs +52 -1
- package/lib/query/Statement.d.ts +51 -0
- package/lib/query/constants.cjs +26 -1
- package/lib/query/constants.d.ts +25 -0
- package/lib/query/errors.cjs +15 -1
- package/lib/query/errors.d.ts +14 -0
- package/lib/query/options.cjs +1 -1
- package/lib/query/options.d.ts +21 -3
- package/lib/query/selectors.cjs +1 -1
- package/lib/query/selectors.d.ts +26 -0
- package/lib/ram/RamAdapter.cjs +312 -1
- package/lib/ram/RamAdapter.d.ts +311 -0
- package/lib/ram/RamContext.cjs +18 -3
- package/lib/ram/RamContext.d.ts +16 -1
- package/lib/ram/RamPaginator.cjs +54 -2
- package/lib/ram/RamPaginator.d.ts +43 -0
- package/lib/ram/RamSequence.cjs +63 -2
- package/lib/ram/RamSequence.d.ts +61 -0
- package/lib/ram/RamStatement.cjs +75 -1
- package/lib/ram/RamStatement.d.ts +74 -0
- package/lib/ram/constants.cjs +9 -1
- package/lib/ram/constants.d.ts +8 -0
- package/lib/ram/handlers.cjs +20 -1
- package/lib/ram/handlers.d.ts +19 -0
- package/lib/ram/model/RamSequence.cjs +19 -1
- package/lib/ram/model/RamSequence.d.ts +25 -0
- package/lib/ram/types.cjs +1 -1
- package/lib/ram/types.d.ts +42 -0
- package/lib/repository/Repository.cjs +360 -15
- package/lib/repository/Repository.d.ts +363 -8
- package/lib/repository/constants.cjs +26 -1
- package/lib/repository/constants.d.ts +25 -0
- package/lib/repository/decorators.cjs +28 -1
- package/lib/repository/decorators.d.ts +27 -0
- package/lib/repository/errors.cjs +13 -6
- package/lib/repository/errors.d.ts +12 -5
- package/lib/repository/injectables.cjs +19 -1
- package/lib/repository/injectables.d.ts +18 -0
- package/lib/repository/types.cjs +1 -1
- package/lib/repository/types.d.ts +15 -0
- package/lib/repository/utils.cjs +12 -1
- package/lib/repository/utils.d.ts +11 -0
- package/lib/utils/decorators.cjs +9 -1
- package/lib/utils/decorators.d.ts +8 -0
- package/lib/utils/errors.cjs +47 -1
- package/lib/utils/errors.d.ts +46 -0
- package/package.json +5 -5
@@ -1,14 +1,103 @@
|
|
1
1
|
import { Constructor, Model } from "@decaf-ts/decorator-validation";
|
2
2
|
import { SequenceOptions } from "../interfaces/SequenceOptions";
|
3
3
|
import { Logger } from "@decaf-ts/logging";
|
4
|
+
/**
|
5
|
+
* @description Abstract base class for sequence generation
|
6
|
+
* @summary Provides a framework for generating sequential values (like primary keys) in the persistence layer.
|
7
|
+
* Implementations of this class handle the specifics of how sequences are stored and incremented in different
|
8
|
+
* database systems.
|
9
|
+
* @param {SequenceOptions} options - Configuration options for the sequence generator
|
10
|
+
* @class Sequence
|
11
|
+
* @example
|
12
|
+
* ```typescript
|
13
|
+
* // Example implementation for a specific database
|
14
|
+
* class PostgresSequence extends Sequence {
|
15
|
+
* constructor(options: SequenceOptions) {
|
16
|
+
* super(options);
|
17
|
+
* }
|
18
|
+
*
|
19
|
+
* async next(): Promise<number> {
|
20
|
+
* // Implementation to get next value from PostgreSQL sequence
|
21
|
+
* const result = await this.options.executor.raw(`SELECT nextval('${this.options.name}')`);
|
22
|
+
* return parseInt(result.rows[0].nextval);
|
23
|
+
* }
|
24
|
+
*
|
25
|
+
* async current(): Promise<number> {
|
26
|
+
* // Implementation to get current value from PostgreSQL sequence
|
27
|
+
* const result = await this.options.executor.raw(`SELECT currval('${this.options.name}')`);
|
28
|
+
* return parseInt(result.rows[0].currval);
|
29
|
+
* }
|
30
|
+
*
|
31
|
+
* async range(count: number): Promise<number[]> {
|
32
|
+
* // Implementation to get a range of values
|
33
|
+
* const values: number[] = [];
|
34
|
+
* for (let i = 0; i < count; i++) {
|
35
|
+
* values.push(await this.next());
|
36
|
+
* }
|
37
|
+
* return values;
|
38
|
+
* }
|
39
|
+
* }
|
40
|
+
*
|
41
|
+
* // Usage
|
42
|
+
* const sequence = new PostgresSequence({
|
43
|
+
* name: 'user_id_seq',
|
44
|
+
* executor: dbExecutor
|
45
|
+
* });
|
46
|
+
*
|
47
|
+
* const nextId = await sequence.next();
|
48
|
+
* ```
|
49
|
+
*/
|
4
50
|
export declare abstract class Sequence {
|
5
51
|
protected readonly options: SequenceOptions;
|
52
|
+
/**
|
53
|
+
* @description Logger instance for this sequence
|
54
|
+
* @summary Lazily initialized logger for the sequence instance
|
55
|
+
*/
|
6
56
|
private logger;
|
57
|
+
/**
|
58
|
+
* @description Accessor for the logger instance
|
59
|
+
* @summary Gets or initializes the logger for this sequence
|
60
|
+
* @return {Logger} The logger instance
|
61
|
+
*/
|
7
62
|
protected get log(): Logger;
|
63
|
+
/**
|
64
|
+
* @description Creates a new sequence instance
|
65
|
+
* @summary Protected constructor that initializes the sequence with the provided options
|
66
|
+
*/
|
8
67
|
protected constructor(options: SequenceOptions);
|
68
|
+
/**
|
69
|
+
* @description Gets the next value in the sequence
|
70
|
+
* @summary Retrieves the next value from the sequence, incrementing it in the process
|
71
|
+
* @return A promise that resolves to the next value in the sequence
|
72
|
+
*/
|
9
73
|
abstract next(): Promise<string | number | bigint>;
|
74
|
+
/**
|
75
|
+
* @description Gets the current value of the sequence
|
76
|
+
* @summary Retrieves the current value of the sequence without incrementing it
|
77
|
+
* @return A promise that resolves to the current value in the sequence
|
78
|
+
*/
|
10
79
|
abstract current(): Promise<string | number | bigint>;
|
80
|
+
/**
|
81
|
+
* @description Gets a range of sequential values
|
82
|
+
* @summary Retrieves multiple sequential values at once, which can be more efficient than calling next() multiple times
|
83
|
+
* @param {number} count - The number of sequential values to retrieve
|
84
|
+
* @return A promise that resolves to an array of sequential values
|
85
|
+
*/
|
11
86
|
abstract range(count: number): Promise<(number | string | bigint)[]>;
|
87
|
+
/**
|
88
|
+
* @description Gets the primary key sequence name for a model
|
89
|
+
* @summary Utility method that returns the standardized sequence name for a model's primary key
|
90
|
+
* @template M - The model type
|
91
|
+
* @param {M|Constructor<M>} model - The model instance or constructor
|
92
|
+
* @return {string} The sequence name for the model's primary key
|
93
|
+
*/
|
12
94
|
static pk<M extends Model>(model: M | Constructor<M>): string;
|
95
|
+
/**
|
96
|
+
* @description Parses a sequence value to the appropriate type
|
97
|
+
* @summary Converts a sequence value to the specified type (Number or BigInt)
|
98
|
+
* @param {"Number"|"BigInt"|undefined} type - The target type to convert to
|
99
|
+
* @param {string|number|bigint} value - The value to convert
|
100
|
+
* @return {string|number|bigint} The converted value
|
101
|
+
*/
|
13
102
|
static parseValue(type: "Number" | "BigInt" | undefined, value: string | number | bigint): string | number | bigint;
|
14
103
|
}
|
@@ -1,18 +1,87 @@
|
|
1
1
|
import { sequenceNameForModel } from "../identity/utils";
|
2
2
|
import { InternalError } from "@decaf-ts/db-decorators";
|
3
3
|
import { Logging } from "@decaf-ts/logging";
|
4
|
+
/**
|
5
|
+
* @description Abstract base class for sequence generation
|
6
|
+
* @summary Provides a framework for generating sequential values (like primary keys) in the persistence layer.
|
7
|
+
* Implementations of this class handle the specifics of how sequences are stored and incremented in different
|
8
|
+
* database systems.
|
9
|
+
* @param {SequenceOptions} options - Configuration options for the sequence generator
|
10
|
+
* @class Sequence
|
11
|
+
* @example
|
12
|
+
* ```typescript
|
13
|
+
* // Example implementation for a specific database
|
14
|
+
* class PostgresSequence extends Sequence {
|
15
|
+
* constructor(options: SequenceOptions) {
|
16
|
+
* super(options);
|
17
|
+
* }
|
18
|
+
*
|
19
|
+
* async next(): Promise<number> {
|
20
|
+
* // Implementation to get next value from PostgreSQL sequence
|
21
|
+
* const result = await this.options.executor.raw(`SELECT nextval('${this.options.name}')`);
|
22
|
+
* return parseInt(result.rows[0].nextval);
|
23
|
+
* }
|
24
|
+
*
|
25
|
+
* async current(): Promise<number> {
|
26
|
+
* // Implementation to get current value from PostgreSQL sequence
|
27
|
+
* const result = await this.options.executor.raw(`SELECT currval('${this.options.name}')`);
|
28
|
+
* return parseInt(result.rows[0].currval);
|
29
|
+
* }
|
30
|
+
*
|
31
|
+
* async range(count: number): Promise<number[]> {
|
32
|
+
* // Implementation to get a range of values
|
33
|
+
* const values: number[] = [];
|
34
|
+
* for (let i = 0; i < count; i++) {
|
35
|
+
* values.push(await this.next());
|
36
|
+
* }
|
37
|
+
* return values;
|
38
|
+
* }
|
39
|
+
* }
|
40
|
+
*
|
41
|
+
* // Usage
|
42
|
+
* const sequence = new PostgresSequence({
|
43
|
+
* name: 'user_id_seq',
|
44
|
+
* executor: dbExecutor
|
45
|
+
* });
|
46
|
+
*
|
47
|
+
* const nextId = await sequence.next();
|
48
|
+
* ```
|
49
|
+
*/
|
4
50
|
export class Sequence {
|
51
|
+
/**
|
52
|
+
* @description Accessor for the logger instance
|
53
|
+
* @summary Gets or initializes the logger for this sequence
|
54
|
+
* @return {Logger} The logger instance
|
55
|
+
*/
|
5
56
|
get log() {
|
6
57
|
if (!this.logger)
|
7
58
|
this.logger = Logging.for(this);
|
8
59
|
return this.logger;
|
9
60
|
}
|
61
|
+
/**
|
62
|
+
* @description Creates a new sequence instance
|
63
|
+
* @summary Protected constructor that initializes the sequence with the provided options
|
64
|
+
*/
|
10
65
|
constructor(options) {
|
11
66
|
this.options = options;
|
12
67
|
}
|
68
|
+
/**
|
69
|
+
* @description Gets the primary key sequence name for a model
|
70
|
+
* @summary Utility method that returns the standardized sequence name for a model's primary key
|
71
|
+
* @template M - The model type
|
72
|
+
* @param {M|Constructor<M>} model - The model instance or constructor
|
73
|
+
* @return {string} The sequence name for the model's primary key
|
74
|
+
*/
|
13
75
|
static pk(model) {
|
14
76
|
return sequenceNameForModel(model, "pk");
|
15
77
|
}
|
78
|
+
/**
|
79
|
+
* @description Parses a sequence value to the appropriate type
|
80
|
+
* @summary Converts a sequence value to the specified type (Number or BigInt)
|
81
|
+
* @param {"Number"|"BigInt"|undefined} type - The target type to convert to
|
82
|
+
* @param {string|number|bigint} value - The value to convert
|
83
|
+
* @return {string|number|bigint} The converted value
|
84
|
+
*/
|
16
85
|
static parseValue(type, value) {
|
17
86
|
switch (type) {
|
18
87
|
case "Number":
|
@@ -28,4 +97,4 @@ export class Sequence {
|
|
28
97
|
}
|
29
98
|
}
|
30
99
|
}
|
31
|
-
//# sourceMappingURL=data:application/json;base64,
|
100
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU2VxdWVuY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvcGVyc2lzdGVuY2UvU2VxdWVuY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLG9CQUFvQixFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFFekQsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBQ3hELE9BQU8sRUFBVSxPQUFPLEVBQUUsTUFBTSxtQk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x1ZSA9PT0gXCJudW1iZXJcIlxuICAgICAgICAgICAgPyB2YWx1ZVxuICAgICAgICAgICAgOiBCaWdJbnQodmFsdWUpO1xuICAgICAgY2FzZSBcIkJpZ0ludFwiOlxuICAgICAgICByZXR1cm4gQmlnSW50KHZhbHVlKTtcbiAgICAgIGRlZmF1bHQ6XG4gICAgICAgIHRocm93IG5ldyBJbnRlcm5hbEVycm9yKFwiU2hvdWxkIG5ldmVyIGhhcHBlblwiKTtcbiAgICB9XG4gIH1cbn1cbiJdfQ==
|
@@ -1,17 +1,39 @@
|
|
1
|
+
/**
|
2
|
+
* @description Persistence-related constant keys
|
3
|
+
* @summary Enum containing string constants used throughout the persistence layer for metadata, relations, and other persistence-related operations
|
4
|
+
* @enum {string}
|
5
|
+
* @readonly
|
6
|
+
* @memberOf module:core
|
7
|
+
*/
|
1
8
|
export declare enum PersistenceKeys {
|
9
|
+
/** @description Key for index metadata */
|
2
10
|
INDEX = "index",
|
11
|
+
/** @description Key for unique constraint metadata */
|
3
12
|
UNIQUE = "unique",
|
13
|
+
/** @description Key for adapter metadata */
|
4
14
|
ADAPTER = "adapter",
|
15
|
+
/** @description Template for injectable adapter names */
|
5
16
|
INJECTABLE = "decaf_{0}_adapter_for_{1}",
|
17
|
+
/** @description Key for table name metadata */
|
6
18
|
TABLE = "table",
|
19
|
+
/** @description Key for column name metadata */
|
7
20
|
COLUMN = "column",
|
21
|
+
/** @description Key for general metadata storage */
|
8
22
|
METADATA = "__metadata",
|
23
|
+
/** @description Key for relations metadata storage */
|
9
24
|
RELATIONS = "__relations",
|
25
|
+
/** @description Key for clause sequence metadata */
|
10
26
|
CLAUSE_SEQUENCE = "clause-sequence",
|
27
|
+
/** @description Key for created-by ownership metadata */
|
11
28
|
CREATED_BY = "ownership.created-by",
|
29
|
+
/** @description Key for updated-by ownership metadata */
|
12
30
|
UPDATED_BY = "ownership.updated-by",
|
31
|
+
/** @description Key for one-to-one relation metadata */
|
13
32
|
ONE_TO_ONE = "relations.one-to-one",
|
33
|
+
/** @description Key for one-to-many relation metadata */
|
14
34
|
ONE_TO_MANY = "relations.one-to-many",
|
35
|
+
/** @description Key for many-to-one relation metadata */
|
15
36
|
MANY_TO_ONE = "relations.many-to-one",
|
37
|
+
/** @description Key for populate metadata */
|
16
38
|
POPULATE = "populate"
|
17
39
|
}
|
@@ -1,21 +1,43 @@
|
|
1
|
+
/**
|
2
|
+
* @description Persistence-related constant keys
|
3
|
+
* @summary Enum containing string constants used throughout the persistence layer for metadata, relations, and other persistence-related operations
|
4
|
+
* @enum {string}
|
5
|
+
* @readonly
|
6
|
+
* @memberOf module:core
|
7
|
+
*/
|
1
8
|
export var PersistenceKeys;
|
2
9
|
(function (PersistenceKeys) {
|
10
|
+
/** @description Key for index metadata */
|
3
11
|
PersistenceKeys["INDEX"] = "index";
|
12
|
+
/** @description Key for unique constraint metadata */
|
4
13
|
PersistenceKeys["UNIQUE"] = "unique";
|
14
|
+
/** @description Key for adapter metadata */
|
5
15
|
PersistenceKeys["ADAPTER"] = "adapter";
|
16
|
+
/** @description Template for injectable adapter names */
|
6
17
|
PersistenceKeys["INJECTABLE"] = "decaf_{0}_adapter_for_{1}";
|
18
|
+
/** @description Key for table name metadata */
|
7
19
|
PersistenceKeys["TABLE"] = "table";
|
20
|
+
/** @description Key for column name metadata */
|
8
21
|
PersistenceKeys["COLUMN"] = "column";
|
22
|
+
/** @description Key for general metadata storage */
|
9
23
|
PersistenceKeys["METADATA"] = "__metadata";
|
24
|
+
/** @description Key for relations metadata storage */
|
10
25
|
PersistenceKeys["RELATIONS"] = "__relations";
|
26
|
+
/** @description Key for clause sequence metadata */
|
11
27
|
PersistenceKeys["CLAUSE_SEQUENCE"] = "clause-sequence";
|
12
28
|
// Ownership
|
29
|
+
/** @description Key for created-by ownership metadata */
|
13
30
|
PersistenceKeys["CREATED_BY"] = "ownership.created-by";
|
31
|
+
/** @description Key for updated-by ownership metadata */
|
14
32
|
PersistenceKeys["UPDATED_BY"] = "ownership.updated-by";
|
15
33
|
// Relations
|
34
|
+
/** @description Key for one-to-one relation metadata */
|
16
35
|
PersistenceKeys["ONE_TO_ONE"] = "relations.one-to-one";
|
36
|
+
/** @description Key for one-to-many relation metadata */
|
17
37
|
PersistenceKeys["ONE_TO_MANY"] = "relations.one-to-many";
|
38
|
+
/** @description Key for many-to-one relation metadata */
|
18
39
|
PersistenceKeys["MANY_TO_ONE"] = "relations.many-to-one";
|
40
|
+
/** @description Key for populate metadata */
|
19
41
|
PersistenceKeys["POPULATE"] = "populate";
|
20
42
|
})(PersistenceKeys || (PersistenceKeys = {}));
|
21
|
-
//# sourceMappingURL=data:application/json;base64,
|
43
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RhbnRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3BlcnNpc3RlbmNlL2NvbnN0YW50cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFDSCxNQUFNLENBQU4sSUFBWSxlQStDWDtBQS9DRCxXQUFZLGVBQWU7SUFDekIsMENBQTBDO0lBQzFDLGtDQUFlLENBQUE7SUFFZixzREFBc0Q7SUFDdEQsb0NBQWlCLENBQUE7SUFFakIsNENBQTRDO0lBQzVDLHNDQUFtQixDQUFBO0lBRW5CLHlEQUF5RDtJQUN6RCwyREFBd0MsQ0FBQTtJQUV4QywrQ0FBK0M7SUFDL0Msa0NBQWUsQ0FBQTtJQUVmLGdEQUFnRDtJQUNoRCxvQ0FBaUIsQ0FBQTtJQUVqQixvREFBb0Q7SUFDcEQsMENBQXVCLENBQUE7SUFFdkIsc0RBQXNEO0lBQ3RELDRDQUF5QixDQUFBO0lBRXpCLG9EQUFvRDtJQUNwRCxzREFBbUMsQ0FBQTtJQUVuQyxZQUFZO0lBQ1oseURBQXlEO0lBQ3pELHNEQUFtQyxDQUFBO0lBRW5DLHlEQUF5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kUgPSBcInJlbGF0aW9ucy5vbmUtdG8tb25lXCIsXG5cbiAgLyoqIEBkZXNjcmlwdGlvbiBLZXkgZm9yIG9uZS10by1tYW55IHJlbGF0aW9uIG1ldGFkYXRhICovXG4gIE9ORV9UT19NQU5ZID0gXCJyZWxhdGlvbnMub25lLXRvLW1hbnlcIixcblxuICAvKiogQGRlc2NyaXB0aW9uIEtleSBmb3IgbWFueS10by1vbmUgcmVsYXRpb24gbWV0YWRhdGEgKi9cbiAgTUFOWV9UT19PTkUgPSBcInJlbGF0aW9ucy5tYW55LXRvLW9uZVwiLFxuXG4gIC8qKiBAZGVzY3JpcHRpb24gS2V5IGZvciBwb3B1bGF0ZSBtZXRhZGF0YSAqL1xuICBQT1BVTEFURSA9IFwicG9wdWxhdGVcIixcbn1cbiJdfQ==
|
@@ -1 +1,11 @@
|
|
1
|
+
/**
|
2
|
+
* @description Specifies which persistence adapter flavor a model should use
|
3
|
+
* @summary This decorator applies metadata to a model class to indicate which persistence adapter flavor
|
4
|
+
* should be used when performing database operations on instances of the model. The flavor is a string
|
5
|
+
* identifier that corresponds to a registered adapter configuration.
|
6
|
+
* @param {string} flavour - The identifier of the adapter flavor to use
|
7
|
+
* @return {Function} A decorator function that can be applied to a model class
|
8
|
+
* @function uses
|
9
|
+
* @category Class Decorators
|
10
|
+
*/
|
1
11
|
export declare function uses(flavour: string): (target: object, propertyKey?: string | symbol | unknown, descriptor?: PropertyDescriptor) => void;
|
@@ -1,7 +1,17 @@
|
|
1
1
|
import { apply, metadata } from "@decaf-ts/reflection";
|
2
2
|
import { PersistenceKeys } from "./constants";
|
3
3
|
import { Adapter } from "./Adapter";
|
4
|
+
/**
|
5
|
+
* @description Specifies which persistence adapter flavor a model should use
|
6
|
+
* @summary This decorator applies metadata to a model class to indicate which persistence adapter flavor
|
7
|
+
* should be used when performing database operations on instances of the model. The flavor is a string
|
8
|
+
* identifier that corresponds to a registered adapter configuration.
|
9
|
+
* @param {string} flavour - The identifier of the adapter flavor to use
|
10
|
+
* @return {Function} A decorator function that can be applied to a model class
|
11
|
+
* @function uses
|
12
|
+
* @category Class Decorators
|
13
|
+
*/
|
4
14
|
export function uses(flavour) {
|
5
15
|
return apply(metadata(Adapter.key(PersistenceKeys.ADAPTER), flavour));
|
6
16
|
}
|
7
|
-
//# sourceMappingURL=data:application/json;base64,
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVjb3JhdG9ycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wZXJzaXN0ZW5jZS9kZWNvcmF0b3JzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxLQUFLLEVBQUUsUUFBUSxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDdkQsT0FBTyxFQUFFLGVBQWUsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUM5QyxPQUFPLEVBQUUsT0FBTyxFQUFFLE1BQU0sV0FBVyxDQUFDO0FBRXBDOzs7Ozs7Ozs7R0FTRztBQUNILE1BQU0sVUFBVSxJQUFJLENBQUMsT0FBZTtJQUNsQyxPQUFPLEtBQUssQ0FBQyxRQUFRLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxlQUFlLENBQUMsT0FBTyxDQUFDLEVBQUUsT0FBTyxDQUFDLENBQUMsQ0FBQztBQUN4RSxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgYXBwbHksIG1ldGFkYXRhIH0gZnJvbSBcIkBkZWNhZi10cy9yZWZsZWN0aW9uXCI7XG5pbXBvcnQgeyBQZXJzaXN0ZW5jZUtleXMgfSBmcm9tIFwiLi9jb25zdGFudHNcIjtcbmltcG9ydCB7IEFkYXB0ZXIgfSBmcm9tIFwiLi9BZGFwdGVyXCI7XG5cbi8qKlxuICogQGRlc2NyaXB0aW9uIFNwZWNpZmllcyB3aGljaCBwZXJzaXN0ZW5jZSBhZGFwdGVyIGZsYXZvciBhIG1vZGVsIHNob3VsZCB1c2VcbiAqIEBzdW1tYXJ5IFRoaXMgZGVjb3JhdG9yIGFwcGxpZXMgbWV0YWRhdGEgdG8gYSBtb2RlbCBjbGFzcyB0byBpbmRpY2F0ZSB3aGljaCBwZXJzaXN0ZW5jZSBhZGFwdGVyIGZsYXZvclxuICogc2hvdWxkIGJlIHVzZWQgd2hlbiBwZXJmb3JtaW5nIGRhdGFiYXNlIG9wZXJhdGlvbnMgb24gaW5zdGFuY2VzIG9mIHRoZSBtb2RlbC4gVGhlIGZsYXZvciBpcyBhIHN0cmluZ1xuICogaWRlbnRpZmllciB0aGF0IGNvcnJlc3BvbmRzIHRvIGEgcmVnaXN0ZXJlZCBhZGFwdGVyIGNvbmZpZ3VyYXRpb24uXG4gKiBAcGFyYW0ge3N0cmluZ30gZmxhdm91ciAtIFRoZSBpZGVudGlmaWVyIG9mIHRoZSBhZGFwdGVyIGZsYXZvciB0byB1c2VcbiAqIEByZXR1cm4ge0Z1bmN0aW9ufSBBIGRlY29yYXRvciBmdW5jdGlvbiB0aGF0IGNhbiBiZSBhcHBsaWVkIHRvIGEgbW9kZWwgY2xhc3NcbiAqIEBmdW5jdGlvbiB1c2VzXG4gKiBAY2F0ZWdvcnkgQ2xhc3MgRGVjb3JhdG9yc1xuICovXG5leHBvcnQgZnVuY3Rpb24gdXNlcyhmbGF2b3VyOiBzdHJpbmcpIHtcbiAgcmV0dXJuIGFwcGx5KG1ldGFkYXRhKEFkYXB0ZXIua2V5KFBlcnNpc3RlbmNlS2V5cy5BREFQVEVSKSwgZmxhdm91cikpO1xufVxuIl19
|
@@ -1,4 +1,27 @@
|
|
1
1
|
import { BaseError } from "@decaf-ts/db-decorators";
|
2
|
+
/**
|
3
|
+
* @description Error thrown when an unsupported operation is attempted
|
4
|
+
* @summary This error is thrown when an operation is requested that is not supported by the current
|
5
|
+
* persistence adapter or configuration. It extends the BaseError class and sets a 500 status code.
|
6
|
+
* @param {string|Error} msg - The error message or an Error object to wrap
|
7
|
+
* @class UnsupportedError
|
8
|
+
* @example
|
9
|
+
* ```typescript
|
10
|
+
* // Throwing an UnsupportedError
|
11
|
+
* if (!adapter.supportsTransactions()) {
|
12
|
+
* throw new UnsupportedError('Transactions are not supported by this adapter');
|
13
|
+
* }
|
14
|
+
*
|
15
|
+
* // Catching an UnsupportedError
|
16
|
+
* try {
|
17
|
+
* await adapter.beginTransaction();
|
18
|
+
* } catch (error) {
|
19
|
+
* if (error instanceof UnsupportedError) {
|
20
|
+
* console.error('Operation not supported:', error.message);
|
21
|
+
* }
|
22
|
+
* }
|
23
|
+
* ```
|
24
|
+
*/
|
2
25
|
export declare class UnsupportedError extends BaseError {
|
3
26
|
constructor(msg: string | Error);
|
4
27
|
}
|
@@ -1,7 +1,30 @@
|
|
1
1
|
import { BaseError } from "@decaf-ts/db-decorators";
|
2
|
+
/**
|
3
|
+
* @description Error thrown when an unsupported operation is attempted
|
4
|
+
* @summary This error is thrown when an operation is requested that is not supported by the current
|
5
|
+
* persistence adapter or configuration. It extends the BaseError class and sets a 500 status code.
|
6
|
+
* @param {string|Error} msg - The error message or an Error object to wrap
|
7
|
+
* @class UnsupportedError
|
8
|
+
* @example
|
9
|
+
* ```typescript
|
10
|
+
* // Throwing an UnsupportedError
|
11
|
+
* if (!adapter.supportsTransactions()) {
|
12
|
+
* throw new UnsupportedError('Transactions are not supported by this adapter');
|
13
|
+
* }
|
14
|
+
*
|
15
|
+
* // Catching an UnsupportedError
|
16
|
+
* try {
|
17
|
+
* await adapter.beginTransaction();
|
18
|
+
* } catch (error) {
|
19
|
+
* if (error instanceof UnsupportedError) {
|
20
|
+
* console.error('Operation not supported:', error.message);
|
21
|
+
* }
|
22
|
+
* }
|
23
|
+
* ```
|
24
|
+
*/
|
2
25
|
export class UnsupportedError extends BaseError {
|
3
26
|
constructor(msg) {
|
4
27
|
super(UnsupportedError.name, msg, 500);
|
5
28
|
}
|
6
29
|
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ciBhbiBFcnJvciBvYmplY3QgdG8gd3JhcFxuICogQGNsYXNzIFVuc3VwcG9ydGVkRXJyb3JcbiAqIEBleGFtcGxlXG4gKiBgYGB0eXBlc2NyaXB0XG4gKiAvLyBUaHJvd2luZyBhbiBVbnN1cHBvcnRlZEVycm9yXG4gKiBpZiAoIWFkYXB0ZXIuc3VwcG9ydHNUcmFuc2FjdGlvbnMoKSkge1xuICogICB0aHJvdyBuZXcgVW5zdXBwb3J0ZWRFcnJvcignVHJhbnNhY3Rpb25zIGFyZSBub3Qgc3VwcG9ydGVkIGJ5IHRoaXMgYWRhcHRlcicpO1xuICogfVxuICogXG4gKiAvLyBDYXRjaGluZyBhbiBVbnN1cHBvcnRlZEVycm9yXG4gKiB0cnkge1xuICogICBhd2FpdCBhZGFwdGVyLmJlZ2luVHJhbnNhY3Rpb24oKTtcbiAqIH0gY2F0Y2ggKGVycm9yKSB7XG4gKiAgIGlmIChlcnJvciBpbnN0YW5jZW9mIFVuc3VwcG9ydGVkRXJyb3IpIHtcbiAqICAgICBjb25zb2xlLmVycm9yKCdPcGVyYXRpb24gbm90IHN1cHBvcnRlZDonLCBlcnJvci5tZXNzYWdlKTtcbiAqICAgfVxuICogfVxuICogYGBgXG4gKi9cbmV4cG9ydCBjbGFzcyBVbnN1cHBvcnRlZEVycm9yIGV4dGVuZHMgQmFzZUVycm9yIHtcbiAgY29uc3RydWN0b3IobXNnOiBzdHJpbmcgfCBFcnJvcikge1xuICAgIHN1cGVyKFVuc3VwcG9ydGVkRXJyb3IubmFtZSwgbXNnLCA1MDApO1xuICB9XG59XG4iXX0=
|
@@ -1,3 +1,21 @@
|
|
1
1
|
import { BulkCrudOperationKeys, OperationKeys } from "@decaf-ts/db-decorators";
|
2
|
+
/**
|
3
|
+
* @description Type representing possible ID formats for database events
|
4
|
+
* @summary A union type that defines the possible formats for event identifiers in the persistence layer.
|
5
|
+
* These can be single values (string, number, bigint) or arrays of these types.
|
6
|
+
* @typedef {(string|number|bigint|string[]|number[]|bigint[])} EventIds
|
7
|
+
* @memberOf module:core
|
8
|
+
*/
|
2
9
|
export type EventIds = string | number | bigint | string[] | number[] | bigint[];
|
10
|
+
/**
|
11
|
+
* @description Function type for filtering observer notifications
|
12
|
+
* @summary A function type that defines a predicate used to determine whether an observer should be notified
|
13
|
+
* about a specific database event. The filter examines the table name, event type, and affected IDs.
|
14
|
+
* @param {string} table - The name of the database table where the event occurred
|
15
|
+
* @param {(OperationKeys|BulkCrudOperationKeys|string)} event - The type of operation that triggered the event
|
16
|
+
* @param {EventIds} id - The identifier(s) of the affected record(s)
|
17
|
+
* @return {boolean} True if the observer should be notified, false otherwise
|
18
|
+
* @typedef {Function} ObserverFilter
|
19
|
+
* @memberOf module:core
|
20
|
+
*/
|
3
21
|
export type ObserverFilter = (table: string, event: OperationKeys | BulkCrudOperationKeys | string, id: EventIds) => boolean;
|
@@ -1,2 +1,2 @@
|
|
1
1
|
export {};
|
2
|
-
//# sourceMappingURL=data:application/json;base64,
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvcGVyc2lzdGVuY2UvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IEJ1bGtDcnVkT3BlcmF0aW9uS2V5cywgT3BlcmF0aW9uS2V5cyB9IGZyb20gXCJAZGVjYWYtdHMvZGItZGVjb3JhdG9yc1wiO1xuXG4vKipcbiAqIEBkZXNjcmlwdGlvbiBUeXBlIHJlcHJlc2VudGluZyBwb3NzaWJsZSBJRCBmb3JtYXRzIGZvciBkYXRhYmFzZSBldmVudHNcbiAqIEBzdW1tYXJ5IEEgdW5pb24gdHlwZSB0aGF0IGRlZmluZXMgdGhlIHBvc3NpYmxlIGZvcm1hdHMgZm9yIGV2ZW50IGlkZW50aWZpZXJ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ldmVudFxuICogQHBhcmFtIHtFdmVudElkc30gaWQgLSBUaGUgaWRlbnRpZmllcihzKSBvZiB0aGUgYWZmZWN0ZWQgcmVjb3JkKHMpXG4gKiBAcmV0dXJuIHtib29sZWFufSBUcnVlIGlmIHRoZSBvYnNlcnZlciBzaG91bGQgYmUgbm90aWZpZWQsIGZhbHNlIG90aGVyd2lzZVxuICogQHR5cGVkZWYge0Z1bmN0aW9ufSBPYnNlcnZlckZpbHRlclxuICogQG1lbWJlck9mIG1vZHVsZTpjb3JlXG4gKi9cbmV4cG9ydCB0eXBlIE9ic2VydmVyRmlsdGVyID0gKFxuICB0YWJsZTogc3RyaW5nLFxuICBldmVudDogT3BlcmF0aW9uS2V5cyB8IEJ1bGtDcnVkT3BlcmF0aW9uS2V5cyB8IHN0cmluZyxcbiAgaWQ6IEV2ZW50SWRzXG4pID0+IGJvb2xlYW47XG4iXX0=
|
@@ -2,14 +2,27 @@ import { AttributeOption, ConditionBuilderOption } from "./options";
|
|
2
2
|
import { Model, ModelErrorDefinition } from "@decaf-ts/decorator-validation";
|
3
3
|
import { GroupOperator, Operator } from "./constants";
|
4
4
|
/**
|
5
|
-
* @
|
6
|
-
* @
|
5
|
+
* @description Represents a logical condition for database queries
|
6
|
+
* @summary A class that encapsulates query conditions with support for complex logical operations.
|
7
|
+
* This class allows for building and combining query conditions using logical operators (AND, OR, NOT)
|
8
|
+
* and comparison operators (equals, not equals, greater than, etc.).
|
9
|
+
* @template M - The model type this condition operates on
|
10
|
+
* @param {string | Condition<M>} attr1 - The attribute name or a nested condition
|
11
|
+
* @param {Operator | GroupOperator} operator - The operator to use for the condition
|
12
|
+
* @param {any} comparison - The value to compare against or another condition
|
13
|
+
* @class Condition
|
14
|
+
* @example
|
15
|
+
* // Create a simple condition
|
16
|
+
* const nameCondition = Condition.attribute("name").eq("John");
|
7
17
|
*
|
8
|
-
*
|
9
|
-
*
|
10
|
-
*
|
18
|
+
* // Create a complex condition
|
19
|
+
* const complexCondition = Condition.attribute("age").gt(18)
|
20
|
+
* .and(Condition.attribute("status").eq("active"));
|
11
21
|
*
|
12
|
-
*
|
22
|
+
* // Use the builder pattern
|
23
|
+
* const userQuery = Condition.builder()
|
24
|
+
* .attribute("email").regexp(".*@example.com")
|
25
|
+
* .and(Condition.attribute("lastLogin").gt(new Date("2023-01-01")));
|
13
26
|
*/
|
14
27
|
export declare class Condition<M extends Model> extends Model {
|
15
28
|
protected attr1?: string | Condition<M>;
|
@@ -17,56 +30,90 @@ export declare class Condition<M extends Model> extends Model {
|
|
17
30
|
protected comparison?: any;
|
18
31
|
private constructor();
|
19
32
|
/**
|
20
|
-
* @
|
21
|
-
* @
|
33
|
+
* @description Combines this condition with another using logical AND
|
34
|
+
* @summary Joins two conditions with an AND operator, requiring both to be true
|
35
|
+
* @param {Condition<M>} condition - The condition to combine with this one
|
36
|
+
* @return {Condition<M>} A new condition representing the AND operation
|
22
37
|
*/
|
23
38
|
and(condition: Condition<M>): Condition<M>;
|
24
39
|
/**
|
25
|
-
* @
|
26
|
-
* @
|
40
|
+
* @description Combines this condition with another using logical OR
|
41
|
+
* @summary Joins two conditions with an OR operator, requiring at least one to be true
|
42
|
+
* @param {Condition<M>} condition - The condition to combine with this one
|
43
|
+
* @return {Condition<M>} A new condition representing the OR operation
|
27
44
|
*/
|
28
45
|
or(condition: Condition<M>): Condition<M>;
|
29
46
|
/**
|
30
|
-
* @
|
31
|
-
* @
|
47
|
+
* @description Creates a negation condition
|
48
|
+
* @summary Excludes a value from the result by applying a NOT operator
|
49
|
+
* @param {any} val - The value to negate
|
50
|
+
* @return {Condition<M>} A new condition representing the NOT operation
|
32
51
|
*/
|
33
52
|
not(val: any): Condition<M>;
|
34
53
|
/**
|
35
|
-
* @
|
54
|
+
* @description Validates the condition and checks for errors
|
55
|
+
* @summary Extends the base validation to ensure the condition is properly formed
|
56
|
+
* @param {...string[]} exceptions - Fields to exclude from validation
|
57
|
+
* @return {ModelErrorDefinition | undefined} Error definition if validation fails, undefined otherwise
|
36
58
|
*/
|
37
59
|
hasErrors(...exceptions: string[]): ModelErrorDefinition | undefined;
|
38
60
|
/**
|
39
|
-
* @
|
40
|
-
* @
|
41
|
-
* @
|
61
|
+
* @description Creates a new condition that combines two conditions with logical AND
|
62
|
+
* @summary Static method that joins two conditions with an AND operator, requiring both to be true
|
63
|
+
* @template M - The model type this condition operates on
|
64
|
+
* @param {Condition<M>} condition1 - The first condition
|
65
|
+
* @param {Condition<M>} condition2 - The second condition
|
66
|
+
* @return {Condition<M>} A new condition representing the AND operation
|
42
67
|
*/
|
43
68
|
static and<M extends Model>(condition1: Condition<M>, condition2: Condition<M>): Condition<M>;
|
44
69
|
/**
|
45
|
-
* @
|
46
|
-
* @
|
47
|
-
* @
|
70
|
+
* @description Creates a new condition that combines two conditions with logical OR
|
71
|
+
* @summary Static method that joins two conditions with an OR operator, requiring at least one to be true
|
72
|
+
* @template M - The model type this condition operates on
|
73
|
+
* @param {Condition<M>} condition1 - The first condition
|
74
|
+
* @param {Condition<M>} condition2 - The second condition
|
75
|
+
* @return {Condition<M>} A new condition representing the OR operation
|
48
76
|
*/
|
49
77
|
static or<M extends Model>(condition1: Condition<M>, condition2: Condition<M>): Condition<M>;
|
50
78
|
/**
|
51
|
-
* @
|
52
|
-
* @
|
53
|
-
* @
|
54
|
-
* @param {Condition}
|
79
|
+
* @description Creates a new condition that groups two conditions with a specified operator
|
80
|
+
* @summary Private static method that combines two conditions using the specified group operator
|
81
|
+
* @template M - The model type this condition operates on
|
82
|
+
* @param {Condition<M>} condition1 - The first condition
|
83
|
+
* @param {GroupOperator} operator - The group operator to use (AND, OR)
|
84
|
+
* @param {Condition<M>} condition2 - The second condition
|
85
|
+
* @return {Condition<M>} A new condition representing the grouped operation
|
55
86
|
*/
|
56
87
|
private static group;
|
88
|
+
/**
|
89
|
+
* @description Creates a condition builder for a specific model attribute
|
90
|
+
* @summary Static method that initializes a condition builder with the specified attribute
|
91
|
+
* @template M - The model type this condition operates on
|
92
|
+
* @param attr - The model attribute to build a condition for
|
93
|
+
* @return {AttributeOption<M>} A condition builder initialized with the attribute
|
94
|
+
*/
|
57
95
|
static attribute<M extends Model>(attr: keyof M): AttributeOption<M>;
|
96
|
+
/**
|
97
|
+
* @description Alias for the attribute method
|
98
|
+
* @summary Shorthand method that initializes a condition builder with the specified attribute
|
99
|
+
* @template M - The model type this condition operates on
|
100
|
+
* @param attr - The model attribute to build a condition for
|
101
|
+
* @return {AttributeOption<M>} A condition builder initialized with the attribute
|
102
|
+
*/
|
58
103
|
static attr<M extends Model>(attr: keyof M): AttributeOption<M>;
|
59
104
|
/**
|
60
|
-
* @
|
61
|
-
* @
|
62
|
-
*
|
105
|
+
* @description Provides a fluent API to build query conditions
|
106
|
+
* @summary A builder class that simplifies the creation of database query conditions
|
107
|
+
* with a chainable interface for setting attributes and operators
|
108
|
+
* @template M - The model type this condition builder operates on
|
63
109
|
* @class ConditionBuilder
|
64
|
-
* @implements Builder
|
65
|
-
* @implements AttributeOption
|
66
|
-
*
|
67
|
-
* @category Query
|
68
|
-
* @subcategory Conditions
|
69
110
|
*/
|
70
111
|
private static Builder;
|
112
|
+
/**
|
113
|
+
* @description Creates a new condition builder
|
114
|
+
* @summary Factory method that returns a new instance of the condition builder
|
115
|
+
* @template M - The model type this condition builder will operate on
|
116
|
+
* @return {ConditionBuilderOption<M>} A new condition builder instance
|
117
|
+
*/
|
71
118
|
static builder<M extends Model>(): ConditionBuilderOption<M>;
|
72
119
|
}
|