@event-driven-io/emmett-esdb 0.11.2 → 0.12.1

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.
@@ -1,2 +1,2 @@
1
- import oe from"async-retry";import{TransformStream as ie}from"web-streams-polyfill";var y=(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))(y||{}),S=e=>typeof e=="number"&&e===e,E=e=>typeof e=="string";var u=class v extends Error{errorCode;constructor(t){let a=t&&typeof t=="object"&&"errorCode"in t?t.errorCode:S(t)?t:500,s=t&&typeof t=="object"&&"message"in t?t.message:E(t)?t:`Error with status code '${a}' ocurred during Emmett processing`;super(s),this.errorCode=a,Object.setPrototypeOf(this,v.prototype)}},f=class w extends u{constructor(t,a,s){super({errorCode:412,message:s??`Expected version ${a.toString()} does not match current ${t?.toString()}`}),this.current=t,this.expected=a,Object.setPrototypeOf(this,w.prototype)}};var m="STREAM_EXISTS",l="STREAM_DOES_NOT_EXIST",i="NO_CONCURRENCY_CHECK";var d=class b extends f{constructor(t,a){super(t?.toString(),a?.toString()),Object.setPrototypeOf(this,b.prototype)}};import{v4 as De}from"uuid";import{ANY as h,STREAM_EXISTS as x,NO_STREAM as N,StreamNotFoundError as T,WrongExpectedVersionError as Y,jsonEvent as U}from"@eventstore/db-client";var O=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,nr=e=>({async aggregateStream(t,a){try{let{evolve:s,initialState:o,read:r}=a,g=r?.expectedStreamVersion,c=o(),p;for await(let{event:n}of e.readStream(t,O(a.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 W(p,g),{currentStreamVersion:p??0n,state:c}}catch(s){if(s instanceof T)return null;throw s}},readStream:async(t,a)=>{let s=[],o;try{for await(let{event:r}of e.readStream(t,O(a)))r&&(s.push({type:r.type,data:r.data,metadata:{eventId:r.id,streamName:r.streamId,streamPosition:r.revision,globalPosition:r.position.commit}}),o=r.revision);return o?{currentStreamVersion:o,events:s}:null}catch(r){if(r instanceof T)return null;throw r}},appendToStream:async(t,a,s)=>{try{let o=a.map(U),r=q(s?.expectedStreamVersion);return{nextExpectedStreamVersion:(await e.appendToStream(t,o,{expectedRevision:r})).nextExpectedRevision}}catch(o){throw o instanceof Y?new d(o.actualVersion,G(o.expectedVersion)):o}}}),q=e=>e===void 0?h:e===i?h:e==l?N:e==m?x:e,G=e=>e===void 0?i:e===h?i:e==N?l:e==x?m:e,J=(e,t)=>t===i?!0:t==l?e===void 0:t==m?e!==void 0:e===t,W=(e,t)=>{if(t??=i,!J(e,t))throw new d(e,t)};export{nr as a};
2
- //# sourceMappingURL=chunk-YLMVDFJ6.mjs.map
1
+ import ne from"async-retry";import{TransformStream as le}from"web-streams-polyfill";var y=(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))(y||{}),E=e=>typeof e=="number"&&e===e,S=e=>typeof e=="string";var u=class v extends Error{errorCode;constructor(t){let a=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 '${a}' ocurred during Emmett processing`;super(s),this.errorCode=a,Object.setPrototypeOf(this,v.prototype)}},f=class w extends u{constructor(t,a,s){super({errorCode:412,message:s??`Expected version ${a.toString()} does not match current ${t?.toString()}`}),this.current=t,this.expected=a,Object.setPrototypeOf(this,w.prototype)}};var m="STREAM_EXISTS",l="STREAM_DOES_NOT_EXIST",i="NO_CONCURRENCY_CHECK";var d=class b extends f{constructor(t,a){super(t?.toString(),a?.toString()),Object.setPrototypeOf(this,b.prototype)}};import{v4 as Pe}from"uuid";import{ANY as h,STREAM_EXISTS as O,NO_STREAM as N,StreamNotFoundError as T,WrongExpectedVersionError as U,jsonEvent as q}from"@eventstore/db-client";var x=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,lr=e=>({async aggregateStream(t,a){try{let{evolve:s,initialState:o,read:r}=a,g=r?.expectedStreamVersion,c=o(),p;for await(let{event:n}of e.readStream(t,x(a.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 J(p,g),{currentStreamVersion:p??0n,state:c}}catch(s){if(s instanceof T)return null;throw s}},readStream:async(t,a)=>{let s=[],o;try{for await(let{event:r}of e.readStream(t,x(a)))r&&(s.push({type:r.type,data:r.data,metadata:{eventId:r.id,streamName:r.streamId,streamPosition:r.revision,globalPosition:r.position.commit}}),o=r.revision);return o?{currentStreamVersion:o,events:s}:null}catch(r){if(r instanceof T)return null;throw r}},appendToStream:async(t,a,s)=>{try{let o=a.map(q),r=G(s?.expectedStreamVersion);return{nextExpectedStreamVersion:(await e.appendToStream(t,o,{expectedRevision:r})).nextExpectedRevision}}catch(o){throw o instanceof U?new d(o.actualVersion,F(o.expectedVersion)):o}}}),G=e=>e===void 0?h:e===i?h:e==l?N:e==m?O:e,F=e=>e===void 0?i:e===h?i:e==N?l:e==O?m:e,W=(e,t)=>t===i?!0:t==l?e===void 0:t==m?e!==void 0:e===t,J=(e,t)=>{if(t??=i,!W(e,t))throw new d(e,t)};export{lr as a};
2
+ //# sourceMappingURL=chunk-72SDUL5D.mjs.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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 _asyncretry = require('async-retry'); var _asyncretry2 = _interopRequireDefault(_asyncretry);var _webstreamspolyfill = require('web-streams-polyfill');var y=(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))(y||{}),S=e=>typeof e=="number"&&e===e,E=e=>typeof e=="string";var u=class v extends Error{constructor(t){let a=t&&typeof t=="object"&&"errorCode"in t?t.errorCode:S(t)?t:500,s=t&&typeof t=="object"&&"message"in t?t.message:E(t)?t:`Error with status code '${a}' ocurred during Emmett processing`;super(s),this.errorCode=a,Object.setPrototypeOf(this,v.prototype)}},f=class w extends u{constructor(t,a,s){super({errorCode:412,message:_nullishCoalesce(s, () => (`Expected version ${a.toString()} does not match current ${_optionalChain([t, 'optionalAccess', _ => _.toString, 'call', _2 => _2()])}`))}),this.current=t,this.expected=a,Object.setPrototypeOf(this,w.prototype)}};var m="STREAM_EXISTS",l="STREAM_DOES_NOT_EXIST",i="NO_CONCURRENCY_CHECK";var d=class b extends f{constructor(t,a){super(_optionalChain([t, 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]),_optionalChain([a, 'optionalAccess', _5 => _5.toString, 'call', _6 => _6()])),Object.setPrototypeOf(this,b.prototype)}};var _uuid = require('uuid');var _dbclient = require('@eventstore/db-client');var O=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,nr= exports.a =e=>({async aggregateStream(t,a){try{let{evolve:s,initialState:o,read:r}=a,g=_optionalChain([r, 'optionalAccess', _7 => _7.expectedStreamVersion]),c=o(),p;for await(let{event:n}of e.readStream(t,O(a.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 W(p,g),{currentStreamVersion:_nullishCoalesce(p, () => (0n)),state:c}}catch(s){if(s instanceof _dbclient.StreamNotFoundError)return null;throw s}},readStream:async(t,a)=>{let s=[],o;try{for await(let{event:r}of e.readStream(t,O(a)))r&&(s.push({type:r.type,data:r.data,metadata:{eventId:r.id,streamName:r.streamId,streamPosition:r.revision,globalPosition:r.position.commit}}),o=r.revision);return o?{currentStreamVersion:o,events:s}:null}catch(r){if(r instanceof _dbclient.StreamNotFoundError)return null;throw r}},appendToStream:async(t,a,s)=>{try{let o=a.map(_dbclient.jsonEvent),r=q(_optionalChain([s, 'optionalAccess', _8 => _8.expectedStreamVersion]));return{nextExpectedStreamVersion:(await e.appendToStream(t,o,{expectedRevision:r})).nextExpectedRevision}}catch(o){throw o instanceof _dbclient.WrongExpectedVersionError?new d(o.actualVersion,G(o.expectedVersion)):o}}}),q=e=>e===void 0?_dbclient.ANY:e===i?_dbclient.ANY:e==l?_dbclient.NO_STREAM:e==m?_dbclient.STREAM_EXISTS:e,G=e=>e===void 0?i:e===_dbclient.ANY?i:e==_dbclient.NO_STREAM?l:e==_dbclient.STREAM_EXISTS?m:e,J=(e,t)=>t===i?!0:t==l?e===void 0:t==m?e!==void 0:e===t,W=(e,t)=>{if(t??=i,!J(e,t))throw new d(e,t)};exports.a = nr;
2
- //# sourceMappingURL=chunk-BJH3O7AC.js.map
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 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 _asyncretry = require('async-retry'); var _asyncretry2 = _interopRequireDefault(_asyncretry);var _webstreamspolyfill = require('web-streams-polyfill');var y=(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))(y||{}),E=e=>typeof e=="number"&&e===e,S=e=>typeof e=="string";var u=class v extends Error{constructor(t){let a=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 '${a}' ocurred during Emmett processing`;super(s),this.errorCode=a,Object.setPrototypeOf(this,v.prototype)}},f=class w extends u{constructor(t,a,s){super({errorCode:412,message:_nullishCoalesce(s, () => (`Expected version ${a.toString()} does not match current ${_optionalChain([t, 'optionalAccess', _ => _.toString, 'call', _2 => _2()])}`))}),this.current=t,this.expected=a,Object.setPrototypeOf(this,w.prototype)}};var m="STREAM_EXISTS",l="STREAM_DOES_NOT_EXIST",i="NO_CONCURRENCY_CHECK";var d=class b extends f{constructor(t,a){super(_optionalChain([t, 'optionalAccess', _3 => _3.toString, 'call', _4 => _4()]),_optionalChain([a, 'optionalAccess', _5 => _5.toString, 'call', _6 => _6()])),Object.setPrototypeOf(this,b.prototype)}};var _uuid = require('uuid');var _dbclient = require('@eventstore/db-client');var x=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,lr= exports.a =e=>({async aggregateStream(t,a){try{let{evolve:s,initialState:o,read:r}=a,g=_optionalChain([r, 'optionalAccess', _7 => _7.expectedStreamVersion]),c=o(),p;for await(let{event:n}of e.readStream(t,x(a.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 J(p,g),{currentStreamVersion:_nullishCoalesce(p, () => (0n)),state:c}}catch(s){if(s instanceof _dbclient.StreamNotFoundError)return null;throw s}},readStream:async(t,a)=>{let s=[],o;try{for await(let{event:r}of e.readStream(t,x(a)))r&&(s.push({type:r.type,data:r.data,metadata:{eventId:r.id,streamName:r.streamId,streamPosition:r.revision,globalPosition:r.position.commit}}),o=r.revision);return o?{currentStreamVersion:o,events:s}:null}catch(r){if(r instanceof _dbclient.StreamNotFoundError)return null;throw r}},appendToStream:async(t,a,s)=>{try{let o=a.map(_dbclient.jsonEvent),r=G(_optionalChain([s, 'optionalAccess', _8 => _8.expectedStreamVersion]));return{nextExpectedStreamVersion:(await e.appendToStream(t,o,{expectedRevision:r})).nextExpectedRevision}}catch(o){throw o instanceof _dbclient.WrongExpectedVersionError?new d(o.actualVersion,F(o.expectedVersion)):o}}}),G=e=>e===void 0?_dbclient.ANY:e===i?_dbclient.ANY:e==l?_dbclient.NO_STREAM:e==m?_dbclient.STREAM_EXISTS:e,F=e=>e===void 0?i:e===_dbclient.ANY?i:e==_dbclient.NO_STREAM?l:e==_dbclient.STREAM_EXISTS?m:e,W=(e,t)=>t===i?!0:t==l?e===void 0:t==m?e!==void 0:e===t,J=(e,t)=>{if(t??=i,!W(e,t))throw new d(e,t)};exports.a = lr;
2
+ //# sourceMappingURL=chunk-LRXBTOUN.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkBJH3O7ACjs = require('../chunk-BJH3O7AC.js');exports.getEventStoreDBEventStore = _chunkBJH3O7ACjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkLRXBTOUNjs = require('../chunk-LRXBTOUN.js');exports.getEventStoreDBEventStore = _chunkLRXBTOUNjs.a;
2
2
  //# sourceMappingURL=eventstoreDBEventStore.js.map
@@ -1,2 +1,2 @@
1
- import{a}from"../chunk-YLMVDFJ6.mjs";export{a as getEventStoreDBEventStore};
1
+ import{a}from"../chunk-72SDUL5D.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 _chunkBJH3O7ACjs = require('../chunk-BJH3O7AC.js');exports.getEventStoreDBEventStore = _chunkBJH3O7ACjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-UXBL2ICC.js');var _chunkLRXBTOUNjs = require('../chunk-LRXBTOUN.js');exports.getEventStoreDBEventStore = _chunkLRXBTOUNjs.a;
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import"../chunk-K54GVY42.mjs";import{a}from"../chunk-YLMVDFJ6.mjs";export{a as getEventStoreDBEventStore};
1
+ import"../chunk-K54GVY42.mjs";import{a}from"../chunk-72SDUL5D.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 _chunkBJH3O7ACjs = require('./chunk-BJH3O7AC.js');exports.getEventStoreDBEventStore = _chunkBJH3O7ACjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-UXBL2ICC.js');var _chunkLRXBTOUNjs = require('./chunk-LRXBTOUN.js');exports.getEventStoreDBEventStore = _chunkLRXBTOUNjs.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-YLMVDFJ6.mjs";export{o as getEventStoreDBEventStore};
1
+ import"./chunk-K54GVY42.mjs";import{a as o}from"./chunk-72SDUL5D.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.11.2",
3
+ "version": "0.12.1",
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.11.2",
53
+ "@event-driven-io/emmett": "0.12.1",
54
54
  "@eventstore/db-client": "^6.1.0"
55
55
  }
56
56
  }