{"_rev":"3-bb8ddd9b2b7326ae3c13151d8e24cfba","time":{"created":"2023-08-18T12:53:56.825Z","1.1.0":"2023-08-14T15:33:41.736Z","modified":"2023-08-18T12:53:57.564Z","0.2.0":"2023-08-18T12:53:57.124Z"},"_id":"@aleios-cloud/eventbridge-toolbox","name":"@aleios-cloud/eventbridge-toolbox","dist-tags":{"latest":"0.2.0"},"versions":{"0.2.0":{"name":"@aleios-cloud/eventbridge-toolbox","version":"0.2.0","description":"Eventbridge Toolbox is a lightweight eventbridge adapter that can help you enforce good practicies in your event driven architectures.","main":"index.js","repository":{"type":"git","url":"git+https://github.com/aleios-cloud/eventbridge-toolbox.git"},"module":"dist/index.js","types":"dist/index.d.ts","keywords":[],"author":"","license":"ISC","devDependencies":{"@aws-sdk/client-lambda":"^3.382.0","@types/node":"^20.4.5","@typescript-eslint/eslint-plugin":"^6.0.0","@typescript-eslint/parser":"^6.0.0","aws-cdk":"^2.89.0","aws-cdk-lib":"^2.89.0","constructs":"^10.0.0","esbuild":"^0.18.17","eslint":"^8.43.0","eslint-config-prettier":"^8.8.0","eslint-import-resolver-typescript":"^3.5.5","eslint-plugin-import":"^2.27.5","eslint-plugin-prefer-arrow":"^1.2.3","eslint-plugin-prettier":"^5.0.0","rimraf":"^5.0.1","ts-json-schema-generator":"^1.2.0","ts-node":"^10.9.1","tsconfig-paths":"^4.2.0","typescript":"^5.1.6","vite-tsconfig-paths":"^4.2.0","vitest":"^0.34.1"},"dependencies":{"@aws-sdk/client-eventbridge":"^3.386.0"},"scripts":{"clean":"rimraf dist","test":"vitest run","lint-fix":"eslint . --ext=js,ts --fix","lint-test":"eslint . --ext=js,ts","build":"pnpm clean && tsc","generate-docs":"ts-node scripts/generate-docs.ts example-architecture/events/contracts"},"bugs":{"url":"https://github.com/aleios-cloud/eventbridge-toolbox/issues"},"homepage":"https://github.com/aleios-cloud/eventbridge-toolbox#readme","_id":"@aleios-cloud/eventbridge-toolbox@0.2.0","_integrity":"sha512-HB217KFARB/hsZOqJIv1W28odCwl5DfpBJzOfaQ+dJO0/EMcGfRj6crHna4JdOJYMjzCoQDi0vFOMt7vZLhCNw==","_resolved":"/tmp/f62f86aab7101c59076db043bbd82839/aleios-cloud-eventbridge-toolbox-0.2.0.tgz","_from":"file:aleios-cloud-eventbridge-toolbox-0.2.0.tgz","_nodeVersion":"18.17.0","_npmVersion":"9.6.7","dist":{"integrity":"sha512-HB217KFARB/hsZOqJIv1W28odCwl5DfpBJzOfaQ+dJO0/EMcGfRj6crHna4JdOJYMjzCoQDi0vFOMt7vZLhCNw==","shasum":"e601133eb5aa6bf4669c60c95406d588c6eeaa72","tarball":"https://registry.npmjs.org/@aleios-cloud/eventbridge-toolbox/-/eventbridge-toolbox-0.2.0.tgz","fileCount":19,"unpackedSize":15508,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBFr56Bt/QjqQCnOlAhwfYbx/tM5DHJuKfKRGjegMeLVAiEA7biNpgLkM+LvIwgzuqL0ITow47tn6HCZNudIwpdqu5k="}]},"_npmUser":{"name":"aiden-walton","email":"aidenw@aleios.com"},"directories":{},"maintainers":[{"name":"lukey-aleios","email":"lukey@aleios.com"},{"name":"aiden-walton","email":"aidenw@aleios.com"},{"name":"ryanschuller","email":"ryans@aleios.com"},{"name":"aleios-npm","email":"npm@aleios.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eventbridge-toolbox_0.2.0_1692363236960_0.7565283506036551"},"_hasShrinkwrap":false}},"maintainers":[{"name":"lukey-aleios","email":"lukey@aleios.com"},{"name":"aiden-walton","email":"aidenw@aleios.com"},{"name":"ryanschuller","email":"ryans@aleios.com"},{"name":"aleios-npm","email":"npm@aleios.com"}],"description":"Eventbridge Toolbox is a lightweight eventbridge adapter that can help you enforce good practicies in your event driven architectures.","homepage":"https://github.com/aleios-cloud/eventbridge-toolbox#readme","keywords":[],"repository":{"type":"git","url":"git+https://github.com/aleios-cloud/eventbridge-toolbox.git"},"bugs":{"url":"https://github.com/aleios-cloud/eventbridge-toolbox/issues"},"license":"ISC","readme":"# eventbridge-toolbox\n\nEventbridge Toolbox is a lightweight eventbridge adapter that can help you enforce good practicies in your event driven architectures.\n\n## Eventbridge Contracts\n\nWithin event-driven architectures, events facilitate communication between loosely connected services in an application. EventBridge is AWS's tool for implementing asynchronous event-driven workflows.\n\nEvent emitters are responsible for broadcasting events to event channels, while event consumers are responsible for executing business logic whenever they encounter a relevant event.\n\nEventBridge contracts ensure a stable and reliable interaction emitters and consumers. These contract acts as a guiding agreement which guarantees that emitters' published events will consistently trigger the corresponding business logic on the consumer side.\n\n## Creating an EventBridge contract\n\nTo create an EventBridge Contract, define a type for your contract. Your contract type must extend the interface `Contract`, with `Contract` being importable from the eventbridge-toolbox package. This typing will force you to add an event version to your contract. If you ever alter your contract (for instance, to add a new field), please create a copy of the contract in a new file, and give it a version number higher that you previous version of your contract. The `detailType` field stays consistent, and allows you to link together all versions of your contract.\n\nCreate an Contract type:\n\n```typescript\nexport interface PersonRegisteredContractV1 extends Contract {\n  version: 1;\n  detailType: \"PersonRegisteredContract\";\n  detail: {\n    firstName: string;\n    lastName: string;\n  };\n}\n```\n\nAs `version` and `detailType` are set as constants in the type, when we create an object of type PersonRegisteredContractV1, the `version` and `detailType` must match what is defined here otherwise you will see an error.\n\nCreate an Contract type:\n\n```typescript\nconst ourEvent: PersonRegisteredContractV1 = {\n  version: 1;\n  detailType: \"PersonRegisteredContract\";\n  detail: {\n    firstName: 'testFirstName';\n    lastName: 'testLastName';\n  };\n}\n```\n\n## Creating an Event\n\nThe Event class bakes in a lot of best practices. To instantiate an eventbridge-toolbox event, create a new Event and pass in your event detail and event detail type.\n\nYou can see an example below:\n\n```typescript\nimport Event from \"@eventbridge-toolbox\";\n\nconst loggedInData: LoggedInContractV1 = {\n  version: 1;\n  detailType: \"LoggedInContract\";\n  detail: {\n    firstName: \"Lucy\",\n    lastName: \"Example\",\n    timeLoggedIn: \"2023-01-01T13:00:00.000Z\",\n  };\n}\n\n\nconst myEvent = new Event(loggedInData);\n\n//equal to the 'loggedInData' object\nconst myEventDetail = myEvent.getDetail();\n\n//equal to 'loggedIn'\nconst myEventDetailType = myEvent.getDetailType():\n\n```\n\nYou can then publish your event by calling the `publish` function, passing in the ARN of the EventBus which you want to publish your event to and your event source.\n\nYou can see an example below for the scenario where the event source is a lambda:\n\n```typescript\nconst EVENT_BUS_ARN = getEnvVariable(\"EVENT_BUS_ARN\");\n\nawait myEvent.publish(EVENT_BUS_ARN, \"lambda.amazonaws.com\");\n```\n\n## Key Features\n\n- An event construct\n- Contracts to enforce types between producers and consumers\n- Event versioning\n\n## Getting Started\n\n### Prerequisites\n\n### Installation\n\nWith npm:\n\n```\nnpm install --save-dev eventbridge-toolbox\n```\n\nWith yarn:\n\n```\nyarn add -D eventbridge-toolbox\n```\n\nWith pnpm:\n\n```\npnpm add -D eventbridge-toolbox\n```\n\n### Usage\n\n## User Documentation\n\nFull docs are available at ...\n\n## Contributors\n\n<!-- markdownlint-disable -->\n<table>\n  <tbody>\n    <tr>\n      <td valign=\"top\"><a href=\"https://github.com/lukey-aleios\"><img src=\"https://avatars.githubusercontent.com/u/93375669?v=4\" width=\"100px;\" alt=\"Luke Yianni\"/><br /><sub><b>Luke Yianni</b></sub></a></td>\n      <td valign=\"top\"><a href=\"https://github.com/april-bates-aleios\"><img src=\"https://avatars.githubusercontent.com/u/124585201?v=4\" width=\"100px;\" alt=\"April Bates\"/><br /><sub><b>April Bates</b></sub></a></td>\n      <td valign=\"top\"><a href=\"https://github.com/RyanT5\"><img src=\"https://avatars.githubusercontent.com/u/22382958?v=4\" width=\"100px;\" alt=\"Ryan Schuller\"/><br /><sub><b>Ryan Schuller</b></sub></a></td>\n    </tr>\n  </tbody>\n</table>\n<!-- markdownlint-restore -->\n","readmeFilename":"README.md"}