{"_id":"@efesto-cloud/unit-of-work","name":"@efesto-cloud/unit-of-work","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@efesto-cloud/unit-of-work","version":"1.0.0","description":"Database-agnostic unit-of-work / transaction boundary for efesto-cloud","repository":{"type":"git","url":"git+https://github.com/efesto-cloud/lib.git","directory":"packages/unit-of-work"},"type":"module","module":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"import":"./dist/index.js","types":"./dist/index.d.ts"},"./*":{"import":"./dist/*.js","types":"./dist/*.d.ts"}},"keywords":[],"license":"MIT","publishConfig":{"access":"public"},"scripts":{"build":"tsc --project tsconfig.json","typecheck":"tsc --noEmit","clean":"rm -rf dist"},"_id":"@efesto-cloud/unit-of-work@1.0.0","bugs":{"url":"https://github.com/efesto-cloud/lib/issues"},"homepage":"https://github.com/efesto-cloud/lib#readme","_integrity":"sha512-Bq06+R9jG/pqVgr3Fv5Gn9qy7ZT4EWVMLUXtPUXtiDzvMibQTws8OaJO6EYDCSyNxkysh9KOuJy8O3w7jl+DcA==","_resolved":"/tmp/124d943a0da942c03f242698da424a70/efesto-cloud-unit-of-work-1.0.0.tgz","_from":"file:efesto-cloud-unit-of-work-1.0.0.tgz","_nodeVersion":"24.16.0","_npmVersion":"11.13.0","dist":{"integrity":"sha512-Bq06+R9jG/pqVgr3Fv5Gn9qy7ZT4EWVMLUXtPUXtiDzvMibQTws8OaJO6EYDCSyNxkysh9KOuJy8O3w7jl+DcA==","shasum":"9785e7ab225c2ba3196f0fa49ae6cd4c062ee794","tarball":"https://registry.npmjs.org/@efesto-cloud/unit-of-work/-/unit-of-work-1.0.0.tgz","fileCount":11,"unpackedSize":4263,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@efesto-cloud%2funit-of-work@1.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQD0fyDLOYs2tPXNRcJL8/YPZn4DsrAHPhR1L1tWWCFOfwIgTNPcyIJ3P7Mi9LYugxsRMBQEWEzic8dLnq18/WKoJ60="}]},"_npmUser":{"name":"dariofurlan","email":"dario@dariofurlan.com"},"directories":{},"maintainers":[{"name":"dariofurlan","email":"dario@dariofurlan.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/unit-of-work_1.0.0_1780908808803_0.30544127090988127"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-08T08:53:28.667Z","1.0.0":"2026-06-08T08:53:28.926Z","modified":"2026-06-08T08:53:29.277Z"},"maintainers":[{"name":"dariofurlan","email":"dario@dariofurlan.com"}],"description":"Database-agnostic unit-of-work / transaction boundary for efesto-cloud","homepage":"https://github.com/efesto-cloud/lib#readme","keywords":[],"repository":{"type":"git","url":"git+https://github.com/efesto-cloud/lib.git","directory":"packages/unit-of-work"},"bugs":{"url":"https://github.com/efesto-cloud/lib/issues"},"license":"MIT","readme":"# @efesto-cloud/unit-of-work\n\nDatabase-agnostic unit-of-work / transaction boundary. Defines the interface that use cases depend on when they need atomicity — concrete implementations live in the adapter packages (e.g. [`@efesto-cloud/mongodb-unit-of-work`](../mongodb-unit-of-work)).\n\n## Installation\n\n```bash\npnpm add @efesto-cloud/unit-of-work\n```\n\n## API\n\n```ts\ninterface IUnitOfWork {\n    runWithTransaction<T>(fn: () => Promise<T>): Promise<T>;\n}\n```\n\nThat's the whole contract:\n\n- `runWithTransaction(fn)` — execute `fn` inside a transaction. If `fn` throws, the transaction is rolled back; otherwise committed. Nested calls must be safe (the implementation should reuse the outer transaction).\n\n## Usage\n\nDepend on `IUnitOfWork` from your application layer — not on a concrete driver. This keeps use cases testable and lets you swap database adapters.\n\n```ts\nimport type { IUnitOfWork } from \"@efesto-cloud/unit-of-work\";\n\nclass CreatePost {\n    constructor(private readonly uow: IUnitOfWork) {}\n\n    async execute(input: Input) {\n        return this.uow.runWithTransaction(async () => {\n            // …load, mutate, save…\n        });\n    }\n}\n```\n\n## Adapters\n\n- [`@efesto-cloud/mongodb-unit-of-work`](../mongodb-unit-of-work) — MongoDB implementation backed by `ClientSession.withTransaction`.\n- [`@efesto-cloud/prisma-unit-of-work`](../prisma-unit-of-work) — Prisma implementation backed by `prisma.$transaction`.\n","readmeFilename":"README.md","_rev":"1-ec3b208a0dd24f3956992c55df4feee4"}