@decaf-ts/core 0.7.12 → 0.7.14
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 +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/lib/esm/identity/decorators.d.ts +1 -1
- package/lib/esm/identity/decorators.js +11 -4
- package/lib/esm/identity/decorators.js.map +1 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/interfaces/ContextuallyLogged.d.ts +2 -2
- package/lib/esm/model/construction.d.ts +4 -5
- package/lib/esm/model/construction.js +1 -1
- package/lib/esm/model/construction.js.map +1 -1
- package/lib/esm/model/decorators.d.ts +1 -0
- package/lib/esm/model/decorators.js +13 -6
- package/lib/esm/model/decorators.js.map +1 -1
- package/lib/esm/model/types.d.ts +1 -1
- package/lib/esm/overrides/Metadata.d.ts +4 -2
- package/lib/esm/overrides/Model.d.ts +10 -0
- package/lib/esm/overrides/decoration.d.ts +1 -0
- package/lib/esm/overrides/decoration.js +6 -0
- package/lib/esm/overrides/decoration.js.map +1 -0
- package/lib/esm/overrides/index.d.ts +1 -0
- package/lib/esm/overrides/index.js +1 -0
- package/lib/esm/overrides/index.js.map +1 -1
- package/lib/esm/overrides/overrides.js +18 -1
- package/lib/esm/overrides/overrides.js.map +1 -1
- package/lib/esm/persistence/Adapter.d.ts +8 -4
- package/lib/esm/persistence/Adapter.js +4 -3
- package/lib/esm/persistence/Adapter.js.map +1 -1
- package/lib/esm/persistence/Context.d.ts +5 -0
- package/lib/esm/persistence/Context.js +7 -0
- package/lib/esm/persistence/Context.js.map +1 -0
- package/lib/esm/persistence/Dispatch.d.ts +2 -2
- package/lib/esm/persistence/Dispatch.js.map +1 -1
- package/lib/esm/persistence/ObserverHandler.js.map +1 -1
- package/lib/esm/persistence/Sequence.d.ts +1 -1
- package/lib/esm/persistence/Sequence.js +2 -1
- package/lib/esm/persistence/Sequence.js.map +1 -1
- package/lib/esm/persistence/constants.d.ts +4 -1
- package/lib/esm/persistence/constants.js +8 -0
- package/lib/esm/persistence/constants.js.map +1 -1
- package/lib/esm/persistence/index.d.ts +1 -0
- package/lib/esm/persistence/index.js +1 -0
- package/lib/esm/persistence/index.js.map +1 -1
- package/lib/esm/persistence/migrations.js +2 -1
- package/lib/esm/persistence/migrations.js.map +1 -1
- package/lib/esm/persistence/types.d.ts +18 -5
- package/lib/esm/query/Condition.d.ts +3 -1
- package/lib/esm/query/Condition.js +11 -3
- package/lib/esm/query/Condition.js.map +1 -1
- package/lib/esm/query/MethodQueryBuilder.d.ts +0 -6
- package/lib/esm/query/MethodQueryBuilder.js +1 -1
- package/lib/esm/query/MethodQueryBuilder.js.map +1 -1
- package/lib/esm/query/Paginator.d.ts +7 -0
- package/lib/esm/query/Paginator.js.map +1 -1
- package/lib/esm/query/Statement.d.ts +17 -5
- package/lib/esm/query/Statement.js +265 -11
- package/lib/esm/query/Statement.js.map +1 -1
- package/lib/esm/query/constants.d.ts +6 -0
- package/lib/esm/query/constants.js +8 -0
- package/lib/esm/query/constants.js.map +1 -1
- package/lib/esm/query/options.d.ts +14 -9
- package/lib/esm/query/types.d.ts +19 -0
- package/lib/esm/query/types.js.map +1 -1
- package/lib/esm/ram/RamAdapter.d.ts +3 -2
- package/lib/esm/ram/RamAdapter.js +6 -3
- package/lib/esm/ram/RamAdapter.js.map +1 -1
- package/lib/esm/ram/RamPaginator.d.ts +2 -2
- package/lib/esm/ram/RamPaginator.js +4 -3
- package/lib/esm/ram/RamPaginator.js.map +1 -1
- package/lib/esm/ram/RamStatement.d.ts +1 -9
- package/lib/esm/ram/RamStatement.js +1 -18
- package/lib/esm/ram/RamStatement.js.map +1 -1
- package/lib/esm/ram/types.d.ts +3 -3
- package/lib/esm/repository/Repository.d.ts +18 -16
- package/lib/esm/repository/Repository.js +34 -12
- package/lib/esm/repository/Repository.js.map +1 -1
- package/lib/esm/utils/ContextualLoggedClass.d.ts +1 -1
- package/lib/esm/utils/ContextualLoggedClass.js +3 -3
- package/lib/esm/utils/ContextualLoggedClass.js.map +1 -1
- package/lib/esm/utils/Services.d.ts +9 -7
- package/lib/esm/utils/Services.js +7 -4
- package/lib/esm/utils/Services.js.map +1 -1
- package/lib/identity/decorators.cjs +10 -3
- package/lib/identity/decorators.d.ts +1 -1
- package/lib/identity/decorators.js.map +1 -1
- package/lib/index.cjs +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/interfaces/ContextuallyLogged.d.ts +2 -2
- package/lib/model/construction.d.ts +4 -5
- package/lib/model/construction.js.map +1 -1
- package/lib/model/decorators.cjs +14 -6
- package/lib/model/decorators.d.ts +1 -0
- package/lib/model/decorators.js.map +1 -1
- package/lib/model/types.d.ts +1 -1
- package/lib/overrides/Metadata.d.ts +4 -2
- package/lib/overrides/Model.d.ts +10 -0
- package/lib/overrides/decoration.cjs +8 -0
- package/lib/overrides/decoration.d.ts +1 -0
- package/lib/overrides/decoration.js.map +1 -0
- package/lib/overrides/index.cjs +1 -0
- package/lib/overrides/index.d.ts +1 -0
- package/lib/overrides/index.js.map +1 -1
- package/lib/overrides/overrides.cjs +30 -13
- package/lib/overrides/overrides.js.map +1 -1
- package/lib/persistence/Adapter.cjs +4 -3
- package/lib/persistence/Adapter.d.ts +8 -4
- package/lib/persistence/Adapter.js.map +1 -1
- package/lib/persistence/Context.cjs +11 -0
- package/lib/persistence/Context.d.ts +5 -0
- package/lib/persistence/Context.js.map +1 -0
- package/lib/persistence/Dispatch.d.ts +2 -2
- package/lib/persistence/Dispatch.js.map +1 -1
- package/lib/persistence/ObserverHandler.js.map +1 -1
- package/lib/persistence/Sequence.cjs +4 -3
- package/lib/persistence/Sequence.d.ts +1 -1
- package/lib/persistence/Sequence.js.map +1 -1
- package/lib/persistence/constants.cjs +9 -1
- package/lib/persistence/constants.d.ts +4 -1
- package/lib/persistence/constants.js.map +1 -1
- package/lib/persistence/index.cjs +1 -0
- package/lib/persistence/index.d.ts +1 -0
- package/lib/persistence/index.js.map +1 -1
- package/lib/persistence/migrations.cjs +2 -1
- package/lib/persistence/migrations.js.map +1 -1
- package/lib/persistence/types.d.ts +18 -5
- package/lib/query/Condition.cjs +11 -3
- package/lib/query/Condition.d.ts +3 -1
- package/lib/query/Condition.js.map +1 -1
- package/lib/query/MethodQueryBuilder.d.ts +0 -6
- package/lib/query/MethodQueryBuilder.js.map +1 -1
- package/lib/query/Paginator.d.ts +7 -0
- package/lib/query/Paginator.js.map +1 -1
- package/lib/query/Statement.cjs +262 -8
- package/lib/query/Statement.d.ts +17 -5
- package/lib/query/Statement.js.map +1 -1
- package/lib/query/constants.cjs +9 -1
- package/lib/query/constants.d.ts +6 -0
- package/lib/query/constants.js.map +1 -1
- package/lib/query/options.d.ts +14 -9
- package/lib/query/types.d.ts +19 -0
- package/lib/query/types.js.map +1 -1
- package/lib/ram/RamAdapter.cjs +4 -1
- package/lib/ram/RamAdapter.d.ts +3 -2
- package/lib/ram/RamAdapter.js.map +1 -1
- package/lib/ram/RamPaginator.cjs +4 -3
- package/lib/ram/RamPaginator.d.ts +2 -2
- package/lib/ram/RamPaginator.js.map +1 -1
- package/lib/ram/RamStatement.cjs +0 -17
- package/lib/ram/RamStatement.d.ts +1 -9
- package/lib/ram/RamStatement.js.map +1 -1
- package/lib/ram/types.d.ts +3 -3
- package/lib/repository/Repository.cjs +41 -19
- package/lib/repository/Repository.d.ts +18 -16
- package/lib/repository/Repository.js.map +1 -1
- package/lib/utils/ContextualLoggedClass.d.ts +1 -1
- package/lib/utils/ContextualLoggedClass.js.map +1 -1
- package/lib/utils/Services.cjs +9 -6
- package/lib/utils/Services.d.ts +9 -7
- package/lib/utils/Services.js.map +1 -1
- package/package.json +1 -1
package/lib/query/options.d.ts
CHANGED
|
@@ -4,6 +4,11 @@ import { Model } from "@decaf-ts/decorator-validation";
|
|
|
4
4
|
import { Condition } from "./Condition";
|
|
5
5
|
import { Paginatable } from "../interfaces/Paginatable";
|
|
6
6
|
import { Constructor } from "@decaf-ts/decoration";
|
|
7
|
+
export interface StatementExecutor<M extends Model, R> extends Executor<R>, Paginatable<M, R, any> {
|
|
8
|
+
}
|
|
9
|
+
export interface PreparableStatementExecutor<M extends Model, R> extends StatementExecutor<M, R> {
|
|
10
|
+
prepare(...args: any[]): Promise<StatementExecutor<M, R>>;
|
|
11
|
+
}
|
|
7
12
|
/**
|
|
8
13
|
* @summary GroupBy Option interface
|
|
9
14
|
* @description Exposes the GROUP BY method and remaining options
|
|
@@ -12,7 +17,7 @@ import { Constructor } from "@decaf-ts/decoration";
|
|
|
12
17
|
* @memberOf module:core
|
|
13
18
|
*/
|
|
14
19
|
export interface GroupByOption<M extends Model, R> extends Executor<R> {
|
|
15
|
-
groupBy(selector: GroupBySelector<M>):
|
|
20
|
+
groupBy(selector: GroupBySelector<M>): PreparableStatementExecutor<M, R>;
|
|
16
21
|
}
|
|
17
22
|
/**
|
|
18
23
|
* @summary Offset Option interface
|
|
@@ -21,8 +26,8 @@ export interface GroupByOption<M extends Model, R> extends Executor<R> {
|
|
|
21
26
|
* @interface GroupByOption
|
|
22
27
|
* @memberOf module:core
|
|
23
28
|
*/
|
|
24
|
-
export interface OffsetOption<R> extends
|
|
25
|
-
offset(selector: OffsetSelector):
|
|
29
|
+
export interface OffsetOption<M extends Model, R> extends PreparableStatementExecutor<M, R> {
|
|
30
|
+
offset(selector: OffsetSelector): PreparableStatementExecutor<M, R>;
|
|
26
31
|
}
|
|
27
32
|
/**
|
|
28
33
|
* @summary Limit Option interface
|
|
@@ -31,8 +36,8 @@ export interface OffsetOption<R> extends Executor<R> {
|
|
|
31
36
|
* @interface LimitOption
|
|
32
37
|
* @memberOf module:core
|
|
33
38
|
*/
|
|
34
|
-
export interface LimitOption<M extends Model, R> extends
|
|
35
|
-
limit(selector: LimitSelector): OffsetOption<R>;
|
|
39
|
+
export interface LimitOption<M extends Model, R> extends PreparableStatementExecutor<M, R> {
|
|
40
|
+
limit(selector: LimitSelector): OffsetOption<M, R>;
|
|
36
41
|
}
|
|
37
42
|
/**
|
|
38
43
|
* @summary OrderBy Option interface
|
|
@@ -41,8 +46,8 @@ export interface LimitOption<M extends Model, R> extends Executor<R>, Paginatabl
|
|
|
41
46
|
* @interface OrderByOption
|
|
42
47
|
* @memberOf module:core
|
|
43
48
|
*/
|
|
44
|
-
export interface OrderByOption<M extends Model, R> extends
|
|
45
|
-
orderBy(selector: OrderBySelector<M>): LimitOption<M, R> & OffsetOption<R>;
|
|
49
|
+
export interface OrderByOption<M extends Model, R> extends PreparableStatementExecutor<M, R> {
|
|
50
|
+
orderBy(selector: OrderBySelector<M>): LimitOption<M, R> & OffsetOption<M, R>;
|
|
46
51
|
}
|
|
47
52
|
/**
|
|
48
53
|
* @summary OrderBy Option interface
|
|
@@ -51,7 +56,7 @@ export interface OrderByOption<M extends Model, R> extends Executor<R>, Paginata
|
|
|
51
56
|
* @interface ThenByOption
|
|
52
57
|
* @memberOf module:core
|
|
53
58
|
*/
|
|
54
|
-
export interface ThenByOption<M extends Model, R> extends LimitOption<M, R>, OffsetOption<
|
|
59
|
+
export interface ThenByOption<M extends Model, R> extends LimitOption<M, R>, OffsetOption<M, R>, PreparableStatementExecutor<M, R> {
|
|
55
60
|
thenBy(selector: OrderBySelector<M>): ThenByOption<M, R>;
|
|
56
61
|
}
|
|
57
62
|
/**
|
|
@@ -64,7 +69,7 @@ export interface ThenByOption<M extends Model, R> extends LimitOption<M, R>, Off
|
|
|
64
69
|
* @extends OffsetOption
|
|
65
70
|
* @memberOf module:core
|
|
66
71
|
*/
|
|
67
|
-
export interface OrderAndGroupOption<M extends Model, R> extends OrderByOption<M, R>,
|
|
72
|
+
export interface OrderAndGroupOption<M extends Model, R> extends OrderByOption<M, R>, PreparableStatementExecutor<M, R>, GroupByOption<M, R>, LimitOption<M, R>, OffsetOption<M, R> {
|
|
68
73
|
}
|
|
69
74
|
/**
|
|
70
75
|
* @summary Where Option interface
|
package/lib/query/types.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Condition } from "./Condition";
|
|
2
2
|
import { OrderBySelector } from "./selectors";
|
|
3
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
4
|
+
import { Constructor } from "@decaf-ts/decoration";
|
|
5
|
+
import { OrderDirection } from "../repository/constants";
|
|
3
6
|
/**
|
|
4
7
|
* @description
|
|
5
8
|
* Options for configuring query building behavior.
|
|
@@ -17,6 +20,22 @@ export type QueryOptions = {
|
|
|
17
20
|
allowOrderBy?: boolean;
|
|
18
21
|
throws?: boolean;
|
|
19
22
|
};
|
|
23
|
+
export type OrderLimitOffsetExtract = {
|
|
24
|
+
orderBy?: OrderBySelector<any>[];
|
|
25
|
+
limit?: number;
|
|
26
|
+
offset?: number;
|
|
27
|
+
};
|
|
28
|
+
export type DirectionLimitOffset = {
|
|
29
|
+
direction?: OrderDirection;
|
|
30
|
+
limit?: number;
|
|
31
|
+
offset?: number;
|
|
32
|
+
};
|
|
33
|
+
export type PreparedStatement<M extends Model> = {
|
|
34
|
+
class: Constructor<M>;
|
|
35
|
+
method: string;
|
|
36
|
+
args: any[];
|
|
37
|
+
params: DirectionLimitOffset;
|
|
38
|
+
};
|
|
20
39
|
/**
|
|
21
40
|
* @description
|
|
22
41
|
* Structured query object representing parsed query clauses.
|
package/lib/query/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/query/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/query/types.ts"],"names":[],"mappings":";;;AAmEA;;;;;;;;;;GAUG;AACH,IAAY,WASX;AATD,WAAY,WAAW;IACrB,iCAAkB,CAAA;IAClB,gCAAiB,CAAA;IACjB,0BAAW,CAAA;IACX,wBAAS,CAAA;IACT,mCAAoB,CAAA;IACpB,mCAAoB,CAAA;IACpB,4BAAa,CAAA;IACb,iCAAkB,CAAA;AACpB,CAAC,EATW,WAAW,2BAAX,WAAW,QAStB"}
|
package/lib/ram/RamAdapter.cjs
CHANGED
|
@@ -9,6 +9,7 @@ const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
|
9
9
|
const handlers_1 = require("./handlers.cjs");
|
|
10
10
|
const constants_1 = require("./constants.cjs");
|
|
11
11
|
const decoration_1 = require("@decaf-ts/decoration");
|
|
12
|
+
const RamPaginator_1 = require("./RamPaginator.cjs");
|
|
12
13
|
/**
|
|
13
14
|
* @description In-memory adapter for data persistence
|
|
14
15
|
* @summary The RamAdapter provides an in-memory implementation of the persistence layer.
|
|
@@ -55,7 +56,6 @@ const decoration_1 = require("@decaf-ts/decoration");
|
|
|
55
56
|
class RamAdapter extends persistence_1.Adapter {
|
|
56
57
|
constructor(conf = {}, alias) {
|
|
57
58
|
super(conf, constants_1.RamFlavour, alias);
|
|
58
|
-
this.Context = db_decorators_1.Context;
|
|
59
59
|
this.indexes = {};
|
|
60
60
|
this.lock = new transactional_decorators_1.Lock();
|
|
61
61
|
}
|
|
@@ -403,6 +403,9 @@ class RamAdapter extends persistence_1.Adapter {
|
|
|
403
403
|
Statement() {
|
|
404
404
|
return new RamStatement_1.RamStatement(this);
|
|
405
405
|
}
|
|
406
|
+
Paginator(query, size, clazz) {
|
|
407
|
+
return new RamPaginator_1.RamPaginator(this, query, size, clazz);
|
|
408
|
+
}
|
|
406
409
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
407
410
|
for(config, ...args) {
|
|
408
411
|
if (!this.proxies)
|
package/lib/ram/RamAdapter.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ import { Dispatch } from "../persistence/Dispatch";
|
|
|
5
5
|
import { Adapter } from "../persistence";
|
|
6
6
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
7
7
|
import { BaseError, OperationKeys, PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
8
|
-
import { Constructor } from "@decaf-ts/decoration";
|
|
8
|
+
import type { Constructor } from "@decaf-ts/decoration";
|
|
9
|
+
import { RamPaginator } from "./RamPaginator";
|
|
9
10
|
/**
|
|
10
11
|
* @description In-memory adapter for data persistence
|
|
11
12
|
* @summary The RamAdapter provides an in-memory implementation of the persistence layer.
|
|
@@ -71,7 +72,6 @@ export declare class RamAdapter extends Adapter<RamConfig, RamStorage, RawRamQue
|
|
|
71
72
|
*/
|
|
72
73
|
flags<M extends Model<boolean>>(operation: OperationKeys, model: Constructor<M>, flags: Partial<RamFlags>): Promise<RamFlags>;
|
|
73
74
|
protected Dispatch(): Dispatch<RamAdapter>;
|
|
74
|
-
Context: Constructor<RamContext>;
|
|
75
75
|
private indexes;
|
|
76
76
|
private lock;
|
|
77
77
|
/**
|
|
@@ -296,6 +296,7 @@ export declare class RamAdapter extends Adapter<RamConfig, RamStorage, RawRamQue
|
|
|
296
296
|
* @return {RamStatement<M, any>} A new statement builder instance
|
|
297
297
|
*/
|
|
298
298
|
Statement<M extends Model<boolean>>(): RamStatement<M, any, Adapter<any, any, RawRamQuery<M>, RamContext>>;
|
|
299
|
+
Paginator<M extends Model<boolean>>(query: RawRamQuery, size: number, clazz: Constructor<M>): RamPaginator<M, any>;
|
|
299
300
|
for(config: Partial<RamConfig>, ...args: any[]): typeof this;
|
|
300
301
|
/**
|
|
301
302
|
* @description Sets up RAM-specific decorations for model properties
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RamAdapter.js","sourceRoot":"","sources":["../../src/ram/RamAdapter.ts"],"names":[],"mappings":";;;AAOA,qDAA8C;AAG9C,4DAAoE;AACpE,iFAA0D;AAC1D,yEAAgE;AAChE,
|
|
1
|
+
{"version":3,"file":"RamAdapter.js","sourceRoot":"","sources":["../../src/ram/RamAdapter.ts"],"names":[],"mappings":";;;AAOA,qDAA8C;AAG9C,4DAAoE;AACpE,iFAA0D;AAC1D,yEAAgE;AAChE,2DAUiC;AACjC,6CAAwD;AACxD,+CAAyC;AACzC,qDAA0E;AAE1E,qDAA8C;AAE9C;;;;;;;;;;;;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,KAAK,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,MAAM,CAAU,UAAU;QACxB,KAAK,CAAC,UAAU,EAAE,CAAC;QACnB,MAAM,YAAY,GAAG,6BAAe,CAAC,UAAU,CAAC;QAChD,MAAM,YAAY,GAAG,6BAAe,CAAC,UAAU,CAAC;QAChD,uBAAU,CAAC,WAAW,CAAC,sBAAU,CAAC;aAC/B,GAAG,CAAC,YAAY,CAAC;aACjB,MAAM,CACL,IAAA,wBAAQ,EAAC,qCAA0B,CAAC,EACpC,IAAA,yBAAY,EAAC,YAAY,EAAE,EAAE,CAAC,CAC/B;aACA,KAAK,EAAE,CAAC;QACX,uBAAU,CAAC,WAAW,CAAC,sBAAU,CAAC;aAC/B,GAAG,CAAC,YAAY,CAAC;aACjB,MAAM,CACL,IAAA,8BAAc,EAAC,qCAA0B,CAAC,EAC1C,IAAA,yBAAY,EAAC,YAAY,EAAE,EAAE,CAAC,CAC/B;aACA,KAAK,EAAE,CAAC;IACb,CAAC;IAEkB,SAAS;QAC1B,OAAO,IAAI,GAAG,EAAE,CAAC;IACnB,CAAC;CACF;AAzgBD,gCAygBC"}
|
package/lib/ram/RamPaginator.cjs
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RamPaginator = void 0;
|
|
4
4
|
const query_1 = require("./../query/index.cjs");
|
|
5
|
-
const
|
|
5
|
+
const persistence_1 = require("./../persistence/index.cjs");
|
|
6
|
+
const Context_1 = require("./../persistence/Context.cjs");
|
|
6
7
|
/**
|
|
7
8
|
* @description RAM-specific paginator implementation
|
|
8
9
|
* @summary Extends the base Paginator class to provide pagination functionality for RAM adapter queries.
|
|
@@ -56,7 +57,7 @@ class RamPaginator extends query_1.Paginator {
|
|
|
56
57
|
* @return {Promise<R[]>} A promise that resolves to an array of results for the requested page
|
|
57
58
|
*/
|
|
58
59
|
async page(page = 1, ...args) {
|
|
59
|
-
const contextArgs = await
|
|
60
|
+
const contextArgs = await Context_1.Context.args(persistence_1.PersistenceKeys.QUERY, this.clazz, args, this.adapter);
|
|
60
61
|
const statement = this.prepare(this.statement);
|
|
61
62
|
if (!this._recordCount || !this._totalPages) {
|
|
62
63
|
this._totalPages = this._recordCount = 0;
|
|
@@ -69,7 +70,7 @@ class RamPaginator extends query_1.Paginator {
|
|
|
69
70
|
}
|
|
70
71
|
page = this.validatePage(page);
|
|
71
72
|
statement.skip = (page - 1) * this.size;
|
|
72
|
-
const results = await this.adapter.raw(statement, ...contextArgs.
|
|
73
|
+
const results = await this.adapter.raw(statement, ...args, contextArgs.context);
|
|
73
74
|
this._currentPage = page;
|
|
74
75
|
return results;
|
|
75
76
|
}
|
|
@@ -2,7 +2,7 @@ import { RawRamQuery } from "./types";
|
|
|
2
2
|
import { Paginator } from "../query";
|
|
3
3
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
4
4
|
import { Adapter } from "../persistence";
|
|
5
|
-
import { Constructor } from "@decaf-ts/decoration";
|
|
5
|
+
import type { Constructor } from "@decaf-ts/decoration";
|
|
6
6
|
import { MaybeContextualArg } from "../utils/index";
|
|
7
7
|
/**
|
|
8
8
|
* @description RAM-specific paginator implementation
|
|
@@ -33,7 +33,7 @@ import { MaybeContextualArg } from "../utils/index";
|
|
|
33
33
|
* ```
|
|
34
34
|
*/
|
|
35
35
|
export declare class RamPaginator<M extends Model, R> extends Paginator<M, R, RawRamQuery<M>> {
|
|
36
|
-
constructor(adapter: Adapter<any, RawRamQuery<M>, any
|
|
36
|
+
constructor(adapter: Adapter<any, any, RawRamQuery<M>, any>, query: RawRamQuery<M>, size: number, clazz: Constructor<M>);
|
|
37
37
|
/**
|
|
38
38
|
* @description Prepares a RAM query for pagination
|
|
39
39
|
* @summary Modifies the raw query statement to include pagination parameters.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RamPaginator.js","sourceRoot":"","sources":["../../src/ram/RamPaginator.ts"],"names":[],"mappings":";;;AACA,gDAAqC;
|
|
1
|
+
{"version":3,"file":"RamPaginator.js","sourceRoot":"","sources":["../../src/ram/RamPaginator.ts"],"names":[],"mappings":";;;AACA,gDAAqC;AAErC,4DAA0D;AAG1D,0DAAiD;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAa,YAAiC,SAAQ,iBAIrD;IACC,YACE,OAA+C,EAC/C,KAAqB,EACrB,IAAY,EACZ,KAAqB;QAErB,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IACrC,CAAC;IAED;;;;;;OAMG;IACO,OAAO,CAAC,YAA4B;QAC5C,MAAM,KAAK,GAAqB,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC;QAChE,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI,CAAC,OAAe,CAAC,EAAE,GAAG,IAA6B;QAC3D,MAAM,WAAW,GAAG,MAAM,iBAAO,CAAC,IAAI,CACpC,6BAAe,CAAC,KAAK,EACrB,IAAI,CAAC,KAAK,EACV,IAAI,EACJ,IAAI,CAAC,OAAO,CACb,CAAC;QACF,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC/C,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YAC5C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;YACzC,MAAM,OAAO,GACX,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CACrB,EAAE,GAAG,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,EAClC,WAAW,CAAC,OAAO,CACpB,CAAC,IAAI,EAAE,CAAC;YACX,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;YACnC,IAAI,IAAI,CAAC,YAAY,GAAG,CAAC,EAAE,CAAC;gBAC1B,MAAM,IAAI,GAAG,SAAS,EAAE,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC;gBAC3C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;QAED,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAC/B,SAAS,CAAC,IAAI,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC;QACxC,MAAM,OAAO,GAAU,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAC3C,SAAS,EACT,GAAG,IAAI,EACP,WAAW,CAAC,OAAO,CACpB,CAAC;QACF,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAnED,oCAmEC"}
|
package/lib/ram/RamStatement.cjs
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RamStatement = void 0;
|
|
4
4
|
const query_1 = require("./../query/index.cjs");
|
|
5
|
-
const RamPaginator_1 = require("./RamPaginator.cjs");
|
|
6
5
|
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
7
6
|
const Statement_1 = require("./../query/Statement.cjs");
|
|
8
7
|
const decoration_1 = require("@decaf-ts/decoration");
|
|
@@ -99,22 +98,6 @@ class RamStatement extends Statement_1.Statement {
|
|
|
99
98
|
result.sort = this.getSort();
|
|
100
99
|
return result;
|
|
101
100
|
}
|
|
102
|
-
/**
|
|
103
|
-
* @description Creates a paginator for the query
|
|
104
|
-
* @summary Builds the query and wraps it in a RamPaginator to enable pagination of results.
|
|
105
|
-
* This allows retrieving large result sets in smaller chunks.
|
|
106
|
-
* @param {number} size - The page size (number of results per page)
|
|
107
|
-
* @return {Promise<Paginator<M, R, RawRamQuery<M>>>} A promise that resolves to a paginator for the query
|
|
108
|
-
*/
|
|
109
|
-
async paginate(size) {
|
|
110
|
-
try {
|
|
111
|
-
const query = this.build();
|
|
112
|
-
return new RamPaginator_1.RamPaginator(this.adapter, query, size, this.fromSelector);
|
|
113
|
-
}
|
|
114
|
-
catch (e) {
|
|
115
|
-
throw new db_decorators_1.InternalError(e);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
101
|
/**
|
|
119
102
|
* @description Parses a condition into a RAM query predicate
|
|
120
103
|
* @summary Converts a Condition object into a predicate function that can be used
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Condition
|
|
1
|
+
import { Condition } from "../query";
|
|
2
2
|
import { RamContext, RawRamQuery } from "./types";
|
|
3
3
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
4
4
|
import { Statement } from "../query/Statement";
|
|
@@ -47,14 +47,6 @@ export declare class RamStatement<M extends Model, R, A extends Adapter<M, any,
|
|
|
47
47
|
* @return {RawRamQuery<M>} The constructed RAM query object
|
|
48
48
|
*/
|
|
49
49
|
protected build(): RawRamQuery<any>;
|
|
50
|
-
/**
|
|
51
|
-
* @description Creates a paginator for the query
|
|
52
|
-
* @summary Builds the query and wraps it in a RamPaginator to enable pagination of results.
|
|
53
|
-
* This allows retrieving large result sets in smaller chunks.
|
|
54
|
-
* @param {number} size - The page size (number of results per page)
|
|
55
|
-
* @return {Promise<Paginator<M, R, RawRamQuery<M>>>} A promise that resolves to a paginator for the query
|
|
56
|
-
*/
|
|
57
|
-
paginate(size: number): Promise<Paginator<M, R, RawRamQuery<any>>>;
|
|
58
50
|
/**
|
|
59
51
|
* @description Parses a condition into a RAM query predicate
|
|
60
52
|
* @summary Converts a Condition object into a predicate function that can be used
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RamStatement.js","sourceRoot":"","sources":["../../src/ram/RamStatement.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"RamStatement.js","sourceRoot":"","sources":["../../src/ram/RamStatement.ts"],"names":[],"mappings":";;;AAAA,gDAA0E;AAG1E,2DAAwD;AACxD,wDAA+C;AAC/C,qDAAgD;AAGhD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAa,YAIX,SAAQ,qBAAoC;IAC5C,YAAY,OAAU;QACpB,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAED;;;;;OAKG;IACK,OAAO;QACb,OAAO,CAAC,GAAU,EAAE,GAAU,EAAE,EAAE;YAChC,IAAI,CAAC,IAAI,CAAC,eAAe;gBACvB,MAAM,IAAI,6BAAa,CACrB,+CAA+C,CAChD,CAAC;YACJ,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC;YACtC,MAAM,CAAC,GAAG,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC;YAClC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,qBAAQ,CAAC,kBAAkB,CACtD,GAAG,CAAC,WAAkB,EACtB,GAAG,CACJ,CAAC;YACF,IAAI,CAAC,IAAI;gBACP,MAAM,IAAI,kBAAU,CAAC,qCAAqC,IAAI,EAAE,CAAC,CAAC;YAEpE,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;gBAClB,KAAK,QAAQ,CAAC;gBACd,KAAK,QAAQ;oBACX,OAAO,CACL,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;wBAC7B,GAAG,CAAC,GAAkB,CAAuB,CAAC,aAAa,CAC1D,GAAG,CAAC,GAAkB,CAAsB,CAC7C,CACF,CAAC;gBACJ,KAAK,QAAQ,CAAC;gBACd,KAAK,QAAQ;oBACX,OAAO,CACL,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,C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AAM,IAAI,6BAAa,CACrB,8CAA8C,QAAQ,EAAE,CACzD,CAAC;oBACN,CAAC;gBACH,CAAC;qBAAM,IAAI,QAAQ,KAAK,gBAAQ,CAAC,GAAG,EAAE,CAAC;oBACrC,MAAM,IAAI,6BAAa,CAAC,iBAAiB,CAAC,CAAC;gBAC7C,CAAC;qBAAM,CAAC;oBACN,MAAM,GAAG,GAAqB,IAAI,CAAC,cAAc,CAC/C,KAAqB,CACtB,CAAC;oBACF,MAAM,GAAG,GAAqB,IAAI,CAAC,cAAc,CAC/C,UAA0B,CAC3B,CAAC;oBACF,QAAQ,QAAQ,EAAE,CAAC;wBACjB,KAAK,qBAAa,CAAC,GAAG;4BACpB,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;wBACtC,KAAK,qBAAa,CAAC,EAAE;4BACnB,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;wBACtC;4BACE,MAAM,IAAI,6BAAa,CACrB,4CAA4C,QAAQ,EAAE,CACvD,CAAC;oBACN,CAAC;gBACH,CAAC;YACH,CAAC;SACkB,CAAC;IACxB,CAAC;CACF;AAlLD,oCAkLC"}
|
package/lib/ram/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Model } from "@decaf-ts/decorator-validation";
|
|
2
2
|
import { Repository } from "../repository";
|
|
3
|
-
import { Context, RepositoryFlags } from "@decaf-ts/db-decorators";
|
|
4
3
|
import { Constructor } from "@decaf-ts/decoration";
|
|
5
|
-
import { Adapter } from "../persistence";
|
|
4
|
+
import { Adapter, AdapterFlags } from "../persistence";
|
|
5
|
+
import { Context } from "../persistence/Context";
|
|
6
6
|
/**
|
|
7
7
|
* @description In-memory storage structure for the RAM adapter
|
|
8
8
|
* @summary A nested Map structure that stores all entities by their table name and primary key.
|
|
@@ -45,7 +45,7 @@ export type RawRamQuery<M extends Model = any> = {
|
|
|
45
45
|
* @memberOf module:core
|
|
46
46
|
* @category Ram
|
|
47
47
|
*/
|
|
48
|
-
export interface RamFlags extends
|
|
48
|
+
export interface RamFlags extends AdapterFlags {
|
|
49
49
|
UUID: string;
|
|
50
50
|
}
|
|
51
51
|
export type RamRepository<M extends Model<boolean>> = Repository<M, Adapter<RamConfig, RamStorage, RawRamQuery<any>, RamContext>>;
|
|
@@ -11,16 +11,18 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Repository = void 0;
|
|
13
13
|
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
14
|
+
const logging_1 = require("@decaf-ts/logging");
|
|
14
15
|
const Adapter_1 = require("./../persistence/Adapter.cjs");
|
|
15
|
-
const
|
|
16
|
+
const Context_1 = require("./../persistence/Context.cjs");
|
|
16
17
|
const constants_1 = require("./../persistence/constants.cjs");
|
|
17
|
-
const constants_2 = require("./constants.cjs");
|
|
18
|
-
const Condition_1 = require("./../query/Condition.cjs");
|
|
19
18
|
const ObserverHandler_1 = require("./../persistence/ObserverHandler.cjs");
|
|
20
|
-
const logging_1 = require("@decaf-ts/logging");
|
|
21
|
-
const decoration_1 = require("@decaf-ts/decoration");
|
|
22
19
|
const errors_1 = require("./../query/errors.cjs");
|
|
20
|
+
const Condition_1 = require("./../query/Condition.cjs");
|
|
21
|
+
const constants_2 = require("./constants.cjs");
|
|
22
|
+
const decoration_1 = require("@decaf-ts/decoration");
|
|
23
|
+
const decorator_validation_1 = require("@decaf-ts/decorator-validation");
|
|
23
24
|
const decorators_1 = require("./../query/decorators.cjs");
|
|
25
|
+
const constants_3 = require("./../query/constants.cjs");
|
|
24
26
|
/**
|
|
25
27
|
* @description Core repository implementation for database operations on models on a table by table way.
|
|
26
28
|
* @summary Provides CRUD operations, querying capabilities, and observer pattern implementation for model persistence.
|
|
@@ -197,7 +199,7 @@ class Repository extends db_decorators_1.Repository {
|
|
|
197
199
|
* @throws {ValidationError} If the model fails validation.
|
|
198
200
|
*/
|
|
199
201
|
async createPrefix(model, ...args) {
|
|
200
|
-
const contextArgs = await
|
|
202
|
+
const contextArgs = await Context_1.Context.args(db_decorators_1.OperationKeys.CREATE, this.class, args, this.adapter, this._overrides || {});
|
|
201
203
|
const ignoreHandlers = contextArgs.context.get("ignoreHandlers");
|
|
202
204
|
const ignoreValidate = contextArgs.context.get("ignoreValidation");
|
|
203
205
|
model = new this.class(model);
|
|
@@ -262,7 +264,7 @@ class Repository extends db_decorators_1.Repository {
|
|
|
262
264
|
* @throws {ValidationError} If any model fails validation.
|
|
263
265
|
*/
|
|
264
266
|
async createAllPrefix(models, ...args) {
|
|
265
|
-
const contextArgs = await
|
|
267
|
+
const contextArgs = await Context_1.Context.args(db_decorators_1.OperationKeys.CREATE, this.class, args, this.adapter, this._overrides || {});
|
|
266
268
|
const ignoreHandlers = contextArgs.context.get("ignoreHandlers");
|
|
267
269
|
const ignoreValidate = contextArgs.context.get("ignoreValidation");
|
|
268
270
|
if (!models.length)
|
|
@@ -311,7 +313,7 @@ class Repository extends db_decorators_1.Repository {
|
|
|
311
313
|
* @return The key and context arguments.
|
|
312
314
|
*/
|
|
313
315
|
async readPrefix(key, ...args) {
|
|
314
|
-
const contextArgs = await
|
|
316
|
+
const contextArgs = await Context_1.Context.args(db_decorators_1.OperationKeys.READ, this.class, args, this.adapter, this._overrides || {});
|
|
315
317
|
const model = new this.class();
|
|
316
318
|
model[this.pk] = key;
|
|
317
319
|
await (0, db_decorators_1.enforceDBDecorators)(this, contextArgs.context, model, db_decorators_1.OperationKeys.READ, db_decorators_1.OperationKeys.ON);
|
|
@@ -338,7 +340,7 @@ class Repository extends db_decorators_1.Repository {
|
|
|
338
340
|
* @return The keys and context arguments.
|
|
339
341
|
*/
|
|
340
342
|
async readAllPrefix(keys, ...args) {
|
|
341
|
-
const contextArgs = await
|
|
343
|
+
const contextArgs = await Context_1.Context.args(db_decorators_1.OperationKeys.READ, this.class, args, this.adapter, this._overrides || {});
|
|
342
344
|
await Promise.all(keys.map(async (k) => {
|
|
343
345
|
const m = new this.class();
|
|
344
346
|
m[this.pk] = k;
|
|
@@ -384,7 +386,7 @@ class Repository extends db_decorators_1.Repository {
|
|
|
384
386
|
* @throws {ValidationError} If the model fails validation.
|
|
385
387
|
*/
|
|
386
388
|
async updatePrefix(model, ...args) {
|
|
387
|
-
const contextArgs = await
|
|
389
|
+
const contextArgs = await Context_1.Context.args(db_decorators_1.OperationKeys.UPDATE, this.class, args, this.adapter, this._overrides || {});
|
|
388
390
|
const ignoreHandlers = contextArgs.context.get("ignoreHandlers");
|
|
389
391
|
const ignoreValidate = contextArgs.context.get("ignoreValidation");
|
|
390
392
|
const pk = model[this.pk];
|
|
@@ -425,7 +427,7 @@ class Repository extends db_decorators_1.Repository {
|
|
|
425
427
|
* @throws {ValidationError} If any model fails validation.
|
|
426
428
|
*/
|
|
427
429
|
async updateAllPrefix(models, ...args) {
|
|
428
|
-
const contextArgs = await
|
|
430
|
+
const contextArgs = await Context_1.Context.args(db_decorators_1.OperationKeys.UPDATE, this.class, args, this.adapter, this._overrides || {});
|
|
429
431
|
const ignoreHandlers = contextArgs.context.get("ignoreHandlers");
|
|
430
432
|
const ignoreValidate = contextArgs.context.get("ignoreValidation");
|
|
431
433
|
const ids = models.map((m) => {
|
|
@@ -458,7 +460,7 @@ class Repository extends db_decorators_1.Repository {
|
|
|
458
460
|
* @return The key and context arguments.
|
|
459
461
|
*/
|
|
460
462
|
async deletePrefix(key, ...args) {
|
|
461
|
-
const contextArgs = await
|
|
463
|
+
const contextArgs = await Context_1.Context.args(db_decorators_1.OperationKeys.DELETE, this.class, args, this.adapter, this._overrides || {});
|
|
462
464
|
const model = await this.read(key, ...contextArgs.args);
|
|
463
465
|
await (0, db_decorators_1.enforceDBDecorators)(this, contextArgs.context, model, db_decorators_1.OperationKeys.DELETE, db_decorators_1.OperationKeys.ON);
|
|
464
466
|
return [key, ...contextArgs.args];
|
|
@@ -484,7 +486,7 @@ class Repository extends db_decorators_1.Repository {
|
|
|
484
486
|
* @return The keys and context arguments.
|
|
485
487
|
*/
|
|
486
488
|
async deleteAllPrefix(keys, ...args) {
|
|
487
|
-
const contextArgs = await
|
|
489
|
+
const contextArgs = await Context_1.Context.args(db_decorators_1.OperationKeys.DELETE, this.class, args, this.adapter, this._overrides || {});
|
|
488
490
|
const models = await this.readAll(keys, ...contextArgs.args);
|
|
489
491
|
await Promise.all(models.map(async (m) => {
|
|
490
492
|
return (0, db_decorators_1.enforceDBDecorators)(this, contextArgs.context, m, db_decorators_1.OperationKeys.DELETE, db_decorators_1.OperationKeys.ON);
|
|
@@ -527,17 +529,19 @@ class Repository extends db_decorators_1.Repository {
|
|
|
527
529
|
* @param {number} [skip] - Optional number of results to skip.
|
|
528
530
|
* @return {Promise<M[]>} The query results as model instances.
|
|
529
531
|
*/
|
|
530
|
-
async query(condition, orderBy, order = constants_2.OrderDirection.ASC, limit, skip) {
|
|
532
|
+
async query(condition, orderBy, order = constants_2.OrderDirection.ASC, limit, skip, ...args) {
|
|
533
|
+
const contextArgs = await Context_1.Context.args(constants_1.PersistenceKeys.QUERY, this.class, args, this.adapter, this._overrides || {});
|
|
534
|
+
const { ctx } = this.logCtx(contextArgs.args, this.query);
|
|
531
535
|
const sort = [orderBy, order];
|
|
532
536
|
const query = this.select().where(condition).orderBy(sort);
|
|
533
537
|
if (limit)
|
|
534
538
|
query.limit(limit);
|
|
535
539
|
if (skip)
|
|
536
540
|
query.offset(skip);
|
|
537
|
-
return query.execute();
|
|
541
|
+
return query.execute(ctx);
|
|
538
542
|
}
|
|
539
543
|
async listBy(key, order, ...args) {
|
|
540
|
-
const contextArgs = await
|
|
544
|
+
const contextArgs = await Context_1.Context.args(constants_3.PreparedStatementKeys.LIST_BY, this.class, args, this.adapter, this._overrides || {});
|
|
541
545
|
const { log, ctxArgs } = this.logCtx(contextArgs.args, this.listBy);
|
|
542
546
|
log.verbose(`listing ${decorator_validation_1.Model.tableName(this.class)} by ${key} ${order}`);
|
|
543
547
|
return this.select()
|
|
@@ -545,7 +549,7 @@ class Repository extends db_decorators_1.Repository {
|
|
|
545
549
|
.execute(...ctxArgs);
|
|
546
550
|
}
|
|
547
551
|
async paginateBy(key, order, size, ...args) {
|
|
548
|
-
const contextArgs = await
|
|
552
|
+
const contextArgs = await Context_1.Context.args(constants_3.PreparedStatementKeys.PAGE_BY, this.class, args, this.adapter, this._overrides || {});
|
|
549
553
|
const { log, ctxArgs } = this.logCtx(contextArgs.args, this.paginateBy);
|
|
550
554
|
log.verbose(`paginating ${decorator_validation_1.Model.tableName(this.class)} with page size ${size}`);
|
|
551
555
|
return this.select()
|
|
@@ -553,9 +557,21 @@ class Repository extends db_decorators_1.Repository {
|
|
|
553
557
|
.paginate(size, ...ctxArgs);
|
|
554
558
|
}
|
|
555
559
|
async findOneBy(key, value, ...args) {
|
|
556
|
-
const contextArgs = await
|
|
560
|
+
const contextArgs = await Context_1.Context.args(constants_3.PreparedStatementKeys.FIND_ONE_BY, this.class, args, this.adapter, this._overrides || {});
|
|
557
561
|
const { log, ctxArgs } = this.logCtx(contextArgs.args, this.findOneBy);
|
|
558
562
|
log.verbose(`finding ${decorator_validation_1.Model.tableName(this.class)} with ${key} ${value}`);
|
|
563
|
+
const result = await this.select()
|
|
564
|
+
.where(this.attr(key).eq(value))
|
|
565
|
+
.limit(1)
|
|
566
|
+
.execute(...ctxArgs);
|
|
567
|
+
if (!result.length)
|
|
568
|
+
throw new db_decorators_1.NotFoundError(`No results found`);
|
|
569
|
+
return result[0];
|
|
570
|
+
}
|
|
571
|
+
async findBy(key, value, ...args) {
|
|
572
|
+
const contextArgs = await Context_1.Context.args(constants_3.PreparedStatementKeys.FIND_BY, this.class, args, this.adapter, this._overrides || {});
|
|
573
|
+
const { log, ctxArgs } = this.logCtx(contextArgs.args, this.findBy);
|
|
574
|
+
log.verbose(`finding ${decorator_validation_1.Model.tableName(this.class)} with ${key} ${value}`);
|
|
559
575
|
return this.select()
|
|
560
576
|
.where(this.attr(key).eq(value))
|
|
561
577
|
.execute(...ctxArgs);
|
|
@@ -563,7 +579,7 @@ class Repository extends db_decorators_1.Repository {
|
|
|
563
579
|
async statement(name, ...args) {
|
|
564
580
|
if (!Repository.statements(this, name))
|
|
565
581
|
throw new errors_1.QueryError(`Invalid prepared statement requested ${name}`);
|
|
566
|
-
const contextArgs = await
|
|
582
|
+
const contextArgs = await Context_1.Context.args(constants_1.PersistenceKeys.STATEMENT, this.class, args, this.adapter, this._overrides || {});
|
|
567
583
|
const { log, ctxArgs } = this.logCtx(contextArgs.args, this.statement);
|
|
568
584
|
log.verbose(`Executing prepared statement ${name}`);
|
|
569
585
|
return this[name](...ctxArgs);
|
|
@@ -763,6 +779,12 @@ __decorate([
|
|
|
763
779
|
__metadata("design:paramtypes", [Object, Object, void 0]),
|
|
764
780
|
__metadata("design:returntype", Promise)
|
|
765
781
|
], Repository.prototype, "findOneBy", null);
|
|
782
|
+
__decorate([
|
|
783
|
+
(0, decorators_1.prepared)(),
|
|
784
|
+
__metadata("design:type", Function),
|
|
785
|
+
__metadata("design:paramtypes", [Object, Object, void 0]),
|
|
786
|
+
__metadata("design:returntype", Promise)
|
|
787
|
+
], Repository.prototype, "findBy", null);
|
|
766
788
|
__decorate([
|
|
767
789
|
(0, logging_1.final)(),
|
|
768
790
|
__metadata("design:type", Function),
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { BulkCrudOperationKeys, IRepository, OperationKeys, Repository as Rep, PrimaryKeyType } from "@decaf-ts/db-decorators";
|
|
2
|
-
import {
|
|
2
|
+
import { Logger } from "@decaf-ts/logging";
|
|
3
|
+
import { ContextualizedArgs, MaybeContextualArg } from "../utils/ContextualLoggedClass";
|
|
3
4
|
import { Adapter } from "../persistence/Adapter";
|
|
4
|
-
import { Model } from "@decaf-ts/decorator-validation";
|
|
5
|
-
import { OrderDirection } from "./constants";
|
|
6
|
-
import { type SequenceOptions } from "../interfaces/SequenceOptions";
|
|
7
|
-
import { Queriable } from "../interfaces/Queriable";
|
|
8
|
-
import { Condition } from "../query/Condition";
|
|
9
|
-
import { WhereOption } from "../query/options";
|
|
10
|
-
import { SelectSelector } from "../query/selectors";
|
|
11
5
|
import { ObserverHandler } from "../persistence/ObserverHandler";
|
|
12
|
-
import
|
|
6
|
+
import type { QueryOptions } from "../query/types";
|
|
7
|
+
import { SelectSelector } from "../query/selectors";
|
|
8
|
+
import { WhereOption } from "../query/options";
|
|
9
|
+
import { Condition } from "../query/Condition";
|
|
10
|
+
import { Queriable } from "../interfaces/Queriable";
|
|
11
|
+
import { SequenceOptions } from "../interfaces/SequenceOptions";
|
|
12
|
+
import { OrderDirection } from "./constants";
|
|
13
|
+
import type { ContextOf, EventIds, FlagsOf, InferredAdapterConfig, ObserverFilter, PersistenceObservable, PersistenceObserver } from "../persistence/types";
|
|
14
|
+
import type { FlagsOf as ContextualFlagsOf } from "@decaf-ts/db-decorators";
|
|
15
|
+
import type { Observer } from "../interfaces/Observer";
|
|
13
16
|
import { Constructor } from "@decaf-ts/decoration";
|
|
14
|
-
import
|
|
15
|
-
import type { ContextualizedArgs, MaybeContextualArg } from "../utils/ContextualLoggedClass";
|
|
16
|
-
import { type QueryOptions } from "../query/types";
|
|
17
|
+
import { Model } from "@decaf-ts/decorator-validation";
|
|
17
18
|
/**
|
|
18
19
|
* @description Type alias for Repository class with simplified generic parameters.
|
|
19
20
|
* @summary Provides a more concise way to reference the Repository class with its generic parameters.
|
|
@@ -85,7 +86,7 @@ export declare class Repository<M extends Model<boolean>, A extends Adapter<any,
|
|
|
85
86
|
protected observerHandler?: ObserverHandler;
|
|
86
87
|
private readonly _adapter;
|
|
87
88
|
private _tableName;
|
|
88
|
-
protected _overrides?: Partial<FlagsOf<A
|
|
89
|
+
protected _overrides?: Partial<FlagsOf<ContextOf<A>>> & Partial<ContextualFlagsOf<ContextOf<A>>>;
|
|
89
90
|
private logger;
|
|
90
91
|
/**
|
|
91
92
|
* @description Logger instance for this repository.
|
|
@@ -122,7 +123,7 @@ export declare class Repository<M extends Model<boolean>, A extends Adapter<any,
|
|
|
122
123
|
* @param {Partial<F>} flags - The flags to override.
|
|
123
124
|
* @return {Repository} A proxy of this repository with overridden flags.
|
|
124
125
|
*/
|
|
125
|
-
override(flags: Partial<FlagsOf<A
|
|
126
|
+
override(flags: Partial<FlagsOf<ContextOf<A>>>): this;
|
|
126
127
|
/**
|
|
127
128
|
* @description Creates a new instance of the Repository class with a specific adapter and arguments.
|
|
128
129
|
*
|
|
@@ -311,10 +312,11 @@ export declare class Repository<M extends Model<boolean>, A extends Adapter<any,
|
|
|
311
312
|
* @param {number} [skip] - Optional number of results to skip.
|
|
312
313
|
* @return {Promise<M[]>} The query results as model instances.
|
|
313
314
|
*/
|
|
314
|
-
query(condition: Condition<M>, orderBy: keyof M, order?: OrderDirection, limit?: number, skip?: number): Promise<M[]>;
|
|
315
|
+
query(condition: Condition<M>, orderBy: keyof M, order?: OrderDirection, limit?: number, skip?: number, ...args: MaybeContextualArg<ContextOf<A>>): Promise<M[]>;
|
|
315
316
|
listBy(key: keyof M, order: OrderDirection, ...args: MaybeContextualArg<ContextOf<A>>): Promise<M[]>;
|
|
316
317
|
paginateBy(key: keyof M, order: OrderDirection, size: number, ...args: MaybeContextualArg<ContextOf<A>>): Promise<import("..").Paginator<M, M[], any>>;
|
|
317
|
-
findOneBy(key: keyof M, value: any, ...args: MaybeContextualArg<ContextOf<A>>): Promise<M
|
|
318
|
+
findOneBy(key: keyof M, value: any, ...args: MaybeContextualArg<ContextOf<A>>): Promise<M>;
|
|
319
|
+
findBy(key: keyof M, value: any, ...args: MaybeContextualArg<ContextOf<A>>): Promise<M[]>;
|
|
318
320
|
statement(name: string, ...args: MaybeContextualArg<ContextOf<A>>): Promise<any>;
|
|
319
321
|
attr(prop: keyof M): import("../query/options").AttributeOption<M>;
|
|
320
322
|
/**
|