@event-driven-io/emmett-esdb 0.6.0 → 0.7.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.
@@ -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 _assert = require('assert'); var _assert2 = _interopRequireDefault(_assert);var _crypto = require('crypto');var _test = require('test');var f=class E extends Error{constructor(t){let r=t&&typeof t=="object"&&"errorCode"in t?t.errorCode:I(t)?t:500,a=t&&typeof t=="object"&&"message"in t?t.message:h(t)?t:`Error with status code '${r}' ocurred during Emmett processing`;super(a),this.errorCode=r,Object.setPrototypeOf(this,E.prototype)}},l=class v extends f{constructor(t,r,a){super({errorCode:412,message:_nullishCoalesce(a, () => (`Expected version ${r.toString()} does not match current ${_optionalChain([t, 'optionalAccess', _ => _.toString, 'call', _2 => _2()])}`))}),this.current=t,this.expected=r,Object.setPrototypeOf(this,v.prototype)}};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||{}),I=e=>typeof e=="number"&&e===e,h=e=>typeof e=="string";var d="STREAM_EXISTS",i="STREAM_DOES_NOT_EXIST",o="NO_CONCURRENCY_CHECK";var m=class T extends l{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 _dbclient = require('@eventstore/db-client');var N=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:a,getInitialState:n,read:s}=r,g=_optionalChain([s, 'optionalAccess', _7 => _7.expectedStreamVersion]),u=n(),c;for await(let{event:p}of e.readStream(t,N(r.read)))p&&(u=a(u,{type:p.type,data:p.data}),c=p.revision);return M(c,g),{currentStreamVersion:_nullishCoalesce(c, () => (0n)),state:u}}catch(a){if(a instanceof _dbclient.StreamNotFoundError)return null;throw a}},readStream:async(t,r)=>{let a=[],n;try{for await(let{event:s}of e.readStream(t,N(r)))s&&(a.push({type:s.type,data:s.data}),n=s.revision);return n?{currentStreamVersion:n,events:a}:null}catch(s){if(s instanceof _dbclient.StreamNotFoundError)return null;throw s}},appendToStream:async(t,r,a)=>{try{let n=r.map(_dbclient.jsonEvent),s=P(_optionalChain([a, 'optionalAccess', _8 => _8.expectedStreamVersion]));return{nextExpectedStreamVersion:(await e.appendToStream(t,n,{expectedRevision:s})).nextExpectedRevision}}catch(n){throw n instanceof _dbclient.WrongExpectedVersionError?new m(n.actualVersion,B(n.expectedVersion)):n}}}),P=e=>e===void 0?_dbclient.ANY:e===o?_dbclient.ANY:e==i?_dbclient.NO_STREAM:e==d?_dbclient.STREAM_EXISTS:e,B=e=>e===void 0?o:e===_dbclient.ANY?o:e==_dbclient.NO_STREAM?i:e==_dbclient.STREAM_EXISTS?d:e,D=(e,t)=>t===o?!0:t==i?e===void 0:t==d?e!==void 0:e===t,M=(e,t)=>{if(t??=o,!D(e,t))throw new m(e,t)};exports.a = nt;
2
- //# sourceMappingURL=chunk-TKXVYSGH.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 _assert = require('assert'); var _assert2 = _interopRequireDefault(_assert);var _crypto = require('crypto');var _test = require('test');var f=class E extends Error{constructor(t){let r=t&&typeof t=="object"&&"errorCode"in t?t.errorCode:I(t)?t:500,a=t&&typeof t=="object"&&"message"in t?t.message:h(t)?t:`Error with status code '${r}' ocurred during Emmett processing`;super(a),this.errorCode=r,Object.setPrototypeOf(this,E.prototype)}},l=class v extends f{constructor(t,r,a){super({errorCode:412,message:_nullishCoalesce(a, () => (`Expected version ${r.toString()} does not match current ${_optionalChain([t, 'optionalAccess', _ => _.toString, 'call', _2 => _2()])}`))}),this.current=t,this.expected=r,Object.setPrototypeOf(this,v.prototype)}};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||{}),I=e=>typeof e=="number"&&e===e,h=e=>typeof e=="string";var d="STREAM_EXISTS",i="STREAM_DOES_NOT_EXIST",o="NO_CONCURRENCY_CHECK";var m=class x extends l{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,x.prototype)}};var _dbclient = require('@eventstore/db-client');var N=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,mt= exports.a =e=>({async aggregateStream(t,r){try{let{evolve:a,getInitialState:s,read:n}=r,g=_optionalChain([n, 'optionalAccess', _7 => _7.expectedStreamVersion]),u=s(),c;for await(let{event:p}of e.readStream(t,N(r.read)))p&&(u=a(u,{type:p.type,data:p.data}),c=p.revision);return D(c,g),{currentStreamVersion:_nullishCoalesce(c, () => (0n)),state:u}}catch(a){if(a instanceof _dbclient.StreamNotFoundError)return null;throw a}},readStream:async(t,r)=>{let a=[],s;try{for await(let{event:n}of e.readStream(t,N(r)))n&&(a.push({type:n.type,data:n.data}),s=n.revision);return s?{currentStreamVersion:s,events:a}:null}catch(n){if(n instanceof _dbclient.StreamNotFoundError)return null;throw n}},appendToStream:async(t,r,a)=>{try{let s=r.map(_dbclient.jsonEvent),n=P(_optionalChain([a, 'optionalAccess', _8 => _8.expectedStreamVersion]));return{nextExpectedStreamVersion:(await e.appendToStream(t,s,{expectedRevision:n})).nextExpectedRevision}}catch(s){throw s instanceof _dbclient.WrongExpectedVersionError?new m(s.actualVersion,B(s.expectedVersion)):s}}}),P=e=>e===void 0?_dbclient.ANY:e===o?_dbclient.ANY:e==i?_dbclient.NO_STREAM:e==d?_dbclient.STREAM_EXISTS:e,B=e=>e===void 0?o:e===_dbclient.ANY?o:e==_dbclient.NO_STREAM?i:e==_dbclient.STREAM_EXISTS?d:e,M=(e,t)=>t===o?!0:t==i?e===void 0:t==d?e!==void 0:e===t,D=(e,t)=>{if(t??=o,!M(e,t))throw new m(e,t)};exports.a = mt;
2
+ //# sourceMappingURL=chunk-MDCGSRTI.js.map
@@ -1,2 +1,2 @@
1
- import H from"assert";import F from"node:assert";import{randomUUID as W}from"node:crypto";import{after as Q,before as Z,describe as ee,it as te}from"node:test";var f=class E extends Error{errorCode;constructor(t){let r=t&&typeof t=="object"&&"errorCode"in t?t.errorCode:I(t)?t:500,a=t&&typeof t=="object"&&"message"in t?t.message:h(t)?t:`Error with status code '${r}' ocurred during Emmett processing`;super(a),this.errorCode=r,Object.setPrototypeOf(this,E.prototype)}},l=class v extends f{constructor(t,r,a){super({errorCode:412,message:a??`Expected version ${r.toString()} does not match current ${t?.toString()}`}),this.current=t,this.expected=r,Object.setPrototypeOf(this,v.prototype)}};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||{}),I=e=>typeof e=="number"&&e===e,h=e=>typeof e=="string";var d="STREAM_EXISTS",i="STREAM_DOES_NOT_EXIST",o="NO_CONCURRENCY_CHECK";var m=class T extends l{constructor(t,r){super(t?.toString(),r?.toString()),Object.setPrototypeOf(this,T.prototype)}};import{randomUUID as le}from"crypto";import{ANY as S,STREAM_EXISTS as O,NO_STREAM as A,StreamNotFoundError as x,WrongExpectedVersionError as C,jsonEvent as V}from"@eventstore/db-client";var N=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:a,getInitialState:n,read:s}=r,g=s?.expectedStreamVersion,u=n(),c;for await(let{event:p}of e.readStream(t,N(r.read)))p&&(u=a(u,{type:p.type,data:p.data}),c=p.revision);return M(c,g),{currentStreamVersion:c??0n,state:u}}catch(a){if(a instanceof x)return null;throw a}},readStream:async(t,r)=>{let a=[],n;try{for await(let{event:s}of e.readStream(t,N(r)))s&&(a.push({type:s.type,data:s.data}),n=s.revision);return n?{currentStreamVersion:n,events:a}:null}catch(s){if(s instanceof x)return null;throw s}},appendToStream:async(t,r,a)=>{try{let n=r.map(V),s=P(a?.expectedStreamVersion);return{nextExpectedStreamVersion:(await e.appendToStream(t,n,{expectedRevision:s})).nextExpectedRevision}}catch(n){throw n instanceof C?new m(n.actualVersion,B(n.expectedVersion)):n}}}),P=e=>e===void 0?S:e===o?S:e==i?A:e==d?O:e,B=e=>e===void 0?o:e===S?o:e==A?i:e==O?d:e,D=(e,t)=>t===o?!0:t==i?e===void 0:t==d?e!==void 0:e===t,M=(e,t)=>{if(t??=o,!D(e,t))throw new m(e,t)};export{nt as a};
2
- //# sourceMappingURL=chunk-BLXONOBH.mjs.map
1
+ import H from"assert";import F from"node:assert";import{randomUUID as W}from"node:crypto";import{after as Q,before as Z,describe as ee,it as te}from"node:test";var f=class E extends Error{errorCode;constructor(t){let r=t&&typeof t=="object"&&"errorCode"in t?t.errorCode:I(t)?t:500,a=t&&typeof t=="object"&&"message"in t?t.message:h(t)?t:`Error with status code '${r}' ocurred during Emmett processing`;super(a),this.errorCode=r,Object.setPrototypeOf(this,E.prototype)}},l=class v extends f{constructor(t,r,a){super({errorCode:412,message:a??`Expected version ${r.toString()} does not match current ${t?.toString()}`}),this.current=t,this.expected=r,Object.setPrototypeOf(this,v.prototype)}};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||{}),I=e=>typeof e=="number"&&e===e,h=e=>typeof e=="string";var d="STREAM_EXISTS",i="STREAM_DOES_NOT_EXIST",o="NO_CONCURRENCY_CHECK";var m=class x extends l{constructor(t,r){super(t?.toString(),r?.toString()),Object.setPrototypeOf(this,x.prototype)}};import{randomUUID as ge}from"crypto";import{ANY as S,STREAM_EXISTS as O,NO_STREAM as A,StreamNotFoundError as T,WrongExpectedVersionError as C,jsonEvent as V}from"@eventstore/db-client";var N=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,mt=e=>({async aggregateStream(t,r){try{let{evolve:a,getInitialState:s,read:n}=r,g=n?.expectedStreamVersion,u=s(),c;for await(let{event:p}of e.readStream(t,N(r.read)))p&&(u=a(u,{type:p.type,data:p.data}),c=p.revision);return D(c,g),{currentStreamVersion:c??0n,state:u}}catch(a){if(a instanceof T)return null;throw a}},readStream:async(t,r)=>{let a=[],s;try{for await(let{event:n}of e.readStream(t,N(r)))n&&(a.push({type:n.type,data:n.data}),s=n.revision);return s?{currentStreamVersion:s,events:a}:null}catch(n){if(n instanceof T)return null;throw n}},appendToStream:async(t,r,a)=>{try{let s=r.map(V),n=P(a?.expectedStreamVersion);return{nextExpectedStreamVersion:(await e.appendToStream(t,s,{expectedRevision:n})).nextExpectedRevision}}catch(s){throw s instanceof C?new m(s.actualVersion,B(s.expectedVersion)):s}}}),P=e=>e===void 0?S:e===o?S:e==i?A:e==d?O:e,B=e=>e===void 0?o:e===S?o:e==A?i:e==O?d:e,M=(e,t)=>t===o?!0:t==i?e===void 0:t==d?e!==void 0:e===t,D=(e,t)=>{if(t??=o,!M(e,t))throw new m(e,t)};export{mt as a};
2
+ //# sourceMappingURL=chunk-PF2HTK3Z.mjs.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkTKXVYSGHjs = require('../chunk-TKXVYSGH.js');exports.getEventStoreDBEventStore = _chunkTKXVYSGHjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkMDCGSRTIjs = require('../chunk-MDCGSRTI.js');exports.getEventStoreDBEventStore = _chunkMDCGSRTIjs.a;
2
2
  //# sourceMappingURL=eventstoreDBEventStore.js.map
@@ -1,2 +1,2 @@
1
- import{a}from"../chunk-BLXONOBH.mjs";export{a as getEventStoreDBEventStore};
1
+ import{a}from"../chunk-PF2HTK3Z.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 _chunkTKXVYSGHjs = require('../chunk-TKXVYSGH.js');exports.getEventStoreDBEventStore = _chunkTKXVYSGHjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-UXBL2ICC.js');var _chunkMDCGSRTIjs = require('../chunk-MDCGSRTI.js');exports.getEventStoreDBEventStore = _chunkMDCGSRTIjs.a;
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import"../chunk-K54GVY42.mjs";import{a}from"../chunk-BLXONOBH.mjs";export{a as getEventStoreDBEventStore};
1
+ import"../chunk-K54GVY42.mjs";import{a}from"../chunk-PF2HTK3Z.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 _chunkTKXVYSGHjs = require('./chunk-TKXVYSGH.js');exports.getEventStoreDBEventStore = _chunkTKXVYSGHjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('./chunk-UXBL2ICC.js');var _chunkMDCGSRTIjs = require('./chunk-MDCGSRTI.js');exports.getEventStoreDBEventStore = _chunkMDCGSRTIjs.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-BLXONOBH.mjs";export{o as getEventStoreDBEventStore};
1
+ import"./chunk-K54GVY42.mjs";import{a as o}from"./chunk-PF2HTK3Z.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.6.0",
3
+ "version": "0.7.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.6.0",
53
+ "@event-driven-io/emmett": "0.7.0",
54
54
  "@eventstore/db-client": "^6.1.0"
55
55
  }
56
56
  }