@mavenmachines/event-handler-lib 1.4.0-rc.9 → 1.4.1-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 +162 -4
- package/dist/config/default.d.ts +3 -1
- package/dist/config/default.js +3 -1
- package/dist/config/default.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/clients/eventLogService.d.ts +4 -16
- package/dist/src/clients/eventLogService.js +4 -7
- package/dist/src/clients/eventLogService.js.map +1 -1
- package/dist/src/clients/kafka/kafkaEventConsumer.js +1 -1
- package/dist/src/clients/mysqlClient.js.map +1 -1
- package/dist/src/clients/openSearch/errors.d.ts +11 -0
- package/dist/src/clients/openSearch/errors.js +20 -0
- package/dist/src/clients/openSearch/errors.js.map +1 -0
- package/dist/src/clients/openSearch/mappings.d.ts +6 -0
- package/dist/src/clients/openSearch/mappings.js +54 -0
- package/dist/src/clients/openSearch/mappings.js.map +1 -0
- package/dist/src/clients/openSearch/openSearchClient.d.ts +7 -4
- package/dist/src/clients/openSearch/openSearchClient.js +76 -61
- package/dist/src/clients/openSearch/openSearchClient.js.map +1 -1
- package/dist/src/clients/redisClient.js.map +1 -1
- package/dist/src/configs/companyConfiguration.d.ts +4 -4
- package/dist/src/configs/companyConfiguration.js +33 -19
- package/dist/src/configs/companyConfiguration.js.map +1 -1
- package/dist/src/configs/inversifyConfig.d.ts +0 -1
- package/dist/src/configs/inversifyConfig.js +3 -18
- package/dist/src/configs/inversifyConfig.js.map +1 -1
- package/dist/src/dependencies/inversify.config.js +0 -2
- package/dist/src/dependencies/inversify.config.js.map +1 -1
- package/dist/src/eventHandlers/baseCommandHandler.d.ts +4 -2
- package/dist/src/eventHandlers/baseCommandHandler.js +15 -4
- package/dist/src/eventHandlers/baseCommandHandler.js.map +1 -1
- package/dist/src/eventHandlers/baseEventHandler.d.ts +1 -1
- package/dist/src/eventHandlers/baseEventHandler.js +5 -2
- package/dist/src/eventHandlers/baseEventHandler.js.map +1 -1
- package/dist/src/eventHandlers/baseHandler.js +33 -15
- package/dist/src/eventHandlers/baseHandler.js.map +1 -1
- package/dist/src/eventHandlers/eventHandlingModule.js +1 -1
- package/dist/src/eventHandlers/syncFirestoreEvents.d.ts +16 -0
- package/dist/src/eventHandlers/syncFirestoreEvents.js +94 -0
- package/dist/src/eventHandlers/syncFirestoreEvents.js.map +1 -0
- package/dist/src/exports/rpc.d.ts +2 -0
- package/dist/src/exports/rpc.js +18 -1
- package/dist/src/exports/rpc.js.map +1 -1
- package/dist/src/exports/sourcing.d.ts +1 -0
- package/dist/src/exports/sourcing.js +4 -1
- package/dist/src/exports/sourcing.js.map +1 -1
- package/dist/src/exports/utils.d.ts +1 -0
- package/dist/src/exports/utils.js +3 -1
- package/dist/src/exports/utils.js.map +1 -1
- package/dist/src/helpers/asyncDebugContext.js.map +1 -1
- package/dist/src/helpers/dataStructure.helpers.d.ts +12 -6
- package/dist/src/helpers/dataStructure.helpers.js +40 -14
- package/dist/src/helpers/dataStructure.helpers.js.map +1 -1
- package/dist/src/helpers/plugins/projectionModifierPlugin.js +12 -5
- package/dist/src/helpers/plugins/projectionModifierPlugin.js.map +1 -1
- package/dist/src/helpers/projectionModifier.d.ts +4 -1
- package/dist/src/helpers/projectionModifier.js +8 -4
- package/dist/src/helpers/projectionModifier.js.map +1 -1
- package/dist/src/initializers/metrics.d.ts +5 -0
- package/dist/src/initializers/metrics.js +13 -1
- package/dist/src/initializers/metrics.js.map +1 -1
- package/dist/src/initializers/queue-manager.service.d.ts +4 -4
- package/dist/src/initializers/queue-manager.service.js +56 -8
- package/dist/src/initializers/queue-manager.service.js.map +1 -1
- package/dist/src/repositories/baseFirestoreRepository.js.map +1 -1
- package/dist/src/repositories/projectionRepository.d.ts +1 -1
- package/dist/src/rpc/abstractRpcClient.d.ts +44 -16
- package/dist/src/rpc/abstractRpcClient.js +110 -31
- package/dist/src/rpc/abstractRpcClient.js.map +1 -1
- package/dist/src/rpc/directoryService.rpc.d.ts +18 -0
- package/dist/src/rpc/directoryService.rpc.js +58 -0
- package/dist/src/rpc/directoryService.rpc.js.map +1 -0
- package/dist/src/rpc/returnEventService.rpc.d.ts +3 -4
- package/dist/src/rpc/returnEventService.rpc.js +4 -7
- package/dist/src/rpc/returnEventService.rpc.js.map +1 -1
- package/dist/src/rpc/rpcModule.js.map +1 -1
- package/dist/src/rpc/rpcProtocols.d.ts +47 -9
- package/dist/src/rpc/rpcProtocols.js +122 -17
- package/dist/src/rpc/rpcProtocols.js.map +1 -1
- package/dist/src/testUtils/index.d.ts +1 -0
- package/dist/src/testUtils/index.js +7 -0
- package/dist/src/testUtils/index.js.map +1 -0
- package/dist/src/testUtils/mocks/directoryServiceClient.mock.d.ts +7 -14
- package/dist/src/testUtils/mocks/directoryServiceClient.mock.js +35 -61
- package/dist/src/testUtils/mocks/directoryServiceClient.mock.js.map +1 -1
- package/dist/src/testUtils/mocks/monitoring-service.mock.js +1 -2
- package/dist/src/testUtils/mocks/monitoring-service.mock.js.map +1 -1
- package/dist/src/testUtils/testDependencies.d.ts +7 -7
- package/dist/src/testUtils/testDependencies.js +28 -44
- package/dist/src/testUtils/testDependencies.js.map +1 -1
- package/dist/src/types/eventSourcedEvent.type.d.ts +4 -1
- package/dist/src/types/eventSourcedEvent.type.js +15 -0
- package/dist/src/types/eventSourcedEvent.type.js.map +1 -1
- package/dist/test/testImplementations/testCommandHandler.d.ts +14 -0
- package/dist/test/testImplementations/testCommandHandler.js +55 -0
- package/dist/test/testImplementations/testCommandHandler.js.map +1 -0
- package/dist/test/testImplementations/testEventHandler.d.ts +20 -0
- package/dist/test/testImplementations/testEventHandler.js +115 -0
- package/dist/test/testImplementations/testEventHandler.js.map +1 -0
- package/dist/test/testImplementations/testFirestoreEventSync.d.ts +18 -0
- package/dist/test/testImplementations/testFirestoreEventSync.js +27 -0
- package/dist/test/testImplementations/testFirestoreEventSync.js.map +1 -0
- package/dist/test/testImplementations/testFirestoreSync.js.map +1 -1
- package/dist/test/tests/clients/companyConfiguration.spec.d.ts +1 -0
- package/dist/test/tests/clients/companyConfiguration.spec.js +70 -0
- package/dist/test/tests/clients/companyConfiguration.spec.js.map +1 -0
- package/dist/test/tests/clients/kafkaEventConsumer.spec.js +2 -1
- package/dist/test/tests/clients/kafkaEventConsumer.spec.js.map +1 -1
- package/dist/test/tests/clients/mysql.client.spec.js.map +1 -1
- package/dist/test/tests/clients/opensearch.client.spec.d.ts +1 -0
- package/dist/test/tests/clients/opensearch.client.spec.js +134 -0
- package/dist/test/tests/clients/opensearch.client.spec.js.map +1 -0
- package/dist/test/tests/common.d.ts +1 -30
- package/dist/test/tests/common.js +8 -169
- package/dist/test/tests/common.js.map +1 -1
- package/dist/test/tests/eventHandlers/baseEventHandler.spec.js +39 -17
- package/dist/test/tests/eventHandlers/baseEventHandler.spec.js.map +1 -1
- package/dist/test/tests/eventHandlers/firestoreEventSyncHandler.spec.d.ts +1 -0
- package/dist/test/tests/eventHandlers/firestoreEventSyncHandler.spec.js +75 -0
- package/dist/test/tests/eventHandlers/firestoreEventSyncHandler.spec.js.map +1 -0
- package/dist/test/tests/helpers/dataStructure.helpers.spec.js +59 -0
- package/dist/test/tests/helpers/dataStructure.helpers.spec.js.map +1 -1
- package/dist/test/tests/helpers/syncFirestore.spec.js +2 -1
- package/dist/test/tests/helpers/syncFirestore.spec.js.map +1 -1
- package/dist/test/tests/helpers/syncOpensearch.spec.js +4 -3
- package/dist/test/tests/helpers/syncOpensearch.spec.js.map +1 -1
- package/dist/test/tests/helpers/syncProjectionBlurbs.spec.js +2 -1
- package/dist/test/tests/helpers/syncProjectionBlurbs.spec.js.map +1 -1
- package/package.json +1 -1
- package/dist/src/rpc/mockRpcClient.d.ts +0 -0
- package/dist/src/rpc/mockRpcClient.js +0 -2
- package/dist/src/rpc/mockRpcClient.js.map +0 -1
package/README.md
CHANGED
|
@@ -82,19 +82,18 @@ library, it will fall back to using that port instead.
|
|
|
82
82
|
## Implement an Event Handler
|
|
83
83
|
|
|
84
84
|
```
|
|
85
|
-
import { BaseEventHandler, EventHandlerContext
|
|
85
|
+
import { BaseEventHandler, EventHandlerContext } from "@mavenmachines/event-handler-lib";
|
|
86
86
|
import { inject, injectable } from "inversify";
|
|
87
87
|
|
|
88
88
|
@injectable()
|
|
89
89
|
export class MyEventHandler1 extends BaseEventHandler<MyEventPayloadType> {
|
|
90
90
|
eventType = "myEventType"
|
|
91
|
-
|
|
91
|
+
classValidatorType = MyEventPayloadType
|
|
92
92
|
|
|
93
93
|
constructor(
|
|
94
|
-
@inject(EventHandlerDependencies) eventHandlerDependencies: EventHandlerDependencies,
|
|
95
94
|
@inject(MyOtherDep) private otherDependency: MyOtherDep
|
|
96
95
|
) {
|
|
97
|
-
super(
|
|
96
|
+
super()
|
|
98
97
|
}
|
|
99
98
|
|
|
100
99
|
protected async handleEvent(context: EventHandlerContext<MyEventPayloadType>): Promise<void> {
|
|
@@ -111,6 +110,165 @@ export class MyEventHandler1 extends BaseEventHandler<MyEventPayloadType> {
|
|
|
111
110
|
}
|
|
112
111
|
```
|
|
113
112
|
|
|
113
|
+
## Implement a Command Handler
|
|
114
|
+
|
|
115
|
+
Command Handlers should inherit BaseCommandHandler and use the CommandHandlerContext. To mirror
|
|
116
|
+
the existing Maven service configurations, the `rpc` field should match an entry in
|
|
117
|
+
`config/bindingKeys.config.json`.
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
import { BaseCommandHandler, CommandHandlerContext } from "@mavenmachines/event-handler-lib";
|
|
121
|
+
import { inject, injectable } from "inversify";
|
|
122
|
+
|
|
123
|
+
@injectable()
|
|
124
|
+
export class MyCommandHandler extends BaseCommandHandler<MyRequestType, MyResponseType> {
|
|
125
|
+
rpc = "myRpcBindingKey";
|
|
126
|
+
classValidatorType = MyRequestType;
|
|
127
|
+
|
|
128
|
+
protected async handleCommand(context: CommandHandlerContext<MyRequestType>): Promise<MyResponseType> {
|
|
129
|
+
const {
|
|
130
|
+
command: { companyId },
|
|
131
|
+
payload: {
|
|
132
|
+
payloadField
|
|
133
|
+
}
|
|
134
|
+
} = context;
|
|
135
|
+
|
|
136
|
+
// perform command handling actions
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Implement a Query Handler
|
|
143
|
+
|
|
144
|
+
The final type of request in Event Sourcing is the Query, which is a request that does not perform
|
|
145
|
+
any actions/side-effects, but gives information about the state of the system.
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
import { AbstractRpcHandler } from "@mavenmachines/event-handler-lib";
|
|
149
|
+
import { inject, injectable } from "inversify"
|
|
150
|
+
|
|
151
|
+
@injectable()
|
|
152
|
+
export class MyQueryEndpoint extends AbstractRpcHandler<
|
|
153
|
+
MyQueryRequestType,
|
|
154
|
+
MyQueryResponseType
|
|
155
|
+
> {
|
|
156
|
+
rpc = "myQueryBindingKey";
|
|
157
|
+
// If these are provided, the responses will be instantiated / validated with class-transformer / class-validator
|
|
158
|
+
requestClass = MyQueryRequestType;
|
|
159
|
+
responseClass = MyQueryResponseType;
|
|
160
|
+
|
|
161
|
+
async handler(
|
|
162
|
+
request: MyQueryRequestType
|
|
163
|
+
): Promise<MyQueryResponseType> {
|
|
164
|
+
// implement query
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Similarly to the CommandHandlers, Query Handlers require an entry in
|
|
170
|
+
`bindingKeys.config.json`. To perform tests using `TestDependencies.rpc`, a test
|
|
171
|
+
binding key is not necessary, as one will be bound for you automatically.
|
|
172
|
+
|
|
173
|
+
## Implement an RPC Service Client
|
|
174
|
+
|
|
175
|
+
To contact external Maven services, there is an `AbstractRpcClient` base class.
|
|
176
|
+
Because historical Maven services have different envelopes for their requests
|
|
177
|
+
and responses, the class can be configured with an `RpcMessageProtocol` that
|
|
178
|
+
defines how to determine protocol-level information from a given request or
|
|
179
|
+
response (e.g., status, errorKey, errorMessage, payload).
|
|
180
|
+
|
|
181
|
+
By default, this class will use the `UnknownRpcProtocol`, which will attempt to
|
|
182
|
+
infer the structure automatically. Since this is error-prone and inefficient,
|
|
183
|
+
it will warn and suggest the proper handling methods.
|
|
184
|
+
|
|
185
|
+
For services built on top of `typescript-service-template`, there is a
|
|
186
|
+
`TypescriptServiceTemplateRpcProtocol`. Other historical services have example
|
|
187
|
+
protocols, such as `PdRoutesServiceRpcProtocol`, which are named after their
|
|
188
|
+
first found example. These may be subject to rename in the future, as this is
|
|
189
|
+
an unsustainable practice.
|
|
190
|
+
|
|
191
|
+
To create an RPC method, you simply need to call the `rpcEndpoint` helper method,
|
|
192
|
+
providing the full rabbitMQ routing key, and optionally providing the request and
|
|
193
|
+
response classes:
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
export class MyRpcServiceClient extends AbstractRpcClient<RequestT, ResponseT> {
|
|
197
|
+
|
|
198
|
+
someMethod = this.rpcEndpoint<RequestT, ResponseT>(
|
|
199
|
+
"myService.otherService.method.name",
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
// optionally, you can provide a class for message validation:
|
|
203
|
+
typeSafeMethod = this.rpcEndpoint<RequestT, ResponseT>(
|
|
204
|
+
"myService.otherService.other.method.name",
|
|
205
|
+
RequestT,
|
|
206
|
+
ResponseT,
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
// If you need to delegate to another service client, such as a shared caching
|
|
210
|
+
// helper, a function can be provided in lieu of the binding key:
|
|
211
|
+
|
|
212
|
+
constructor(private readonly otherService: SharedServiceClient) {}
|
|
213
|
+
|
|
214
|
+
myDelegatedMethod = this.rpcEndpoint(
|
|
215
|
+
async ({ companyId, customerId }: { companyId: number, customerId: number }) => {
|
|
216
|
+
return await this.otherService.someMethod(companyId, customerId);
|
|
217
|
+
}
|
|
218
|
+
)
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
To simplify configuration and avoid issues, these helpers will automatically inject their own Routing Keys, and therefore do not need an entry in `config/routingKeys.config.json`.
|
|
223
|
+
|
|
224
|
+
Additionally, these methods are self-mocking:
|
|
225
|
+
|
|
226
|
+
```
|
|
227
|
+
// common.ts
|
|
228
|
+
|
|
229
|
+
export class TestDependencies extends BaseTestDependencies {
|
|
230
|
+
constructor(
|
|
231
|
+
baseDeps: BaseTestDependencies,
|
|
232
|
+
public readonly myRpcClient: MyRpcServiceClient,
|
|
233
|
+
) {
|
|
234
|
+
super(...baseDeps.baseConstructorDeps());
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
async beforeEach() {
|
|
238
|
+
await super.beforeEach();
|
|
239
|
+
// This method will return a constant response
|
|
240
|
+
this.myRpcClient.someMethod.mock(this.sandbox, { value: 1, otherValue: 2 });
|
|
241
|
+
|
|
242
|
+
// This method will return a constant error
|
|
243
|
+
this.myRpcClient.someOtherMethod.mock(this.sandbox, {
|
|
244
|
+
errorKey: "ERROR_KEY",
|
|
245
|
+
errorMessage: "Constant Error Message",
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
// This method will call a fake
|
|
249
|
+
this.myRpcClient.yetAnotherMethod.mock(this.sandbox, (request) => {
|
|
250
|
+
if (request.shouldError) {
|
|
251
|
+
throw new MockRpcResponseError("ERROR_KEY", "Constant Error Message")
|
|
252
|
+
}
|
|
253
|
+
value: getValue(),
|
|
254
|
+
otherValue: getOtherValue()
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Within test
|
|
260
|
+
|
|
261
|
+
describe("", () => {
|
|
262
|
+
let deps: TestDependencies;
|
|
263
|
+
|
|
264
|
+
it("", async () => {
|
|
265
|
+
// ....
|
|
266
|
+
expect(deps.myRpcClient.someMethod.stub.callCount).to.equal(1);
|
|
267
|
+
})
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
```
|
|
271
|
+
|
|
114
272
|
### Projection Repository
|
|
115
273
|
|
|
116
274
|
The `projectionRepository` is an instance of the `BaseEventHandler` class (TODO: should probably move to `EventContext`). It is primarily used for loading projections, as any modifications or creation will be done using the Projection Modifier.
|
package/dist/config/default.d.ts
CHANGED
package/dist/config/default.js
CHANGED
|
@@ -52,7 +52,9 @@ exports.default = {
|
|
|
52
52
|
prefetch: +(process.env.rabbitmq_prefetch || 10),
|
|
53
53
|
autoDeleteQueue: process.env.rabbitmq_autodelete === "true",
|
|
54
54
|
disableLogging: process.env.rabbitmq_disablelogging === "true",
|
|
55
|
-
bindingKeys: {
|
|
55
|
+
bindingKeys: {
|
|
56
|
+
testRpcRequest: "#.eventHandlerLib.test.rpcRequest",
|
|
57
|
+
},
|
|
56
58
|
routingKey: {},
|
|
57
59
|
},
|
|
58
60
|
monitoring: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../config/default.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0EAAuE;AACvE,+CAAiC;AAEjC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;AAEjC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9B,IAAI,EAAE,uBAAuB,GAAG,EAAE;CACnC,CAAC,CAAC;AAEH,IAAI,KAAK,EAAE,CAAC;IACV,MAAM,KAAK,CAAC;AACd,CAAC;AAED,kBAAe;IACb,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW;IACpC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI;IACtB,QAAQ,EAAE;QACR,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,kBAAkB;QACrD,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,aAAa;QACxD,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,mBAAmB;QACxD,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,EAAE,CAAC;QAChD,eAAe,EAAE,OAA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kB,EAAlB,uCAAkB;CACnB,CAAC"}
|
package/dist/package.json
CHANGED
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
import { EventDeclaration } from "../types/eventSourcedEvent.type";
|
|
2
2
|
import { AbstractRpcClient } from "../rpc/abstractRpcClient";
|
|
3
|
+
import { TypescriptServiceTemplateRpcProtocol } from "../rpc/rpcProtocols";
|
|
3
4
|
export declare class EventLogServiceRpc extends AbstractRpcClient {
|
|
4
|
-
|
|
5
|
-
addNewEvent: (
|
|
5
|
+
rpcProtocolClass: typeof TypescriptServiceTemplateRpcProtocol;
|
|
6
|
+
addNewEvent: import("../rpc/abstractRpcClient").RpcEndpoint<EventDeclaration, {
|
|
6
7
|
eventId: string;
|
|
7
|
-
}
|
|
8
|
-
mock: (sandbox: import("sinon").SinonSandbox, value: {
|
|
9
|
-
eventId: string;
|
|
10
|
-
} | {
|
|
11
|
-
errorKey: string;
|
|
12
|
-
errorMessage: string;
|
|
13
|
-
} | ((request: EventDeclaration) => {
|
|
14
|
-
eventId: string;
|
|
15
|
-
} | Promise<{
|
|
16
|
-
eventId: string;
|
|
17
|
-
}>)) => import("sinon").SinonStub<[request: EventDeclaration], Promise<{
|
|
18
|
-
eventId: string;
|
|
19
|
-
}>>;
|
|
20
|
-
};
|
|
8
|
+
}>;
|
|
21
9
|
}
|
|
@@ -5,9 +5,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
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
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
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
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
9
|
exports.EventLogServiceRpc = void 0;
|
|
13
10
|
const inversify_1 = require("inversify");
|
|
@@ -15,13 +12,13 @@ const abstractRpcClient_1 = require("../rpc/abstractRpcClient");
|
|
|
15
12
|
const rpcProtocols_1 = require("../rpc/rpcProtocols");
|
|
16
13
|
let EventLogServiceRpc = class EventLogServiceRpc extends abstractRpcClient_1.AbstractRpcClient {
|
|
17
14
|
constructor() {
|
|
18
|
-
super(
|
|
19
|
-
this.
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.rpcProtocolClass = rpcProtocols_1.TypescriptServiceTemplateRpcProtocol;
|
|
17
|
+
this.addNewEvent = this.rpcEndpoint("salesService.eventSourcingService.addNewEvent");
|
|
20
18
|
}
|
|
21
19
|
};
|
|
22
20
|
exports.EventLogServiceRpc = EventLogServiceRpc;
|
|
23
21
|
exports.EventLogServiceRpc = EventLogServiceRpc = __decorate([
|
|
24
|
-
(0, inversify_1.injectable)()
|
|
25
|
-
__metadata("design:paramtypes", [])
|
|
22
|
+
(0, inversify_1.injectable)()
|
|
26
23
|
], EventLogServiceRpc);
|
|
27
24
|
//# sourceMappingURL=eventLogService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventLogService.js","sourceRoot":"","sources":["../../../src/clients/eventLogService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"eventLogService.js","sourceRoot":"","sources":["../../../src/clients/eventLogService.ts"],"names":[],"mappings":";;;;;;;;;AAAA,yCAAuC;AAEvC,gEAA6D;AAC7D,sDAA2E;AAGpE,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,qCAAiB;IAAlD;;QACL,qBAAgB,GAAG,mDAAoC,CAAC;QACxD,gBAAW,GAAG,IAAI,CAAC,WAAW,CAC5B,+CAA+C,CAChD,CAAC;IACJ,CAAC;CAAA,CAAA;AALY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,sBAAU,GAAE;GACA,kBAAkB,CAK9B"}
|
|
@@ -1 +1 @@
|
|
|
1
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AsB;iCAAtB,sBAAsB;IADlC,IAAA,sBAAU,GAAE;GACA,sBAAsB,CAIlC;AAGM,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,WAAW;IAC9C,KAAK,CAAC,IAAI;QACR,IAAI,CAAC;YACH,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QACrB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;gBACpC,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,wEAAwE,CACzE,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,MAAM,GAAG,CAAC;YACZ,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAfY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,sBAAU,GAAE;GACA,eAAe,CAe3B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class OpenSearchError extends Error {
|
|
2
|
+
}
|
|
3
|
+
export declare class MappingError extends OpenSearchError {
|
|
4
|
+
}
|
|
5
|
+
export declare class MaxRecursionSanitizationReached extends MappingError {
|
|
6
|
+
readonly limit: number;
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly item: Record<string, any>;
|
|
9
|
+
readonly removedFields: [string, any][];
|
|
10
|
+
constructor(limit: number, name: string, item: Record<string, any>, removedFields: [string, any][]);
|
|
11
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MaxRecursionSanitizationReached = exports.MappingError = exports.OpenSearchError = void 0;
|
|
4
|
+
class OpenSearchError extends Error {
|
|
5
|
+
}
|
|
6
|
+
exports.OpenSearchError = OpenSearchError;
|
|
7
|
+
class MappingError extends OpenSearchError {
|
|
8
|
+
}
|
|
9
|
+
exports.MappingError = MappingError;
|
|
10
|
+
class MaxRecursionSanitizationReached extends MappingError {
|
|
11
|
+
constructor(limit, name, item, removedFields) {
|
|
12
|
+
super(`Maximum depth ${limit} reached indexing ${name}`);
|
|
13
|
+
this.limit = limit;
|
|
14
|
+
this.name = name;
|
|
15
|
+
this.item = item;
|
|
16
|
+
this.removedFields = removedFields;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.MaxRecursionSanitizationReached = MaxRecursionSanitizationReached;
|
|
20
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../src/clients/openSearch/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,eAAgB,SAAQ,KAAK;CAAG;AAA7C,0CAA6C;AAC7C,MAAa,YAAa,SAAQ,eAAe;CAAG;AAApD,oCAAoD;AACpD,MAAa,+BAAgC,SAAQ,YAAY;IAC/D,YACkB,KAAa,EACb,IAAY,EACZ,IAAyB,EACzB,aAA8B;QAE9C,KAAK,CAAC,iBAAiB,KAAK,qBAAqB,IAAI,EAAE,CAAC,CAAC;QALzC,UAAK,GAAL,KAAK,CAAQ;QACb,SAAI,GAAJ,IAAI,CAAQ;QACZ,SAAI,GAAJ,IAAI,CAAqB;QACzB,kBAAa,GAAb,aAAa,CAAiB;IAGhD,CAAC;CACF;AATD,0EASC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BooleanProperty, DateProperty, LongNumberProperty, TextProperty, TypeMapping } from "@opensearch-project/opensearch/api/_types/_common.mapping";
|
|
2
|
+
export declare const NUM_MAPPING: LongNumberProperty;
|
|
3
|
+
export declare const STRING_MAPPING: TextProperty;
|
|
4
|
+
export declare const DATE_MAPPING: DateProperty;
|
|
5
|
+
export declare const BOOLEAN_MAPPING: BooleanProperty;
|
|
6
|
+
export declare const DEFAULT_MAPPING: TypeMapping;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_MAPPING = exports.BOOLEAN_MAPPING = exports.DATE_MAPPING = exports.STRING_MAPPING = exports.NUM_MAPPING = void 0;
|
|
4
|
+
exports.NUM_MAPPING = {
|
|
5
|
+
type: "long",
|
|
6
|
+
};
|
|
7
|
+
exports.STRING_MAPPING = {
|
|
8
|
+
fields: {
|
|
9
|
+
keyword: {
|
|
10
|
+
type: "keyword",
|
|
11
|
+
ignore_above: 256,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
type: "text",
|
|
15
|
+
};
|
|
16
|
+
exports.DATE_MAPPING = {
|
|
17
|
+
type: "date",
|
|
18
|
+
format: "date_time",
|
|
19
|
+
};
|
|
20
|
+
exports.BOOLEAN_MAPPING = {
|
|
21
|
+
type: "boolean",
|
|
22
|
+
};
|
|
23
|
+
exports.DEFAULT_MAPPING = {
|
|
24
|
+
dynamic: "false",
|
|
25
|
+
properties: {
|
|
26
|
+
companyId: exports.NUM_MAPPING,
|
|
27
|
+
companyId_projectionType_entityId: exports.STRING_MAPPING,
|
|
28
|
+
entityId: exports.STRING_MAPPING,
|
|
29
|
+
referenceIds: {
|
|
30
|
+
type: "flat_object",
|
|
31
|
+
},
|
|
32
|
+
traceId: exports.STRING_MAPPING,
|
|
33
|
+
event: {
|
|
34
|
+
type: "object",
|
|
35
|
+
dynamic: "false",
|
|
36
|
+
properties: {
|
|
37
|
+
eventId: exports.STRING_MAPPING,
|
|
38
|
+
eventType: exports.STRING_MAPPING,
|
|
39
|
+
eventKey: exports.STRING_MAPPING,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
command: {
|
|
43
|
+
type: "object",
|
|
44
|
+
dynamic: "false",
|
|
45
|
+
properties: {
|
|
46
|
+
commandId: exports.STRING_MAPPING,
|
|
47
|
+
service: exports.STRING_MAPPING,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
openSearchUpdateTime: exports.DATE_MAPPING,
|
|
51
|
+
isDeleted: exports.BOOLEAN_MAPPING,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=mappings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mappings.js","sourceRoot":"","sources":["../../../../src/clients/openSearch/mappings.ts"],"names":[],"mappings":";;;AAQa,QAAA,WAAW,GAAuB;IAC7C,IAAI,EAAE,MAAM;CACb,CAAC;AAEW,QAAA,cAAc,GAAiB;IAC1C,MAAM,EAAE;QACN,OAAO,EAAE;YACP,IAAI,EAAE,SAAS;YACf,YAAY,EAAE,GAAG;SAClB;KACF;IACD,IAAI,EAAE,MAAM;CACb,CAAC;AAEW,QAAA,YAAY,GAAiB;IACxC,IAAI,EAAE,MAAM;IAEZ,MAAM,EAAE,WAAW;CACpB,CAAC;AAEW,QAAA,eAAe,GAAoB;IAC9C,IAAI,EAAE,SAAS;CAChB,CAAC;AAEW,QAAA,eAAe,GAAgB;IAC1C,OAAO,EAAE,OAAO;IAChB,UAAU,EAAE;QACV,SAAS,EAAE,mBAAW;QACtB,iCAAiC,EAAE,sBAAc;QACjD,QAAQ,EAAE,sBAAc;QACxB,YAAY,EAAE;YACZ,IAAI,EAAE,aAAa;SACpB;QACD,OAAO,EAAE,sBAAc;QACvB,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,OAAO;YAChB,UAAU,EAAE;gBACV,OAAO,EAAE,sBAAc;gBACvB,SAAS,EAAE,sBAAc;gBACzB,QAAQ,EAAE,sBAAc;aACzB;SACF;QACD,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,OAAO;YAChB,UAAU,EAAE;gBACV,SAAS,EAAE,sBAAc;gBACzB,OAAO,EAAE,sBAAc;aACxB;SACF;QACD,oBAAoB,EAAE,oBAAY;QAClC,SAAS,EAAE,uBAAe;KAC3B;CACF,CAAC"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Client } from "@opensearch-project/opensearch";
|
|
2
2
|
import { EventSourcedProjection } from "../../types/eventSourcedProjection.type";
|
|
3
3
|
import { Logger, LoggerService } from "../../initializers/logger.service";
|
|
4
|
-
import { TextProperty } from "@opensearch-project/opensearch/api/_types/_common.mapping";
|
|
5
4
|
import { DistributedLocking } from "../redisClient";
|
|
6
|
-
export declare const STRING_MAPPING: TextProperty;
|
|
7
5
|
declare class BaseOpenSearchClient {
|
|
8
6
|
protected readonly client: Client;
|
|
9
7
|
protected readonly distributedLocking: DistributedLocking;
|
|
@@ -11,10 +9,15 @@ declare class BaseOpenSearchClient {
|
|
|
11
9
|
readonly isConnected: boolean;
|
|
12
10
|
protected readonly logger: Logger;
|
|
13
11
|
}
|
|
14
|
-
export type
|
|
12
|
+
export type AddedIndexFields = {
|
|
13
|
+
openSearchUpdateTime?: string;
|
|
14
|
+
};
|
|
15
|
+
export type ProjectionIndex<T extends Record<string, any> = Record<string, any>> = Pick<EventSourcedProjection<T>, "projectionType" | "entityId" | "companyId" | "payload" | "referenceIds" | "version" | "traceId"> & AddedIndexFields;
|
|
16
|
+
export declare const MAX_OPENSEARCH_SANTIZE_RECURSION = 20;
|
|
15
17
|
export declare class OpenSearchClient extends BaseOpenSearchClient {
|
|
16
18
|
private readonly indexCache;
|
|
17
|
-
indexProjection<T extends Record<string, any>>(projection: EventSourcedProjection<T> | ProjectionIndex<T
|
|
19
|
+
indexProjection<T extends Record<string, any>>(projection: EventSourcedProjection<T> | ProjectionIndex<T>, maxDepth?: number): Promise<void>;
|
|
20
|
+
private indexSanitizedProjection;
|
|
18
21
|
private getIndexName;
|
|
19
22
|
private getAliasName;
|
|
20
23
|
private createAliasedIndex;
|
|
@@ -12,7 +12,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.OpensearchAdminClient = exports.OpenSearchClient = exports.
|
|
15
|
+
exports.OpensearchAdminClient = exports.OpenSearchClient = exports.MAX_OPENSEARCH_SANTIZE_RECURSION = void 0;
|
|
16
16
|
const opensearch_1 = require("@opensearch-project/opensearch");
|
|
17
17
|
const inversify_1 = require("inversify");
|
|
18
18
|
const logger_service_1 = require("../../initializers/logger.service");
|
|
@@ -20,58 +20,13 @@ const opensearch_2 = require("@opensearch-project/opensearch");
|
|
|
20
20
|
const bluebird_1 = require("bluebird");
|
|
21
21
|
const luxon_1 = require("luxon");
|
|
22
22
|
const redisClient_1 = require("../redisClient");
|
|
23
|
+
const lodash_1 = require("lodash");
|
|
24
|
+
const metrics_1 = require("../../initializers/metrics");
|
|
25
|
+
const mappings_1 = require("./mappings");
|
|
26
|
+
const errors_1 = require("./errors");
|
|
27
|
+
const dataStructure_helpers_1 = require("../../helpers/dataStructure.helpers");
|
|
23
28
|
const dashed = (camel) => camel.charAt(0).toLowerCase() +
|
|
24
29
|
camel.slice(1).replace(/[A-Z]/g, (m) => "-" + m.toLowerCase());
|
|
25
|
-
const NUM_MAPPING = {
|
|
26
|
-
type: "long",
|
|
27
|
-
};
|
|
28
|
-
exports.STRING_MAPPING = {
|
|
29
|
-
fields: {
|
|
30
|
-
keyword: {
|
|
31
|
-
type: "keyword",
|
|
32
|
-
ignore_above: 256,
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
type: "text",
|
|
36
|
-
};
|
|
37
|
-
const DATE_MAPPING = {
|
|
38
|
-
type: "date",
|
|
39
|
-
format: "date_time",
|
|
40
|
-
};
|
|
41
|
-
const BOOLEAN_MAPPING = {
|
|
42
|
-
type: "boolean",
|
|
43
|
-
};
|
|
44
|
-
const DEFAULT_MAPPING = {
|
|
45
|
-
dynamic: "false",
|
|
46
|
-
properties: {
|
|
47
|
-
companyId: NUM_MAPPING,
|
|
48
|
-
companyId_projectionType_entityId: exports.STRING_MAPPING,
|
|
49
|
-
entityId: exports.STRING_MAPPING,
|
|
50
|
-
referenceIds: {
|
|
51
|
-
type: "flat_object",
|
|
52
|
-
},
|
|
53
|
-
traceId: exports.STRING_MAPPING,
|
|
54
|
-
event: {
|
|
55
|
-
type: "object",
|
|
56
|
-
dynamic: "false",
|
|
57
|
-
properties: {
|
|
58
|
-
eventId: exports.STRING_MAPPING,
|
|
59
|
-
eventType: exports.STRING_MAPPING,
|
|
60
|
-
eventKey: exports.STRING_MAPPING,
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
command: {
|
|
64
|
-
type: "object",
|
|
65
|
-
dynamic: "false",
|
|
66
|
-
properties: {
|
|
67
|
-
commandId: exports.STRING_MAPPING,
|
|
68
|
-
service: exports.STRING_MAPPING,
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
openSearchUpdateTime: DATE_MAPPING,
|
|
72
|
-
isDeleted: BOOLEAN_MAPPING,
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
30
|
let BaseOpenSearchClient = class BaseOpenSearchClient {
|
|
76
31
|
constructor(loggerService, client, distributedLocking) {
|
|
77
32
|
this.client = client;
|
|
@@ -94,20 +49,63 @@ BaseOpenSearchClient = __decorate([
|
|
|
94
49
|
opensearch_1.Client,
|
|
95
50
|
redisClient_1.DistributedLocking])
|
|
96
51
|
], BaseOpenSearchClient);
|
|
52
|
+
function parseField(error) {
|
|
53
|
+
const reason = error.body.error?.reason;
|
|
54
|
+
if (!reason) {
|
|
55
|
+
throw new Error(`Cannot parse empty error reason: ${JSON.stringify(error)}`);
|
|
56
|
+
}
|
|
57
|
+
const failedToParse = "failed to parse field [";
|
|
58
|
+
if (!reason.startsWith(failedToParse)) {
|
|
59
|
+
throw new Error(`Cannot parse error reason ${reason}`);
|
|
60
|
+
}
|
|
61
|
+
const fieldStartIndex = failedToParse.length;
|
|
62
|
+
const fieldEndIndex = reason.indexOf("]");
|
|
63
|
+
if (fieldEndIndex === -1) {
|
|
64
|
+
throw new Error(`Cannot parse error reason ${reason}`);
|
|
65
|
+
}
|
|
66
|
+
return reason.slice(fieldStartIndex, fieldEndIndex);
|
|
67
|
+
}
|
|
68
|
+
function isMappingError(error) {
|
|
69
|
+
if (!(error instanceof opensearch_2.errors.ResponseError)) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
return error.body.error?.type === "mapper_parsing_exception";
|
|
73
|
+
}
|
|
74
|
+
exports.MAX_OPENSEARCH_SANTIZE_RECURSION = 20;
|
|
97
75
|
class OpenSearchClient extends BaseOpenSearchClient {
|
|
98
76
|
constructor() {
|
|
99
77
|
super(...arguments);
|
|
100
78
|
this.indexCache = new Set();
|
|
101
79
|
}
|
|
102
|
-
async indexProjection(projection) {
|
|
80
|
+
async indexProjection(projection, maxDepth = exports.MAX_OPENSEARCH_SANTIZE_RECURSION) {
|
|
103
81
|
const id = `${projection.companyId}_${projection.projectionType}_${projection.entityId}`;
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
82
|
+
await this.ensureIndex(projection);
|
|
83
|
+
this.logger.info("Updating index for projection", {
|
|
84
|
+
id,
|
|
85
|
+
index: this.getAliasName(projection),
|
|
86
|
+
version: projection.version,
|
|
87
|
+
});
|
|
88
|
+
const [success, removedFields] = await this.indexSanitizedProjection((0, lodash_1.cloneDeep)(projection), id, 0, maxDepth);
|
|
89
|
+
if (!success) {
|
|
90
|
+
throw new errors_1.MaxRecursionSanitizationReached(maxDepth, id, projection, removedFields.sort());
|
|
91
|
+
}
|
|
92
|
+
if (removedFields) {
|
|
93
|
+
this.logger.warn(`Removed ${removedFields.length} from projection`, {
|
|
94
|
+
...(0, lodash_1.pick)(projection, "companyId", "entityId", "projectionType"),
|
|
95
|
+
removedFields,
|
|
110
96
|
});
|
|
97
|
+
(0, metrics_1.incrementTrackedWarning)("removedOpensearch", projection.projectionType);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
this.logger.debug(`Successfully updated index for ${id}`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async indexSanitizedProjection(projection, id, depth, maxDepth) {
|
|
104
|
+
if (depth >= maxDepth) {
|
|
105
|
+
this.logger.error(`Maximum field recursion limit ${maxDepth} reached`, projection);
|
|
106
|
+
return [false, []];
|
|
107
|
+
}
|
|
108
|
+
try {
|
|
111
109
|
await this.client.index({
|
|
112
110
|
id,
|
|
113
111
|
index: this.getAliasName(projection),
|
|
@@ -117,10 +115,25 @@ class OpenSearchClient extends BaseOpenSearchClient {
|
|
|
117
115
|
},
|
|
118
116
|
refresh: true,
|
|
119
117
|
});
|
|
118
|
+
return [true, []];
|
|
120
119
|
}
|
|
121
120
|
catch (err) {
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
if (isMappingError(err)) {
|
|
122
|
+
const fieldPath = parseField(err);
|
|
123
|
+
const [container, field, i] = (0, dataStructure_helpers_1.findLast)(projection, fieldPath);
|
|
124
|
+
const subPath = fieldPath
|
|
125
|
+
.split(".")
|
|
126
|
+
.slice(0, i + 1)
|
|
127
|
+
.join(".");
|
|
128
|
+
this.logger.debug(`Removing field ${subPath} from projection`);
|
|
129
|
+
const value = container[field];
|
|
130
|
+
delete container[field];
|
|
131
|
+
const [success, fields] = await this.indexSanitizedProjection(projection, id, depth + 1, maxDepth);
|
|
132
|
+
return [success, [[fieldPath, value], ...fields]];
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
throw err;
|
|
136
|
+
}
|
|
124
137
|
}
|
|
125
138
|
}
|
|
126
139
|
getIndexName(projection) {
|
|
@@ -144,10 +157,12 @@ class OpenSearchClient extends BaseOpenSearchClient {
|
|
|
144
157
|
}
|
|
145
158
|
const key = projection.projectionType;
|
|
146
159
|
if (this.indexCache.has(key)) {
|
|
160
|
+
this.logger.info(`IndexCache already has ${key}`);
|
|
147
161
|
return;
|
|
148
162
|
}
|
|
149
163
|
const alias = this.getAliasName(projection);
|
|
150
164
|
if (await this.aliasExists(alias)) {
|
|
165
|
+
this.logger.info(`Alias ${alias} already exists`);
|
|
151
166
|
return;
|
|
152
167
|
}
|
|
153
168
|
const index = this.getIndexName(projection);
|
|
@@ -165,7 +180,7 @@ class OpenSearchClient extends BaseOpenSearchClient {
|
|
|
165
180
|
await this.client.indices.create({
|
|
166
181
|
index,
|
|
167
182
|
body: {
|
|
168
|
-
mappings: DEFAULT_MAPPING,
|
|
183
|
+
mappings: mappings_1.DEFAULT_MAPPING,
|
|
169
184
|
},
|
|
170
185
|
});
|
|
171
186
|
}
|