@mavenmachines/event-handler-lib 1.5.0-rc.1 → 1.5.0-rc.10
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 +98 -2
- package/dist/config/default.d.ts +12 -0
- package/dist/config/default.js +12 -0
- package/dist/config/default.js.map +1 -1
- package/dist/package.json +2 -1
- package/dist/src/clients/openSearch/mappings.d.ts +4 -2
- package/dist/src/clients/openSearch/mappings.js +8 -1
- package/dist/src/clients/openSearch/mappings.js.map +1 -1
- package/dist/src/clients/openSearch/openSearchClient.d.ts +6 -6
- package/dist/src/clients/openSearch/openSearchClient.js +56 -71
- package/dist/src/clients/openSearch/openSearchClient.js.map +1 -1
- package/dist/src/configs/inversifyConfig.d.ts +2 -0
- package/dist/src/configs/inversifyConfig.js +29 -3
- package/dist/src/configs/inversifyConfig.js.map +1 -1
- package/dist/src/dependencies/dependencyTypes.d.ts +1 -0
- package/dist/src/dependencies/dependencyTypes.js +1 -0
- package/dist/src/dependencies/dependencyTypes.js.map +1 -1
- package/dist/src/handlers/crud/baseHandlers.d.ts +6 -10
- package/dist/src/handlers/crud/baseHandlers.js +48 -20
- package/dist/src/handlers/crud/baseHandlers.js.map +1 -1
- package/dist/src/handlers/crud/createProjectionHandler.d.ts +3 -2
- package/dist/src/handlers/crud/createProjectionHandler.js +39 -2
- package/dist/src/handlers/crud/createProjectionHandler.js.map +1 -1
- package/dist/src/handlers/crud/createUpdateProjectionHandler.d.ts +1 -1
- package/dist/src/handlers/crud/createUpdateProjectionHandler.js +27 -1
- package/dist/src/handlers/crud/createUpdateProjectionHandler.js.map +1 -1
- package/dist/src/handlers/crud/decorators.d.ts +8 -2
- package/dist/src/handlers/crud/decorators.js +6 -4
- package/dist/src/handlers/crud/decorators.js.map +1 -1
- package/dist/src/handlers/crud/deleteProjectionHandler.d.ts +1 -1
- package/dist/src/handlers/crud/deleteProjectionHandler.js.map +1 -1
- package/dist/src/handlers/crud/getProjectionHandler.d.ts +5 -4
- package/dist/src/handlers/crud/getProjectionHandler.js +31 -2
- package/dist/src/handlers/crud/getProjectionHandler.js.map +1 -1
- package/dist/src/handlers/crud/getProjectionsHandler.d.ts +2 -1
- package/dist/src/handlers/crud/getProjectionsHandler.js +21 -1
- package/dist/src/handlers/crud/getProjectionsHandler.js.map +1 -1
- package/dist/src/handlers/crud/helpers.d.ts +27 -0
- package/dist/src/handlers/crud/helpers.js +174 -13
- package/dist/src/handlers/crud/helpers.js.map +1 -1
- package/dist/src/handlers/crud/index.d.ts +6 -3
- package/dist/src/handlers/crud/index.js +37 -4
- package/dist/src/handlers/crud/index.js.map +1 -1
- package/dist/src/handlers/crud/schemaHandler.d.ts +23 -0
- package/dist/src/handlers/crud/schemaHandler.js +127 -0
- package/dist/src/handlers/crud/schemaHandler.js.map +1 -0
- package/dist/src/handlers/crud/searchProjectionsHandler.d.ts +3 -13
- package/dist/src/handlers/crud/searchProjectionsHandler.js +91 -13
- package/dist/src/handlers/crud/searchProjectionsHandler.js.map +1 -1
- package/dist/src/handlers/crud/types.d.ts +49 -0
- package/dist/src/handlers/crud/types.js +42 -0
- package/dist/src/handlers/crud/types.js.map +1 -0
- package/dist/src/handlers/eventHandlers/eventHandlingModule.js +1 -2
- package/dist/src/handlers/eventHandlers/eventHandlingModule.js.map +1 -1
- package/dist/src/helpers/dataStructure.helpers.d.ts +1 -0
- package/dist/src/helpers/dataStructure.helpers.js +16 -0
- package/dist/src/helpers/dataStructure.helpers.js.map +1 -1
- package/dist/src/helpers/string.helpers.d.ts +2 -0
- package/dist/src/helpers/string.helpers.js +17 -0
- package/dist/src/helpers/string.helpers.js.map +1 -1
- package/dist/src/helpers/typeManipulation/classValidation.d.ts +1 -0
- package/dist/src/helpers/typeManipulation/classValidation.js.map +1 -1
- package/dist/src/helpers/typeManipulation/decorators.d.ts +10 -7
- package/dist/src/helpers/typeManipulation/decorators.js +63 -5
- package/dist/src/helpers/typeManipulation/decorators.js.map +1 -1
- package/dist/src/helpers/typeManipulation/dynamicClasses.d.ts +6 -7
- package/dist/src/helpers/typeManipulation/dynamicClasses.js +40 -13
- package/dist/src/helpers/typeManipulation/dynamicClasses.js.map +1 -1
- package/dist/src/initializers/queue-manager.service.d.ts +1 -1
- package/dist/src/initializers/queue-manager.service.js +1 -0
- package/dist/src/initializers/queue-manager.service.js.map +1 -1
- package/dist/src/testUtils/mocks/openSearch.client.mock.d.ts +102 -0
- package/dist/src/testUtils/mocks/openSearch.client.mock.js +405 -0
- package/dist/src/testUtils/mocks/openSearch.client.mock.js.map +1 -0
- package/dist/test/testImplementations/testCrud.d.ts +29 -0
- package/dist/test/testImplementations/testCrud.js +125 -1
- package/dist/test/testImplementations/testCrud.js.map +1 -1
- package/dist/test/tests/clients/opensearch.client.spec.js +1 -72
- package/dist/test/tests/clients/opensearch.client.spec.js.map +1 -1
- package/dist/test/tests/common.js +7 -5
- package/dist/test/tests/common.js.map +1 -1
- package/dist/test/tests/eventHandlers/crudHandlers.spec.js +170 -3
- package/dist/test/tests/eventHandlers/crudHandlers.spec.js.map +1 -1
- package/dist/test/tests/helpers/decorators.spec.d.ts +1 -0
- package/dist/test/tests/helpers/decorators.spec.js +109 -0
- package/dist/test/tests/helpers/decorators.spec.js.map +1 -0
- package/dist/test/tests/helpers/syncOpensearch.spec.js +0 -43
- package/dist/test/tests/helpers/syncOpensearch.spec.js.map +1 -1
- package/package.json +3 -2
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { LatLon } from "../../src/handlers/crud/types";
|
|
2
|
+
import { ClassConverter, EventLogServiceRpc, ProjectionRepository } from "../../src";
|
|
1
3
|
export declare class ExampleObject {
|
|
2
4
|
optionalEditableNumber?: number;
|
|
3
5
|
optionalEditableString?: string;
|
|
@@ -13,7 +15,34 @@ export declare class ExampleProjection extends ExampleObject {
|
|
|
13
15
|
id: string;
|
|
14
16
|
optionalEditableObject?: ExampleObject;
|
|
15
17
|
optionalObject?: ExampleObject;
|
|
18
|
+
latLon?: string;
|
|
19
|
+
latLonObject?: LatLon;
|
|
16
20
|
mandatoryEditableObject: ExampleObject;
|
|
17
21
|
mandatoryObject: ExampleObject;
|
|
18
22
|
}
|
|
23
|
+
export declare class CreatedProjection {
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
}
|
|
27
|
+
export declare class LoadProjection {
|
|
28
|
+
companyId: number;
|
|
29
|
+
requestedId: string;
|
|
30
|
+
private validateInjectedArgument;
|
|
31
|
+
createEntity(projectionRepository: ProjectionRepository, unusedEventLogService: EventLogServiceRpc, unusedClassConverter: ClassConverter): Promise<Record<string, any>>;
|
|
32
|
+
}
|
|
33
|
+
export declare class CreationRequestProjection {
|
|
34
|
+
companyId: number;
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
}
|
|
38
|
+
export declare class CreationRequestProjectionEnvelope {
|
|
39
|
+
companyId: number;
|
|
40
|
+
id: string;
|
|
41
|
+
projection: CreationRequestProjection;
|
|
42
|
+
}
|
|
43
|
+
export declare class CreationRequestArray {
|
|
44
|
+
companyId: number;
|
|
45
|
+
id: string;
|
|
46
|
+
projections: CreationRequestProjection[];
|
|
47
|
+
}
|
|
19
48
|
export declare const exampleProjection: ExampleProjection;
|
|
@@ -8,12 +8,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.exampleProjection = exports.ExampleProjection = exports.exampleObject = exports.ExampleObject = void 0;
|
|
15
|
+
exports.exampleProjection = exports.CreationRequestArray = exports.CreationRequestProjectionEnvelope = exports.CreationRequestProjection = exports.LoadProjection = exports.CreatedProjection = exports.ExampleProjection = exports.exampleObject = exports.ExampleObject = void 0;
|
|
13
16
|
const class_validator_1 = require("class-validator");
|
|
14
17
|
const decorators_1 = require("../../src/handlers/crud/decorators");
|
|
15
18
|
const class_transformer_1 = require("class-transformer");
|
|
16
19
|
const crypto_1 = require("crypto");
|
|
20
|
+
const types_1 = require("../../src/handlers/crud/types");
|
|
21
|
+
const src_1 = require("../../src");
|
|
17
22
|
class ExampleObject {
|
|
18
23
|
}
|
|
19
24
|
exports.ExampleObject = ExampleObject;
|
|
@@ -86,6 +91,19 @@ __decorate([
|
|
|
86
91
|
(0, class_transformer_1.Type)(() => ExampleObject),
|
|
87
92
|
__metadata("design:type", ExampleObject)
|
|
88
93
|
], ExampleProjection.prototype, "optionalObject", void 0);
|
|
94
|
+
__decorate([
|
|
95
|
+
(0, class_validator_1.IsOptional)(),
|
|
96
|
+
(0, decorators_1.IsSearchable)(),
|
|
97
|
+
(0, class_validator_1.IsLatLong)(),
|
|
98
|
+
__metadata("design:type", String)
|
|
99
|
+
], ExampleProjection.prototype, "latLon", void 0);
|
|
100
|
+
__decorate([
|
|
101
|
+
(0, class_validator_1.ValidateNested)(),
|
|
102
|
+
(0, class_validator_1.IsOptional)(),
|
|
103
|
+
(0, decorators_1.IsSearchable)("geopoint"),
|
|
104
|
+
(0, class_transformer_1.Type)(() => types_1.LatLon),
|
|
105
|
+
__metadata("design:type", types_1.LatLon)
|
|
106
|
+
], ExampleProjection.prototype, "latLonObject", void 0);
|
|
89
107
|
__decorate([
|
|
90
108
|
(0, decorators_1.IsEditable)(),
|
|
91
109
|
(0, class_validator_1.ValidateNested)(),
|
|
@@ -100,6 +118,112 @@ __decorate([
|
|
|
100
118
|
exports.ExampleProjection = ExampleProjection = __decorate([
|
|
101
119
|
(0, decorators_1.ProjectionType)("exampleProjection")
|
|
102
120
|
], ExampleProjection);
|
|
121
|
+
class CreatedProjection {
|
|
122
|
+
}
|
|
123
|
+
exports.CreatedProjection = CreatedProjection;
|
|
124
|
+
__decorate([
|
|
125
|
+
(0, class_validator_1.IsString)(),
|
|
126
|
+
__metadata("design:type", String)
|
|
127
|
+
], CreatedProjection.prototype, "id", void 0);
|
|
128
|
+
__decorate([
|
|
129
|
+
(0, class_validator_1.IsString)(),
|
|
130
|
+
__metadata("design:type", String)
|
|
131
|
+
], CreatedProjection.prototype, "name", void 0);
|
|
132
|
+
class LoadProjection {
|
|
133
|
+
validateInjectedArgument(position, value, expectedType) {
|
|
134
|
+
if (!(value instanceof expectedType)) {
|
|
135
|
+
throw new Error(`Argument ${position} should be ${expectedType.name}; ${value?.constructor ? value.constructor.name : value} received`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async createEntity(projectionRepository, unusedEventLogService, unusedClassConverter) {
|
|
139
|
+
this.validateInjectedArgument(0, projectionRepository, src_1.ProjectionRepository);
|
|
140
|
+
this.validateInjectedArgument(1, unusedEventLogService, src_1.EventLogServiceRpc);
|
|
141
|
+
this.validateInjectedArgument(2, unusedClassConverter, src_1.ClassConverter);
|
|
142
|
+
const projection = await projectionRepository.loadItem({
|
|
143
|
+
companyId: this.companyId,
|
|
144
|
+
entityId: this.requestedId,
|
|
145
|
+
projectionType: "creationRequestProjection",
|
|
146
|
+
});
|
|
147
|
+
return projection.payload;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
exports.LoadProjection = LoadProjection;
|
|
151
|
+
__decorate([
|
|
152
|
+
(0, class_validator_1.IsNumber)(),
|
|
153
|
+
__metadata("design:type", Number)
|
|
154
|
+
], LoadProjection.prototype, "companyId", void 0);
|
|
155
|
+
__decorate([
|
|
156
|
+
(0, class_validator_1.IsString)(),
|
|
157
|
+
__metadata("design:type", String)
|
|
158
|
+
], LoadProjection.prototype, "requestedId", void 0);
|
|
159
|
+
__decorate([
|
|
160
|
+
__param(0, (0, decorators_1.Inject)(src_1.ProjectionRepository)),
|
|
161
|
+
__param(1, (0, decorators_1.Inject)(src_1.EventLogServiceRpc)),
|
|
162
|
+
__param(2, (0, decorators_1.Inject)(src_1.ClassConverter)),
|
|
163
|
+
__metadata("design:type", Function),
|
|
164
|
+
__metadata("design:paramtypes", [src_1.ProjectionRepository,
|
|
165
|
+
src_1.EventLogServiceRpc,
|
|
166
|
+
src_1.ClassConverter]),
|
|
167
|
+
__metadata("design:returntype", Promise)
|
|
168
|
+
], LoadProjection.prototype, "createEntity", null);
|
|
169
|
+
let CreationRequestProjection = class CreationRequestProjection {
|
|
170
|
+
};
|
|
171
|
+
exports.CreationRequestProjection = CreationRequestProjection;
|
|
172
|
+
__decorate([
|
|
173
|
+
(0, class_validator_1.IsNumber)(),
|
|
174
|
+
__metadata("design:type", Number)
|
|
175
|
+
], CreationRequestProjection.prototype, "companyId", void 0);
|
|
176
|
+
__decorate([
|
|
177
|
+
(0, class_validator_1.IsString)(),
|
|
178
|
+
__metadata("design:type", String)
|
|
179
|
+
], CreationRequestProjection.prototype, "id", void 0);
|
|
180
|
+
__decorate([
|
|
181
|
+
(0, class_validator_1.IsString)(),
|
|
182
|
+
__metadata("design:type", String)
|
|
183
|
+
], CreationRequestProjection.prototype, "name", void 0);
|
|
184
|
+
exports.CreationRequestProjection = CreationRequestProjection = __decorate([
|
|
185
|
+
(0, decorators_1.ProjectionType)("creationRequestProjection"),
|
|
186
|
+
(0, decorators_1.CreationRequestType)(LoadProjection)
|
|
187
|
+
], CreationRequestProjection);
|
|
188
|
+
let CreationRequestProjectionEnvelope = class CreationRequestProjectionEnvelope {
|
|
189
|
+
};
|
|
190
|
+
exports.CreationRequestProjectionEnvelope = CreationRequestProjectionEnvelope;
|
|
191
|
+
__decorate([
|
|
192
|
+
(0, class_validator_1.IsNumber)(),
|
|
193
|
+
__metadata("design:type", Number)
|
|
194
|
+
], CreationRequestProjectionEnvelope.prototype, "companyId", void 0);
|
|
195
|
+
__decorate([
|
|
196
|
+
(0, class_validator_1.IsString)(),
|
|
197
|
+
__metadata("design:type", String)
|
|
198
|
+
], CreationRequestProjectionEnvelope.prototype, "id", void 0);
|
|
199
|
+
__decorate([
|
|
200
|
+
(0, class_validator_1.ValidateNested)(),
|
|
201
|
+
(0, class_transformer_1.Type)(() => CreationRequestProjection),
|
|
202
|
+
__metadata("design:type", CreationRequestProjection)
|
|
203
|
+
], CreationRequestProjectionEnvelope.prototype, "projection", void 0);
|
|
204
|
+
exports.CreationRequestProjectionEnvelope = CreationRequestProjectionEnvelope = __decorate([
|
|
205
|
+
(0, decorators_1.ProjectionType)("creationRequestProjectionEnvelope")
|
|
206
|
+
], CreationRequestProjectionEnvelope);
|
|
207
|
+
let CreationRequestArray = class CreationRequestArray {
|
|
208
|
+
};
|
|
209
|
+
exports.CreationRequestArray = CreationRequestArray;
|
|
210
|
+
__decorate([
|
|
211
|
+
(0, class_validator_1.IsNumber)(),
|
|
212
|
+
__metadata("design:type", Number)
|
|
213
|
+
], CreationRequestArray.prototype, "companyId", void 0);
|
|
214
|
+
__decorate([
|
|
215
|
+
(0, class_validator_1.IsString)(),
|
|
216
|
+
__metadata("design:type", String)
|
|
217
|
+
], CreationRequestArray.prototype, "id", void 0);
|
|
218
|
+
__decorate([
|
|
219
|
+
(0, class_validator_1.IsArray)(),
|
|
220
|
+
(0, class_validator_1.ValidateNested)({ each: true }),
|
|
221
|
+
(0, class_transformer_1.Type)(() => CreationRequestProjection),
|
|
222
|
+
__metadata("design:type", Array)
|
|
223
|
+
], CreationRequestArray.prototype, "projections", void 0);
|
|
224
|
+
exports.CreationRequestArray = CreationRequestArray = __decorate([
|
|
225
|
+
(0, decorators_1.ProjectionType)("creationRequestArray")
|
|
226
|
+
], CreationRequestArray);
|
|
103
227
|
exports.exampleProjection = {
|
|
104
228
|
id: (0, crypto_1.randomUUID)(),
|
|
105
229
|
...exports.exampleObject,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testCrud.js","sourceRoot":"","sources":["../../../test/testImplementations/testCrud.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"testCrud.js","sourceRoot":"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AIZ;IAFC,IAAA,gCAAc,GAAE;IAChB,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,yBAAyB,CAAC;8BACzB,yBAAyB;qEAAC;4CAT5B,iCAAiC;IAD7C,IAAA,2BAAc,EAAC,mCAAmC,CAAC;GACvC,iCAAiC,CAU7C;AAGM,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CAWhC,CAAA;AAXY,oDAAoB;AAE/B;IADC,IAAA,0BAAQ,GAAE;;uDACQ;AAGnB;IADC,IAAA,0BAAQ,GAAE;;gDACC;AAKZ;IAHC,IAAA,yBAAO,GAAE;IACT,IAAA,gCAAc,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IAC9B,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,yBAAyB,CAAC;;yDACI;+BAV/B,oBAAoB;IADhC,IAAA,2BAAc,EAAC,sBAAsB,CAAC;GAC1B,oBAAoB,CAWhC;AAEY,QAAA,iBAAiB,GAAsB;IAClD,EAAE,EAAE,IAAA,mBAAU,GAAE;IAChB,GAAG,qBAAa;IAChB,uBAAuB,EAAE,qBAAa;IACtC,eAAe,EAAE,qBAAa;CAC/B,CAAC"}
|
|
@@ -5,8 +5,6 @@ const common_1 = require("../common");
|
|
|
5
5
|
const crypto_1 = require("crypto");
|
|
6
6
|
const chai_1 = require("chai");
|
|
7
7
|
const lodash_1 = require("lodash");
|
|
8
|
-
const assert_1 = require("assert");
|
|
9
|
-
const errors_1 = require("../../../src/clients/openSearch/errors");
|
|
10
8
|
describe("OpenSearchClient", () => {
|
|
11
9
|
let appContainer;
|
|
12
10
|
let deps;
|
|
@@ -40,7 +38,7 @@ describe("OpenSearchClient", () => {
|
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
40
|
async function indexProjection(args, maxRecursionLimit) {
|
|
43
|
-
await deps.openSearch.indexProjection(createProjection(args)
|
|
41
|
+
await deps.openSearch.indexProjection(createProjection(args));
|
|
44
42
|
const indexedValue = await deps.openSearch.getProjectionIndex({
|
|
45
43
|
companyId: deps.companyId,
|
|
46
44
|
projectionType: args?.projectionType ?? projectionType,
|
|
@@ -61,74 +59,5 @@ describe("OpenSearchClient", () => {
|
|
|
61
59
|
referenceIds: { entityId },
|
|
62
60
|
});
|
|
63
61
|
});
|
|
64
|
-
it("Should successfully remove a failed field", async () => {
|
|
65
|
-
const indexedValue = await indexProjection({
|
|
66
|
-
event: { eventId: { entityId } },
|
|
67
|
-
});
|
|
68
|
-
(0, chai_1.expect)(indexedValue).to.deep.equal({
|
|
69
|
-
companyId: deps.companyId,
|
|
70
|
-
entityId,
|
|
71
|
-
projectionType,
|
|
72
|
-
event: {},
|
|
73
|
-
payload: {
|
|
74
|
-
value: 1,
|
|
75
|
-
},
|
|
76
|
-
version: 1,
|
|
77
|
-
referenceIds: { entityId },
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
it("Should successfully remove multiple failed fields", async () => {
|
|
81
|
-
const indexedValue = await indexProjection({
|
|
82
|
-
event: {
|
|
83
|
-
eventId: { entityId },
|
|
84
|
-
eventType: { entityId },
|
|
85
|
-
},
|
|
86
|
-
command: {
|
|
87
|
-
commandId: { entityId },
|
|
88
|
-
service: "serviceName",
|
|
89
|
-
},
|
|
90
|
-
});
|
|
91
|
-
(0, chai_1.expect)(indexedValue).to.deep.equal({
|
|
92
|
-
companyId: deps.companyId,
|
|
93
|
-
projectionType,
|
|
94
|
-
entityId,
|
|
95
|
-
payload: {
|
|
96
|
-
value: 1,
|
|
97
|
-
},
|
|
98
|
-
event: {},
|
|
99
|
-
command: {
|
|
100
|
-
service: "serviceName",
|
|
101
|
-
},
|
|
102
|
-
version: 1,
|
|
103
|
-
referenceIds: { entityId },
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
it("Should not exceed the maximum recursion limit", async () => {
|
|
107
|
-
const args = {
|
|
108
|
-
event: {
|
|
109
|
-
eventId: { entityId },
|
|
110
|
-
eventType: { entityId },
|
|
111
|
-
},
|
|
112
|
-
command: {
|
|
113
|
-
commandId: { entityId },
|
|
114
|
-
service: "serviceName",
|
|
115
|
-
},
|
|
116
|
-
};
|
|
117
|
-
try {
|
|
118
|
-
await indexProjection(args, 2);
|
|
119
|
-
(0, assert_1.fail)();
|
|
120
|
-
}
|
|
121
|
-
catch (err) {
|
|
122
|
-
(0, chai_1.expect)(err).to.be.instanceOf(errors_1.MaxRecursionSanitizationReached);
|
|
123
|
-
const typedLimit = err;
|
|
124
|
-
(0, chai_1.expect)(typedLimit.name).to.equal(`${deps.companyId}_${projectionType}_${entityId}`);
|
|
125
|
-
(0, chai_1.expect)(typedLimit.limit).to.equal(2);
|
|
126
|
-
(0, chai_1.expect)(typedLimit.item).to.deep.equal(createProjection(args));
|
|
127
|
-
(0, chai_1.expect)(typedLimit.removedFields).to.deep.equal([
|
|
128
|
-
["event.eventId", { entityId }],
|
|
129
|
-
["event.eventType", { entityId }],
|
|
130
|
-
]);
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
62
|
});
|
|
134
63
|
//# sourceMappingURL=opensearch.client.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opensearch.client.spec.js","sourceRoot":"","sources":["../../../../test/tests/clients/opensearch.client.spec.ts"],"names":[],"mappings":";;AACA,sCASsB;AACtB,sCAAgD;AAChD,mCAAoC;AACpC,+BAA8B;AAC9B,mCAA8B;
|
|
1
|
+
{"version":3,"file":"opensearch.client.spec.js","sourceRoot":"","sources":["../../../../test/tests/clients/opensearch.client.spec.ts"],"names":[],"mappings":";;AACA,sCASsB;AACtB,sCAAgD;AAChD,mCAAoC;AACpC,+BAA8B;AAC9B,mCAA8B;AAE9B,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,IAAI,YAAuB,CAAC;IAC5B,IAAI,IAAsB,CAAC;IAC3B,MAAM,cAAc,GAAG,gBAAgB,CAAC;IACxC,IAAI,QAAgB,CAAC;IAErB,MAAM,CAAC,KAAK,IAAI,EAAE;QAChB,YAAY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,IAAA,aAAM,EAAC,YAAY,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;YACjC,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,cAAc;YACd,QAAQ;YACR,OAAO,EAAE;gBACP,KAAK,EAAE,CAAC;aACT;YACD,OAAO,EAAE,CAAC;YACV,YAAY,EAAE,EAAE,QAAQ,EAAE;SAC3B,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getTestAppContainer = getTestAppContainer;
|
|
4
4
|
exports.expectValidProjectionIndex = expectValidProjectionIndex;
|
|
5
5
|
exports.expectDeletedProjectionIndex = expectDeletedProjectionIndex;
|
|
6
|
-
const monitoring_service_1 = require("../../src/initializers/monitoring.service");
|
|
7
6
|
const src_1 = require("../../src");
|
|
8
7
|
const testProjectionBlurbSync_1 = require("../testImplementations/testProjectionBlurbSync");
|
|
9
8
|
const testFirestoreSync_1 = require("../testImplementations/testFirestoreSync");
|
|
@@ -15,7 +14,6 @@ const metrics_1 = require("../../src/initializers/metrics");
|
|
|
15
14
|
const bluebird_1 = require("bluebird");
|
|
16
15
|
const inversify_config_1 = require("../../src/dependencies/inversify.config");
|
|
17
16
|
const app_module_1 = require("../../src/app.module");
|
|
18
|
-
const monitoring_service_mock_1 = require("../../src/testUtils/mocks/monitoring-service.mock");
|
|
19
17
|
const testCommandHandler_1 = require("../testImplementations/testCommandHandler");
|
|
20
18
|
const testEventHandler_1 = require("../testImplementations/testEventHandler");
|
|
21
19
|
const testFirestoreEventSync_1 = require("../testImplementations/testFirestoreEventSync");
|
|
@@ -29,9 +27,13 @@ async function getTestAppContainer() {
|
|
|
29
27
|
inversify_config_1.appContainer.bind(src_1.TYPES.EventHandler).to(testEventHandler_1.TestEventHandler);
|
|
30
28
|
inversify_config_1.appContainer.bind(testEventHandler_1.TestEventHandler).to(testEventHandler_1.TestEventHandler);
|
|
31
29
|
crud_1.CrudHandlerFactory.bind(inversify_config_1.appContainer, testCrud_1.ExampleProjection);
|
|
32
|
-
inversify_config_1.appContainer
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
crud_1.CrudHandlerFactory.bind(inversify_config_1.appContainer, testCrud_1.CreationRequestProjection, [
|
|
31
|
+
"create",
|
|
32
|
+
]);
|
|
33
|
+
crud_1.CrudHandlerFactory.bind(inversify_config_1.appContainer, testCrud_1.CreationRequestProjectionEnvelope, [
|
|
34
|
+
"create",
|
|
35
|
+
]);
|
|
36
|
+
crud_1.CrudHandlerFactory.bind(inversify_config_1.appContainer, testCrud_1.CreationRequestArray, ["create"]);
|
|
35
37
|
[
|
|
36
38
|
testFirestoreSync_1.TestFirestoreSet,
|
|
37
39
|
testFirestoreSync_1.TestFirestoreUpdate,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../test/tests/common.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../test/tests/common.ts"],"names":[],"mappings":";;AAsCA,kDAmCC;AAED,gEAKC;AAED,oEAIC;AArFD,mCAKmB;AACnB,4FAGwD;AACxD,gFAKkD;AAClD,iCAAiC;AACjC,mCAA8B;AAC9B,+BAA8B;AAC9B,mCAA8B;AAC9B,4DAAuE;AACvE,uCAAmC;AACnC,8EAAuE;AACvE,qDAAiD;AACjD,kFAA+E;AAC/E,8EAA2E;AAC3E,0FAA2F;AAC3F,8DAKyC;AACzC,kDAA6D;AAE7D,IAAI,SAAoB,CAAC;AAElB,KAAK,UAAU,mBAAmB;IACvC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,IAAA,0BAAoB,EAAC,+BAAY,CAAC,CAAC;QACnC,+BAAY,CAAC,IAAI,CAAC,WAAK,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,uCAAkB,CAAC,CAAC;QAC/D,+BAAY,CAAC,IAAI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: { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const class_validator_1 = require("class-validator");
|
|
4
7
|
const class_transformer_1 = require("class-transformer");
|
|
@@ -12,6 +15,7 @@ const assert_1 = require("assert");
|
|
|
12
15
|
const createProjectionHandler_1 = require("../../../src/handlers/crud/createProjectionHandler");
|
|
13
16
|
const createUpdateProjectionHandler_1 = require("../../../src/handlers/crud/createUpdateProjectionHandler");
|
|
14
17
|
const errors_1 = require("../../../src/clients/openSearch/errors");
|
|
18
|
+
const haversine_distance_1 = __importDefault(require("haversine-distance"));
|
|
15
19
|
function doValidate(e, type, expectedError) {
|
|
16
20
|
const instance = (0, class_transformer_1.plainToInstance)(type, e);
|
|
17
21
|
const errors = (0, class_validator_1.validateSync)(instance);
|
|
@@ -80,6 +84,93 @@ describe("Abstract CRUD handler", () => {
|
|
|
80
84
|
...testCrud_1.exampleProjection,
|
|
81
85
|
});
|
|
82
86
|
});
|
|
87
|
+
it("Should allow a custom creationRequest", async () => {
|
|
88
|
+
const creationRequestEntityId = (0, crypto_1.randomUUID)();
|
|
89
|
+
const creationRequestProjection = await deps.projectionRepository.putItem({
|
|
90
|
+
companyId: deps.companyId,
|
|
91
|
+
projectionType: "creationRequestProjection",
|
|
92
|
+
entityId: creationRequestEntityId,
|
|
93
|
+
payload: {
|
|
94
|
+
companyId: deps.companyId,
|
|
95
|
+
id: creationRequestEntityId,
|
|
96
|
+
name: "Requested Projection Name",
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
const { id } = await deps.rpc("createCreationRequestProjection", {
|
|
100
|
+
companyId: deps.companyId,
|
|
101
|
+
requestedId: creationRequestEntityId,
|
|
102
|
+
});
|
|
103
|
+
const projection = await deps.projectionRepository.loadItem({
|
|
104
|
+
companyId: deps.companyId,
|
|
105
|
+
projectionType: "creationRequestProjection",
|
|
106
|
+
entityId: id,
|
|
107
|
+
});
|
|
108
|
+
(0, chai_1.expect)(projection.payload).to.deep.equal(creationRequestProjection.payload);
|
|
109
|
+
});
|
|
110
|
+
it("Should allow a nested custom creationRequest", async () => {
|
|
111
|
+
const creationRequestEntityId = (0, crypto_1.randomUUID)();
|
|
112
|
+
const creationRequestProjection = await deps.projectionRepository.putItem({
|
|
113
|
+
companyId: deps.companyId,
|
|
114
|
+
projectionType: "creationRequestProjection",
|
|
115
|
+
entityId: creationRequestEntityId,
|
|
116
|
+
payload: {
|
|
117
|
+
companyId: deps.companyId,
|
|
118
|
+
id: creationRequestEntityId,
|
|
119
|
+
name: "Requested Projection Name",
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
const { id } = await deps.rpc("createCreationRequestProjectionEnvelope", {
|
|
123
|
+
companyId: deps.companyId,
|
|
124
|
+
projection: {
|
|
125
|
+
companyId: deps.companyId,
|
|
126
|
+
requestedId: creationRequestEntityId,
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
const projection = await deps.projectionRepository.loadItem({
|
|
130
|
+
companyId: deps.companyId,
|
|
131
|
+
projectionType: "creationRequestProjectionEnvelope",
|
|
132
|
+
entityId: id,
|
|
133
|
+
});
|
|
134
|
+
(0, chai_1.expect)(projection.payload).to.deep.equal({
|
|
135
|
+
companyId: deps.companyId,
|
|
136
|
+
id,
|
|
137
|
+
projection: creationRequestProjection.payload,
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
it("Should allow an array of creationRequests", async () => {
|
|
141
|
+
const projections = [];
|
|
142
|
+
for (let i = 0; i < 5; i++) {
|
|
143
|
+
const entityId = (0, crypto_1.randomUUID)();
|
|
144
|
+
const projection = await deps.projectionRepository.putItem({
|
|
145
|
+
companyId: deps.companyId,
|
|
146
|
+
projectionType: "creationRequestProjection",
|
|
147
|
+
entityId,
|
|
148
|
+
payload: {
|
|
149
|
+
companyId: deps.companyId,
|
|
150
|
+
id: entityId,
|
|
151
|
+
name: "Requested Projection Name",
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
projections.push(projection.payload);
|
|
155
|
+
}
|
|
156
|
+
const { id } = await deps.rpc("createCreationRequestArray", {
|
|
157
|
+
companyId: deps.companyId,
|
|
158
|
+
projections: projections.map(({ id }) => ({
|
|
159
|
+
companyId: deps.companyId,
|
|
160
|
+
requestedId: id,
|
|
161
|
+
})),
|
|
162
|
+
});
|
|
163
|
+
const projection = await deps.projectionRepository.loadItem({
|
|
164
|
+
companyId: deps.companyId,
|
|
165
|
+
projectionType: "creationRequestArray",
|
|
166
|
+
entityId: id,
|
|
167
|
+
});
|
|
168
|
+
(0, chai_1.expect)(projection.payload).to.deep.equal({
|
|
169
|
+
companyId: deps.companyId,
|
|
170
|
+
id,
|
|
171
|
+
projections,
|
|
172
|
+
});
|
|
173
|
+
});
|
|
83
174
|
});
|
|
84
175
|
describe("updateProjectionHandler", () => {
|
|
85
176
|
let entityId;
|
|
@@ -133,7 +224,7 @@ describe("Abstract CRUD handler", () => {
|
|
|
133
224
|
mandatoryNumber: 100,
|
|
134
225
|
},
|
|
135
226
|
}, exports_1.RpcResponseStatus.Error);
|
|
136
|
-
(0, chai_1.expect)(errorMessage).to.contain("
|
|
227
|
+
(0, chai_1.expect)(errorMessage).to.contain(".mandatoryNumber");
|
|
137
228
|
const projection = await deps.projectionRepository.loadItem({
|
|
138
229
|
companyId: deps.companyId,
|
|
139
230
|
projectionType: "exampleProjection",
|
|
@@ -175,15 +266,23 @@ describe("Abstract CRUD handler", () => {
|
|
|
175
266
|
describe("searchProjectionHandler", () => {
|
|
176
267
|
let entityIds;
|
|
177
268
|
let projections;
|
|
269
|
+
const lat0 = 75.0;
|
|
270
|
+
const lon0 = 40.71;
|
|
271
|
+
function getPoint(i) {
|
|
272
|
+
return [lat0 + i / 1000, lon0 + i / 1000];
|
|
273
|
+
}
|
|
178
274
|
async function putProjection(i) {
|
|
179
275
|
const entityId = (0, crypto_1.randomUUID)();
|
|
180
276
|
entityIds.push(entityId);
|
|
277
|
+
const [lat, lon] = getPoint(i);
|
|
181
278
|
const projection = await deps.projectionRepository.putItem({
|
|
182
279
|
companyId: deps.companyId,
|
|
183
280
|
projectionType: "exampleProjection",
|
|
184
281
|
entityId,
|
|
185
282
|
payload: {
|
|
186
283
|
id: entityId,
|
|
284
|
+
latLon: `${lat},${lon}`,
|
|
285
|
+
latLonObject: { lat, lon },
|
|
187
286
|
mandatoryEditableObject: {
|
|
188
287
|
optionalEditableString: `sorting by ${(0, crypto_1.randomInt)(1000)}`,
|
|
189
288
|
mandatoryEditableString: `test value ${i}`,
|
|
@@ -311,7 +410,10 @@ describe("Abstract CRUD handler", () => {
|
|
|
311
410
|
} while (continuationToken);
|
|
312
411
|
(0, chai_1.expect)(results).to.deep.equal(sortByQuery(getExpectedResults(projections)));
|
|
313
412
|
});
|
|
314
|
-
it("Should paginate over a point-in-time snapshot", async ()
|
|
413
|
+
it("Should paginate over a point-in-time snapshot", async function () {
|
|
414
|
+
if (deps.openSearch.isFakeClient) {
|
|
415
|
+
this.skip();
|
|
416
|
+
}
|
|
315
417
|
const results = [];
|
|
316
418
|
let continuationToken;
|
|
317
419
|
let i = 10;
|
|
@@ -329,7 +431,10 @@ describe("Abstract CRUD handler", () => {
|
|
|
329
431
|
} while (continuationToken);
|
|
330
432
|
(0, chai_1.expect)(sortById(results)).to.deep.equal(sortById(getExpectedResults(projections)));
|
|
331
433
|
});
|
|
332
|
-
it("Should delete the point-in-time search when results are exhausted", async ()
|
|
434
|
+
it("Should delete the point-in-time search when results are exhausted", async function () {
|
|
435
|
+
if (deps.openSearch.isFakeClient) {
|
|
436
|
+
this.skip();
|
|
437
|
+
}
|
|
333
438
|
let firstContinuationToken;
|
|
334
439
|
let continuationToken;
|
|
335
440
|
do {
|
|
@@ -394,6 +499,49 @@ describe("Abstract CRUD handler", () => {
|
|
|
394
499
|
} while (continuationToken);
|
|
395
500
|
(0, chai_1.expect)(sortById(results)).to.deep.equal(sortById(getExpectedResults(projections)));
|
|
396
501
|
});
|
|
502
|
+
describe("Geospatial", async () => {
|
|
503
|
+
it("Should find entries by distance", async () => {
|
|
504
|
+
const fourthDistance = (0, haversine_distance_1.default)({ lat: lat0, lon: lon0 }, { lat: getPoint(3)[0], lon: getPoint(3)[1] });
|
|
505
|
+
const fifthDistance = (0, haversine_distance_1.default)({ lat: lat0, lon: lon0 }, { lat: getPoint(4)[0], lon: getPoint(4)[1] });
|
|
506
|
+
const maxDistance = (fourthDistance + fifthDistance) / 2;
|
|
507
|
+
const units = "meters";
|
|
508
|
+
const { results } = await doSearch({
|
|
509
|
+
query: {
|
|
510
|
+
latLonObject: {
|
|
511
|
+
distance: maxDistance,
|
|
512
|
+
units,
|
|
513
|
+
lat: lat0,
|
|
514
|
+
lon: lon0,
|
|
515
|
+
},
|
|
516
|
+
},
|
|
517
|
+
limit: 5,
|
|
518
|
+
});
|
|
519
|
+
(0, chai_1.expect)(results.length).to.equal(4);
|
|
520
|
+
for (const result of results) {
|
|
521
|
+
const distance = (0, haversine_distance_1.default)({ lat: lat0, lon: lon0 }, result.latLonObject);
|
|
522
|
+
(0, chai_1.expect)(distance).to.be.lessThan(maxDistance);
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
it("Should find entries by bounding box", async () => {
|
|
526
|
+
const { results } = await doSearch({
|
|
527
|
+
query: {
|
|
528
|
+
latLonObject: {
|
|
529
|
+
top: lat0 + 1.2,
|
|
530
|
+
left: lon0,
|
|
531
|
+
bottom: lat0,
|
|
532
|
+
right: lon0 + 1.5,
|
|
533
|
+
},
|
|
534
|
+
},
|
|
535
|
+
});
|
|
536
|
+
(0, chai_1.expect)(results).to.not.be.empty;
|
|
537
|
+
for (const result of results) {
|
|
538
|
+
(0, chai_1.expect)(result.latLonObject.lat).to.be.greaterThanOrEqual(lat0);
|
|
539
|
+
(0, chai_1.expect)(result.latLonObject.lat).to.be.lessThanOrEqual(lat0 + 1.5);
|
|
540
|
+
(0, chai_1.expect)(result.latLonObject.lon).to.be.greaterThanOrEqual(lon0);
|
|
541
|
+
(0, chai_1.expect)(result.latLonObject.lon).to.be.lessThanOrEqual(lon0 + 1.5);
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
});
|
|
397
545
|
});
|
|
398
546
|
describe("getProjectionHandler", async () => {
|
|
399
547
|
function getProjection(id) {
|
|
@@ -490,5 +638,24 @@ describe("Abstract CRUD handler", () => {
|
|
|
490
638
|
(0, chai_1.expect)(missing).to.deep.equal(ids);
|
|
491
639
|
});
|
|
492
640
|
});
|
|
641
|
+
describe("SchemaHandler", () => {
|
|
642
|
+
[
|
|
643
|
+
["get", "getExampleProjectionSchema"],
|
|
644
|
+
["get-multiple", "getExampleProjectionsSchema"],
|
|
645
|
+
["create", "createExampleProjectionSchema"],
|
|
646
|
+
["update", "updateExampleProjectionSchema"],
|
|
647
|
+
["delete", "deleteExampleProjectionSchema"],
|
|
648
|
+
["search", "searchExampleProjectionsSchema"],
|
|
649
|
+
["create-with-request", "createCreationRequestProjectionSchema"],
|
|
650
|
+
[
|
|
651
|
+
"create-with-nested-request",
|
|
652
|
+
"createCreationRequestProjectionEnvelopeSchema",
|
|
653
|
+
],
|
|
654
|
+
].forEach(([action, routingKey]) => {
|
|
655
|
+
it(`Should fetch the ${action} schema for a projection`, async () => {
|
|
656
|
+
const { requestSchema, responseSchema } = await deps.rpc(routingKey, {});
|
|
657
|
+
});
|
|
658
|
+
});
|
|
659
|
+
});
|
|
493
660
|
});
|
|
494
661
|
//# sourceMappingURL=crudHandlers.spec.js.map
|