@loopback/repository-tests 0.20.0 → 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.
- package/dist/crud/create-retrieve.suite.js +8 -8
- package/dist/crud/freeform-properties.suite.js +6 -6
- package/dist/crud/nested-model-properties.suite.js +15 -15
- package/dist/crud/nested-model-properties.suite.js.map +1 -1
- package/dist/crud/relations/acceptance/belongs-to.inclusion-resolver.polymorphic.relation.acceptance.d.ts +2 -0
- package/dist/crud/relations/acceptance/belongs-to.inclusion-resolver.polymorphic.relation.acceptance.js +170 -0
- package/dist/crud/relations/acceptance/belongs-to.inclusion-resolver.polymorphic.relation.acceptance.js.map +1 -0
- package/dist/crud/relations/acceptance/belongs-to.polymorphic.relation.acceptance.d.ts +2 -0
- package/dist/crud/relations/acceptance/belongs-to.polymorphic.relation.acceptance.js +55 -0
- package/dist/crud/relations/acceptance/belongs-to.polymorphic.relation.acceptance.js.map +1 -0
- package/dist/crud/relations/acceptance/has-many-through-inclusion-resolver.polymorphic.acceptance.d.ts +2 -0
- package/dist/crud/relations/acceptance/has-many-through-inclusion-resolver.polymorphic.acceptance.js +170 -0
- package/dist/crud/relations/acceptance/has-many-through-inclusion-resolver.polymorphic.acceptance.js.map +1 -0
- package/dist/crud/relations/acceptance/has-many-through.relation.polymorphic.acceptance.d.ts +2 -0
- package/dist/crud/relations/acceptance/has-many-through.relation.polymorphic.acceptance.js +361 -0
- package/dist/crud/relations/acceptance/has-many-through.relation.polymorphic.acceptance.js.map +1 -0
- package/dist/crud/relations/acceptance/has-many.relation.acceptance.js +1 -1
- package/dist/crud/relations/acceptance/has-many.relation.acceptance.js.map +1 -1
- package/dist/crud/relations/acceptance/has-one.inclusion-resolver.polymorphic.acceptance.d.ts +2 -0
- package/dist/crud/relations/acceptance/has-one.inclusion-resolver.polymorphic.acceptance.js +161 -0
- package/dist/crud/relations/acceptance/has-one.inclusion-resolver.polymorphic.acceptance.js.map +1 -0
- package/dist/crud/relations/acceptance/has-one.relation.polymorphic.acceptance.d.ts +2 -0
- package/dist/crud/relations/acceptance/has-one.relation.polymorphic.acceptance.js +190 -0
- package/dist/crud/relations/acceptance/has-one.relation.polymorphic.acceptance.js.map +1 -0
- package/dist/crud/relations/fixtures/models/address.model.js +13 -13
- package/dist/crud/relations/fixtures/models/cart-item.model.js +7 -7
- package/dist/crud/relations/fixtures/models/contact.model.d.ts +18 -0
- package/dist/crud/relations/fixtures/models/contact.model.js +49 -0
- package/dist/crud/relations/fixtures/models/contact.model.js.map +1 -0
- package/dist/crud/relations/fixtures/models/customer-cart-item-link.model.js +9 -9
- package/dist/crud/relations/fixtures/models/customer-promotion-link.model.d.ts +14 -0
- package/dist/crud/relations/fixtures/models/customer-promotion-link.model.js +46 -0
- package/dist/crud/relations/fixtures/models/customer-promotion-link.model.js.map +1 -0
- package/dist/crud/relations/fixtures/models/customer.model.d.ts +16 -3
- package/dist/crud/relations/fixtures/models/customer.model.js +40 -22
- package/dist/crud/relations/fixtures/models/customer.model.js.map +1 -1
- package/dist/crud/relations/fixtures/models/index.d.ts +6 -0
- package/dist/crud/relations/fixtures/models/index.js +14 -8
- package/dist/crud/relations/fixtures/models/index.js.map +1 -1
- package/dist/crud/relations/fixtures/models/order.model.js +11 -11
- package/dist/crud/relations/fixtures/models/payment-method.model.d.ts +47 -0
- package/dist/crud/relations/fixtures/models/payment-method.model.js +87 -0
- package/dist/crud/relations/fixtures/models/payment-method.model.js.map +1 -0
- package/dist/crud/relations/fixtures/models/promotion.model.d.ts +27 -0
- package/dist/crud/relations/fixtures/models/promotion.model.js +54 -0
- package/dist/crud/relations/fixtures/models/promotion.model.js.map +1 -0
- package/dist/crud/relations/fixtures/models/shipment.model.js +10 -10
- package/dist/crud/relations/fixtures/models/stakeholder.model.d.ts +7 -0
- package/dist/crud/relations/fixtures/models/stakeholder.model.js +38 -0
- package/dist/crud/relations/fixtures/models/stakeholder.model.js.map +1 -0
- package/dist/crud/relations/fixtures/models/supplier.model.d.ts +15 -0
- package/dist/crud/relations/fixtures/models/supplier.model.js +23 -0
- package/dist/crud/relations/fixtures/models/supplier.model.js.map +1 -0
- package/dist/crud/relations/fixtures/models/user-link.model.js +9 -9
- package/dist/crud/relations/fixtures/models/user.model.js +7 -7
- package/dist/crud/relations/fixtures/repositories/contact.repository.d.ts +30 -0
- package/dist/crud/relations/fixtures/repositories/contact.repository.js +21 -0
- package/dist/crud/relations/fixtures/repositories/contact.repository.js.map +1 -0
- package/dist/crud/relations/fixtures/repositories/customer-promotion-link.repository.d.ts +26 -0
- package/dist/crud/relations/fixtures/repositories/customer-promotion-link.repository.js +18 -0
- package/dist/crud/relations/fixtures/repositories/customer-promotion-link.repository.js.map +1 -0
- package/dist/crud/relations/fixtures/repositories/customer.repository.d.ts +9 -2
- package/dist/crud/relations/fixtures/repositories/customer.repository.js +7 -1
- package/dist/crud/relations/fixtures/repositories/customer.repository.js.map +1 -1
- package/dist/crud/relations/fixtures/repositories/index.d.ts +6 -1
- package/dist/crud/relations/fixtures/repositories/index.js +13 -8
- package/dist/crud/relations/fixtures/repositories/index.js.map +1 -1
- package/dist/crud/relations/fixtures/repositories/payment-method.repository.d.ts +77 -0
- package/dist/crud/relations/fixtures/repositories/payment-method.repository.js +45 -0
- package/dist/crud/relations/fixtures/repositories/payment-method.repository.js.map +1 -0
- package/dist/crud/relations/fixtures/repositories/promotion.repository.d.ts +49 -0
- package/dist/crud/relations/fixtures/repositories/promotion.repository.js +25 -0
- package/dist/crud/relations/fixtures/repositories/promotion.repository.js.map +1 -0
- package/dist/crud/relations/fixtures/repositories/supplier.repository.d.ts +28 -0
- package/dist/crud/relations/fixtures/repositories/supplier.repository.js +21 -0
- package/dist/crud/relations/fixtures/repositories/supplier.repository.js.map +1 -0
- package/dist/crud/relations/helpers.d.ts +9 -1
- package/dist/crud/relations/helpers.js +85 -10
- package/dist/crud/relations/helpers.js.map +1 -1
- package/dist/crud/replace-by-id.suite.js +10 -10
- package/dist/crud/transactions.suite.js +6 -6
- package/dist/crud-test-suite.js +3 -3
- package/dist/crud-test-suite.js.map +1 -1
- package/dist/helpers.repository-tests.d.ts +1 -1
- package/dist/helpers.repository-tests.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +13 -13
- package/src/crud/relations/acceptance/belongs-to.inclusion-resolver.polymorphic.relation.acceptance.ts +221 -0
- package/src/crud/relations/acceptance/belongs-to.polymorphic.relation.acceptance.ts +88 -0
- package/src/crud/relations/acceptance/has-many-through-inclusion-resolver.polymorphic.acceptance.ts +255 -0
- package/src/crud/relations/acceptance/has-many-through.relation.polymorphic.acceptance.ts +494 -0
- package/src/crud/relations/acceptance/has-one.inclusion-resolver.polymorphic.acceptance.ts +208 -0
- package/src/crud/relations/acceptance/has-one.relation.polymorphic.acceptance.ts +328 -0
- package/src/crud/relations/fixtures/models/contact.model.ts +56 -0
- package/src/crud/relations/fixtures/models/customer-promotion-link.model.ts +52 -0
- package/src/crud/relations/fixtures/models/customer.model.ts +39 -9
- package/src/crud/relations/fixtures/models/index.ts +6 -0
- package/src/crud/relations/fixtures/models/payment-method.model.ts +118 -0
- package/src/crud/relations/fixtures/models/promotion.model.ts +67 -0
- package/src/crud/relations/fixtures/models/stakeholder.model.ts +33 -0
- package/src/crud/relations/fixtures/models/supplier.model.ts +35 -0
- package/src/crud/relations/fixtures/repositories/contact.repository.ts +44 -0
- package/src/crud/relations/fixtures/repositories/customer-promotion-link.repository.ts +20 -0
- package/src/crud/relations/fixtures/repositories/customer.repository.ts +47 -0
- package/src/crud/relations/fixtures/repositories/index.ts +6 -1
- package/src/crud/relations/fixtures/repositories/payment-method.repository.ts +118 -0
- package/src/crud/relations/fixtures/repositories/promotion.repository.ts +37 -0
- package/src/crud/relations/fixtures/repositories/supplier.repository.ts +40 -0
- package/src/crud/relations/helpers.ts +200 -30
- package/src/helpers.repository-tests.ts +1 -1
|
@@ -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,
|
|
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,8CAiC2B;AAC3B,0DAiBiC;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,gBAAO,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC;IACxD,mBAAU,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC3D,iBAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC;IACzD,aAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC;IACrD,iBAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC;IACzD,6BAAoB,CAAC,UAAU,CAAC,UAAU,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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"}
|
|
@@ -16,7 +16,7 @@ function createSuiteForReplaceById(dataSourceOptions, repositoryClass, features)
|
|
|
16
16
|
super(data);
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
-
|
|
19
|
+
tslib_1.__decorate([
|
|
20
20
|
(0, repository_1.property)({
|
|
21
21
|
type: features.idType,
|
|
22
22
|
id: true,
|
|
@@ -24,23 +24,23 @@ function createSuiteForReplaceById(dataSourceOptions, repositoryClass, features)
|
|
|
24
24
|
useDefaultIdType: true,
|
|
25
25
|
description: 'The unique identifier for a product',
|
|
26
26
|
}),
|
|
27
|
-
|
|
27
|
+
tslib_1.__metadata("design:type", Object)
|
|
28
28
|
], Product.prototype, "id", void 0);
|
|
29
|
-
|
|
29
|
+
tslib_1.__decorate([
|
|
30
30
|
(0, repository_1.property)({ type: 'string', required: false }),
|
|
31
|
-
|
|
31
|
+
tslib_1.__metadata("design:type", String)
|
|
32
32
|
], Product.prototype, "_rev", void 0);
|
|
33
|
-
|
|
33
|
+
tslib_1.__decorate([
|
|
34
34
|
(0, repository_1.property)({ type: 'string', required: true }),
|
|
35
|
-
|
|
35
|
+
tslib_1.__metadata("design:type", String)
|
|
36
36
|
], Product.prototype, "name", void 0);
|
|
37
|
-
|
|
37
|
+
tslib_1.__decorate([
|
|
38
38
|
(0, repository_1.property)({ type: 'string', required: false }),
|
|
39
|
-
|
|
39
|
+
tslib_1.__metadata("design:type", String)
|
|
40
40
|
], Product.prototype, "description", void 0);
|
|
41
|
-
Product =
|
|
41
|
+
Product = tslib_1.__decorate([
|
|
42
42
|
(0, repository_1.model)(),
|
|
43
|
-
|
|
43
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
44
44
|
], Product);
|
|
45
45
|
describe('replaceById', () => {
|
|
46
46
|
before(helpers_repository_tests_1.deleteAllModelsInDefaultDataSource);
|
|
@@ -19,22 +19,22 @@ function transactionSuite(dataSourceOptions, repositoryClass, connectorFeatures)
|
|
|
19
19
|
super(data);
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
tslib_1.__decorate([
|
|
23
23
|
(0, repository_1.property)({
|
|
24
24
|
type: connectorFeatures.idType,
|
|
25
25
|
id: true,
|
|
26
26
|
generated: true,
|
|
27
27
|
description: 'The unique identifier for a product',
|
|
28
28
|
}),
|
|
29
|
-
|
|
29
|
+
tslib_1.__metadata("design:type", Object)
|
|
30
30
|
], Product.prototype, "id", void 0);
|
|
31
|
-
|
|
31
|
+
tslib_1.__decorate([
|
|
32
32
|
(0, repository_1.property)({ type: 'string', required: true }),
|
|
33
|
-
|
|
33
|
+
tslib_1.__metadata("design:type", String)
|
|
34
34
|
], Product.prototype, "name", void 0);
|
|
35
|
-
Product =
|
|
35
|
+
Product = tslib_1.__decorate([
|
|
36
36
|
(0, repository_1.model)(),
|
|
37
|
-
|
|
37
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
38
38
|
], Product);
|
|
39
39
|
describe('create-retrieve with transactions', () => {
|
|
40
40
|
let repo;
|
package/dist/crud-test-suite.js
CHANGED
|
@@ -7,9 +7,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
exports.crudRepositoryTestSuite = void 0;
|
|
8
8
|
const tslib_1 = require("tslib");
|
|
9
9
|
const repository_1 = require("@loopback/repository");
|
|
10
|
-
const debug_1 =
|
|
11
|
-
const fs_1 =
|
|
12
|
-
const path_1 =
|
|
10
|
+
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
11
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
12
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
13
13
|
const helpers_repository_tests_1 = require("./helpers.repository-tests");
|
|
14
14
|
const debug = (0, debug_1.default)('loopback:repository-tests');
|
|
15
15
|
function crudRepositoryTestSuite(dataSourceOptions, repositoryClass, partialFeatures) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crud-test-suite.js","sourceRoot":"","sources":["../src/crud-test-suite.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,0CAA0C;AAC1C,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,qDAA6C;AAC7C
|
|
1
|
+
{"version":3,"file":"crud-test-suite.js","sourceRoot":"","sources":["../src/crud-test-suite.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,0CAA0C;AAC1C,+CAA+C;AAC/C,gEAAgE;;;;AAEhE,qDAA6C;AAC7C,0DAAiC;AACjC,oDAAoB;AACpB,wDAAwB;AACxB,yEAAuD;AAQvD,MAAM,KAAK,GAAG,IAAA,eAAY,EAAC,2BAA2B,CAAC,CAAC;AAQxD,SAAgB,uBAAuB,CACrC,iBAAoC,EACpC,eAAmC,EACnC,eAAsC;IAEtC,MAAM,QAAQ,GAAiB;QAC7B,MAAM,EAAE,QAAQ;QAChB,kBAAkB,EAAE,IAAI;QACxB,UAAU,EAAE,SAAS;QACrB,oBAAoB,EAAE,IAAI;QAC1B,0BAA0B,EAAE,IAAI;QAChC,gBAAgB,EAAE,KAAK;QACvB,GAAG,eAAe;KACnB,CAAC;IAEF,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;QAC1C,MAAM,CACJ,IAAA,sCAAW,EAAC,SAAS,YAAY,CAA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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.
|
|
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,
|
|
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/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ const tslib_1 = require("tslib");
|
|
|
16
16
|
*
|
|
17
17
|
* @packageDocumentation
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
tslib_1.__exportStar(require("./crud-test-suite"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./types.repository-tests"), exports);
|
|
21
21
|
// TODO(bajtos) Implement test suite for KeyValue repository
|
|
22
22
|
//# 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,0CAA0C;AAC1C,+CAA+C;AAC/C,gEAAgE;;;AAEhE;;;;;;;;;;GAUG;AAEH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,0CAA0C;AAC1C,+CAA+C;AAC/C,gEAAgE;;;AAEhE;;;;;;;;;;GAUG;AAEH,4DAAkC;AAClC,mEAAyC;AAEzC,4DAA4D"}
|
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.
|
|
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": "
|
|
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": "^
|
|
36
|
-
"@loopback/repository": "^
|
|
35
|
+
"@loopback/core": "^4.0.0",
|
|
36
|
+
"@loopback/repository": "^5.0.0"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@loopback/testlab": "^
|
|
39
|
+
"@loopback/testlab": "^5.0.0",
|
|
40
40
|
"@types/debug": "^4.1.7",
|
|
41
|
-
"debug": "^4.3.
|
|
42
|
-
"tslib": "^2.
|
|
41
|
+
"debug": "^4.3.4",
|
|
42
|
+
"tslib": "^2.4.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@loopback/build": "^
|
|
46
|
-
"@loopback/core": "^
|
|
47
|
-
"@loopback/repository": "^
|
|
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.
|
|
50
|
-
"@types/node": "^12.20.
|
|
49
|
+
"@types/lodash": "^4.14.182",
|
|
50
|
+
"@types/node": "^12.20.50",
|
|
51
51
|
"lodash": "^4.17.21"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
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
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
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, toJSON} from '@loopback/testlab';
|
|
7
|
+
import {
|
|
8
|
+
deleteAllModelsInDefaultDataSource,
|
|
9
|
+
withCrudCtx,
|
|
10
|
+
} from '../../../helpers.repository-tests';
|
|
11
|
+
import {
|
|
12
|
+
CrudFeatures,
|
|
13
|
+
CrudRepositoryCtor,
|
|
14
|
+
CrudTestContext,
|
|
15
|
+
DataSourceOptions,
|
|
16
|
+
} from '../../../types.repository-tests';
|
|
17
|
+
import {
|
|
18
|
+
Contact,
|
|
19
|
+
ContactRepository,
|
|
20
|
+
Customer,
|
|
21
|
+
CustomerRepository,
|
|
22
|
+
Supplier,
|
|
23
|
+
SupplierRepository,
|
|
24
|
+
} from '../fixtures/models';
|
|
25
|
+
import {givenBoundCrudRepositories} from '../helpers';
|
|
26
|
+
|
|
27
|
+
export function belongsToRelationPolymorphicAcceptance(
|
|
28
|
+
dataSourceOptions: DataSourceOptions,
|
|
29
|
+
repositoryClass: CrudRepositoryCtor,
|
|
30
|
+
features: CrudFeatures,
|
|
31
|
+
) {
|
|
32
|
+
describe('BelongsTo relation (acceptance)', () => {
|
|
33
|
+
before(deleteAllModelsInDefaultDataSource);
|
|
34
|
+
|
|
35
|
+
let customerRepo: CustomerRepository;
|
|
36
|
+
let supplierRepo: SupplierRepository;
|
|
37
|
+
let contactRepo: ContactRepository;
|
|
38
|
+
|
|
39
|
+
before(
|
|
40
|
+
withCrudCtx(async function setupRepository(ctx: CrudTestContext) {
|
|
41
|
+
({customerRepo, supplierRepo, contactRepo} = givenBoundCrudRepositories(
|
|
42
|
+
ctx.dataSource,
|
|
43
|
+
repositoryClass,
|
|
44
|
+
features,
|
|
45
|
+
));
|
|
46
|
+
const models = [Customer, Supplier, Contact];
|
|
47
|
+
await ctx.dataSource.automigrate(models.map(m => m.name));
|
|
48
|
+
}),
|
|
49
|
+
);
|
|
50
|
+
beforeEach(async () => {
|
|
51
|
+
await contactRepo.deleteAll();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('can find customer from contact', async () => {
|
|
55
|
+
const customer = await customerRepo.create({
|
|
56
|
+
name: 'McForder customer',
|
|
57
|
+
});
|
|
58
|
+
const contact = await contactRepo.create({
|
|
59
|
+
stakeholderId: customer.id,
|
|
60
|
+
stakeholderType: 'Customer',
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const result = await contactRepo.stakeholder(contact.id, 'Customer');
|
|
64
|
+
// adding parentId to customer so MySQL doesn't complain about null vs
|
|
65
|
+
// undefined
|
|
66
|
+
expect(toJSON(result)).to.deepEqual(
|
|
67
|
+
toJSON({...customer, parentId: features.emptyValue}),
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('can find supplier from contact', async () => {
|
|
72
|
+
const supplier = await supplierRepo.create({
|
|
73
|
+
name: 'McForder supplier',
|
|
74
|
+
});
|
|
75
|
+
const contact = await contactRepo.create({
|
|
76
|
+
stakeholderId: supplier.id,
|
|
77
|
+
stakeholderType: 'Supplier',
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const result = await contactRepo.stakeholder(contact.id, 'Supplier');
|
|
81
|
+
// adding parentId to customer so MySQL doesn't complain about null vs
|
|
82
|
+
// undefined
|
|
83
|
+
expect(toJSON(result)).to.deepEqual(
|
|
84
|
+
toJSON({...supplier, parentId: features.emptyValue}),
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|