{"_id":"@deltic/event-sourcing","_rev":"4-ddd845f7c2f20039bf4c68d1eefa609f","name":"@deltic/event-sourcing","dist-tags":{"latest":"0.1.3"},"versions":{"0.1.0":{"name":"@deltic/event-sourcing","version":"0.1.0","keywords":["event-sourcing","aggregate","cqrs","domain-events","snapshotting"],"author":{"url":"https://frankdejonge.nl","name":"Frank de Jonge"},"license":"ISC","_id":"@deltic/event-sourcing@0.1.0","maintainers":[{"name":"frankdejonge","email":"info@frankdejonge.nl"}],"homepage":"https://github.com/deltic-oss/deltic#readme","bugs":{"url":"https://github.com/deltic-oss/deltic/issues"},"dist":{"shasum":"bd840fa04877fa4d38071c512eedeb6d12f60288","tarball":"https://registry.npmjs.org/@deltic/event-sourcing/-/event-sourcing-0.1.0.tgz","fileCount":40,"integrity":"sha512-JQyxkzy9kPpjDPlMBerO3AZ/D10I92KlfCXxuTDxyQE9/8K8sPzu2UMdNdHbvsYCQCjdHRrGEEwQQx1+ZHHTeQ==","signatures":[{"sig":"MEYCIQCvFIKYKZIiiVKc2EsMFvYImF1ywZ0m8NKD8rxjOvHC6gIhAIEkVDKsyGWc93o2T6F0MxxYmmFRa8GHtjsp2u5WYfKD","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":78713},"type":"module","_from":"file:deltic-event-sourcing-0.1.0.tgz","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs","module-sync":"./dist/index.js"},"./snapshotting":{"types":"./dist/snapshotting.d.ts","import":"./dist/snapshotting.js","require":"./dist/snapshotting.cjs","module-sync":"./dist/snapshotting.js"},"./test-tooling":{"types":"./dist/test-tooling.d.ts","import":"./dist/test-tooling.js","require":"./dist/test-tooling.cjs","module-sync":"./dist/test-tooling.js"},"./using-handler-map":{"types":"./dist/using-handler-map.d.ts","import":"./dist/using-handler-map.js","require":"./dist/using-handler-map.cjs","module-sync":"./dist/using-handler-map.js"},"./using-reducer-map":{"types":"./dist/using-reducer-map.d.ts","import":"./dist/using-reducer-map.js","require":"./dist/using-reducer-map.cjs","module-sync":"./dist/using-reducer-map.js"},"./using-reducer-func":{"types":"./dist/using-reducer-func.d.ts","import":"./dist/using-reducer-func.js","require":"./dist/using-reducer-func.cjs","module-sync":"./dist/using-reducer-func.js"},"./aggregate-projection":{"types":"./dist/aggregate-projection.d.ts","import":"./dist/aggregate-projection.js","require":"./dist/aggregate-projection.cjs","module-sync":"./dist/aggregate-projection.js"},"./pg/snapshot-repository":{"types":"./dist/pg/snapshot-repository.d.ts","import":"./dist/pg/snapshot-repository.js","require":"./dist/pg/snapshot-repository.cjs","module-sync":"./dist/pg/snapshot-repository.js"},"./using-reflect-metadata":{"types":"./dist/using-reflect-metadata.d.ts","import":"./dist/using-reflect-metadata.js","require":"./dist/using-reflect-metadata.cjs","module-sync":"./dist/using-reflect-metadata.js"}},"scripts":{},"_npmUser":{"name":"frankdejonge","email":"info@frankdejonge.nl"},"_resolved":"/private/var/folders/cf/f1s7n7kd3938zynwcqk8_2z00000gn/T/562d2a734fd0e14366b53c7ef734b41d/deltic-event-sourcing-0.1.0.tgz","_integrity":"sha512-JQyxkzy9kPpjDPlMBerO3AZ/D10I92KlfCXxuTDxyQE9/8K8sPzu2UMdNdHbvsYCQCjdHRrGEEwQQx1+ZHHTeQ==","repository":{"url":"git+https://github.com/deltic-oss/deltic.git","type":"git","directory":"packages/event-sourcing"},"_npmVersion":"11.6.0","description":"A rich event-sourcing implementation","directories":{},"_nodeVersion":"24.8.0","dependencies":{"@deltic/clock":"^0.1.1","@deltic/messaging":"^0.1.0","@deltic/transaction-manager":"^0.1.0"},"_hasShrinkwrap":false,"devDependencies":{"pg":"^8.16.3","uuid":"^11.0.3","@types/pg":"^8.15.6","@deltic/uid":"^0.1.0","@deltic/context":"^0.1.0","reflect-metadata":"^0.2.2","@deltic/async-pg-pool":"^0.2.0","@deltic/service-dispatcher":"^0.2.0"},"peerDependencies":{"pg":"^8.16.3","@deltic/uid":"^0.1.0","@deltic/clock":"^0.1.1","@deltic/context":"^0.1.0","reflect-metadata":"^0.2.2","@deltic/messaging":"^0.1.0","@deltic/async-pg-pool":"^0.2.0","@deltic/service-dispatcher":"^0.2.0","@deltic/transaction-manager":"^0.1.0"},"peerDependenciesMeta":{"pg":{"optional":true},"@deltic/uid":{"optional":true},"@deltic/context":{"optional":true},"@deltic/async-pg-pool":{"optional":true},"@deltic/service-dispatcher":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/event-sourcing_0.1.0_1774450026911_0.7702579038042072","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@deltic/event-sourcing","version":"0.1.1","keywords":["event-sourcing","aggregate","cqrs","domain-events","snapshotting"],"author":{"url":"https://frankdejonge.nl","name":"Frank de Jonge"},"license":"ISC","_id":"@deltic/event-sourcing@0.1.1","maintainers":[{"name":"frankdejonge","email":"info@frankdejonge.nl"}],"homepage":"https://github.com/deltic-oss/deltic#readme","bugs":{"url":"https://github.com/deltic-oss/deltic/issues"},"dist":{"shasum":"b94ba3a4feef8ef0dd3b61fea25fa17a796b84e9","tarball":"https://registry.npmjs.org/@deltic/event-sourcing/-/event-sourcing-0.1.1.tgz","fileCount":40,"integrity":"sha512-8lHDHv1Bjyxe8W8CwNahfLzVPrC1mIV4HAqLJznKbEGzLH0jQguXBbZe9poaUIGBgGcUEOIuP+nH/tupKUjpXQ==","signatures":[{"sig":"MEUCIQCLm05zt578b2kpJIZB0D0mfbT5cBdwBHk2lDDkJdx5pwIgUpeALRxfWWmdpa9E3uP5w1BSurlk/AA4KoHFuAb12l0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":79052},"type":"module","_from":"file:deltic-event-sourcing-0.1.1.tgz","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs","module-sync":"./dist/index.mjs"},"./snapshotting":{"types":"./dist/snapshotting.d.ts","import":"./dist/snapshotting.mjs","require":"./dist/snapshotting.cjs","module-sync":"./dist/snapshotting.mjs"},"./test-tooling":{"types":"./dist/test-tooling.d.ts","import":"./dist/test-tooling.mjs","require":"./dist/test-tooling.cjs","module-sync":"./dist/test-tooling.mjs"},"./using-handler-map":{"types":"./dist/using-handler-map.d.ts","import":"./dist/using-handler-map.mjs","require":"./dist/using-handler-map.cjs","module-sync":"./dist/using-handler-map.mjs"},"./using-reducer-map":{"types":"./dist/using-reducer-map.d.ts","import":"./dist/using-reducer-map.mjs","require":"./dist/using-reducer-map.cjs","module-sync":"./dist/using-reducer-map.mjs"},"./using-reducer-func":{"types":"./dist/using-reducer-func.d.ts","import":"./dist/using-reducer-func.mjs","require":"./dist/using-reducer-func.cjs","module-sync":"./dist/using-reducer-func.mjs"},"./aggregate-projection":{"types":"./dist/aggregate-projection.d.ts","import":"./dist/aggregate-projection.mjs","require":"./dist/aggregate-projection.cjs","module-sync":"./dist/aggregate-projection.mjs"},"./pg/snapshot-repository":{"types":"./dist/pg/snapshot-repository.d.ts","import":"./dist/pg/snapshot-repository.mjs","require":"./dist/pg/snapshot-repository.cjs","module-sync":"./dist/pg/snapshot-repository.mjs"},"./using-reflect-metadata":{"types":"./dist/using-reflect-metadata.d.ts","import":"./dist/using-reflect-metadata.mjs","require":"./dist/using-reflect-metadata.cjs","module-sync":"./dist/using-reflect-metadata.mjs"}},"scripts":{},"_npmUser":{"name":"frankdejonge","email":"info@frankdejonge.nl"},"_resolved":"/private/var/folders/cf/f1s7n7kd3938zynwcqk8_2z00000gn/T/55f826012e8116b09b00a97e1a338939/deltic-event-sourcing-0.1.1.tgz","_integrity":"sha512-8lHDHv1Bjyxe8W8CwNahfLzVPrC1mIV4HAqLJznKbEGzLH0jQguXBbZe9poaUIGBgGcUEOIuP+nH/tupKUjpXQ==","repository":{"url":"git+https://github.com/deltic-oss/deltic.git","type":"git","directory":"packages/event-sourcing"},"_npmVersion":"11.6.0","description":"A rich event-sourcing implementation","directories":{},"_nodeVersion":"24.8.0","dependencies":{"@deltic/clock":"^0.1.2","@deltic/messaging":"^0.1.1","@deltic/transaction-manager":"^0.1.1"},"_hasShrinkwrap":false,"devDependencies":{"pg":"^8.16.3","uuid":"^11.0.3","@types/pg":"^8.15.6","@deltic/uid":"^0.1.1","@deltic/context":"^0.1.1","reflect-metadata":"^0.2.2","@deltic/async-pg-pool":"^0.2.1","@deltic/service-dispatcher":"^0.2.1"},"peerDependencies":{"pg":"^8.16.3","@deltic/uid":"^0.1.1","@deltic/clock":"^0.1.2","@deltic/context":"^0.1.1","reflect-metadata":"^0.2.2","@deltic/messaging":"^0.1.1","@deltic/async-pg-pool":"^0.2.1","@deltic/service-dispatcher":"^0.2.1","@deltic/transaction-manager":"^0.1.1"},"peerDependenciesMeta":{"pg":{"optional":true},"@deltic/uid":{"optional":true},"@deltic/context":{"optional":true},"@deltic/async-pg-pool":{"optional":true},"@deltic/service-dispatcher":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/event-sourcing_0.1.1_1774454225174_0.46019551844305906","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@deltic/event-sourcing","version":"0.1.2","keywords":["event-sourcing","aggregate","cqrs","domain-events","snapshotting"],"author":{"url":"https://frankdejonge.nl","name":"Frank de Jonge"},"license":"ISC","_id":"@deltic/event-sourcing@0.1.2","maintainers":[{"name":"frankdejonge","email":"info@frankdejonge.nl"}],"homepage":"https://github.com/deltic-oss/deltic#readme","bugs":{"url":"https://github.com/deltic-oss/deltic/issues"},"dist":{"shasum":"a36c01f3d910feb1835eb31b7ef3a39daa5f34b5","tarball":"https://registry.npmjs.org/@deltic/event-sourcing/-/event-sourcing-0.1.2.tgz","fileCount":40,"integrity":"sha512-RjCIAZJmpTeJgMl0oneSFIGFo3LDViKfKwK43gHoxjkXp0lTqY8iKVhmUDuEaoCSqs4jt5HpTo2MHq6RC1Z3ZA==","signatures":[{"sig":"MEYCIQDDloeMlorp2Dg9ybGIY37YfOXvy79+KLDXUU+IB3YqFQIhAPxK1+Vi9xhAoIaZluc243E8ikb6ob1paz7Ah+WCnQiT","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":79382},"type":"module","_from":"file:deltic-event-sourcing-0.1.2.tgz","exports":{".":{"types":"./dist/index.d.mts","import":"./dist/index.mjs","require":"./dist/index.cjs","module-sync":"./dist/index.mjs"},"./snapshotting":{"types":"./dist/snapshotting.d.mts","import":"./dist/snapshotting.mjs","require":"./dist/snapshotting.cjs","module-sync":"./dist/snapshotting.mjs"},"./test-tooling":{"types":"./dist/test-tooling.d.mts","import":"./dist/test-tooling.mjs","require":"./dist/test-tooling.cjs","module-sync":"./dist/test-tooling.mjs"},"./using-handler-map":{"types":"./dist/using-handler-map.d.mts","import":"./dist/using-handler-map.mjs","require":"./dist/using-handler-map.cjs","module-sync":"./dist/using-handler-map.mjs"},"./using-reducer-map":{"types":"./dist/using-reducer-map.d.mts","import":"./dist/using-reducer-map.mjs","require":"./dist/using-reducer-map.cjs","module-sync":"./dist/using-reducer-map.mjs"},"./using-reducer-func":{"types":"./dist/using-reducer-func.d.mts","import":"./dist/using-reducer-func.mjs","require":"./dist/using-reducer-func.cjs","module-sync":"./dist/using-reducer-func.mjs"},"./aggregate-projection":{"types":"./dist/aggregate-projection.d.mts","import":"./dist/aggregate-projection.mjs","require":"./dist/aggregate-projection.cjs","module-sync":"./dist/aggregate-projection.mjs"},"./pg/snapshot-repository":{"types":"./dist/pg/snapshot-repository.d.mts","import":"./dist/pg/snapshot-repository.mjs","require":"./dist/pg/snapshot-repository.cjs","module-sync":"./dist/pg/snapshot-repository.mjs"},"./using-reflect-metadata":{"types":"./dist/using-reflect-metadata.d.mts","import":"./dist/using-reflect-metadata.mjs","require":"./dist/using-reflect-metadata.cjs","module-sync":"./dist/using-reflect-metadata.mjs"}},"scripts":{},"_npmUser":{"name":"frankdejonge","email":"info@frankdejonge.nl"},"_resolved":"/private/var/folders/cf/f1s7n7kd3938zynwcqk8_2z00000gn/T/42d5ef567885522eed69330eaac78c86/deltic-event-sourcing-0.1.2.tgz","_integrity":"sha512-RjCIAZJmpTeJgMl0oneSFIGFo3LDViKfKwK43gHoxjkXp0lTqY8iKVhmUDuEaoCSqs4jt5HpTo2MHq6RC1Z3ZA==","repository":{"url":"git+https://github.com/deltic-oss/deltic.git","type":"git","directory":"packages/event-sourcing"},"_npmVersion":"11.6.0","description":"A rich event-sourcing implementation","directories":{},"_nodeVersion":"24.8.0","dependencies":{"@deltic/clock":"^0.1.3","@deltic/messaging":"^0.1.2","@deltic/transaction-manager":"^0.1.2"},"_hasShrinkwrap":false,"devDependencies":{"pg":"^8.16.3","uuid":"^11.0.3","@types/pg":"^8.15.6","@deltic/uid":"^0.1.2","@deltic/context":"^0.1.2","reflect-metadata":"^0.2.2","@deltic/async-pg-pool":"^0.2.2","@deltic/service-dispatcher":"^0.2.2"},"peerDependencies":{"pg":"^8.16.3","@deltic/uid":"^0.1.2","@deltic/clock":"^0.1.3","@deltic/context":"^0.1.2","reflect-metadata":"^0.2.2","@deltic/messaging":"^0.1.2","@deltic/async-pg-pool":"^0.2.2","@deltic/service-dispatcher":"^0.2.2","@deltic/transaction-manager":"^0.1.2"},"peerDependenciesMeta":{"pg":{"optional":true},"@deltic/uid":{"optional":true},"@deltic/context":{"optional":true},"@deltic/async-pg-pool":{"optional":true},"@deltic/service-dispatcher":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/event-sourcing_0.1.2_1774454591656_0.2641495893568102","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"@deltic/event-sourcing","type":"module","version":"0.1.3","description":"A rich event-sourcing implementation","exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.cjs","module-sync":"./dist/index.mjs","types":"./dist/index.d.mts"},"./aggregate-projection":{"import":"./dist/aggregate-projection.mjs","require":"./dist/aggregate-projection.cjs","module-sync":"./dist/aggregate-projection.mjs","types":"./dist/aggregate-projection.d.mts"},"./using-reflect-metadata":{"import":"./dist/using-reflect-metadata.mjs","require":"./dist/using-reflect-metadata.cjs","module-sync":"./dist/using-reflect-metadata.mjs","types":"./dist/using-reflect-metadata.d.mts"},"./snapshotting":{"import":"./dist/snapshotting.mjs","require":"./dist/snapshotting.cjs","module-sync":"./dist/snapshotting.mjs","types":"./dist/snapshotting.d.mts"},"./test-tooling":{"import":"./dist/test-tooling.mjs","require":"./dist/test-tooling.cjs","module-sync":"./dist/test-tooling.mjs","types":"./dist/test-tooling.d.mts"},"./pg/snapshot-repository":{"import":"./dist/pg/snapshot-repository.mjs","require":"./dist/pg/snapshot-repository.cjs","module-sync":"./dist/pg/snapshot-repository.mjs","types":"./dist/pg/snapshot-repository.d.mts"},"./using-handler-map":{"import":"./dist/using-handler-map.mjs","require":"./dist/using-handler-map.cjs","module-sync":"./dist/using-handler-map.mjs","types":"./dist/using-handler-map.d.mts"},"./using-reducer-func":{"import":"./dist/using-reducer-func.mjs","require":"./dist/using-reducer-func.cjs","module-sync":"./dist/using-reducer-func.mjs","types":"./dist/using-reducer-func.d.mts"},"./using-reducer-map":{"import":"./dist/using-reducer-map.mjs","require":"./dist/using-reducer-map.cjs","module-sync":"./dist/using-reducer-map.mjs","types":"./dist/using-reducer-map.d.mts"}},"keywords":["event-sourcing","aggregate","cqrs","domain-events","snapshotting"],"author":{"name":"Frank de Jonge","url":"https://frankdejonge.nl"},"license":"ISC","repository":{"type":"git","url":"git+https://github.com/deltic-oss/deltic.git","directory":"packages/event-sourcing"},"dependencies":{"@deltic/transaction-manager":"^0.1.2","@deltic/clock":"^0.1.3","@deltic/messaging":"^0.1.2"},"peerDependencies":{"pg":"^8.16.3","reflect-metadata":"^0.2.2","@deltic/async-pg-pool":"^0.2.3","@deltic/clock":"^0.1.3","@deltic/context":"^0.1.4","@deltic/messaging":"^0.1.2","@deltic/transaction-manager":"^0.1.2","@deltic/service-dispatcher":"^0.2.3","@deltic/uid":"^0.1.2"},"devDependencies":{"@types/pg":"^8.20.0","pg":"^8.20.0","reflect-metadata":"^0.2.2","uuid":"^13.0.0","@deltic/async-pg-pool":"^0.2.3","@deltic/context":"^0.1.4","@deltic/service-dispatcher":"^0.2.3","@deltic/uid":"^0.1.2"},"peerDependenciesMeta":{"@deltic/service-dispatcher":{"optional":true},"@deltic/async-pg-pool":{"optional":true},"@deltic/context":{"optional":true},"@deltic/uid":{"optional":true},"pg":{"optional":true}},"scripts":{},"_id":"@deltic/event-sourcing@0.1.3","bugs":{"url":"https://github.com/deltic-oss/deltic/issues"},"homepage":"https://github.com/deltic-oss/deltic#readme","_integrity":"sha512-2Jkwi5oGoRh2QYQOojCH6Z79/KrAlprIja5O3+axFvSmxU23DF76lk/kmHSh5GoPBiaoHQFdivvQzG/WTqQ2hA==","_resolved":"/private/var/folders/cf/f1s7n7kd3938zynwcqk8_2z00000gn/T/b4e7d5064fdc0f8532d53780eafef7b2/deltic-event-sourcing-0.1.3.tgz","_from":"file:deltic-event-sourcing-0.1.3.tgz","_nodeVersion":"24.8.0","_npmVersion":"11.6.0","dist":{"integrity":"sha512-2Jkwi5oGoRh2QYQOojCH6Z79/KrAlprIja5O3+axFvSmxU23DF76lk/kmHSh5GoPBiaoHQFdivvQzG/WTqQ2hA==","shasum":"07af2d8d483dcb4065955adf50b848e8800f5009","tarball":"https://registry.npmjs.org/@deltic/event-sourcing/-/event-sourcing-0.1.3.tgz","fileCount":40,"unpackedSize":80095,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC0bTZrPyDiefnb0HgwfSgegKLsqfHuT054EmzK9/hCvQIgLGSr4slnTyRtiKzr/N4vMDMdHbJs+hHWIz+RIyKwPKU="}]},"_npmUser":{"name":"frankdejonge","email":"info@frankdejonge.nl"},"directories":{},"maintainers":[{"name":"frankdejonge","email":"info@frankdejonge.nl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/event-sourcing_0.1.3_1775721106194_0.6250246329003608"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-25T14:47:06.818Z","modified":"2026-04-09T07:51:46.491Z","0.1.0":"2026-03-25T14:47:07.048Z","0.1.1":"2026-03-25T15:57:05.409Z","0.1.2":"2026-03-25T16:03:11.837Z","0.1.3":"2026-04-09T07:51:46.338Z"},"bugs":{"url":"https://github.com/deltic-oss/deltic/issues"},"author":{"name":"Frank de Jonge","url":"https://frankdejonge.nl"},"license":"ISC","homepage":"https://github.com/deltic-oss/deltic#readme","keywords":["event-sourcing","aggregate","cqrs","domain-events","snapshotting"],"repository":{"type":"git","url":"git+https://github.com/deltic-oss/deltic.git","directory":"packages/event-sourcing"},"description":"A rich event-sourcing implementation","maintainers":[{"name":"frankdejonge","email":"info@frankdejonge.nl"}],"readme":"# @deltic/event-sourcing\n\nA rich event-sourcing implementation with aggregate roots, multiple reducer patterns, snapshotting, and projections.\n\n## Installation\n\n```bash\nnpm install @deltic/event-sourcing @deltic/messaging @deltic/clock @deltic/transaction-manager\n```\n\n## Usage\n\n### Defining an Aggregate Stream\n\n```typescript\nimport type {AggregateStream, AggregateRoot} from '@deltic/event-sourcing';\n\ninterface OrderStream extends AggregateStream<OrderStream> {\n    aggregateRootId: string;\n    aggregateRoot: Order;\n    messages: {\n        OrderPlaced: {total: number};\n        OrderShipped: {trackingNumber: string};\n        OrderCancelled: {reason: string};\n    };\n}\n```\n\n### Implementing an Aggregate Root\n\nExtend `AggregateRootBehavior` and implement `apply()` to handle events:\n\n```typescript\nimport {AggregateRootBehavior} from '@deltic/event-sourcing';\n\nclass Order extends AggregateRootBehavior<OrderStream> {\n    private total = 0;\n    private status: 'pending' | 'shipped' | 'cancelled' = 'pending';\n\n    static place(id: string, total: number): Order {\n        const order = new Order(id);\n        order.recordThat('OrderPlaced', {total});\n        return order;\n    }\n\n    ship(trackingNumber: string): void {\n        this.recordThat('OrderShipped', {trackingNumber});\n    }\n\n    protected apply(message: AnyMessageFrom<OrderStream>): void {\n        switch (message.type) {\n            case 'OrderPlaced':\n                this.total = message.payload.total;\n                break;\n            case 'OrderShipped':\n                this.status = 'shipped';\n                break;\n            case 'OrderCancelled':\n                this.status = 'cancelled';\n                break;\n        }\n    }\n}\n```\n\n### Using a Handler Map\n\nFor explicit event-to-handler mapping:\n\n```typescript\nimport {AggregateRootUsingHandlerMap} from '@deltic/event-sourcing/using-handler-map';\n\nclass Order extends AggregateRootUsingHandlerMap<OrderStream> {\n    protected handlers = {\n        OrderPlaced: (message) => { this.total = message.payload.total; },\n        OrderShipped: (message) => { this.status = 'shipped'; },\n        OrderCancelled: (message) => { this.status = 'cancelled'; },\n    };\n}\n```\n\n### Using a Reducer Function\n\nFor functional-style state management:\n\n```typescript\nimport {AggregateRootUsingReducerFunc} from '@deltic/event-sourcing/using-reducer-func';\n\ntype OrderState = {total: number; status: string};\n\nclass Order extends AggregateRootUsingReducerFunc<OrderStream, OrderState> {\n    constructor(id: string) {\n        super(id, {total: 0, status: 'pending'});\n    }\n\n    protected reduce(state: OrderState, message: AnyMessageFrom<OrderStream>): OrderState {\n        switch (message.type) {\n            case 'OrderPlaced':\n                return {...state, total: message.payload.total};\n            case 'OrderShipped':\n                return {...state, status: 'shipped'};\n            default:\n                return state;\n        }\n    }\n}\n```\n\n### Using Reflect Metadata Decorators\n\n```typescript\nimport {AggregateRootUsingReflectMetadata, makeEventHandler} from '@deltic/event-sourcing/using-reflect-metadata';\n\nconst handle = makeEventHandler<OrderStream>();\n\nclass Order extends AggregateRootUsingReflectMetadata<OrderStream> {\n    @handle('OrderPlaced')\n    onOrderPlaced(message: SpecificMessageFrom<OrderStream, 'OrderPlaced'>) {\n        this.total = message.payload.total;\n    }\n}\n```\n\n### Repository\n\nPersist and retrieve aggregates:\n\n```typescript\nimport {EventSourcedAggregateRepository} from '@deltic/event-sourcing';\n\nconst repository = new EventSourcedAggregateRepository<OrderStream>(\n    orderFactory,\n    messageRepository,\n    messageDispatcher,   // optional: dispatch events on persist\n    messageDecorator,    // optional: decorate events before storage\n    transactionManager,\n);\n\n// Retrieve\nconst order = await repository.retrieve(orderId);\nconst orderAtV3 = await repository.retrieveAtVersion(orderId, 3);\n\n// Persist\nconst order = Order.place('order-1', 99.99);\nawait repository.persist(order);\n```\n\n### Snapshotting\n\nSpeed up reconstitution by storing aggregate state snapshots:\n\n```typescript\nimport {AggregateRootRepositoryWithSnapshotting} from '@deltic/event-sourcing/snapshotting';\n\nconst repository = new AggregateRootRepositoryWithSnapshotting<OrderStream>(\n    orderFactory,\n    snapshotRepository,\n    messageRepository,\n    messageDispatcher,\n    messageDecorator,\n    false, // authoritativeSnapshots — if true, snapshots are trusted without replaying events\n    transactionManager,\n);\n\n// Persist with snapshot\nawait repository.persist(order, true); // second arg stores a snapshot\n```\n\n### Aggregate Projections\n\nAutomatically project aggregate state on persist:\n\n```typescript\nimport {AggregateRepositoryWithProjector} from '@deltic/event-sourcing/aggregate-projection';\n\nconst repository = new AggregateRepositoryWithProjector<OrderStream>(\n    eventSourcedRepository,\n    projector,\n    transactionManager,\n);\n\n// Projector runs after every persist\nawait repository.persist(order);\n```\n\n## API Reference\n\n### Core Interfaces\n\n| Interface | Description |\n|-----------|-------------|\n| `AggregateStream<Stream>` | Defines aggregate ID, root type, and message shapes |\n| `AggregateRoot<Stream>` | Aggregate root with event recording |\n| `AggregateRootFactory<Stream>` | Reconstitutes aggregates from events |\n| `AggregateRepository<Stream>` | Persist and retrieve aggregates |\n\n### `AggregateRoot<Stream>` Methods\n\n| Method | Description |\n|--------|-------------|\n| `releaseEvents()` | Returns and clears unreleased events |\n| `peekEvents()` | Returns a copy of unreleased events |\n| `hasUnreleasedEvents()` | Whether there are uncommitted events |\n| `aggregateRootVersion()` | Current version number |\n\n### Base Classes\n\n| Class | Import | Description |\n|-------|--------|-------------|\n| `AggregateRootBehavior` | `@deltic/event-sourcing` | Abstract base with `recordThat()` and `apply()` |\n| `AggregateRootUsingHandlerMap` | `@deltic/event-sourcing/using-handler-map` | Event-to-handler map |\n| `AggregateRootUsingReducerFunc` | `@deltic/event-sourcing/using-reducer-func` | Functional reducer |\n| `AggregateRootUsingReflectMetadata` | `@deltic/event-sourcing/using-reflect-metadata` | Decorator-based handlers |\n\n### Entry Points\n\n| Import | Description |\n|--------|-------------|\n| `@deltic/event-sourcing` | Core aggregate types and repository |\n| `@deltic/event-sourcing/using-handler-map` | Handler map base class |\n| `@deltic/event-sourcing/using-reducer-func` | Reducer function base class |\n| `@deltic/event-sourcing/using-reducer-map` | Reducer map implementation |\n| `@deltic/event-sourcing/using-reflect-metadata` | Decorator-based handlers |\n| `@deltic/event-sourcing/snapshotting` | Snapshot support |\n| `@deltic/event-sourcing/aggregate-projection` | Projection support |\n| `@deltic/event-sourcing/test-tooling` | Testing helpers |\n| `@deltic/event-sourcing/pg/snapshot-repository` | PostgreSQL snapshot storage |\n\n## License\n\nISC\n","readmeFilename":"README.md"}