@ptc-org/nestjs-query-core 0.30.1 → 0.30.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/package.json +2 -2
- package/src/assemblers/abstract.assembler.d.ts +33 -0
- package/src/assemblers/abstract.assembler.js +55 -0
- package/src/assemblers/abstract.assembler.js.map +1 -0
- package/src/assemblers/assembler.d.ts +86 -0
- package/src/assemblers/assembler.deserializer.d.ts +4 -0
- package/src/assemblers/assembler.deserializer.js +22 -0
- package/src/assemblers/assembler.deserializer.js.map +1 -0
- package/src/assemblers/assembler.factory.d.ts +8 -0
- package/src/assemblers/assembler.factory.js +29 -0
- package/src/assemblers/assembler.factory.js.map +1 -0
- package/src/assemblers/assembler.js +33 -0
- package/src/assemblers/assembler.js.map +1 -0
- package/src/assemblers/assembler.serializer.d.ts +4 -0
- package/src/assemblers/assembler.serializer.js +22 -0
- package/src/assemblers/assembler.serializer.js.map +1 -0
- package/src/assemblers/class-transformer.assembler.d.ts +17 -0
- package/src/assemblers/class-transformer.assembler.js +67 -0
- package/src/assemblers/class-transformer.assembler.js.map +1 -0
- package/src/assemblers/constants.d.ts +4 -0
- package/src/assemblers/constants.js +8 -0
- package/src/assemblers/constants.js.map +1 -0
- package/src/assemblers/default.assembler.d.ts +8 -0
- package/src/assemblers/default.assembler.js +14 -0
- package/src/assemblers/default.assembler.js.map +1 -0
- package/src/assemblers/index.d.ts +7 -0
- package/src/assemblers/index.js +19 -0
- package/src/assemblers/index.js.map +1 -0
- package/src/common/class.type.d.ts +8 -0
- package/src/common/class.type.js +3 -0
- package/src/common/class.type.js.map +1 -0
- package/src/common/class.utils.d.ts +2 -0
- package/src/common/class.utils.js +12 -0
- package/src/common/class.utils.js.map +1 -0
- package/src/common/deep-partial.type.d.ts +6 -0
- package/src/common/deep-partial.type.js +3 -0
- package/src/common/deep-partial.type.js.map +1 -0
- package/src/common/index.d.ts +5 -0
- package/src/common/index.js +9 -0
- package/src/common/index.js.map +1 -0
- package/src/common/misc.utils.d.ts +4 -0
- package/src/common/misc.utils.js +9 -0
- package/src/common/misc.utils.js.map +1 -0
- package/src/common/reflect.utils.d.ts +31 -0
- package/src/common/reflect.utils.js +98 -0
- package/src/common/reflect.utils.js.map +1 -0
- package/src/decorators/helpers.d.ts +6 -0
- package/src/decorators/helpers.js +12 -0
- package/src/decorators/helpers.js.map +1 -0
- package/src/decorators/index.d.ts +3 -0
- package/src/decorators/index.js +10 -0
- package/src/decorators/index.js.map +1 -0
- package/src/decorators/inject-assembler-query-service.decorator.d.ts +4 -0
- package/src/decorators/inject-assembler-query-service.decorator.js +8 -0
- package/src/decorators/inject-assembler-query-service.decorator.js.map +1 -0
- package/src/decorators/inject-query-service.decorator.d.ts +3 -0
- package/src/decorators/inject-query-service.decorator.js +8 -0
- package/src/decorators/inject-query-service.decorator.js.map +1 -0
- package/src/helpers/aggregate.helpers.d.ts +4 -0
- package/src/helpers/aggregate.helpers.js +56 -0
- package/src/helpers/aggregate.helpers.js.map +1 -0
- package/src/helpers/comparison.builder.d.ts +11 -0
- package/src/helpers/comparison.builder.js +92 -0
- package/src/helpers/comparison.builder.js.map +1 -0
- package/src/helpers/filter.builder.d.ts +10 -0
- package/src/helpers/filter.builder.js +49 -0
- package/src/helpers/filter.builder.js.map +1 -0
- package/src/helpers/filter.helpers.d.ts +24 -0
- package/src/helpers/filter.helpers.js +115 -0
- package/src/helpers/filter.helpers.js.map +1 -0
- package/src/helpers/index.d.ts +3 -0
- package/src/helpers/index.js +17 -0
- package/src/helpers/index.js.map +1 -0
- package/src/helpers/page.builder.d.ts +6 -0
- package/src/helpers/page.builder.js +13 -0
- package/src/helpers/page.builder.js.map +1 -0
- package/src/helpers/query.helpers.d.ts +11 -0
- package/src/helpers/query.helpers.js +60 -0
- package/src/helpers/query.helpers.js.map +1 -0
- package/src/helpers/sort.builder.d.ts +11 -0
- package/src/helpers/sort.builder.js +82 -0
- package/src/helpers/sort.builder.js.map +1 -0
- package/src/helpers/types.d.ts +3 -0
- package/src/helpers/types.js +3 -0
- package/src/helpers/types.js.map +1 -0
- package/src/index.d.ts +7 -0
- package/src/index.js.map +1 -0
- package/src/interfaces/aggregate-query.interface.d.ts +8 -0
- package/src/interfaces/aggregate-query.interface.js +3 -0
- package/src/interfaces/aggregate-query.interface.js.map +1 -0
- package/src/interfaces/aggregate-response.interface.d.ts +14 -0
- package/src/interfaces/aggregate-response.interface.js +3 -0
- package/src/interfaces/aggregate-response.interface.js.map +1 -0
- package/src/interfaces/delete-many-options.interface.d.ts +2 -0
- package/src/interfaces/delete-many-options.interface.js +3 -0
- package/src/interfaces/delete-many-options.interface.js.map +1 -0
- package/src/interfaces/delete-many-response.interface.d.ts +9 -0
- package/src/interfaces/delete-many-response.interface.js +3 -0
- package/src/interfaces/delete-many-response.interface.js.map +1 -0
- package/src/interfaces/delete-one-options.interface.d.ts +7 -0
- package/src/interfaces/delete-one-options.interface.js +3 -0
- package/src/interfaces/delete-one-options.interface.js.map +1 -0
- package/src/interfaces/filter-field-comparison.interface.d.ts +202 -0
- package/src/interfaces/filter-field-comparison.interface.js +3 -0
- package/src/interfaces/filter-field-comparison.interface.js.map +1 -0
- package/src/interfaces/filter.interface.d.ts +113 -0
- package/src/interfaces/filter.interface.js +3 -0
- package/src/interfaces/filter.interface.js.map +1 -0
- package/src/interfaces/filterable.interface.d.ts +13 -0
- package/src/interfaces/filterable.interface.js +3 -0
- package/src/interfaces/filterable.interface.js.map +1 -0
- package/src/interfaces/find-by-id-options.interface.d.ts +7 -0
- package/src/interfaces/find-by-id-options.interface.js +3 -0
- package/src/interfaces/find-by-id-options.interface.js.map +1 -0
- package/src/interfaces/find-relation-options.interface.d.ts +2 -0
- package/src/interfaces/find-relation-options.interface.js +3 -0
- package/src/interfaces/find-relation-options.interface.js.map +1 -0
- package/src/interfaces/get-by-id-options.interface.d.ts +2 -0
- package/src/interfaces/get-by-id-options.interface.js +3 -0
- package/src/interfaces/get-by-id-options.interface.js.map +1 -0
- package/src/interfaces/index.d.ts +17 -0
- package/src/interfaces/index.js +21 -0
- package/src/interfaces/index.js.map +1 -0
- package/src/interfaces/modify-relation-options.interface.d.ts +9 -0
- package/src/interfaces/modify-relation-options.interface.js +3 -0
- package/src/interfaces/modify-relation-options.interface.js.map +1 -0
- package/src/interfaces/paging.interface.d.ts +13 -0
- package/src/interfaces/paging.interface.js +3 -0
- package/src/interfaces/paging.interface.js.map +1 -0
- package/src/interfaces/query.inteface.d.ts +37 -0
- package/src/interfaces/query.inteface.js +3 -0
- package/src/interfaces/query.inteface.js.map +1 -0
- package/src/interfaces/sort-field.interface.d.ts +60 -0
- package/src/interfaces/sort-field.interface.js +26 -0
- package/src/interfaces/sort-field.interface.js.map +1 -0
- package/src/interfaces/update-many-response.interface.d.ts +9 -0
- package/src/interfaces/update-many-response.interface.js +3 -0
- package/src/interfaces/update-many-response.interface.js.map +1 -0
- package/src/interfaces/update-one-options.interface.d.ts +8 -0
- package/src/interfaces/update-one-options.interface.js +3 -0
- package/src/interfaces/update-one-options.interface.js.map +1 -0
- package/src/module.d.ts +10 -0
- package/src/module.js +18 -0
- package/src/module.js.map +1 -0
- package/src/providers.d.ts +4 -0
- package/src/providers.js +24 -0
- package/src/providers.js.map +1 -0
- package/src/services/assembler-query.service.d.ts +63 -0
- package/src/services/assembler-query.service.js +132 -0
- package/src/services/assembler-query.service.js.map +1 -0
- package/src/services/index.d.ts +5 -0
- package/src/services/index.js +14 -0
- package/src/services/index.js.map +1 -0
- package/src/services/noop-query.service.d.ts +32 -0
- package/src/services/noop-query.service.js +76 -0
- package/src/services/noop-query.service.js.map +1 -0
- package/src/services/proxy-query.service.d.ts +59 -0
- package/src/services/proxy-query.service.js +82 -0
- package/src/services/proxy-query.service.js.map +1 -0
- package/src/services/query.service.d.ts +175 -0
- package/src/services/query.service.js +14 -0
- package/src/services/query.service.js.map +1 -0
- package/src/services/relation-query.service.d.ts +50 -0
- package/src/services/relation-query.service.js +103 -0
- package/src/services/relation-query.service.js.map +1 -0
- package/CHANGELOG.md +0 -471
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AssemblerQueryService = void 0;
|
|
4
|
+
class AssemblerQueryService {
|
|
5
|
+
constructor(assembler, queryService) {
|
|
6
|
+
this.assembler = assembler;
|
|
7
|
+
this.queryService = queryService;
|
|
8
|
+
}
|
|
9
|
+
addRelations(relationName, id, relationIds, opts) {
|
|
10
|
+
return this.assembler.convertAsyncToDTO(this.queryService.addRelations(relationName, id, relationIds, this.convertModifyRelationsOptions(opts)));
|
|
11
|
+
}
|
|
12
|
+
createMany(items) {
|
|
13
|
+
const { assembler } = this;
|
|
14
|
+
const converted = assembler.convertToCreateEntities(items);
|
|
15
|
+
return this.assembler.convertAsyncToDTOs(this.queryService.createMany(converted));
|
|
16
|
+
}
|
|
17
|
+
createOne(item) {
|
|
18
|
+
const c = this.assembler.convertToCreateEntity(item);
|
|
19
|
+
return this.assembler.convertAsyncToDTO(this.queryService.createOne(c));
|
|
20
|
+
}
|
|
21
|
+
async deleteMany(filter) {
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
23
|
+
return this.queryService.deleteMany(this.assembler.convertQuery({ filter }).filter);
|
|
24
|
+
}
|
|
25
|
+
deleteOne(id, opts) {
|
|
26
|
+
return this.assembler.convertAsyncToDTO(this.queryService.deleteOne(id, this.convertFilterable(opts)));
|
|
27
|
+
}
|
|
28
|
+
async findById(id, opts) {
|
|
29
|
+
const entity = await this.queryService.findById(id, this.convertFilterable(opts));
|
|
30
|
+
if (!entity) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
return this.assembler.convertToDTO(entity);
|
|
34
|
+
}
|
|
35
|
+
getById(id, opts) {
|
|
36
|
+
return this.assembler.convertAsyncToDTO(this.queryService.getById(id, this.convertFilterable(opts)));
|
|
37
|
+
}
|
|
38
|
+
query(query) {
|
|
39
|
+
return this.assembler.convertAsyncToDTOs(this.queryService.query(this.assembler.convertQuery(query)));
|
|
40
|
+
}
|
|
41
|
+
async aggregate(filter, aggregate) {
|
|
42
|
+
const aggregateResponse = await this.queryService.aggregate(this.assembler.convertQuery({ filter }).filter || {}, this.assembler.convertAggregateQuery(aggregate));
|
|
43
|
+
return aggregateResponse.map((agg) => this.assembler.convertAggregateResponse(agg));
|
|
44
|
+
}
|
|
45
|
+
count(filter) {
|
|
46
|
+
return this.queryService.count(this.assembler.convertQuery({ filter }).filter || {});
|
|
47
|
+
}
|
|
48
|
+
async queryRelations(RelationClass, relationName, dto, query) {
|
|
49
|
+
if (Array.isArray(dto)) {
|
|
50
|
+
const entities = this.assembler.convertToEntities(dto);
|
|
51
|
+
const relationMap = await this.queryService.queryRelations(RelationClass, relationName, entities, query);
|
|
52
|
+
return entities.reduce((map, e, index) => {
|
|
53
|
+
const entry = relationMap.get(e) ?? [];
|
|
54
|
+
map.set(dto[index], entry);
|
|
55
|
+
return map;
|
|
56
|
+
}, new Map());
|
|
57
|
+
}
|
|
58
|
+
return this.queryService.queryRelations(RelationClass, relationName, this.assembler.convertToEntity(dto), query);
|
|
59
|
+
}
|
|
60
|
+
async countRelations(RelationClass, relationName, dto, filter) {
|
|
61
|
+
if (Array.isArray(dto)) {
|
|
62
|
+
const entities = this.assembler.convertToEntities(dto);
|
|
63
|
+
const relationMap = await this.queryService.countRelations(RelationClass, relationName, entities, filter);
|
|
64
|
+
return entities.reduce((map, e, index) => {
|
|
65
|
+
const entry = relationMap.get(e) ?? 0;
|
|
66
|
+
map.set(dto[index], entry);
|
|
67
|
+
return map;
|
|
68
|
+
}, new Map());
|
|
69
|
+
}
|
|
70
|
+
return this.queryService.countRelations(RelationClass, relationName, this.assembler.convertToEntity(dto), filter);
|
|
71
|
+
}
|
|
72
|
+
async findRelation(RelationClass, relationName, dto, opts) {
|
|
73
|
+
if (Array.isArray(dto)) {
|
|
74
|
+
const entities = this.assembler.convertToEntities(dto);
|
|
75
|
+
const relationMap = await this.queryService.findRelation(RelationClass, relationName, entities, opts);
|
|
76
|
+
return entities.reduce((map, e, index) => {
|
|
77
|
+
map.set(dto[index], relationMap.get(e));
|
|
78
|
+
return map;
|
|
79
|
+
}, new Map());
|
|
80
|
+
}
|
|
81
|
+
return this.queryService.findRelation(RelationClass, relationName, this.assembler.convertToEntity(dto));
|
|
82
|
+
}
|
|
83
|
+
removeRelation(relationName, id, relationId, opts) {
|
|
84
|
+
return this.assembler.convertAsyncToDTO(this.queryService.removeRelation(relationName, id, relationId, this.convertModifyRelationsOptions(opts)));
|
|
85
|
+
}
|
|
86
|
+
removeRelations(relationName, id, relationIds, opts) {
|
|
87
|
+
return this.assembler.convertAsyncToDTO(this.queryService.removeRelations(relationName, id, relationIds, this.convertModifyRelationsOptions(opts)));
|
|
88
|
+
}
|
|
89
|
+
setRelations(relationName, id, relationIds, opts) {
|
|
90
|
+
return this.assembler.convertAsyncToDTO(this.queryService.setRelations(relationName, id, relationIds, this.convertModifyRelationsOptions(opts)));
|
|
91
|
+
}
|
|
92
|
+
setRelation(relationName, id, relationId, opts) {
|
|
93
|
+
return this.assembler.convertAsyncToDTO(this.queryService.setRelation(relationName, id, relationId, this.convertModifyRelationsOptions(opts)));
|
|
94
|
+
}
|
|
95
|
+
updateMany(update, filter) {
|
|
96
|
+
return this.queryService.updateMany(this.assembler.convertToUpdateEntity(update),
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
98
|
+
this.assembler.convertQuery({ filter }).filter);
|
|
99
|
+
}
|
|
100
|
+
updateOne(id, update, opts) {
|
|
101
|
+
return this.assembler.convertAsyncToDTO(this.queryService.updateOne(id, this.assembler.convertToUpdateEntity(update), this.convertFilterable(opts)));
|
|
102
|
+
}
|
|
103
|
+
async aggregateRelations(RelationClass, relationName, dto, filter, aggregate) {
|
|
104
|
+
if (Array.isArray(dto)) {
|
|
105
|
+
const entities = this.assembler.convertToEntities(dto);
|
|
106
|
+
const relationMap = await this.queryService.aggregateRelations(RelationClass, relationName, entities, filter, aggregate);
|
|
107
|
+
return entities.reduce((map, e, index) => {
|
|
108
|
+
const entry = relationMap.get(e) ?? [];
|
|
109
|
+
map.set(dto[index], entry);
|
|
110
|
+
return map;
|
|
111
|
+
}, new Map());
|
|
112
|
+
}
|
|
113
|
+
return this.queryService.aggregateRelations(RelationClass, relationName, this.assembler.convertToEntity(dto), filter, aggregate);
|
|
114
|
+
}
|
|
115
|
+
convertFilterable(filterable) {
|
|
116
|
+
if (!filterable) {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
return { ...filterable, filter: this.assembler.convertQuery({ filter: filterable?.filter }).filter };
|
|
120
|
+
}
|
|
121
|
+
convertModifyRelationsOptions(modifyRelationOptions) {
|
|
122
|
+
if (!modifyRelationOptions) {
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
filter: this.assembler.convertQuery({ filter: modifyRelationOptions?.filter }).filter,
|
|
127
|
+
relationFilter: modifyRelationOptions.relationFilter,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
exports.AssemblerQueryService = AssemblerQueryService;
|
|
132
|
+
//# sourceMappingURL=assembler-query.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assembler-query.service.js","sourceRoot":"","sources":["../../../../../packages/core/src/services/assembler-query.service.ts"],"names":[],"mappings":";;;AAmBA,MAAa,qBAAqB;IAGhC,YACW,SAA+C,EAC/C,YAA0C;QAD1C,cAAS,GAAT,SAAS,CAAsC;QAC/C,iBAAY,GAAZ,YAAY,CAA8B;IAClD,CAAC;IAEJ,YAAY,CACV,YAAoB,EACpB,EAAmB,EACnB,WAAgC,EAChC,IAA2C;QAE3C,OAAO,IAAI,CAAC,SAAS,CAAC,iBAAiB,CACrC,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,YAAY,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI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AS,CAAC;SAClB;QACD,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM;YACrF,cAAc,EAAE,qBAAqB,CAAC,cAAc;SACrD,CAAC;IACJ,CAAC;CACF;AAvTD,sDAuTC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { QueryService } from './query.service';
|
|
2
|
+
export { AssemblerQueryService } from './assembler-query.service';
|
|
3
|
+
export { RelationQueryService, QueryServiceRelation } from './relation-query.service';
|
|
4
|
+
export { NoOpQueryService } from './noop-query.service';
|
|
5
|
+
export { ProxyQueryService } from './proxy-query.service';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProxyQueryService = exports.NoOpQueryService = exports.RelationQueryService = exports.AssemblerQueryService = exports.QueryService = void 0;
|
|
4
|
+
var query_service_1 = require("./query.service");
|
|
5
|
+
Object.defineProperty(exports, "QueryService", { enumerable: true, get: function () { return query_service_1.QueryService; } });
|
|
6
|
+
var assembler_query_service_1 = require("./assembler-query.service");
|
|
7
|
+
Object.defineProperty(exports, "AssemblerQueryService", { enumerable: true, get: function () { return assembler_query_service_1.AssemblerQueryService; } });
|
|
8
|
+
var relation_query_service_1 = require("./relation-query.service");
|
|
9
|
+
Object.defineProperty(exports, "RelationQueryService", { enumerable: true, get: function () { return relation_query_service_1.RelationQueryService; } });
|
|
10
|
+
var noop_query_service_1 = require("./noop-query.service");
|
|
11
|
+
Object.defineProperty(exports, "NoOpQueryService", { enumerable: true, get: function () { return noop_query_service_1.NoOpQueryService; } });
|
|
12
|
+
var proxy_query_service_1 = require("./proxy-query.service");
|
|
13
|
+
Object.defineProperty(exports, "ProxyQueryService", { enumerable: true, get: function () { return proxy_query_service_1.ProxyQueryService; } });
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/core/src/services/index.ts"],"names":[],"mappings":";;;AAAA,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AACrB,qEAAkE;AAAzD,gIAAA,qBAAqB,OAAA;AAC9B,mEAAsF;AAA7E,8HAAA,oBAAoB,OAAA;AAC7B,2DAAwD;AAA/C,sHAAA,gBAAgB,OAAA;AACzB,6DAA0D;AAAjD,wHAAA,iBAAiB,OAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Filter, UpdateManyResponse, Query, DeleteManyResponse, AggregateQuery, AggregateResponse, ModifyRelationOptions, DeleteOneOptions, FindByIdOptions, FindRelationOptions, GetByIdOptions, UpdateOneOptions } from '../interfaces';
|
|
2
|
+
import { QueryService } from './query.service';
|
|
3
|
+
import { DeepPartial, Class } from '../common';
|
|
4
|
+
export declare class NoOpQueryService<DTO, C = DeepPartial<DTO>, U = DeepPartial<DTO>> implements QueryService<DTO, C, U> {
|
|
5
|
+
private static instance;
|
|
6
|
+
static getInstance<DTO, C, U>(): QueryService<DTO, C, U>;
|
|
7
|
+
constructor();
|
|
8
|
+
addRelations<Relation>(relationName: string, id: string | number, relationIds: (string | number)[], opts?: ModifyRelationOptions<DTO, Relation>): Promise<DTO>;
|
|
9
|
+
createMany(items: C[]): Promise<DTO[]>;
|
|
10
|
+
createOne(item: C): Promise<DTO>;
|
|
11
|
+
deleteMany(filter: Filter<DTO>): Promise<DeleteManyResponse>;
|
|
12
|
+
deleteOne(id: number | string, opts?: DeleteOneOptions<DTO>): Promise<DTO>;
|
|
13
|
+
findById(id: string | number, opts?: FindByIdOptions<DTO>): Promise<DTO | undefined>;
|
|
14
|
+
findRelation<Relation>(RelationClass: Class<Relation>, relationName: string, dto: DTO, opts?: FindRelationOptions<Relation>): Promise<Relation | undefined>;
|
|
15
|
+
findRelation<Relation>(RelationClass: Class<Relation>, relationName: string, dtos: DTO[], opts?: FindRelationOptions<Relation>): Promise<Map<DTO, Relation | undefined>>;
|
|
16
|
+
getById(id: string | number, opts?: GetByIdOptions<DTO>): Promise<DTO>;
|
|
17
|
+
query(query: Query<DTO>): Promise<DTO[]>;
|
|
18
|
+
aggregate(filter: Filter<DTO>, aggregate: AggregateQuery<DTO>): Promise<AggregateResponse<DTO>[]>;
|
|
19
|
+
count(filter: Filter<DTO>): Promise<number>;
|
|
20
|
+
queryRelations<Relation>(RelationClass: Class<Relation>, relationName: string, dto: DTO, query: Query<Relation>): Promise<Relation[]>;
|
|
21
|
+
queryRelations<Relation>(RelationClass: Class<Relation>, relationName: string, dtos: DTO[], query: Query<Relation>): Promise<Map<DTO, Relation[]>>;
|
|
22
|
+
countRelations<Relation>(RelationClass: Class<Relation>, relationName: string, dto: DTO, filter: Filter<Relation>): Promise<number>;
|
|
23
|
+
countRelations<Relation>(RelationClass: Class<Relation>, relationName: string, dtos: DTO[], filter: Filter<Relation>): Promise<Map<DTO, number>>;
|
|
24
|
+
removeRelation<Relation>(relationName: string, id: string | number, relationId: string | number, opts?: ModifyRelationOptions<DTO, Relation>): Promise<DTO>;
|
|
25
|
+
removeRelations<Relation>(relationName: string, id: string | number, relationIds: (string | number)[], opts?: ModifyRelationOptions<DTO, Relation>): Promise<DTO>;
|
|
26
|
+
setRelations<Relation>(relationName: string, id: string | number, relationId: (string | number)[], opts?: ModifyRelationOptions<DTO, Relation>): Promise<DTO>;
|
|
27
|
+
setRelation<Relation>(relationName: string, id: string | number, relationId: string | number, opts?: ModifyRelationOptions<DTO, Relation>): Promise<DTO>;
|
|
28
|
+
updateMany(update: U, filter: Filter<DTO>): Promise<UpdateManyResponse>;
|
|
29
|
+
updateOne(id: string | number, update: U, opts?: UpdateOneOptions<DTO>): Promise<DTO>;
|
|
30
|
+
aggregateRelations<Relation>(RelationClass: Class<Relation>, relationName: string, dto: DTO, filter: Filter<Relation>, aggregate: AggregateQuery<Relation>): Promise<AggregateResponse<Relation>[]>;
|
|
31
|
+
aggregateRelations<Relation>(RelationClass: Class<Relation>, relationName: string, dtos: DTO[], filter: Filter<Relation>, aggregate: AggregateQuery<Relation>): Promise<Map<DTO, AggregateResponse<Relation>[]>>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NoOpQueryService = void 0;
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
class NoOpQueryService {
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
8
|
+
constructor() { }
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
10
|
+
static getInstance() {
|
|
11
|
+
return this.instance;
|
|
12
|
+
}
|
|
13
|
+
addRelations(relationName, id, relationIds, opts) {
|
|
14
|
+
return Promise.reject(new common_1.NotImplementedException('addRelations is not implemented'));
|
|
15
|
+
}
|
|
16
|
+
createMany(items) {
|
|
17
|
+
return Promise.reject(new common_1.NotImplementedException('createMany is not implemented'));
|
|
18
|
+
}
|
|
19
|
+
createOne(item) {
|
|
20
|
+
return Promise.reject(new common_1.NotImplementedException('createOne is not implemented'));
|
|
21
|
+
}
|
|
22
|
+
deleteMany(filter) {
|
|
23
|
+
return Promise.reject(new common_1.NotImplementedException('deleteMany is not implemented'));
|
|
24
|
+
}
|
|
25
|
+
deleteOne(id, opts) {
|
|
26
|
+
return Promise.reject(new common_1.NotImplementedException('deleteOne is not implemented'));
|
|
27
|
+
}
|
|
28
|
+
findById(id, opts) {
|
|
29
|
+
return Promise.reject(new common_1.NotImplementedException('findById is not implemented'));
|
|
30
|
+
}
|
|
31
|
+
findRelation(RelationClass, relationName, dto, opts) {
|
|
32
|
+
return Promise.reject(new common_1.NotImplementedException('findRelation is not implemented'));
|
|
33
|
+
}
|
|
34
|
+
getById(id, opts) {
|
|
35
|
+
return Promise.reject(new common_1.NotImplementedException('getById is not implemented'));
|
|
36
|
+
}
|
|
37
|
+
query(query) {
|
|
38
|
+
return Promise.reject(new common_1.NotImplementedException('query is not implemented'));
|
|
39
|
+
}
|
|
40
|
+
aggregate(filter, aggregate) {
|
|
41
|
+
return Promise.reject(new common_1.NotImplementedException('aggregate is not implemented'));
|
|
42
|
+
}
|
|
43
|
+
count(filter) {
|
|
44
|
+
return Promise.reject(new common_1.NotImplementedException('count is not implemented'));
|
|
45
|
+
}
|
|
46
|
+
queryRelations(RelationClass, relationName, dto, query) {
|
|
47
|
+
return Promise.reject(new common_1.NotImplementedException('queryRelations is not implemented'));
|
|
48
|
+
}
|
|
49
|
+
countRelations(RelationClass, relationName, dto, filter) {
|
|
50
|
+
return Promise.reject(new common_1.NotImplementedException('countRelations is not implemented'));
|
|
51
|
+
}
|
|
52
|
+
removeRelation(relationName, id, relationId, opts) {
|
|
53
|
+
return Promise.reject(new common_1.NotImplementedException('removeRelation is not implemented'));
|
|
54
|
+
}
|
|
55
|
+
removeRelations(relationName, id, relationIds, opts) {
|
|
56
|
+
return Promise.reject(new common_1.NotImplementedException('removeRelations is not implemented'));
|
|
57
|
+
}
|
|
58
|
+
setRelations(relationName, id, relationId, opts) {
|
|
59
|
+
return Promise.reject(new common_1.NotImplementedException('setRelations is not implemented'));
|
|
60
|
+
}
|
|
61
|
+
setRelation(relationName, id, relationId, opts) {
|
|
62
|
+
return Promise.reject(new common_1.NotImplementedException('setRelation is not implemented'));
|
|
63
|
+
}
|
|
64
|
+
updateMany(update, filter) {
|
|
65
|
+
return Promise.reject(new common_1.NotImplementedException('updateMany is not implemented'));
|
|
66
|
+
}
|
|
67
|
+
updateOne(id, update, opts) {
|
|
68
|
+
return Promise.reject(new common_1.NotImplementedException('updateOne is not implemented'));
|
|
69
|
+
}
|
|
70
|
+
aggregateRelations(RelationClass, relationName, dto, filter, aggregate) {
|
|
71
|
+
return Promise.reject(new common_1.NotImplementedException('aggregateRelations is not implemented'));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.NoOpQueryService = NoOpQueryService;
|
|
75
|
+
NoOpQueryService.instance = new NoOpQueryService();
|
|
76
|
+
//# sourceMappingURL=noop-query.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noop-query.service.js","sourceRoot":"","sources":["../../../../../packages/core/src/services/noop-query.service.ts"],"names":[],"mappings":";;;AAAA,sDAAsD;AACtD,2CAAyD;AAkBzD,MAAa,gBAAgB;IAQ3B,gEAAgE;IAChE,gBAAe,CAAC;IANhB,wDAAwD;IACxD,MAAM,CAAC,WAAW;QAChB,OAAO,IAAI,CAAC,QAAmC,CAAC;IAClD,CAAC;IAKD,YAAY,CACV,YAAoB,EACpB,EAAmB,EACnB,WAAgC,EAChC,IAA2C;QAE3C,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,gCAAuB,CAAC,iCAAiC,CAAC,CAAC,CAAC;IACxF,CAAC;IAED,UAAU,CAAC,KAAU;QACnB,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,gCAAuB,CAAC,+BAA+B,CAAC,CAAC,CAAC;IACtF,CAAC;IAED,SAAS,CAAC,IAAO;QACf,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,gCAAuB,CAAC,8BAA8B,CAAC,CAAC,CAAC;IACrF,CAAC;IAED,UAAU,CAAC,MAAmB;QAC5B,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,gCAAuB,CAAC,+BAA+B,CAAC,CAAC,CAAC;IACtF,CAAC;IAED,SAAS,CAAC,EAAmB,EAAE,IAA4B;QACzD,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,gCAAuB,CAAC,8BAA8B,CAAC,CAAC,CAAC;IACrF,CAAC;IAED,QAAQ,CAAC,EAAmB,EAAE,IAA2B;QACvD,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,gCAAuB,CAAC,6BAA6B,CAAC,CAAC,CAAC;IACpF,CAAC;IAgBD,YAAY,CACV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M,CAAC,IAAI,gCAAuB,CAAC,oCAAoC,CAAC,CAAC,CAAC;IAC3F,CAAC;IAED,YAAY,CACV,YAAoB,EACpB,EAAmB,EACnB,UAA+B,EAC/B,IAA2C;QAE3C,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,gCAAuB,CAAC,iCAAiC,CAAC,CAAC,CAAC;IACxF,CAAC;IAED,WAAW,CACT,YAAoB,EACpB,EAAmB,EACnB,UAA2B,EAC3B,IAA2C;QAE3C,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,gCAAuB,CAAC,gCAAgC,CAAC,CAAC,CAAC;IACvF,CAAC;IAED,UAAU,CAAC,MAAS,EAAE,MAAmB;QACvC,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,gCAAuB,CAAC,+BAA+B,CAAC,CAAC,CAAC;IACtF,CAAC;IAED,SAAS,CAAC,EAAmB,EAAE,MAAS,EAAE,IAA4B;QACpE,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,gCAAuB,CAAC,8BAA8B,CAAC,CAAC,CAAC;IACrF,CAAC;IAkBD,kBAAkB,CAChB,aAA8B,EAC9B,YAAoB,EACpB,GAAgB,EAChB,MAAwB,EACxB,SAAmC;QAEnC,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,gCAAuB,CAAC,uCAAuC,CAAC,CAAC,CAAC;IAC9F,CAAC;;AAjMH,4CAkMC;AAjMgB,yBAAQ,GAA4C,IAAI,gBAAgB,EAAE,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Class, DeepPartial } from '../common';
|
|
2
|
+
import { AggregateQuery, AggregateResponse, DeleteManyResponse, DeleteOneOptions, Filter, FindByIdOptions, FindRelationOptions, GetByIdOptions, ModifyRelationOptions, Query, UpdateManyResponse, UpdateOneOptions } from '../interfaces';
|
|
3
|
+
import { QueryService } from './query.service';
|
|
4
|
+
export declare class ProxyQueryService<DTO, C = DeepPartial<DTO>, U = DeepPartial<DTO>> implements QueryService<DTO, C, U> {
|
|
5
|
+
readonly proxied: QueryService<DTO, C, U>;
|
|
6
|
+
constructor(proxied: QueryService<DTO, C, U>);
|
|
7
|
+
addRelations<Relation>(relationName: string, id: string | number, relationIds: (string | number)[], opts?: ModifyRelationOptions<DTO, Relation>): Promise<DTO>;
|
|
8
|
+
removeRelation<Relation>(relationName: string, id: string | number, relationId: string | number, opts?: ModifyRelationOptions<DTO, Relation>): Promise<DTO>;
|
|
9
|
+
removeRelations<Relation>(relationName: string, id: string | number, relationIds: (string | number)[], opts?: ModifyRelationOptions<DTO, Relation>): Promise<DTO>;
|
|
10
|
+
setRelations<Relation>(relationName: string, id: string | number, relationIds: (string | number)[], opts?: ModifyRelationOptions<DTO, Relation>): Promise<DTO>;
|
|
11
|
+
setRelation<Relation>(relationName: string, id: string | number, relationId: string | number, opts?: ModifyRelationOptions<DTO, Relation>): Promise<DTO>;
|
|
12
|
+
/**
|
|
13
|
+
* Query for relations for an array of DTOs. This method will return a map with the DTO as the key and the relations as the value.
|
|
14
|
+
* @param RelationClass - The class of the relation.
|
|
15
|
+
* @param relationName - The name of the relation to load.
|
|
16
|
+
* @param dtos - the dtos to find relations for.
|
|
17
|
+
* @param query - A query to use to filter, page, and sort relations.
|
|
18
|
+
*/
|
|
19
|
+
queryRelations<Relation>(RelationClass: Class<Relation>, relationName: string, dtos: DTO[], query: Query<Relation>): Promise<Map<DTO, Relation[]>>;
|
|
20
|
+
/**
|
|
21
|
+
* Query for an array of relations.
|
|
22
|
+
* @param RelationClass - The class to serialize the relations into.
|
|
23
|
+
* @param dto - The dto to query relations for.
|
|
24
|
+
* @param relationName - The name of relation to query for.
|
|
25
|
+
* @param query - A query to filter, page and sort relations.
|
|
26
|
+
*/
|
|
27
|
+
queryRelations<Relation>(RelationClass: Class<Relation>, relationName: string, dto: DTO, query: Query<Relation>): Promise<Relation[]>;
|
|
28
|
+
countRelations<Relation>(RelationClass: Class<Relation>, relationName: string, dtos: DTO[], filter: Filter<Relation>): Promise<Map<DTO, number>>;
|
|
29
|
+
countRelations<Relation>(RelationClass: Class<Relation>, relationName: string, dto: DTO, filter: Filter<Relation>): Promise<number>;
|
|
30
|
+
/**
|
|
31
|
+
* Find a relation for an array of DTOs. This will return a Map where the key is the DTO and the value is to relation or undefined if not found.
|
|
32
|
+
* @param RelationClass - the class of the relation
|
|
33
|
+
* @param relationName - the name of the relation to load.
|
|
34
|
+
* @param dtos - the dtos to find the relation for.
|
|
35
|
+
* @param filter - Additional filter to apply when finding relations
|
|
36
|
+
*/
|
|
37
|
+
findRelation<Relation>(RelationClass: Class<Relation>, relationName: string, dtos: DTO[], opts?: FindRelationOptions<Relation>): Promise<Map<DTO, Relation | undefined>>;
|
|
38
|
+
/**
|
|
39
|
+
* Finds a single relation.
|
|
40
|
+
* @param RelationClass - The class to serialize the relation into.
|
|
41
|
+
* @param dto - The dto to find the relation for.
|
|
42
|
+
* @param relationName - The name of the relation to query for.
|
|
43
|
+
* @param filter - Additional filter to apply when finding relations
|
|
44
|
+
*/
|
|
45
|
+
findRelation<Relation>(RelationClass: Class<Relation>, relationName: string, dto: DTO, opts?: FindRelationOptions<Relation>): Promise<Relation | undefined>;
|
|
46
|
+
createMany(items: C[]): Promise<DTO[]>;
|
|
47
|
+
createOne(item: C): Promise<DTO>;
|
|
48
|
+
deleteMany(filter: Filter<DTO>): Promise<DeleteManyResponse>;
|
|
49
|
+
deleteOne(id: number | string, opts?: DeleteOneOptions<DTO>): Promise<DTO>;
|
|
50
|
+
findById(id: string | number, opts?: FindByIdOptions<DTO>): Promise<DTO | undefined>;
|
|
51
|
+
getById(id: string | number, opts?: GetByIdOptions<DTO>): Promise<DTO>;
|
|
52
|
+
query(query: Query<DTO>): Promise<DTO[]>;
|
|
53
|
+
aggregate(filter: Filter<DTO>, query: AggregateQuery<DTO>): Promise<AggregateResponse<DTO>[]>;
|
|
54
|
+
count(filter: Filter<DTO>): Promise<number>;
|
|
55
|
+
updateMany(update: U, filter: Filter<DTO>): Promise<UpdateManyResponse>;
|
|
56
|
+
updateOne(id: string | number, update: U, opts?: UpdateOneOptions<DTO>): Promise<DTO>;
|
|
57
|
+
aggregateRelations<Relation>(RelationClass: Class<Relation>, relationName: string, dto: DTO, filter: Filter<Relation>, aggregate: AggregateQuery<Relation>): Promise<AggregateResponse<Relation>[]>;
|
|
58
|
+
aggregateRelations<Relation>(RelationClass: Class<Relation>, relationName: string, dtos: DTO[], filter: Filter<Relation>, aggregate: AggregateQuery<Relation>): Promise<Map<DTO, AggregateResponse<Relation>[]>>;
|
|
59
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProxyQueryService = void 0;
|
|
4
|
+
class ProxyQueryService {
|
|
5
|
+
constructor(proxied) {
|
|
6
|
+
this.proxied = proxied;
|
|
7
|
+
}
|
|
8
|
+
addRelations(relationName, id, relationIds, opts) {
|
|
9
|
+
return this.proxied.addRelations(relationName, id, relationIds, opts);
|
|
10
|
+
}
|
|
11
|
+
removeRelation(relationName, id, relationId, opts) {
|
|
12
|
+
return this.proxied.removeRelation(relationName, id, relationId, opts);
|
|
13
|
+
}
|
|
14
|
+
removeRelations(relationName, id, relationIds, opts) {
|
|
15
|
+
return this.proxied.removeRelations(relationName, id, relationIds, opts);
|
|
16
|
+
}
|
|
17
|
+
setRelations(relationName, id, relationIds, opts) {
|
|
18
|
+
return this.proxied.setRelations(relationName, id, relationIds, opts);
|
|
19
|
+
}
|
|
20
|
+
setRelation(relationName, id, relationId, opts) {
|
|
21
|
+
return this.proxied.setRelation(relationName, id, relationId, opts);
|
|
22
|
+
}
|
|
23
|
+
async queryRelations(RelationClass, relationName, dto, query) {
|
|
24
|
+
if (Array.isArray(dto)) {
|
|
25
|
+
return this.proxied.queryRelations(RelationClass, relationName, dto, query);
|
|
26
|
+
}
|
|
27
|
+
return this.proxied.queryRelations(RelationClass, relationName, dto, query);
|
|
28
|
+
}
|
|
29
|
+
async countRelations(RelationClass, relationName, dto, filter) {
|
|
30
|
+
if (Array.isArray(dto)) {
|
|
31
|
+
return this.proxied.countRelations(RelationClass, relationName, dto, filter);
|
|
32
|
+
}
|
|
33
|
+
return this.proxied.countRelations(RelationClass, relationName, dto, filter);
|
|
34
|
+
}
|
|
35
|
+
async findRelation(RelationClass, relationName, dto, opts) {
|
|
36
|
+
if (Array.isArray(dto)) {
|
|
37
|
+
return this.proxied.findRelation(RelationClass, relationName, dto, opts);
|
|
38
|
+
}
|
|
39
|
+
return this.proxied.findRelation(RelationClass, relationName, dto, opts);
|
|
40
|
+
}
|
|
41
|
+
createMany(items) {
|
|
42
|
+
return this.proxied.createMany(items);
|
|
43
|
+
}
|
|
44
|
+
createOne(item) {
|
|
45
|
+
return this.proxied.createOne(item);
|
|
46
|
+
}
|
|
47
|
+
async deleteMany(filter) {
|
|
48
|
+
return this.proxied.deleteMany(filter);
|
|
49
|
+
}
|
|
50
|
+
deleteOne(id, opts) {
|
|
51
|
+
return this.proxied.deleteOne(id, opts);
|
|
52
|
+
}
|
|
53
|
+
async findById(id, opts) {
|
|
54
|
+
return this.proxied.findById(id, opts);
|
|
55
|
+
}
|
|
56
|
+
getById(id, opts) {
|
|
57
|
+
return this.proxied.getById(id, opts);
|
|
58
|
+
}
|
|
59
|
+
query(query) {
|
|
60
|
+
return this.proxied.query(query);
|
|
61
|
+
}
|
|
62
|
+
aggregate(filter, query) {
|
|
63
|
+
return this.proxied.aggregate(filter, query);
|
|
64
|
+
}
|
|
65
|
+
count(filter) {
|
|
66
|
+
return this.proxied.count(filter);
|
|
67
|
+
}
|
|
68
|
+
updateMany(update, filter) {
|
|
69
|
+
return this.proxied.updateMany(update, filter);
|
|
70
|
+
}
|
|
71
|
+
updateOne(id, update, opts) {
|
|
72
|
+
return this.proxied.updateOne(id, update, opts);
|
|
73
|
+
}
|
|
74
|
+
async aggregateRelations(RelationClass, relationName, dto, filter, aggregate) {
|
|
75
|
+
if (Array.isArray(dto)) {
|
|
76
|
+
return this.proxied.aggregateRelations(RelationClass, relationName, dto, filter, aggregate);
|
|
77
|
+
}
|
|
78
|
+
return this.proxied.aggregateRelations(RelationClass, relationName, dto, filter, aggregate);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
exports.ProxyQueryService = ProxyQueryService;
|
|
82
|
+
//# sourceMappingURL=proxy-query.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy-query.service.js","sourceRoot":"","sources":["../../../../../packages/core/src/services/proxy-query.service.ts"],"names":[],"mappings":";;;AAiBA,MAAa,iBAAiB;IAC5B,YAAqB,OAAgC;QAAhC,YAAO,GAAP,OAAO,CAAyB;IAAG,CAAC;IAEzD,YAAY,CACV,YAAoB,EACpB,EAAmB,EACnB,WAAgC,EAChC,IAA2C;QAE3C,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,YAAY,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;IACxE,CAAC;IAED,cAAc,CACZ,YAAoB,EACpB,EAAmB,EACnB,UAA2B,EAC3B,IAA2C;QAE3C,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,YAAY,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IACzE,CAAC;IAED,eAAe,CACb,YAAoB,EACpB,EAAmB,EACnB,WAAgC,EAChC,IAA2C;QAE3C,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,YAAY,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;IAC3E,CAAC;IAED,YAAY,CACV,YAAoB,EACpB,EAAmB,EACnB,WAAgC,EAChC,IAA2C;QAE3C,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,YAAY,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;IACxE,CAAC;IAED,WAAW,CACT,YAAoB,EACpB,EAAmB,EACnB,UAA2B,EAC3B,IAA2C;QAE3C,OAAO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AM,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC;IAgBD,KAAK,CAAC,kBAAkB,CACtB,aAA8B,EAC9B,YAAoB,EACpB,GAAgB,EAChB,MAAwB,EACxB,SAAmC;QAEnC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YACtB,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,aAAa,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;SAC7F;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,aAAa,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IAC9F,CAAC;CACF;AAhOD,8CAgOC"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { DeepPartial, Class } from '../common';
|
|
2
|
+
import { AggregateQuery, AggregateResponse, DeleteManyResponse, Filter, ModifyRelationOptions, Query, UpdateManyResponse, FindRelationOptions, FindByIdOptions, GetByIdOptions, UpdateOneOptions, DeleteOneOptions, DeleteManyOptions } from '../interfaces';
|
|
3
|
+
/**
|
|
4
|
+
* Base interface for all QueryServices.
|
|
5
|
+
*
|
|
6
|
+
* @typeparam T - The record type that the query service will operate on.
|
|
7
|
+
*/
|
|
8
|
+
export interface QueryService<DTO, C = DeepPartial<DTO>, U = DeepPartial<DTO>> {
|
|
9
|
+
/**
|
|
10
|
+
* Query for multiple records of type `T`.
|
|
11
|
+
* @param query - the query used to filer, page or sort records.
|
|
12
|
+
* @returns a promise with an array of records that match the query.
|
|
13
|
+
*/
|
|
14
|
+
query(query: Query<DTO>): Promise<DTO[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Perform an aggregate query
|
|
17
|
+
* @param filter
|
|
18
|
+
* @param aggregate
|
|
19
|
+
*/
|
|
20
|
+
aggregate(filter: Filter<DTO>, aggregate: AggregateQuery<DTO>): Promise<AggregateResponse<DTO>[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Count the number of records that match the filter.
|
|
23
|
+
* @param filter - the filter
|
|
24
|
+
* @returns a promise with the total number of records.
|
|
25
|
+
*/
|
|
26
|
+
count(filter: Filter<DTO>): Promise<number>;
|
|
27
|
+
/**
|
|
28
|
+
* Finds a record by `id`.
|
|
29
|
+
* @param id - the id of the record to find.
|
|
30
|
+
* @param opts - Additional options to apply when finding by id.
|
|
31
|
+
* @returns the found record or undefined.
|
|
32
|
+
*/
|
|
33
|
+
findById(id: string | number, opts?: FindByIdOptions<DTO>): Promise<DTO | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* Query for an array of relations.
|
|
36
|
+
* * @param RelationClass - The class to serialize the Relations into
|
|
37
|
+
* @param dto - The dto to query relations for.
|
|
38
|
+
* @param relationName - The name of relation to query for.
|
|
39
|
+
* @param query - A query to filter, page or sort relations.
|
|
40
|
+
*/
|
|
41
|
+
queryRelations<Relation>(RelationClass: Class<Relation>, relationName: string, dto: DTO, query: Query<Relation>): Promise<Relation[]>;
|
|
42
|
+
queryRelations<Relation>(RelationClass: Class<Relation>, relationName: string, dtos: DTO[], query: Query<Relation>): Promise<Map<DTO, Relation[]>>;
|
|
43
|
+
/**
|
|
44
|
+
* Aggregate relations for a DTO.
|
|
45
|
+
* * @param RelationClass - The class to serialize the Relations into
|
|
46
|
+
* @param dto - The DTO to query relations for.
|
|
47
|
+
* @param relationName - The name of relation to query for.
|
|
48
|
+
* @param filter - A filter to apply to relations.
|
|
49
|
+
* @param aggregate - The aggregate query
|
|
50
|
+
*/
|
|
51
|
+
aggregateRelations<Relation>(RelationClass: Class<Relation>, relationName: string, dto: DTO, filter: Filter<Relation>, aggregate: AggregateQuery<Relation>): Promise<AggregateResponse<Relation>[]>;
|
|
52
|
+
aggregateRelations<Relation>(RelationClass: Class<Relation>, relationName: string, dtos: DTO[], filter: Filter<Relation>, aggregate: AggregateQuery<Relation>): Promise<Map<DTO, AggregateResponse<Relation>[]>>;
|
|
53
|
+
/**
|
|
54
|
+
* Count the number of relations
|
|
55
|
+
* @param filter - Filter to create a where clause.
|
|
56
|
+
*/
|
|
57
|
+
countRelations<Relation>(RelationClass: Class<Relation>, relationName: string, dto: DTO, filter: Filter<Relation>): Promise<number>;
|
|
58
|
+
countRelations<Relation>(RelationClass: Class<Relation>, relationName: string, dto: DTO[], filter: Filter<Relation>): Promise<Map<DTO, number>>;
|
|
59
|
+
/**
|
|
60
|
+
* Finds a single relation.
|
|
61
|
+
* @param RelationClass - The class to serialize the Relation into
|
|
62
|
+
* @param dto - The dto to find the relation on.
|
|
63
|
+
* @param relationName - The name of the relation to query for.
|
|
64
|
+
* @param opts - Additional options.
|
|
65
|
+
*/
|
|
66
|
+
findRelation<Relation>(RelationClass: Class<Relation>, relationName: string, dto: DTO, opts?: FindRelationOptions<Relation>): Promise<Relation | undefined>;
|
|
67
|
+
/**
|
|
68
|
+
* Finds a single relation for each DTO passed in.
|
|
69
|
+
*
|
|
70
|
+
* @param RelationClass - The class to serialize the Relation into*
|
|
71
|
+
* @param relationName - The name of the relation to query for.
|
|
72
|
+
* @param dtos - The dto to find the relation on.
|
|
73
|
+
* @param opts - Additional options.
|
|
74
|
+
*/
|
|
75
|
+
findRelation<Relation>(RelationClass: Class<Relation>, relationName: string, dtos: DTO[], opts?: FindRelationOptions<Relation>): Promise<Map<DTO, Relation | undefined>>;
|
|
76
|
+
/**
|
|
77
|
+
* Adds multiple relations.
|
|
78
|
+
* @param relationName - The name of the relation to query for.
|
|
79
|
+
* @param id - The id of the dto to add the relation to.
|
|
80
|
+
* @param relationIds - The ids of the relations to add.
|
|
81
|
+
* @param opts - Additional options.
|
|
82
|
+
*/
|
|
83
|
+
addRelations<Relation>(relationName: string, id: string | number, relationIds: (string | number)[], opts?: ModifyRelationOptions<DTO, Relation>): Promise<DTO>;
|
|
84
|
+
/**
|
|
85
|
+
* Set the relations on the dto.
|
|
86
|
+
*
|
|
87
|
+
* @param relationName - The name of the relation to query for.
|
|
88
|
+
* @param id - The id of the dto to set the relation on.
|
|
89
|
+
* @param relationIds - The ids of the relation to set on the dto. If the array is empty the relations will be
|
|
90
|
+
* removed.
|
|
91
|
+
* @param opts - Additional options.
|
|
92
|
+
*/
|
|
93
|
+
setRelations<Relation>(relationName: string, id: string | number, relationIds: (string | number)[], opts?: ModifyRelationOptions<DTO, Relation>): Promise<DTO>;
|
|
94
|
+
/**
|
|
95
|
+
* Set the relation on the dto.
|
|
96
|
+
*
|
|
97
|
+
* @param relationName - The name of the relation to query for.
|
|
98
|
+
* @param id - The id of the dto to set the relation on.
|
|
99
|
+
* @param relationId - The id of the relation to set on the dto.
|
|
100
|
+
* @param opts - Additional options.
|
|
101
|
+
*/
|
|
102
|
+
setRelation<Relation>(relationName: string, id: string | number, relationId: string | number, opts?: ModifyRelationOptions<DTO, Relation>): Promise<DTO>;
|
|
103
|
+
/**
|
|
104
|
+
* Removes multiple relations.
|
|
105
|
+
* @param relationName - The name of the relation to query for.
|
|
106
|
+
* @param id - The id of the dto to add the relation to.
|
|
107
|
+
* @param relationIds - The ids of the relations to add.
|
|
108
|
+
* @param opts - Additional options.
|
|
109
|
+
*/
|
|
110
|
+
removeRelations<Relation>(relationName: string, id: string | number, relationIds: (string | number)[], opts?: ModifyRelationOptions<DTO, Relation>): Promise<DTO>;
|
|
111
|
+
/**
|
|
112
|
+
* Remove the relation on the dto.
|
|
113
|
+
*
|
|
114
|
+
* @param relationName - The name of the relation to query for.
|
|
115
|
+
* @param id - The id of the dto to set the relation on.
|
|
116
|
+
* @param relationId - The id of the relation to set on the dto.
|
|
117
|
+
* @param opts - Additional options.
|
|
118
|
+
*/
|
|
119
|
+
removeRelation<Relation>(relationName: string, id: string | number, relationId: string | number, opts?: ModifyRelationOptions<DTO, Relation>): Promise<DTO>;
|
|
120
|
+
/**
|
|
121
|
+
* Gets a record by `id`.
|
|
122
|
+
*
|
|
123
|
+
* **NOTE** This method will return a rejected Promise if the record is not found.
|
|
124
|
+
*
|
|
125
|
+
* @param id - the id of the record.
|
|
126
|
+
* @param opts - Additional options to apply when getting by id.
|
|
127
|
+
* @returns the found record or a rejected promise.
|
|
128
|
+
*/
|
|
129
|
+
getById(id: string | number, opts?: GetByIdOptions<DTO>): Promise<DTO>;
|
|
130
|
+
/**
|
|
131
|
+
* Create a single record.
|
|
132
|
+
*
|
|
133
|
+
* @param item - the record to create.
|
|
134
|
+
* @returns the created record.
|
|
135
|
+
*/
|
|
136
|
+
createOne(item: C): Promise<DTO>;
|
|
137
|
+
/**
|
|
138
|
+
* Creates a multiple record.
|
|
139
|
+
*
|
|
140
|
+
* @param items - the records to create.
|
|
141
|
+
* @returns a created records.
|
|
142
|
+
*/
|
|
143
|
+
createMany(items: C[]): Promise<DTO[]>;
|
|
144
|
+
/**
|
|
145
|
+
* Update one record.
|
|
146
|
+
* @param id - the id of the record to update
|
|
147
|
+
* @param update - The update to apply.
|
|
148
|
+
* @param opts - Additional opts to apply when updating one entity.
|
|
149
|
+
* @returns the updated record.
|
|
150
|
+
*/
|
|
151
|
+
updateOne(id: string | number, update: U, opts?: UpdateOneOptions<DTO>): Promise<DTO>;
|
|
152
|
+
/**
|
|
153
|
+
* Updates multiple records using a filter.
|
|
154
|
+
* @param update - the update to apply.
|
|
155
|
+
* @param filter - the filter used to specify records to update
|
|
156
|
+
*/
|
|
157
|
+
updateMany(update: U, filter: Filter<DTO>): Promise<UpdateManyResponse>;
|
|
158
|
+
/**
|
|
159
|
+
* Delete a single record by id.
|
|
160
|
+
* @param id - the id of the record to delete.
|
|
161
|
+
* @param opts - Additional opts to apply when deleting by id.
|
|
162
|
+
*/
|
|
163
|
+
deleteOne(id: number | string, opts?: DeleteOneOptions<DTO>): Promise<DTO>;
|
|
164
|
+
/**
|
|
165
|
+
* Delete multiple records using a filter.
|
|
166
|
+
*
|
|
167
|
+
* @param filter - the filter to find records to delete.
|
|
168
|
+
*/
|
|
169
|
+
deleteMany(filter: Filter<DTO>, opts?: DeleteManyOptions<DTO>): Promise<DeleteManyResponse>;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* QueryService decorator to register with nestjs-query
|
|
173
|
+
* @param DTOClass - the DTO class that the QueryService is used for.
|
|
174
|
+
*/
|
|
175
|
+
export declare function QueryService<DTO, C = DeepPartial<DTO>, U = DeepPartial<DTO>>(DTOClass: Class<DTO>): <Cls extends Class<QueryService<DTO, C, U>>>(cls: Cls) => void | Cls;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QueryService = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
/**
|
|
6
|
+
* QueryService decorator to register with nestjs-query
|
|
7
|
+
* @param DTOClass - the DTO class that the QueryService is used for.
|
|
8
|
+
*/
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare,@typescript-eslint/no-unused-vars -- intentional
|
|
10
|
+
function QueryService(DTOClass) {
|
|
11
|
+
return (cls) => (0, common_1.Injectable)()(cls);
|
|
12
|
+
}
|
|
13
|
+
exports.QueryService = QueryService;
|
|
14
|
+
//# sourceMappingURL=query.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.service.js","sourceRoot":"","sources":["../../../../../packages/core/src/services/query.service.ts"],"names":[],"mappings":";;;AAAA,2CAA4C;AAqR5C;;;GAGG;AACH,4GAA4G;AAC5G,SAAgB,YAAY,CAAkD,QAAoB;IAChG,OAAO,CAA6C,GAAQ,EAAc,EAAE,CAAC,IAAA,mBAAU,GAAE,CAAC,GAAG,CAAC,CAAC;AACjG,CAAC;AAFD,oCAEC"}
|