@ptc-org/nestjs-query-sequelize 1.0.0-alpha.1 → 1.0.0-alpha.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/README.md +5 -5
- package/package.json +4 -4
- package/src/index.d.ts +2 -0
- package/src/index.js.map +1 -0
- package/src/module.d.ts +5 -0
- package/src/module.js +19 -0
- package/src/module.js.map +1 -0
- package/src/providers.d.ts +3 -0
- package/src/providers.js +21 -0
- package/src/providers.js.map +1 -0
- package/src/query/aggregate.builder.d.ts +19 -0
- package/src/query/aggregate.builder.js +87 -0
- package/src/query/aggregate.builder.js.map +1 -0
- package/src/query/filter-query.builder.d.ts +96 -0
- package/src/query/filter-query.builder.js +203 -0
- package/src/query/filter-query.builder.js.map +1 -0
- package/src/query/index.d.ts +4 -0
- package/src/query/index.js +8 -0
- package/src/query/index.js.map +1 -0
- package/src/query/sql-comparison.builder.d.ts +26 -0
- package/src/query/sql-comparison.builder.js +74 -0
- package/src/query/sql-comparison.builder.js.map +1 -0
- package/src/query/where.builder.d.ts +24 -0
- package/src/query/where.builder.js +81 -0
- package/src/query/where.builder.js.map +1 -0
- package/src/services/index.d.ts +1 -0
- package/src/services/index.js +5 -0
- package/src/services/index.js.map +1 -0
- package/src/services/relation-query.service.d.ts +119 -0
- package/src/services/relation-query.service.js +234 -0
- package/src/services/relation-query.service.js.map +1 -0
- package/src/services/sequelize-query.service.d.ts +147 -0
- package/src/services/sequelize-query.service.js +239 -0
- package/src/services/sequelize-query.service.js.map +1 -0
- package/CHANGELOG.md +0 -426
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SQLComparisonBuilder = void 0;
|
|
4
|
+
const sequelize_1 = require("sequelize");
|
|
5
|
+
/**
|
|
6
|
+
* @internal
|
|
7
|
+
* Builder to create SQL Comparisons. (=, !=, \>, etc...)
|
|
8
|
+
*/
|
|
9
|
+
class SQLComparisonBuilder {
|
|
10
|
+
constructor(comparisonMap = SQLComparisonBuilder.DEFAULT_COMPARISON_MAP) {
|
|
11
|
+
this.comparisonMap = comparisonMap;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Creates a valid SQL fragment with parameters.
|
|
15
|
+
*
|
|
16
|
+
* @param field - the property in Entity to create the comparison for.
|
|
17
|
+
* @param cmp - the FilterComparisonOperator (eq, neq, gt, etc...)
|
|
18
|
+
* @param val - the value to compare to.
|
|
19
|
+
*/
|
|
20
|
+
build(field, cmp, val, alias) {
|
|
21
|
+
const col = alias ? `$${alias}.${field}$` : `${field}`;
|
|
22
|
+
const normalizedCmp = cmp.toLowerCase();
|
|
23
|
+
if (this.comparisonMap[normalizedCmp]) {
|
|
24
|
+
// comparison operator (e.b. =, !=, >, <)
|
|
25
|
+
return { [col]: { [this.comparisonMap[normalizedCmp]]: val } };
|
|
26
|
+
}
|
|
27
|
+
if (normalizedCmp === 'between') {
|
|
28
|
+
// between comparison (field BETWEEN x AND y)
|
|
29
|
+
return this.betweenComparisonSQL(col, val);
|
|
30
|
+
}
|
|
31
|
+
if (normalizedCmp === 'notbetween') {
|
|
32
|
+
// notBetween comparison (field NOT BETWEEN x AND y)
|
|
33
|
+
return this.notBetweenComparisonSQL(col, val);
|
|
34
|
+
}
|
|
35
|
+
throw new Error(`unknown operator ${JSON.stringify(cmp)}`);
|
|
36
|
+
}
|
|
37
|
+
betweenComparisonSQL(col, val) {
|
|
38
|
+
if (this.isBetweenVal(val)) {
|
|
39
|
+
return {
|
|
40
|
+
[col]: { [sequelize_1.Op.between]: [val.lower, val.upper] }
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
throw new Error(`Invalid value for between expected {lower: val, upper: val} got ${JSON.stringify(val)}`);
|
|
44
|
+
}
|
|
45
|
+
notBetweenComparisonSQL(col, val) {
|
|
46
|
+
if (this.isBetweenVal(val)) {
|
|
47
|
+
return {
|
|
48
|
+
[col]: { [sequelize_1.Op.notBetween]: [val.lower, val.upper] }
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
throw new Error(`Invalid value for not between expected {lower: val, upper: val} got ${JSON.stringify(val)}`);
|
|
52
|
+
}
|
|
53
|
+
isBetweenVal(val) {
|
|
54
|
+
return val !== null && typeof val === 'object' && 'lower' in val && 'upper' in val;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.SQLComparisonBuilder = SQLComparisonBuilder;
|
|
58
|
+
SQLComparisonBuilder.DEFAULT_COMPARISON_MAP = {
|
|
59
|
+
eq: sequelize_1.Op.eq,
|
|
60
|
+
neq: sequelize_1.Op.ne,
|
|
61
|
+
gt: sequelize_1.Op.gt,
|
|
62
|
+
gte: sequelize_1.Op.gte,
|
|
63
|
+
lt: sequelize_1.Op.lt,
|
|
64
|
+
lte: sequelize_1.Op.lte,
|
|
65
|
+
like: sequelize_1.Op.like,
|
|
66
|
+
in: sequelize_1.Op.in,
|
|
67
|
+
notin: sequelize_1.Op.notIn,
|
|
68
|
+
notlike: sequelize_1.Op.notLike,
|
|
69
|
+
ilike: sequelize_1.Op.iLike,
|
|
70
|
+
notilike: sequelize_1.Op.notILike,
|
|
71
|
+
is: sequelize_1.Op.is,
|
|
72
|
+
isnot: sequelize_1.Op.not
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=sql-comparison.builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-comparison.builder.js","sourceRoot":"","sources":["../../../../../packages/query-sequelize/src/query/sql-comparison.builder.ts"],"names":[],"mappings":";;;AACA,yCAAuD;AAavD;;;GAGG;AACH,MAAa,oBAAoB;IAkB/B,YAAqB,gBAAwC,oBAAoB,CAAC,sBAAsB;QAAnF,kBAAa,GAAb,aAAa,CAAsE;IAAG,CAAC;IAE5G;;;;;;OAMG;IACH,KAAK,CACH,KAAQ,EACR,GAAyC,EACzC,GAAqC,EACrC,KAAc;QAEd,MAAM,GAAG,G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AE,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,CAAgC,EAAE;aAClF,CAAC;SACH;QACD,MAAM,IAAI,KAAK,CAAC,uEAAuE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChH,CAAC;IAEO,YAAY,CAClB,GAAqC;QAErC,OAAO,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,IAAI,GAAG,IAAI,OAAO,IAAI,GAAG,CAAC;IACrF,CAAC;;AAxEH,oDAyEC;AAxEQ,2CAAsB,GAA2B;IACtD,EAAE,EAAE,cAAE,CAAC,EAAE;IACT,GAAG,EAAE,cAAE,CAAC,EAAE;IACV,EAAE,EAAE,cAAE,CAAC,EAAE;IACT,GAAG,EAAE,cAAE,CAAC,GAAG;IACX,EAAE,EAAE,cAAE,CAAC,EAAE;IACT,GAAG,EAAE,cAAE,CAAC,GAAG;IACX,IAAI,EAAE,cAAE,CAAC,IAAI;IACb,EAAE,EAAE,cAAE,CAAC,EAAE;IACT,KAAK,EAAE,cAAE,CAAC,KAAK;IACf,OAAO,EAAE,cAAE,CAAC,OAAO;IACnB,KAAK,EAAE,cAAE,CAAC,KAAK;IACf,QAAQ,EAAE,cAAE,CAAC,QAAQ;IACrB,EAAE,EAAE,cAAE,CAAC,EAAE;IACT,KAAK,EAAE,cAAE,CAAC,GAAG;CACd,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { WhereOptions, Association } from 'sequelize';
|
|
2
|
+
import { Filter } from '@ptc-org/nestjs-query-core';
|
|
3
|
+
import { SQLComparisonBuilder } from './sql-comparison.builder';
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
* Builds a WHERE clause from a Filter.
|
|
7
|
+
*/
|
|
8
|
+
export declare class WhereBuilder<Entity> {
|
|
9
|
+
readonly sqlComparisonBuilder: SQLComparisonBuilder<Entity>;
|
|
10
|
+
constructor(sqlComparisonBuilder?: SQLComparisonBuilder<Entity>);
|
|
11
|
+
/**
|
|
12
|
+
* Builds a WHERE clause from a Filter.
|
|
13
|
+
* @param filter - the filter to build the WHERE clause from.
|
|
14
|
+
* @param associations - map of associations that are included in the query.
|
|
15
|
+
*/
|
|
16
|
+
build(filter: Filter<Entity>, associations: Map<string, Association>, alias?: string): WhereOptions;
|
|
17
|
+
/**
|
|
18
|
+
* Creates field comparisons from a filter. This method will ignore and/or properties.
|
|
19
|
+
* @param filter - the filter with fields to create comparisons for.
|
|
20
|
+
*/
|
|
21
|
+
private filterFields;
|
|
22
|
+
private getField;
|
|
23
|
+
private withFilterComparison;
|
|
24
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WhereBuilder = void 0;
|
|
4
|
+
const sequelize_1 = require("sequelize");
|
|
5
|
+
const sql_comparison_builder_1 = require("./sql-comparison.builder");
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
* Builds a WHERE clause from a Filter.
|
|
9
|
+
*/
|
|
10
|
+
class WhereBuilder {
|
|
11
|
+
constructor(sqlComparisonBuilder = new sql_comparison_builder_1.SQLComparisonBuilder()) {
|
|
12
|
+
this.sqlComparisonBuilder = sqlComparisonBuilder;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Builds a WHERE clause from a Filter.
|
|
16
|
+
* @param filter - the filter to build the WHERE clause from.
|
|
17
|
+
* @param associations - map of associations that are included in the query.
|
|
18
|
+
*/
|
|
19
|
+
build(filter, associations, alias) {
|
|
20
|
+
const { and, or } = filter;
|
|
21
|
+
let ands = [];
|
|
22
|
+
let ors = [];
|
|
23
|
+
let whereOpts = {};
|
|
24
|
+
if (and && and.length) {
|
|
25
|
+
ands = and.map((f) => this.build(f, associations, alias));
|
|
26
|
+
}
|
|
27
|
+
if (or && or.length) {
|
|
28
|
+
ors = or.map((f) => this.build(f, associations, alias));
|
|
29
|
+
}
|
|
30
|
+
const filterAnds = this.filterFields(filter, associations, alias);
|
|
31
|
+
if (filterAnds) {
|
|
32
|
+
ands = [...ands, filterAnds];
|
|
33
|
+
}
|
|
34
|
+
if (ands.length) {
|
|
35
|
+
whereOpts = { ...whereOpts, [sequelize_1.Op.and]: ands };
|
|
36
|
+
}
|
|
37
|
+
if (ors.length) {
|
|
38
|
+
whereOpts = { ...whereOpts, [sequelize_1.Op.or]: ors };
|
|
39
|
+
}
|
|
40
|
+
return whereOpts;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Creates field comparisons from a filter. This method will ignore and/or properties.
|
|
44
|
+
* @param filter - the filter with fields to create comparisons for.
|
|
45
|
+
*/
|
|
46
|
+
filterFields(filter, associations, alias) {
|
|
47
|
+
const ands = Object.keys(filter)
|
|
48
|
+
.filter((f) => f !== 'and' && f !== 'or')
|
|
49
|
+
.map((field) => this.withFilterComparison(field, this.getField(filter, field), associations, alias));
|
|
50
|
+
if (ands.length === 1) {
|
|
51
|
+
return ands[0];
|
|
52
|
+
}
|
|
53
|
+
if (ands.length) {
|
|
54
|
+
return { [sequelize_1.Op.and]: ands };
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
getField(obj, field) {
|
|
59
|
+
return obj[field];
|
|
60
|
+
}
|
|
61
|
+
withFilterComparison(field, cmp, associations, alias) {
|
|
62
|
+
if (associations.has(field)) {
|
|
63
|
+
const wb = new WhereBuilder();
|
|
64
|
+
return wb.build(cmp, associations, field);
|
|
65
|
+
}
|
|
66
|
+
let colName = field;
|
|
67
|
+
if (alias && associations.has(alias)) {
|
|
68
|
+
colName = (associations.get(alias)?.target.rawAttributes[colName]?.field ?? colName);
|
|
69
|
+
}
|
|
70
|
+
const opts = Object.keys(cmp);
|
|
71
|
+
if (opts.length === 1) {
|
|
72
|
+
const cmpType = opts[0];
|
|
73
|
+
return this.sqlComparisonBuilder.build(colName, cmpType, cmp[cmpType], alias);
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
[sequelize_1.Op.or]: opts.map((cmpType) => this.sqlComparisonBuilder.build(colName, cmpType, cmp[cmpType], alias))
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.WhereBuilder = WhereBuilder;
|
|
81
|
+
//# sourceMappingURL=where.builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"where.builder.js","sourceRoot":"","sources":["../../../../../packages/query-sequelize/src/query/where.builder.ts"],"names":[],"mappings":";;;AAAA,yCAA0D;AAE1D,qEAAuF;AAEvF;;;GAGG;AACH,MAAa,YAAY;IACvB,YAAqB,uBAAqD,IAAI,6CAAoB,EAAU;QAAvF,yBAAoB,GAApB,oBAAoB,CAAmE;IAAG,CAAC;IAEhH;;;;OAIG;IACH,KAAK,CAAC,MAAsB,EAAE,YAAsC,EAAE,KAAc;QAClF,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,MAAM,CAAC;QAC3B,IAAI,IAAI,GAAmB,EAAE,CAAC;QAC9B,IAAI,GAAG,GAAmB,EAAE,CAAC;QAC7B,IAAI,SAAS,GAAiB,EAAE,CAAC;QACjC,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,EAAE;YACrB,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC;SAC3D;QACD,IAAI,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE;YACnB,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC;SACzD;QACD,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,E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KAAc;QAEd,IAAI,YAAY,CAAC,GAAG,CAAC,KAAe,CAAC,EAAE;YACrC,MAAM,EAAE,GAAG,IAAI,YAAY,EAAa,CAAC;YACzC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAmC,EAAE,YAAY,EAAE,KAAe,CAAC,CAAC;SACrF;QACD,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,IAAI,KAAK,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YACpC,OAAO,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,aAAa,CAAC,OAAiB,CAAC,EAAE,KAAK,IAAI,OAAO,CAAM,CAAC;SACrG;QACD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAA+C,CAAC;QAC5E,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;YACrB,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACxB,OAAO,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,CAAqC,EAAE,KAAK,CAAC,CAAC;SACnH;QACD,OAAO;YACL,CAAC,cAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAC5B,IAAI,CAAC,oBAAoB,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,CAAqC,EAAE,KAAK,CAAC,CAC3G;SACF,CAAC;IACJ,CAAC;CACF;AAnFD,oCAmFC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './sequelize-query.service';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/query-sequelize/src/services/index.ts"],"names":[],"mappings":";;;AAAA,yEAA0C"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { Query, Class, Filter, AggregateQuery, AggregateResponse, ModifyRelationOptions, GetByIdOptions, FindRelationOptions } from '@ptc-org/nestjs-query-core';
|
|
2
|
+
import { Model, ModelCtor } from 'sequelize-typescript';
|
|
3
|
+
import { FilterQueryBuilder } from '../query';
|
|
4
|
+
/**
|
|
5
|
+
* Base class to house relations loading.
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class RelationQueryService<Entity extends Model<Entity, Partial<Entity>>> {
|
|
9
|
+
abstract filterQueryBuilder: FilterQueryBuilder<Entity>;
|
|
10
|
+
abstract model: ModelCtor<Entity>;
|
|
11
|
+
abstract getById(id: string | number, opts?: GetByIdOptions<Entity>): Promise<Entity>;
|
|
12
|
+
/**
|
|
13
|
+
* Query for relations for an array of Entities. This method will return a map
|
|
14
|
+
* with the Entity as the key and the relations as the value.
|
|
15
|
+
* @param RelationClass - The class of the relation.
|
|
16
|
+
* @param relationName - The name of the relation to load.
|
|
17
|
+
* @param entities - the dtos to find relations for.
|
|
18
|
+
* @param query - A query to use to filter, page, and sort relations.
|
|
19
|
+
*/
|
|
20
|
+
queryRelations<Relation>(RelationClass: Class<Relation>, relationName: string, entities: Entity[], query: Query<Relation>): Promise<Map<Entity, Relation[]>>;
|
|
21
|
+
/**
|
|
22
|
+
* Query for an array of relations.
|
|
23
|
+
* @param RelationClass - The class to serialize the relations into.
|
|
24
|
+
* @param dto - The dto to query relations for.
|
|
25
|
+
* @param relationName - The name of relation to query for.
|
|
26
|
+
* @param query - A query to filter, page and sort relations.
|
|
27
|
+
*/
|
|
28
|
+
queryRelations<Relation>(RelationClass: Class<Relation>, relationName: string, dto: Entity, query: Query<Relation>): Promise<Relation[]>;
|
|
29
|
+
aggregateRelations<Relation>(RelationClass: Class<Relation>, relationName: string, entities: Entity[], filter: Filter<Relation>, aggregate: AggregateQuery<Relation>): Promise<Map<Entity, AggregateResponse<Relation>[]>>;
|
|
30
|
+
/**
|
|
31
|
+
* Query for an array of relations.
|
|
32
|
+
* @param RelationClass - The class to serialize the relations into.
|
|
33
|
+
* @param dto - The dto to query relations for.
|
|
34
|
+
* @param relationName - The name of relation to query for.
|
|
35
|
+
* @param filter - Filter for relations to aggregate on.
|
|
36
|
+
* @param aggregate - Aggregate query
|
|
37
|
+
*/
|
|
38
|
+
aggregateRelations<Relation>(RelationClass: Class<Relation>, relationName: string, dto: Entity, filter: Filter<Relation>, aggregate: AggregateQuery<Relation>): Promise<AggregateResponse<Relation>[]>;
|
|
39
|
+
countRelations<Relation>(RelationClass: Class<Relation>, relationName: string, entities: Entity[], filter: Filter<Relation>): Promise<Map<Entity, number>>;
|
|
40
|
+
countRelations<Relation>(RelationClass: Class<Relation>, relationName: string, dto: Entity, filter: Filter<Relation>): Promise<number>;
|
|
41
|
+
/**
|
|
42
|
+
* Find a relation for an array of Entities. This will return a Map where the key is the Entity and the value is to
|
|
43
|
+
* relation or undefined if not found.
|
|
44
|
+
* @param RelationClass - the class of the relation
|
|
45
|
+
* @param relationName - the name of the relation to load.
|
|
46
|
+
* @param dtos - the dtos to find the relation for.
|
|
47
|
+
* @param opts - Additional options
|
|
48
|
+
*/
|
|
49
|
+
findRelation<Relation>(RelationClass: Class<Relation>, relationName: string, dtos: Entity[], opts?: FindRelationOptions<Relation>): Promise<Map<Entity, Relation | undefined>>;
|
|
50
|
+
/**
|
|
51
|
+
* Finds a single relation.
|
|
52
|
+
* @param RelationClass - The class to serialize the relation into.
|
|
53
|
+
* @param dto - The dto to find the relation for.
|
|
54
|
+
* @param relationName - The name of the relation to query for.
|
|
55
|
+
* @param opts - Additional options
|
|
56
|
+
*/
|
|
57
|
+
findRelation<Relation>(RelationClass: Class<Relation>, relationName: string, dto: Entity, opts?: FindRelationOptions<Relation>): Promise<Relation | undefined>;
|
|
58
|
+
/**
|
|
59
|
+
* Add a single relation.
|
|
60
|
+
* @param id - The id of the entity to add the relation to.
|
|
61
|
+
* @param relationName - The name of the relation to query for.
|
|
62
|
+
* @param relationIds - The ids of relations to add.
|
|
63
|
+
* @param opts - Additional options
|
|
64
|
+
*/
|
|
65
|
+
addRelations<Relation>(relationName: string, id: string | number, relationIds: string[] | number[], opts?: ModifyRelationOptions<Entity, Relation>): Promise<Entity>;
|
|
66
|
+
/**
|
|
67
|
+
* Set the relations on the entity.
|
|
68
|
+
*
|
|
69
|
+
* @param id - The id of the entity to set the relation on.
|
|
70
|
+
* @param relationName - The name of the relation to query for.
|
|
71
|
+
* @param relationIds - The ids of the relation to set on the entity. If the relationIds is empty all relations
|
|
72
|
+
* will be removed.
|
|
73
|
+
* @param opts - Additional options
|
|
74
|
+
*/
|
|
75
|
+
setRelations<Relation>(relationName: string, id: string | number, relationIds: string[] | number[], opts?: ModifyRelationOptions<Entity, Relation>): Promise<Entity>;
|
|
76
|
+
/**
|
|
77
|
+
* Set the relation on the entity.
|
|
78
|
+
*
|
|
79
|
+
* @param id - The id of the entity to set the relation on.
|
|
80
|
+
* @param relationName - The name of the relation to query for.
|
|
81
|
+
* @param relationId - The id of the relation to set on the entity.
|
|
82
|
+
* @param opts - Additional options
|
|
83
|
+
*/
|
|
84
|
+
setRelation<Relation>(relationName: string, id: string | number, relationId: string | number, opts?: ModifyRelationOptions<Entity, Relation>): Promise<Entity>;
|
|
85
|
+
/**
|
|
86
|
+
* Removes multiple relations.
|
|
87
|
+
* @param id - The id of the entity to add the relation to.
|
|
88
|
+
* @param relationName - The name of the relation to query for.
|
|
89
|
+
* @param relationIds - The ids of the relations to add.
|
|
90
|
+
* @param opts - Additional options
|
|
91
|
+
*/
|
|
92
|
+
removeRelations<Relation>(relationName: string, id: string | number, relationIds: string[] | number[], opts?: ModifyRelationOptions<Entity, Relation>): Promise<Entity>;
|
|
93
|
+
/**
|
|
94
|
+
* Remove the relation on the entity.
|
|
95
|
+
*
|
|
96
|
+
* @param id - The id of the entity to set the relation on.
|
|
97
|
+
* @param relationName - The name of the relation to query for.
|
|
98
|
+
* @param relationId - The id of the relation to set on the entity.
|
|
99
|
+
* @param opts - Additional options
|
|
100
|
+
*/
|
|
101
|
+
removeRelation<Relation>(relationName: string, id: string | number, relationId: string | number, opts?: ModifyRelationOptions<Entity, Relation>): Promise<Entity>;
|
|
102
|
+
getRelationQueryBuilder<Relation extends Model>(model: ModelCtor<Relation>): FilterQueryBuilder<Relation>;
|
|
103
|
+
/**
|
|
104
|
+
* Query for an array of relations for multiple dtos.
|
|
105
|
+
* @param RelationClass - The class to serialize the relations into.
|
|
106
|
+
* @param entities - The entities to query relations for.
|
|
107
|
+
* @param relationName - The name of relation to query for.
|
|
108
|
+
* @param query - A query to filter, page or sort relations.
|
|
109
|
+
*/
|
|
110
|
+
private batchQueryRelations;
|
|
111
|
+
private batchAggregateRelations;
|
|
112
|
+
private batchCountRelations;
|
|
113
|
+
private batchFindRelations;
|
|
114
|
+
private ensureIsEntity;
|
|
115
|
+
private getAssociation;
|
|
116
|
+
private getRelationEntity;
|
|
117
|
+
private getRelations;
|
|
118
|
+
private foundAllRelations;
|
|
119
|
+
}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RelationQueryService = void 0;
|
|
4
|
+
const nestjs_query_core_1 = require("@ptc-org/nestjs-query-core");
|
|
5
|
+
const query_1 = require("../query");
|
|
6
|
+
/**
|
|
7
|
+
* Base class to house relations loading.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
class RelationQueryService {
|
|
11
|
+
async queryRelations(RelationClass, relationName, dto, query) {
|
|
12
|
+
if (Array.isArray(dto)) {
|
|
13
|
+
return this.batchQueryRelations(RelationClass, relationName, dto, query);
|
|
14
|
+
}
|
|
15
|
+
const relationEntity = this.getRelationEntity(relationName);
|
|
16
|
+
const assembler = nestjs_query_core_1.AssemblerFactory.getAssembler(RelationClass, relationEntity);
|
|
17
|
+
const relationQueryBuilder = this.getRelationQueryBuilder(relationEntity);
|
|
18
|
+
const relations = await this.ensureIsEntity(dto).$get(relationName, relationQueryBuilder.findOptions(assembler.convertQuery(query)));
|
|
19
|
+
return assembler.convertToDTOs(relations);
|
|
20
|
+
}
|
|
21
|
+
async aggregateRelations(RelationClass, relationName, dto, filter, aggregate) {
|
|
22
|
+
if (Array.isArray(dto)) {
|
|
23
|
+
return this.batchAggregateRelations(RelationClass, relationName, dto, filter, aggregate);
|
|
24
|
+
}
|
|
25
|
+
const relationEntity = this.getRelationEntity(relationName);
|
|
26
|
+
const assembler = nestjs_query_core_1.AssemblerFactory.getAssembler(RelationClass, relationEntity);
|
|
27
|
+
const relationQueryBuilder = this.getRelationQueryBuilder(relationEntity);
|
|
28
|
+
const results = (await this.ensureIsEntity(dto).$get(relationName, relationQueryBuilder.relationAggregateOptions(assembler.convertQuery({ filter }), assembler.convertAggregateQuery(aggregate))));
|
|
29
|
+
return query_1.AggregateBuilder.convertToAggregateResponse(results).map((a) => assembler.convertAggregateResponse(a));
|
|
30
|
+
}
|
|
31
|
+
async countRelations(RelationClass, relationName, dto, filter) {
|
|
32
|
+
if (Array.isArray(dto)) {
|
|
33
|
+
return this.batchCountRelations(RelationClass, relationName, dto, filter);
|
|
34
|
+
}
|
|
35
|
+
const relationEntity = this.getRelationEntity(relationName);
|
|
36
|
+
const assembler = nestjs_query_core_1.AssemblerFactory.getAssembler(RelationClass, relationEntity);
|
|
37
|
+
const relationQueryBuilder = this.getRelationQueryBuilder(relationEntity);
|
|
38
|
+
return this.ensureIsEntity(dto).$count(relationName, relationQueryBuilder.countOptions(assembler.convertQuery({ filter })));
|
|
39
|
+
}
|
|
40
|
+
async findRelation(RelationClass, relationName, dto, opts) {
|
|
41
|
+
if (Array.isArray(dto)) {
|
|
42
|
+
return this.batchFindRelations(RelationClass, relationName, dto, opts);
|
|
43
|
+
}
|
|
44
|
+
const relationEntity = this.getRelationEntity(relationName);
|
|
45
|
+
const assembler = nestjs_query_core_1.AssemblerFactory.getAssembler(RelationClass, relationEntity);
|
|
46
|
+
const relationQueryBuilder = this.getRelationQueryBuilder(relationEntity);
|
|
47
|
+
const relation = await this.ensureIsEntity(dto).$get(relationName, relationQueryBuilder.findOptions(opts ?? {}));
|
|
48
|
+
if (!relation) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
return assembler.convertToDTO(relation);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Add a single relation.
|
|
55
|
+
* @param id - The id of the entity to add the relation to.
|
|
56
|
+
* @param relationName - The name of the relation to query for.
|
|
57
|
+
* @param relationIds - The ids of relations to add.
|
|
58
|
+
* @param opts - Additional options
|
|
59
|
+
*/
|
|
60
|
+
async addRelations(relationName, id, relationIds, opts) {
|
|
61
|
+
const entity = await this.getById(id, opts);
|
|
62
|
+
const relations = await this.getRelations(relationName, relationIds, opts?.relationFilter);
|
|
63
|
+
if (!this.foundAllRelations(relationIds, relations)) {
|
|
64
|
+
throw new Error(`Unable to find all ${relationName} to add to ${this.model.name}`);
|
|
65
|
+
}
|
|
66
|
+
await entity.$add(relationName, relationIds);
|
|
67
|
+
return entity;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Set the relations on the entity.
|
|
71
|
+
*
|
|
72
|
+
* @param id - The id of the entity to set the relation on.
|
|
73
|
+
* @param relationName - The name of the relation to query for.
|
|
74
|
+
* @param relationIds - The ids of the relation to set on the entity. If the relationIds is empty all relations
|
|
75
|
+
* will be removed.
|
|
76
|
+
* @param opts - Additional options
|
|
77
|
+
*/
|
|
78
|
+
async setRelations(relationName, id, relationIds, opts) {
|
|
79
|
+
const entity = await this.getById(id, opts);
|
|
80
|
+
if (relationIds.length) {
|
|
81
|
+
const relations = await this.getRelations(relationName, relationIds, opts?.relationFilter);
|
|
82
|
+
if (relations.length !== relationIds.length) {
|
|
83
|
+
throw new Error(`Unable to find all ${relationName} to set on ${this.model.name}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
await entity.$set(relationName, relationIds);
|
|
87
|
+
return entity;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Set the relation on the entity.
|
|
91
|
+
*
|
|
92
|
+
* @param id - The id of the entity to set the relation on.
|
|
93
|
+
* @param relationName - The name of the relation to query for.
|
|
94
|
+
* @param relationId - The id of the relation to set on the entity.
|
|
95
|
+
* @param opts - Additional options
|
|
96
|
+
*/
|
|
97
|
+
async setRelation(relationName, id, relationId, opts) {
|
|
98
|
+
const entity = await this.getById(id, opts);
|
|
99
|
+
const relation = (await this.getRelations(relationName, [relationId], opts?.relationFilter))[0];
|
|
100
|
+
if (!relation) {
|
|
101
|
+
throw new Error(`Unable to find ${relationName} to set on ${this.model.name}`);
|
|
102
|
+
}
|
|
103
|
+
await entity.$set(relationName, relationId);
|
|
104
|
+
return entity;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Removes multiple relations.
|
|
108
|
+
* @param id - The id of the entity to add the relation to.
|
|
109
|
+
* @param relationName - The name of the relation to query for.
|
|
110
|
+
* @param relationIds - The ids of the relations to add.
|
|
111
|
+
* @param opts - Additional options
|
|
112
|
+
*/
|
|
113
|
+
async removeRelations(relationName, id, relationIds, opts) {
|
|
114
|
+
const entity = await this.getById(id, opts);
|
|
115
|
+
const relations = await this.getRelations(relationName, relationIds, opts?.relationFilter);
|
|
116
|
+
if (!this.foundAllRelations(relationIds, relations)) {
|
|
117
|
+
throw new Error(`Unable to find all ${relationName} to remove from ${this.model.name}`);
|
|
118
|
+
}
|
|
119
|
+
await entity.$remove(relationName, relationIds);
|
|
120
|
+
return entity;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Remove the relation on the entity.
|
|
124
|
+
*
|
|
125
|
+
* @param id - The id of the entity to set the relation on.
|
|
126
|
+
* @param relationName - The name of the relation to query for.
|
|
127
|
+
* @param relationId - The id of the relation to set on the entity.
|
|
128
|
+
* @param opts - Additional options
|
|
129
|
+
*/
|
|
130
|
+
async removeRelation(relationName, id, relationId, opts) {
|
|
131
|
+
const entity = await this.getById(id, opts);
|
|
132
|
+
const association = this.getAssociation(relationName);
|
|
133
|
+
const relation = (await this.getRelations(relationName, [relationId], opts?.relationFilter))[0];
|
|
134
|
+
if (!relation) {
|
|
135
|
+
throw new Error(`Unable to find ${relationName} to remove from ${this.model.name}`);
|
|
136
|
+
}
|
|
137
|
+
if (association.isSingleAssociation) {
|
|
138
|
+
// TODO:: update that this line to remove the casting once
|
|
139
|
+
// https://github.com/RobinBuschmann/sequelize-typescript/issues/803 is addressed.
|
|
140
|
+
await entity.$set(relationName, null);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
await entity.$remove(relationName, relationId);
|
|
144
|
+
}
|
|
145
|
+
return entity;
|
|
146
|
+
}
|
|
147
|
+
getRelationQueryBuilder(model) {
|
|
148
|
+
return new query_1.FilterQueryBuilder(model);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Query for an array of relations for multiple dtos.
|
|
152
|
+
* @param RelationClass - The class to serialize the relations into.
|
|
153
|
+
* @param entities - The entities to query relations for.
|
|
154
|
+
* @param relationName - The name of relation to query for.
|
|
155
|
+
* @param query - A query to filter, page or sort relations.
|
|
156
|
+
*/
|
|
157
|
+
async batchQueryRelations(RelationClass, relationName, entities, query) {
|
|
158
|
+
const relationEntity = this.getRelationEntity(relationName);
|
|
159
|
+
const assembler = nestjs_query_core_1.AssemblerFactory.getAssembler(RelationClass, relationEntity);
|
|
160
|
+
const relationQueryBuilder = this.getRelationQueryBuilder(relationEntity);
|
|
161
|
+
const findOptions = relationQueryBuilder.findOptions(assembler.convertQuery(query));
|
|
162
|
+
return entities.reduce(async (mapPromise, e) => {
|
|
163
|
+
const map = await mapPromise;
|
|
164
|
+
const relations = await this.ensureIsEntity(e).$get(relationName, findOptions);
|
|
165
|
+
map.set(e, assembler.convertToDTOs(relations));
|
|
166
|
+
return map;
|
|
167
|
+
}, Promise.resolve(new Map()));
|
|
168
|
+
}
|
|
169
|
+
async batchAggregateRelations(RelationClass, relationName, entities, filter, aggregate) {
|
|
170
|
+
const relationEntity = this.getRelationEntity(relationName);
|
|
171
|
+
const assembler = nestjs_query_core_1.AssemblerFactory.getAssembler(RelationClass, relationEntity);
|
|
172
|
+
const relationQueryBuilder = this.getRelationQueryBuilder(relationEntity);
|
|
173
|
+
const findOptions = relationQueryBuilder.relationAggregateOptions(assembler.convertQuery({ filter }), assembler.convertAggregateQuery(aggregate));
|
|
174
|
+
return entities.reduce(async (mapPromise, e) => {
|
|
175
|
+
const map = await mapPromise;
|
|
176
|
+
const results = (await this.ensureIsEntity(e).$get(relationName, findOptions));
|
|
177
|
+
const aggResponse = query_1.AggregateBuilder.convertToAggregateResponse(results).map((agg) => assembler.convertAggregateResponse(agg));
|
|
178
|
+
map.set(e, aggResponse);
|
|
179
|
+
return map;
|
|
180
|
+
}, Promise.resolve(new Map()));
|
|
181
|
+
}
|
|
182
|
+
async batchCountRelations(RelationClass, relationName, entities, filter) {
|
|
183
|
+
const relationEntity = this.getRelationEntity(relationName);
|
|
184
|
+
const assembler = nestjs_query_core_1.AssemblerFactory.getAssembler(RelationClass, relationEntity);
|
|
185
|
+
const relationQueryBuilder = this.getRelationQueryBuilder(relationEntity);
|
|
186
|
+
const findOptions = relationQueryBuilder.countOptions(assembler.convertQuery({ filter }));
|
|
187
|
+
return entities.reduce(async (mapPromise, e) => {
|
|
188
|
+
const map = await mapPromise;
|
|
189
|
+
const count = await this.ensureIsEntity(e).$count(relationName, findOptions);
|
|
190
|
+
map.set(e, count);
|
|
191
|
+
return map;
|
|
192
|
+
}, Promise.resolve(new Map()));
|
|
193
|
+
}
|
|
194
|
+
async batchFindRelations(RelationClass, relationName, dtos, opts) {
|
|
195
|
+
const relationEntity = this.getRelationEntity(relationName);
|
|
196
|
+
const assembler = nestjs_query_core_1.AssemblerFactory.getAssembler(RelationClass, relationEntity);
|
|
197
|
+
const relationQueryBuilder = this.getRelationQueryBuilder(relationEntity);
|
|
198
|
+
return dtos.reduce(async (mapPromise, e) => {
|
|
199
|
+
const map = await mapPromise;
|
|
200
|
+
const relation = await this.ensureIsEntity(e).$get(relationName, relationQueryBuilder.findOptions(opts ?? {}));
|
|
201
|
+
if (relation) {
|
|
202
|
+
map.set(e, assembler.convertToDTO(relation));
|
|
203
|
+
}
|
|
204
|
+
return map;
|
|
205
|
+
}, Promise.resolve(new Map()));
|
|
206
|
+
}
|
|
207
|
+
ensureIsEntity(entity) {
|
|
208
|
+
if (!(entity instanceof this.model)) {
|
|
209
|
+
return this.model.build(entity);
|
|
210
|
+
}
|
|
211
|
+
return entity;
|
|
212
|
+
}
|
|
213
|
+
getAssociation(relationName) {
|
|
214
|
+
const association = this.model.associations[relationName];
|
|
215
|
+
if (!association) {
|
|
216
|
+
throw new Error(`Unable to find relation ${relationName} on ${this.model.name}`);
|
|
217
|
+
}
|
|
218
|
+
return association;
|
|
219
|
+
}
|
|
220
|
+
getRelationEntity(relationName) {
|
|
221
|
+
return this.getAssociation(relationName).target;
|
|
222
|
+
}
|
|
223
|
+
getRelations(relationName, ids, filter) {
|
|
224
|
+
const relationEntity = this.getRelationEntity(relationName);
|
|
225
|
+
const relationQueryBuilder = this.getRelationQueryBuilder(relationEntity);
|
|
226
|
+
const findOptions = relationQueryBuilder.findByIdOptions(ids, { filter });
|
|
227
|
+
return relationEntity.findAll({ ...findOptions, attributes: [...relationEntity.primaryKeyAttributes] });
|
|
228
|
+
}
|
|
229
|
+
foundAllRelations(relationIds, relations) {
|
|
230
|
+
return new Set([...relationIds]).size === relations.length;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
exports.RelationQueryService = RelationQueryService;
|
|
234
|
+
//# sourceMappingURL=relation-query.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relation-query.service.js","sourceRoot":"","sources":["../../../../../packages/query-sequelize/src/services/relation-query.service.ts"],"names":[],"mappings":";;;AAAA,kEAUoC;AAGpC,oCAAgE;AAUhE;;;GAGG;AACH,MAAsB,oBAAoB;IAoCxC,KAAK,CAAC,cAAc,CAClB,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