@event-driven-io/emmett-esdb 0.10.0 → 0.11.0

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.
@@ -0,0 +1,2 @@
1
+ var h=(e=>(e.NOT_A_NONEMPTY_STRING="NOT_A_NONEMPTY_STRING",e.NOT_A_POSITIVE_NUMBER="NOT_A_POSITIVE_NUMBER",e.NOT_AN_UNSIGNED_BIGINT="NOT_AN_UNSIGNED_BIGINT",e))(h||{}),E=e=>typeof e=="number"&&e===e,S=e=>typeof e=="string";var y=class v extends Error{errorCode;constructor(t){let r=t&&typeof t=="object"&&"errorCode"in t?t.errorCode:E(t)?t:500,s=t&&typeof t=="object"&&"message"in t?t.message:S(t)?t:`Error with status code '${r}' ocurred during Emmett processing`;super(s),this.errorCode=r,Object.setPrototypeOf(this,v.prototype)}},u=class T extends y{constructor(t,r,s){super({errorCode:412,message:s??`Expected version ${r.toString()} does not match current ${t?.toString()}`}),this.current=t,this.expected=r,Object.setPrototypeOf(this,T.prototype)}};var l="STREAM_EXISTS",m="STREAM_DOES_NOT_EXIST",i="NO_CONCURRENCY_CHECK";var d=class O extends u{constructor(t,r){super(t?.toString(),r?.toString()),Object.setPrototypeOf(this,O.prototype)}};import{v4 as le}from"uuid";import{ANY as f,STREAM_EXISTS as x,NO_STREAM as b,StreamNotFoundError as N,WrongExpectedVersionError as k,jsonEvent as P}from"@eventstore/db-client";var w=e=>e?{fromRevision:"from"in e?e.from:void 0,maxCount:"maxCount"in e?e.maxCount:"to"in e?e.to:void 0}:void 0,Tt=e=>({async aggregateStream(t,r){try{let{evolve:s,initialState:n,read:a}=r,g=a?.expectedStreamVersion,c=n(),p;for await(let{event:o}of e.readStream(t,w(r.read)))o&&(c=s(c,{type:o.type,data:o.data,metadata:{...o.metadata??{},eventId:o.id,streamName:o.streamId,streamPosition:o.revision,globalPosition:o.position.commit}}),p=o.revision);return Y(p,g),{currentStreamVersion:p??0n,state:c}}catch(s){if(s instanceof N)return null;throw s}},readStream:async(t,r)=>{let s=[],n;try{for await(let{event:a}of e.readStream(t,w(r)))a&&(s.push({type:a.type,data:a.data,metadata:{eventId:a.id,streamName:a.streamId,streamPosition:a.revision,globalPosition:a.position.commit}}),n=a.revision);return n?{currentStreamVersion:n,events:s}:null}catch(a){if(a instanceof N)return null;throw a}},appendToStream:async(t,r,s)=>{try{let n=r.map(P),a=D(s?.expectedStreamVersion);return{nextExpectedStreamVersion:(await e.appendToStream(t,n,{expectedRevision:a})).nextExpectedRevision}}catch(n){throw n instanceof k?new d(n.actualVersion,j(n.expectedVersion)):n}}}),D=e=>e===void 0?f:e===i?f:e==m?b:e==l?x:e,j=e=>e===void 0?i:e===f?i:e==b?m:e==x?l:e,B=(e,t)=>t===i?!0:t==m?e===void 0:t==l?e!==void 0:e===t,Y=(e,t)=>{if(t??=i,!B(e,t))throw new d(e,t)};export{Tt as a};
2
+ //# sourceMappingURL=chunk-6MEKGDXJ.mjs.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var h=(e=>(e.NOT_A_NONEMPTY_STRING="NOT_A_NONEMPTY_STRING",e.NOT_A_POSITIVE_NUMBER="NOT_A_POSITIVE_NUMBER",e.NOT_AN_UNSIGNED_BIGINT="NOT_AN_UNSIGNED_BIGINT",e))(h||{}),E=e=>typeof e=="number"&&e===e,y=e=>typeof e=="string";var S=class v extends Error{constructor(t){let r=t&&typeof t=="object"&&"errorCode"in t?t.errorCode:E(t)?t:500,s=t&&typeof t=="object"&&"message"in t?t.message:y(t)?t:`Error with status code '${r}' ocurred during Emmett processing`;super(s),this.errorCode=r,Object.setPrototypeOf(this,v.prototype)}},u=class O extends S{constructor(t,r,s){super({errorCode:412,message:_nullishCoalesce(s, () => (`Expected version ${r.toString()} does not match current ${_optionalChain([t, 'optionalAccess', _ => _.toString, 'call', _2 => _2()])}`))}),this.current=t,this.expected=r,Object.setPrototypeOf(this,O.prototype)}};var l="STREAM_EXISTS",m="STREAM_DOES_NOT_EXIST",i="NO_CONCURRENCY_CHECK";var d=class T extends u{constructor(t,r){super(_optionalChain([t, 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]),_optionalChain([r, 'optionalAccess', _5 => _5.toString, 'call', _6 => _6()])),Object.setPrototypeOf(this,T.prototype)}};var _uuid = require('uuid');var _dbclient = require('@eventstore/db-client');var w=e=>e?{fromRevision:"from"in e?e.from:void 0,maxCount:"maxCount"in e?e.maxCount:"to"in e?e.to:void 0}:void 0,Nt= exports.a =e=>({async aggregateStream(t,r){try{let{evolve:s,initialState:o,read:a}=r,g=_optionalChain([a, 'optionalAccess', _7 => _7.expectedStreamVersion]),c=o(),p;for await(let{event:n}of e.readStream(t,w(r.read)))n&&(c=s(c,{type:n.type,data:n.data,metadata:{..._nullishCoalesce(n.metadata, () => ({})),eventId:n.id,streamName:n.streamId,streamPosition:n.revision,globalPosition:n.position.commit}}),p=n.revision);return Y(p,g),{currentStreamVersion:_nullishCoalesce(p, () => (0n)),state:c}}catch(s){if(s instanceof _dbclient.StreamNotFoundError)return null;throw s}},readStream:async(t,r)=>{let s=[],o;try{for await(let{event:a}of e.readStream(t,w(r)))a&&(s.push({type:a.type,data:a.data,metadata:{eventId:a.id,streamName:a.streamId,streamPosition:a.revision,globalPosition:a.position.commit}}),o=a.revision);return o?{currentStreamVersion:o,events:s}:null}catch(a){if(a instanceof _dbclient.StreamNotFoundError)return null;throw a}},appendToStream:async(t,r,s)=>{try{let o=r.map(_dbclient.jsonEvent),a=D(_optionalChain([s, 'optionalAccess', _8 => _8.expectedStreamVersion]));return{nextExpectedStreamVersion:(await e.appendToStream(t,o,{expectedRevision:a})).nextExpectedRevision}}catch(o){throw o instanceof _dbclient.WrongExpectedVersionError?new d(o.actualVersion,j(o.expectedVersion)):o}}}),D=e=>e===void 0?_dbclient.ANY:e===i?_dbclient.ANY:e==m?_dbclient.NO_STREAM:e==l?_dbclient.STREAM_EXISTS:e,j=e=>e===void 0?i:e===_dbclient.ANY?i:e==_dbclient.NO_STREAM?m:e==_dbclient.STREAM_EXISTS?l:e,B=(e,t)=>t===i?!0:t==m?e===void 0:t==l?e!==void 0:e===t,Y=(e,t)=>{if(t??=i,!B(e,t))throw new d(e,t)};exports.a = Nt;
2
- //# sourceMappingURL=chunk-N6MJKM6Y.js.map
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var h=(e=>(e.NOT_A_NONEMPTY_STRING="NOT_A_NONEMPTY_STRING",e.NOT_A_POSITIVE_NUMBER="NOT_A_POSITIVE_NUMBER",e.NOT_AN_UNSIGNED_BIGINT="NOT_AN_UNSIGNED_BIGINT",e))(h||{}),E=e=>typeof e=="number"&&e===e,S=e=>typeof e=="string";var y=class v extends Error{constructor(t){let r=t&&typeof t=="object"&&"errorCode"in t?t.errorCode:E(t)?t:500,s=t&&typeof t=="object"&&"message"in t?t.message:S(t)?t:`Error with status code '${r}' ocurred during Emmett processing`;super(s),this.errorCode=r,Object.setPrototypeOf(this,v.prototype)}},u=class T extends y{constructor(t,r,s){super({errorCode:412,message:_nullishCoalesce(s, () => (`Expected version ${r.toString()} does not match current ${_optionalChain([t, 'optionalAccess', _ => _.toString, 'call', _2 => _2()])}`))}),this.current=t,this.expected=r,Object.setPrototypeOf(this,T.prototype)}};var l="STREAM_EXISTS",m="STREAM_DOES_NOT_EXIST",i="NO_CONCURRENCY_CHECK";var d=class O extends u{constructor(t,r){super(_optionalChain([t, 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]),_optionalChain([r, 'optionalAccess', _5 => _5.toString, 'call', _6 => _6()])),Object.setPrototypeOf(this,O.prototype)}};var _uuid = require('uuid');var _dbclient = require('@eventstore/db-client');var w=e=>e?{fromRevision:"from"in e?e.from:void 0,maxCount:"maxCount"in e?e.maxCount:"to"in e?e.to:void 0}:void 0,Tt= exports.a =e=>({async aggregateStream(t,r){try{let{evolve:s,initialState:n,read:a}=r,g=_optionalChain([a, 'optionalAccess', _7 => _7.expectedStreamVersion]),c=n(),p;for await(let{event:o}of e.readStream(t,w(r.read)))o&&(c=s(c,{type:o.type,data:o.data,metadata:{..._nullishCoalesce(o.metadata, () => ({})),eventId:o.id,streamName:o.streamId,streamPosition:o.revision,globalPosition:o.position.commit}}),p=o.revision);return Y(p,g),{currentStreamVersion:_nullishCoalesce(p, () => (0n)),state:c}}catch(s){if(s instanceof _dbclient.StreamNotFoundError)return null;throw s}},readStream:async(t,r)=>{let s=[],n;try{for await(let{event:a}of e.readStream(t,w(r)))a&&(s.push({type:a.type,data:a.data,metadata:{eventId:a.id,streamName:a.streamId,streamPosition:a.revision,globalPosition:a.position.commit}}),n=a.revision);return n?{currentStreamVersion:n,events:s}:null}catch(a){if(a instanceof _dbclient.StreamNotFoundError)return null;throw a}},appendToStream:async(t,r,s)=>{try{let n=r.map(_dbclient.jsonEvent),a=D(_optionalChain([s, 'optionalAccess', _8 => _8.expectedStreamVersion]));return{nextExpectedStreamVersion:(await e.appendToStream(t,n,{expectedRevision:a})).nextExpectedRevision}}catch(n){throw n instanceof _dbclient.WrongExpectedVersionError?new d(n.actualVersion,j(n.expectedVersion)):n}}}),D=e=>e===void 0?_dbclient.ANY:e===i?_dbclient.ANY:e==m?_dbclient.NO_STREAM:e==l?_dbclient.STREAM_EXISTS:e,j=e=>e===void 0?i:e===_dbclient.ANY?i:e==_dbclient.NO_STREAM?m:e==_dbclient.STREAM_EXISTS?l:e,B=(e,t)=>t===i?!0:t==m?e===void 0:t==l?e!==void 0:e===t,Y=(e,t)=>{if(t??=i,!B(e,t))throw new d(e,t)};exports.a = Tt;
2
+ //# sourceMappingURL=chunk-FZD3RUOT.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkN6MJKM6Yjs = require('../chunk-N6MJKM6Y.js');exports.getEventStoreDBEventStore = _chunkN6MJKM6Yjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkFZD3RUOTjs = require('../chunk-FZD3RUOT.js');exports.getEventStoreDBEventStore = _chunkFZD3RUOTjs.a;
2
2
  //# sourceMappingURL=eventstoreDBEventStore.js.map
@@ -1,2 +1,2 @@
1
- import{a}from"../chunk-HEWBUAGU.mjs";export{a as getEventStoreDBEventStore};
1
+ import{a}from"../chunk-6MEKGDXJ.mjs";export{a as getEventStoreDBEventStore};
2
2
  //# sourceMappingURL=eventstoreDBEventStore.mjs.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-UXBL2ICC.js');var _chunkN6MJKM6Yjs = require('../chunk-N6MJKM6Y.js');exports.getEventStoreDBEventStore = _chunkN6MJKM6Yjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-UXBL2ICC.js');var _chunkFZD3RUOTjs = require('../chunk-FZD3RUOT.js');exports.getEventStoreDBEventStore = _chunkFZD3RUOTjs.a;
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import"../chunk-K54GVY42.mjs";import{a}from"../chunk-HEWBUAGU.mjs";export{a as getEventStoreDBEventStore};
1
+ import"../chunk-K54GVY42.mjs";import{a}from"../chunk-6MEKGDXJ.mjs";export{a as getEventStoreDBEventStore};
2
2
  //# sourceMappingURL=index.mjs.map
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-UXBL2ICC.js');var _chunkN6MJKM6Yjs = require('./chunk-N6MJKM6Y.js');exports.getEventStoreDBEventStore = _chunkN6MJKM6Yjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-UXBL2ICC.js');var _chunkFZD3RUOTjs = require('./chunk-FZD3RUOT.js');exports.getEventStoreDBEventStore = _chunkFZD3RUOTjs.a;
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import"./chunk-K54GVY42.mjs";import{a as o}from"./chunk-HEWBUAGU.mjs";export{o as getEventStoreDBEventStore};
1
+ import"./chunk-K54GVY42.mjs";import{a as o}from"./chunk-6MEKGDXJ.mjs";export{o as getEventStoreDBEventStore};
2
2
  //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@event-driven-io/emmett-esdb",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Emmett - EventStoreDB - Event Sourcing development made simple",
5
5
  "scripts": {
6
6
  "build": "tsup",
@@ -50,7 +50,7 @@
50
50
  "@event-driven-io/emmett-testcontainers": "^0.5.0"
51
51
  },
52
52
  "peerDependencies": {
53
- "@event-driven-io/emmett": "0.10.0",
53
+ "@event-driven-io/emmett": "0.11.0",
54
54
  "@eventstore/db-client": "^6.1.0"
55
55
  }
56
56
  }
@@ -1,2 +0,0 @@
1
- var h=(e=>(e.NOT_A_NONEMPTY_STRING="NOT_A_NONEMPTY_STRING",e.NOT_A_POSITIVE_NUMBER="NOT_A_POSITIVE_NUMBER",e.NOT_AN_UNSIGNED_BIGINT="NOT_AN_UNSIGNED_BIGINT",e))(h||{}),E=e=>typeof e=="number"&&e===e,y=e=>typeof e=="string";var S=class v extends Error{errorCode;constructor(t){let r=t&&typeof t=="object"&&"errorCode"in t?t.errorCode:E(t)?t:500,s=t&&typeof t=="object"&&"message"in t?t.message:y(t)?t:`Error with status code '${r}' ocurred during Emmett processing`;super(s),this.errorCode=r,Object.setPrototypeOf(this,v.prototype)}},u=class O extends S{constructor(t,r,s){super({errorCode:412,message:s??`Expected version ${r.toString()} does not match current ${t?.toString()}`}),this.current=t,this.expected=r,Object.setPrototypeOf(this,O.prototype)}};var l="STREAM_EXISTS",m="STREAM_DOES_NOT_EXIST",i="NO_CONCURRENCY_CHECK";var d=class T extends u{constructor(t,r){super(t?.toString(),r?.toString()),Object.setPrototypeOf(this,T.prototype)}};import{v4 as le}from"uuid";import{ANY as f,STREAM_EXISTS as x,NO_STREAM as A,StreamNotFoundError as N,WrongExpectedVersionError as k,jsonEvent as P}from"@eventstore/db-client";var w=e=>e?{fromRevision:"from"in e?e.from:void 0,maxCount:"maxCount"in e?e.maxCount:"to"in e?e.to:void 0}:void 0,Nt=e=>({async aggregateStream(t,r){try{let{evolve:s,initialState:o,read:a}=r,g=a?.expectedStreamVersion,c=o(),p;for await(let{event:n}of e.readStream(t,w(r.read)))n&&(c=s(c,{type:n.type,data:n.data,metadata:{...n.metadata??{},eventId:n.id,streamName:n.streamId,streamPosition:n.revision,globalPosition:n.position.commit}}),p=n.revision);return Y(p,g),{currentStreamVersion:p??0n,state:c}}catch(s){if(s instanceof N)return null;throw s}},readStream:async(t,r)=>{let s=[],o;try{for await(let{event:a}of e.readStream(t,w(r)))a&&(s.push({type:a.type,data:a.data,metadata:{eventId:a.id,streamName:a.streamId,streamPosition:a.revision,globalPosition:a.position.commit}}),o=a.revision);return o?{currentStreamVersion:o,events:s}:null}catch(a){if(a instanceof N)return null;throw a}},appendToStream:async(t,r,s)=>{try{let o=r.map(P),a=D(s?.expectedStreamVersion);return{nextExpectedStreamVersion:(await e.appendToStream(t,o,{expectedRevision:a})).nextExpectedRevision}}catch(o){throw o instanceof k?new d(o.actualVersion,j(o.expectedVersion)):o}}}),D=e=>e===void 0?f:e===i?f:e==m?A:e==l?x:e,j=e=>e===void 0?i:e===f?i:e==A?m:e==x?l:e,B=(e,t)=>t===i?!0:t==m?e===void 0:t==l?e!==void 0:e===t,Y=(e,t)=>{if(t??=i,!B(e,t))throw new d(e,t)};export{Nt as a};
2
- //# sourceMappingURL=chunk-HEWBUAGU.mjs.map