@mavenmachines/event-handler-lib 1.5.0-fix-1 → 1.5.0-rc.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/README.md +1 -271
- package/dist/config/default.d.ts +0 -6
- package/dist/config/default.js +0 -6
- package/dist/config/default.js.map +1 -1
- package/dist/package.json +2 -4
- package/dist/src/app.module.d.ts +2 -2
- package/dist/src/app.module.js +2 -2
- package/dist/src/app.module.js.map +1 -1
- package/dist/src/clients/openSearch/errors.d.ts +0 -2
- package/dist/src/clients/openSearch/errors.js +1 -4
- package/dist/src/clients/openSearch/errors.js.map +1 -1
- package/dist/src/clients/openSearch/mappings.d.ts +2 -6
- package/dist/src/clients/openSearch/mappings.js +2 -25
- package/dist/src/clients/openSearch/mappings.js.map +1 -1
- package/dist/src/clients/openSearch/openSearchClient.d.ts +3 -22
- package/dist/src/clients/openSearch/openSearchClient.js +60 -267
- package/dist/src/clients/openSearch/openSearchClient.js.map +1 -1
- package/dist/src/configs/inversifyConfig.d.ts +0 -1
- package/dist/src/configs/inversifyConfig.js +3 -20
- package/dist/src/configs/inversifyConfig.js.map +1 -1
- package/dist/src/{handlers/commandHandlers → eventHandlers}/baseCommandHandler.d.ts +19 -19
- package/dist/src/{handlers/commandHandlers → eventHandlers}/baseCommandHandler.js +7 -7
- package/dist/src/eventHandlers/baseCommandHandler.js.map +1 -0
- package/dist/src/{handlers/eventHandlers → eventHandlers}/baseEventHandler.d.ts +18 -18
- package/dist/src/{handlers/eventHandlers → eventHandlers}/baseEventHandler.js +3 -3
- package/dist/src/eventHandlers/baseEventHandler.js.map +1 -0
- package/dist/src/{handlers → eventHandlers}/baseHandler.d.ts +3 -3
- package/dist/src/{handlers → eventHandlers}/baseHandler.js +5 -2
- package/dist/src/eventHandlers/baseHandler.js.map +1 -0
- package/dist/src/{handlers/commandHandlers → eventHandlers}/commandHandlingModule.d.ts +3 -3
- package/dist/src/{handlers/commandHandlers → eventHandlers}/commandHandlingModule.js +3 -3
- package/dist/src/eventHandlers/commandHandlingModule.js.map +1 -0
- package/dist/src/{handlers/eventHandlers → eventHandlers}/eventHandlingModule.d.ts +7 -7
- package/dist/src/{handlers/eventHandlers → eventHandlers}/eventHandlingModule.js +8 -8
- package/dist/src/eventHandlers/eventHandlingModule.js.map +1 -0
- package/dist/src/{handlers/eventHandlers → eventHandlers}/syncFirestoreEvents.d.ts +3 -3
- package/dist/src/{handlers/eventHandlers → eventHandlers}/syncFirestoreEvents.js +3 -3
- package/dist/src/eventHandlers/syncFirestoreEvents.js.map +1 -0
- package/dist/src/exports/clients.d.ts +0 -1
- package/dist/src/exports/clients.js +1 -3
- package/dist/src/exports/clients.js.map +1 -1
- package/dist/src/exports/services.d.ts +2 -2
- package/dist/src/exports/services.js +2 -2
- package/dist/src/exports/services.js.map +1 -1
- package/dist/src/exports/sourcing.d.ts +3 -4
- package/dist/src/exports/sourcing.js +3 -18
- package/dist/src/exports/sourcing.js.map +1 -1
- package/dist/src/exports/utils.d.ts +0 -2
- package/dist/src/exports/utils.js +0 -2
- package/dist/src/exports/utils.js.map +1 -1
- package/dist/src/helpers/classConverter.d.ts +1 -0
- package/dist/src/helpers/classConverter.js +18 -0
- package/dist/src/helpers/classConverter.js.map +1 -1
- package/dist/src/helpers/dataStructure.helpers.d.ts +0 -2
- package/dist/src/helpers/dataStructure.helpers.js +0 -33
- package/dist/src/helpers/dataStructure.helpers.js.map +1 -1
- package/dist/src/initializers/logger.service.d.ts +0 -4
- package/dist/src/initializers/logger.service.js +0 -14
- package/dist/src/initializers/logger.service.js.map +1 -1
- package/dist/src/initializers/queue-manager.service.d.ts +1 -1
- package/dist/src/initializers/queue-manager.service.js +0 -1
- package/dist/src/initializers/queue-manager.service.js.map +1 -1
- package/dist/src/repositories/projectionRepository.d.ts +8 -4
- package/dist/src/repositories/projectionRepository.js +30 -13
- package/dist/src/repositories/projectionRepository.js.map +1 -1
- package/dist/src/rpc/rpcModule.js +1 -4
- package/dist/src/rpc/rpcModule.js.map +1 -1
- package/dist/src/testUtils/testDependencies.d.ts +2 -1
- package/dist/src/testUtils/testDependencies.js +13 -10
- package/dist/src/testUtils/testDependencies.js.map +1 -1
- package/dist/test/testImplementations/testCommandHandler.d.ts +1 -1
- package/dist/test/testImplementations/testCommandHandler.js +1 -1
- package/dist/test/testImplementations/testCommandHandler.js.map +1 -1
- package/dist/test/testImplementations/testEventHandler.d.ts +10 -3
- package/dist/test/testImplementations/testEventHandler.js +32 -4
- package/dist/test/testImplementations/testEventHandler.js.map +1 -1
- package/dist/test/testImplementations/testFirestoreEventSync.js +1 -1
- package/dist/test/testImplementations/testFirestoreEventSync.js.map +1 -1
- package/dist/test/tests/clients/opensearch.client.spec.js +72 -1
- package/dist/test/tests/clients/opensearch.client.spec.js.map +1 -1
- package/dist/test/tests/common.js +5 -3
- package/dist/test/tests/common.js.map +1 -1
- package/dist/test/tests/eventHandlers/baseEventHandler.spec.js +19 -6
- package/dist/test/tests/eventHandlers/baseEventHandler.spec.js.map +1 -1
- package/dist/test/tests/eventHandlers/firestoreEventSyncHandler.spec.js +16 -6
- package/dist/test/tests/eventHandlers/firestoreEventSyncHandler.spec.js.map +1 -1
- package/dist/test/tests/helpers/classConverter.spec.js +21 -0
- package/dist/test/tests/helpers/classConverter.spec.js.map +1 -1
- package/dist/test/tests/helpers/syncOpensearch.spec.js +43 -0
- package/dist/test/tests/helpers/syncOpensearch.spec.js.map +1 -1
- package/dist/test/tests/repositories/projectionRepository.spec.js +4 -3
- package/dist/test/tests/repositories/projectionRepository.spec.js.map +1 -1
- package/package.json +2 -4
- package/dist/src/handlers/baseHandler.js.map +0 -1
- package/dist/src/handlers/commandHandlers/baseCommandHandler.js.map +0 -1
- package/dist/src/handlers/commandHandlers/commandHandlingModule.js.map +0 -1
- package/dist/src/handlers/crud/baseHandlers.d.ts +0 -21
- package/dist/src/handlers/crud/baseHandlers.js +0 -90
- package/dist/src/handlers/crud/baseHandlers.js.map +0 -1
- package/dist/src/handlers/crud/createProjectionHandler.d.ts +0 -9
- package/dist/src/handlers/crud/createProjectionHandler.js +0 -37
- package/dist/src/handlers/crud/createProjectionHandler.js.map +0 -1
- package/dist/src/handlers/crud/createUpdateProjectionHandler.d.ts +0 -10
- package/dist/src/handlers/crud/createUpdateProjectionHandler.js +0 -40
- package/dist/src/handlers/crud/createUpdateProjectionHandler.js.map +0 -1
- package/dist/src/handlers/crud/decorators.d.ts +0 -4
- package/dist/src/handlers/crud/decorators.js +0 -9
- package/dist/src/handlers/crud/decorators.js.map +0 -1
- package/dist/src/handlers/crud/deleteProjectionHandler.d.ts +0 -9
- package/dist/src/handlers/crud/deleteProjectionHandler.js +0 -43
- package/dist/src/handlers/crud/deleteProjectionHandler.js.map +0 -1
- package/dist/src/handlers/crud/getProjectionHandler.d.ts +0 -11
- package/dist/src/handlers/crud/getProjectionHandler.js +0 -30
- package/dist/src/handlers/crud/getProjectionHandler.js.map +0 -1
- package/dist/src/handlers/crud/getProjectionsHandler.d.ts +0 -10
- package/dist/src/handlers/crud/getProjectionsHandler.js +0 -57
- package/dist/src/handlers/crud/getProjectionsHandler.js.map +0 -1
- package/dist/src/handlers/crud/helpers.d.ts +0 -22
- package/dist/src/handlers/crud/helpers.js +0 -179
- package/dist/src/handlers/crud/helpers.js.map +0 -1
- package/dist/src/handlers/crud/index.d.ts +0 -31
- package/dist/src/handlers/crud/index.js +0 -88
- package/dist/src/handlers/crud/index.js.map +0 -1
- package/dist/src/handlers/crud/searchProjectionsHandler.d.ts +0 -8
- package/dist/src/handlers/crud/searchProjectionsHandler.js +0 -162
- package/dist/src/handlers/crud/searchProjectionsHandler.js.map +0 -1
- package/dist/src/handlers/crud/types.d.ts +0 -46
- package/dist/src/handlers/crud/types.js +0 -42
- package/dist/src/handlers/crud/types.js.map +0 -1
- package/dist/src/handlers/eventHandlers/baseEventHandler.js.map +0 -1
- package/dist/src/handlers/eventHandlers/eventHandlingModule.js.map +0 -1
- package/dist/src/handlers/eventHandlers/syncFirestoreEvents.js.map +0 -1
- package/dist/src/helpers/string.helpers.d.ts +0 -3
- package/dist/src/helpers/string.helpers.js +0 -24
- package/dist/src/helpers/string.helpers.js.map +0 -1
- package/dist/src/helpers/typeManipulation/classValidation.d.ts +0 -7
- package/dist/src/helpers/typeManipulation/classValidation.js +0 -30
- package/dist/src/helpers/typeManipulation/classValidation.js.map +0 -1
- package/dist/src/helpers/typeManipulation/decorators.d.ts +0 -18
- package/dist/src/helpers/typeManipulation/decorators.js +0 -86
- package/dist/src/helpers/typeManipulation/decorators.js.map +0 -1
- package/dist/src/helpers/typeManipulation/dynamicClasses.d.ts +0 -8
- package/dist/src/helpers/typeManipulation/dynamicClasses.js +0 -27
- package/dist/src/helpers/typeManipulation/dynamicClasses.js.map +0 -1
- package/dist/src/helpers/typeManipulation/index.d.ts +0 -3
- package/dist/src/helpers/typeManipulation/index.js +0 -20
- package/dist/src/helpers/typeManipulation/index.js.map +0 -1
- package/dist/src/testUtils/mocks/openSearch.client.mock.d.ts +0 -102
- package/dist/src/testUtils/mocks/openSearch.client.mock.js +0 -405
- package/dist/src/testUtils/mocks/openSearch.client.mock.js.map +0 -1
- package/dist/test/testImplementations/testCrud.d.ts +0 -22
- package/dist/test/testImplementations/testCrud.js +0 -123
- package/dist/test/testImplementations/testCrud.js.map +0 -1
- package/dist/test/tests/eventHandlers/crudHandlers.spec.d.ts +0 -1
- package/dist/test/tests/eventHandlers/crudHandlers.spec.js +0 -555
- package/dist/test/tests/eventHandlers/crudHandlers.spec.js.map +0 -1
- package/dist/test/tests/helpers/decorators.spec.d.ts +0 -1
- package/dist/test/tests/helpers/decorators.spec.js +0 -109
- package/dist/test/tests/helpers/decorators.spec.js.map +0 -1
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.exampleProjection = exports.ExampleProjection = exports.exampleObject = exports.ExampleObject = void 0;
|
|
13
|
-
const class_validator_1 = require("class-validator");
|
|
14
|
-
const decorators_1 = require("../../src/handlers/crud/decorators");
|
|
15
|
-
const class_transformer_1 = require("class-transformer");
|
|
16
|
-
const crypto_1 = require("crypto");
|
|
17
|
-
const types_1 = require("../../src/handlers/crud/types");
|
|
18
|
-
class ExampleObject {
|
|
19
|
-
}
|
|
20
|
-
exports.ExampleObject = ExampleObject;
|
|
21
|
-
__decorate([
|
|
22
|
-
(0, decorators_1.IsEditable)(),
|
|
23
|
-
(0, class_validator_1.IsNumber)(),
|
|
24
|
-
(0, class_validator_1.IsOptional)(),
|
|
25
|
-
__metadata("design:type", Number)
|
|
26
|
-
], ExampleObject.prototype, "optionalEditableNumber", void 0);
|
|
27
|
-
__decorate([
|
|
28
|
-
(0, decorators_1.IsEditable)(),
|
|
29
|
-
(0, class_validator_1.IsString)(),
|
|
30
|
-
(0, decorators_1.IsSearchable)(),
|
|
31
|
-
(0, class_validator_1.IsOptional)(),
|
|
32
|
-
__metadata("design:type", String)
|
|
33
|
-
], ExampleObject.prototype, "optionalEditableString", void 0);
|
|
34
|
-
__decorate([
|
|
35
|
-
(0, decorators_1.IsEditable)(),
|
|
36
|
-
(0, decorators_1.IsSearchable)(),
|
|
37
|
-
(0, class_validator_1.IsString)(),
|
|
38
|
-
__metadata("design:type", String)
|
|
39
|
-
], ExampleObject.prototype, "mandatoryEditableString", void 0);
|
|
40
|
-
__decorate([
|
|
41
|
-
(0, decorators_1.IsEditable)(),
|
|
42
|
-
(0, class_validator_1.IsNumber)(),
|
|
43
|
-
(0, decorators_1.IsSearchable)(),
|
|
44
|
-
__metadata("design:type", Number)
|
|
45
|
-
], ExampleObject.prototype, "mandatoryEditableNumber", void 0);
|
|
46
|
-
__decorate([
|
|
47
|
-
(0, class_validator_1.IsOptional)(),
|
|
48
|
-
(0, class_validator_1.IsString)(),
|
|
49
|
-
__metadata("design:type", String)
|
|
50
|
-
], ExampleObject.prototype, "optionalString", void 0);
|
|
51
|
-
__decorate([
|
|
52
|
-
(0, class_validator_1.IsOptional)(),
|
|
53
|
-
(0, class_validator_1.IsNumber)(),
|
|
54
|
-
__metadata("design:type", Number)
|
|
55
|
-
], ExampleObject.prototype, "optionalNumber", void 0);
|
|
56
|
-
__decorate([
|
|
57
|
-
(0, class_validator_1.IsString)(),
|
|
58
|
-
__metadata("design:type", String)
|
|
59
|
-
], ExampleObject.prototype, "mandatoryString", void 0);
|
|
60
|
-
__decorate([
|
|
61
|
-
(0, class_validator_1.IsNumber)(),
|
|
62
|
-
__metadata("design:type", Number)
|
|
63
|
-
], ExampleObject.prototype, "mandatoryNumber", void 0);
|
|
64
|
-
exports.exampleObject = {
|
|
65
|
-
mandatoryEditableNumber: 1,
|
|
66
|
-
mandatoryEditableString: "a",
|
|
67
|
-
mandatoryNumber: 2,
|
|
68
|
-
mandatoryString: "b",
|
|
69
|
-
};
|
|
70
|
-
let ExampleProjection = class ExampleProjection extends ExampleObject {
|
|
71
|
-
};
|
|
72
|
-
exports.ExampleProjection = ExampleProjection;
|
|
73
|
-
__decorate([
|
|
74
|
-
(0, class_validator_1.IsString)(),
|
|
75
|
-
__metadata("design:type", String)
|
|
76
|
-
], ExampleProjection.prototype, "id", void 0);
|
|
77
|
-
__decorate([
|
|
78
|
-
(0, class_validator_1.IsOptional)(),
|
|
79
|
-
(0, decorators_1.IsEditable)(),
|
|
80
|
-
(0, class_validator_1.ValidateNested)(),
|
|
81
|
-
(0, class_transformer_1.Type)(() => ExampleObject),
|
|
82
|
-
__metadata("design:type", ExampleObject)
|
|
83
|
-
], ExampleProjection.prototype, "optionalEditableObject", void 0);
|
|
84
|
-
__decorate([
|
|
85
|
-
(0, class_validator_1.IsOptional)(),
|
|
86
|
-
(0, class_validator_1.ValidateNested)(),
|
|
87
|
-
(0, class_transformer_1.Type)(() => ExampleObject),
|
|
88
|
-
__metadata("design:type", ExampleObject)
|
|
89
|
-
], ExampleProjection.prototype, "optionalObject", void 0);
|
|
90
|
-
__decorate([
|
|
91
|
-
(0, class_validator_1.IsOptional)(),
|
|
92
|
-
(0, decorators_1.IsSearchable)(),
|
|
93
|
-
(0, class_validator_1.IsLatLong)(),
|
|
94
|
-
__metadata("design:type", String)
|
|
95
|
-
], ExampleProjection.prototype, "latLon", void 0);
|
|
96
|
-
__decorate([
|
|
97
|
-
(0, class_validator_1.ValidateNested)(),
|
|
98
|
-
(0, class_validator_1.IsOptional)(),
|
|
99
|
-
(0, decorators_1.IsSearchable)("geopoint"),
|
|
100
|
-
(0, class_transformer_1.Type)(() => types_1.LatLon),
|
|
101
|
-
__metadata("design:type", types_1.LatLon)
|
|
102
|
-
], ExampleProjection.prototype, "latLonObject", void 0);
|
|
103
|
-
__decorate([
|
|
104
|
-
(0, decorators_1.IsEditable)(),
|
|
105
|
-
(0, class_validator_1.ValidateNested)(),
|
|
106
|
-
(0, class_transformer_1.Type)(() => ExampleObject),
|
|
107
|
-
__metadata("design:type", ExampleObject)
|
|
108
|
-
], ExampleProjection.prototype, "mandatoryEditableObject", void 0);
|
|
109
|
-
__decorate([
|
|
110
|
-
(0, class_validator_1.ValidateNested)(),
|
|
111
|
-
(0, class_transformer_1.Type)(() => ExampleObject),
|
|
112
|
-
__metadata("design:type", ExampleObject)
|
|
113
|
-
], ExampleProjection.prototype, "mandatoryObject", void 0);
|
|
114
|
-
exports.ExampleProjection = ExampleProjection = __decorate([
|
|
115
|
-
(0, decorators_1.ProjectionType)("exampleProjection")
|
|
116
|
-
], ExampleProjection);
|
|
117
|
-
exports.exampleProjection = {
|
|
118
|
-
id: (0, crypto_1.randomUUID)(),
|
|
119
|
-
...exports.exampleObject,
|
|
120
|
-
mandatoryEditableObject: exports.exampleObject,
|
|
121
|
-
mandatoryObject: exports.exampleObject,
|
|
122
|
-
};
|
|
123
|
-
//# sourceMappingURL=testCrud.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"testCrud.js","sourceRoot":"","sources":["../../../test/testImplementations/testCrud.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAMyB;AACzB,mEAI4C;AAC5C,yDAAyC;AACzC,mCAAoC;AACpC,yDAAuD;AAEvD,MAAa,aAAa;CAmCzB;AAnCD,sCAmCC;AA/BC;IAHC,IAAA,uBAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;6DACmB;AAMhC;IAJC,IAAA,uBAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,yBAAY,GAAE;IACd,IAAA,4BAAU,GAAE;;6DACmB;AAKhC;IAHC,IAAA,uBAAU,GAAE;IACZ,IAAA,yBAAY,GAAE;IACd,IAAA,0BAAQ,GAAE;;8DACsB;AAKjC;IAHC,IAAA,uBAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;IACV,IAAA,yBAAY,GAAE;;8DACkB;AAIjC;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;qDACa;AAIxB;IAFC,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;qDACa;AAGxB;IADC,IAAA,0BAAQ,GAAE;;sDACc;AAGzB;IADC,IAAA,0BAAQ,GAAE;;sDACc;AAGd,QAAA,aAAa,GAAkB;IAC1C,uBAAuB,EAAE,CAAC;IAC1B,uBAAuB,EAAE,GAAG;IAC5B,eAAe,EAAE,CAAC;IAClB,eAAe,EAAE,GAAG;CACrB,CAAC;AAGK,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,aAAa;CAkCnD,CAAA;AAlCY,8CAAiB;AAE5B;IADC,IAAA,0BAAQ,GAAE;;6CACC;AAMZ;IAJC,IAAA,4BAAU,GAAE;IACZ,IAAA,uBAAU,GAAE;IACZ,IAAA,gCAAc,GAAE;IAChB,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,aAAa,CAAC;8BACD,aAAa;iEAAC;AAKvC;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,gCAAc,GAAE;IAChB,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,aAAa,CAAC;8BACT,aAAa;yDAAC;AAK/B;IAHC,IAAA,4BAAU,GAAE;IACZ,IAAA,yBAAY,GAAE;IACd,IAAA,2BAAS,GAAE;;iDACI;AAMhB;IAJC,IAAA,gCAAc,GAAE;IAChB,IAAA,4BAAU,GAAE;IACZ,IAAA,yBAAY,EAAC,UAAU,CAAC;IACxB,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,cAAM,CAAC;8BACJ,cAAM;uDAAC;AAKtB;IAHC,IAAA,uBAAU,GAAE;IACZ,IAAA,gCAAc,GAAE;IAChB,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,aAAa,CAAC;8BACA,aAAa;kEAAC;AAIxC;IAFC,IAAA,gCAAc,GAAE;IAChB,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,aAAa,CAAC;8BACR,aAAa;0DAAC;4BAjCrB,iBAAiB;IAD7B,IAAA,2BAAc,EAAC,mBAAmB,CAAC;GACvB,iBAAiB,CAkC7B;AAEY,QAAA,iBAAiB,GAAsB;IAClD,EAAE,EAAE,IAAA,mBAAU,GAAE;IAChB,GAAG,qBAAa;IAChB,uBAAuB,EAAE,qBAAa;IACtC,eAAe,EAAE,qBAAa;CAC/B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,555 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const class_validator_1 = require("class-validator");
|
|
7
|
-
const class_transformer_1 = require("class-transformer");
|
|
8
|
-
const crypto_1 = require("crypto");
|
|
9
|
-
const chai_1 = require("chai");
|
|
10
|
-
const lodash_1 = require("lodash");
|
|
11
|
-
const exports_1 = require("../../../src/exports");
|
|
12
|
-
const testCrud_1 = require("../../testImplementations/testCrud");
|
|
13
|
-
const common_1 = require("../common");
|
|
14
|
-
const assert_1 = require("assert");
|
|
15
|
-
const createProjectionHandler_1 = require("../../../src/handlers/crud/createProjectionHandler");
|
|
16
|
-
const createUpdateProjectionHandler_1 = require("../../../src/handlers/crud/createUpdateProjectionHandler");
|
|
17
|
-
const errors_1 = require("../../../src/clients/openSearch/errors");
|
|
18
|
-
const haversine_distance_1 = __importDefault(require("haversine-distance"));
|
|
19
|
-
function doValidate(e, type, expectedError) {
|
|
20
|
-
const instance = (0, class_transformer_1.plainToInstance)(type, e);
|
|
21
|
-
const errors = (0, class_validator_1.validateSync)(instance);
|
|
22
|
-
if (expectedError) {
|
|
23
|
-
(0, chai_1.expect)(errors.join(", ")).to.include(expectedError);
|
|
24
|
-
}
|
|
25
|
-
else if (errors.length) {
|
|
26
|
-
throw new Error(errors.join(", "));
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
class CreateExampleRequest extends (0, createProjectionHandler_1.createCreateRequest)(testCrud_1.ExampleProjection) {
|
|
30
|
-
}
|
|
31
|
-
class UpdateExampleRequest extends (0, createUpdateProjectionHandler_1.createUpdateRequest)(testCrud_1.ExampleProjection) {
|
|
32
|
-
}
|
|
33
|
-
describe("Abstract CRUD handler", () => {
|
|
34
|
-
let appContainer;
|
|
35
|
-
let deps;
|
|
36
|
-
before(async () => {
|
|
37
|
-
appContainer = await (0, common_1.getTestAppContainer)();
|
|
38
|
-
deps = await (0, exports_1.getTestDependencies)(appContainer);
|
|
39
|
-
});
|
|
40
|
-
(0, exports_1.registerTestHooks)(() => deps);
|
|
41
|
-
describe("Type Validation", () => {
|
|
42
|
-
it("Should properly handle a create request", async () => {
|
|
43
|
-
doValidate({ companyId: deps.companyId, ...(0, lodash_1.omit)(testCrud_1.exampleProjection, "id") }, CreateExampleRequest);
|
|
44
|
-
});
|
|
45
|
-
it("Should properly handle an update request", async () => {
|
|
46
|
-
doValidate({
|
|
47
|
-
companyId: deps.companyId,
|
|
48
|
-
id: (0, crypto_1.randomUUID)(),
|
|
49
|
-
optionalEditableObject: {
|
|
50
|
-
optionalEditableNumber: 9,
|
|
51
|
-
},
|
|
52
|
-
}, UpdateExampleRequest);
|
|
53
|
-
});
|
|
54
|
-
it("Should fail update request for invalid types", async () => {
|
|
55
|
-
doValidate({
|
|
56
|
-
companyId: deps.companyId,
|
|
57
|
-
id: (0, crypto_1.randomUUID)(),
|
|
58
|
-
optionalEditableNumber: "string",
|
|
59
|
-
}, CreateExampleRequest, "property optionalEditableNumber has failed the following constraints: isNumber");
|
|
60
|
-
});
|
|
61
|
-
it("Should fail update of nested field", async () => {
|
|
62
|
-
doValidate({
|
|
63
|
-
companyId: deps.companyId,
|
|
64
|
-
id: (0, crypto_1.randomUUID)(),
|
|
65
|
-
optionalEditableObject: {
|
|
66
|
-
optionalEditableNumber: "9",
|
|
67
|
-
},
|
|
68
|
-
}, CreateExampleRequest, "property optionalEditableObject.optionalEditableNumber has failed the following constraints: isNumber");
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
describe("createProjectionHandler", () => {
|
|
72
|
-
it("Should create a new projection", async () => {
|
|
73
|
-
const { id } = await deps.rpc("createExampleProjection", {
|
|
74
|
-
...testCrud_1.exampleProjection,
|
|
75
|
-
companyId: deps.companyId,
|
|
76
|
-
});
|
|
77
|
-
const loaded = await deps.projectionRepository.loadItem({
|
|
78
|
-
companyId: deps.companyId,
|
|
79
|
-
projectionType: "exampleProjection",
|
|
80
|
-
entityId: id,
|
|
81
|
-
});
|
|
82
|
-
(0, chai_1.expect)(loaded.payload).to.deep.equal({
|
|
83
|
-
companyId: deps.companyId,
|
|
84
|
-
...testCrud_1.exampleProjection,
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
describe("updateProjectionHandler", () => {
|
|
89
|
-
let entityId;
|
|
90
|
-
beforeEach(async () => {
|
|
91
|
-
entityId = (0, crypto_1.randomUUID)();
|
|
92
|
-
await deps.projectionRepository.putItem({
|
|
93
|
-
companyId: deps.companyId,
|
|
94
|
-
projectionType: "exampleProjection",
|
|
95
|
-
entityId,
|
|
96
|
-
payload: testCrud_1.exampleProjection,
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
it("Should fail without a companyId", async () => {
|
|
100
|
-
const result = await deps.rpc("updateExampleProjection", {
|
|
101
|
-
id: entityId,
|
|
102
|
-
mandatoryEditableObject: {
|
|
103
|
-
optionalEditableNumber: 1000,
|
|
104
|
-
},
|
|
105
|
-
}, exports_1.RpcResponseStatus.Error);
|
|
106
|
-
(0, chai_1.expect)(result.errorKey).to.equal(exports_1.RpcErrorKey.ERROR_INVALID_FORMAT);
|
|
107
|
-
});
|
|
108
|
-
it("Should update legal fields in a projection", async () => {
|
|
109
|
-
const { modified } = await deps.rpc("updateExampleProjection", {
|
|
110
|
-
companyId: deps.companyId,
|
|
111
|
-
id: entityId,
|
|
112
|
-
mandatoryEditableObject: {
|
|
113
|
-
optionalEditableNumber: 1000,
|
|
114
|
-
},
|
|
115
|
-
mandatoryEditableNumber: 50,
|
|
116
|
-
});
|
|
117
|
-
(0, chai_1.expect)(modified).to.be.true;
|
|
118
|
-
const projection = await deps.projectionRepository.loadItem({
|
|
119
|
-
companyId: deps.companyId,
|
|
120
|
-
projectionType: "exampleProjection",
|
|
121
|
-
entityId,
|
|
122
|
-
});
|
|
123
|
-
(0, chai_1.expect)(projection.payload).to.deep.equal({
|
|
124
|
-
...testCrud_1.exampleProjection,
|
|
125
|
-
mandatoryEditableNumber: 50,
|
|
126
|
-
mandatoryEditableObject: {
|
|
127
|
-
...testCrud_1.exampleProjection.mandatoryEditableObject,
|
|
128
|
-
optionalEditableNumber: 1000,
|
|
129
|
-
},
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
it("Should fail updating illegal fields in a projection", async () => {
|
|
133
|
-
const { errorMessage } = await deps.rpc("updateExampleProjection", {
|
|
134
|
-
companyId: deps.companyId,
|
|
135
|
-
id: entityId,
|
|
136
|
-
mandatoryEditableObject: {
|
|
137
|
-
mandatoryNumber: 100,
|
|
138
|
-
},
|
|
139
|
-
}, exports_1.RpcResponseStatus.Error);
|
|
140
|
-
(0, chai_1.expect)(errorMessage).to.contain("Cannot modify ExampleObject.mandatoryNumber");
|
|
141
|
-
const projection = await deps.projectionRepository.loadItem({
|
|
142
|
-
companyId: deps.companyId,
|
|
143
|
-
projectionType: "exampleProjection",
|
|
144
|
-
entityId,
|
|
145
|
-
});
|
|
146
|
-
(0, chai_1.expect)(projection.payload).to.deep.equal(testCrud_1.exampleProjection);
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
describe("deleteProjectionHandler", () => {
|
|
150
|
-
it("Should delete a projection", async () => {
|
|
151
|
-
const entityId = (0, crypto_1.randomUUID)();
|
|
152
|
-
await deps.projectionRepository.putItem({
|
|
153
|
-
companyId: deps.companyId,
|
|
154
|
-
projectionType: "exampleProjection",
|
|
155
|
-
entityId,
|
|
156
|
-
payload: testCrud_1.exampleProjection,
|
|
157
|
-
});
|
|
158
|
-
await deps.rpc("deleteExampleProjection", {
|
|
159
|
-
companyId: deps.companyId,
|
|
160
|
-
id: entityId,
|
|
161
|
-
});
|
|
162
|
-
try {
|
|
163
|
-
await deps.projectionRepository.loadItem({
|
|
164
|
-
companyId: deps.companyId,
|
|
165
|
-
projectionType: "exampleProjection",
|
|
166
|
-
entityId,
|
|
167
|
-
});
|
|
168
|
-
(0, assert_1.fail)();
|
|
169
|
-
}
|
|
170
|
-
catch (err) {
|
|
171
|
-
(0, chai_1.expect)(err).to.be.instanceOf(exports_1.ItemDeleted);
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
it("Should return NOT_FOUND when deleting a non-existent projection", async () => {
|
|
175
|
-
const { errorKey } = await deps.rpc("deleteExampleProjection", { companyId: deps.companyId, id: (0, crypto_1.randomUUID)() }, exports_1.RpcResponseStatus.Error);
|
|
176
|
-
(0, chai_1.expect)(errorKey).to.equal("NOT_FOUND");
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
describe("searchProjectionHandler", () => {
|
|
180
|
-
let entityIds;
|
|
181
|
-
let projections;
|
|
182
|
-
const lat0 = 75.0;
|
|
183
|
-
const lon0 = 40.71;
|
|
184
|
-
function getPoint(i) {
|
|
185
|
-
return [lat0 + i / 1000, lon0 + i / 1000];
|
|
186
|
-
}
|
|
187
|
-
async function putProjection(i) {
|
|
188
|
-
const entityId = (0, crypto_1.randomUUID)();
|
|
189
|
-
entityIds.push(entityId);
|
|
190
|
-
const [lat, lon] = getPoint(i);
|
|
191
|
-
const projection = await deps.projectionRepository.putItem({
|
|
192
|
-
companyId: deps.companyId,
|
|
193
|
-
projectionType: "exampleProjection",
|
|
194
|
-
entityId,
|
|
195
|
-
payload: {
|
|
196
|
-
id: entityId,
|
|
197
|
-
latLon: `${lat},${lon}`,
|
|
198
|
-
latLonObject: { lat, lon },
|
|
199
|
-
mandatoryEditableObject: {
|
|
200
|
-
optionalEditableString: `sorting by ${(0, crypto_1.randomInt)(1000)}`,
|
|
201
|
-
mandatoryEditableString: `test value ${i}`,
|
|
202
|
-
mandatoryEditableNumber: i * 100,
|
|
203
|
-
mandatoryString: `testMandatoryString${i}`,
|
|
204
|
-
mandatoryNumber: i * 100 + 1,
|
|
205
|
-
},
|
|
206
|
-
mandatoryObject: {
|
|
207
|
-
mandatoryEditableString: `TestEditable${i % 2}`,
|
|
208
|
-
mandatoryEditableNumber: i * 100 + 2,
|
|
209
|
-
mandatoryString: "",
|
|
210
|
-
mandatoryNumber: i * 100 + 3,
|
|
211
|
-
},
|
|
212
|
-
mandatoryEditableString: "",
|
|
213
|
-
mandatoryEditableNumber: i * 100 + 4,
|
|
214
|
-
mandatoryString: "",
|
|
215
|
-
mandatoryNumber: i * 100 + 5,
|
|
216
|
-
},
|
|
217
|
-
});
|
|
218
|
-
await deps.openSearch.indexProjection(projection);
|
|
219
|
-
return projection;
|
|
220
|
-
}
|
|
221
|
-
function sortBy(projections, key, direction) {
|
|
222
|
-
if (direction === "asc") {
|
|
223
|
-
return projections.sort((a, b) => key(a).localeCompare(key(b)));
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
return projections.sort((a, b) => key(b).localeCompare(key(a)));
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
function sortById(projections, direction = "asc") {
|
|
230
|
-
return sortBy(projections, (p) => p.id, direction);
|
|
231
|
-
}
|
|
232
|
-
function sortByQuery(projections, direction = "desc") {
|
|
233
|
-
return sortBy(projections, (p) => p.mandatoryEditableObject.optionalEditableString, direction);
|
|
234
|
-
}
|
|
235
|
-
function getExpectedResults(projections) {
|
|
236
|
-
return projections
|
|
237
|
-
.filter((_, i) => i % 2 === 0)
|
|
238
|
-
.map(({ payload }) => payload);
|
|
239
|
-
}
|
|
240
|
-
const query = {
|
|
241
|
-
mandatoryObject: {
|
|
242
|
-
mandatoryEditableString: "TestEditable0",
|
|
243
|
-
},
|
|
244
|
-
};
|
|
245
|
-
const sort = {
|
|
246
|
-
mandatoryEditableObject: {
|
|
247
|
-
optionalEditableString: "desc",
|
|
248
|
-
},
|
|
249
|
-
};
|
|
250
|
-
function doSearch(args, expectError) {
|
|
251
|
-
if (expectError) {
|
|
252
|
-
return deps.rpc("searchExampleProjections", {
|
|
253
|
-
companyId: deps.companyId,
|
|
254
|
-
...args,
|
|
255
|
-
}, exports_1.RpcResponseStatus.Error);
|
|
256
|
-
}
|
|
257
|
-
else {
|
|
258
|
-
return deps.rpc("searchExampleProjections", {
|
|
259
|
-
companyId: deps.companyId,
|
|
260
|
-
...args,
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
beforeEach(async () => {
|
|
265
|
-
entityIds = [];
|
|
266
|
-
projections = [];
|
|
267
|
-
for (let i = 0; i < 10; i++) {
|
|
268
|
-
projections.push(await putProjection(i));
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
it("Should find a nested string match", async () => {
|
|
272
|
-
const { results } = await doSearch({
|
|
273
|
-
query: {
|
|
274
|
-
mandatoryEditableObject: {
|
|
275
|
-
mandatoryEditableString: "test value 4",
|
|
276
|
-
},
|
|
277
|
-
},
|
|
278
|
-
});
|
|
279
|
-
(0, chai_1.expect)(results).to.deep.equal([projections[4].payload]);
|
|
280
|
-
});
|
|
281
|
-
it("Should limit queries when requested", async () => {
|
|
282
|
-
const { results, continuationToken } = await doSearch({
|
|
283
|
-
query,
|
|
284
|
-
limit: 2,
|
|
285
|
-
});
|
|
286
|
-
(0, chai_1.expect)(results.length).to.equal(2);
|
|
287
|
-
(0, chai_1.expect)(continuationToken).to.not.be.empty;
|
|
288
|
-
});
|
|
289
|
-
it("Should properly paginate queries", async () => {
|
|
290
|
-
const results = [];
|
|
291
|
-
let continuationToken;
|
|
292
|
-
do {
|
|
293
|
-
const response = await doSearch({
|
|
294
|
-
query,
|
|
295
|
-
continuationToken,
|
|
296
|
-
limit: 2,
|
|
297
|
-
});
|
|
298
|
-
results.push(...response.results);
|
|
299
|
-
continuationToken = response.continuationToken;
|
|
300
|
-
} while (continuationToken);
|
|
301
|
-
(0, chai_1.expect)(sortById(results)).to.deep.equal(sortById(getExpectedResults(projections)));
|
|
302
|
-
});
|
|
303
|
-
it("Should properly sort an individual query", async () => {
|
|
304
|
-
const { results, continuationToken } = await doSearch({
|
|
305
|
-
query,
|
|
306
|
-
sort,
|
|
307
|
-
});
|
|
308
|
-
(0, chai_1.expect)(continuationToken).to.be.undefined;
|
|
309
|
-
(0, chai_1.expect)(results).to.deep.equal(sortByQuery(getExpectedResults(projections)));
|
|
310
|
-
});
|
|
311
|
-
it("Should properly sort a paginated query", async () => {
|
|
312
|
-
const results = [];
|
|
313
|
-
let continuationToken;
|
|
314
|
-
do {
|
|
315
|
-
const response = await doSearch({
|
|
316
|
-
query,
|
|
317
|
-
sort,
|
|
318
|
-
continuationToken,
|
|
319
|
-
limit: 2,
|
|
320
|
-
});
|
|
321
|
-
results.push(...response.results);
|
|
322
|
-
continuationToken = response.continuationToken;
|
|
323
|
-
} while (continuationToken);
|
|
324
|
-
(0, chai_1.expect)(results).to.deep.equal(sortByQuery(getExpectedResults(projections)));
|
|
325
|
-
});
|
|
326
|
-
it("Should paginate over a point-in-time snapshot", async function () {
|
|
327
|
-
if (deps.openSearch.isFakeClient) {
|
|
328
|
-
this.skip();
|
|
329
|
-
}
|
|
330
|
-
const results = [];
|
|
331
|
-
let continuationToken;
|
|
332
|
-
let i = 10;
|
|
333
|
-
do {
|
|
334
|
-
const response = await doSearch({
|
|
335
|
-
query,
|
|
336
|
-
continuationToken,
|
|
337
|
-
limit: 2,
|
|
338
|
-
});
|
|
339
|
-
results.push(...response.results);
|
|
340
|
-
continuationToken = response.continuationToken;
|
|
341
|
-
for (let j = 0; j < 4; j++) {
|
|
342
|
-
await putProjection(i++);
|
|
343
|
-
}
|
|
344
|
-
} while (continuationToken);
|
|
345
|
-
(0, chai_1.expect)(sortById(results)).to.deep.equal(sortById(getExpectedResults(projections)));
|
|
346
|
-
});
|
|
347
|
-
it("Should delete the point-in-time search when results are exhausted", async function () {
|
|
348
|
-
if (deps.openSearch.isFakeClient) {
|
|
349
|
-
this.skip();
|
|
350
|
-
}
|
|
351
|
-
let firstContinuationToken;
|
|
352
|
-
let continuationToken;
|
|
353
|
-
do {
|
|
354
|
-
const response = await doSearch({
|
|
355
|
-
query,
|
|
356
|
-
continuationToken,
|
|
357
|
-
limit: 2,
|
|
358
|
-
});
|
|
359
|
-
continuationToken = response.continuationToken;
|
|
360
|
-
if (continuationToken) {
|
|
361
|
-
if (!firstContinuationToken) {
|
|
362
|
-
firstContinuationToken = continuationToken;
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
else {
|
|
366
|
-
if (!firstContinuationToken) {
|
|
367
|
-
(0, assert_1.fail)("unexpected");
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
} while (continuationToken);
|
|
371
|
-
try {
|
|
372
|
-
await deps.openSearch.searchProjections(deps.companyId, "exampleProjection", {
|
|
373
|
-
mandatoryObject: { mandatoryEditableString: "TestEditable0" },
|
|
374
|
-
}, undefined, undefined, undefined, firstContinuationToken);
|
|
375
|
-
(0, assert_1.fail)();
|
|
376
|
-
}
|
|
377
|
-
catch (err) {
|
|
378
|
-
(0, chai_1.expect)(err).to.be.instanceOf(errors_1.ExpiredPointInTime);
|
|
379
|
-
}
|
|
380
|
-
});
|
|
381
|
-
it("Should successfully handle an expired point-in-time id", async () => {
|
|
382
|
-
const results = [];
|
|
383
|
-
const adminClient = await appContainer.getAsync(exports_1.OpensearchAdminClient);
|
|
384
|
-
let continuationToken;
|
|
385
|
-
do {
|
|
386
|
-
const response = await doSearch({
|
|
387
|
-
query,
|
|
388
|
-
continuationToken,
|
|
389
|
-
limit: 2,
|
|
390
|
-
});
|
|
391
|
-
results.push(...response.results);
|
|
392
|
-
continuationToken = response.continuationToken;
|
|
393
|
-
if (continuationToken) {
|
|
394
|
-
const [pit_id] = continuationToken.split(":");
|
|
395
|
-
await adminClient.expirePointInTime(pit_id);
|
|
396
|
-
}
|
|
397
|
-
} while (continuationToken);
|
|
398
|
-
(0, chai_1.expect)(sortById(results)).to.deep.equal(sortById(getExpectedResults(projections)));
|
|
399
|
-
});
|
|
400
|
-
it("Should allow queries with point-in-time explicitly disabled", async () => {
|
|
401
|
-
const results = [];
|
|
402
|
-
let continuationToken;
|
|
403
|
-
do {
|
|
404
|
-
const response = await doSearch({
|
|
405
|
-
query,
|
|
406
|
-
continuationToken,
|
|
407
|
-
limit: 2,
|
|
408
|
-
pointInTime: false,
|
|
409
|
-
});
|
|
410
|
-
results.push(...response.results);
|
|
411
|
-
continuationToken = response.continuationToken;
|
|
412
|
-
} while (continuationToken);
|
|
413
|
-
(0, chai_1.expect)(sortById(results)).to.deep.equal(sortById(getExpectedResults(projections)));
|
|
414
|
-
});
|
|
415
|
-
describe("Geospatial", async () => {
|
|
416
|
-
it("Should find entries by distance", async () => {
|
|
417
|
-
const fourthDistance = (0, haversine_distance_1.default)({ lat: lat0, lon: lon0 }, { lat: getPoint(3)[0], lon: getPoint(3)[1] });
|
|
418
|
-
const fifthDistance = (0, haversine_distance_1.default)({ lat: lat0, lon: lon0 }, { lat: getPoint(4)[0], lon: getPoint(4)[1] });
|
|
419
|
-
const maxDistance = (fourthDistance + fifthDistance) / 2;
|
|
420
|
-
const units = "meters";
|
|
421
|
-
const { results } = await doSearch({
|
|
422
|
-
query: {
|
|
423
|
-
latLonObject: {
|
|
424
|
-
distance: maxDistance,
|
|
425
|
-
units,
|
|
426
|
-
lat: lat0,
|
|
427
|
-
lon: lon0,
|
|
428
|
-
},
|
|
429
|
-
},
|
|
430
|
-
limit: 5,
|
|
431
|
-
});
|
|
432
|
-
(0, chai_1.expect)(results.length).to.equal(4);
|
|
433
|
-
for (const result of results) {
|
|
434
|
-
const distance = (0, haversine_distance_1.default)({ lat: lat0, lon: lon0 }, result.latLonObject);
|
|
435
|
-
(0, chai_1.expect)(distance).to.be.lessThan(maxDistance);
|
|
436
|
-
}
|
|
437
|
-
});
|
|
438
|
-
it("Should find entries by bounding box", async () => {
|
|
439
|
-
const { results } = await doSearch({
|
|
440
|
-
query: {
|
|
441
|
-
latLonObject: {
|
|
442
|
-
top: lat0 + 1.2,
|
|
443
|
-
left: lon0,
|
|
444
|
-
bottom: lat0,
|
|
445
|
-
right: lon0 + 1.5,
|
|
446
|
-
},
|
|
447
|
-
},
|
|
448
|
-
});
|
|
449
|
-
(0, chai_1.expect)(results).to.not.be.empty;
|
|
450
|
-
for (const result of results) {
|
|
451
|
-
(0, chai_1.expect)(result.latLonObject.lat).to.be.greaterThanOrEqual(lat0);
|
|
452
|
-
(0, chai_1.expect)(result.latLonObject.lat).to.be.lessThanOrEqual(lat0 + 1.5);
|
|
453
|
-
(0, chai_1.expect)(result.latLonObject.lon).to.be.greaterThanOrEqual(lon0);
|
|
454
|
-
(0, chai_1.expect)(result.latLonObject.lon).to.be.lessThanOrEqual(lon0 + 1.5);
|
|
455
|
-
}
|
|
456
|
-
});
|
|
457
|
-
});
|
|
458
|
-
});
|
|
459
|
-
describe("getProjectionHandler", async () => {
|
|
460
|
-
function getProjection(id) {
|
|
461
|
-
return deps.rpc("getExampleProjection", {
|
|
462
|
-
companyId: deps.companyId,
|
|
463
|
-
id,
|
|
464
|
-
});
|
|
465
|
-
}
|
|
466
|
-
it("Should find an entity by id", async () => {
|
|
467
|
-
const entityId = (0, crypto_1.randomUUID)();
|
|
468
|
-
await deps.projectionRepository.putItem({
|
|
469
|
-
companyId: deps.companyId,
|
|
470
|
-
projectionType: "exampleProjection",
|
|
471
|
-
entityId,
|
|
472
|
-
payload: testCrud_1.exampleProjection,
|
|
473
|
-
});
|
|
474
|
-
const result = await deps.rpc("getExampleProjection", {
|
|
475
|
-
companyId: deps.companyId,
|
|
476
|
-
id: entityId,
|
|
477
|
-
});
|
|
478
|
-
(0, chai_1.expect)(result.projection).to.deep.equal(testCrud_1.exampleProjection);
|
|
479
|
-
});
|
|
480
|
-
it("Should return undefined if the id does not exist", async () => {
|
|
481
|
-
const result = await deps.rpc("getExampleProjection", {
|
|
482
|
-
companyId: deps.companyId,
|
|
483
|
-
id: (0, crypto_1.randomUUID)(),
|
|
484
|
-
});
|
|
485
|
-
(0, chai_1.expect)(result).to.deep.equal({});
|
|
486
|
-
});
|
|
487
|
-
});
|
|
488
|
-
describe("getProjectionsHandler", () => {
|
|
489
|
-
let projectionStore;
|
|
490
|
-
beforeEach(async () => {
|
|
491
|
-
projectionStore = [];
|
|
492
|
-
for (let i = 0; i < 10; i++) {
|
|
493
|
-
const entityId = (0, crypto_1.randomUUID)();
|
|
494
|
-
const projection = await deps.projectionRepository.putItem({
|
|
495
|
-
companyId: deps.companyId,
|
|
496
|
-
projectionType: "exampleProjection",
|
|
497
|
-
entityId,
|
|
498
|
-
payload: {
|
|
499
|
-
id: entityId,
|
|
500
|
-
mandatoryEditableObject: {
|
|
501
|
-
mandatoryEditableString: `mandatoryEditableObject${i * 100}`,
|
|
502
|
-
mandatoryEditableNumber: i * 100 + 1,
|
|
503
|
-
mandatoryString: `mandatoryString${i * 100 + 2}`,
|
|
504
|
-
mandatoryNumber: i * 100 + 3,
|
|
505
|
-
},
|
|
506
|
-
mandatoryObject: {
|
|
507
|
-
mandatoryEditableString: `mandatoryEditableString${i * 100 + 4}`,
|
|
508
|
-
mandatoryEditableNumber: i * 100 + 5,
|
|
509
|
-
mandatoryString: `mandatoryString${i * 100 + 6}`,
|
|
510
|
-
mandatoryNumber: i * 100 + 7,
|
|
511
|
-
},
|
|
512
|
-
mandatoryEditableString: `mandatoryEditableString${i * 100 + 8}`,
|
|
513
|
-
mandatoryEditableNumber: i * 100 + 9,
|
|
514
|
-
mandatoryString: `mandatoryString${i + 100 + 10}`,
|
|
515
|
-
mandatoryNumber: i * 100 + 11,
|
|
516
|
-
},
|
|
517
|
-
}, testCrud_1.ExampleProjection);
|
|
518
|
-
projectionStore.push(projection);
|
|
519
|
-
}
|
|
520
|
-
});
|
|
521
|
-
function doRpc(ids) {
|
|
522
|
-
return deps.rpc("getExampleProjections", {
|
|
523
|
-
companyId: deps.companyId,
|
|
524
|
-
ids,
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
it("Should fetch all the requested projections if they exist", async () => {
|
|
528
|
-
const { projections, missing } = await doRpc(projectionStore.slice(3, 8).map((p) => p.entityId));
|
|
529
|
-
(0, chai_1.expect)(projections).to.deep.equal(projectionStore.slice(3, 8).map((p) => p.payload));
|
|
530
|
-
(0, chai_1.expect)(missing).to.be.empty;
|
|
531
|
-
});
|
|
532
|
-
it("Should fetch a single requested projection", async () => {
|
|
533
|
-
const { projections, missing } = await doRpc([
|
|
534
|
-
projectionStore[5].entityId,
|
|
535
|
-
]);
|
|
536
|
-
(0, chai_1.expect)(projections).to.deep.equal([projectionStore[5].payload]);
|
|
537
|
-
(0, chai_1.expect)(missing).to.be.empty;
|
|
538
|
-
});
|
|
539
|
-
it("Should return an empty array if none are requested", async () => {
|
|
540
|
-
const { projections, missing } = await doRpc([]);
|
|
541
|
-
(0, chai_1.expect)(projections).to.be.empty;
|
|
542
|
-
(0, chai_1.expect)(missing).to.be.empty;
|
|
543
|
-
});
|
|
544
|
-
it("Should return an empty array if none are found", async () => {
|
|
545
|
-
const ids = [];
|
|
546
|
-
for (let i = 0; i < 10; i++) {
|
|
547
|
-
ids.push((0, crypto_1.randomUUID)());
|
|
548
|
-
}
|
|
549
|
-
const { projections, missing } = await doRpc(ids);
|
|
550
|
-
(0, chai_1.expect)(projections).to.be.empty;
|
|
551
|
-
(0, chai_1.expect)(missing).to.deep.equal(ids);
|
|
552
|
-
});
|
|
553
|
-
});
|
|
554
|
-
});
|
|
555
|
-
//# sourceMappingURL=crudHandlers.spec.js.map
|