@alanszp/eventbridge-client 7.0.1

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/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ node_modules
2
+ *.log
3
+ dist
package/.npmignore ADDED
@@ -0,0 +1,3 @@
1
+ node_modules
2
+ src
3
+ *.log
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Alan Szpigiel
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ import AWS from "aws-sdk";
2
+ export declare const eventbridgeClient: AWS.EventBridge;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.eventbridgeClient = void 0;
7
+ const aws_sdk_1 = __importDefault(require("aws-sdk"));
8
+ exports.eventbridgeClient = new aws_sdk_1.default.EventBridge();
9
+ //# sourceMappingURL=awsEventbridgeClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"awsEventbridgeClient.js","sourceRoot":"","sources":["../../src/aws/awsEventbridgeClient.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA0B;AAEb,QAAA,iBAAiB,GAAG,IAAI,iBAAG,CAAC,WAAW,EAAE,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { PromiseResult as AWSPromiseResult } from "aws-sdk/lib/request";
2
+ export declare type EventRequest = AWS.EventBridge.Types.PutEventsRequest;
3
+ export declare type EventResponse = AWS.EventBridge.Types.PutEventsResponse;
4
+ export declare type AWSResponse<D, E> = AWS.Response<D, E>;
5
+ export declare type PromiseResult<D, E> = AWSPromiseResult<D, E>;
6
+ export declare type PutEventEntryResponse = AWS.EventBridge.PutEventsResultEntry;
7
+ export declare type PutEventEntryRequest = AWS.EventBridge.PutEventsRequestEntry;
8
+ export declare type EventError = AWS.AWSError;
9
+ export declare type PromiseEventResponse = PromiseResult<EventResponse, EventError>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=awsTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"awsTypes.js","sourceRoot":"","sources":["../../src/aws/awsTypes.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export * from "./awsEventbridgeClient";
2
+ export * from "./awsTypes";
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./awsEventbridgeClient"), exports);
14
+ __exportStar(require("./awsTypes"), exports);
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/aws/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAuC;AACvC,6CAA2B"}
@@ -0,0 +1,34 @@
1
+ import { ILogger } from "@alanszp/logger";
2
+ import { SharedContext } from "@alanszp/shared-context";
3
+ import { PutEventEntryResponse } from "./aws";
4
+ /**
5
+ * Represents an event that is sent in the Lara ecosystem.
6
+ *
7
+ * @property topic: The topic of the event. E.g.: if an employee was created, topid would be employee.created.
8
+ * @property lid: The lifecycle id to identify the execution that generated the event.
9
+ * @property body: The body of the event. This will be used to match in the rules, along with the topic and maybe the id. If it has a property id it
10
+ * will be overwritten by the id sent to this method in the parameters.
11
+ */
12
+ export declare type LaraEvent = {
13
+ topic: string;
14
+ entity: Record<string, unknown>;
15
+ modifiedKeys: string[];
16
+ };
17
+ export interface EventDispatchResult {
18
+ successful: PutEventEntryResponse[];
19
+ failed: PutEventEntryResponse[];
20
+ failedCount: number | undefined;
21
+ }
22
+ /**
23
+ * Basic client for Eventbridge.
24
+ * Usage will be done by extending this class and implementing methods that internally call the protected sendEvents method.
25
+ */
26
+ export declare class BasicEventbridgeClient {
27
+ private appName;
28
+ private env;
29
+ private bus;
30
+ protected getLogger: () => ILogger;
31
+ protected context: SharedContext;
32
+ constructor(appName: string, env: string, getLogger: () => ILogger, context: SharedContext, bus?: string);
33
+ protected sendEvents(events: LaraEvent[]): Promise<EventDispatchResult>;
34
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.BasicEventbridgeClient = void 0;
13
+ const lodash_1 = require("lodash");
14
+ const aws_1 = require("./aws");
15
+ const mapLaraEventToAWSEvent_1 = require("./helpers/mapLaraEventToAWSEvent");
16
+ const DEFAULT_CUSTOM_BUS_NAME_SUFFIX = "lara-eventbus";
17
+ /**
18
+ * Basic client for Eventbridge.
19
+ * Usage will be done by extending this class and implementing methods that internally call the protected sendEvents method.
20
+ */
21
+ class BasicEventbridgeClient {
22
+ constructor(appName, env, getLogger, context, bus = `${env}-${DEFAULT_CUSTOM_BUS_NAME_SUFFIX}`) {
23
+ this.appName = appName;
24
+ this.env = env;
25
+ this.bus = bus;
26
+ this.getLogger = getLogger;
27
+ this.context = context;
28
+ }
29
+ sendEvents(events) {
30
+ return __awaiter(this, void 0, void 0, function* () {
31
+ const logger = this.getLogger();
32
+ const eventsToSend = {
33
+ Entries: (0, lodash_1.compact)(events.map((event) => (0, mapLaraEventToAWSEvent_1.mapLaraEventToAWSEvent)(event, this.env, this.appName, this.bus, logger, this.context))),
34
+ };
35
+ const result = yield aws_1.eventbridgeClient.putEvents(eventsToSend).promise();
36
+ const { Entries, FailedEntryCount: failedCount } = result;
37
+ const [successful, failed] = (0, lodash_1.partition)(Entries, (entry) => entry.EventId);
38
+ logger.info("eventbridge.client.sendEvents.end", {
39
+ successful,
40
+ failed,
41
+ });
42
+ return {
43
+ successful,
44
+ failed,
45
+ failedCount,
46
+ };
47
+ });
48
+ }
49
+ }
50
+ exports.BasicEventbridgeClient = BasicEventbridgeClient;
51
+ //# sourceMappingURL=basicEventbridgeClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"basicEventbridgeClient.js","sourceRoot":"","sources":["../src/basicEventbridgeClient.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,mCAA4C;AAC5C,+BAA+E;AAC/E,6EAA0E;AAsB1E,MAAM,8BAA8B,GAAG,eAAe,CAAC;AAEvD;;;GAGG;AACH,MAAa,sBAAsB;IAQjC,YACE,OAAe,EACf,GAAW,EACX,SAAwB,EACxB,OAAsB,EACtB,GAAG,GAAG,GAAG,GAAG,IAAI,8BAA8B,EAAE;QAEhD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEe,UAAU,CACxB,MAAmB;;YAEnB,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;YAEhC,MAAM,YAAY,GAAiB;gBACjC,OAAO,EAAE,IAAA,gBAAO,EACd,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACnB,IAAA,+CAAsB,EACpB,KAAK,EACL,IAAI,CAAC,GAAG,EACR,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,GAAG,EACR,MAAM,EACN,IAAI,CAAC,OAAO,CACb,CACF,CACF;aACF,CAAC;YAEF,MAAM,MAAM,GAAG,MAAM,uBAAiB,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC;YACzE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;YAC1D,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,GAAG,IAAA,kBAAS,EAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAE1E,MAAM,CAAC,IAAI,CAAC,mCAAmC,EAAE;gBAC/C,UAAU;gBACV,MAAM;aACP,CAAC,CAAC;YAEH,OAAO;gBACL,UAAU;gBACV,MAAM;gBACN,WAAW;aACZ,CAAC;QACJ,CAAC;KAAA;CACF;AAzDD,wDAyDC"}
@@ -0,0 +1,5 @@
1
+ import { LaraEvent } from "../basicEventbridgeClient";
2
+ import { PutEventsRequestEntry } from "aws-sdk/clients/eventbridge";
3
+ import type { ILogger } from "@alanszp/logger";
4
+ import type { SharedContext } from "@alanszp/shared-context";
5
+ export declare function mapLaraEventToAWSEvent({ topic, entity }: LaraEvent, env: string, appName: string, bus: string, logger: ILogger, context: SharedContext): PutEventsRequestEntry | undefined;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.mapLaraEventToAWSEvent = void 0;
7
+ const lodash_1 = require("lodash");
8
+ const cuid_1 = __importDefault(require("cuid"));
9
+ function mapLaraEventToAWSEvent({ topic, entity }, env, appName, bus, logger, context) {
10
+ const lid = context.getLifecycleId() || (0, cuid_1.default)();
11
+ const oldlLch = context.getLifecycleChain();
12
+ const lch = (0, lodash_1.compact)([oldlLch, "aws.eventbridge"]).join(",");
13
+ try {
14
+ return {
15
+ DetailType: topic,
16
+ Detail: JSON.stringify(Object.assign(Object.assign({}, entity), { lch })),
17
+ Source: `${env}.lara.${appName}`,
18
+ EventBusName: bus,
19
+ Time: new Date(),
20
+ TraceHeader: lid,
21
+ };
22
+ }
23
+ catch (_a) {
24
+ const org = entity.organizationReference;
25
+ logger.error("eventbridge.client.map_lara_to_aws_event.parse_error", {
26
+ topic,
27
+ org,
28
+ lid,
29
+ });
30
+ return undefined;
31
+ }
32
+ }
33
+ exports.mapLaraEventToAWSEvent = mapLaraEventToAWSEvent;
34
+ //# sourceMappingURL=mapLaraEventToAWSEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapLaraEventToAWSEvent.js","sourceRoot":"","sources":["../../src/helpers/mapLaraEventToAWSEvent.ts"],"names":[],"mappings":";;;;;;AAIA,mCAAiC;AACjC,gDAAwB;AAExB,SAAgB,sBAAsB,CACpC,EAAE,KAAK,EAAE,MAAM,EAAa,EAC5B,GAAW,EACX,OAAe,EACf,GAAW,EACX,MAAe,EACf,OAAsB;IAEtB,MAAM,GAAG,GAAG,OAAO,CAAC,cAAc,EAAE,IAAI,IAAA,cAAI,GAAE,CAAC;IAC/C,MAAM,OAAO,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAC5C,MAAM,GAAG,GAAG,IAAA,gBAAO,EAAC,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5D,IAAI;QACF,OAAO;YACL,UAAU,EAAE,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,SAAS,iCAAM,MAAM,KAAE,GAAG,IAAG;YAC1C,MAAM,EAAE,GAAG,GAAG,SAAS,OAAO,EAAE;YAChC,YAAY,EAAE,GAAG;YACjB,IAAI,EAAE,IAAI,IAAI,EAAE;YAChB,WAAW,EAAE,GAAG;SACjB,CAAC;KACH;IAAC,WAAM;QACN,MAAM,GAAG,GAAG,MAAM,CAAC,qBAA+B,CAAC;QACnD,MAAM,CAAC,KAAK,CAAC,sDAAsD,EAAE;YACnE,KAAK;YACL,GAAG;YACH,GAAG;SACJ,CAAC,CAAC;QACH,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AA7BD,wDA6BC"}
@@ -0,0 +1,2 @@
1
+ export * from "./basicEventbridgeClient";
2
+ export * from "./aws/awsTypes";
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./basicEventbridgeClient"), exports);
14
+ __exportStar(require("./aws/awsTypes"), exports);
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAAyC;AACzC,iDAA+B"}
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@alanszp/eventbridge-client",
3
+ "version": "7.0.1",
4
+ "description": "Alan's basic eventbridge client.",
5
+ "main": "dist/index.js",
6
+ "typings": "dist/index.d.ts",
7
+ "license": "MIT",
8
+ "files": [
9
+ "**/*"
10
+ ],
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "scripts": {
15
+ "compile": "rm -rf ./dist && tsc --declaration",
16
+ "compile-watch": "tsc -w",
17
+ "build": "yarn run compile",
18
+ "prepack": "yarn run build",
19
+ "yalc-publish": "yarn run yalc publish"
20
+ },
21
+ "devDependencies": {
22
+ "@types/node": "^15.12.3",
23
+ "ts-node": "^10.0.0",
24
+ "typescript": "^4.3.4"
25
+ },
26
+ "dependencies": {
27
+ "@alanszp/logger": "^7.0.0",
28
+ "@alanszp/shared-context": "^7.0.0",
29
+ "aws-sdk": "^2.1204.0",
30
+ "cuid": "^2.1.8",
31
+ "lodash": "^4.17.21"
32
+ },
33
+ "gitHead": "67e6ad3d56d02ee10f45ca59f7e68bc77d574f41"
34
+ }
@@ -0,0 +1,3 @@
1
+ import AWS from "aws-sdk";
2
+
3
+ export const eventbridgeClient = new AWS.EventBridge();
@@ -0,0 +1,10 @@
1
+ import { PromiseResult as AWSPromiseResult } from "aws-sdk/lib/request";
2
+
3
+ export type EventRequest = AWS.EventBridge.Types.PutEventsRequest;
4
+ export type EventResponse = AWS.EventBridge.Types.PutEventsResponse;
5
+ export type AWSResponse<D, E> = AWS.Response<D, E>;
6
+ export type PromiseResult<D, E> = AWSPromiseResult<D, E>;
7
+ export type PutEventEntryResponse = AWS.EventBridge.PutEventsResultEntry;
8
+ export type PutEventEntryRequest = AWS.EventBridge.PutEventsRequestEntry;
9
+ export type EventError = AWS.AWSError;
10
+ export type PromiseEventResponse = PromiseResult<EventResponse, EventError>;
@@ -0,0 +1,2 @@
1
+ export * from "./awsEventbridgeClient";
2
+ export * from "./awsTypes";
@@ -0,0 +1,90 @@
1
+ import { ILogger } from "@alanszp/logger";
2
+ import { SharedContext } from "@alanszp/shared-context";
3
+ import { compact, partition } from "lodash";
4
+ import { eventbridgeClient, EventRequest, PutEventEntryResponse } from "./aws";
5
+ import { mapLaraEventToAWSEvent } from "./helpers/mapLaraEventToAWSEvent";
6
+
7
+ /**
8
+ * Represents an event that is sent in the Lara ecosystem.
9
+ *
10
+ * @property topic: The topic of the event. E.g.: if an employee was created, topid would be employee.created.
11
+ * @property lid: The lifecycle id to identify the execution that generated the event.
12
+ * @property body: The body of the event. This will be used to match in the rules, along with the topic and maybe the id. If it has a property id it
13
+ * will be overwritten by the id sent to this method in the parameters.
14
+ */
15
+ export type LaraEvent = {
16
+ topic: string;
17
+ entity: Record<string, unknown>;
18
+ modifiedKeys: string[];
19
+ };
20
+
21
+ export interface EventDispatchResult {
22
+ successful: PutEventEntryResponse[];
23
+ failed: PutEventEntryResponse[];
24
+ failedCount: number | undefined;
25
+ }
26
+
27
+ const DEFAULT_CUSTOM_BUS_NAME_SUFFIX = "lara-eventbus";
28
+
29
+ /**
30
+ * Basic client for Eventbridge.
31
+ * Usage will be done by extending this class and implementing methods that internally call the protected sendEvents method.
32
+ */
33
+ export class BasicEventbridgeClient {
34
+ private appName: string;
35
+ private env: string;
36
+ private bus: string;
37
+
38
+ protected getLogger: () => ILogger;
39
+ protected context: SharedContext;
40
+
41
+ constructor(
42
+ appName: string,
43
+ env: string,
44
+ getLogger: () => ILogger,
45
+ context: SharedContext,
46
+ bus = `${env}-${DEFAULT_CUSTOM_BUS_NAME_SUFFIX}`
47
+ ) {
48
+ this.appName = appName;
49
+ this.env = env;
50
+ this.bus = bus;
51
+ this.getLogger = getLogger;
52
+ this.context = context;
53
+ }
54
+
55
+ protected async sendEvents(
56
+ events: LaraEvent[]
57
+ ): Promise<EventDispatchResult> {
58
+ const logger = this.getLogger();
59
+
60
+ const eventsToSend: EventRequest = {
61
+ Entries: compact(
62
+ events.map((event) =>
63
+ mapLaraEventToAWSEvent(
64
+ event,
65
+ this.env,
66
+ this.appName,
67
+ this.bus,
68
+ logger,
69
+ this.context
70
+ )
71
+ )
72
+ ),
73
+ };
74
+
75
+ const result = await eventbridgeClient.putEvents(eventsToSend).promise();
76
+ const { Entries, FailedEntryCount: failedCount } = result;
77
+ const [successful, failed] = partition(Entries, (entry) => entry.EventId);
78
+
79
+ logger.info("eventbridge.client.sendEvents.end", {
80
+ successful,
81
+ failed,
82
+ });
83
+
84
+ return {
85
+ successful,
86
+ failed,
87
+ failedCount,
88
+ };
89
+ }
90
+ }
@@ -0,0 +1,37 @@
1
+ import { LaraEvent } from "../basicEventbridgeClient";
2
+ import { PutEventsRequestEntry } from "aws-sdk/clients/eventbridge";
3
+ import type { ILogger } from "@alanszp/logger";
4
+ import type { SharedContext } from "@alanszp/shared-context";
5
+ import { compact } from "lodash";
6
+ import cuid from "cuid";
7
+
8
+ export function mapLaraEventToAWSEvent(
9
+ { topic, entity }: LaraEvent,
10
+ env: string,
11
+ appName: string,
12
+ bus: string,
13
+ logger: ILogger,
14
+ context: SharedContext
15
+ ): PutEventsRequestEntry | undefined {
16
+ const lid = context.getLifecycleId() || cuid();
17
+ const oldlLch = context.getLifecycleChain();
18
+ const lch = compact([oldlLch, "aws.eventbridge"]).join(",");
19
+ try {
20
+ return {
21
+ DetailType: topic,
22
+ Detail: JSON.stringify({ ...entity, lch }),
23
+ Source: `${env}.lara.${appName}`,
24
+ EventBusName: bus,
25
+ Time: new Date(),
26
+ TraceHeader: lid,
27
+ };
28
+ } catch {
29
+ const org = entity.organizationReference as string;
30
+ logger.error("eventbridge.client.map_lara_to_aws_event.parse_error", {
31
+ topic,
32
+ org,
33
+ lid,
34
+ });
35
+ return undefined;
36
+ }
37
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./basicEventbridgeClient";
2
+ export * from "./aws/awsTypes";
package/tsconfig.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "rootDir": "src",
4
+ "outDir": "dist",
5
+ "module": "commonjs",
6
+ "target": "es6",
7
+ "types": ["node"],
8
+ "esModuleInterop": true,
9
+ "sourceMap": true,
10
+
11
+ "alwaysStrict": true,
12
+ "strictNullChecks": true
13
+ },
14
+ "exclude": ["node_modules"]
15
+ }