@loopback/repository 1.10.1 → 1.13.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/dist/common-types.d.ts +1 -1
  3. package/dist/common-types.js.map +1 -1
  4. package/dist/decorators/model.decorator.js +2 -2
  5. package/dist/decorators/model.decorator.js.map +1 -1
  6. package/dist/decorators/repository.decorator.d.ts +1 -1
  7. package/dist/index.d.ts +6 -5
  8. package/dist/index.js +5 -4
  9. package/dist/index.js.map +1 -1
  10. package/dist/mixins/repository.mixin.d.ts +1 -1
  11. package/dist/model.js +3 -3
  12. package/dist/model.js.map +1 -1
  13. package/dist/relations/index.d.ts +3 -2
  14. package/dist/relations/index.js +3 -2
  15. package/dist/relations/index.js.map +1 -1
  16. package/dist/relations/relation.decorator.js +15 -5
  17. package/dist/relations/relation.decorator.js.map +1 -1
  18. package/dist/relations/relation.helpers.d.ts +23 -0
  19. package/dist/relations/relation.helpers.js +94 -0
  20. package/dist/relations/relation.helpers.js.map +1 -0
  21. package/dist/relations/relation.types.d.ts +22 -0
  22. package/dist/relations/relation.types.js.map +1 -1
  23. package/dist/repositories/legacy-juggler-bridge.d.ts +39 -4
  24. package/dist/repositories/legacy-juggler-bridge.js +63 -6
  25. package/dist/repositories/legacy-juggler-bridge.js.map +1 -1
  26. package/dist/repositories/repository.d.ts +23 -0
  27. package/dist/repositories/repository.js +1 -0
  28. package/dist/repositories/repository.js.map +1 -1
  29. package/dist/transaction.d.ts +26 -0
  30. package/dist/transaction.js +17 -0
  31. package/dist/transaction.js.map +1 -0
  32. package/package.json +11 -11
  33. package/src/common-types.ts +5 -1
  34. package/src/decorators/model.decorator.ts +2 -0
  35. package/src/index.ts +6 -5
  36. package/src/relations/index.ts +3 -2
  37. package/src/relations/relation.decorator.ts +15 -5
  38. package/src/relations/relation.helpers.ts +134 -0
  39. package/src/relations/relation.types.ts +24 -0
  40. package/src/repositories/legacy-juggler-bridge.ts +106 -9
  41. package/src/repositories/repository.ts +32 -0
  42. package/src/transaction.ts +34 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,61 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.13.1](https://github.com/strongloop/loopback-next/compare/@loopback/repository@1.13.0...@loopback/repository@1.13.1) (2019-09-06)
7
+
8
+ **Note:** Version bump only for package @loopback/repository
9
+
10
+
11
+
12
+
13
+
14
+ # [1.13.0](https://github.com/strongloop/loopback-next/compare/@loopback/repository@1.12.0...@loopback/repository@1.13.0) (2019-09-03)
15
+
16
+
17
+ ### Features
18
+
19
+ * **repository:** add inclusionResolvers to DefaultCrudRepository ([642c4b6](https://github.com/strongloop/loopback-next/commit/642c4b6))
20
+
21
+
22
+
23
+
24
+
25
+ # [1.12.0](https://github.com/strongloop/loopback-next/compare/@loopback/repository@1.11.1...@loopback/repository@1.12.0) (2019-08-19)
26
+
27
+
28
+ ### Features
29
+
30
+ * **repository:** add InclusionResolver type and includeRelatedModels helper function ([c9c39c9](https://github.com/strongloop/loopback-next/commit/c9c39c9))
31
+
32
+
33
+
34
+
35
+
36
+ ## [1.11.1](https://github.com/strongloop/loopback-next/compare/@loopback/repository@1.11.0...@loopback/repository@1.11.1) (2019-08-15)
37
+
38
+ **Note:** Version bump only for package @loopback/repository
39
+
40
+
41
+
42
+
43
+
44
+ # [1.11.0](https://github.com/strongloop/loopback-next/compare/@loopback/repository@1.10.1...@loopback/repository@1.11.0) (2019-08-15)
45
+
46
+
47
+ ### Bug Fixes
48
+
49
+ * fixup findByForeignKeys ([e26e7b7](https://github.com/strongloop/loopback-next/commit/e26e7b7))
50
+
51
+
52
+ ### Features
53
+
54
+ * **repository:** add function findByForeignKeys ([f5eaf1d](https://github.com/strongloop/loopback-next/commit/f5eaf1d))
55
+ * **repository:** expose beginTransaction() API ([0471315](https://github.com/strongloop/loopback-next/commit/0471315))
56
+
57
+
58
+
59
+
60
+
6
61
  ## [1.10.1](https://github.com/strongloop/loopback-next/compare/@loopback/repository@1.10.0...@loopback/repository@1.10.1) (2019-07-31)
7
62
 
8
63
  **Note:** Version bump only for package @loopback/repository
@@ -37,7 +37,7 @@ export interface AnyObject {
37
37
  * in deeply nested properties too.
38
38
  */
39
39
  export declare type DeepPartial<T> = {
40
- [P in keyof T]?: DeepPartial<T[P]>;
40
+ [P in keyof T]?: T[P] extends never ? DeepPartial<T[P]> : DeepPartial<T[P]>;
41
41
  };
42
42
  /**
43
43
  * Type alias for strongly or weakly typed objects of T
@@ -1 +1 @@
1
- {"version":3,"file":"common-types.js","sourceRoot":"","sources":["../src/common-types.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AA2FhE;;;GAGG;AACU,QAAA,WAAW,GAAG;IACzB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,EAAC,KAAK,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,EAAC;CACtC,CAAC"}
1
+ {"version":3,"file":"common-types.js","sourceRoot":"","sources":["../src/common-types.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AA+FhE;;;GAGG;AACU,QAAA,WAAW,GAAG;IACzB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,EAAC,KAAK,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,EAAC;CACtC,CAAC"}
@@ -21,7 +21,7 @@ function model(definition) {
21
21
  const def = Object.assign(definition, {
22
22
  name: definition.name || target.name,
23
23
  });
24
- const decorator = context_1.ClassDecoratorFactory.createDecorator(exports.MODEL_KEY, definition);
24
+ const decorator = context_1.ClassDecoratorFactory.createDecorator(exports.MODEL_KEY, definition, { decoratorName: '@model' });
25
25
  decorator(target);
26
26
  // Build "ModelDefinition" and store it on model constructor
27
27
  buildModelDefinition(target, def);
@@ -72,7 +72,7 @@ exports.buildModelDefinition = buildModelDefinition;
72
72
  * @returns A property decorator
73
73
  */
74
74
  function property(definition) {
75
- return context_1.PropertyDecoratorFactory.createDecorator(exports.MODEL_PROPERTIES_KEY, Object.assign({}, definition));
75
+ return context_1.PropertyDecoratorFactory.createDecorator(exports.MODEL_PROPERTIES_KEY, Object.assign({}, definition), { decoratorName: '@property' });
76
76
  }
77
77
  exports.property = property;
78
78
  (function (property) {
@@ -1 +1 @@
1
- {"version":3,"file":"model.decorator.js","sourceRoot":"","sources":["../../src/decorators/model.decorator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AAEhE,+CAM2B;AAC3B,oCAMkB;AAClB,wEAA8D;AAEjD,QAAA,SAAS,GAAG,0BAAgB,CAAC,MAAM,CAG9C,gBAAgB,CAAC,CAAC;AACP,QAAA,oBAAoB,GAAG,0BAAgB,CAAC,MAAM,CAGzD,2BAA2B,CAAC,CAAC;AAClB,QAAA,yBAAyB,GAAG,0BAAgB,CAAC,MAAM,CAG9D,+BAA+B,CAAC,CAAC;AAInC;;;;GAIG;AACH,SAAgB,KAAK,CAAC,UAA2C;IAC/D,OAAO,UAAS,MAAiD;QAC/D,UAAU,GAAG,UAAU,IAAI,EAAE,CAAC;QAC9B,MAAM,GAAG,GAA0B,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE;YAC3D,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI;SACrC,CAAC,CAAC;QACH,MAAM,SAAS,GAAG,+BAAqB,CAAC,eAAe,CACrD,iBAAS,EACT,UAAU,CACX,CAAC;QAEF,SAAS,CAAC,MAAM,CAAC,CAAC;QAElB,4DAA4D;QAC5D,oBAAoB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACpC,CAAC,CAAC;AACJ,CAAC;AAhBD,sBAgBC;AAED;;;;GAIG;AACH,SAAgB,oBAAoB,CAClC,MAA6D,EAC7D,G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CACb,CAAC;YACF,IAAI,QAAQ,KAAK,KAAK,EAAE;gBACtB,MAAM,IAAI,KAAK,CAAC,SAAA,kBAAkB,CAAC,CAAC;aACrC;iBAAM;gBACL,QAAQ,CACN,MAAM,CAAC,MAAM,CACX,EAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAgC,EACtD,UAAU,CACX,CACF,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;aACzB;QACH,CAAC,CAAC;IACJ,CAAC;IApBe,cAAK,QAoBpB,CAAA;AACH,CAAC,EAjCgB,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAiCxB"}
@@ -102,5 +102,5 @@ export declare namespace repository {
102
102
  * factory
103
103
  * @param nameOrClass - The repository class (ProductRepository) or a string name ('ProductRepository').
104
104
  */
105
- function getter(nameOrClass: string | Class<Repository<Model>>): (target: Object, member: string, methodDescriptorOrParameterIndex?: number | TypedPropertyDescriptor<any> | undefined) => void;
105
+ function getter(nameOrClass: string | Class<Repository<Model>>): (target: Object, member: string | undefined, methodDescriptorOrParameterIndex?: number | TypedPropertyDescriptor<any> | undefined) => void;
106
106
  }
package/dist/index.d.ts CHANGED
@@ -1,12 +1,13 @@
1
+ export * from './common-types';
1
2
  export * from './connectors';
3
+ export * from './datasource';
2
4
  export * from './decorators';
3
5
  export * from './errors';
4
6
  export * from './mixins';
5
- export * from './repositories';
6
- export * from './types';
7
- export * from './common-types';
8
- export * from './datasource';
9
7
  export * from './model';
10
8
  export * from './query';
11
- export * from './type-resolver';
12
9
  export * from './relations';
10
+ export * from './repositories';
11
+ export * from './transaction';
12
+ export * from './type-resolver';
13
+ export * from './types';
package/dist/index.js CHANGED
@@ -7,14 +7,15 @@ function __export(m) {
7
7
  for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
8
8
  }
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
+ __export(require("./common-types"));
10
11
  __export(require("./decorators"));
11
12
  __export(require("./errors"));
12
13
  __export(require("./mixins"));
13
- __export(require("./repositories"));
14
- __export(require("./types"));
15
- __export(require("./common-types"));
16
14
  __export(require("./model"));
17
15
  __export(require("./query"));
18
- __export(require("./type-resolver"));
19
16
  __export(require("./relations"));
17
+ __export(require("./repositories"));
18
+ __export(require("./transaction"));
19
+ __export(require("./type-resolver"));
20
+ __export(require("./types"));
20
21
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;;AAGhE,kCAA6B;AAC7B,8BAAyB;AACzB,8BAAyB;AACzB,oCAA+B;AAC/B,6BAAwB;AACxB,oCAA+B;AAE/B,6BAAwB;AACxB,6BAAwB;AACxB,qCAAgC;AAChC,iCAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;;AAEhE,oCAA+B;AAG/B,kCAA6B;AAC7B,8BAAyB;AACzB,8BAAyB;AACzB,6BAAwB;AACxB,6BAAwB;AACxB,iCAA4B;AAC5B,oCAA+B;AAC/B,mCAA8B;AAC9B,qCAAgC;AAChC,6BAAwB"}
@@ -54,7 +54,7 @@ export declare function RepositoryMixin<T extends Class<any>>(superClass: T): {
54
54
  *
55
55
  * @param repo - The repository class to retrieve the instance of
56
56
  */
57
- getRepository<R extends Repository<any>>(repo: Class<R>): Promise<R>;
57
+ getRepository<R_1 extends Repository<any>>(repo: Class<R_1>): Promise<R_1>;
58
58
  /**
59
59
  * Add the dataSource to this application.
60
60
  *
package/dist/model.js CHANGED
@@ -113,6 +113,9 @@ function asObject(value, options) {
113
113
  * Base class for models
114
114
  */
115
115
  class Model {
116
+ constructor(data) {
117
+ Object.assign(this, data);
118
+ }
116
119
  static get modelName() {
117
120
  return (this.definition && this.definition.name) || this.name;
118
121
  }
@@ -159,9 +162,6 @@ class Model {
159
162
  }
160
163
  return obj;
161
164
  }
162
- constructor(data) {
163
- Object.assign(this, data);
164
- }
165
165
  }
166
166
  exports.Model = Model;
167
167
  /**
package/dist/model.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AA+DhE;;GAEG;AACH,MAAa,eAAe;IAQ1B,YAAY,SAAyC;QACnD,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;YACjC,SAAS,GAAG,EAAC,IAAI,EAAE,SAAS,EAAC,CAAC;SAC/B;QACD,MAAM,EAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAC,GAAG,SAAS,CAAC;QAE1D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,UAAU,EAAE;YACd,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE;gBAC1B,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;aACpC;SACF;QAED,IAAI,CAAC,QAAQ,GAAG,QAAQ,IAAI,IAAI,GAAG,EAAE,CAAC;QACtC,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,EAAE,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,WAAW,CACT,IAAY,EACZ,gBAAmD;QAEnD,MAAM,UAAU,GAAI,gBAAuC,CAAC,IAAI;YAC9D,CAAC,CAAE,gBAAuC;YAC1C,CAAC,CAAC,EAAC,IAAI,EAAE,gBAAgB,EAAC,CAAC;QAC7B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,UAAU,CAAC,IAA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/C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;YACxB,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;SACxB;aAAM;YACL,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;gBAC5B,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;aAC5B;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAxED,wBAwEC;AAED;;GAEG;AACH,MAAa,KAAK;CAGjB;AAHD,sBAGC"}
@@ -1,5 +1,6 @@
1
- export * from './relation.types';
2
- export * from './relation.decorator';
3
1
  export * from './belongs-to';
4
2
  export * from './has-many';
5
3
  export * from './has-one';
4
+ export * from './relation.decorator';
5
+ export * from './relation.helpers';
6
+ export * from './relation.types';
@@ -7,9 +7,10 @@ function __export(m) {
7
7
  for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
8
8
  }
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- __export(require("./relation.types"));
11
- __export(require("./relation.decorator"));
12
10
  __export(require("./belongs-to"));
13
11
  __export(require("./has-many"));
14
12
  __export(require("./has-one"));
13
+ __export(require("./relation.decorator"));
14
+ __export(require("./relation.helpers"));
15
+ __export(require("./relation.types"));
15
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/relations/index.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;;AAEhE,sCAAiC;AACjC,0CAAqC;AACrC,kCAA6B;AAC7B,gCAA2B;AAC3B,+BAA0B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/relations/index.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;;;;AAEhE,kCAA6B;AAC7B,gCAA2B;AAC3B,+BAA0B;AAC1B,0CAAqC;AACrC,wCAAmC;AACnC,sCAAiC"}
@@ -15,7 +15,9 @@ exports.RELATIONS_KEY = 'loopback:relations';
15
15
  */
16
16
  function relation(definition) {
17
17
  // Apply relation definition to the model class
18
- return context_1.PropertyDecoratorFactory.createDecorator(exports.RELATIONS_KEY, definition);
18
+ return context_1.PropertyDecoratorFactory.createDecorator(exports.RELATIONS_KEY, definition, {
19
+ decoratorName: '@relation',
20
+ });
19
21
  }
20
22
  exports.relation = relation;
21
23
  /**
@@ -41,7 +43,9 @@ exports.getModelRelations = getModelRelations;
41
43
  */
42
44
  function embedsOne(definition) {
43
45
  const rel = Object.assign({ type: relation_types_1.RelationType.embedsOne }, definition);
44
- return context_1.PropertyDecoratorFactory.createDecorator(exports.RELATIONS_KEY, rel);
46
+ return context_1.PropertyDecoratorFactory.createDecorator(exports.RELATIONS_KEY, rel, {
47
+ decoratorName: '@embedsOne',
48
+ });
45
49
  }
46
50
  exports.embedsOne = embedsOne;
47
51
  /**
@@ -51,7 +55,9 @@ exports.embedsOne = embedsOne;
51
55
  */
52
56
  function embedsMany(definition) {
53
57
  const rel = Object.assign({ type: relation_types_1.RelationType.embedsMany }, definition);
54
- return context_1.PropertyDecoratorFactory.createDecorator(exports.RELATIONS_KEY, rel);
58
+ return context_1.PropertyDecoratorFactory.createDecorator(exports.RELATIONS_KEY, rel, {
59
+ decoratorName: '@embedsMany',
60
+ });
55
61
  }
56
62
  exports.embedsMany = embedsMany;
57
63
  /**
@@ -61,7 +67,9 @@ exports.embedsMany = embedsMany;
61
67
  */
62
68
  function referencesOne(definition) {
63
69
  const rel = Object.assign({ type: relation_types_1.RelationType.referencesOne }, definition);
64
- return context_1.PropertyDecoratorFactory.createDecorator(exports.RELATIONS_KEY, rel);
70
+ return context_1.PropertyDecoratorFactory.createDecorator(exports.RELATIONS_KEY, rel, {
71
+ decoratorName: '@referencesOne',
72
+ });
65
73
  }
66
74
  exports.referencesOne = referencesOne;
67
75
  /**
@@ -71,7 +79,9 @@ exports.referencesOne = referencesOne;
71
79
  */
72
80
  function referencesMany(definition) {
73
81
  const rel = Object.assign({ type: relation_types_1.RelationType.referencesMany }, definition);
74
- return context_1.PropertyDecoratorFactory.createDecorator(exports.RELATIONS_KEY, rel);
82
+ return context_1.PropertyDecoratorFactory.createDecorator(exports.RELATIONS_KEY, rel, {
83
+ decoratorName: '@referencesMany',
84
+ });
75
85
  }
76
86
  exports.referencesMany = referencesMany;
77
87
  //# sourceMappingURL=relation.decorator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"relation.decorator.js","sourceRoot":"","sources":["../../src/relations/relation.decorator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AAEhE,+CAA2D;AAC3D,8CAAmD;AAEnD,qDAA8C;AAEjC,QAAA,aAAa,GAAG,oBAAoB,CAAC;AAElD;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,UAAmB;IAC1C,+CAA+C;IAC/C,OAAO,kCAAwB,CAAC,eAAe,CAAC,qBAAa,EAAE,UAAU,CAAC,CAAC;AAC7E,CAAC;AAHD,4BAGC;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAC/B,SAAuB;IAEvB,iDAAiD;IACjD,MAAM,QAAQ,GAAG,iCAAoB,CAAC,SAAS,CAAC,CAAC;IACjD,OAAO,CAAC,QAAQ,IAAI,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;AAChD,CAAC;AAND,8CAMC;AAED,EAAE;AACF,oEAAoE;AACpE,6DAA6D;AAC7D,EAAE;AAEF;;;;GAIG;AACH,SAAgB,SAAS,CAAC,UAAmB;IAC3C,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,EAAC,IAAI,EAAE,6BAAY,CAAC,SAAS,EAAC,EAAE,UAAU,CAAC,CAAC;IACtE,OAAO,kCAAwB,CAAC,eAAe,CAAC,qBAAa,EAAE,GAAG,CAAC,CAAC;AACtE,CAAC;AAHD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,EAAE,6BAAY,CAAC,cAAc,EAAC,EAAE,UAAU,CAAC,CAAC;IAC3E,OAAO,kCAAwB,CAAC,eAAe,CAAC,qBAAa,EAAE,GAAG,EAAE;QAClE,aAAa,EAAE,iBAAiB;KACjC,CAAC,CAAC;AACL,CAAC;AALD,wCAKC"}
@@ -0,0 +1,23 @@
1
+ import { Entity, EntityCrudRepository, Filter, Inclusion, Options } from '..';
2
+ /**
3
+ * Finds model instances that contain any of the provided foreign key values.
4
+ *
5
+ * @param targetRepository - The target repository where the model instances are found
6
+ * @param fkName - Name of the foreign key
7
+ * @param fkValues - One value or array of values of the foreign key to be included
8
+ * @param scope - Additional scope constraints (not currently supported)
9
+ * @param options - Options for the operations
10
+ */
11
+ export declare function findByForeignKeys<Target extends Entity, TargetRelations extends object, ForeignKey extends StringKeyOf<Target>>(targetRepository: EntityCrudRepository<Target, unknown, TargetRelations>, fkName: ForeignKey, fkValues: Target[ForeignKey][] | Target[ForeignKey], scope?: Filter<Target>, options?: Options): Promise<(Target & TargetRelations)[]>;
12
+ declare type StringKeyOf<T> = Extract<keyof T, string>;
13
+ /**
14
+ * Returns model instances that include related models that have a registered
15
+ * resolver.
16
+ *
17
+ * @param targetRepository - The target repository where the model instances are found
18
+ * @param entities - An array of entity instances or data
19
+ * @param include -Inclusion filter
20
+ * @param options - Options for the operations
21
+ */
22
+ export declare function includeRelatedModels<T extends Entity, Relations extends object = {}>(targetRepository: EntityCrudRepository<T, unknown, Relations>, entities: T[], include?: Inclusion<T>[], options?: Options): Promise<(T & Relations)[]>;
23
+ export {};
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ // Copyright IBM Corp. 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
+ const debugFactory = require("debug");
8
+ const _ = require("lodash");
9
+ const debug = debugFactory('loopback:repository:relation-helpers');
10
+ /**
11
+ * Finds model instances that contain any of the provided foreign key values.
12
+ *
13
+ * @param targetRepository - The target repository where the model instances are found
14
+ * @param fkName - Name of the foreign key
15
+ * @param fkValues - One value or array of values of the foreign key to be included
16
+ * @param scope - Additional scope constraints (not currently supported)
17
+ * @param options - Options for the operations
18
+ */
19
+ async function findByForeignKeys(targetRepository, fkName, fkValues, scope, options) {
20
+ // throw error if scope is defined and non-empty
21
+ // see https://github.com/strongloop/loopback-next/issues/3453
22
+ if (scope && !_.isEmpty(scope)) {
23
+ throw new Error('scope is not supported');
24
+ }
25
+ let value;
26
+ if (Array.isArray(fkValues)) {
27
+ if (fkValues.length === 0)
28
+ return [];
29
+ value = fkValues.length === 1 ? fkValues[0] : { inq: fkValues };
30
+ }
31
+ else {
32
+ value = fkValues;
33
+ }
34
+ const where = { [fkName]: value };
35
+ const targetFilter = { where };
36
+ return targetRepository.find(targetFilter, options);
37
+ }
38
+ exports.findByForeignKeys = findByForeignKeys;
39
+ /**
40
+ * Returns model instances that include related models that have a registered
41
+ * resolver.
42
+ *
43
+ * @param targetRepository - The target repository where the model instances are found
44
+ * @param entities - An array of entity instances or data
45
+ * @param include -Inclusion filter
46
+ * @param options - Options for the operations
47
+ */
48
+ async function includeRelatedModels(targetRepository, entities, include, options) {
49
+ const result = entities;
50
+ if (!include)
51
+ return result;
52
+ const invalidInclusions = include.filter(inclusionFilter => !isInclusionAllowed(targetRepository, inclusionFilter));
53
+ if (invalidInclusions.length) {
54
+ const msg = 'Invalid "filter.include" entries: ' +
55
+ invalidInclusions
56
+ .map(inclusionFilter => JSON.stringify(inclusionFilter))
57
+ .join('; ');
58
+ const err = new Error(msg);
59
+ Object.assign(err, {
60
+ code: 'INVALID_INCLUSION_FILTER',
61
+ });
62
+ throw err;
63
+ }
64
+ const resolveTasks = include.map(async (inclusionFilter) => {
65
+ const relationName = inclusionFilter.relation;
66
+ const resolver = targetRepository.inclusionResolvers.get(relationName);
67
+ const targets = await resolver(entities, inclusionFilter, options);
68
+ result.forEach((entity, ix) => {
69
+ const src = entity;
70
+ src[relationName] = targets[ix];
71
+ });
72
+ });
73
+ await Promise.all(resolveTasks);
74
+ return result;
75
+ }
76
+ exports.includeRelatedModels = includeRelatedModels;
77
+ /**
78
+ * Checks if the resolver of the inclusion relation is registered
79
+ * in the inclusionResolver of the target repository
80
+ *
81
+ * @param targetRepository - The target repository where the relations are registered
82
+ * @param include - Inclusion filter
83
+ */
84
+ function isInclusionAllowed(targetRepository, include) {
85
+ const relationName = include.relation;
86
+ if (!relationName) {
87
+ debug('isInclusionAllowed for %j? No: missing relation name', include);
88
+ return false;
89
+ }
90
+ const allowed = targetRepository.inclusionResolvers.has(relationName);
91
+ debug('isInclusionAllowed for %j (relation %s)? %s', include, allowed);
92
+ return allowed;
93
+ }
94
+ //# sourceMappingURL=relation.helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relation.helpers.js","sourceRoot":"","sources":["../../src/relations/relation.helpers.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AAEhE,sCAAsC;AACtC,4BAA4B;AAU5B,MAAM,KAAK,GAAG,YAAY,CAAC,sCAAsC,CAAC,CAAC;AAEnE;;;;;;;;GAQG;AACI,KAAK,UAAU,iBAAiB,CAKrC,gBAAwE,EACxE,MAAkB,EAClB,QAAmD,EACnD,KAAsB,EACtB,OAAiB;IAEjB,gDAAgD;IAChD,8DAA8D;IAC9D,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QAC9B,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;KAC3C;IAED,IAAI,KAAK,CAAC;IAEV,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC3B,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QACrC,KAAK,GAAG,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAA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AAkB,CAAC,GAAG,CAAC,YAAY,CAAE,CAAC;QACxE,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC;QAEnE,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE;YAC5B,MAAM,GAAG,GAAG,MAAmB,CAAC;YAChC,GAAG,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,EAAE,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAEhC,OAAO,MAAM,CAAC;AAChB,CAAC;AA1CD,oDA0CC;AACD;;;;;;GAMG;AACH,SAAS,kBAAkB,CACzB,gBAA6D,EAC7D,OAAkB;IAElB,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC;IACtC,IAAI,CAAC,YAAY,EAAE;QACjB,KAAK,CAAC,sDAAsD,EAAE,OAAO,CAAC,CAAC;QACvE,OAAO,KAAK,CAAC;KACd;IACD,MAAM,OAAO,GAAG,gBAAgB,CAAC,kBAAkB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACtE,KAAK,CAAC,6CAA6C,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACvE,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -1,4 +1,6 @@
1
+ import { Options } from '../common-types';
1
2
  import { Entity } from '../model';
3
+ import { Inclusion } from '../query';
2
4
  import { TypeResolver } from '../type-resolver';
3
5
  export declare enum RelationType {
4
6
  belongsTo = "belongsTo",
@@ -73,3 +75,23 @@ export interface HasOneDefinition extends RelationDefinitionBase {
73
75
  */
74
76
  export declare type RelationMetadata = HasManyDefinition | BelongsToDefinition | HasOneDefinition | RelationDefinitionBase;
75
77
  export { Getter } from '@loopback/context';
78
+ /**
79
+ * @returns An array of resolved values, the items must be ordered in the same
80
+ * way as `sourceEntities`. The resolved value can be one of:
81
+ * - `undefined` when no target model(s) were found
82
+ * - `Entity` for relations targeting a single model
83
+ * - `Entity[]` for relations targeting multiple models
84
+ */
85
+ export declare type InclusionResolver<S extends Entity, T extends Entity> = (
86
+ /**
87
+ * List of source models as returned by the first database query.
88
+ */
89
+ sourceEntities: S[],
90
+ /**
91
+ * Inclusion requested by the user (e.g. scope constraints to apply).
92
+ */
93
+ inclusion: Inclusion,
94
+ /**
95
+ * Generic options object, e.g. carrying the Transaction object.
96
+ */
97
+ options?: Options) => Promise<(T | undefined)[] | (T[] | undefined)[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"relation.types.js","sourceRoot":"","sources":["../../src/relations/relation.types.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AAKhE,IAAY,YAQX;AARD,WAAY,YAAY;IACtB,uCAAuB,CAAA;IACvB,iCAAiB,CAAA;IACjB,mCAAmB,CAAA;IACnB,uCAAuB,CAAA;IACvB,yCAAyB,CAAA;IACzB,+CAA+B,CAAA;IAC/B,iDAAiC,CAAA;AACnC,CAAC,EARW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAQvB;AA4FD,6EAA6E;AAC7E,6CAAyC;AAAjC,2BAAA,MAAM,CAAA"}
1
+ {"version":3,"file":"relation.types.js","sourceRoot":"","sources":["../../src/relations/relation.types.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,oCAAoC;AACpC,+CAA+C;AAC/C,gEAAgE;;AAOhE,IAAY,YAQX;AARD,WAAY,YAAY;IACtB,uCAAuB,CAAA;IACvB,iCAAiB,CAAA;IACjB,mCAAmB,CAAA;IACnB,uCAAuB,CAAA;IACvB,yCAAyB,CAAA;IACzB,+CAA+B,CAAA;IAC/B,iDAAiC,CAAA;AACnC,CAAC,EARW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAQvB;AA4FD,6EAA6E;AAC7E,6CAAyC;AAAjC,2BAAA,MAAM,CAAA"}
@@ -2,9 +2,10 @@ import { Getter } from '@loopback/context';
2
2
  import * as legacy from 'loopback-datasource-juggler';
3
3
  import { AnyObject, Command, Count, DataObject, NamedParameters, Options, PositionalParameters } from '../common-types';
4
4
  import { Entity } from '../model';
5
- import { Filter, Where } from '../query';
6
- import { BelongsToAccessor, HasManyRepositoryFactory, HasOneRepositoryFactory } from '../relations';
7
- import { EntityCrudRepository } from './repository';
5
+ import { Filter, Inclusion, Where } from '../query';
6
+ import { BelongsToAccessor, HasManyRepositoryFactory, HasOneRepositoryFactory, InclusionResolver } from '../relations';
7
+ import { IsolationLevel, Transaction } from '../transaction';
8
+ import { EntityCrudRepository, TransactionalEntityRepository } from './repository';
8
9
  export declare namespace juggler {
9
10
  export import DataSource = legacy.DataSource;
10
11
  export import ModelBase = legacy.ModelBase;
@@ -12,6 +13,8 @@ export declare namespace juggler {
12
13
  export import PersistedModel = legacy.PersistedModel;
13
14
  export import KeyValueModel = legacy.KeyValueModel;
14
15
  export import PersistedModelClass = legacy.PersistedModelClass;
16
+ export import Transaction = legacy.Transaction;
17
+ export import IsolationLevel = legacy.IsolationLevel;
15
18
  }
16
19
  /**
17
20
  * This is a bridge to the legacy DAO class. The function mixes DAO methods
@@ -36,6 +39,7 @@ export declare class DefaultCrudRepository<T extends Entity, ID, Relations exten
36
39
  };
37
40
  dataSource: juggler.DataSource;
38
41
  modelClass: juggler.PersistedModelClass;
42
+ readonly inclusionResolvers: Map<string, InclusionResolver<T, Entity>>;
39
43
  /**
40
44
  * Constructor of DefaultCrudRepository
41
45
  * @param entityClass - Legacy entity class
@@ -121,7 +125,7 @@ export declare class DefaultCrudRepository<T extends Entity, ID, Relations exten
121
125
  createAll(entities: DataObject<T>[], options?: Options): Promise<T[]>;
122
126
  save(entity: T, options?: Options): Promise<T>;
123
127
  find(filter?: Filter<T>, options?: Options): Promise<(T & Relations)[]>;
124
- findOne(filter?: Filter<T>, options?: Options): Promise<T | null>;
128
+ findOne(filter?: Filter<T>, options?: Options): Promise<(T & Relations) | null>;
125
129
  findById(id: ID, filter?: Filter<T>, options?: Options): Promise<T & Relations>;
126
130
  update(entity: T, options?: Options): Promise<void>;
127
131
  delete(entity: T, options?: Options): Promise<void>;
@@ -135,4 +139,35 @@ export declare class DefaultCrudRepository<T extends Entity, ID, Relations exten
135
139
  execute(command: Command, parameters: NamedParameters | PositionalParameters, options?: Options): Promise<AnyObject>;
136
140
  protected toEntity<R extends T>(model: juggler.PersistedModel): R;
137
141
  protected toEntities<R extends T>(models: juggler.PersistedModel[]): R[];
142
+ /**
143
+ * Register an inclusion resolver for the related model name.
144
+ *
145
+ * @param relationName - Name of the relation defined on the source model
146
+ * @param resolver - Resolver function for getting related model entities
147
+ */
148
+ registerInclusionResolver(relationName: string, resolver: InclusionResolver<T, Entity>): void;
149
+ /**
150
+ * Returns model instances that include related models of this repository
151
+ * that have a registered resolver.
152
+ *
153
+ * @param entities - An array of entity instances or data
154
+ * @param include -Inclusion filter
155
+ * @param options - Options for the operations
156
+ */
157
+ protected includeRelatedModels(entities: T[], include?: Inclusion<T>[], options?: Options): Promise<(T & Relations)[]>;
158
+ /**
159
+ * Removes juggler's "include" filter as it does not apply to LoopBack 4
160
+ * relations.
161
+ *
162
+ * @param filter - Query filter
163
+ */
164
+ protected normalizeFilter(filter?: Filter<T>): legacy.Filter | undefined;
165
+ }
166
+ /**
167
+ * Default implementation of CRUD repository using legacy juggler model
168
+ * and data source with beginTransaction() method for connectors which
169
+ * support Transactions
170
+ */
171
+ export declare class DefaultTransactionalRepository<T extends Entity, ID, Relations extends object = {}> extends DefaultCrudRepository<T, ID, Relations> implements TransactionalEntityRepository<T, ID, Relations> {
172
+ beginTransaction(options?: IsolationLevel | Options): Promise<Transaction>;
138
173
  }