@mavenmachines/event-handler-lib 1.0.1-rc.5 → 1.0.2
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 +84 -0
- package/dist/config/default.d.ts +18 -51
- package/dist/config/default.js +2 -5
- package/dist/config/default.js.map +1 -1
- package/dist/package.json +4 -8
- package/dist/src/clients/amqp/amqpClient.js +5 -1
- package/dist/src/clients/amqp/amqpClient.js.map +1 -1
- package/dist/src/clients/amqp/amqpListener.d.ts +0 -1
- package/dist/src/clients/amqp/amqpListener.js +1 -2
- package/dist/src/clients/amqp/amqpListener.js.map +1 -1
- package/dist/src/configs/dynamoDb.config.d.ts +8 -0
- package/dist/{config/dynamoDbConfig.json → src/configs/dynamoDb.config.js} +6 -2
- package/dist/src/configs/dynamoDb.config.js.map +1 -0
- package/dist/src/configs/firestore.config.d.ts +9 -0
- package/dist/src/configs/firestore.config.js +38 -0
- package/dist/src/configs/firestore.config.js.map +1 -0
- package/dist/src/configs/index.d.ts +22 -0
- package/dist/src/configs/index.js +16 -0
- package/dist/src/configs/index.js.map +1 -0
- package/dist/src/configs/inversifyConfig.d.ts +9 -0
- package/dist/src/configs/inversifyConfig.js +74 -0
- package/dist/src/configs/inversifyConfig.js.map +1 -0
- package/dist/src/configs/node_envs.d.ts +1 -0
- package/dist/src/configs/node_envs.js +3 -0
- package/dist/src/configs/node_envs.js.map +1 -0
- package/dist/src/configs/redis.config.d.ts +9 -0
- package/dist/src/configs/redis.config.js +66 -0
- package/dist/src/configs/redis.config.js.map +1 -0
- package/dist/src/dependencies/index.d.ts +1 -0
- package/dist/src/dependencies/index.js +18 -0
- package/dist/src/dependencies/index.js.map +1 -0
- package/dist/src/dependencies/inversify.config.js +6 -2
- package/dist/src/dependencies/inversify.config.js.map +1 -1
- package/dist/src/eventHandlers/baseEventHandler.d.ts +13 -9
- package/dist/src/eventHandlers/baseEventHandler.js +44 -25
- package/dist/src/eventHandlers/baseEventHandler.js.map +1 -1
- package/dist/src/helpers/dynamoDB.client.d.ts +1 -2
- package/dist/src/helpers/dynamoDB.client.js +7 -5
- package/dist/src/helpers/dynamoDB.client.js.map +1 -1
- package/dist/src/helpers/projectionModifier.js +10 -7
- package/dist/src/helpers/projectionModifier.js.map +1 -1
- package/dist/src/index.d.ts +10 -17
- package/dist/src/index.js +10 -34
- package/dist/src/index.js.map +1 -1
- package/dist/src/initializers/index.d.ts +1 -0
- package/dist/src/initializers/index.js +18 -0
- package/dist/src/initializers/index.js.map +1 -0
- package/dist/src/initializers/logger.service.d.ts +6 -6
- package/dist/src/initializers/logger.service.js +42 -12
- package/dist/src/initializers/logger.service.js.map +1 -1
- package/dist/src/libs/firestore/index.d.ts +3 -0
- package/dist/src/libs/firestore/index.js +20 -0
- package/dist/src/libs/firestore/index.js.map +1 -0
- package/dist/src/libs/index.d.ts +1 -0
- package/dist/src/libs/index.js +18 -0
- package/dist/src/libs/index.js.map +1 -0
- package/dist/src/repositories/baseDynamoRepository.d.ts +1 -0
- package/dist/src/repositories/baseDynamoRepository.js +21 -14
- package/dist/src/repositories/baseDynamoRepository.js.map +1 -1
- package/dist/src/repositories/baseFirestoreRepository.d.ts +9 -3
- package/dist/src/repositories/baseFirestoreRepository.js +42 -20
- package/dist/src/repositories/baseFirestoreRepository.js.map +1 -1
- package/dist/src/repositories/projectionRepository.js +3 -1
- package/dist/src/repositories/projectionRepository.js.map +1 -1
- package/dist/src/repositories/stateRepository.d.ts +19 -0
- package/dist/src/repositories/stateRepository.js +93 -0
- package/dist/src/repositories/stateRepository.js.map +1 -0
- package/dist/src/rpc/index.d.ts +1 -0
- package/dist/src/rpc/index.js +18 -0
- package/dist/src/rpc/index.js.map +1 -0
- package/dist/src/rpc/returnEventService.rpc.js +1 -1
- package/dist/src/rpc/returnEventService.rpc.js.map +1 -1
- package/dist/src/types/eventHandler.d.ts +2 -2
- package/dist/src/types/eventSourcedEvent.type.d.ts +12 -3
- package/dist/src/types/eventSourcedEvent.type.js.map +1 -1
- package/dist/src/types/index.d.ts +2 -1
- package/dist/src/types/index.js +1 -0
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/types/rpc/index.d.ts +1 -0
- package/dist/src/types/rpc/index.js +18 -0
- package/dist/src/types/rpc/index.js.map +1 -0
- package/dist/test/tests/repositories/stateRepository.spec.d.ts +1 -0
- package/dist/test/tests/repositories/stateRepository.spec.js +66 -0
- package/dist/test/tests/repositories/stateRepository.spec.js.map +1 -0
- package/package.json +4 -8
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# README #
|
|
2
|
+
|
|
3
|
+
# What is this repository for? #
|
|
4
|
+
|
|
5
|
+
* Provides libraries required for writing a service containing Event Handlers
|
|
6
|
+
|
|
7
|
+
# How do I get set up? #
|
|
8
|
+
|
|
9
|
+
## inversify config
|
|
10
|
+
|
|
11
|
+
To create an inversify container, your `inversify.config.ts` file should include the following:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
import { AppModule } from "../app.module";
|
|
15
|
+
import { EventHandler, TYPES as EVENT_HANDLER_TYPES, bindEventHandlerDeps } from "@mavenmachines/event-handler-lib";
|
|
16
|
+
import { MyEventHandler1, MyEventHandler2 } from "../api/eventHandlers";
|
|
17
|
+
|
|
18
|
+
const appContainer = new Container({ autoBindInjectable: true, defaultScope: "Singleton" });
|
|
19
|
+
|
|
20
|
+
bindEventHandlerDeps(appContainer);
|
|
21
|
+
|
|
22
|
+
appContainer.bind<EventHandler>(EVENT_HANDLER_TYPES.EventHandler).to(MyEventHandler1)
|
|
23
|
+
appContainer.bind<EventHandler>(EVENT_HANDLER_TYPES.EventHandler).to(MyEventHandler2)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Implement an Event Handler
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
import { BaseEventHandler, EventHandlerContext, EventHandlerDependencies } from "@mavenmachines/event-handler-lib";
|
|
30
|
+
import { inject, injectable } from "inversify";
|
|
31
|
+
|
|
32
|
+
@injectable()
|
|
33
|
+
export class MyEventHandler1 extends BaseEventHandler<MyEventPayloadType> {
|
|
34
|
+
name = "My Event Handler's Descriptive Name";
|
|
35
|
+
eventType = "myEventType"
|
|
36
|
+
payloadType = MyEventPayloadType
|
|
37
|
+
|
|
38
|
+
constructor(
|
|
39
|
+
@inject(EventHandlerDependencies) eventHandlerDependencies: EventHandlerDependencies,
|
|
40
|
+
@inject(MyOtherDep) private otherDependency: MyOtherDep
|
|
41
|
+
) {
|
|
42
|
+
super(eventHandlerDependencies)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
protected async handleEvent(context: EventHandlerContext<MyEventPayloadType>): Promise<void> {
|
|
46
|
+
const {
|
|
47
|
+
event: { companyId },
|
|
48
|
+
payload: {
|
|
49
|
+
payloadField
|
|
50
|
+
}
|
|
51
|
+
} = context;
|
|
52
|
+
|
|
53
|
+
// perform event handler actions
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Projection Repository
|
|
60
|
+
|
|
61
|
+
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.
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
const myProjection = this.projectionRepository.load({
|
|
65
|
+
companyId,
|
|
66
|
+
projectionType: "myProjectionType",
|
|
67
|
+
entityId: "myEntityId"
|
|
68
|
+
})
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Projection Modifier
|
|
72
|
+
|
|
73
|
+
The `projectionModifier` object lives in the `EventContext` for a given Event Handler execution. It provides methods to perform basic modifications on the projection, and returns the modified projections. Some important things to note are:
|
|
74
|
+
|
|
75
|
+
1. Modifications to the projection are stored internally within the `ProjectionModifier` class, and are only persisted to DynamoDB on successful execution of the Event Handler. This prevents partially modified projections in the event of failure.
|
|
76
|
+
|
|
77
|
+
2. When performing multiple modifications on a single projection, you must store the returned value of the previous modification, and pass it to the next method invocation. If you fail to do this, you will lose the previous modifications when the projection is written to DynamoDB.
|
|
78
|
+
Additionally, the published modifications will include all operations, causing incorrect state to be reported to the update handlers.
|
|
79
|
+
|
|
80
|
+
3. Modifications to a projection through the `projectionModifier` will trigger a `projection.<ProjectionType>.updated` event to be published for handling changes. For example, a single update handler can be responsible for persisting projection changes to Firestore, sending Return Events, or performing other external operations, regardless of which Event Handler made those changes.
|
|
81
|
+
|
|
82
|
+
### State Repository
|
|
83
|
+
|
|
84
|
+
The `EventContext` object will also include a `.state` field containing a Redis-backed `StateRepository` for handling state that must cross Event Handler invocation boundaries but are too light-weight and/or transient to justify versioned projections in DynamoDB.
|
package/dist/config/default.d.ts
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
+
dynamoDB: {
|
|
3
|
+
region: string;
|
|
4
|
+
endpoint: string;
|
|
5
|
+
eventsTableName: string;
|
|
6
|
+
projectionsTableName: string;
|
|
7
|
+
};
|
|
8
|
+
redis: {
|
|
9
|
+
stateRepository: {
|
|
10
|
+
host: string;
|
|
11
|
+
port: number;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
firestore: {
|
|
15
|
+
projectId?: string;
|
|
16
|
+
host?: string;
|
|
17
|
+
ssl?: boolean;
|
|
18
|
+
secretName?: string;
|
|
19
|
+
};
|
|
2
20
|
environment: string | undefined;
|
|
3
21
|
port: string | undefined;
|
|
4
22
|
rabbitmq: {
|
|
@@ -11,57 +29,6 @@ declare const _default: {
|
|
|
11
29
|
bindingKeys: {};
|
|
12
30
|
routingKey: {};
|
|
13
31
|
};
|
|
14
|
-
dynamoDB: {
|
|
15
|
-
region: string;
|
|
16
|
-
endpoint: string;
|
|
17
|
-
eventsTableName: string;
|
|
18
|
-
projectionsTableName: string;
|
|
19
|
-
} | {
|
|
20
|
-
region: string;
|
|
21
|
-
endpoint: string;
|
|
22
|
-
eventsTableName: string;
|
|
23
|
-
projectionsTableName: string;
|
|
24
|
-
} | {
|
|
25
|
-
region: string;
|
|
26
|
-
endpoint: string;
|
|
27
|
-
eventsTableName: string;
|
|
28
|
-
projectionsTableName: string;
|
|
29
|
-
} | {
|
|
30
|
-
region: string;
|
|
31
|
-
endpoint: string;
|
|
32
|
-
eventsTableName: string;
|
|
33
|
-
projectionsTableName: string;
|
|
34
|
-
} | {
|
|
35
|
-
region: string;
|
|
36
|
-
endpoint: string;
|
|
37
|
-
eventsTableName: string;
|
|
38
|
-
projectionsTableName: string;
|
|
39
|
-
} | {
|
|
40
|
-
region: string;
|
|
41
|
-
endpoint: string;
|
|
42
|
-
eventsTableName: string;
|
|
43
|
-
projectionsTableName: string;
|
|
44
|
-
} | {
|
|
45
|
-
region: string;
|
|
46
|
-
endpoint: string;
|
|
47
|
-
eventsTableName: string;
|
|
48
|
-
projectionsTableName: string;
|
|
49
|
-
} | {
|
|
50
|
-
region: string;
|
|
51
|
-
endpoint: string;
|
|
52
|
-
eventsTableName: string;
|
|
53
|
-
projectionsTableName: string;
|
|
54
|
-
} | {
|
|
55
|
-
region: string;
|
|
56
|
-
endpoint: string;
|
|
57
|
-
eventsTableName: string;
|
|
58
|
-
projectionsTableName: string;
|
|
59
|
-
} | {
|
|
60
|
-
region: string;
|
|
61
|
-
endpoint: string;
|
|
62
|
-
eventsTableName: string;
|
|
63
|
-
projectionsTableName: string;
|
|
64
|
-
};
|
|
65
32
|
monitoring: {
|
|
66
33
|
port: string | undefined;
|
|
67
34
|
};
|
package/dist/config/default.js
CHANGED
|
@@ -32,11 +32,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
const
|
|
36
|
+
const configs_1 = require("../src/configs");
|
|
40
37
|
const dotenv = __importStar(require("dotenv"));
|
|
41
38
|
const env = process.env.NODE_ENV;
|
|
42
39
|
const { error } = dotenv.config({
|
|
@@ -58,9 +55,9 @@ exports.default = {
|
|
|
58
55
|
bindingKeys: {},
|
|
59
56
|
routingKey: {},
|
|
60
57
|
},
|
|
61
|
-
dynamoDB: dynamoDbConfig_json_1.default[env] || {},
|
|
62
58
|
monitoring: {
|
|
63
59
|
port: process.env.monitoring_port || process.env.MONITORING_PORT,
|
|
64
60
|
},
|
|
61
|
+
...configs_1.eventHandlerConfig
|
|
65
62
|
};
|
|
66
63
|
//# sourceMappingURL=default.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../config/default.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../config/default.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAoD;AACpD,+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,OAAO,CAAC,GAAG,CAAC,mBAAmB,KAAK,MAAM;QAC3D,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,uBAAuB,KAAK,MAAM;QAC9D,WAAW,EAAE,EAAE;QACf,UAAU,EAAE,EAAE;KACf;IACD,UAAU,EAAE;QACV,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe;KACjE;IACD,GAAG,4BAAkB;CACtB,CAAC"}
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mavenmachines/event-handler-lib",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Helper libraries for creating an Event Handler",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"module": "./dist/src/index.mjs",
|
|
@@ -20,13 +20,7 @@
|
|
|
20
20
|
"clean": "rm -rf ./dist",
|
|
21
21
|
"test": "NODE_ENV=test nyc mocha --config config/.mocharc.json",
|
|
22
22
|
"format": "npx prettier --write \"*/**/*.ts\"",
|
|
23
|
-
"lint": "npx eslint \"src/**/*.ts\" --fix"
|
|
24
|
-
"db-migrate-create": "NODE_ENV=test db-migrate create --config config/dbMigrateConfig.json --env test",
|
|
25
|
-
"db-migrate-test": "NODE_ENV=test db-migrate up --config config/dbMigrateConfig.json --env test",
|
|
26
|
-
"db-migrate-dev": "NODE_ENV=development ./dbMigrate.sh",
|
|
27
|
-
"db-migrate-qa": "NODE_ENV=qa ./dbMigrate.sh",
|
|
28
|
-
"db-migrate-staging": "NODE_ENV=staging ./dbMigrate.sh",
|
|
29
|
-
"db-migrate-prod": "NODE_ENV=production ./dbMigrate.sh"
|
|
23
|
+
"lint": "npx eslint \"src/**/*.ts\" --fix"
|
|
30
24
|
},
|
|
31
25
|
"repository": {
|
|
32
26
|
"type": "git",
|
|
@@ -66,6 +60,7 @@
|
|
|
66
60
|
"@google-cloud/firestore": "^7.8.0",
|
|
67
61
|
"@mavenmachines/prometheus-nodejs-client": "^1.0.2",
|
|
68
62
|
"@mavenmachines/pump": "^1.5.3",
|
|
63
|
+
"@mavenmachines/redis": "^1.0.11",
|
|
69
64
|
"amqplib": "^0.10.5",
|
|
70
65
|
"bluebird": "^3.7.2",
|
|
71
66
|
"chalk": "^1.1.3",
|
|
@@ -77,6 +72,7 @@
|
|
|
77
72
|
"firebase-admin": "^12.1.1",
|
|
78
73
|
"inversify": "^6.0.2",
|
|
79
74
|
"lodash": "^4.17.21",
|
|
75
|
+
"lru-cache": "^11.0.2",
|
|
80
76
|
"luxon": "^3.5.0",
|
|
81
77
|
"uuid": "^9.0.1",
|
|
82
78
|
"winston": "^3.17.0"
|
|
@@ -24,6 +24,7 @@ const amqpListener_1 = require("./amqpListener");
|
|
|
24
24
|
const logger_service_1 = require("../../initializers/logger.service");
|
|
25
25
|
const crypto_1 = require("crypto");
|
|
26
26
|
const errors_1 = require("./errors");
|
|
27
|
+
const lru_cache_1 = require("lru-cache");
|
|
27
28
|
let AmqpClient = class AmqpClient extends events_1.default {
|
|
28
29
|
constructor(loggerService, host, exchange, queue) {
|
|
29
30
|
super();
|
|
@@ -31,7 +32,10 @@ let AmqpClient = class AmqpClient extends events_1.default {
|
|
|
31
32
|
this.host = host;
|
|
32
33
|
this.exchange = exchange;
|
|
33
34
|
this.queue = queue;
|
|
34
|
-
this.messageResponses = new
|
|
35
|
+
this.messageResponses = new lru_cache_1.LRUCache({
|
|
36
|
+
maxSize: 1000,
|
|
37
|
+
sizeCalculation: () => { return 1; }
|
|
38
|
+
});
|
|
35
39
|
this.predicates = [];
|
|
36
40
|
this.isInitialized = false;
|
|
37
41
|
this.logger = loggerService.getLogger(this);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amqpClient.js","sourceRoot":"","sources":["../../../../src/clients/amqp/amqpClient.ts"],"names":[],"mappings":";;;;;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Y,gCAAU;qBAAV,UAAU;IADtB,IAAA,sBAAU,GAAE;IAsBR,WAAA,IAAA,kBAAM,EAAC,8BAAa,CAAC,CAAA;IACrB,WAAA,IAAA,kBAAM,EAAC,sBAAsB,CAAC,CAAA;IAC9B,WAAA,IAAA,kBAAM,EAAC,0BAA0B,CAAC,CAAA;IAClC,WAAA,IAAA,kBAAM,EAAC,uBAAuB,CAAC,CAAA;qCAHc,8BAAa;GArBlD,UAAU,CAiJtB"}
|
|
@@ -8,7 +8,6 @@ export declare class AmqpListener extends EventEmitter {
|
|
|
8
8
|
private connection;
|
|
9
9
|
private queue;
|
|
10
10
|
readonly EVENT_NAME: string;
|
|
11
|
-
private isInitialized;
|
|
12
11
|
private channels;
|
|
13
12
|
private readonly logger;
|
|
14
13
|
constructor(loggerService: LoggerService, exchange: string, connection: Connection, queue: string);
|
|
@@ -29,7 +29,6 @@ let AmqpListener = class AmqpListener extends events_1.default {
|
|
|
29
29
|
this.connection = connection;
|
|
30
30
|
this.queue = queue;
|
|
31
31
|
this.EVENT_NAME = "messageReceived";
|
|
32
|
-
this.isInitialized = false;
|
|
33
32
|
this.channels = [];
|
|
34
33
|
this.logger = loggerService.getLogger(this);
|
|
35
34
|
}
|
|
@@ -69,7 +68,7 @@ let AmqpListener = class AmqpListener extends events_1.default {
|
|
|
69
68
|
...message,
|
|
70
69
|
content: JSON.parse(message.content.toString()),
|
|
71
70
|
};
|
|
72
|
-
this.logger.info(
|
|
71
|
+
this.logger.info('Emitting message', { message: messageSummary });
|
|
73
72
|
this.emit(this.EVENT_NAME, message);
|
|
74
73
|
}
|
|
75
74
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amqpListener.js","sourceRoot":"","sources":["../../../../src/clients/amqp/amqpListener.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA,oDAAkC;AAClC,sEAA0E;AAC1E,wEAA2D;AAC3D,yCAAmC;AAEnC,qCAAqC;AAErC,IAAa,YAAY,GAAz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AC,QAAQ,EAAE,CAAC;SAChD,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAA;QAEjE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;CACF,CAAA;AA/DY,oCAAY;uBAAZ,YAAY;IAOpB,WAAA,IAAA,kBAAM,EAAC,8BAAa,CAAC,CAAA;IACrB,WAAA,IAAA,kBAAM,EAAC,0BAA0B,CAAC,CAAA;IAClC,WAAA,IAAA,kBAAM,EAAC,uBAAK,CAAC,cAAc,CAAC,CAAA;IAC5B,WAAA,IAAA,kBAAM,EAAC,uBAAuB,CAAC,CAAA;qCAHc,8BAAa;GAPlD,YAAY,CA+DxB"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dynamoDbConfig = void 0;
|
|
4
|
+
exports.dynamoDbConfig = {
|
|
2
5
|
"test": {
|
|
3
6
|
"region": "us-east-1",
|
|
4
7
|
"endpoint": "http://localhost:8000",
|
|
@@ -59,4 +62,5 @@
|
|
|
59
62
|
"eventsTableName": "event-sourcing-event-log-production",
|
|
60
63
|
"projectionsTableName": "event-sourcing-projections-production"
|
|
61
64
|
}
|
|
62
|
-
}
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=dynamoDb.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamoDb.config.js","sourceRoot":"","sources":["../../../src/configs/dynamoDb.config.ts"],"names":[],"mappings":";;;AAQa,QAAA,cAAc,GAAmC;IAC5D,MAAM,EAAE;QACN,QAAQ,EAAE,WAAW;QACrB,UAAU,EAAE,uBAAuB;QACnC,iBAAiB,EAAE,+BAA+B;QAClD,sBAAsB,EAAE,iCAAiC;KAC1D;IACD,OAAO,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";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.firestoreConfig = void 0;
|
|
4
|
+
exports.firestoreConfig = {
|
|
5
|
+
"test": {
|
|
6
|
+
"projectId": "event-sourcing",
|
|
7
|
+
"host": "localhost:8080",
|
|
8
|
+
"ssl": false
|
|
9
|
+
},
|
|
10
|
+
"local": {
|
|
11
|
+
"secretName": "firestore/maven-development"
|
|
12
|
+
},
|
|
13
|
+
"localDev": {
|
|
14
|
+
"secretName": "firestore/maven-development"
|
|
15
|
+
},
|
|
16
|
+
"development": {
|
|
17
|
+
"secretName": "firestore/maven-development"
|
|
18
|
+
},
|
|
19
|
+
"qa": {
|
|
20
|
+
"secretName": "firestore/maven-qa"
|
|
21
|
+
},
|
|
22
|
+
"staging": {
|
|
23
|
+
"secretName": "firestore/maven-staging"
|
|
24
|
+
},
|
|
25
|
+
"production": {
|
|
26
|
+
"secretName": "firestore/maven-production"
|
|
27
|
+
},
|
|
28
|
+
localQa: {
|
|
29
|
+
"secretName": "firestore/maven-development"
|
|
30
|
+
},
|
|
31
|
+
localStaging: {
|
|
32
|
+
"secretName": "firestore/maven-staging"
|
|
33
|
+
},
|
|
34
|
+
localProd: {
|
|
35
|
+
secretName: "firestore/maven-production"
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=firestore.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firestore.config.js","sourceRoot":"","sources":["../../../src/configs/firestore.config.ts"],"names":[],"mappings":";;;AASa,QAAA,eAAe,GAAqC;IAC/D,MAAM,EAAE;QACN,WAAW,EAAE,gBAAgB;QAC7B,MAAM,EAAE,gBAAgB;QACxB,KAAK,EAAE,KAAK;KACb;IACD,OAAO,EAAE;QACP,YAAY,EAAE,6BAA6B;KAC5C;IACD,UAAU,EAAE;QACV,YAAY,EAAE,6BAA6B;KAC5C;IACD,aAAa,EAAE;QACb,YAAY,EAAE,6BAA6B;KAC5C;IACD,IAAI,EAAE;QACJ,YAAY,EAAE,oBAAoB;KACnC;IACD,SAAS,EAAE;QACT,YAAY,EAAE,yBAAyB;KACxC;IACD,YAAY,EAAE;QACZ,YAAY,EAAE,4BAA4B;KAC3C;IACD,OAAO,EAAE;QACP,YAAY,EAAE,6BAA6B;KAC5C;IACD,YAAY,EAAE;QACZ,YAAY,EAAE,yBAAyB;KACxC;IACD,SAAS,EAAE;QACT,UAAU,EAAE,4BAA4B;KACzC;CACF,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { bindEventHandlerDeps } from "./inversifyConfig";
|
|
2
|
+
declare const eventHandlerConfig: {
|
|
3
|
+
dynamoDB: {
|
|
4
|
+
region: string;
|
|
5
|
+
endpoint: string;
|
|
6
|
+
eventsTableName: string;
|
|
7
|
+
projectionsTableName: string;
|
|
8
|
+
};
|
|
9
|
+
redis: {
|
|
10
|
+
stateRepository: {
|
|
11
|
+
host: string;
|
|
12
|
+
port: number;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
firestore: {
|
|
16
|
+
projectId?: string;
|
|
17
|
+
host?: string;
|
|
18
|
+
ssl?: boolean;
|
|
19
|
+
secretName?: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export { bindEventHandlerDeps, eventHandlerConfig };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.eventHandlerConfig = exports.bindEventHandlerDeps = void 0;
|
|
4
|
+
const dynamoDb_config_1 = require("./dynamoDb.config");
|
|
5
|
+
const firestore_config_1 = require("./firestore.config");
|
|
6
|
+
const redis_config_1 = require("./redis.config");
|
|
7
|
+
const inversifyConfig_1 = require("./inversifyConfig");
|
|
8
|
+
Object.defineProperty(exports, "bindEventHandlerDeps", { enumerable: true, get: function () { return inversifyConfig_1.bindEventHandlerDeps; } });
|
|
9
|
+
const node_env = (process.env.NODE_ENV || 'test');
|
|
10
|
+
const eventHandlerConfig = {
|
|
11
|
+
dynamoDB: dynamoDb_config_1.dynamoDbConfig[node_env],
|
|
12
|
+
redis: redis_config_1.redisConfig[node_env],
|
|
13
|
+
firestore: firestore_config_1.firestoreConfig[node_env],
|
|
14
|
+
};
|
|
15
|
+
exports.eventHandlerConfig = eventHandlerConfig;
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/configs/index.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AACnD,yDAAqD;AACrD,iDAA6C;AAC7C,uDAAyD;AAYhD,qGAZA,sCAAoB,OAYA;AAT7B,MAAM,QAAQ,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,MAAM,CAAY,CAAA;AAG5D,MAAM,kBAAkB,GAAG;IACzB,QAAQ,EAAE,gCAAc,CAAC,QAAQ,CAAC;IAClC,KAAK,EAAE,0BAAW,CAAC,QAAQ,CAAC;IAC5B,SAAS,EAAE,kCAAe,CAAC,QAAQ,CAAC;CACrC,CAAA;AAE8B,gDAAkB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type Getable = {
|
|
2
|
+
get: <T = string>(key: string) => T;
|
|
3
|
+
};
|
|
4
|
+
export declare const bindConfig: (config: Getable, container_or_bind: any) => void;
|
|
5
|
+
export declare const bindRabbitConnection: (config: Getable, container_or_bind: any) => void;
|
|
6
|
+
export declare const bindDynamoDb: (config: Getable, container_or_bind: any) => void;
|
|
7
|
+
export declare const bindRedis: (config: Getable, container_or_bind: any) => void;
|
|
8
|
+
export declare const bindEventHandlerDeps: (config: Getable, container_or_bind: any) => void;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bindEventHandlerDeps = exports.bindRedis = exports.bindDynamoDb = exports.bindRabbitConnection = exports.bindConfig = void 0;
|
|
4
|
+
const amqplib_1 = require("amqplib");
|
|
5
|
+
const dependencies_1 = require("../dependencies");
|
|
6
|
+
const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
|
|
7
|
+
const lib_dynamodb_1 = require("@aws-sdk/lib-dynamodb");
|
|
8
|
+
const redis_1 = require("@mavenmachines/redis");
|
|
9
|
+
const disambiguate_bind = (container_or_bind) => {
|
|
10
|
+
if (container_or_bind.bind) {
|
|
11
|
+
return container_or_bind.bind.bind(container_or_bind);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
return container_or_bind;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const bindConfig = (config, container_or_bind) => {
|
|
18
|
+
const bind = disambiguate_bind(container_or_bind);
|
|
19
|
+
for (const [key, value] of walkMembers(config)) {
|
|
20
|
+
bind(`CONFIG.${key}`).toConstantValue(value);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
exports.bindConfig = bindConfig;
|
|
24
|
+
const bindRabbitConnection = (config, container_or_bind) => {
|
|
25
|
+
const bind = disambiguate_bind(container_or_bind);
|
|
26
|
+
const rabbitHost = config.get("rabbitmq.host");
|
|
27
|
+
(0, amqplib_1.connect)(rabbitHost).then((connection) => {
|
|
28
|
+
bind(dependencies_1.TYPES.AmqpConnection).toConstantValue(connection);
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
exports.bindRabbitConnection = bindRabbitConnection;
|
|
32
|
+
const bindDynamoDb = (config, container_or_bind) => {
|
|
33
|
+
const bind = disambiguate_bind(container_or_bind);
|
|
34
|
+
bind(dependencies_1.TYPES.DynamoDocumentClientFactory).toFactory((context) => {
|
|
35
|
+
return () => {
|
|
36
|
+
const dynamoDBClient = new client_dynamodb_1.DynamoDBClient({
|
|
37
|
+
region: context.container.get("CONFIG.dynamoDB.region"),
|
|
38
|
+
endpoint: context.container.get("CONFIG.dynamoDB.endpoint")
|
|
39
|
+
});
|
|
40
|
+
return lib_dynamodb_1.DynamoDBDocumentClient.from(dynamoDBClient);
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
exports.bindDynamoDb = bindDynamoDb;
|
|
45
|
+
const bindRedis = (config, container_or_bind) => {
|
|
46
|
+
const bind = disambiguate_bind(container_or_bind);
|
|
47
|
+
const redis = new redis_1.RedisClient(config.get('redis.stateRepository'));
|
|
48
|
+
bind(redis_1.RedisClient).toConstantValue(redis);
|
|
49
|
+
};
|
|
50
|
+
exports.bindRedis = bindRedis;
|
|
51
|
+
function walkMembers(container) {
|
|
52
|
+
return Object.entries(container)
|
|
53
|
+
.filter((p) => !["constructor", "__proto__"].includes(p[0]))
|
|
54
|
+
.filter((p) => !["undefined", "function"].includes(typeof p[1]))
|
|
55
|
+
.flatMap(([key, value]) => {
|
|
56
|
+
if (typeof value === "object") {
|
|
57
|
+
return walkMembers(value).map(([childKey, value]) => [
|
|
58
|
+
`${key}.${childKey}`,
|
|
59
|
+
value,
|
|
60
|
+
]);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
return [[key, value]];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const bindEventHandlerDeps = (config, container_or_bind) => {
|
|
68
|
+
(0, exports.bindConfig)(config, container_or_bind);
|
|
69
|
+
(0, exports.bindRabbitConnection)(config, container_or_bind);
|
|
70
|
+
(0, exports.bindDynamoDb)(config, container_or_bind);
|
|
71
|
+
(0, exports.bindRedis)(config, container_or_bind);
|
|
72
|
+
};
|
|
73
|
+
exports.bindEventHandlerDeps = bindEventHandlerDeps;
|
|
74
|
+
//# sourceMappingURL=inversifyConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inversifyConfig.js","sourceRoot":"","sources":["../../../src/configs/inversifyConfig.ts"],"names":[],"mappings":";;;AAAA,qCAA6C;AAC7C,kDAAwC;AACxC,8DAA0D;AAC1D,wDAA+D;AAC/D,g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CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;gBACnD,GAAG,GAAG,IAAI,QAAQ,EAAE;gBACpB,KAAK;aACN,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;QACxB,CAAC;IACH,CAAC,CAAoB,CAAC;AAC1B,CAAC;AAEM,MAAM,oBAAoB,GAAG,CAAC,MAAe,EAAE,iBAAsB,EAAE,EAAE;IAC9E,IAAA,kBAAU,EAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACtC,IAAA,4BAAoB,EAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IAChD,IAAA,oBAAY,EAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACxC,IAAA,iBAAS,EAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;AACtC,CAAC,CAAA;AALY,QAAA,oBAAoB,wBAKhC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type NodeEnv = 'test' | 'local' | 'localDev' | 'development' | 'localQa' | 'qa' | 'localStaging' | 'staging' | 'localProd' | 'production';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node_envs.js","sourceRoot":"","sources":["../../../src/configs/node_envs.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.redisConfig = void 0;
|
|
4
|
+
exports.redisConfig = {
|
|
5
|
+
"test": {
|
|
6
|
+
"stateRepository": {
|
|
7
|
+
"host": "localhost",
|
|
8
|
+
"port": 6379
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
local: {
|
|
12
|
+
stateRepository: {
|
|
13
|
+
host: "",
|
|
14
|
+
port: 0
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
localDev: {
|
|
18
|
+
stateRepository: {
|
|
19
|
+
host: "",
|
|
20
|
+
port: 0
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
development: {
|
|
24
|
+
stateRepository: {
|
|
25
|
+
host: "",
|
|
26
|
+
port: 0
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
localQa: {
|
|
30
|
+
stateRepository: {
|
|
31
|
+
host: "",
|
|
32
|
+
port: 0
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
qa: {
|
|
36
|
+
stateRepository: {
|
|
37
|
+
host: "",
|
|
38
|
+
port: 0
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
localStaging: {
|
|
42
|
+
stateRepository: {
|
|
43
|
+
host: "",
|
|
44
|
+
port: 0
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
staging: {
|
|
48
|
+
stateRepository: {
|
|
49
|
+
host: "",
|
|
50
|
+
port: 0
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
localProd: {
|
|
54
|
+
stateRepository: {
|
|
55
|
+
host: "",
|
|
56
|
+
port: 0
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
production: {
|
|
60
|
+
stateRepository: {
|
|
61
|
+
host: "",
|
|
62
|
+
port: 0
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=redis.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.config.js","sourceRoot":"","sources":["../../../src/configs/redis.config.ts"],"names":[],"mappings":";;;AAQa,QAAA,WAAW,GAAiC;IACvD,MAAM,EAAE;QACN,iBAAiB,EAAE;YACjB,MAAM,EAAE,WAAW;YACnB,MAAM,EAAE,IAAI;SACb;KACF;IAED,KAAK,EAAE;QACL,eAAe,EAAE;YACf,IAAI,EAAE,EAAE;YACR,IAAI,EAAE,CAAC;SACR;KACF;IACD,QAAQ,EAAE;QACR,eAAe,EAAE;YACf,IAAI,EAAE,EAAE;YACR,IAAI,EAAE,CAAC;SACR;KACF;IACD,WAAW,EAAE;QACX,eAAe,EAAE;YACf,IAAI,EAAE,EAAE;YACR,IAAI,EAAE,CAAC;SACR;KACF;IACD,OAAO,EAAE;QACP,eAAe,EAAE;YACf,IAAI,EAAE,EAAE;YACR,IAAI,EAAE,CAAC;SACR;KACF;IACD,EAAE,EAAE;QACF,eAAe,EAAE;YACf,IAAI,EAAE,EAAE;YACR,IAAI,EAAE,CAAC;SACR;KACF;IACD,YAAY,EAAE;QACZ,eAAe,EAAE;YACf,IAAI,EAAE,EAAE;YACR,IAAI,EAAE,CAAC;SACR;KACF;IACD,OAAO,EAAE;QACP,eAAe,EAAE;YACf,IAAI,EAAE,EAAE;YACR,IAAI,EAAE,CAAC;SACR;KACF;IACD,SAAS,EAAE;QACT,eAAe,EAAE;YACf,IAAI,EAAE,EAAE;YACR,IAAI,EAAE,CAAC;SACR;KACF;IACD,UAAU,EAAE;QACV,eAAe,EAAE;YACf,IAAI,EAAE,EAAE;YACR,IAAI,EAAE,CAAC;SACR;KACF;CACF,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dependencyTypes';
|