@event-driven-io/emmett 0.20.1-alpha.1 → 0.20.1-alpha.2
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.
- package/dist/index.cjs +12 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +12 -12
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { C as ConcurrencyError, E as ErrorConstructor } from './index-D9zse73H.cjs';
|
|
2
2
|
export { f as EmmettCliPlugin, d as EmmettCliPluginRegistration, j as EmmettError, g as EmmettPlugin, b as EmmettPluginConfig, e as EmmettPluginRegistration, c as EmmettPluginType, a as EmmettPluginsConfig, I as IllegalStateError, N as NotFoundError, V as ValidationError, h as isErrorConstructor, i as isPluginConfig } from './index-D9zse73H.cjs';
|
|
3
3
|
import retry from 'async-retry';
|
|
4
|
-
import streams, { ReadableStream } from '@event-driven-io/emmett-shims';
|
|
5
4
|
import * as web_streams_polyfill from 'web-streams-polyfill';
|
|
5
|
+
import { TransformStream, ReadableStream } from 'web-streams-polyfill';
|
|
6
6
|
import 'commander';
|
|
7
7
|
|
|
8
8
|
type Primitive = undefined | null | boolean | string | number | bigint | symbol | Function;
|
|
@@ -213,7 +213,7 @@ declare const InMemoryEventStoreDefaultStreamVersion = 0n;
|
|
|
213
213
|
declare const getInMemoryEventStore: () => EventStore<DefaultStreamVersionType, ReadEventMetadataWithGlobalPosition>;
|
|
214
214
|
|
|
215
215
|
declare const streamTrackingGlobalPosition: (currentEvents: ReadEvent<Event, ReadEventMetadataWithGlobalPosition>[]) => CaughtUpTransformStream;
|
|
216
|
-
declare class CaughtUpTransformStream extends
|
|
216
|
+
declare class CaughtUpTransformStream extends TransformStream<ReadEvent<Event, ReadEventMetadataWithGlobalPosition>, ReadEvent<Event, ReadEventMetadataWithGlobalPosition> | GlobalSubscriptionEvent> {
|
|
217
217
|
private _currentPosition;
|
|
218
218
|
private _logPosition;
|
|
219
219
|
constructor(events: ReadEvent<Event, ReadEventMetadataWithGlobalPosition>[]);
|
|
@@ -411,7 +411,7 @@ declare const streamGenerators: {
|
|
|
411
411
|
|
|
412
412
|
declare const restream: <Source = unknown, Transformed = Source, StreamType = Source>(createSourceStream: () => ReadableStream<StreamType>, transform?: (input: Source) => Transformed, retryOptions?: AsyncRetryOptions, decoder?: Decoder<StreamType, Source>) => ReadableStream<Transformed>;
|
|
413
413
|
|
|
414
|
-
declare class NotifyAboutNoActiveReadersStream<Item> extends
|
|
414
|
+
declare class NotifyAboutNoActiveReadersStream<Item> extends TransformStream<Item, Item> {
|
|
415
415
|
private onNoActiveReaderCallback;
|
|
416
416
|
private checkInterval;
|
|
417
417
|
readonly streamId: string;
|
|
@@ -426,19 +426,19 @@ declare class NotifyAboutNoActiveReadersStream<Item> extends streams.TransformSt
|
|
|
426
426
|
private checkNoActiveReader;
|
|
427
427
|
}
|
|
428
428
|
|
|
429
|
-
declare class ReduceTransformStream<I, O> extends
|
|
429
|
+
declare class ReduceTransformStream<I, O> extends TransformStream<I, O> {
|
|
430
430
|
private accumulator;
|
|
431
431
|
private reducer;
|
|
432
432
|
constructor(reducer: (accumulator: O, chunk: I) => O, initialValue: O);
|
|
433
433
|
}
|
|
434
434
|
|
|
435
|
-
declare class SkipTransformStream<T> extends
|
|
435
|
+
declare class SkipTransformStream<T> extends TransformStream<T, T> {
|
|
436
436
|
private count;
|
|
437
437
|
private skip;
|
|
438
438
|
constructor(skip: number);
|
|
439
439
|
}
|
|
440
440
|
|
|
441
|
-
declare class TakeTransformStream<T> extends
|
|
441
|
+
declare class TakeTransformStream<T> extends TransformStream<T, T> {
|
|
442
442
|
private count;
|
|
443
443
|
private limit;
|
|
444
444
|
constructor(limit: number);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { C as ConcurrencyError, E as ErrorConstructor } from './index-D9zse73H.js';
|
|
2
2
|
export { f as EmmettCliPlugin, d as EmmettCliPluginRegistration, j as EmmettError, g as EmmettPlugin, b as EmmettPluginConfig, e as EmmettPluginRegistration, c as EmmettPluginType, a as EmmettPluginsConfig, I as IllegalStateError, N as NotFoundError, V as ValidationError, h as isErrorConstructor, i as isPluginConfig } from './index-D9zse73H.js';
|
|
3
3
|
import retry from 'async-retry';
|
|
4
|
-
import streams, { ReadableStream } from '@event-driven-io/emmett-shims';
|
|
5
4
|
import * as web_streams_polyfill from 'web-streams-polyfill';
|
|
5
|
+
import { TransformStream, ReadableStream } from 'web-streams-polyfill';
|
|
6
6
|
import 'commander';
|
|
7
7
|
|
|
8
8
|
type Primitive = undefined | null | boolean | string | number | bigint | symbol | Function;
|
|
@@ -213,7 +213,7 @@ declare const InMemoryEventStoreDefaultStreamVersion = 0n;
|
|
|
213
213
|
declare const getInMemoryEventStore: () => EventStore<DefaultStreamVersionType, ReadEventMetadataWithGlobalPosition>;
|
|
214
214
|
|
|
215
215
|
declare const streamTrackingGlobalPosition: (currentEvents: ReadEvent<Event, ReadEventMetadataWithGlobalPosition>[]) => CaughtUpTransformStream;
|
|
216
|
-
declare class CaughtUpTransformStream extends
|
|
216
|
+
declare class CaughtUpTransformStream extends TransformStream<ReadEvent<Event, ReadEventMetadataWithGlobalPosition>, ReadEvent<Event, ReadEventMetadataWithGlobalPosition> | GlobalSubscriptionEvent> {
|
|
217
217
|
private _currentPosition;
|
|
218
218
|
private _logPosition;
|
|
219
219
|
constructor(events: ReadEvent<Event, ReadEventMetadataWithGlobalPosition>[]);
|
|
@@ -411,7 +411,7 @@ declare const streamGenerators: {
|
|
|
411
411
|
|
|
412
412
|
declare const restream: <Source = unknown, Transformed = Source, StreamType = Source>(createSourceStream: () => ReadableStream<StreamType>, transform?: (input: Source) => Transformed, retryOptions?: AsyncRetryOptions, decoder?: Decoder<StreamType, Source>) => ReadableStream<Transformed>;
|
|
413
413
|
|
|
414
|
-
declare class NotifyAboutNoActiveReadersStream<Item> extends
|
|
414
|
+
declare class NotifyAboutNoActiveReadersStream<Item> extends TransformStream<Item, Item> {
|
|
415
415
|
private onNoActiveReaderCallback;
|
|
416
416
|
private checkInterval;
|
|
417
417
|
readonly streamId: string;
|
|
@@ -426,19 +426,19 @@ declare class NotifyAboutNoActiveReadersStream<Item> extends streams.TransformSt
|
|
|
426
426
|
private checkNoActiveReader;
|
|
427
427
|
}
|
|
428
428
|
|
|
429
|
-
declare class ReduceTransformStream<I, O> extends
|
|
429
|
+
declare class ReduceTransformStream<I, O> extends TransformStream<I, O> {
|
|
430
430
|
private accumulator;
|
|
431
431
|
private reducer;
|
|
432
432
|
constructor(reducer: (accumulator: O, chunk: I) => O, initialValue: O);
|
|
433
433
|
}
|
|
434
434
|
|
|
435
|
-
declare class SkipTransformStream<T> extends
|
|
435
|
+
declare class SkipTransformStream<T> extends TransformStream<T, T> {
|
|
436
436
|
private count;
|
|
437
437
|
private skip;
|
|
438
438
|
constructor(skip: number);
|
|
439
439
|
}
|
|
440
440
|
|
|
441
|
-
declare class TakeTransformStream<T> extends
|
|
441
|
+
declare class TakeTransformStream<T> extends TransformStream<T, T> {
|
|
442
442
|
private count;
|
|
443
443
|
private limit;
|
|
444
444
|
constructor(limit: number);
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import{a as
|
|
2
|
-
`)}decode(){if(!this.hasCompleteMessage())return null;let e=
|
|
3
|
-
`);if(n===-1)return null;let o=r.slice(0,n),a=new Uint8Array(e.buffer,n+1);return this.buffer=a.byteLength>0?[a]:[],JSON.parse(o)}};var
|
|
1
|
+
import{a as Ye,b as ze,c as Qe,d as Ze,e as et,f as tt,g as rt,h as nt,i as ot,j as $,k as I,l as J,m as at,n as st,o as it,p as mt}from"./chunk-6TXKRKDJ.js";var K=t=>"withSession"in t,X=t=>({withSession:e=>e({eventStore:t,close:()=>Promise.resolve()})});var pt=(t,e,r)=>({type:t,data:e,metadata:r});var L=(t,e,r)=>({type:t,data:e,metadata:r});var ut=t=>({kind:"Reply",message:t}),ft=t=>({kind:"Send",message:t}),yt=t=>({kind:"Publish",message:t}),vt=(t,e)=>({kind:"Schedule",message:t,when:e}),Et=()=>({kind:"Complete"}),St=t=>({kind:"Ignore",reason:t}),Tt=t=>({kind:"Error",reason:t}),xt=()=>({kind:"Accept"});var H="__emt:GlobalStreamCaughtUp",Y=t=>t.type===H,Mt=t=>e=>e.type===H&&e.metadata?.globalPosition>=t,j=t=>L(H,t,{globalPosition:t.globalPosition}),Vt=t=>Y(t),Pt=t=>!Y(t);var xe="STREAM_EXISTS",F="STREAM_DOES_NOT_EXIST",D="NO_CONCURRENCY_CHECK",ge=(t,e,r)=>e===D?!0:e==F?t===r:e==xe?t!==r:t===e,N=(t,e,r)=>{if(e??=D,!ge(t,e,r))throw new b(t,e)},b=class t extends J{constructor(e,r){super(e?.toString(),r?.toString()),Object.setPrototypeOf(this,t.prototype)}},z=t=>t instanceof b;import{v4 as De}from"uuid";import{TransformStream as he}from"web-streams-polyfill";var Q=t=>new _(t),_=class extends he{_currentPosition;_logPosition;constructor(e){super({start:r=>{let n=0n;for(let o of e)r.enqueue(o),n=o.metadata.globalPosition;r.enqueue(j({globalPosition:n}))},transform:(r,n)=>{this._currentPosition=r.metadata.globalPosition,n.enqueue(r),!(this._currentPosition<this._logPosition)&&n.enqueue(j({globalPosition:this._currentPosition}))}}),this._currentPosition=this._logPosition=e.length>0?e[e.length-1].metadata.globalPosition:0n}set logPosition(e){this._logPosition=e}};import{v4 as be}from"uuid";import{v4 as Ce}from"uuid";import{TransformStream as Re}from"web-streams-polyfill";var O=(t,e={})=>new S(t,e),S=class extends Re{constructor(r,n={}){super({cancel:o=>{console.log("Stream was canceled. Reason:",o),this.stopChecking()}});this.onNoActiveReaderCallback=r;this.streamId=n?.streamId??Ce(),this.onNoActiveReaderCallback=r,this.startChecking(n?.intervalCheckInMs??20)}checkInterval=null;streamId;_isStopped=!1;get hasActiveSubscribers(){return!this._isStopped}startChecking(r){this.checkInterval=setInterval(()=>{this.checkNoActiveReader()},r)}stopChecking(){this.checkInterval&&(clearInterval(this.checkInterval),this.checkInterval=null,this._isStopped=!0,this.onNoActiveReaderCallback(this))}checkNoActiveReader(){!this.readable.locked&&!this._isStopped&&this.stopChecking()}};var Z=async(t,e)=>{if(t.writable.locked)return!1;let r=t.writable.getWriter();if(await r.ready,!t.readable.locked)return!1;try{for(let n of e)await r.write(n)}catch(n){console.log(n)}finally{await r.close()}return!0};var ee=()=>{let t=[],e=new Map;return{notify:async r=>{if(r.length!==0){t.push(...r);for(let n of e.values())n.logPosition=r[r.length-1].metadata.globalPosition,await Z(n,r)}},stream:()=>{let r=be(),n=Q(t);return e.set(r,n),n.readable.pipeThrough(O(o=>{e.has(o.streamId)&&e.delete(o.streamId)},{streamId:r}))}}};var T=0n,ir=()=>{let t=new Map,e=ee(),r=()=>Array.from(t.values()).map(n=>n.length).reduce((n,o)=>n+o,0);return{async aggregateStream(n,o){let{evolve:a,initialState:i,read:m}=o,l=await this.readStream(n,m),y=l?.events??[];return{currentStreamVersion:BigInt(y.length),state:y.reduce(a,i()),streamExists:l.streamExists}},readStream:(n,o)=>{let a=t.get(n),i=a?BigInt(a.length):T;N(i,o?.expectedStreamVersion,T);let m=Number(o&&"from"in o?o.from:0),l=Number(o&&"to"in o?o.to:o&&"maxCount"in o&&o.maxCount?o.from+o.maxCount:a?.length??1),y=a!==void 0&&a.length>0?a.map(f=>f).slice(m,l):[],E={currentStreamVersion:i,events:y,streamExists:a!==void 0&&a.length>0};return Promise.resolve(E)},appendToStream:async(n,o,a)=>{let i=t.get(n)??[],m=i.length>0?BigInt(i.length):T;N(m,a?.expectedStreamVersion,T);let l=o.map((f,v)=>({...f,metadata:{...f.metadata??{},streamName:n,eventId:De(),streamPosition:BigInt(i.length+v+1),globalPosition:BigInt(r()+v+1)}})),y=BigInt(l.slice(-1)[0].metadata.streamPosition);return t.set(n,[...i,...l]),await e.notify(l),{nextExpectedStreamVersion:y,createdNewStream:m===T}}}};var d=(t,e)=>{if(Oe(t))return t.equals(e);if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((o,a)=>d(o,e[a]));if(typeof t!="object"||typeof e!="object"||t===null||e===null)return t===e;if(Array.isArray(e))return!1;let r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length||!r.every(o=>n.includes(o)))return!1;for(let o in t){if(t[o]instanceof Function&&e[o]instanceof Function)continue;if(!d(t[o],e[o]))return!1}return!0},Oe=t=>t&&typeof t=="object"&&"equals"in t&&typeof t.equals=="function";var vr=t=>{let e,r,n=0;do({value:e,done:r}=t.next()),n+=e||0;while(!r);return n};var Sr=(t,e,r,n,o=()=>{})=>{let a=!1,i=t.map(m=>r(m)?(a=!0,n(m)):m).filter(m=>m!==void 0).map(m=>{if(!m)throw Error("That should not happen");return m});return!a&&o()!==void 0?[...t,e]:i};import we from"async-retry";var te={retries:0},w=async(t,e)=>e===void 0||e.retries===0?t():we(async r=>{try{return await t()}catch(n){throw e?.shouldRetryError&&!e.shouldRetryError(n)&&r(n),n}},e??{retries:0});var re={retries:3,minTimeout:100,factor:1.5,shouldRetryError:z},Me=t=>t===void 0?te:"onVersionConflict"in t?typeof t.onVersionConflict=="boolean"?re:typeof t.onVersionConflict=="number"?{...re,retries:t.onVersionConflict}:t.onVersionConflict:t,ne=t=>async(e,r,n,o)=>w(async()=>await Ve(e,async({eventStore:i})=>{let{evolve:m,initialState:l}=t,E=(t.mapToStreamId??(Te=>Te))(r),f=await i.aggregateStream(E,{evolve:m,initialState:l,read:{expectedStreamVersion:o?.expectedStreamVersion??D}}),v=f.state,B=f.currentStreamVersion,A=await n(v),R=Array.isArray(A)?A:[A];if(R.length===0)return{newEvents:[],newState:v,nextExpectedStreamVersion:B,createdNewStream:!1};let Se=o?.expectedStreamVersion??(f.streamExists?B:F);return{...await i.appendToStream(E,R,{...o,expectedStreamVersion:Se}),newEvents:R,newState:R.reduce(m,v)}}),Me(o&&"retry"in o?o.retry:t.retry)),Ve=(t,e)=>(K(t)?t:X(t)).withSession(e);var Pr=t=>async(e,r,n,o)=>{let{decide:a,...i}=t;return ne(i)(e,r,m=>a(n,m),o)};var Nr=()=>{let t=new Map,e=[];return{send:async r=>{let n=t.get(r.type);if(n===void 0||n.length===0)throw new I(`No handler registered for command ${r.type}!`);let o=n[0];await o(r)},publish:async r=>{let n=t.get(r.type)??[];for(let o of n)await o(r)},schedule:(r,n)=>{e=[...e,{message:r,options:n}]},handle:(r,...n)=>{let o=[...t.keys()].filter(a=>n.includes(a));if(o.length>0)throw new I(`Cannot register handler for commands ${o.join(", ")} as they're already registered!`);for(let a of n)t.set(a,[r])},subscribe(r,...n){for(let o of n)t.has(o)||t.set(o,[]),t.set(o,[...t.get(o)??[],r])},dequeue:()=>{let r=e;return e=[],r}}};var Wr=t=>t,Pe=t=>t.map(e=>({type:"inline",projection:e})),ke=t=>t.map(e=>({type:"async",projection:e})),Gr={inline:Pe,async:ke};var W=class extends Error{constructor(e){super(`Cannot parse! ${e}`)}},c={stringify:(t,e)=>JSON.stringify(e?.map?e.map(t):t,(r,n)=>typeof n=="bigint"?n.toString():n),parse:(t,e)=>{let r=JSON.parse(t,e?.reviver);if(e?.typeCheck&&!e?.typeCheck(r))throw new W(t);return e?.map?e.map(r):r}};var G=t=>{let e=t.reduce((o,a)=>o+a.length,0),r=new Uint8Array(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return r};var Lr=async t=>{let e=[];for await(let r of t)e.push(r);return e};var M=class{buffer=[];addToBuffer(e){this.buffer.push(e)}clearBuffer(){this.buffer=[]}hasCompleteMessage(){let e=G(this.buffer);return new TextDecoder().decode(e).includes(`
|
|
2
|
+
`)}decode(){if(!this.hasCompleteMessage())return null;let e=G(this.buffer),r=new TextDecoder().decode(e),n=r.indexOf(`
|
|
3
|
+
`);if(n===-1)return null;let o=r.slice(0,n),a=new Uint8Array(e.buffer,n+1);return this.buffer=a.byteLength>0?[a]:[],JSON.parse(o)}};var V=class{constructor(e){this.transform=e;this.transform=e}buffer=[];addToBuffer(e){this.buffer.push(e)}clearBuffer(){this.buffer=[]}hasCompleteMessage(){return this.buffer.some(e=>e.includes(`
|
|
4
4
|
`))}decode(){let e=this.buffer.join("");if(!this.hasCompleteMessage()){if(e.trim().length>0)throw new Error("Unterminated string in JSON at position");return null}let r=e.indexOf(`
|
|
5
|
-
`),n=e.slice(0,r).trim();return this.buffer=[e.slice(r+1)],this.transform(n)}};var
|
|
6
|
-
${
|
|
5
|
+
`),n=e.slice(0,r).trim();return this.buffer=[e.slice(r+1)],this.transform(n)}};var P=class extends V{constructor(){super(e=>JSON.parse(e))}};var k=class{buffer=null;addToBuffer(e){this.buffer=e}clearBuffer(){this.buffer=null}hasCompleteMessage(){return this.buffer!==null}decode(){if(!this.hasCompleteMessage()||!this.buffer)return null;let e=this.buffer;return this.clearBuffer(),e}};var q=class{constructor(e){this.decoders=e}decoderFor(e){let r=this.decoders.find(n=>n[0](e));return r?r[1]:null}addToBuffer(e){this.decoderFor(e)?.addToBuffer(e)}clearBuffer(){for(let e of this.decoders.map(r=>r[1]))e.clearBuffer()}hasCompleteMessage(){return this.decoders.some(e=>e[1].hasCompleteMessage())}decode(){return this.decoders.map(r=>r[1]).find(r=>r.hasCompleteMessage())?.decode()??null}},x=class extends q{constructor(){super([[e=>typeof e=="string",new P],[e=>e instanceof Uint8Array,new M],[e=>typeof e=="object",new k]])}};import{ReadableStream as Ae}from"web-streams-polyfill";var oe=t=>new Ae({start(e){for(let r of t)e.enqueue(r);e.close()}});var En={fromArray:oe};import"web-streams-polyfill";import{TransformStream as Ie}from"web-streams-polyfill";var ae=t=>new Ie({transform(e,r){t(e)&&r.enqueue(e)}});import{TransformStream as He}from"web-streams-polyfill";var se=t=>new He({transform(e,r){r.enqueue(t(e))}});import{TransformStream as je}from"web-streams-polyfill";var ie=(t,e)=>new g(t,e),g=class extends je{accumulator;reducer;constructor(e,r){super({transform:n=>{this.accumulator=this.reducer(this.accumulator,n)},flush:n=>{n.enqueue(this.accumulator),n.terminate()}}),this.accumulator=r,this.reducer=e}};import{TransformStream as Fe}from"web-streams-polyfill";var me=(t,e,r={forever:!0,minTimeout:25})=>new Fe({start(n){w(()=>Ne(t,e,n),r).catch(o=>{n.error(o)})}}),Ne=async(t,e,r)=>{let o=t().getReader();try{let a;do{let i=await o.read();a=i.done,await e(i,r),a&&r.terminate()}while(!a)}finally{o.releaseLock()}};import{TransformStream as _e}from"web-streams-polyfill";var de=t=>new h(t),h=class extends _e{count=0;skip;constructor(e){super({transform:(r,n)=>{this.count++,this.count>this.skip&&n.enqueue(r)}}),this.skip=e}};import{TransformStream as We}from"web-streams-polyfill";var pe=t=>new We({transform(e,r){r.enqueue(e),t(e)&&r.terminate()}});import{TransformStream as Ge}from"web-streams-polyfill";var le=t=>new Ge({async transform(e,r){if(!t(e)){r.enqueue(e);return}await Promise.resolve(),r.terminate()}});import{TransformStream as qe}from"web-streams-polyfill";var ce=t=>new C(t),C=class extends qe{count=0;limit;constructor(e){super({transform:(r,n)=>{this.count<this.limit?(this.count++,n.enqueue(r)):n.terminate()}}),this.limit=e}};import{TransformStream as Ue}from"web-streams-polyfill";var ue=t=>new Ue({start(e){let r=setTimeout(()=>{e.terminate()},t),n=e.terminate.bind(e);e.terminate=()=>{clearTimeout(r),n()}},transform(e,r){r.enqueue(e)}});var fe={filter:ae,take:ce,TakeTransformStream:C,skip:de,SkipTransformStream:h,map:se,notifyAboutNoActiveReadersStream:O,NotifyAboutNoActiveReadersStream:S,reduce:ie,ReduceTransformStream:g,retry:me,stopAfter:pe,stopOn:le,waitAtMost:ue};var{retry:Be}=fe,Qn=(t,e=o=>o,r={forever:!0,minTimeout:25},n=new x)=>Be(t,$e(e,n),r).readable,$e=(t=r=>r,e=new x)=>(r,n)=>{let{done:o,value:a}=r;a&&e.addToBuffer(a),!(!o&&!e.hasCompleteMessage())&&Je(e,t,n)},Je=(t,e,r)=>{try{let n=t.decode();if(!n)return;let o=e(n);r.enqueue(o)}catch(n){r.error(new Error(`Decoding error: ${n?.toString()}`))}};var p=class extends Error{constructor(e){super(e)}},ye=(t,e)=>{let r=t,n=e;return U(r),U(n),Object.keys(n).every(o=>typeof n[o]=="object"?ye(r[o],n[o]):n[o]===r[o])},po=t=>{throw new p(t??"That should not ever happened, right?")},lo=async(t,e)=>{try{throw await t(),new p("Function didn't throw expected error")}catch(r){let n=r;return e&&s(e(n)),n}},co=(t,e)=>{try{throw t(),new p("Function didn't throw expected error")}catch(r){let n=r;return e&&s(e(n)),n}},uo=async(t,e)=>{try{throw await t,new p("Function didn't throw expected error")}catch(r){if(!e)return;e instanceof Error?Ke(r,e):s(e(r))}},ve=(t,e,r)=>{if(!ye(t,e))throw new p(r??`subObj:
|
|
6
|
+
${c.stringify(e)}
|
|
7
7
|
is not subset of
|
|
8
|
-
${
|
|
9
|
-
${
|
|
8
|
+
${c.stringify(t)}`)},Ke=(t,e,r)=>{if(!d(t,e))throw new p(r??`subObj:
|
|
9
|
+
${c.stringify(e)}
|
|
10
10
|
is not equal to
|
|
11
|
-
${
|
|
12
|
-
${
|
|
11
|
+
${c.stringify(t)}`)},fo=(t,e,r)=>{if(d(t,e))throw new p(r??`subObj:
|
|
12
|
+
${c.stringify(e)}
|
|
13
13
|
is equals to
|
|
14
|
-
${
|
|
15
|
-
Expected: ${
|
|
16
|
-
Actual:${
|
|
14
|
+
${c.stringify(t)}`)},yo=t=>({isEqualTo:e=>s(d(t,e))});function Xe(t,e){if(t)throw new p(e??"Condition is false")}function s(t,e){if(!t)throw new p(e??"Condition is false")}function U(t,e){if(!t)throw new p(e??"Condition is not truthy")}function u(t,e,r){if(t!==e)throw new p(`${r??"Objects are not equal"}:
|
|
15
|
+
Expected: ${c.stringify(t)}
|
|
16
|
+
Actual:${c.stringify(e)}`)}function Ee(t,e,r){if(t===e)throw new p(r??`Objects are equal: ${c.stringify(t)}`)}function vo(t){Ee(t,null),U(t)}function Eo(t){u(t,null)}var So=t=>e=>d(e,t),To=t=>e=>t(e);function xo(t){return{calledTimes:e=>{u(t.mock?.calls?.length,e)},notCalled:()=>{u(t?.mock?.calls?.length,0)},called:()=>{s(t.mock?.calls.length!==void 0&&t.mock.calls.length>0)},calledWith:(...e)=>{s(t.mock?.calls.length!==void 0&&t.mock.calls.length>=1&&t.mock.calls.some(r=>d(r.arguments,e)))},calledOnceWith:(...e)=>{s(t.mock?.calls.length!==void 0&&t.mock.calls.length===1&&t.mock.calls.some(r=>d(r.arguments,e)))},calledWithArgumentMatching:(...e)=>{s(t.mock?.calls.length!==void 0&&t.mock.calls.length>=1),s(t.mock?.calls.length!==void 0&&t.mock.calls.length>=1&&t.mock.calls.some(r=>r.arguments&&r.arguments.length>=e.length&&e.every((n,o)=>n(r.arguments[o]))))},notCalledWithArgumentMatching:(...e)=>{Xe(t.mock?.calls.length!==void 0&&t.mock.calls.length>=1&&t.mock.calls[0].arguments&&t.mock.calls[0].arguments.length>=e.length&&e.every((r,n)=>r(t.mock.calls[0].arguments[n])))}}}var go=t=>({isEmpty:()=>u(t.length,0),isNotEmpty:()=>Ee(t.length,0),hasSize:e=>u(t.length,e),containsElements:(...e)=>{s(e.every(r=>e.some(n=>d(r,n))))},containsExactlyInAnyOrder:(...e)=>{u(t.length,e.length),s(t.every(r=>e.some(n=>d(r,n))))},containsExactlyInAnyOrderElementsOf:e=>{u(t.length,e.length),s(t.every(r=>e.some(n=>d(r,n))))},containsExactlyElementsOf:e=>{u(t.length,e.length);for(let r=0;r<t.length;r++)s(d(t[r],e[r]))},containsExactly:e=>{u(t.length,1),s(d(t[0],e))},contains:e=>{s(t.some(r=>d(r,e)))},containsOnlyOnceElementsOf:e=>{s(e.map(r=>t.filter(n=>d(n,r)).length).filter(r=>r===1).length===e.length)},containsAnyOf:(...e)=>{s(t.some(r=>e.some(n=>d(r,n))))},allMatch:e=>{s(t.every(e))},anyMatches:e=>{s(t.some(e))},allMatchAsync:async e=>{for(let r of t)s(await e(r))}});var bo={for:t=>e=>({when:r=>{let n=()=>{let a=(Array.isArray(e)?e:[e]).reduce(t.evolve,t.initialState());return t.decide(r,a)};return{then:o=>{let a=n(),i=Array.isArray(a)?a:[a],m=Array.isArray(o)?o:[o];ve(i,m)},thenThrows:(...o)=>{try{throw n(),new p("Handler did not fail as expected")}catch(a){if(a instanceof p)throw a;if(o.length===0)return;if(!$(o[0])){s(o[0](a),`Error didn't match the error condition: ${a?.toString()}`);return}s(a instanceof o[0],`Caught error is not an instance of the expected type: ${a?.toString()}`),o[1]&&s(o[1](a),`Error didn't match the error condition: ${a?.toString()}`)}}}}})};var wo=t=>{let e=new Map;return{async aggregateStream(r,n){return t.aggregateStream(r,n)},readStream(r,n){return t.readStream(r,n)},appendToStream:async(r,n,o)=>{let a=await t.appendToStream(r,n,o),i=e.get(r)??[r,[]];return e.set(r,[r,[...i[1],...n]]),a},appendedEvents:e,setup:async(r,n)=>t.appendToStream(r,n)}};export{p as AssertionError,M as BinaryJsonDecoder,_ as CaughtUpTransformStream,ne as CommandHandler,re as CommandHandlerStreamVersionConflictRetryOptions,q as CompositeDecoder,J as ConcurrencyError,Pr as DeciderCommandHandler,bo as DeciderSpecification,x as DefaultDecoder,I as EmmettError,b as ExpectedVersionConflictError,H as GlobalStreamCaughtUpType,st as IllegalStateError,T as InMemoryEventStoreDefaultStreamVersion,c as JSONParser,P as JsonDecoder,D as NO_CONCURRENCY_CHECK,te as NoRetries,it as NotFoundError,k as ObjectDecoder,W as ParseError,F as STREAM_DOES_NOT_EXIST,xe as STREAM_EXISTS,ee as StreamingCoordinator,V as StringDecoder,at as ValidationError,Ze as ValidationErrors,wo as WrapEventStore,xt as accept,To as argMatches,So as argValue,Ke as assertDeepEqual,u as assertEqual,N as assertExpectedVersionMatchesCurrent,po as assertFails,Xe as assertFalse,vo as assertIsNotNull,Eo as assertIsNull,ve as assertMatches,fo as assertNotDeepEqual,rt as assertNotEmptyString,Ee as assertNotEqual,U as assertOk,nt as assertPositiveNumber,uo as assertRejects,yo as assertThat,go as assertThatArray,co as assertThrows,lo as assertThrowsAsync,s as assertTrue,ot as assertUnsignedBigInt,ke as asyncProjections,w as asyncRetry,K as canCreateEventStoreSession,Mt as caughtUpEventFrom,Lr as collect,pt as command,Et as complete,G as concatUint8Arrays,d as deepEquals,Tt as error,L as event,Ye as formatDateToUtcYYYYMMDD,ir as getInMemoryEventStore,Nr as getInMemoryMessageBus,j as globalStreamCaughtUp,St as ignore,Pe as inlineProjections,Oe as isEquatable,$ as isErrorConstructor,z as isExpectedVersionConflictError,Y as isGlobalStreamCaughtUp,Pt as isNotInternalEvent,et as isNumber,mt as isPluginConfig,tt as isString,Vt as isSubscriptionEvent,ye as isSubset,ze as isValidYYYYMMDD,ge as matchesExpectedVersion,Sr as merge,X as nulloSessionFactory,Qe as parseDateFromUtcYYYYMMDD,Wr as projection,Gr as projections,yt as publish,ut as reply,Qn as restream,vt as schedule,ft as send,En as streamGenerators,Q as streamTrackingGlobalPosition,fe as streamTransformations,vr as sum,xo as verifyThat};
|
|
17
17
|
//# sourceMappingURL=index.js.map
|