{"_id":"@atlas-id/event-bus","_rev":"2-2d18dc2e9cdc22c1e981f574a919ad5f","name":"@atlas-id/event-bus","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"@atlas-id/event-bus","version":"0.1.0","keywords":["event-bus","nats","outbox","event-driven","microservices","typescript"],"author":{"name":"Atlas ID"},"license":"MIT","_id":"@atlas-id/event-bus@0.1.0","maintainers":[{"name":"agrufino","email":"agrufino@cloud.opendex.dev"}],"dist":{"shasum":"e13cceaebea8744eb6d8be0d484427ac00ea5726","tarball":"https://registry.npmjs.org/@atlas-id/event-bus/-/event-bus-0.1.0.tgz","fileCount":8,"integrity":"sha512-7y7plWyxfzGxtvV0pixdMM/WvPF892X4H7Mex5sVNXFJZOGzXNo+ZiQsW7dIqQLSK2snK9rAt4Ys0LG/ewDT5A==","signatures":[{"sig":"MEUCIQC8hgaixlGbnVL1vKiKT69BstLvAbdvGhDsTAksaqJAbQIgLrdy6Q0Ps2xIwGZtzLEtsVZU2K0MEhW/Q7fJEw9/0EU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":57155},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=18.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","default":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"ea6239796fbe24b8f7d58c424b78bb4a96e19786","private":false,"scripts":{"lint":"eslint --ext .ts .","test":"vitest run","build":"rimraf dist && tsup","clean":"rimraf dist && rimraf node_modules","typecheck":"tsc --noEmit","prepublishOnly":"npm run build && npm run typecheck"},"_npmUser":{"name":"agrufino","email":"agrufino@cloud.opendex.dev"},"repository":{"url":"https://git.opendex.dev/aip/event-bus.git","type":"git"},"_npmVersion":"11.7.0","description":"Event bus library with NATS implementation and Outbox pattern support","directories":{},"_nodeVersion":"24.10.0","dependencies":{"nats":"^2.20.0","@atlas-id/contracts":"0.2.1"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.1","rimraf":"^6.1.2","vitest":"^4.0.16","typescript":"5.3.3","@types/node":"20.17.6","@prisma/client":"^5.0.0"},"peerDependencies":{"@prisma/client":"^5.0.0"},"peerDependenciesMeta":{"@prisma/client":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/event-bus_0.1.0_1767433567137_0.4973604622886423","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@atlas-id/event-bus","version":"0.2.0","description":"Event bus library with NATS implementation and Outbox pattern support","keywords":["event-bus","nats","outbox","event-driven","microservices","typescript"],"author":{"name":"Opendex, Inc."},"license":"UNLICENSED","type":"module","main":"./dist/index.cjs","module":"./dist/index.mjs","types":"./dist/index.d.ts","sideEffects":false,"repository":{"type":"git","url":"https://git.opendex.dev/aip/event-bus.git"},"scripts":{"build":"rimraf dist && tsup","ci":"npm run lint && npm run typecheck && npm run test","typecheck":"tsc --noEmit","test":"vitest run","lint":"eslint . --max-warnings=0","audit":"npm audit --audit-level=high","sbom":"pnpm exec cdxgen -t js --exclude-type php --no-install-deps -o sbom.json","clean":"rimraf dist && rimraf node_modules","prepublishOnly":"npm run build && npm run typecheck && npm run lint && npm run test"},"exports":{".":{"types":"./dist/index.d.ts","require":"./dist/index.cjs","import":"./dist/index.mjs","default":"./dist/index.mjs"},"./package.json":"./package.json"},"engines":{"node":">=18.0.0"},"dependencies":{"@atlas-id/contracts":"0.2.1","nats":"^2.20.0"},"peerDependencies":{"@prisma/client":"^5.0.0"},"peerDependenciesMeta":{"@prisma/client":{"optional":true}},"devDependencies":{"@cyclonedx/cdxgen":"^12.0.0","@typescript-eslint/eslint-plugin":"^8.38.0","@typescript-eslint/parser":"^8.38.0","@prisma/client":"^5.0.0","@types/node":"20.19.0","eslint":"^9.23.0","rimraf":"^6.1.2","tsup":"^8.5.1","typescript":"5.3.3","vitest":"^4.0.16"},"gitHead":"7286f80dc045d523cd72d486d9763d54c68f3be2","_id":"@atlas-id/event-bus@0.2.0","_nodeVersion":"24.10.0","_npmVersion":"11.7.0","dist":{"integrity":"sha512-qabLIMHf6pD7VH8ZQj4I/j0jbJsxlJ7S4tywCtXqJdluu2IazzxBrPnRnBp6qri2M9Ii0br/0F75UF70FhL8hQ==","shasum":"d5a34f1cd05be44a3a27f6dedbfa4889cf054e0b","tarball":"https://registry.npmjs.org/@atlas-id/event-bus/-/event-bus-0.2.0.tgz","fileCount":10,"unpackedSize":63036,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD3Im/Su0ZTN3H1j9dTOrYUcHv6rsuGo8vZxiDrumu7VwIhAJk6fV7oLLrV/P3/8RjsOdBV2TFeqZIn4ys2UQuJj9Sw"}]},"_npmUser":{"name":"agrufino","email":"agrufino@cloud.opendex.dev"},"directories":{},"maintainers":[{"name":"agrufino","email":"agrufino@cloud.opendex.dev"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/event-bus_0.2.0_1767680936882_0.3465360315147077"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-03T09:46:07.012Z","modified":"2026-01-06T06:28:57.293Z","0.1.0":"2026-01-03T09:46:07.287Z","0.2.0":"2026-01-06T06:28:57.080Z"},"author":{"name":"Opendex, Inc."},"license":"UNLICENSED","keywords":["event-bus","nats","outbox","event-driven","microservices","typescript"],"repository":{"type":"git","url":"https://git.opendex.dev/aip/event-bus.git"},"description":"Event bus library with NATS implementation and Outbox pattern support","maintainers":[{"name":"agrufino","email":"agrufino@cloud.opendex.dev"}],"readme":"# @atlas-id/event-bus\n\nProduction-ready event bus for NATS with Transactional Outbox support.\n\n## Highlights\n\n- NATS publish/subscribe with queue groups\n- Transactional Outbox processor for reliable delivery\n- Dead letter queue handling and retry controls\n- TypeScript-first API with shared contracts\n- ESM + CJS builds\n\n## Install\n\n```bash\npnpm add @atlas-id/event-bus\n```\n\n```bash\nnpm install @atlas-id/event-bus\n```\n\n## Quick start\n\n```ts\nimport { NatsEventBus } from \"@atlas-id/event-bus\";\nimport type { EventEnvelope } from \"@atlas-id/contracts\";\n\nconst eventBus = new NatsEventBus(\"nats://localhost:4222\", {\n  maxReconnectAttempts: 10,\n  reconnectTimeWait: 2000,\n  name: \"my-service\",\n  logger: console,\n});\n\nawait eventBus.connect();\n\nconst event: EventEnvelope<{ userId: string }> = {\n  id: \"event-123\",\n  type: \"user.created\",\n  version: \"1.0.0\",\n  occurredAt: new Date().toISOString(),\n  payload: { userId: \"user-456\" },\n  meta: { source: \"users-service\" },\n};\n\nawait eventBus.publish(\"user\", event);\n\nconst subscription = await eventBus.subscribe(\n  \"user\",\n  async (evt) => {\n    console.log(\"Received event:\", evt);\n  },\n  { queue: \"user-processors\", maxDeliveries: 3 }\n);\n\nawait subscription.unsubscribe();\nawait eventBus.close();\n```\n\n## Transactional Outbox\n\n```ts\nimport { OutboxProcessor, PrismaOutboxRepository } from \"@atlas-id/event-bus\";\nimport { PrismaClient } from \"@prisma/client\";\n\nconst prisma = new PrismaClient();\nconst repository = new PrismaOutboxRepository(prisma);\n\nconst processor = new OutboxProcessor(eventBus, repository, {\n  pollIntervalMs: 5000,\n  batchSize: 10,\n  maxRetries: 3,\n  logger: console,\n});\n\nprocessor.start();\n```\n\nNotes:\n- `OutboxProcessor` derives the publish topic from `eventType` by removing the last segment (`orders.created.v1` -> `orders.created`).\n- Failed events are marked and can be routed to a DLQ by your bus implementation.\n\n## Configuration\n\n### NatsEventBus options\n\n- `maxReconnectAttempts` (default 10)\n- `reconnectTimeWait` (default 2000ms)\n- `name` client name used by NATS\n- `logger` optional custom logger\n\n### OutboxProcessor options\n\n- `pollIntervalMs` (default 5000ms)\n- `batchSize` (default 10)\n- `maxRetries` (default 3)\n- `logger` optional custom logger\n\n### Logger interface\n\n```ts\nexport interface Logger {\n  debug(message: string, meta?: Record<string, unknown>): void;\n  info(message: string, meta?: Record<string, unknown>): void;\n  warn(message: string, meta?: Record<string, unknown>): void;\n  error(message: string, meta?: Record<string, unknown>): void;\n}\n```\n\n## Development\n\n```bash\npnpm install\npnpm run ci\npnpm run build\npnpm run sbom\n```\n\n## Requirements\n\n- Node.js >= 18\n- NATS Server 2.x+\n- Prisma 5.x (optional, only for PrismaOutboxRepository)\n\n## License\n\nUNLICENSED - Proprietary software.\n","readmeFilename":"README.md"}