@loopback/repository-tests 0.20.2 → 0.21.0

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 (92) hide show
  1. package/dist/crud/relations/acceptance/belongs-to.inclusion-resolver.polymorphic.relation.acceptance.d.ts +2 -0
  2. package/dist/crud/relations/acceptance/belongs-to.inclusion-resolver.polymorphic.relation.acceptance.js +170 -0
  3. package/dist/crud/relations/acceptance/belongs-to.inclusion-resolver.polymorphic.relation.acceptance.js.map +1 -0
  4. package/dist/crud/relations/acceptance/belongs-to.polymorphic.relation.acceptance.d.ts +2 -0
  5. package/dist/crud/relations/acceptance/belongs-to.polymorphic.relation.acceptance.js +55 -0
  6. package/dist/crud/relations/acceptance/belongs-to.polymorphic.relation.acceptance.js.map +1 -0
  7. package/dist/crud/relations/acceptance/has-many-through-inclusion-resolver.polymorphic.acceptance.d.ts +2 -0
  8. package/dist/crud/relations/acceptance/has-many-through-inclusion-resolver.polymorphic.acceptance.js +170 -0
  9. package/dist/crud/relations/acceptance/has-many-through-inclusion-resolver.polymorphic.acceptance.js.map +1 -0
  10. package/dist/crud/relations/acceptance/has-many-through.relation.polymorphic.acceptance.d.ts +2 -0
  11. package/dist/crud/relations/acceptance/has-many-through.relation.polymorphic.acceptance.js +361 -0
  12. package/dist/crud/relations/acceptance/has-many-through.relation.polymorphic.acceptance.js.map +1 -0
  13. package/dist/crud/relations/acceptance/has-one.inclusion-resolver.polymorphic.acceptance.d.ts +2 -0
  14. package/dist/crud/relations/acceptance/has-one.inclusion-resolver.polymorphic.acceptance.js +161 -0
  15. package/dist/crud/relations/acceptance/has-one.inclusion-resolver.polymorphic.acceptance.js.map +1 -0
  16. package/dist/crud/relations/acceptance/has-one.relation.polymorphic.acceptance.d.ts +2 -0
  17. package/dist/crud/relations/acceptance/has-one.relation.polymorphic.acceptance.js +190 -0
  18. package/dist/crud/relations/acceptance/has-one.relation.polymorphic.acceptance.js.map +1 -0
  19. package/dist/crud/relations/fixtures/models/contact.model.d.ts +18 -0
  20. package/dist/crud/relations/fixtures/models/contact.model.js +49 -0
  21. package/dist/crud/relations/fixtures/models/contact.model.js.map +1 -0
  22. package/dist/crud/relations/fixtures/models/customer-promotion-link.model.d.ts +14 -0
  23. package/dist/crud/relations/fixtures/models/customer-promotion-link.model.js +46 -0
  24. package/dist/crud/relations/fixtures/models/customer-promotion-link.model.js.map +1 -0
  25. package/dist/crud/relations/fixtures/models/customer.model.d.ts +16 -3
  26. package/dist/crud/relations/fixtures/models/customer.model.js +27 -9
  27. package/dist/crud/relations/fixtures/models/customer.model.js.map +1 -1
  28. package/dist/crud/relations/fixtures/models/index.d.ts +6 -0
  29. package/dist/crud/relations/fixtures/models/index.js +6 -0
  30. package/dist/crud/relations/fixtures/models/index.js.map +1 -1
  31. package/dist/crud/relations/fixtures/models/payment-method.model.d.ts +47 -0
  32. package/dist/crud/relations/fixtures/models/payment-method.model.js +87 -0
  33. package/dist/crud/relations/fixtures/models/payment-method.model.js.map +1 -0
  34. package/dist/crud/relations/fixtures/models/promotion.model.d.ts +27 -0
  35. package/dist/crud/relations/fixtures/models/promotion.model.js +54 -0
  36. package/dist/crud/relations/fixtures/models/promotion.model.js.map +1 -0
  37. package/dist/crud/relations/fixtures/models/stakeholder.model.d.ts +7 -0
  38. package/dist/crud/relations/fixtures/models/stakeholder.model.js +38 -0
  39. package/dist/crud/relations/fixtures/models/stakeholder.model.js.map +1 -0
  40. package/dist/crud/relations/fixtures/models/supplier.model.d.ts +15 -0
  41. package/dist/crud/relations/fixtures/models/supplier.model.js +23 -0
  42. package/dist/crud/relations/fixtures/models/supplier.model.js.map +1 -0
  43. package/dist/crud/relations/fixtures/repositories/contact.repository.d.ts +30 -0
  44. package/dist/crud/relations/fixtures/repositories/contact.repository.js +21 -0
  45. package/dist/crud/relations/fixtures/repositories/contact.repository.js.map +1 -0
  46. package/dist/crud/relations/fixtures/repositories/customer-promotion-link.repository.d.ts +26 -0
  47. package/dist/crud/relations/fixtures/repositories/customer-promotion-link.repository.js +18 -0
  48. package/dist/crud/relations/fixtures/repositories/customer-promotion-link.repository.js.map +1 -0
  49. package/dist/crud/relations/fixtures/repositories/customer.repository.d.ts +9 -2
  50. package/dist/crud/relations/fixtures/repositories/customer.repository.js +7 -1
  51. package/dist/crud/relations/fixtures/repositories/customer.repository.js.map +1 -1
  52. package/dist/crud/relations/fixtures/repositories/index.d.ts +6 -1
  53. package/dist/crud/relations/fixtures/repositories/index.js +6 -1
  54. package/dist/crud/relations/fixtures/repositories/index.js.map +1 -1
  55. package/dist/crud/relations/fixtures/repositories/payment-method.repository.d.ts +77 -0
  56. package/dist/crud/relations/fixtures/repositories/payment-method.repository.js +45 -0
  57. package/dist/crud/relations/fixtures/repositories/payment-method.repository.js.map +1 -0
  58. package/dist/crud/relations/fixtures/repositories/promotion.repository.d.ts +49 -0
  59. package/dist/crud/relations/fixtures/repositories/promotion.repository.js +25 -0
  60. package/dist/crud/relations/fixtures/repositories/promotion.repository.js.map +1 -0
  61. package/dist/crud/relations/fixtures/repositories/supplier.repository.d.ts +28 -0
  62. package/dist/crud/relations/fixtures/repositories/supplier.repository.js +21 -0
  63. package/dist/crud/relations/fixtures/repositories/supplier.repository.js.map +1 -0
  64. package/dist/crud/relations/helpers.d.ts +9 -1
  65. package/dist/crud/relations/helpers.js +85 -10
  66. package/dist/crud/relations/helpers.js.map +1 -1
  67. package/dist/helpers.repository-tests.d.ts +1 -1
  68. package/dist/helpers.repository-tests.js.map +1 -1
  69. package/package.json +12 -12
  70. package/src/crud/relations/acceptance/belongs-to.inclusion-resolver.polymorphic.relation.acceptance.ts +221 -0
  71. package/src/crud/relations/acceptance/belongs-to.polymorphic.relation.acceptance.ts +88 -0
  72. package/src/crud/relations/acceptance/has-many-through-inclusion-resolver.polymorphic.acceptance.ts +255 -0
  73. package/src/crud/relations/acceptance/has-many-through.relation.polymorphic.acceptance.ts +494 -0
  74. package/src/crud/relations/acceptance/has-one.inclusion-resolver.polymorphic.acceptance.ts +208 -0
  75. package/src/crud/relations/acceptance/has-one.relation.polymorphic.acceptance.ts +328 -0
  76. package/src/crud/relations/fixtures/models/contact.model.ts +56 -0
  77. package/src/crud/relations/fixtures/models/customer-promotion-link.model.ts +52 -0
  78. package/src/crud/relations/fixtures/models/customer.model.ts +39 -9
  79. package/src/crud/relations/fixtures/models/index.ts +6 -0
  80. package/src/crud/relations/fixtures/models/payment-method.model.ts +118 -0
  81. package/src/crud/relations/fixtures/models/promotion.model.ts +67 -0
  82. package/src/crud/relations/fixtures/models/stakeholder.model.ts +33 -0
  83. package/src/crud/relations/fixtures/models/supplier.model.ts +35 -0
  84. package/src/crud/relations/fixtures/repositories/contact.repository.ts +44 -0
  85. package/src/crud/relations/fixtures/repositories/customer-promotion-link.repository.ts +20 -0
  86. package/src/crud/relations/fixtures/repositories/customer.repository.ts +47 -0
  87. package/src/crud/relations/fixtures/repositories/index.ts +6 -1
  88. package/src/crud/relations/fixtures/repositories/payment-method.repository.ts +118 -0
  89. package/src/crud/relations/fixtures/repositories/promotion.repository.ts +37 -0
  90. package/src/crud/relations/fixtures/repositories/supplier.repository.ts +40 -0
  91. package/src/crud/relations/helpers.ts +200 -30
  92. package/src/helpers.repository-tests.ts +1 -1
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ // Copyright IBM Corp. 2019. All Rights Reserved.
3
+ // Node module: @loopback/repository-tests
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.createHalfPriceRepo = exports.createFreeDeliveryRepo = void 0;
8
+ const models_1 = require("../models");
9
+ function createFreeDeliveryRepo(repoClass) {
10
+ return class FreeDeliveryRepository extends repoClass {
11
+ constructor(db) {
12
+ super(models_1.FreeDelivery, db);
13
+ }
14
+ };
15
+ }
16
+ exports.createFreeDeliveryRepo = createFreeDeliveryRepo;
17
+ function createHalfPriceRepo(repoClass) {
18
+ return class HalfPriceRepository extends repoClass {
19
+ constructor(db) {
20
+ super(models_1.HalfPrice, db);
21
+ }
22
+ };
23
+ }
24
+ exports.createHalfPriceRepo = createHalfPriceRepo;
25
+ //# sourceMappingURL=promotion.repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promotion.repository.js","sourceRoot":"","sources":["../../../../../src/crud/relations/fixtures/repositories/promotion.repository.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,0CAA0C;AAC1C,+CAA+C;AAC/C,gEAAgE;;;AAIhE,sCAKmB;AAEnB,SAAgB,sBAAsB,CAAC,SAA6B;IAClE,OAAO,MAAM,sBAAuB,SAAQ,SAI3C;QACC,YAAY,EAAsB;YAChC,KAAK,CAAC,qBAAY,EAAE,EAAE,CAAC,CAAC;QAC1B,CAAC;KACF,CAAC;AACJ,CAAC;AAVD,wDAUC;AAED,SAAgB,mBAAmB,CAAC,SAA6B;IAC/D,OAAO,MAAM,mBAAoB,SAAQ,SAIxC;QACC,YAAY,EAAsB;YAChC,KAAK,CAAC,kBAAS,EAAE,EAAE,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC;AAVD,kDAUC"}
@@ -0,0 +1,28 @@
1
+ import { Getter } from '@loopback/core';
2
+ import { HasOneRepositoryFactory, juggler } from '@loopback/repository';
3
+ import { CrudRepositoryCtor } from '../../../../types.repository-tests';
4
+ import { Contact, Supplier, SupplierRelations } from '../models';
5
+ export declare function createSupplierRepo(repoClass: CrudRepositoryCtor): {
6
+ new (db: juggler.DataSource, contactRepositoryGetter: Getter<typeof repoClass.prototype>): {
7
+ readonly contact: HasOneRepositoryFactory<Contact, typeof Supplier.prototype.id>;
8
+ entityClass: typeof import("@loopback/repository").Entity & {
9
+ prototype: Supplier;
10
+ };
11
+ inclusionResolvers: Map<string, import("@loopback/repository").InclusionResolver<Supplier, import("@loopback/repository").Entity>>;
12
+ save(entity: import("@loopback/repository").DataObject<Supplier>, options?: import("@loopback/repository").AnyObject | undefined): Promise<Supplier>;
13
+ update(entity: import("@loopback/repository").DataObject<Supplier>, options?: import("@loopback/repository").AnyObject | undefined): Promise<void>;
14
+ delete(entity: import("@loopback/repository").DataObject<Supplier>, options?: import("@loopback/repository").AnyObject | undefined): Promise<void>;
15
+ findById(id: import("../../../../helpers.repository-tests").MixedIdType, filter?: import("@loopback/repository").FilterExcludingWhere<Supplier> | undefined, options?: import("@loopback/repository").AnyObject | undefined): Promise<Supplier & SupplierRelations>;
16
+ updateById(id: import("../../../../helpers.repository-tests").MixedIdType, data: import("@loopback/repository").DataObject<Supplier>, options?: import("@loopback/repository").AnyObject | undefined): Promise<void>;
17
+ replaceById(id: import("../../../../helpers.repository-tests").MixedIdType, data: import("@loopback/repository").DataObject<Supplier>, options?: import("@loopback/repository").AnyObject | undefined): Promise<void>;
18
+ deleteById(id: import("../../../../helpers.repository-tests").MixedIdType, options?: import("@loopback/repository").AnyObject | undefined): Promise<void>;
19
+ exists(id: import("../../../../helpers.repository-tests").MixedIdType, options?: import("@loopback/repository").AnyObject | undefined): Promise<boolean>;
20
+ execute(command: import("@loopback/repository").Command, parameters: import("@loopback/repository").AnyObject | import("@loopback/repository").PositionalParameters, options?: import("@loopback/repository").AnyObject | undefined): Promise<import("@loopback/repository").AnyObject>;
21
+ create(dataObject: import("@loopback/repository").DataObject<Supplier>, options?: import("@loopback/repository").AnyObject | undefined): Promise<Supplier>;
22
+ createAll(dataObjects: import("@loopback/repository").DataObject<Supplier>[], options?: import("@loopback/repository").AnyObject | undefined): Promise<Supplier[]>;
23
+ find(filter?: import("@loopback/repository").Filter<Supplier> | undefined, options?: import("@loopback/repository").AnyObject | undefined): Promise<(Supplier & SupplierRelations)[]>;
24
+ updateAll(dataObject: import("@loopback/repository").DataObject<Supplier>, where?: import("@loopback/repository").Where<Supplier> | undefined, options?: import("@loopback/repository").AnyObject | undefined): Promise<import("@loopback/repository").Count>;
25
+ deleteAll(where?: import("@loopback/repository").Where<Supplier> | undefined, options?: import("@loopback/repository").AnyObject | undefined): Promise<import("@loopback/repository").Count>;
26
+ count(where?: import("@loopback/repository").Where<Supplier> | undefined, options?: import("@loopback/repository").AnyObject | undefined): Promise<import("@loopback/repository").Count>;
27
+ };
28
+ };
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ // Copyright IBM Corp. 2019,2020. All Rights Reserved.
3
+ // Node module: @loopback/repository-tests
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.createSupplierRepo = void 0;
8
+ const repository_1 = require("@loopback/repository");
9
+ const models_1 = require("../models");
10
+ // create the SupplierRepo by calling this func so that it can be extended from CrudRepositoryCtor
11
+ function createSupplierRepo(repoClass) {
12
+ return class SupplierRepository extends repoClass {
13
+ constructor(db, contactRepositoryGetter) {
14
+ super(models_1.Supplier, db);
15
+ const contactMeta = this.entityClass.definition.relations['contact'];
16
+ this.contact = (0, repository_1.createHasOneRepositoryFactory)(contactMeta, contactRepositoryGetter);
17
+ }
18
+ };
19
+ }
20
+ exports.createSupplierRepo = createSupplierRepo;
21
+ //# sourceMappingURL=supplier.repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supplier.repository.js","sourceRoot":"","sources":["../../../../../src/crud/relations/fixtures/repositories/supplier.repository.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,0CAA0C;AAC1C,+CAA+C;AAC/C,gEAAgE;;;AAGhE,qDAK8B;AAE9B,sCAA+D;AAE/D,kGAAkG;AAClG,SAAgB,kBAAkB,CAAC,SAA6B;IAC9D,OAAO,MAAM,kBAAmB,SAAQ,SAIvC;QAMC,YACE,EAAsB,EACtB,uBAA2D;YAE3D,KAAK,CAAC,iBAAQ,EAAE,EAAE,CAAC,CAAC;YACpB,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;YACrE,IAAI,CAAC,OAAO,GAAG,IAAA,0CAA6B,EAC1C,WAA+B,EAC/B,uBAAuB,CACxB,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAvBD,gDAuBC"}
@@ -1,6 +1,6 @@
1
1
  import { juggler } from '@loopback/repository';
2
2
  import { CrudFeatures, CrudRepositoryCtor } from '../..';
3
- import { AddressRepository, CartItemRepository, CustomerCartItemLinkRepository, CustomerRepository, OrderRepository, ShipmentRepository, UserLinkRepository, UserRepository } from './fixtures/models';
3
+ import { AddressRepository, CardInfoRepository, CartItemRepository, CashRepository, ContactRepository, CreditCardRepository, CustomerCartItemLinkRepository, CustomerPromotionLinkRepository, CustomerRepository, FreeDeliveryRepository, HalfPriceRepository, OrderRepository, ShipmentRepository, SupplierRepository, UserLinkRepository, UserRepository } from './fixtures/models';
4
4
  export declare function givenBoundCrudRepositories(db: juggler.DataSource, repositoryClass: CrudRepositoryCtor, features: CrudFeatures): {
5
5
  customerRepo: CustomerRepository;
6
6
  orderRepo: OrderRepository;
@@ -8,6 +8,14 @@ export declare function givenBoundCrudRepositories(db: juggler.DataSource, repos
8
8
  addressRepo: AddressRepository;
9
9
  cartItemRepo: CartItemRepository;
10
10
  customerCartItemLinkRepo: CustomerCartItemLinkRepository;
11
+ freeDeliveryRepo: FreeDeliveryRepository;
12
+ halfPriceRepo: HalfPriceRepository;
13
+ customerPromotionLinkRepo: CustomerPromotionLinkRepository;
11
14
  userRepo: UserRepository;
12
15
  userLinkRepo: UserLinkRepository;
16
+ creditCardRepo: CreditCardRepository;
17
+ cashRepo: CashRepository;
18
+ contactRepo: ContactRepository;
19
+ supplierRepo: SupplierRepository;
20
+ cardInfoRepo: CardInfoRepository;
13
21
  };
@@ -11,8 +11,16 @@ function givenBoundCrudRepositories(db, repositoryClass, features) {
11
11
  models_1.Order.definition.properties.id.type = features.idType;
12
12
  models_1.Address.definition.properties.id.type = features.idType;
13
13
  models_1.Customer.definition.properties.id.type = features.idType;
14
+ models_1.Supplier.definition.properties.id.type = features.idType;
15
+ models_1.Contact.definition.properties.id.type = features.idType;
16
+ models_1.CreditCard.definition.properties.id.type = features.idType;
17
+ models_1.CardInfo.definition.properties.id.type = features.idType;
18
+ models_1.Cash.definition.properties.id.type = features.idType;
14
19
  models_1.CartItem.definition.properties.id.type = features.idType;
15
20
  models_1.CustomerCartItemLink.definition.properties.id.type = features.idType;
21
+ models_1.FreeDelivery.definition.properties.id.type = features.idType;
22
+ models_1.HalfPrice.definition.properties.id.type = features.idType;
23
+ models_1.CustomerPromotionLink.definition.properties.id.type = features.idType;
16
24
  models_1.Shipment.definition.properties.id.type = features.idType;
17
25
  models_1.User.definition.properties.id.type = features.idType;
18
26
  models_1.UserLink.definition.properties.id.type = features.idType;
@@ -20,6 +28,10 @@ function givenBoundCrudRepositories(db, repositoryClass, features) {
20
28
  // this config for mongo connector to pass the test.
21
29
  // however real-world applications might have such config for MongoDB
22
30
  // setting it up to check if it works fine as well
31
+ models_1.Contact.definition.properties.stakeholderId.type = features.idType;
32
+ models_1.Contact.definition.properties.stakeholderId.mongodb = {
33
+ dataType: 'ObjectID',
34
+ };
23
35
  models_1.Order.definition.properties.customerId.type = features.idType;
24
36
  models_1.Order.definition.properties.customerId.mongodb = {
25
37
  dataType: 'ObjectID',
@@ -28,12 +40,24 @@ function givenBoundCrudRepositories(db, repositoryClass, features) {
28
40
  models_1.Address.definition.properties.customerId.mongodb = {
29
41
  dataType: 'ObjectID',
30
42
  };
43
+ models_1.CreditCard.definition.properties.customerId.type = features.idType;
44
+ models_1.CreditCard.definition.properties.customerId.mongodb = {
45
+ dataType: 'ObjectID',
46
+ };
47
+ models_1.CardInfo.definition.properties.creditCardId.type = features.idType;
48
+ models_1.CardInfo.definition.properties.creditCardId.mongodb = {
49
+ dataType: 'ObjectID',
50
+ };
51
+ models_1.Cash.definition.properties.customerId.type = features.idType;
52
+ models_1.Cash.definition.properties.customerId.mongodb = {
53
+ dataType: 'ObjectID',
54
+ };
31
55
  models_1.CustomerCartItemLink.definition.properties.customerId.type = features.idType;
32
56
  models_1.CustomerCartItemLink.definition.properties.customerId.mongodb = {
33
57
  dataType: 'ObjectID',
34
58
  };
35
- models_1.CustomerCartItemLink.definition.properties.cartItemId.type = features.idType;
36
- models_1.CustomerCartItemLink.definition.properties.cartItemId.mongodb = {
59
+ models_1.CustomerPromotionLink.definition.properties.customerId.type = features.idType;
60
+ models_1.CustomerPromotionLink.definition.properties.customerId.mongodb = {
37
61
  dataType: 'ObjectID',
38
62
  };
39
63
  models_1.UserLink.definition.properties.followerId.type = features.idType;
@@ -44,14 +68,6 @@ function givenBoundCrudRepositories(db, repositoryClass, features) {
44
68
  models_1.UserLink.definition.properties.followeeId.mongodb = {
45
69
  dataType: 'ObjectID',
46
70
  };
47
- // get the repository class and create a new instance of it
48
- const customerRepoClass = (0, repositories_1.createCustomerRepo)(repositoryClass);
49
- const customerRepo = new customerRepoClass(db, async () => orderRepo, async () => addressRepo, async () => cartItemRepo, async () => customerCartItemLinkRepo);
50
- // register the inclusionResolvers here for customerRepo
51
- customerRepo.inclusionResolvers.set('orders', customerRepo.orders.inclusionResolver);
52
- customerRepo.inclusionResolvers.set('customers', customerRepo.customers.inclusionResolver);
53
- customerRepo.inclusionResolvers.set('address', customerRepo.address.inclusionResolver);
54
- customerRepo.inclusionResolvers.set('cartItems', customerRepo.cartItems.inclusionResolver);
55
71
  const orderRepoClass = (0, repositories_1.createOrderRepo)(repositoryClass);
56
72
  const orderRepo = new orderRepoClass(db, async () => customerRepo, async () => shipmentRepo);
57
73
  // register the inclusionResolvers here for orderRepo
@@ -61,16 +77,67 @@ function givenBoundCrudRepositories(db, repositoryClass, features) {
61
77
  shipmentRepo.inclusionResolvers.set('shipmentOrders', shipmentRepo.shipmentOrders.inclusionResolver);
62
78
  const addressRepoClass = (0, repositories_1.createAddressRepo)(repositoryClass);
63
79
  const addressRepo = new addressRepoClass(db, async () => customerRepo);
80
+ const creditCardRepoClass = (0, repositories_1.createCreditCardRepo)(repositoryClass);
81
+ const cashRepoClass = (0, repositories_1.createCashRepo)(repositoryClass);
82
+ const creditCardRepo = new creditCardRepoClass(db, async () => customerRepo, async () => cardInfoRepo);
83
+ const cashRepo = new cashRepoClass(db, async () => customerRepo);
84
+ creditCardRepo.inclusionResolvers.set('customer', creditCardRepo.customer.inclusionResolver);
85
+ creditCardRepo.inclusionResolvers.set('cardInfo', creditCardRepo.cardInfo.inclusionResolver);
86
+ cashRepo.inclusionResolvers.set('customer', cashRepo.customer.inclusionResolver);
87
+ const paymentMethodRepo = {
88
+ // eslint-disable-next-line @typescript-eslint/naming-convention
89
+ CreditCard: async () => creditCardRepo,
90
+ // eslint-disable-next-line @typescript-eslint/naming-convention
91
+ Cash: async () => cashRepo,
92
+ };
93
+ const cardInfoRepoClass = (0, repositories_1.createCardInfoRepo)(repositoryClass);
94
+ const cardInfoRepo = new cardInfoRepoClass(db, async () => creditCardRepo);
95
+ cardInfoRepo.inclusionResolvers.set('creditCard', cardInfoRepo.creditCard.inclusionResolver);
64
96
  const cartItemRepoClass = (0, repositories_1.createCartItemRepo)(repositoryClass);
65
97
  const cartItemRepo = new cartItemRepoClass(db, async () => orderRepo);
66
98
  cartItemRepo.inclusionResolvers.set('order', cartItemRepo.order.inclusionResolver);
67
99
  const customerCartItemLinkRepoClass = (0, repositories_1.createCustomerCartItemLinkRepo)(repositoryClass);
68
100
  const customerCartItemLinkRepo = new customerCartItemLinkRepoClass(db);
101
+ const freeDeliveryRepoClass = (0, repositories_1.createFreeDeliveryRepo)(repositoryClass);
102
+ const freeDeliveryRepo = new freeDeliveryRepoClass(db);
103
+ const halfPriceRepoClass = (0, repositories_1.createHalfPriceRepo)(repositoryClass);
104
+ const halfPriceRepo = new halfPriceRepoClass(db);
105
+ const promotionRepo = {
106
+ // eslint-disable-next-line @typescript-eslint/naming-convention
107
+ FreeDelivery: async () => freeDeliveryRepo,
108
+ // eslint-disable-next-line @typescript-eslint/naming-convention
109
+ HalfPrice: async () => halfPriceRepo,
110
+ };
111
+ const customerPromotionLinkRepoClass = (0, repositories_1.createCustomerPromotionLinkRepo)(repositoryClass);
112
+ const customerPromotionLinkRepo = new customerPromotionLinkRepoClass(db);
69
113
  const userRepoClass = (0, repositories_1.createUserRepo)(repositoryClass);
70
114
  const userRepo = new userRepoClass(db, async () => userLinkRepo);
71
115
  const userLinkRepoClass = (0, repositories_1.createUserLinkRepo)(repositoryClass);
72
116
  const userLinkRepo = new userLinkRepoClass(db);
73
117
  userRepo.inclusionResolvers.set('users', userRepo.users.inclusionResolver);
118
+ const supplierRepoClass = (0, repositories_1.createSupplierRepo)(repositoryClass);
119
+ const supplierRepo = new supplierRepoClass(db, async () => contactRepo);
120
+ // get the repository class and create a new instance of it
121
+ const customerRepoClass = (0, repositories_1.createCustomerRepo)(repositoryClass);
122
+ const customerRepo = new customerRepoClass(db, async () => orderRepo, async () => addressRepo, async () => cartItemRepo, async () => customerCartItemLinkRepo, promotionRepo, async () => customerPromotionLinkRepo, paymentMethodRepo, async () => contactRepo);
123
+ const stakeholderRepo = {
124
+ // eslint-disable-next-line @typescript-eslint/naming-convention
125
+ Customer: async () => customerRepo,
126
+ // eslint-disable-next-line @typescript-eslint/naming-convention
127
+ Supplier: async () => supplierRepo,
128
+ };
129
+ const contactRepoClass = (0, repositories_1.createContactRepo)(repositoryClass);
130
+ const contactRepo = new contactRepoClass(db, stakeholderRepo);
131
+ contactRepo.inclusionResolvers.set('stakeholder', contactRepo.stakeholder.inclusionResolver);
132
+ // register the inclusionResolvers here for customerRepo
133
+ customerRepo.inclusionResolvers.set('orders', customerRepo.orders.inclusionResolver);
134
+ customerRepo.inclusionResolvers.set('customers', customerRepo.customers.inclusionResolver);
135
+ customerRepo.inclusionResolvers.set('address', customerRepo.address.inclusionResolver);
136
+ customerRepo.inclusionResolvers.set('cartItems', customerRepo.cartItems.inclusionResolver);
137
+ customerRepo.inclusionResolvers.set('promotions', customerRepo.promotions.inclusionResolver);
138
+ customerRepo.inclusionResolvers.set('paymentMethod', customerRepo.paymentMethod.inclusionResolver);
139
+ customerRepo.inclusionResolvers.set('contact', customerRepo.contact.inclusionResolver);
140
+ supplierRepo.inclusionResolvers.set('contact', supplierRepo.contact.inclusionResolver);
74
141
  return {
75
142
  customerRepo,
76
143
  orderRepo,
@@ -78,8 +145,16 @@ function givenBoundCrudRepositories(db, repositoryClass, features) {
78
145
  addressRepo,
79
146
  cartItemRepo,
80
147
  customerCartItemLinkRepo,
148
+ freeDeliveryRepo,
149
+ halfPriceRepo,
150
+ customerPromotionLinkRepo,
81
151
  userRepo,
82
152
  userLinkRepo,
153
+ creditCardRepo,
154
+ cashRepo,
155
+ contactRepo,
156
+ supplierRepo,
157
+ cardInfoRepo,
83
158
  };
84
159
  }
85
160
  exports.givenBoundCrudRepositories = givenBoundCrudRepositories;
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/crud/relations/helpers.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,0CAA0C;AAC1C,+CAA+C;AAC/C,gEAAgE;;;AAIhE,8CAiB2B;AAC3B,0DASiC;AAEjC,SAAgB,0BAA0B,CACxC,EAAsB,EACtB,eAAmC,EACnC,QAAsB;IAEtB,cAAK,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC;IACtD,gBAAO,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC;IACxD,iBAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC;IACzD,iBAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC;IACzD,6BAAoB,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC;IACrE,iBAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,GAAG,QAAQ,CAAC,MAAM,CAA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,aAAa,CAAC,iBAAiB,CAC7C,CAAC;IACF,YAAY,CAAC,kBAAkB,CAAC,GAAG,CACjC,SAAS,EACT,YAAY,CAAC,OAAO,CAAC,iBAAiB,CACvC,CAAC;IACF,YAAY,CAAC,kBAAkB,CAAC,GAAG,CACjC,SAAS,EACT,YAAY,CAAC,OAAO,CAAC,iBAAiB,CACvC,CAAC;IAEF,OAAO;QACL,YAAY;QACZ,SAAS;QACT,YAAY;QACZ,WAAW;QACX,YAAY;QACZ,wBAAwB;QACxB,gBAAgB;QAChB,aAAa;QACb,yBAAyB;QACzB,QAAQ;QACR,YAAY;QACZ,cAAc;QACd,QAAQ;QACR,WAAW;QACX,YAAY;QACZ,YAAY;KACb,CAAC;AACJ,CAAC;AAzRD,gEAyRC"}
@@ -20,7 +20,7 @@ export declare function withCrudCtx(fn: (context: CrudTestContext) => PromiseLik
20
20
  * Call this method from the first `before` hook of your test suite to avoid
21
21
  * conflicts when the same model name is used for different model classes.
22
22
  */
23
- export declare const deleteAllModelsInDefaultDataSource: Mocha.AsyncFunc | Mocha.Func;
23
+ export declare const deleteAllModelsInDefaultDataSource: Mocha.Func;
24
24
  /**
25
25
  * A union type between string and number to use since MongoDB and MySQL use
26
26
  * different id types.
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.repository-tests.js","sourceRoot":"","sources":["../src/helpers.repository-tests.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,0CAA0C;AAC1C,+CAA+C;AAC/C,gEAAgE;;;AAIhE;;;;GAIG;AACH,SAAgB,cAAc,CAAC,OAAsB;IACnD,OAAO,OAAqC,CAAC;AAC/C,CAAC;AAFD,wCAEC;AAED;;;;;GAKG;AACH,SAAgB,WAAW,CACzB,EAA6D;IAE7D,OAAO;QACL,OAAO,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC;AACJ,CAAC;AAND,kCAMC;AAED;;;;;;GAMG;AACU,QAAA,kCAAkC,GAAG,WAAW,CAAC,GAAG,CAAC,EAAE;IAClE,GAAG,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC;AACnC,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"helpers.repository-tests.js","sourceRoot":"","sources":["../src/helpers.repository-tests.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,0CAA0C;AAC1C,+CAA+C;AAC/C,gEAAgE;;;AAIhE;;;;GAIG;AACH,SAAgB,cAAc,CAAC,OAAsB;IACnD,OAAO,OAAqC,CAAC;AAC/C,CAAC;AAFD,wCAEC;AAED;;;;;GAKG;AACH,SAAgB,WAAW,CACzB,EAA6D;IAE7D,OAAO;QACL,OAAO,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC;AACJ,CAAC;AAND,kCAMC;AAED;;;;;;GAMG;AACU,QAAA,kCAAkC,GAAG,WAAW,CAAC,GAAG,CAAC,EAAE;IAClE,GAAG,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC;AACnC,CAAC,CAAe,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@loopback/repository-tests",
3
3
  "description": "A shared test suite to verify `@loopback/repository` functionality with a given compatible connector",
4
- "version": "0.20.2",
4
+ "version": "0.21.0",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -13,7 +13,7 @@
13
13
  "directory": "packages/repository-tests"
14
14
  },
15
15
  "engines": {
16
- "node": "12 || 14 || 16 || 17"
16
+ "node": "14 || 16 || 17 || 18"
17
17
  },
18
18
  "scripts": {
19
19
  "build": "lb-tsc",
@@ -32,23 +32,23 @@
32
32
  "!*/__tests__"
33
33
  ],
34
34
  "peerDependencies": {
35
- "@loopback/core": "^3.1.2",
36
- "@loopback/repository": "^4.1.2"
35
+ "@loopback/core": "^4.0.0",
36
+ "@loopback/repository": "^5.0.0"
37
37
  },
38
38
  "dependencies": {
39
- "@loopback/testlab": "^4.1.2",
39
+ "@loopback/testlab": "^5.0.0",
40
40
  "@types/debug": "^4.1.7",
41
41
  "debug": "^4.3.4",
42
- "tslib": "^2.3.1"
42
+ "tslib": "^2.4.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@loopback/build": "^8.1.2",
46
- "@loopback/core": "^3.1.2",
47
- "@loopback/repository": "^4.1.2",
45
+ "@loopback/build": "^9.0.0",
46
+ "@loopback/core": "^4.0.0",
47
+ "@loopback/repository": "^5.0.0",
48
48
  "@types/debug": "^4.1.7",
49
- "@types/lodash": "^4.14.180",
50
- "@types/node": "^12.20.47",
49
+ "@types/lodash": "^4.14.182",
50
+ "@types/node": "^12.20.50",
51
51
  "lodash": "^4.17.21"
52
52
  },
53
- "gitHead": "22d993c73a7b4ccdb36f2e26ea52460dc46fbd11"
53
+ "gitHead": "61453a3d7a16f9f37875a3f2c2a071568eb3e3af"
54
54
  }
@@ -0,0 +1,221 @@
1
+ // Copyright IBM Corp. 2019,2020. All Rights Reserved.
2
+ // Node module: @loopback/repository-tests
3
+ // This file is licensed under the MIT License.
4
+ // License text available at https://opensource.org/licenses/MIT
5
+
6
+ import {expect, skipIf, toJSON} from '@loopback/testlab';
7
+ import {Suite} from 'mocha';
8
+ import {
9
+ CrudFeatures,
10
+ CrudRepositoryCtor,
11
+ CrudTestContext,
12
+ DataSourceOptions,
13
+ } from '../../..';
14
+ import {
15
+ deleteAllModelsInDefaultDataSource,
16
+ withCrudCtx,
17
+ } from '../../../helpers.repository-tests';
18
+ import {
19
+ Contact,
20
+ ContactRepository,
21
+ Customer,
22
+ CustomerRepository,
23
+ Supplier,
24
+ SupplierRepository,
25
+ } from '../fixtures/models';
26
+ import {givenBoundCrudRepositories} from '../helpers';
27
+
28
+ export function belongsToInclusionResolverPolymorphicAcceptance(
29
+ dataSourceOptions: DataSourceOptions,
30
+ repositoryClass: CrudRepositoryCtor,
31
+ features: CrudFeatures,
32
+ ) {
33
+ skipIf<[(this: Suite) => void], void>(
34
+ !features.supportsInclusionResolvers,
35
+ describe,
36
+ 'BelongsTo inclusion resolvers - polymorphic - acceptance',
37
+ suite,
38
+ );
39
+ function suite() {
40
+ before(deleteAllModelsInDefaultDataSource);
41
+ let customerRepo: CustomerRepository;
42
+ let supplierRepo: SupplierRepository;
43
+ let contactRepo: ContactRepository;
44
+
45
+ before(
46
+ withCrudCtx(async function setupRepository(ctx: CrudTestContext) {
47
+ // this helper should create the inclusion resolvers and also
48
+ // register inclusion resolvers for us
49
+ ({customerRepo, supplierRepo, contactRepo} = givenBoundCrudRepositories(
50
+ ctx.dataSource,
51
+ repositoryClass,
52
+ features,
53
+ ));
54
+ expect(customerRepo.contact.inclusionResolver).to.be.Function();
55
+ expect(supplierRepo.contact.inclusionResolver).to.be.Function();
56
+ expect(contactRepo.stakeholder.inclusionResolver).to.be.Function();
57
+
58
+ await ctx.dataSource.automigrate([
59
+ Customer.name,
60
+ Supplier.name,
61
+ Contact.name,
62
+ ]);
63
+ }),
64
+ );
65
+
66
+ beforeEach(async () => {
67
+ await customerRepo.deleteAll();
68
+ await supplierRepo.deleteAll();
69
+ await contactRepo.deleteAll();
70
+ });
71
+
72
+ it('throws an error if it tries to query nonexistent relation names', async () => {
73
+ const customer = await customerRepo.create({name: 'customer'});
74
+ await contactRepo.create({
75
+ stakeholderId: customer.id,
76
+ });
77
+ await expect(
78
+ contactRepo.find({include: ['shipment']}),
79
+ ).to.be.rejectedWith(`Invalid "filter.include" entries: "shipment"`);
80
+ });
81
+
82
+ it('returns single model instance including single related instance', async () => {
83
+ const thor = await customerRepo.create({name: 'Thor'});
84
+ const contact = await contactRepo.create({
85
+ stakeholderId: thor.id,
86
+ });
87
+ const result = await contactRepo.find({
88
+ include: ['stakeholder'],
89
+ });
90
+
91
+ const expected = {
92
+ ...contact,
93
+ isShipped: features.emptyValue,
94
+ shipmentInfo: features.emptyValue,
95
+ stakeholder: {
96
+ ...thor,
97
+ parentId: features.emptyValue,
98
+ },
99
+ };
100
+ expect(toJSON(result)).to.deepEqual([toJSON(expected)]);
101
+ });
102
+
103
+ it('returns multiple model instances including related instances', async () => {
104
+ const thor = await customerRepo.create({
105
+ name: 'Thor',
106
+ paymentMethodType: 'CreditCard',
107
+ });
108
+ const odin = await supplierRepo.create({name: 'Odin'});
109
+ const thorContact = await contactRepo.create({
110
+ stakeholderId: thor.id,
111
+ });
112
+ const odinContact = await contactRepo.create({
113
+ stakeholderId: odin.id,
114
+ stakeholderType: 'Supplier',
115
+ });
116
+
117
+ const result = await contactRepo.find({
118
+ include: ['stakeholder'],
119
+ });
120
+
121
+ const expected = [
122
+ {
123
+ ...thorContact,
124
+ isShipped: features.emptyValue,
125
+ shipmentInfo: features.emptyValue,
126
+ stakeholder: {
127
+ ...thor,
128
+ parentId: features.emptyValue,
129
+ },
130
+ },
131
+ {
132
+ ...odinContact,
133
+ isShipped: features.emptyValue,
134
+ shipmentInfo: features.emptyValue,
135
+ stakeholder: {
136
+ ...odin,
137
+ parentId: features.emptyValue,
138
+ },
139
+ },
140
+ ];
141
+ expect(toJSON(result)).to.deepEqual(toJSON(expected));
142
+ });
143
+
144
+ it('returns a specified instance including its related model instances', async () => {
145
+ const thor = await customerRepo.create({name: 'Thor'});
146
+ const odin = await supplierRepo.create({name: 'Odin'});
147
+ const bella = await supplierRepo.create({name: 'Bella'});
148
+ await contactRepo.create({
149
+ stakeholderId: thor.id,
150
+ });
151
+ await contactRepo.create({
152
+ stakeholderId: bella.id,
153
+ stakeholderType: 'Supplier',
154
+ });
155
+ const odinContact = await contactRepo.create({
156
+ stakeholderId: odin.id,
157
+ stakeholderType: 'Supplier',
158
+ });
159
+
160
+ const result = await contactRepo.findById(odinContact.id, {
161
+ include: ['stakeholder'],
162
+ });
163
+ const expected = {
164
+ ...odinContact,
165
+ isShipped: features.emptyValue,
166
+ shipmentInfo: features.emptyValue,
167
+ stakeholder: {
168
+ ...odin,
169
+ parentId: features.emptyValue,
170
+ },
171
+ };
172
+ expect(toJSON(result)).to.deepEqual(toJSON(expected));
173
+ });
174
+
175
+ it('queries entities with null foreign key', async () => {
176
+ const customer = await customerRepo.create({
177
+ name: 'Thor',
178
+ });
179
+
180
+ const contact1 = await contactRepo.create({
181
+ stakeholderId: customer.id,
182
+ });
183
+
184
+ const contact2 = await contactRepo.create({});
185
+
186
+ const expected = [
187
+ {
188
+ ...contact1,
189
+ isShipped: features.emptyValue,
190
+ shipmentInfo: features.emptyValue,
191
+ stakeholder: {
192
+ ...customer,
193
+ parentId: features.emptyValue,
194
+ },
195
+ },
196
+ {
197
+ ...contact2,
198
+ stakeholderId: features.emptyValue,
199
+ isShipped: features.emptyValue,
200
+ shipmentInfo: features.emptyValue,
201
+ },
202
+ ];
203
+
204
+ const result = await contactRepo.find({include: ['stakeholder']});
205
+ expect(toJSON(result)).to.deepEqual(toJSON(expected));
206
+ });
207
+
208
+ it('throws error if the target repository does not have the registered resolver', async () => {
209
+ const customer = await customerRepo.create({name: 'customer'});
210
+ await contactRepo.create({
211
+ stakeholderId: customer.id,
212
+ });
213
+ // unregister the resolver
214
+ contactRepo.inclusionResolvers.delete('stakeholder');
215
+
216
+ await expect(
217
+ contactRepo.find({include: ['stakeholder']}),
218
+ ).to.be.rejectedWith(`Invalid "filter.include" entries: "stakeholder"`);
219
+ });
220
+ }
221
+ }