@event-driven-io/emmett 0.20.1-alpha.5 → 0.20.2-alpha.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.
package/dist/index.js CHANGED
@@ -1,17 +1,1333 @@
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
- `))}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 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)}
1
+ import {
2
+ ConcurrencyError,
3
+ EmmettError,
4
+ IllegalStateError,
5
+ NotFoundError,
6
+ ValidationError,
7
+ ValidationErrors,
8
+ assertNotEmptyString,
9
+ assertPositiveNumber,
10
+ assertUnsignedBigInt,
11
+ formatDateToUtcYYYYMMDD,
12
+ isErrorConstructor,
13
+ isNumber,
14
+ isPluginConfig,
15
+ isString,
16
+ isValidYYYYMMDD,
17
+ parseDateFromUtcYYYYMMDD
18
+ } from "./chunk-AEEEXE2R.js";
19
+
20
+ // src/eventStore/eventStore.ts
21
+ var canCreateEventStoreSession = (eventStore) => "withSession" in eventStore;
22
+ var nulloSessionFactory = (eventStore) => ({
23
+ withSession: (callback) => {
24
+ const nulloSession = {
25
+ eventStore,
26
+ close: () => Promise.resolve()
27
+ };
28
+ return callback(nulloSession);
29
+ }
30
+ });
31
+
32
+ // src/typing/command.ts
33
+ var command = (type, data, metadata) => {
34
+ return {
35
+ type,
36
+ data,
37
+ metadata
38
+ };
39
+ };
40
+
41
+ // src/typing/event.ts
42
+ var event = (type, data, metadata) => {
43
+ return {
44
+ type,
45
+ data,
46
+ metadata
47
+ };
48
+ };
49
+
50
+ // src/typing/workflow.ts
51
+ var reply = (message) => {
52
+ return {
53
+ kind: "Reply",
54
+ message
55
+ };
56
+ };
57
+ var send = (message) => {
58
+ return {
59
+ kind: "Send",
60
+ message
61
+ };
62
+ };
63
+ var publish = (message) => {
64
+ return {
65
+ kind: "Publish",
66
+ message
67
+ };
68
+ };
69
+ var schedule = (message, when) => {
70
+ return {
71
+ kind: "Schedule",
72
+ message,
73
+ when
74
+ };
75
+ };
76
+ var complete = () => {
77
+ return {
78
+ kind: "Complete"
79
+ };
80
+ };
81
+ var ignore = (reason) => {
82
+ return {
83
+ kind: "Ignore",
84
+ reason
85
+ };
86
+ };
87
+ var error = (reason) => {
88
+ return {
89
+ kind: "Error",
90
+ reason
91
+ };
92
+ };
93
+ var accept = () => {
94
+ return { kind: "Accept" };
95
+ };
96
+
97
+ // src/eventStore/events/index.ts
98
+ var GlobalStreamCaughtUpType = "__emt:GlobalStreamCaughtUp";
99
+ var isGlobalStreamCaughtUp = (event2) => event2.type === GlobalStreamCaughtUpType;
100
+ var caughtUpEventFrom = (position) => (event2) => event2.type === GlobalStreamCaughtUpType && event2.metadata?.globalPosition >= position;
101
+ var globalStreamCaughtUp = (data) => event(GlobalStreamCaughtUpType, data, {
102
+ globalPosition: data.globalPosition
103
+ });
104
+ var isSubscriptionEvent = (event2) => isGlobalStreamCaughtUp(event2);
105
+ var isNotInternalEvent = (event2) => !isGlobalStreamCaughtUp(event2);
106
+
107
+ // src/eventStore/expectedVersion.ts
108
+ var STREAM_EXISTS = "STREAM_EXISTS";
109
+ var STREAM_DOES_NOT_EXIST = "STREAM_DOES_NOT_EXIST";
110
+ var NO_CONCURRENCY_CHECK = "NO_CONCURRENCY_CHECK";
111
+ var matchesExpectedVersion = (current, expected, defaultVersion) => {
112
+ if (expected === NO_CONCURRENCY_CHECK) return true;
113
+ if (expected == STREAM_DOES_NOT_EXIST) return current === defaultVersion;
114
+ if (expected == STREAM_EXISTS) return current !== defaultVersion;
115
+ return current === expected;
116
+ };
117
+ var assertExpectedVersionMatchesCurrent = (current, expected, defaultVersion) => {
118
+ expected ??= NO_CONCURRENCY_CHECK;
119
+ if (!matchesExpectedVersion(current, expected, defaultVersion))
120
+ throw new ExpectedVersionConflictError(current, expected);
121
+ };
122
+ var ExpectedVersionConflictError = class _ExpectedVersionConflictError extends ConcurrencyError {
123
+ constructor(current, expected) {
124
+ super(current?.toString(), expected?.toString());
125
+ Object.setPrototypeOf(this, _ExpectedVersionConflictError.prototype);
126
+ }
127
+ };
128
+ var isExpectedVersionConflictError = (error2) => error2 instanceof ExpectedVersionConflictError;
129
+
130
+ // src/eventStore/inMemoryEventStore.ts
131
+ import { v4 as uuid3 } from "uuid";
132
+
133
+ // src/eventStore/subscriptions/caughtUpTransformStream.ts
134
+ import { TransformStream } from "web-streams-polyfill";
135
+ var streamTrackingGlobalPosition = (currentEvents) => new CaughtUpTransformStream(currentEvents);
136
+ var CaughtUpTransformStream = class extends TransformStream {
137
+ _currentPosition;
138
+ _logPosition;
139
+ constructor(events) {
140
+ super({
141
+ start: (controller) => {
142
+ let globalPosition = 0n;
143
+ for (const event2 of events) {
144
+ controller.enqueue(event2);
145
+ globalPosition = event2.metadata.globalPosition;
146
+ }
147
+ controller.enqueue(globalStreamCaughtUp({ globalPosition }));
148
+ },
149
+ transform: (event2, controller) => {
150
+ this._currentPosition = event2.metadata.globalPosition;
151
+ controller.enqueue(event2);
152
+ if (this._currentPosition < this._logPosition) return;
153
+ controller.enqueue(
154
+ globalStreamCaughtUp({ globalPosition: this._currentPosition })
155
+ );
156
+ }
157
+ });
158
+ this._currentPosition = this._logPosition = events.length > 0 ? events[events.length - 1].metadata.globalPosition : 0n;
159
+ }
160
+ set logPosition(value) {
161
+ this._logPosition = value;
162
+ }
163
+ };
164
+
165
+ // src/eventStore/subscriptions/streamingCoordinator.ts
166
+ import { v4 as uuid2 } from "uuid";
167
+
168
+ // src/streaming/transformations/notifyAboutNoActiveReaders.ts
169
+ import { v4 as uuid } from "uuid";
170
+ import { TransformStream as TransformStream2 } from "web-streams-polyfill";
171
+ var notifyAboutNoActiveReadersStream = (onNoActiveReaderCallback, options = {}) => new NotifyAboutNoActiveReadersStream(onNoActiveReaderCallback, options);
172
+ var NotifyAboutNoActiveReadersStream = class extends TransformStream2 {
173
+ constructor(onNoActiveReaderCallback, options = {}) {
174
+ super({
175
+ cancel: (reason) => {
176
+ console.log("Stream was canceled. Reason:", reason);
177
+ this.stopChecking();
178
+ }
179
+ });
180
+ this.onNoActiveReaderCallback = onNoActiveReaderCallback;
181
+ this.streamId = options?.streamId ?? uuid();
182
+ this.onNoActiveReaderCallback = onNoActiveReaderCallback;
183
+ this.startChecking(options?.intervalCheckInMs ?? 20);
184
+ }
185
+ checkInterval = null;
186
+ streamId;
187
+ _isStopped = false;
188
+ get hasActiveSubscribers() {
189
+ return !this._isStopped;
190
+ }
191
+ startChecking(interval) {
192
+ this.checkInterval = setInterval(() => {
193
+ this.checkNoActiveReader();
194
+ }, interval);
195
+ }
196
+ stopChecking() {
197
+ if (!this.checkInterval) return;
198
+ clearInterval(this.checkInterval);
199
+ this.checkInterval = null;
200
+ this._isStopped = true;
201
+ this.onNoActiveReaderCallback(this);
202
+ }
203
+ checkNoActiveReader() {
204
+ if (!this.readable.locked && !this._isStopped) {
205
+ this.stopChecking();
206
+ }
207
+ }
208
+ };
209
+
210
+ // src/streaming/writers/writeToStream.ts
211
+ var writeToStream = async (stream, items) => {
212
+ if (stream.writable.locked) return false;
213
+ const writer = stream.writable.getWriter();
214
+ await writer.ready;
215
+ if (!stream.readable.locked) return false;
216
+ try {
217
+ for (const item of items) {
218
+ await writer.write(item);
219
+ }
220
+ } catch (error2) {
221
+ console.log(error2);
222
+ } finally {
223
+ await writer.close();
224
+ }
225
+ return true;
226
+ };
227
+
228
+ // src/eventStore/subscriptions/streamingCoordinator.ts
229
+ var StreamingCoordinator = () => {
230
+ const allEvents = [];
231
+ const listeners = /* @__PURE__ */ new Map();
232
+ return {
233
+ notify: async (events) => {
234
+ if (events.length === 0) return;
235
+ allEvents.push(...events);
236
+ for (const listener of listeners.values()) {
237
+ listener.logPosition = events[events.length - 1].metadata.globalPosition;
238
+ await writeToStream(listener, events);
239
+ }
240
+ },
241
+ stream: () => {
242
+ const streamId = uuid2();
243
+ const transformStream = streamTrackingGlobalPosition(allEvents);
244
+ listeners.set(streamId, transformStream);
245
+ return transformStream.readable.pipeThrough(
246
+ notifyAboutNoActiveReadersStream(
247
+ (stream) => {
248
+ if (listeners.has(stream.streamId))
249
+ listeners.delete(stream.streamId);
250
+ },
251
+ { streamId }
252
+ )
253
+ );
254
+ }
255
+ };
256
+ };
257
+
258
+ // src/eventStore/inMemoryEventStore.ts
259
+ var InMemoryEventStoreDefaultStreamVersion = 0n;
260
+ var getInMemoryEventStore = () => {
261
+ const streams = /* @__PURE__ */ new Map();
262
+ const streamingCoordinator = StreamingCoordinator();
263
+ const getAllEventsCount = () => {
264
+ return Array.from(streams.values()).map((s) => s.length).reduce((p, c) => p + c, 0);
265
+ };
266
+ return {
267
+ async aggregateStream(streamName, options) {
268
+ const { evolve, initialState, read } = options;
269
+ const result = await this.readStream(streamName, read);
270
+ const events = result?.events ?? [];
271
+ return {
272
+ currentStreamVersion: BigInt(events.length),
273
+ state: events.reduce(evolve, initialState()),
274
+ streamExists: result.streamExists
275
+ };
276
+ },
277
+ readStream: (streamName, options) => {
278
+ const events = streams.get(streamName);
279
+ const currentStreamVersion = events ? BigInt(events.length) : InMemoryEventStoreDefaultStreamVersion;
280
+ assertExpectedVersionMatchesCurrent(
281
+ currentStreamVersion,
282
+ options?.expectedStreamVersion,
283
+ InMemoryEventStoreDefaultStreamVersion
284
+ );
285
+ const from = Number(options && "from" in options ? options.from : 0);
286
+ const to = Number(
287
+ options && "to" in options ? options.to : options && "maxCount" in options && options.maxCount ? options.from + options.maxCount : events?.length ?? 1
288
+ );
289
+ const resultEvents = events !== void 0 && events.length > 0 ? events.map(
290
+ (e) => e
291
+ ).slice(from, to) : [];
292
+ const result = {
293
+ currentStreamVersion,
294
+ events: resultEvents,
295
+ streamExists: events !== void 0 && events.length > 0
296
+ };
297
+ return Promise.resolve(result);
298
+ },
299
+ appendToStream: async (streamName, events, options) => {
300
+ const currentEvents = streams.get(streamName) ?? [];
301
+ const currentStreamVersion = currentEvents.length > 0 ? BigInt(currentEvents.length) : InMemoryEventStoreDefaultStreamVersion;
302
+ assertExpectedVersionMatchesCurrent(
303
+ currentStreamVersion,
304
+ options?.expectedStreamVersion,
305
+ InMemoryEventStoreDefaultStreamVersion
306
+ );
307
+ const newEvents = events.map((event2, index) => {
308
+ return {
309
+ ...event2,
310
+ metadata: {
311
+ ...event2.metadata ?? {},
312
+ streamName,
313
+ eventId: uuid3(),
314
+ streamPosition: BigInt(currentEvents.length + index + 1),
315
+ globalPosition: BigInt(getAllEventsCount() + index + 1)
316
+ }
317
+ };
318
+ });
319
+ const positionOfLastEventInTheStream = BigInt(
320
+ newEvents.slice(-1)[0].metadata.streamPosition
321
+ );
322
+ streams.set(streamName, [...currentEvents, ...newEvents]);
323
+ await streamingCoordinator.notify(newEvents);
324
+ const result = {
325
+ nextExpectedStreamVersion: positionOfLastEventInTheStream,
326
+ createdNewStream: currentStreamVersion === InMemoryEventStoreDefaultStreamVersion
327
+ };
328
+ return result;
329
+ }
330
+ //streamEvents: streamingCoordinator.stream,
331
+ };
332
+ };
333
+
334
+ // src/utils/deepEquals.ts
335
+ var deepEquals = (left, right) => {
336
+ if (isEquatable(left)) {
337
+ return left.equals(right);
338
+ }
339
+ if (Array.isArray(left)) {
340
+ return Array.isArray(right) && left.length === right.length && left.every((val, index) => deepEquals(val, right[index]));
341
+ }
342
+ if (typeof left !== "object" || typeof right !== "object" || left === null || right === null) {
343
+ return left === right;
344
+ }
345
+ if (Array.isArray(right)) return false;
346
+ const keys1 = Object.keys(left);
347
+ const keys2 = Object.keys(right);
348
+ if (keys1.length !== keys2.length || !keys1.every((key) => keys2.includes(key)))
349
+ return false;
350
+ for (const key in left) {
351
+ if (left[key] instanceof Function && right[key] instanceof Function)
352
+ continue;
353
+ const isEqual = deepEquals(left[key], right[key]);
354
+ if (!isEqual) {
355
+ return false;
356
+ }
357
+ }
358
+ return true;
359
+ };
360
+ var isEquatable = (left) => {
361
+ return left && typeof left === "object" && "equals" in left && typeof left["equals"] === "function";
362
+ };
363
+
364
+ // src/utils/iterators.ts
365
+ var sum = (iterator) => {
366
+ let value, done, sum2 = 0;
367
+ do {
368
+ ({ value, done } = iterator.next());
369
+ sum2 += value || 0;
370
+ } while (!done);
371
+ return sum2;
372
+ };
373
+
374
+ // src/utils/merge.ts
375
+ var merge = (array, item, where, onExisting, onNotFound = () => void 0) => {
376
+ let wasFound = false;
377
+ const result = array.map((p) => {
378
+ if (!where(p)) return p;
379
+ wasFound = true;
380
+ return onExisting(p);
381
+ }).filter((p) => p !== void 0).map((p) => {
382
+ if (!p) throw Error("That should not happen");
383
+ return p;
384
+ });
385
+ if (!wasFound) {
386
+ const result2 = onNotFound();
387
+ if (result2 !== void 0) return [...array, item];
388
+ }
389
+ return result;
390
+ };
391
+
392
+ // src/utils/retry.ts
393
+ import retry from "async-retry";
394
+ var NoRetries = { retries: 0 };
395
+ var asyncRetry = async (fn, opts) => {
396
+ if (opts === void 0 || opts.retries === 0) return fn();
397
+ return retry(
398
+ async (bail) => {
399
+ try {
400
+ return await fn();
401
+ } catch (error2) {
402
+ if (opts?.shouldRetryError && !opts.shouldRetryError(error2)) {
403
+ bail(error2);
404
+ }
405
+ throw error2;
406
+ }
407
+ },
408
+ opts ?? { retries: 0 }
409
+ );
410
+ };
411
+
412
+ // src/commandHandling/handleCommand.ts
413
+ var CommandHandlerStreamVersionConflictRetryOptions = {
414
+ retries: 3,
415
+ minTimeout: 100,
416
+ factor: 1.5,
417
+ shouldRetryError: isExpectedVersionConflictError
418
+ };
419
+ var fromCommandHandlerRetryOptions = (retryOptions) => {
420
+ if (retryOptions === void 0) return NoRetries;
421
+ if ("onVersionConflict" in retryOptions) {
422
+ if (typeof retryOptions.onVersionConflict === "boolean")
423
+ return CommandHandlerStreamVersionConflictRetryOptions;
424
+ else if (typeof retryOptions.onVersionConflict === "number")
425
+ return {
426
+ ...CommandHandlerStreamVersionConflictRetryOptions,
427
+ retries: retryOptions.onVersionConflict
428
+ };
429
+ else return retryOptions.onVersionConflict;
430
+ }
431
+ return retryOptions;
432
+ };
433
+ var CommandHandler = (options) => async (store, id, handle, handleOptions) => asyncRetry(
434
+ async () => {
435
+ const result = await withSession(store, async ({ eventStore }) => {
436
+ const { evolve, initialState } = options;
437
+ const mapToStreamId = options.mapToStreamId ?? ((id2) => id2);
438
+ const streamName = mapToStreamId(id);
439
+ const aggregationResult = await eventStore.aggregateStream(streamName, {
440
+ evolve,
441
+ initialState,
442
+ read: {
443
+ // expected stream version is passed to fail fast
444
+ // if stream is in the wrong state
445
+ expectedStreamVersion: handleOptions?.expectedStreamVersion ?? NO_CONCURRENCY_CHECK
446
+ }
447
+ });
448
+ const state = aggregationResult.state;
449
+ const currentStreamVersion = aggregationResult.currentStreamVersion;
450
+ const result2 = await handle(state);
451
+ const newEvents = Array.isArray(result2) ? result2 : [result2];
452
+ if (newEvents.length === 0) {
453
+ return {
454
+ newEvents: [],
455
+ newState: state,
456
+ nextExpectedStreamVersion: currentStreamVersion,
457
+ createdNewStream: false
458
+ };
459
+ }
460
+ const expectedStreamVersion = handleOptions?.expectedStreamVersion ?? (aggregationResult.streamExists ? currentStreamVersion : STREAM_DOES_NOT_EXIST);
461
+ const appendResult = await eventStore.appendToStream(
462
+ streamName,
463
+ newEvents,
464
+ {
465
+ ...handleOptions,
466
+ expectedStreamVersion
467
+ }
468
+ );
469
+ return {
470
+ ...appendResult,
471
+ newEvents,
472
+ newState: newEvents.reduce(evolve, state)
473
+ };
474
+ });
475
+ return result;
476
+ },
477
+ fromCommandHandlerRetryOptions(
478
+ handleOptions && "retry" in handleOptions ? handleOptions.retry : options.retry
479
+ )
480
+ );
481
+ var withSession = (eventStore, callback) => {
482
+ const sessionFactory = canCreateEventStoreSession(eventStore) ? eventStore : nulloSessionFactory(eventStore);
483
+ return sessionFactory.withSession(callback);
484
+ };
485
+
486
+ // src/commandHandling/handleCommandWithDecider.ts
487
+ var DeciderCommandHandler = (options) => async (eventStore, id, command2, handleOptions) => {
488
+ const { decide, ...rest } = options;
489
+ return CommandHandler(rest)(
490
+ eventStore,
491
+ id,
492
+ (state) => decide(command2, state),
493
+ handleOptions
494
+ );
495
+ };
496
+
497
+ // src/messageBus/index.ts
498
+ var getInMemoryMessageBus = () => {
499
+ const allHandlers = /* @__PURE__ */ new Map();
500
+ let pendingMessages = [];
501
+ return {
502
+ send: async (command2) => {
503
+ const handlers = allHandlers.get(command2.type);
504
+ if (handlers === void 0 || handlers.length === 0)
505
+ throw new EmmettError(
506
+ `No handler registered for command ${command2.type}!`
507
+ );
508
+ const commandHandler = handlers[0];
509
+ await commandHandler(command2);
510
+ },
511
+ publish: async (event2) => {
512
+ const handlers = allHandlers.get(event2.type) ?? [];
513
+ for (const handler of handlers) {
514
+ const eventHandler = handler;
515
+ await eventHandler(event2);
516
+ }
517
+ },
518
+ schedule: (message, when) => {
519
+ pendingMessages = [...pendingMessages, { message, options: when }];
520
+ },
521
+ handle: (commandHandler, ...commandTypes) => {
522
+ const alreadyRegistered = [...allHandlers.keys()].filter(
523
+ (registered) => commandTypes.includes(registered)
524
+ );
525
+ if (alreadyRegistered.length > 0)
526
+ throw new EmmettError(
527
+ `Cannot register handler for commands ${alreadyRegistered.join(", ")} as they're already registered!`
528
+ );
529
+ for (const commandType of commandTypes) {
530
+ allHandlers.set(commandType, [commandHandler]);
531
+ }
532
+ },
533
+ subscribe(eventHandler, ...eventTypes) {
534
+ for (const eventType of eventTypes) {
535
+ if (!allHandlers.has(eventType)) allHandlers.set(eventType, []);
536
+ allHandlers.set(eventType, [
537
+ ...allHandlers.get(eventType) ?? [],
538
+ eventHandler
539
+ ]);
540
+ }
541
+ },
542
+ dequeue: () => {
543
+ const pending = pendingMessages;
544
+ pendingMessages = [];
545
+ return pending;
546
+ }
547
+ };
548
+ };
549
+
550
+ // src/projections/index.ts
551
+ var projection = (definition) => definition;
552
+ var inlineProjections = (definitions) => definitions.map((projection2) => ({ type: "inline", projection: projection2 }));
553
+ var asyncProjections = (definitions) => definitions.map((projection2) => ({ type: "async", projection: projection2 }));
554
+ var projections = {
555
+ inline: inlineProjections,
556
+ async: asyncProjections
557
+ };
558
+
559
+ // src/serialization/json/JSONParser.ts
560
+ var ParseError = class extends Error {
561
+ constructor(text) {
562
+ super(`Cannot parse! ${text}`);
563
+ }
564
+ };
565
+ var JSONParser = {
566
+ stringify: (value, options) => {
567
+ return JSON.stringify(
568
+ options?.map ? options.map(value) : value,
569
+ //TODO: Consider adding support to DateTime and adding specific format to mark that's a bigint
570
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
571
+ (_, v) => typeof v === "bigint" ? v.toString() : v
572
+ );
573
+ },
574
+ parse: (text, options) => {
575
+ const parsed = JSON.parse(text, options?.reviver);
576
+ if (options?.typeCheck && !options?.typeCheck(parsed))
577
+ throw new ParseError(text);
578
+ return options?.map ? options.map(parsed) : parsed;
579
+ }
580
+ };
581
+
582
+ // src/streaming/binaryArrays.ts
583
+ var concatUint8Arrays = (chunks) => {
584
+ const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0);
585
+ const result = new Uint8Array(totalLength);
586
+ let offset = 0;
587
+ for (const chunk of chunks) {
588
+ result.set(chunk, offset);
589
+ offset += chunk.length;
590
+ }
591
+ return result;
592
+ };
593
+
594
+ // src/streaming/collectors/collect.ts
595
+ var collect = async (stream) => {
596
+ const results = [];
597
+ for await (const value of stream) {
598
+ results.push(value);
599
+ }
600
+ return results;
601
+ };
602
+
603
+ // src/streaming/decoders/binary.ts
604
+ var BinaryJsonDecoder = class {
605
+ buffer = [];
606
+ addToBuffer(data) {
607
+ this.buffer.push(data);
608
+ }
609
+ clearBuffer() {
610
+ this.buffer = [];
611
+ }
612
+ hasCompleteMessage() {
613
+ const combined = concatUint8Arrays(this.buffer);
614
+ const text = new TextDecoder().decode(combined);
615
+ return text.includes("\n");
616
+ }
617
+ decode() {
618
+ if (!this.hasCompleteMessage()) {
619
+ return null;
620
+ }
621
+ const combined = concatUint8Arrays(this.buffer);
622
+ const text = new TextDecoder().decode(combined);
623
+ const delimiterIndex = text.indexOf("\n");
624
+ if (delimiterIndex === -1) {
625
+ return null;
626
+ }
627
+ const jsonString = text.slice(0, delimiterIndex);
628
+ const remaining = new Uint8Array(combined.buffer, delimiterIndex + 1);
629
+ this.buffer = remaining.byteLength > 0 ? [remaining] : [];
630
+ return JSON.parse(jsonString);
631
+ }
632
+ };
633
+
634
+ // src/streaming/decoders/string.ts
635
+ var StringDecoder = class {
636
+ constructor(transform) {
637
+ this.transform = transform;
638
+ this.transform = transform;
639
+ }
640
+ buffer = [];
641
+ addToBuffer(data) {
642
+ this.buffer.push(data);
643
+ }
644
+ clearBuffer() {
645
+ this.buffer = [];
646
+ }
647
+ hasCompleteMessage() {
648
+ return this.buffer.some((chunk) => chunk.includes("\n"));
649
+ }
650
+ decode() {
651
+ const completeString = this.buffer.join("");
652
+ if (!this.hasCompleteMessage()) {
653
+ if (completeString.trim().length > 0) {
654
+ throw new Error("Unterminated string in JSON at position");
655
+ }
656
+ return null;
657
+ }
658
+ const delimiterIndex = completeString.indexOf("\n");
659
+ const message = completeString.slice(0, delimiterIndex).trim();
660
+ this.buffer = [completeString.slice(delimiterIndex + 1)];
661
+ return this.transform(message);
662
+ }
663
+ };
664
+
665
+ // src/streaming/decoders/json.ts
666
+ var JsonDecoder = class extends StringDecoder {
667
+ constructor() {
668
+ super((jsonString) => JSON.parse(jsonString));
669
+ }
670
+ };
671
+
672
+ // src/streaming/decoders/object.ts
673
+ var ObjectDecoder = class {
674
+ buffer = null;
675
+ addToBuffer(data) {
676
+ this.buffer = data;
677
+ }
678
+ clearBuffer() {
679
+ this.buffer = null;
680
+ }
681
+ hasCompleteMessage() {
682
+ return this.buffer !== null;
683
+ }
684
+ decode() {
685
+ if (!this.hasCompleteMessage() || !this.buffer) {
686
+ return null;
687
+ }
688
+ const data = this.buffer;
689
+ this.clearBuffer();
690
+ return data;
691
+ }
692
+ };
693
+
694
+ // src/streaming/decoders/composite.ts
695
+ var CompositeDecoder = class {
696
+ constructor(decoders) {
697
+ this.decoders = decoders;
698
+ }
699
+ decoderFor(data) {
700
+ const decoder = this.decoders.find((d) => d[0](data));
701
+ if (!decoder) return null;
702
+ return decoder[1];
703
+ }
704
+ addToBuffer(data) {
705
+ this.decoderFor(data)?.addToBuffer(data);
706
+ }
707
+ clearBuffer() {
708
+ for (const decoder of this.decoders.map((d) => d[1])) {
709
+ decoder.clearBuffer();
710
+ }
711
+ }
712
+ hasCompleteMessage() {
713
+ return this.decoders.some((d) => d[1].hasCompleteMessage());
714
+ }
715
+ decode() {
716
+ const decoder = this.decoders.map((d) => d[1]).find((d) => d.hasCompleteMessage());
717
+ return decoder?.decode() ?? null;
718
+ }
719
+ };
720
+ var DefaultDecoder = class extends CompositeDecoder {
721
+ constructor() {
722
+ super([
723
+ [(data) => typeof data === "string", new JsonDecoder()],
724
+ [(data) => data instanceof Uint8Array, new BinaryJsonDecoder()],
725
+ [(data) => typeof data === "object", new ObjectDecoder()]
726
+ ]);
727
+ }
728
+ };
729
+
730
+ // src/streaming/generators/fromArray.ts
731
+ import { ReadableStream } from "web-streams-polyfill";
732
+ var fromArray = (chunks) => new ReadableStream({
733
+ start(controller) {
734
+ for (const chunk of chunks) controller.enqueue(chunk);
735
+ controller.close();
736
+ }
737
+ });
738
+
739
+ // src/streaming/generators/index.ts
740
+ var streamGenerators = { fromArray };
741
+
742
+ // src/streaming/restream.ts
743
+ import "web-streams-polyfill";
744
+
745
+ // src/streaming/transformations/filter.ts
746
+ import { TransformStream as TransformStream3 } from "web-streams-polyfill";
747
+ var filter = (filter2) => new TransformStream3({
748
+ transform(chunk, controller) {
749
+ if (filter2(chunk)) {
750
+ controller.enqueue(chunk);
751
+ }
752
+ }
753
+ });
754
+
755
+ // src/streaming/transformations/map.ts
756
+ import { TransformStream as TransformStream4 } from "web-streams-polyfill";
757
+ var map = (map2) => new TransformStream4({
758
+ transform(chunk, controller) {
759
+ controller.enqueue(map2(chunk));
760
+ }
761
+ });
762
+
763
+ // src/streaming/transformations/reduce.ts
764
+ import { TransformStream as TransformStream5 } from "web-streams-polyfill";
765
+ var reduce = (reducer, initialValue) => new ReduceTransformStream(reducer, initialValue);
766
+ var ReduceTransformStream = class extends TransformStream5 {
767
+ accumulator;
768
+ reducer;
769
+ constructor(reducer, initialValue) {
770
+ super({
771
+ transform: (chunk) => {
772
+ this.accumulator = this.reducer(this.accumulator, chunk);
773
+ },
774
+ flush: (controller) => {
775
+ controller.enqueue(this.accumulator);
776
+ controller.terminate();
777
+ }
778
+ });
779
+ this.accumulator = initialValue;
780
+ this.reducer = reducer;
781
+ }
782
+ };
783
+
784
+ // src/streaming/transformations/retry.ts
785
+ import {
786
+ TransformStream as TransformStream6
787
+ } from "web-streams-polyfill";
788
+ var retryStream = (createSourceStream, handleChunk2, retryOptions = { forever: true, minTimeout: 25 }) => new TransformStream6({
789
+ start(controller) {
790
+ asyncRetry(
791
+ () => onRestream(createSourceStream, handleChunk2, controller),
792
+ retryOptions
793
+ ).catch((error2) => {
794
+ controller.error(error2);
795
+ });
796
+ }
797
+ });
798
+ var onRestream = async (createSourceStream, handleChunk2, controller) => {
799
+ const sourceStream = createSourceStream();
800
+ const reader = sourceStream.getReader();
801
+ try {
802
+ let done;
803
+ do {
804
+ const result = await reader.read();
805
+ done = result.done;
806
+ await handleChunk2(result, controller);
807
+ if (done) {
808
+ controller.terminate();
809
+ }
810
+ } while (!done);
811
+ } finally {
812
+ reader.releaseLock();
813
+ }
814
+ };
815
+
816
+ // src/streaming/transformations/skip.ts
817
+ import { TransformStream as TransformStream7 } from "web-streams-polyfill";
818
+ var skip = (limit) => new SkipTransformStream(limit);
819
+ var SkipTransformStream = class extends TransformStream7 {
820
+ count = 0;
821
+ skip;
822
+ constructor(skip2) {
823
+ super({
824
+ transform: (chunk, controller) => {
825
+ this.count++;
826
+ if (this.count > this.skip) {
827
+ controller.enqueue(chunk);
828
+ }
829
+ }
830
+ });
831
+ this.skip = skip2;
832
+ }
833
+ };
834
+
835
+ // src/streaming/transformations/stopAfter.ts
836
+ import { TransformStream as TransformStream8 } from "web-streams-polyfill";
837
+ var stopAfter = (stopCondition) => new TransformStream8({
838
+ transform(chunk, controller) {
839
+ controller.enqueue(chunk);
840
+ if (stopCondition(chunk)) {
841
+ controller.terminate();
842
+ }
843
+ }
844
+ });
845
+
846
+ // src/streaming/transformations/stopOn.ts
847
+ import { TransformStream as TransformStream9 } from "web-streams-polyfill";
848
+ var stopOn = (stopCondition) => new TransformStream9({
849
+ async transform(chunk, controller) {
850
+ if (!stopCondition(chunk)) {
851
+ controller.enqueue(chunk);
852
+ return;
853
+ }
854
+ await Promise.resolve();
855
+ controller.terminate();
856
+ }
857
+ });
858
+
859
+ // src/streaming/transformations/take.ts
860
+ import { TransformStream as TransformStream10 } from "web-streams-polyfill";
861
+ var take = (limit) => new TakeTransformStream(limit);
862
+ var TakeTransformStream = class extends TransformStream10 {
863
+ count = 0;
864
+ limit;
865
+ constructor(limit) {
866
+ super({
867
+ transform: (chunk, controller) => {
868
+ if (this.count < this.limit) {
869
+ this.count++;
870
+ controller.enqueue(chunk);
871
+ } else {
872
+ controller.terminate();
873
+ }
874
+ }
875
+ });
876
+ this.limit = limit;
877
+ }
878
+ };
879
+
880
+ // src/streaming/transformations/waitAtMost.ts
881
+ import { TransformStream as TransformStream11 } from "web-streams-polyfill";
882
+ var waitAtMost = (waitTimeInMs) => new TransformStream11({
883
+ start(controller) {
884
+ const timeoutId = setTimeout(() => {
885
+ controller.terminate();
886
+ }, waitTimeInMs);
887
+ const originalTerminate = controller.terminate.bind(controller);
888
+ controller.terminate = () => {
889
+ clearTimeout(timeoutId);
890
+ originalTerminate();
891
+ };
892
+ },
893
+ transform(chunk, controller) {
894
+ controller.enqueue(chunk);
895
+ }
896
+ });
897
+
898
+ // src/streaming/transformations/index.ts
899
+ var streamTransformations = {
900
+ filter,
901
+ take,
902
+ TakeTransformStream,
903
+ skip,
904
+ SkipTransformStream,
905
+ map,
906
+ notifyAboutNoActiveReadersStream,
907
+ NotifyAboutNoActiveReadersStream,
908
+ reduce,
909
+ ReduceTransformStream,
910
+ retry: retryStream,
911
+ stopAfter,
912
+ stopOn,
913
+ waitAtMost
914
+ };
915
+
916
+ // src/streaming/restream.ts
917
+ var { retry: retry2 } = streamTransformations;
918
+ var restream = (createSourceStream, transform = (source) => source, retryOptions = { forever: true, minTimeout: 25 }, decoder = new DefaultDecoder()) => retry2(createSourceStream, handleChunk(transform, decoder), retryOptions).readable;
919
+ var handleChunk = (transform = (source) => source, decoder = new DefaultDecoder()) => (readResult, controller) => {
920
+ const { done: isDone, value } = readResult;
921
+ if (value) decoder.addToBuffer(value);
922
+ if (!isDone && !decoder.hasCompleteMessage()) return;
923
+ decodeAndTransform(decoder, transform, controller);
924
+ };
925
+ var decodeAndTransform = (decoder, transform, controller) => {
926
+ try {
927
+ const decoded = decoder.decode();
928
+ if (!decoded) return;
929
+ const transformed = transform(decoded);
930
+ controller.enqueue(transformed);
931
+ } catch (error2) {
932
+ controller.error(new Error(`Decoding error: ${error2?.toString()}`));
933
+ }
934
+ };
935
+
936
+ // src/testing/assertions.ts
937
+ var AssertionError = class extends Error {
938
+ constructor(message) {
939
+ super(message);
940
+ }
941
+ };
942
+ var isSubset = (superObj, subObj) => {
943
+ const sup = superObj;
944
+ const sub = subObj;
945
+ assertOk(sup);
946
+ assertOk(sub);
947
+ return Object.keys(sub).every((ele) => {
948
+ if (typeof sub[ele] == "object") {
949
+ return isSubset(sup[ele], sub[ele]);
950
+ }
951
+ return sub[ele] === sup[ele];
952
+ });
953
+ };
954
+ var assertFails = (message) => {
955
+ throw new AssertionError(message ?? "That should not ever happened, right?");
956
+ };
957
+ var assertThrowsAsync = async (fun, errorCheck) => {
958
+ try {
959
+ await fun();
960
+ throw new AssertionError("Function didn't throw expected error");
961
+ } catch (error2) {
962
+ const typedError = error2;
963
+ if (errorCheck) assertTrue(errorCheck(typedError));
964
+ return typedError;
965
+ }
966
+ };
967
+ var assertThrows = (fun, errorCheck) => {
968
+ try {
969
+ fun();
970
+ throw new AssertionError("Function didn't throw expected error");
971
+ } catch (error2) {
972
+ const typedError = error2;
973
+ if (errorCheck) assertTrue(errorCheck(typedError));
974
+ return typedError;
975
+ }
976
+ };
977
+ var assertRejects = async (promise, errorCheck) => {
978
+ try {
979
+ await promise;
980
+ throw new AssertionError("Function didn't throw expected error");
981
+ } catch (error2) {
982
+ if (!errorCheck) return;
983
+ if (errorCheck instanceof Error) assertDeepEqual(error2, errorCheck);
984
+ else assertTrue(errorCheck(error2));
985
+ }
986
+ };
987
+ var assertMatches = (actual, expected, message) => {
988
+ if (!isSubset(actual, expected))
989
+ throw new AssertionError(
990
+ message ?? `subObj:
991
+ ${JSONParser.stringify(expected)}
7
992
  is not subset of
8
- ${c.stringify(t)}`)},Ke=(t,e,r)=>{if(!d(t,e))throw new p(r??`subObj:
9
- ${c.stringify(e)}
993
+ ${JSONParser.stringify(actual)}`
994
+ );
995
+ };
996
+ var assertDeepEqual = (actual, expected, message) => {
997
+ if (!deepEquals(actual, expected))
998
+ throw new AssertionError(
999
+ message ?? `subObj:
1000
+ ${JSONParser.stringify(expected)}
10
1001
  is not equal to
11
- ${c.stringify(t)}`)},fo=(t,e,r)=>{if(d(t,e))throw new p(r??`subObj:
12
- ${c.stringify(e)}
1002
+ ${JSONParser.stringify(actual)}`
1003
+ );
1004
+ };
1005
+ var assertNotDeepEqual = (actual, expected, message) => {
1006
+ if (deepEquals(actual, expected))
1007
+ throw new AssertionError(
1008
+ message ?? `subObj:
1009
+ ${JSONParser.stringify(expected)}
13
1010
  is equals to
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};
1011
+ ${JSONParser.stringify(actual)}`
1012
+ );
1013
+ };
1014
+ var assertThat = (item) => {
1015
+ return {
1016
+ isEqualTo: (other) => assertTrue(deepEquals(item, other))
1017
+ };
1018
+ };
1019
+ function assertFalse(condition, message) {
1020
+ if (condition) throw new AssertionError(message ?? `Condition is false`);
1021
+ }
1022
+ function assertTrue(condition, message) {
1023
+ if (!condition) throw new AssertionError(message ?? `Condition is false`);
1024
+ }
1025
+ function assertOk(obj, message) {
1026
+ if (!obj) throw new AssertionError(message ?? `Condition is not truthy`);
1027
+ }
1028
+ function assertEqual(expected, actual, message) {
1029
+ if (expected !== actual)
1030
+ throw new AssertionError(
1031
+ `${message ?? "Objects are not equal"}:
1032
+ Expected: ${JSONParser.stringify(expected)}
1033
+ Actual:${JSONParser.stringify(actual)}`
1034
+ );
1035
+ }
1036
+ function assertNotEqual(obj, other, message) {
1037
+ if (obj === other)
1038
+ throw new AssertionError(
1039
+ message ?? `Objects are equal: ${JSONParser.stringify(obj)}`
1040
+ );
1041
+ }
1042
+ function assertIsNotNull(result) {
1043
+ assertNotEqual(result, null);
1044
+ assertOk(result);
1045
+ }
1046
+ function assertIsNull(result) {
1047
+ assertEqual(result, null);
1048
+ }
1049
+ var argValue = (value) => (arg) => deepEquals(arg, value);
1050
+ var argMatches = (matches) => (arg) => matches(arg);
1051
+ function verifyThat(fn) {
1052
+ return {
1053
+ calledTimes: (times) => {
1054
+ assertEqual(fn.mock?.calls?.length, times);
1055
+ },
1056
+ notCalled: () => {
1057
+ assertEqual(fn?.mock?.calls?.length, 0);
1058
+ },
1059
+ called: () => {
1060
+ assertTrue(
1061
+ fn.mock?.calls.length !== void 0 && fn.mock.calls.length > 0
1062
+ );
1063
+ },
1064
+ calledWith: (...args) => {
1065
+ assertTrue(
1066
+ fn.mock?.calls.length !== void 0 && fn.mock.calls.length >= 1 && fn.mock.calls.some((call) => deepEquals(call.arguments, args))
1067
+ );
1068
+ },
1069
+ calledOnceWith: (...args) => {
1070
+ assertTrue(
1071
+ fn.mock?.calls.length !== void 0 && fn.mock.calls.length === 1 && fn.mock.calls.some((call) => deepEquals(call.arguments, args))
1072
+ );
1073
+ },
1074
+ calledWithArgumentMatching: (...matches) => {
1075
+ assertTrue(
1076
+ fn.mock?.calls.length !== void 0 && fn.mock.calls.length >= 1
1077
+ );
1078
+ assertTrue(
1079
+ fn.mock?.calls.length !== void 0 && fn.mock.calls.length >= 1 && fn.mock.calls.some(
1080
+ (call) => call.arguments && call.arguments.length >= matches.length && matches.every((match, index) => match(call.arguments[index]))
1081
+ )
1082
+ );
1083
+ },
1084
+ notCalledWithArgumentMatching: (...matches) => {
1085
+ assertFalse(
1086
+ fn.mock?.calls.length !== void 0 && fn.mock.calls.length >= 1 && fn.mock.calls[0].arguments && fn.mock.calls[0].arguments.length >= matches.length && matches.every(
1087
+ (match, index) => match(fn.mock.calls[0].arguments[index])
1088
+ )
1089
+ );
1090
+ }
1091
+ };
1092
+ }
1093
+ var assertThatArray = (array) => {
1094
+ return {
1095
+ isEmpty: () => assertEqual(array.length, 0),
1096
+ isNotEmpty: () => assertNotEqual(array.length, 0),
1097
+ hasSize: (length) => assertEqual(array.length, length),
1098
+ containsElements: (...other) => {
1099
+ assertTrue(other.every((ts) => other.some((o) => deepEquals(ts, o))));
1100
+ },
1101
+ containsExactlyInAnyOrder: (...other) => {
1102
+ assertEqual(array.length, other.length);
1103
+ assertTrue(array.every((ts) => other.some((o) => deepEquals(ts, o))));
1104
+ },
1105
+ containsExactlyInAnyOrderElementsOf: (other) => {
1106
+ assertEqual(array.length, other.length);
1107
+ assertTrue(array.every((ts) => other.some((o) => deepEquals(ts, o))));
1108
+ },
1109
+ containsExactlyElementsOf: (other) => {
1110
+ assertEqual(array.length, other.length);
1111
+ for (let i = 0; i < array.length; i++) {
1112
+ assertTrue(deepEquals(array[i], other[i]));
1113
+ }
1114
+ },
1115
+ containsExactly: (elem) => {
1116
+ assertEqual(array.length, 1);
1117
+ assertTrue(deepEquals(array[0], elem));
1118
+ },
1119
+ contains: (elem) => {
1120
+ assertTrue(array.some((a) => deepEquals(a, elem)));
1121
+ },
1122
+ containsOnlyOnceElementsOf: (other) => {
1123
+ assertTrue(
1124
+ other.map((o) => array.filter((a) => deepEquals(a, o)).length).filter((a) => a === 1).length === other.length
1125
+ );
1126
+ },
1127
+ containsAnyOf: (...other) => {
1128
+ assertTrue(array.some((a) => other.some((o) => deepEquals(a, o))));
1129
+ },
1130
+ allMatch: (matches) => {
1131
+ assertTrue(array.every(matches));
1132
+ },
1133
+ anyMatches: (matches) => {
1134
+ assertTrue(array.some(matches));
1135
+ },
1136
+ allMatchAsync: async (matches) => {
1137
+ for (const item of array) {
1138
+ assertTrue(await matches(item));
1139
+ }
1140
+ }
1141
+ };
1142
+ };
1143
+
1144
+ // src/testing/deciderSpecification.ts
1145
+ var DeciderSpecification = {
1146
+ for: (decider) => {
1147
+ {
1148
+ return (givenEvents) => {
1149
+ return {
1150
+ when: (command2) => {
1151
+ const handle = () => {
1152
+ const existingEvents = Array.isArray(givenEvents) ? givenEvents : [givenEvents];
1153
+ const currentState = existingEvents.reduce(
1154
+ decider.evolve,
1155
+ decider.initialState()
1156
+ );
1157
+ return decider.decide(command2, currentState);
1158
+ };
1159
+ return {
1160
+ then: (expectedEvents) => {
1161
+ const resultEvents = handle();
1162
+ const resultEventsArray = Array.isArray(resultEvents) ? resultEvents : [resultEvents];
1163
+ const expectedEventsArray = Array.isArray(expectedEvents) ? expectedEvents : [expectedEvents];
1164
+ assertMatches(resultEventsArray, expectedEventsArray);
1165
+ },
1166
+ thenThrows: (...args) => {
1167
+ try {
1168
+ handle();
1169
+ throw new AssertionError("Handler did not fail as expected");
1170
+ } catch (error2) {
1171
+ if (error2 instanceof AssertionError) throw error2;
1172
+ if (args.length === 0) return;
1173
+ if (!isErrorConstructor(args[0])) {
1174
+ assertTrue(
1175
+ args[0](error2),
1176
+ `Error didn't match the error condition: ${error2?.toString()}`
1177
+ );
1178
+ return;
1179
+ }
1180
+ assertTrue(
1181
+ error2 instanceof args[0],
1182
+ `Caught error is not an instance of the expected type: ${error2?.toString()}`
1183
+ );
1184
+ if (args[1]) {
1185
+ assertTrue(
1186
+ args[1](error2),
1187
+ `Error didn't match the error condition: ${error2?.toString()}`
1188
+ );
1189
+ }
1190
+ }
1191
+ }
1192
+ };
1193
+ }
1194
+ };
1195
+ };
1196
+ }
1197
+ }
1198
+ };
1199
+
1200
+ // src/testing/wrapEventStore.ts
1201
+ var WrapEventStore = (eventStore) => {
1202
+ const appendedEvents = /* @__PURE__ */ new Map();
1203
+ return {
1204
+ async aggregateStream(streamName, options) {
1205
+ return eventStore.aggregateStream(streamName, options);
1206
+ },
1207
+ readStream(streamName, options) {
1208
+ return eventStore.readStream(streamName, options);
1209
+ },
1210
+ appendToStream: async (streamName, events, options) => {
1211
+ const result = await eventStore.appendToStream(
1212
+ streamName,
1213
+ events,
1214
+ options
1215
+ );
1216
+ const currentStream = appendedEvents.get(streamName) ?? [streamName, []];
1217
+ appendedEvents.set(streamName, [
1218
+ streamName,
1219
+ [...currentStream[1], ...events]
1220
+ ]);
1221
+ return result;
1222
+ },
1223
+ appendedEvents,
1224
+ setup: async (streamName, events) => {
1225
+ return eventStore.appendToStream(streamName, events);
1226
+ }
1227
+ // streamEvents: (): ReadableStream<
1228
+ // // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
1229
+ // ReadEvent<Event, ReadEventMetadataType> | GlobalSubscriptionEvent
1230
+ // > => {
1231
+ // return eventStore.streamEvents();
1232
+ // },
1233
+ };
1234
+ };
1235
+ export {
1236
+ AssertionError,
1237
+ BinaryJsonDecoder,
1238
+ CaughtUpTransformStream,
1239
+ CommandHandler,
1240
+ CommandHandlerStreamVersionConflictRetryOptions,
1241
+ CompositeDecoder,
1242
+ ConcurrencyError,
1243
+ DeciderCommandHandler,
1244
+ DeciderSpecification,
1245
+ DefaultDecoder,
1246
+ EmmettError,
1247
+ ExpectedVersionConflictError,
1248
+ GlobalStreamCaughtUpType,
1249
+ IllegalStateError,
1250
+ InMemoryEventStoreDefaultStreamVersion,
1251
+ JSONParser,
1252
+ JsonDecoder,
1253
+ NO_CONCURRENCY_CHECK,
1254
+ NoRetries,
1255
+ NotFoundError,
1256
+ ObjectDecoder,
1257
+ ParseError,
1258
+ STREAM_DOES_NOT_EXIST,
1259
+ STREAM_EXISTS,
1260
+ StreamingCoordinator,
1261
+ StringDecoder,
1262
+ ValidationError,
1263
+ ValidationErrors,
1264
+ WrapEventStore,
1265
+ accept,
1266
+ argMatches,
1267
+ argValue,
1268
+ assertDeepEqual,
1269
+ assertEqual,
1270
+ assertExpectedVersionMatchesCurrent,
1271
+ assertFails,
1272
+ assertFalse,
1273
+ assertIsNotNull,
1274
+ assertIsNull,
1275
+ assertMatches,
1276
+ assertNotDeepEqual,
1277
+ assertNotEmptyString,
1278
+ assertNotEqual,
1279
+ assertOk,
1280
+ assertPositiveNumber,
1281
+ assertRejects,
1282
+ assertThat,
1283
+ assertThatArray,
1284
+ assertThrows,
1285
+ assertThrowsAsync,
1286
+ assertTrue,
1287
+ assertUnsignedBigInt,
1288
+ asyncProjections,
1289
+ asyncRetry,
1290
+ canCreateEventStoreSession,
1291
+ caughtUpEventFrom,
1292
+ collect,
1293
+ command,
1294
+ complete,
1295
+ concatUint8Arrays,
1296
+ deepEquals,
1297
+ error,
1298
+ event,
1299
+ formatDateToUtcYYYYMMDD,
1300
+ getInMemoryEventStore,
1301
+ getInMemoryMessageBus,
1302
+ globalStreamCaughtUp,
1303
+ ignore,
1304
+ inlineProjections,
1305
+ isEquatable,
1306
+ isErrorConstructor,
1307
+ isExpectedVersionConflictError,
1308
+ isGlobalStreamCaughtUp,
1309
+ isNotInternalEvent,
1310
+ isNumber,
1311
+ isPluginConfig,
1312
+ isString,
1313
+ isSubscriptionEvent,
1314
+ isSubset,
1315
+ isValidYYYYMMDD,
1316
+ matchesExpectedVersion,
1317
+ merge,
1318
+ nulloSessionFactory,
1319
+ parseDateFromUtcYYYYMMDD,
1320
+ projection,
1321
+ projections,
1322
+ publish,
1323
+ reply,
1324
+ restream,
1325
+ schedule,
1326
+ send,
1327
+ streamGenerators,
1328
+ streamTrackingGlobalPosition,
1329
+ streamTransformations,
1330
+ sum,
1331
+ verifyThat
1332
+ };
17
1333
  //# sourceMappingURL=index.js.map