@loopback/repository 4.1.1 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/dist/connectors/connector.js +1 -1
- package/dist/connectors/connector.js.map +1 -1
- package/dist/connectors/crud.connector.js +1 -1
- package/dist/connectors/crud.connector.js.map +1 -1
- package/dist/connectors/index.js +4 -4
- package/dist/connectors/index.js.map +1 -1
- package/dist/connectors/kv.connector.js +1 -1
- package/dist/connectors/kv.connector.js.map +1 -1
- package/dist/datasource.js +1 -1
- package/dist/datasource.js.map +1 -1
- package/dist/decorators/index.js +4 -4
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/metadata.js +1 -1
- package/dist/decorators/metadata.js.map +1 -1
- package/dist/decorators/model.decorator.js +1 -1
- package/dist/decorators/model.decorator.js.map +1 -1
- package/dist/decorators/repository.decorator.js +2 -2
- package/dist/decorators/repository.decorator.js.map +1 -1
- package/dist/define-model-class.js +2 -2
- package/dist/define-model-class.js.map +1 -1
- package/dist/define-repository-class.js +2 -2
- package/dist/define-repository-class.js.map +1 -1
- package/dist/errors/entity-not-found.error.js +1 -1
- package/dist/errors/entity-not-found.error.js.map +1 -1
- package/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.js +4 -3
- package/dist/errors/index.js.map +1 -1
- package/dist/errors/invalid-polymorphism.error.d.ts +5 -0
- package/dist/errors/invalid-polymorphism.error.js +22 -0
- package/dist/errors/invalid-polymorphism.error.js.map +1 -0
- package/dist/errors/invalid-relation.error.d.ts +1 -1
- package/dist/errors/invalid-relation.error.js +1 -1
- package/dist/errors/invalid-relation.error.js.map +1 -1
- package/dist/index.js +17 -17
- package/dist/index.js.map +1 -1
- package/dist/mixins/index.js +2 -2
- package/dist/mixins/index.js.map +1 -1
- package/dist/mixins/repository.mixin.d.ts +49 -50
- package/dist/mixins/repository.mixin.js +2 -2
- package/dist/mixins/repository.mixin.js.map +1 -1
- package/dist/model.d.ts +7 -1
- package/dist/model.js +15 -1
- package/dist/model.js.map +1 -1
- package/dist/relations/belongs-to/belongs-to.accessor.d.ts +6 -2
- package/dist/relations/belongs-to/belongs-to.accessor.js +20 -7
- package/dist/relations/belongs-to/belongs-to.accessor.js.map +1 -1
- package/dist/relations/belongs-to/belongs-to.decorator.js +1 -1
- package/dist/relations/belongs-to/belongs-to.decorator.js.map +1 -1
- package/dist/relations/belongs-to/belongs-to.helpers.d.ts +3 -0
- package/dist/relations/belongs-to/belongs-to.helpers.js +34 -10
- package/dist/relations/belongs-to/belongs-to.helpers.js.map +1 -1
- package/dist/relations/belongs-to/belongs-to.inclusion-resolver.d.ts +5 -2
- package/dist/relations/belongs-to/belongs-to.inclusion-resolver.js +82 -9
- package/dist/relations/belongs-to/belongs-to.inclusion-resolver.js.map +1 -1
- package/dist/relations/belongs-to/belongs-to.repository.d.ts +28 -5
- package/dist/relations/belongs-to/belongs-to.repository.js +50 -11
- package/dist/relations/belongs-to/belongs-to.repository.js.map +1 -1
- package/dist/relations/belongs-to/index.d.ts +2 -2
- package/dist/relations/belongs-to/index.js +5 -5
- package/dist/relations/belongs-to/index.js.map +1 -1
- package/dist/relations/has-many/has-many-through.helpers.d.ts +3 -0
- package/dist/relations/has-many/has-many-through.helpers.js +27 -3
- package/dist/relations/has-many/has-many-through.helpers.js.map +1 -1
- package/dist/relations/has-many/has-many-through.inclusion-resolver.d.ts +3 -1
- package/dist/relations/has-many/has-many-through.inclusion-resolver.js +94 -23
- package/dist/relations/has-many/has-many-through.inclusion-resolver.js.map +1 -1
- package/dist/relations/has-many/has-many-through.repository-factory.d.ts +3 -1
- package/dist/relations/has-many/has-many-through.repository-factory.js +8 -2
- package/dist/relations/has-many/has-many-through.repository-factory.js.map +1 -1
- package/dist/relations/has-many/has-many-through.repository.d.ts +66 -11
- package/dist/relations/has-many/has-many-through.repository.js +212 -36
- package/dist/relations/has-many/has-many-through.repository.js.map +1 -1
- package/dist/relations/has-many/has-many.decorator.js +1 -1
- package/dist/relations/has-many/has-many.decorator.js.map +1 -1
- package/dist/relations/has-many/has-many.helpers.js +2 -2
- package/dist/relations/has-many/has-many.helpers.js.map +1 -1
- package/dist/relations/has-many/has-many.inclusion-resolver.js +2 -2
- package/dist/relations/has-many/has-many.inclusion-resolver.js.map +1 -1
- package/dist/relations/has-many/has-many.repository-factory.js +2 -2
- package/dist/relations/has-many/has-many.repository-factory.js.map +1 -1
- package/dist/relations/has-many/has-many.repository.js +1 -1
- package/dist/relations/has-many/has-many.repository.js.map +1 -1
- package/dist/relations/has-many/index.d.ts +2 -2
- package/dist/relations/has-many/index.js +7 -7
- package/dist/relations/has-many/index.js.map +1 -1
- package/dist/relations/has-one/has-one.decorator.js +1 -1
- package/dist/relations/has-one/has-one.decorator.js.map +1 -1
- package/dist/relations/has-one/has-one.helpers.d.ts +3 -0
- package/dist/relations/has-one/has-one.helpers.js +36 -10
- package/dist/relations/has-one/has-one.helpers.js.map +1 -1
- package/dist/relations/has-one/has-one.inclusion-resolver.d.ts +6 -3
- package/dist/relations/has-one/has-one.inclusion-resolver.js +83 -8
- package/dist/relations/has-one/has-one.inclusion-resolver.js.map +1 -1
- package/dist/relations/has-one/has-one.repository-factory.d.ts +9 -3
- package/dist/relations/has-one/has-one.repository-factory.js +15 -5
- package/dist/relations/has-one/has-one.repository-factory.js.map +1 -1
- package/dist/relations/has-one/has-one.repository.d.ts +58 -11
- package/dist/relations/has-one/has-one.repository.js +119 -16
- package/dist/relations/has-one/has-one.repository.js.map +1 -1
- package/dist/relations/has-one/index.js +4 -4
- package/dist/relations/has-one/index.js.map +1 -1
- package/dist/relations/index.d.ts +2 -0
- package/dist/relations/index.js +9 -7
- package/dist/relations/index.js.map +1 -1
- package/dist/relations/references-many/index.d.ts +4 -0
- package/dist/relations/references-many/index.js +12 -0
- package/dist/relations/references-many/index.js.map +1 -0
- package/dist/relations/references-many/references-many.accessor.d.ts +17 -0
- package/dist/relations/references-many/references-many.accessor.js +40 -0
- package/dist/relations/references-many/references-many.accessor.js.map +1 -0
- package/dist/relations/references-many/references-many.decorator.d.ts +11 -0
- package/dist/relations/references-many/references-many.decorator.js +73 -0
- package/dist/relations/references-many/references-many.decorator.js.map +1 -0
- package/dist/relations/references-many/references-many.helpers.d.ts +17 -0
- package/dist/relations/references-many/references-many.helpers.js +63 -0
- package/dist/relations/references-many/references-many.helpers.js.map +1 -0
- package/dist/relations/references-many/references-many.inclusion-resolver.d.ts +14 -0
- package/dist/relations/references-many/references-many.inclusion-resolver.js +42 -0
- package/dist/relations/references-many/references-many.inclusion-resolver.js.map +1 -0
- package/dist/relations/references-many/references-many.repository.d.ts +28 -0
- package/dist/relations/references-many/references-many.repository.js +33 -0
- package/dist/relations/references-many/references-many.repository.js.map +1 -0
- package/dist/relations/relation.decorator.d.ts +0 -6
- package/dist/relations/relation.decorator.js +2 -14
- package/dist/relations/relation.decorator.js.map +1 -1
- package/dist/relations/relation.filter.solver.d.ts +2 -0
- package/dist/relations/relation.filter.solver.js +57 -0
- package/dist/relations/relation.filter.solver.js.map +1 -0
- package/dist/relations/relation.helpers.js +20 -5
- package/dist/relations/relation.helpers.js.map +1 -1
- package/dist/relations/relation.types.d.ts +52 -1
- package/dist/relations/relation.types.js +1 -1
- package/dist/relations/relation.types.js.map +1 -1
- package/dist/repositories/constraint-utils.js +1 -1
- package/dist/repositories/constraint-utils.js.map +1 -1
- package/dist/repositories/index.d.ts +2 -2
- package/dist/repositories/index.js +6 -6
- package/dist/repositories/index.js.map +1 -1
- package/dist/repositories/kv.repository.bridge.js +1 -1
- package/dist/repositories/kv.repository.bridge.js.map +1 -1
- package/dist/repositories/kv.repository.d.ts +2 -2
- package/dist/repositories/kv.repository.js +1 -1
- package/dist/repositories/kv.repository.js.map +1 -1
- package/dist/repositories/legacy-juggler-bridge.d.ts +35 -8
- package/dist/repositories/legacy-juggler-bridge.js +39 -17
- package/dist/repositories/legacy-juggler-bridge.js.map +1 -1
- package/dist/repositories/repository.js +1 -1
- package/dist/repositories/repository.js.map +1 -1
- package/dist/type-resolver.js +1 -1
- package/dist/type-resolver.js.map +1 -1
- package/dist/types/any.js +1 -1
- package/dist/types/any.js.map +1 -1
- package/dist/types/array.js +2 -2
- package/dist/types/array.js.map +1 -1
- package/dist/types/boolean.js +1 -1
- package/dist/types/boolean.js.map +1 -1
- package/dist/types/buffer.js +2 -2
- package/dist/types/buffer.js.map +1 -1
- package/dist/types/date.js +2 -2
- package/dist/types/date.js.map +1 -1
- package/dist/types/index.js +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/model.js +1 -1
- package/dist/types/model.js.map +1 -1
- package/dist/types/null.js +1 -1
- package/dist/types/null.js.map +1 -1
- package/dist/types/number.js +2 -2
- package/dist/types/number.js.map +1 -1
- package/dist/types/object.js +2 -2
- package/dist/types/object.js.map +1 -1
- package/dist/types/string.js +1 -1
- package/dist/types/string.js.map +1 -1
- package/dist/types/type.js +1 -1
- package/dist/types/type.js.map +1 -1
- package/dist/types/union.js +2 -2
- package/dist/types/union.js.map +1 -1
- package/package.json +17 -17
- package/src/connectors/connector.ts +1 -1
- package/src/connectors/crud.connector.ts +1 -1
- package/src/connectors/index.ts +1 -1
- package/src/connectors/kv.connector.ts +1 -1
- package/src/datasource.ts +1 -1
- package/src/decorators/index.ts +1 -1
- package/src/decorators/metadata.ts +1 -1
- package/src/decorators/model.decorator.ts +1 -1
- package/src/decorators/repository.decorator.ts +1 -1
- package/src/define-model-class.ts +1 -1
- package/src/define-repository-class.ts +1 -1
- package/src/errors/entity-not-found.error.ts +1 -1
- package/src/errors/index.ts +2 -1
- package/src/errors/invalid-polymorphism.error.ts +28 -0
- package/src/errors/invalid-relation.error.ts +2 -2
- package/src/index.ts +1 -1
- package/src/mixins/index.ts +1 -1
- package/src/mixins/repository.mixin.ts +1 -6
- package/src/model.ts +20 -1
- package/src/relations/belongs-to/belongs-to.accessor.ts +36 -7
- package/src/relations/belongs-to/belongs-to.decorator.ts +2 -2
- package/src/relations/belongs-to/belongs-to.helpers.ts +37 -10
- package/src/relations/belongs-to/belongs-to.inclusion-resolver.ts +109 -18
- package/src/relations/belongs-to/belongs-to.repository.ts +78 -18
- package/src/relations/belongs-to/index.ts +3 -3
- package/src/relations/has-many/has-many-through.helpers.ts +28 -2
- package/src/relations/has-many/has-many-through.inclusion-resolver.ts +118 -27
- package/src/relations/has-many/has-many-through.repository-factory.ts +22 -4
- package/src/relations/has-many/has-many-through.repository.ts +344 -77
- package/src/relations/has-many/has-many.decorator.ts +1 -1
- package/src/relations/has-many/has-many.helpers.ts +1 -1
- package/src/relations/has-many/has-many.inclusion-resolver.ts +1 -1
- package/src/relations/has-many/has-many.repository-factory.ts +1 -1
- package/src/relations/has-many/has-many.repository.ts +1 -1
- package/src/relations/has-many/index.ts +3 -3
- package/src/relations/has-one/has-one.decorator.ts +1 -1
- package/src/relations/has-one/has-one.helpers.ts +41 -14
- package/src/relations/has-one/has-one.inclusion-resolver.ts +110 -16
- package/src/relations/has-one/has-one.repository-factory.ts +35 -7
- package/src/relations/has-one/has-one.repository.ts +189 -36
- package/src/relations/has-one/index.ts +1 -1
- package/src/relations/index.ts +3 -1
- package/src/relations/references-many/index.ts +9 -0
- package/src/relations/references-many/references-many.accessor.ts +76 -0
- package/src/relations/references-many/references-many.decorator.ts +100 -0
- package/src/relations/references-many/references-many.helpers.ts +82 -0
- package/src/relations/references-many/references-many.inclusion-resolver.ts +80 -0
- package/src/relations/references-many/references-many.repository.ts +55 -0
- package/src/relations/relation.decorator.ts +1 -13
- package/src/relations/relation.filter.solver.ts +56 -0
- package/src/relations/relation.helpers.ts +17 -2
- package/src/relations/relation.types.ts +52 -1
- package/src/repositories/constraint-utils.ts +1 -1
- package/src/repositories/index.ts +3 -3
- package/src/repositories/kv.repository.bridge.ts +1 -1
- package/src/repositories/kv.repository.ts +3 -3
- package/src/repositories/legacy-juggler-bridge.ts +79 -15
- package/src/repositories/repository.ts +1 -1
- package/src/type-resolver.ts +1 -1
- package/src/types/any.ts +1 -1
- package/src/types/array.ts +1 -1
- package/src/types/boolean.ts +1 -1
- package/src/types/buffer.ts +1 -1
- package/src/types/date.ts +1 -1
- package/src/types/index.ts +1 -1
- package/src/types/model.ts +1 -1
- package/src/types/null.ts +1 -1
- package/src/types/number.ts +1 -1
- package/src/types/object.ts +1 -1
- package/src/types/string.ts +1 -1
- package/src/types/type.ts +1 -1
- package/src/types/union.ts +1 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright IBM Corp. and LoopBack contributors 2018,2019. All Rights Reserved.
|
|
3
|
+
// Node module: @loopback/repository
|
|
4
|
+
// This file is licensed under the MIT License.
|
|
5
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.createReferencesManyAccessor = void 0;
|
|
8
|
+
const tslib_1 = require("tslib");
|
|
9
|
+
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
10
|
+
const references_many_helpers_1 = require("./references-many.helpers");
|
|
11
|
+
const references_many_inclusion_resolver_1 = require("./references-many.inclusion-resolver");
|
|
12
|
+
const references_many_repository_1 = require("./references-many.repository");
|
|
13
|
+
const debug = (0, debug_1.default)('loopback:repository:relations:references-many:accessor');
|
|
14
|
+
/**
|
|
15
|
+
* Enforces a ReferencesMany constraint on a repository
|
|
16
|
+
*/
|
|
17
|
+
function createReferencesManyAccessor(referencesManyMetadata, targetRepoGetter, sourceRepository) {
|
|
18
|
+
const meta = (0, references_many_helpers_1.resolveReferencesManyMetadata)(referencesManyMetadata);
|
|
19
|
+
debug('Resolved ReferencesMany relation metadata: %o', meta);
|
|
20
|
+
const result = async function getTargetInstancesOfReferencesMany(sourceId) {
|
|
21
|
+
const foreignKey = meta.keyFrom;
|
|
22
|
+
const primaryKey = meta.keyTo;
|
|
23
|
+
const sourceModel = await sourceRepository.findById(sourceId);
|
|
24
|
+
const foreignKeyValue = sourceModel[foreignKey];
|
|
25
|
+
// workaround to check referential integrity.
|
|
26
|
+
// should be removed once the memory connector ref integrity is done
|
|
27
|
+
// GH issue: https://github.com/loopbackio/loopback-next/issues/2333
|
|
28
|
+
if (!foreignKeyValue) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
|
+
const constraint = { [primaryKey]: foreignKeyValue };
|
|
33
|
+
const constrainedRepo = new references_many_repository_1.DefaultReferencesManyRepository(targetRepoGetter, constraint);
|
|
34
|
+
return constrainedRepo.get();
|
|
35
|
+
};
|
|
36
|
+
result.inclusionResolver = (0, references_many_inclusion_resolver_1.createReferencesManyInclusionResolver)(meta, targetRepoGetter);
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
exports.createReferencesManyAccessor = createReferencesManyAccessor;
|
|
40
|
+
//# sourceMappingURL=references-many.accessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references-many.accessor.js","sourceRoot":"","sources":["../../../src/relations/references-many/references-many.accessor.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,0DAAiC;AASjC,uEAAwE;AACxE,6FAA2F;AAC3F,6EAA6E;AAE7E,MAAM,KAAK,GAAG,IAAA,eAAY,EACxB,wDAAwD,CACzD,CAAC;AAcF;;GAEG;AACH,SAAgB,4BAA4B,CAM1C,sBAAgD,EAChD,gBAAiE,EACjE,gBAAwD;IAExD,MAAM,IAAI,GAAG,IAAA,uDAA6B,EAAC,sBAAsB,CAAC,CAAC;IACnE,KAAK,CAAC,+CAA+C,EAAE,IAAI,CAAC,CAAC;IAC7D,MAAM,MAAM,GACV,KAAK,UAAU,kCAAkC,CAAC,QAAkB;QAClE,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC;QAChC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC;QAC9B,MAAM,WAAW,GAAG,MAAM,gBAAgB,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC9D,MAAM,eAAe,GAAG,WAAW,CAAC,UAA0B,CAAC,CAAC;QAChE,6CAA6C;QAC7C,oEAAoE;QACpE,oEAAoE;QACpE,IAAI,CAAC,eAAe,EAAE;YACpB,OAAO,SAA8B,CAAC;SACvC;QACD,8DAA8D;QAC9D,MAAM,UAAU,GAAQ,EAAC,CAAC,UAAU,CAAC,EAAE,eAAe,EAAC,CAAC;QACxD,MAAM,eAAe,GAAG,IAAI,4DAA+B,CACzD,gBAAgB,EAChB,UAAgC,CACjC,CAAC;QACF,OAAO,eAAe,CAAC,GAAG,EAAE,CAAC;IAC/B,CAAC,CAAC;IAEJ,MAAM,CAAC,iBAAiB,GAAG,IAAA,0EAAqC,EAC9D,IAAI,EACJ,gBAAgB,CACjB,CAAC;IACF,OAAO,MAAM,CAAC;AAChB,CAAC;AAtCD,oEAsCC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Entity, EntityResolver, PropertyDefinition } from '../../model';
|
|
2
|
+
import { ReferencesManyDefinition } from '../relation.types';
|
|
3
|
+
/**
|
|
4
|
+
* Decorator for referencesMany
|
|
5
|
+
* @param targetResolver - A resolver function that returns the target model for
|
|
6
|
+
* a referencesMany relation
|
|
7
|
+
* @param definition - Optional metadata for setting up a referencesMany relation
|
|
8
|
+
* @param propertyDefinition - Optional metadata for setting up the property
|
|
9
|
+
* @returns A property decorator
|
|
10
|
+
*/
|
|
11
|
+
export declare function referencesMany<T extends Entity>(targetResolver: EntityResolver<T>, definition?: Partial<ReferencesManyDefinition>, propertyDefinition?: Partial<PropertyDefinition>): (decoratedTarget: Entity, decoratedKey: string) => void;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright IBM Corp. and LoopBack contributors 2018,2020. All Rights Reserved.
|
|
3
|
+
// Node module: @loopback/repository
|
|
4
|
+
// This file is licensed under the MIT License.
|
|
5
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.referencesMany = void 0;
|
|
8
|
+
const core_1 = require("@loopback/core");
|
|
9
|
+
const decorators_1 = require("../../decorators");
|
|
10
|
+
const relation_decorator_1 = require("../relation.decorator");
|
|
11
|
+
const relation_types_1 = require("../relation.types");
|
|
12
|
+
/**
|
|
13
|
+
* Decorator for referencesMany
|
|
14
|
+
* @param targetResolver - A resolver function that returns the target model for
|
|
15
|
+
* a referencesMany relation
|
|
16
|
+
* @param definition - Optional metadata for setting up a referencesMany relation
|
|
17
|
+
* @param propertyDefinition - Optional metadata for setting up the property
|
|
18
|
+
* @returns A property decorator
|
|
19
|
+
*/
|
|
20
|
+
function referencesMany(targetResolver, definition, propertyDefinition) {
|
|
21
|
+
return function (decoratedTarget, decoratedKey) {
|
|
22
|
+
var _a, _b, _c;
|
|
23
|
+
const propType = (_a = core_1.MetadataInspector.getDesignTypeForProperty(decoratedTarget, decoratedKey)) !== null && _a !== void 0 ? _a : propertyDefinition === null || propertyDefinition === void 0 ? void 0 : propertyDefinition.type;
|
|
24
|
+
if (!propType) {
|
|
25
|
+
const fullPropName = core_1.DecoratorFactory.getTargetName(decoratedTarget, decoratedKey);
|
|
26
|
+
throw new Error(`Cannot infer type of model property ${fullPropName} because ` +
|
|
27
|
+
'TypeScript compiler option `emitDecoratorMetadata` is not set. ' +
|
|
28
|
+
'Please enable `emitDecoratorMetadata` or use the third argument of ' +
|
|
29
|
+
'`@referencesMany` decorator to specify the property type explicitly.');
|
|
30
|
+
}
|
|
31
|
+
const sourceKeyType = core_1.MetadataInspector.getDesignTypeForProperty(targetResolver().prototype, (_b = definition === null || definition === void 0 ? void 0 : definition.keyTo) !== null && _b !== void 0 ? _b : 'id');
|
|
32
|
+
if (!sourceKeyType) {
|
|
33
|
+
const fullPropName = core_1.DecoratorFactory.getTargetName(targetResolver().prototype, (_c = definition === null || definition === void 0 ? void 0 : definition.keyTo) !== null && _c !== void 0 ? _c : 'id');
|
|
34
|
+
throw new Error(`Cannot infer type of model property ${fullPropName} because ` +
|
|
35
|
+
'TypeScript compiler option `emitDecoratorMetadata` is not set. ' +
|
|
36
|
+
'Please enable `emitDecoratorMetadata` or use the second argument of ' +
|
|
37
|
+
'`@referencesMany` decorator to specify the property type explicitly.');
|
|
38
|
+
}
|
|
39
|
+
const propMeta = Object.assign({},
|
|
40
|
+
// properties provided by the caller
|
|
41
|
+
propertyDefinition,
|
|
42
|
+
// properties enforced by the decorator
|
|
43
|
+
{
|
|
44
|
+
type: propType,
|
|
45
|
+
itemType: sourceKeyType,
|
|
46
|
+
// TODO(bajtos) Make the foreign key required once our REST API layer
|
|
47
|
+
// allows controller methods to exclude required properties
|
|
48
|
+
// required: true,
|
|
49
|
+
});
|
|
50
|
+
(0, decorators_1.property)(propMeta)(decoratedTarget, decoratedKey);
|
|
51
|
+
// @referencesMany() is typically decorating the foreign key property,
|
|
52
|
+
// e.g. customerIds. We need to strip the trailing "Ids" suffix from the name.
|
|
53
|
+
const relationName = decoratedKey.replace(/Ids$/, 's');
|
|
54
|
+
const meta = Object.assign(
|
|
55
|
+
// default values, can be customized by the caller
|
|
56
|
+
{
|
|
57
|
+
keyFrom: decoratedKey,
|
|
58
|
+
name: relationName,
|
|
59
|
+
},
|
|
60
|
+
// properties provided by the caller
|
|
61
|
+
definition,
|
|
62
|
+
// properties enforced by the decorator
|
|
63
|
+
{
|
|
64
|
+
type: relation_types_1.RelationType.referencesMany,
|
|
65
|
+
targetsMany: true,
|
|
66
|
+
source: decoratedTarget.constructor,
|
|
67
|
+
target: targetResolver,
|
|
68
|
+
});
|
|
69
|
+
(0, relation_decorator_1.relation)(meta)(decoratedTarget, decoratedKey);
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
exports.referencesMany = referencesMany;
|
|
73
|
+
//# sourceMappingURL=references-many.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references-many.decorator.js","sourceRoot":"","s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IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,aAAa;YACvB,qEAAqE;YACrE,2DAA2D;YAC3D,kBAAkB;SACnB,CACF,CAAC;QACF,IAAA,qBAAQ,EAAC,QAAQ,CAAC,CAAC,eAAe,EAAE,YAAY,CAAC,CAAC;QAElD,sEAAsE;QACtE,8EAA8E;QAC9E,MAAM,YAAY,GAAG,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAEvD,MAAM,IAAI,GAA6B,MAAM,CAAC,MAAM;QAClD,kDAAkD;QAClD;YACE,OAAO,EAAE,YAAY;YACrB,IAAI,EAAE,YAAY;SACnB;QACD,oCAAoC;QACpC,UAAU;QACV,uCAAuC;QACvC;YACE,IAAI,EAAE,6BAAY,CAAC,cAAc;YACjC,WAAW,EAAE,IAAI;YACjB,MAAM,EAAE,eAAe,CAAC,WAAW;YACnC,MAAM,EAAE,cAAc;SACvB,CACF,CAAC;QACF,IAAA,6BAAQ,EAAC,IAAI,CAAC,CAAC,eAAe,EAAE,YAAY,CAAC,CAAC;IAChD,CAAC,CAAC;AACJ,CAAC;AAhFD,wCAgFC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ReferencesManyDefinition } from '../relation.types';
|
|
2
|
+
/**
|
|
3
|
+
* Relation definition with optional metadata (e.g. `keyTo`) filled in.
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare type ReferencesManyResolvedDefinition = ReferencesManyDefinition & {
|
|
7
|
+
keyFrom: string;
|
|
8
|
+
keyTo: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Resolves given referencesMany metadata if target is specified to be a resolver.
|
|
12
|
+
* Mainly used to infer what the `keyTo` property should be from the target's
|
|
13
|
+
* property id metadata
|
|
14
|
+
* @param relationMeta - referencesMany metadata to resolve
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveReferencesManyMetadata(relationMeta: ReferencesManyDefinition): ReferencesManyResolvedDefinition;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright IBM Corp. and LoopBack contributors 2019. All Rights Reserved.
|
|
3
|
+
// Node module: @loopback/repository
|
|
4
|
+
// This file is licensed under the MIT License.
|
|
5
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.resolveReferencesManyMetadata = void 0;
|
|
8
|
+
const tslib_1 = require("tslib");
|
|
9
|
+
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
10
|
+
const lodash_1 = require("lodash");
|
|
11
|
+
const errors_1 = require("../../errors");
|
|
12
|
+
const type_resolver_1 = require("../../type-resolver");
|
|
13
|
+
const relation_types_1 = require("../relation.types");
|
|
14
|
+
const debug = (0, debug_1.default)('loopback:repository:relations:references-many:helpers');
|
|
15
|
+
/**
|
|
16
|
+
* Resolves given referencesMany metadata if target is specified to be a resolver.
|
|
17
|
+
* Mainly used to infer what the `keyTo` property should be from the target's
|
|
18
|
+
* property id metadata
|
|
19
|
+
* @param relationMeta - referencesMany metadata to resolve
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
function resolveReferencesManyMetadata(relationMeta) {
|
|
23
|
+
if (relationMeta.type !== relation_types_1.RelationType.referencesMany) {
|
|
24
|
+
const reason = 'relation type must be ReferencesMany';
|
|
25
|
+
throw new errors_1.InvalidRelationError(reason, relationMeta);
|
|
26
|
+
}
|
|
27
|
+
if (!(0, type_resolver_1.isTypeResolver)(relationMeta.target)) {
|
|
28
|
+
const reason = 'target must be a type resolver';
|
|
29
|
+
throw new errors_1.InvalidRelationError(reason, relationMeta);
|
|
30
|
+
}
|
|
31
|
+
const sourceModel = relationMeta.source;
|
|
32
|
+
if (!sourceModel || !sourceModel.modelName) {
|
|
33
|
+
const reason = 'source model must be defined';
|
|
34
|
+
throw new errors_1.InvalidRelationError(reason, relationMeta);
|
|
35
|
+
}
|
|
36
|
+
const targetModel = relationMeta.target();
|
|
37
|
+
const targetName = targetModel.modelName;
|
|
38
|
+
debug('Resolved model %s from given metadata: %o', targetName, targetModel);
|
|
39
|
+
let keyFrom;
|
|
40
|
+
if (relationMeta.keyFrom &&
|
|
41
|
+
relationMeta.source.definition.properties[relationMeta.keyFrom]) {
|
|
42
|
+
keyFrom = relationMeta.keyFrom;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
keyFrom = (0, lodash_1.camelCase)(targetName + '_ids');
|
|
46
|
+
}
|
|
47
|
+
const targetProperties = targetModel.definition.properties;
|
|
48
|
+
debug('relation metadata from %o: %o', targetName, targetProperties);
|
|
49
|
+
if (relationMeta.keyTo && targetProperties[relationMeta.keyTo]) {
|
|
50
|
+
// The explicit cast is needed because of a limitation of type inference
|
|
51
|
+
return Object.assign(relationMeta, {
|
|
52
|
+
keyFrom,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
const targetPrimaryKey = targetModel.definition.idProperties()[0];
|
|
56
|
+
if (!targetPrimaryKey) {
|
|
57
|
+
const reason = `${targetName} does not have any primary key (id property)`;
|
|
58
|
+
throw new errors_1.InvalidRelationError(reason, relationMeta);
|
|
59
|
+
}
|
|
60
|
+
return Object.assign(relationMeta, { keyFrom, keyTo: targetPrimaryKey });
|
|
61
|
+
}
|
|
62
|
+
exports.resolveReferencesManyMetadata = resolveReferencesManyMetadata;
|
|
63
|
+
//# sourceMappingURL=references-many.helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references-many.helpers.js","sourceRoot":"","sources":["../../../src/relations/references-many/references-many.helpers.ts"],"names":[],"mappings":";AAAA,2EAA2E;AAC3E,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,0DAAiC;AACjC,mCAAiC;AACjC,yCAAkD;AAClD,uDAAmD;AACnD,sDAAyE;AAEzE,MAAM,KAAK,GAAG,IAAA,eAAY,EACxB,uDAAuD,CACxD,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Y,CAAC,KAAK,CAAC,EAAE;QAC9D,wEAAwE;QACxE,OAAO,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE;YACjC,OAAO;SACR,CAAqC,CAAC;KACxC;IAED,MAAM,gBAAgB,GAAG,WAAW,CAAC,UAAU,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC;IAClE,IAAI,CAAC,gBAAgB,EAAE;QACrB,MAAM,MAAM,GAAG,GAAG,UAAU,8CAA8C,CAAC;QAC3E,MAAM,IAAI,6BAAoB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;KACtD;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,EAAC,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAC,CAAC,CAAC;AACzE,CAAC;AAlDD,sEAkDC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Entity } from '../../model';
|
|
2
|
+
import { EntityCrudRepository } from '../../repositories';
|
|
3
|
+
import { Getter, InclusionResolver, ReferencesManyDefinition } from '../relation.types';
|
|
4
|
+
/**
|
|
5
|
+
* Creates InclusionResolver for ReferencesMany relation.
|
|
6
|
+
* Notice that this function only generates the inclusionResolver.
|
|
7
|
+
* It doesn't register it for the source repository.
|
|
8
|
+
*
|
|
9
|
+
* Notice: scope field for inclusion is not supported yet
|
|
10
|
+
*
|
|
11
|
+
* @param meta - resolved ReferencesManyMetadata
|
|
12
|
+
* @param getTargetRepo - target repository i.e where related instances are
|
|
13
|
+
*/
|
|
14
|
+
export declare function createReferencesManyInclusionResolver<Target extends Entity, TargetIds, TargetRelations extends object>(meta: ReferencesManyDefinition, getTargetRepo: Getter<EntityCrudRepository<Target, TargetIds, TargetRelations>>): InclusionResolver<Entity, Target>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright IBM Corp. and LoopBack contributors 2019,2020. All Rights Reserved.
|
|
3
|
+
// Node module: @loopback/repository
|
|
4
|
+
// This file is licensed under the MIT License.
|
|
5
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.createReferencesManyInclusionResolver = void 0;
|
|
8
|
+
const relation_helpers_1 = require("../relation.helpers");
|
|
9
|
+
const references_many_helpers_1 = require("./references-many.helpers");
|
|
10
|
+
/**
|
|
11
|
+
* Creates InclusionResolver for ReferencesMany relation.
|
|
12
|
+
* Notice that this function only generates the inclusionResolver.
|
|
13
|
+
* It doesn't register it for the source repository.
|
|
14
|
+
*
|
|
15
|
+
* Notice: scope field for inclusion is not supported yet
|
|
16
|
+
*
|
|
17
|
+
* @param meta - resolved ReferencesManyMetadata
|
|
18
|
+
* @param getTargetRepo - target repository i.e where related instances are
|
|
19
|
+
*/
|
|
20
|
+
function createReferencesManyInclusionResolver(meta, getTargetRepo) {
|
|
21
|
+
const relationMeta = (0, references_many_helpers_1.resolveReferencesManyMetadata)(meta);
|
|
22
|
+
return async function fetchIncludedModels(entities, inclusion, options) {
|
|
23
|
+
if (!entities.length)
|
|
24
|
+
return [];
|
|
25
|
+
const sourceKey = relationMeta.keyFrom;
|
|
26
|
+
const sourceMap = entities.map(e => e[sourceKey]);
|
|
27
|
+
const sourceIds = sourceMap.flat();
|
|
28
|
+
const targetKey = relationMeta.keyTo;
|
|
29
|
+
const dedupedSourceIds = (0, relation_helpers_1.deduplicate)(sourceIds);
|
|
30
|
+
const scope = typeof inclusion === 'string' ? {} : inclusion.scope;
|
|
31
|
+
const targetRepo = await getTargetRepo();
|
|
32
|
+
const targetsFound = await (0, relation_helpers_1.findByForeignKeys)(targetRepo, targetKey, dedupedSourceIds.filter(e => e), scope, options);
|
|
33
|
+
return sourceMap.map(chainIds => {
|
|
34
|
+
if (!chainIds)
|
|
35
|
+
return [];
|
|
36
|
+
const targets = (0, relation_helpers_1.flattenTargetsOfOneToOneRelation)(chainIds, targetsFound, targetKey);
|
|
37
|
+
return targets.filter((v) => v != null);
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
exports.createReferencesManyInclusionResolver = createReferencesManyInclusionResolver;
|
|
42
|
+
//# sourceMappingURL=references-many.inclusion-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references-many.inclusion-resolver.js","sourceRoot":"","sources":["../../../src/relations/references-many/references-many.inclusion-resolver.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;AAMhE,0DAK6B;AAM7B,uEAAwE;AAExE;;;;;;;;;GASG;AACH,SAAgB,qCAAqC,CAKnD,IAA8B,EAC9B,aAEC;IAED,MAAM,YAAY,GAAG,IAAA,uDAA6B,EAAC,IAAI,CAAC,CAAC;IAEzD,OAAO,KAAK,UAAU,mBAAmB,CACvC,QAAkB,EAClB,SAA0B,EAC1B,OAAiB;QAEjB,IAAI,CAAC,QAAQ,CAAC,MAAM;YAAE,OAAO,EAAE,CAAC;QAEhC,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC;QACvC,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAE,CAAe,CAAC,SAAS,CAAC,CAAC,CAAC;QACjE,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;QACnC,MAAM,SAAS,GAAG,YAAY,CAAC,KAA4B,CAAC;QAC5D,MAAM,gBAAgB,GAAG,IAAA,8BAAW,EAAC,SAAS,CAAC,CAAC;QAEhD,MAAM,KAAK,GACT,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAE,SAAS,CAAC,KAAwB,CAAC;QAE3E,MAAM,UAAU,GAAG,MAAM,aAAa,EAAE,CAAC;QACzC,MAAM,YAAY,GAAG,MAAM,IAAA,oCAAiB,EAC1C,UAAU,EACV,SAAS,EACT,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAC/B,KAAK,EACL,OAAO,CACR,CAAC;QAEF,OAAO,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YAC9B,IAAI,CAAC,QAAQ;gBAAE,OAAO,EAAE,CAAC;YACzB,MAAM,OAAO,GAAG,IAAA,mDAAgC,EAC9C,QAAQ,EACR,YAAY,EACZ,SAAS,CACV,CAAC;YACF,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAiC,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC;QACzE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AA/CD,sFA+CC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Getter } from '@loopback/core';
|
|
2
|
+
import { DataObject, Options } from '../../common-types';
|
|
3
|
+
import { Entity } from '../../model';
|
|
4
|
+
import { EntityCrudRepository } from '../../repositories';
|
|
5
|
+
/**
|
|
6
|
+
* CRUD operations for a target repository of a ReferencesMany relation
|
|
7
|
+
*/
|
|
8
|
+
export interface ReferencesManyRepository<Target extends Entity> {
|
|
9
|
+
/**
|
|
10
|
+
* Gets the target model instance
|
|
11
|
+
* @param options
|
|
12
|
+
* @returns A promise resolved with the target object or rejected
|
|
13
|
+
* with an EntityNotFoundError when target model instance was not found.
|
|
14
|
+
*/
|
|
15
|
+
get(options?: Options): Promise<Target>;
|
|
16
|
+
}
|
|
17
|
+
export declare class DefaultReferencesManyRepository<TargetEntity extends Entity, TargetIds, TargetRepository extends EntityCrudRepository<TargetEntity, TargetIds>> implements ReferencesManyRepository<TargetEntity> {
|
|
18
|
+
getTargetRepository: Getter<TargetRepository>;
|
|
19
|
+
constraint: DataObject<TargetEntity>;
|
|
20
|
+
/**
|
|
21
|
+
* Constructor of DefaultReferencesManyEntityCrudRepository
|
|
22
|
+
* @param getTargetRepository - the getter of the related target model repository instance
|
|
23
|
+
* @param constraint - the key value pair representing foreign key name to constrain
|
|
24
|
+
* the target repository instance
|
|
25
|
+
*/
|
|
26
|
+
constructor(getTargetRepository: Getter<TargetRepository>, constraint: DataObject<TargetEntity>);
|
|
27
|
+
get(options?: Options): Promise<TargetEntity>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright IBM Corp. and LoopBack contributors 2018,2020. All Rights Reserved.
|
|
3
|
+
// Node module: @loopback/repository
|
|
4
|
+
// This file is licensed under the MIT License.
|
|
5
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.DefaultReferencesManyRepository = void 0;
|
|
8
|
+
const errors_1 = require("../../errors");
|
|
9
|
+
const repositories_1 = require("../../repositories");
|
|
10
|
+
class DefaultReferencesManyRepository {
|
|
11
|
+
/**
|
|
12
|
+
* Constructor of DefaultReferencesManyEntityCrudRepository
|
|
13
|
+
* @param getTargetRepository - the getter of the related target model repository instance
|
|
14
|
+
* @param constraint - the key value pair representing foreign key name to constrain
|
|
15
|
+
* the target repository instance
|
|
16
|
+
*/
|
|
17
|
+
constructor(getTargetRepository, constraint) {
|
|
18
|
+
this.getTargetRepository = getTargetRepository;
|
|
19
|
+
this.constraint = constraint;
|
|
20
|
+
}
|
|
21
|
+
async get(options) {
|
|
22
|
+
const targetRepo = await this.getTargetRepository();
|
|
23
|
+
const result = await targetRepo.find((0, repositories_1.constrainFilter)(undefined, this.constraint), options);
|
|
24
|
+
if (!result.length) {
|
|
25
|
+
// We don't have a direct access to the foreign key value here :(
|
|
26
|
+
const id = 'constraint ' + JSON.stringify(this.constraint);
|
|
27
|
+
throw new errors_1.EntityNotFoundError(targetRepo.entityClass, id);
|
|
28
|
+
}
|
|
29
|
+
return result[0];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.DefaultReferencesManyRepository = DefaultReferencesManyRepository;
|
|
33
|
+
//# sourceMappingURL=references-many.repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references-many.repository.js","sourceRoot":"","sources":["../../../src/relations/references-many/references-many.repository.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;AAIhE,yCAAiD;AAEjD,qDAAyE;AAezE,MAAa,+BAA+B;IAM1C;;;;;OAKG;IACH,YACS,mBAA6C,EAC7C,UAAoC;QADpC,wBAAmB,GAAnB,mBAAmB,CAA0B;QAC7C,eAAU,GAAV,UAAU,CAA0B;IAC1C,CAAC;IAEJ,KAAK,CAAC,GAAG,CAAC,OAAiB;QACzB,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACpD,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,IAAI,CAClC,IAAA,8BAAe,EAAC,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,EAC3C,OAAO,CACR,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YAClB,iEAAiE;YACjE,MAAM,EAAE,GAAG,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC3D,MAAM,IAAI,4BAAmB,CAAC,UAAU,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;SAC3D;QACD,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC;CACF;AA9BD,0EA8BC"}
|
|
@@ -31,9 +31,3 @@ export declare function embedsMany(definition?: Object): PropertyDecorator;
|
|
|
31
31
|
* @returns A property decorator
|
|
32
32
|
*/
|
|
33
33
|
export declare function referencesOne(definition?: Object): PropertyDecorator;
|
|
34
|
-
/**
|
|
35
|
-
* Decorator for referencesMany
|
|
36
|
-
* @param definition
|
|
37
|
-
* @returns A property decorator
|
|
38
|
-
*/
|
|
39
|
-
export declare function referencesMany(definition?: Object): PropertyDecorator;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright IBM Corp. 2018,2020. All Rights Reserved.
|
|
2
|
+
// Copyright IBM Corp. and LoopBack contributors 2018,2020. All Rights Reserved.
|
|
3
3
|
// Node module: @loopback/repository
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.referencesOne = exports.embedsMany = exports.embedsOne = exports.getModelRelations = exports.relation = exports.RELATIONS_KEY = void 0;
|
|
8
8
|
const core_1 = require("@loopback/core");
|
|
9
9
|
const decorators_1 = require("../decorators");
|
|
10
10
|
const relation_types_1 = require("./relation.types");
|
|
@@ -73,16 +73,4 @@ function referencesOne(definition) {
|
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
exports.referencesOne = referencesOne;
|
|
76
|
-
/**
|
|
77
|
-
* Decorator for referencesMany
|
|
78
|
-
* @param definition
|
|
79
|
-
* @returns A property decorator
|
|
80
|
-
*/
|
|
81
|
-
function referencesMany(definition) {
|
|
82
|
-
const rel = Object.assign({ type: relation_types_1.RelationType.referencesMany }, definition);
|
|
83
|
-
return core_1.PropertyDecoratorFactory.createDecorator(exports.RELATIONS_KEY, rel, {
|
|
84
|
-
decoratorName: '@referencesMany',
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
exports.referencesMany = referencesMany;
|
|
88
76
|
//# sourceMappingURL=relation.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relation.decorator.js","sourceRoot":"","sources":["../../src/relations/relation.decorator.ts"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"relation.decorator.js","sourceRoot":"","sources":["../../src/relations/relation.decorator.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;AAEhE,yCAAwD;AACxD,8CAAmD;AAEnD,qDAA8C;AAEjC,QAAA,aAAa,GAAG,oBAAoB,CA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AC;IAC1E,OAAO,+BAAwB,CAAC,eAAe,CAAC,qBAAa,EAAE,GAAG,EAAE;QAClE,aAAa,EAAE,gBAAgB;KAChC,CAAC,CAAC;AACL,CAAC;AALD,sCAKC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.includeFieldIfNot = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
function includeFieldIfNot(fields, fieldToInclude) {
|
|
6
|
+
if (!fields) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
else if (Array.isArray(fields)) {
|
|
10
|
+
const fieldsCloned = fields.reduce((prev, current) => ({ ...prev, [current]: true }), {});
|
|
11
|
+
if (Object.keys(fieldsCloned).length > 0) {
|
|
12
|
+
if (fieldsCloned[fieldToInclude] === true) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
fieldsCloned[fieldToInclude] = true;
|
|
16
|
+
return fieldsCloned;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
const fieldsCloned = (0, lodash_1.cloneDeep)(fields);
|
|
21
|
+
if (Object.keys(fieldsCloned).length > 0) {
|
|
22
|
+
let containsTrue = false;
|
|
23
|
+
for (const k in fieldsCloned) {
|
|
24
|
+
if (fieldsCloned[k] === true) {
|
|
25
|
+
containsTrue = true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
for (const k in fieldsCloned) {
|
|
29
|
+
if (k === fieldToInclude) {
|
|
30
|
+
if (fieldsCloned[k] === true) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
if (containsTrue) {
|
|
35
|
+
fieldsCloned[k] = true;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
delete fieldsCloned[k];
|
|
39
|
+
}
|
|
40
|
+
return fieldsCloned;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (containsTrue) {
|
|
45
|
+
fieldsCloned[fieldToInclude] = true;
|
|
46
|
+
return fieldsCloned;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.includeFieldIfNot = includeFieldIfNot;
|
|
57
|
+
//# sourceMappingURL=relation.filter.solver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relation.filter.solver.js","sourceRoot":"","sources":["../../src/relations/relation.filter.solver.ts"],"names":[],"mappings":";;;AACA,mCAAiC;AAEjC,SAAgB,iBAAiB,CAC/B,MAA8B,EAC9B,cAAyC;IAEzC,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,KAAK,CAAC;KACd;SAAM,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QAChC,MAAM,YAAY,GAAgC,MAAM,CAAC,MAAM,CAC7D,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,EAAC,GAAG,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,EAAC,CAAC,EAC/C,EAAE,CACH,CAAC;QACF,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;YACxC,IAAI,YAAY,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE;gBACzC,OAAO,KAAK,CAAC;aACd;YACD,YAAY,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;YACpC,OAAO,YAAY,CAAC;SACrB;QACD,OAAO,KAAK,CAAC;KACd;IAED,MAAM,YAAY,GAAG,IAAA,kBAAS,EAAC,MAAM,CAAC,CAAC;IACvC,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;QACxC,IAAI,YAAY,GAAG,KAAK,CAAC;QACzB,KAAK,MAAM,CAAC,IAAI,YAAY,EAAE;YAC5B,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;gBAC5B,YAAY,GAAG,IAAI,CAAC;aACrB;SACF;QACD,KAAK,MAAM,CAAC,IAAI,YAAY,EAAE;YAC5B,IAAI,CAAC,KAAK,cAAc,EAAE;gBACxB,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;oBAC5B,OAAO,KAAK,CAAC;iBACd;qBAAM;oBACL,IAAI,YAAY,EAAE;wBAChB,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;qBACxB;yBAAM;wBACL,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC;qBACxB;oBACD,OAAO,YAAY,CAAC;iBACrB;aACF;SACF;QACD,IAAI,YAAY,EAAE;YAChB,YAAY,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;YACpC,OAAO,YAAY,CAAC;SACrB;aAAM;YACL,OAAO,KAAK,CAAC;SACd;KACF;SAAM;QACL,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AApDD,8CAoDC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Copyright IBM Corp. 2019,2020. All Rights Reserved.
|
|
2
|
+
// Copyright IBM Corp. and LoopBack contributors 2019,2020. All Rights Reserved.
|
|
3
3
|
// Node module: @loopback/repository
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.isBsonType = exports.deduplicate = exports.reduceAsSingleItem = exports.reduceAsArray = exports.normalizeKey = exports.getKeyValue = exports.buildLookupMap = exports.flattenMapByKeys = exports.flattenTargetsOfOneToManyRelation = exports.flattenTargetsOfOneToOneRelation = exports.includeRelatedModels = exports.findByForeignKeys = void 0;
|
|
8
8
|
const tslib_1 = require("tslib");
|
|
9
|
-
const assert_1 =
|
|
10
|
-
const debug_1 =
|
|
11
|
-
const lodash_1 =
|
|
9
|
+
const assert_1 = tslib_1.__importDefault(require("assert"));
|
|
10
|
+
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
11
|
+
const lodash_1 = tslib_1.__importStar(require("lodash"));
|
|
12
12
|
const __1 = require("..");
|
|
13
13
|
const debug = (0, debug_1.default)('loopback:repository:relation-helpers');
|
|
14
14
|
/**
|
|
@@ -92,7 +92,22 @@ exports.findByForeignKeys = findByForeignKeys;
|
|
|
92
92
|
*/
|
|
93
93
|
async function includeRelatedModels(targetRepository, entities, include, options) {
|
|
94
94
|
entities = (0, lodash_1.cloneDeep)(entities);
|
|
95
|
-
|
|
95
|
+
if (options === null || options === void 0 ? void 0 : options.polymorphicType) {
|
|
96
|
+
include = include === null || include === void 0 ? void 0 : include.filter(inclusionFilter => {
|
|
97
|
+
if (typeof inclusionFilter === 'string') {
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
if (inclusionFilter.targetType === undefined ||
|
|
102
|
+
inclusionFilter.targetType === (options === null || options === void 0 ? void 0 : options.polymorphicType)) {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
include = (0, lodash_1.cloneDeep)(include);
|
|
110
|
+
}
|
|
96
111
|
const result = entities;
|
|
97
112
|
if (!include)
|
|
98
113
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relation.helpers.js","sourceRoot":"","sources":["../../src/relations/relation.helpers.ts"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"relation.helpers.js","sourceRoot":"","sources":["../../src/relations/relation.helpers.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,4DAA4B;AAC5B,0DAAiC;AACjC,yDAAoC;AAC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