@leancodepl/rx-cqrs-client 9.7.4 → 10.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(_,P){typeof exports=="object"&&typeof module<"u"?P(exports):typeof define=="function"&&define.amd?define(["exports"],P):(_=typeof globalThis<"u"?globalThis:_||self,P(_["@leancodepl/rx-cqrs-client"]={}))})(this,(function(_){"use strict";var P=function(e,r){return P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])},P(e,r)};function q(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");P(e,r);function t(){this.constructor=e}e.prototype=r===null?Object.create(r):(t.prototype=r.prototype,new t)}var H=function(){return H=Object.assign||function(r){for(var t,n=1,i=arguments.length;n<i;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(r[o]=t[o])}return r},H.apply(this,arguments)};function Ne(e,r,t,n){function i(o){return o instanceof t?o:new t(function(u){u(o)})}return new(t||(t=Promise))(function(o,u){function a(f){try{s(n.next(f))}catch(d){u(d)}}function c(f){try{s(n.throw(f))}catch(d){u(d)}}function s(f){f.done?o(f.value):i(f.value).then(a,c)}s((n=n.apply(e,r||[])).next())})}function se(e,r){var t={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,u=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return u.next=a(0),u.throw=a(1),u.return=a(2),typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function a(s){return function(f){return c([s,f])}}function c(s){if(n)throw new TypeError("Generator is already executing.");for(;u&&(u=0,s[0]&&(t=0)),t;)try{if(n=1,i&&(o=s[0]&2?i.return:s[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,s[1])).done)return o;switch(i=0,o&&(s=[s[0]&2,o.value]),s[0]){case 0:case 1:o=s;break;case 4:return t.label++,{value:s[1],done:!1};case 5:t.label++,i=s[1],s=[0];continue;case 7:s=t.ops.pop(),t.trys.pop();continue;default:if(o=t.trys,!(o=o.length>0&&o[o.length-1])&&(s[0]===6||s[0]===2)){t=0;continue}if(s[0]===3&&(!o||s[1]>o[0]&&s[1]<o[3])){t.label=s[1];break}if(s[0]===6&&t.label<o[1]){t.label=o[1],o=s;break}if(o&&t.label<o[2]){t.label=o[2],t.ops.push(s);break}o[2]&&t.ops.pop(),t.trys.pop();continue}s=r.call(e,t)}catch(f){s=[6,f],i=0}finally{n=o=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function D(e){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&e[r],n=0;if(t)return t.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function V(e,r){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var n=t.call(e),i,o=[],u;try{for(;(r===void 0||r-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(a){u={error:a}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(u)throw u.error}}return o}function $(e,r,t){if(t||arguments.length===2)for(var n=0,i=r.length,o;n<i;n++)(o||!(n in r))&&(o||(o=Array.prototype.slice.call(r,0,n)),o[n]=r[n]);return e.concat(o||Array.prototype.slice.call(r))}function F(e){return this instanceof F?(this.v=e,this):new F(e)}function Ve(e,r,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=t.apply(e,r||[]),i,o=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",u),i[Symbol.asyncIterator]=function(){return this},i;function u(l){return function(S){return Promise.resolve(S).then(l,d)}}function a(l,S){n[l]&&(i[l]=function(h){return new Promise(function(U,I){o.push([l,h,U,I])>1||c(l,h)})},S&&(i[l]=S(i[l])))}function c(l,S){try{s(n[l](S))}catch(h){y(o[0][3],h)}}function s(l){l.value instanceof F?Promise.resolve(l.value.v).then(f,d):y(o[0][2],l)}function f(l){c("next",l)}function d(l){c("throw",l)}function y(l,S){l(S),o.shift(),o.length&&c(o[0][0],o[0][1])}}function $e(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=e[Symbol.asyncIterator],t;return r?r.call(e):(e=typeof D=="function"?D(e):e[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(o){t[o]=e[o]&&function(u){return new Promise(function(a,c){u=e[o](u),i(a,c,u.done,u.value)})}}function i(o,u,a,c){Promise.resolve(c).then(function(s){o({value:s,done:a})},u)}}typeof SuppressedError=="function"&&SuppressedError;function v(e){return typeof e=="function"}function X(e){var r=function(n){Error.call(n),n.stack=new Error().stack},t=e(r);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var Y=X(function(e){return function(t){e(this),this.message=t?t.length+` errors occurred during unsubscription:
2
- `+t.map(function(n,i){return i+1+") "+n.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=t}});function J(e,r){if(e){var t=e.indexOf(r);0<=t&&e.splice(t,1)}}var G=(function(){function e(r){this.initialTeardown=r,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var r,t,n,i,o;if(!this.closed){this.closed=!0;var u=this._parentage;if(u)if(this._parentage=null,Array.isArray(u))try{for(var a=D(u),c=a.next();!c.done;c=a.next()){var s=c.value;s.remove(this)}}catch(h){r={error:h}}finally{try{c&&!c.done&&(t=a.return)&&t.call(a)}finally{if(r)throw r.error}}else u.remove(this);var f=this.initialTeardown;if(v(f))try{f()}catch(h){o=h instanceof Y?h.errors:[h]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var y=D(d),l=y.next();!l.done;l=y.next()){var S=l.value;try{le(S)}catch(h){o=o??[],h instanceof Y?o=$($([],V(o)),V(h.errors)):o.push(h)}}}catch(h){n={error:h}}finally{try{l&&!l.done&&(i=y.return)&&i.call(y)}finally{if(n)throw n.error}}}if(o)throw new Y(o)}},e.prototype.add=function(r){var t;if(r&&r!==this)if(this.closed)le(r);else{if(r instanceof e){if(r.closed||r._hasParent(this))return;r._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(r)}},e.prototype._hasParent=function(r){var t=this._parentage;return t===r||Array.isArray(t)&&t.includes(r)},e.prototype._addParent=function(r){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(r),t):t?[t,r]:r},e.prototype._removeParent=function(r){var t=this._parentage;t===r?this._parentage=null:Array.isArray(t)&&J(t,r)},e.prototype.remove=function(r){var t=this._finalizers;t&&J(t,r),r instanceof e&&r._removeParent(this)},e.EMPTY=(function(){var r=new e;return r.closed=!0,r})(),e})(),ce=G.EMPTY;function fe(e){return e instanceof G||e&&"closed"in e&&v(e.remove)&&v(e.add)&&v(e.unsubscribe)}function le(e){v(e)?e():e.unsubscribe()}var Xe={Promise:void 0},Ye={setTimeout:function(e,r){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];return setTimeout.apply(void 0,$([e,r],V(t)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function de(e){Ye.setTimeout(function(){throw e})}function he(){}function z(e){e()}var Q=(function(e){q(r,e);function r(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,fe(t)&&t.add(n)):n.destination=Ke,n}return r.create=function(t,n,i){return new K(t,n,i)},r.prototype.next=function(t){this.isStopped||this._next(t)},r.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},r.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(t){this.destination.next(t)},r.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r})(G),Je=(function(){function e(r){this.partialObserver=r}return e.prototype.next=function(r){var t=this.partialObserver;if(t.next)try{t.next(r)}catch(n){N(n)}},e.prototype.error=function(r){var t=this.partialObserver;if(t.error)try{t.error(r)}catch(n){N(n)}else N(r)},e.prototype.complete=function(){var r=this.partialObserver;if(r.complete)try{r.complete()}catch(t){N(t)}},e})(),K=(function(e){q(r,e);function r(t,n,i){var o=e.call(this)||this,u;return v(t)||!t?u={next:t??void 0,error:n??void 0,complete:i??void 0}:u=t,o.destination=new Je(u),o}return r})(Q);function N(e){de(e)}function Qe(e){throw e}var Ke={closed:!0,next:he,error:Qe,complete:he},Z=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function Ze(e){return e}function et(e){return e.length===0?Ze:e.length===1?e[0]:function(t){return e.reduce(function(n,i){return i(n)},t)}}var x=(function(){function e(r){r&&(this._subscribe=r)}return e.prototype.lift=function(r){var t=new e;return t.source=this,t.operator=r,t},e.prototype.subscribe=function(r,t,n){var i=this,o=rt(r)?r:new K(r,t,n);return z(function(){var u=i,a=u.operator,c=u.source;o.add(a?a.call(o,c):c?i._subscribe(o):i._trySubscribe(o))}),o},e.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(t){r.error(t)}},e.prototype.forEach=function(r,t){var n=this;return t=pe(t),new t(function(i,o){var u=new K({next:function(a){try{r(a)}catch(c){o(c),u.unsubscribe()}},error:o,complete:i});n.subscribe(u)})},e.prototype._subscribe=function(r){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(r)},e.prototype[Z]=function(){return this},e.prototype.pipe=function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];return et(r)(this)},e.prototype.toPromise=function(r){var t=this;return r=pe(r),new r(function(n,i){var o;t.subscribe(function(u){return o=u},function(u){return i(u)},function(){return n(o)})})},e.create=function(r){return new e(r)},e})();function pe(e){var r;return(r=e??Xe.Promise)!==null&&r!==void 0?r:Promise}function tt(e){return e&&v(e.next)&&v(e.error)&&v(e.complete)}function rt(e){return e&&e instanceof Q||tt(e)&&fe(e)}function nt(e){return v(e?.lift)}function R(e){return function(r){if(nt(r))return r.lift(function(t){try{return e(t,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function A(e,r,t,n,i){return new ot(e,r,t,n,i)}var ot=(function(e){q(r,e);function r(t,n,i,o,u,a){var c=e.call(this,t)||this;return c.onFinalize=u,c.shouldUnsubscribe=a,c._next=n?function(s){try{n(s)}catch(f){t.error(f)}}:e.prototype._next,c._error=o?function(s){try{o(s)}catch(f){t.error(f)}finally{this.unsubscribe()}}:e.prototype._error,c._complete=i?function(){try{i()}catch(s){t.error(s)}finally{this.unsubscribe()}}:e.prototype._complete,c}return r.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},r})(Q),it=X(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ee=(function(e){q(r,e);function r(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return r.prototype.lift=function(t){var n=new ve(this,this);return n.operator=t,n},r.prototype._throwIfClosed=function(){if(this.closed)throw new it},r.prototype.next=function(t){var n=this;z(function(){var i,o;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var u=D(n.currentObservers),a=u.next();!a.done;a=u.next()){var c=a.value;c.next(t)}}catch(s){i={error:s}}finally{try{a&&!a.done&&(o=u.return)&&o.call(u)}finally{if(i)throw i.error}}}})},r.prototype.error=function(t){var n=this;z(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=t;for(var i=n.observers;i.length;)i.shift().error(t)}})},r.prototype.complete=function(){var t=this;z(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var n=t.observers;n.length;)n.shift().complete()}})},r.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(r.prototype,"observed",{get:function(){var t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),r.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},r.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},r.prototype._innerSubscribe=function(t){var n=this,i=this,o=i.hasError,u=i.isStopped,a=i.observers;return o||u?ce:(this.currentObservers=null,a.push(t),new G(function(){n.currentObservers=null,J(a,t)}))},r.prototype._checkFinalizedStatuses=function(t){var n=this,i=n.hasError,o=n.thrownError,u=n.isStopped;i?t.error(o):u&&t.complete()},r.prototype.asObservable=function(){var t=new x;return t.source=this,t},r.create=function(t,n){return new ve(t,n)},r})(x),ve=(function(e){q(r,e);function r(t,n){var i=e.call(this)||this;return i.destination=t,i.source=n,i}return r.prototype.next=function(t){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.next)===null||i===void 0||i.call(n,t)},r.prototype.error=function(t){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.error)===null||i===void 0||i.call(n,t)},r.prototype.complete=function(){var t,n;(n=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||n===void 0||n.call(t)},r.prototype._subscribe=function(t){var n,i;return(i=(n=this.source)===null||n===void 0?void 0:n.subscribe(t))!==null&&i!==void 0?i:ce},r})(ee),ye={now:function(){return(ye.delegate||Date).now()},delegate:void 0},ut=(function(e){q(r,e);function r(t,n,i){t===void 0&&(t=1/0),n===void 0&&(n=1/0),i===void 0&&(i=ye);var o=e.call(this)||this;return o._bufferSize=t,o._windowTime=n,o._timestampProvider=i,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=n===1/0,o._bufferSize=Math.max(1,t),o._windowTime=Math.max(1,n),o}return r.prototype.next=function(t){var n=this,i=n.isStopped,o=n._buffer,u=n._infiniteTimeWindow,a=n._timestampProvider,c=n._windowTime;i||(o.push(t),!u&&o.push(a.now()+c)),this._trimBuffer(),e.prototype.next.call(this,t)},r.prototype._subscribe=function(t){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(t),i=this,o=i._infiniteTimeWindow,u=i._buffer,a=u.slice(),c=0;c<a.length&&!t.closed;c+=o?1:2)t.next(a[c]);return this._checkFinalizedStatuses(t),n},r.prototype._trimBuffer=function(){var t=this,n=t._bufferSize,i=t._timestampProvider,o=t._buffer,u=t._infiniteTimeWindow,a=(u?1:2)*n;if(n<1/0&&a<o.length&&o.splice(0,o.length-a),!u){for(var c=i.now(),s=0,f=1;f<o.length&&o[f]<=c;f+=2)s=f;s&&o.splice(0,s+1)}},r})(ee);function at(e){return e&&v(e.schedule)}function st(e){return e[e.length-1]}function ct(e){return at(st(e))?e.pop():void 0}var me=(function(e){return e&&typeof e.length=="number"&&typeof e!="function"});function be(e){return v(e?.then)}function we(e){return v(e[Z])}function Se(e){return Symbol.asyncIterator&&v(e?.[Symbol.asyncIterator])}function xe(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function ft(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Te=ft();function ge(e){return v(e?.[Te])}function Ee(e){return Ve(this,arguments,function(){var t,n,i,o;return se(this,function(u){switch(u.label){case 0:t=e.getReader(),u.label=1;case 1:u.trys.push([1,,9,10]),u.label=2;case 2:return[4,F(t.read())];case 3:return n=u.sent(),i=n.value,o=n.done,o?[4,F(void 0)]:[3,5];case 4:return[2,u.sent()];case 5:return[4,F(i)];case 6:return[4,u.sent()];case 7:return u.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function _e(e){return v(e?.getReader)}function C(e){if(e instanceof x)return e;if(e!=null){if(we(e))return lt(e);if(me(e))return dt(e);if(be(e))return ht(e);if(Se(e))return Oe(e);if(ge(e))return pt(e);if(_e(e))return vt(e)}throw xe(e)}function lt(e){return new x(function(r){var t=e[Z]();if(v(t.subscribe))return t.subscribe(r);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function dt(e){return new x(function(r){for(var t=0;t<e.length&&!r.closed;t++)r.next(e[t]);r.complete()})}function ht(e){return new x(function(r){e.then(function(t){r.closed||(r.next(t),r.complete())},function(t){return r.error(t)}).then(null,de)})}function pt(e){return new x(function(r){var t,n;try{for(var i=D(e),o=i.next();!o.done;o=i.next()){var u=o.value;if(r.next(u),r.closed)return}}catch(a){t={error:a}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}r.complete()})}function Oe(e){return new x(function(r){yt(e,r).catch(function(t){return r.error(t)})})}function vt(e){return Oe(Ee(e))}function yt(e,r){var t,n,i,o;return Ne(this,void 0,void 0,function(){var u,a;return se(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),t=$e(e),c.label=1;case 1:return[4,t.next()];case 2:if(n=c.sent(),!!n.done)return[3,4];if(u=n.value,r.next(u),r.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),i={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),n&&!n.done&&(o=t.return)?[4,o.call(t)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return r.complete(),[2]}})})}function L(e,r,t,n,i){n===void 0&&(n=0),i===void 0&&(i=!1);var o=r.schedule(function(){t(),i?e.add(this.schedule(null,n)):this.unsubscribe()},n);if(e.add(o),!i)return o}function Ae(e,r){return r===void 0&&(r=0),R(function(t,n){t.subscribe(A(n,function(i){return L(n,e,function(){return n.next(i)},r)},function(){return L(n,e,function(){return n.complete()},r)},function(i){return L(n,e,function(){return n.error(i)},r)}))})}function je(e,r){return r===void 0&&(r=0),R(function(t,n){n.add(e.schedule(function(){return t.subscribe(n)},r))})}function mt(e,r){return C(e).pipe(je(r),Ae(r))}function bt(e,r){return C(e).pipe(je(r),Ae(r))}function wt(e,r){return new x(function(t){var n=0;return r.schedule(function(){n===e.length?t.complete():(t.next(e[n++]),t.closed||this.schedule())})})}function St(e,r){return new x(function(t){var n;return L(t,r,function(){n=e[Te](),L(t,r,function(){var i,o,u;try{i=n.next(),o=i.value,u=i.done}catch(a){t.error(a);return}u?t.complete():t.next(o)},0,!0)}),function(){return v(n?.return)&&n.return()}})}function Ie(e,r){if(!e)throw new Error("Iterable cannot be null");return new x(function(t){L(t,r,function(){var n=e[Symbol.asyncIterator]();L(t,r,function(){n.next().then(function(i){i.done?t.complete():t.next(i.value)})},0,!0)})})}function xt(e,r){return Ie(Ee(e),r)}function Tt(e,r){if(e!=null){if(we(e))return mt(e,r);if(me(e))return wt(e,r);if(be(e))return bt(e,r);if(Se(e))return Ie(e,r);if(ge(e))return St(e,r);if(_e(e))return xt(e,r)}throw xe(e)}function M(e,r){return r?Tt(e,r):C(e)}function te(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var t=ct(e);return M(e,t)}function Pe(e,r){var t=v(e)?e:function(){return e},n=function(i){return i.error(t())};return new x(n)}function E(e,r){return R(function(t,n){var i=0;t.subscribe(A(n,function(o){n.next(e.call(r,o,i++))}))})}function gt(e,r,t,n,i,o,u,a){var c=[],s=0,f=0,d=!1,y=function(){d&&!c.length&&!s&&r.complete()},l=function(h){return s<n?S(h):c.push(h)},S=function(h){s++;var U=!1;C(t(h,f++)).subscribe(A(r,function(I){r.next(I)},function(){U=!0},void 0,function(){if(U)try{s--;for(var I=function(){var k=c.shift();u||S(k)};c.length&&s<n;)I();y()}catch(k){r.error(k)}}))};return e.subscribe(A(r,l,function(){d=!0,y()})),function(){}}function j(e,r,t){return t===void 0&&(t=1/0),v(r)?j(function(n,i){return E(function(o,u){return r(n,o,i,u)})(C(e(n,i)))},t):(typeof r=="number"&&(t=r),R(function(n,i){return gt(n,i,e,t)}))}function Re(e){return R(function(r,t){var n=null,i=!1,o;n=r.subscribe(A(t,void 0,void 0,function(u){o=C(e(u,Re(e)(r))),n?(n.unsubscribe(),n=null,o.subscribe(t)):i=!0})),i&&(n.unsubscribe(),n=null,o.subscribe(t))})}function Et(e,r,t,n,i){return function(o,u){var a=t,c=r,s=0;o.subscribe(A(u,function(f){var d=s++;c=a?e(c,f,d):(a=!0,f)},(function(){a&&u.next(c),u.complete()})))}}function Ce(e,r){return R(Et(e,r,arguments.length>=2,!1,!0))}function _t(e,r){return v(r)?j(e,r,1):j(e,1)}function Ot(e){return R(function(r,t){var n,i=!1,o,u=function(){n=r.subscribe(A(t,void 0,void 0,function(a){o||(o=new ee,C(e(o)).subscribe(A(t,function(){return n?u():i=!0}))),o&&o.next(a)})),i&&(n.unsubscribe(),n=null,i=!1,u())};u()})}function At(e){return r=>r.pipe(_t(t=>{const n=new ut;return e(t)({reducer:(i,o)=>n.next(o),initialValue:null}),n.complete(),n}))}function Le(e){switch(e.responseType){case"json":{if("response"in e)return e.response;var r=e;return JSON.parse(r.responseText)}case"document":return e.responseXML;default:{if("response"in e)return e.response;var r=e;return r.responseText}}}var jt=(function(){function e(r,t,n,i){i===void 0&&(i="download_load"),this.originalEvent=r,this.xhr=t,this.request=n,this.type=i;var o=t.status,u=t.responseType;this.status=o??0,this.responseType=u??"";var a=t.getAllResponseHeaders();this.responseHeaders=a?a.split(`
4
- `).reduce(function(f,d){var y=d.indexOf(": ");return f[d.slice(0,y)]=d.slice(y+2),f},{}):{},this.response=Le(t);var c=r.loaded,s=r.total;this.loaded=c,this.total=s}return e})(),W=X(function(e){return function(t,n,i){this.message=t,this.name="AjaxError",this.xhr=n,this.request=i,this.status=n.status,this.responseType=n.responseType;var o;try{o=Le(n)}catch{o=n.responseText}this.response=o}}),It=(function(){function e(r,t){return W.call(this,"ajax timeout",r,t),this.name="AjaxTimeoutError",this}return e.prototype=Object.create(W.prototype),e})();function Pt(e,r){return O({method:"GET",url:e,headers:r})}function Rt(e,r,t){return O({method:"POST",url:e,body:r,headers:t})}function Ct(e,r){return O({method:"DELETE",url:e,headers:r})}function Lt(e,r,t){return O({method:"PUT",url:e,body:r,headers:t})}function Ut(e,r,t){return O({method:"PATCH",url:e,body:r,headers:t})}var kt=E(function(e){return e.response});function Bt(e,r){return kt(O({method:"GET",url:e,headers:r}))}var O=(function(){var e=function(r){var t=typeof r=="string"?{url:r}:r;return Dt(t)};return e.get=Pt,e.post=Rt,e.delete=Ct,e.put=Lt,e.patch=Ut,e.getJSON=Bt,e})(),qt="upload",Ue="download",re="loadstart",ne="progress",ke="load";function Dt(e){return new x(function(r){var t,n,i=H({async:!0,crossDomain:!1,withCredentials:!1,method:"GET",timeout:0,responseType:"json"},e),o=i.queryParams,u=i.body,a=i.headers,c=i.url;if(!c)throw new TypeError("url is required");if(o){var s;if(c.includes("?")){var f=c.split("?");if(2<f.length)throw new TypeError("invalid url");s=new URLSearchParams(f[1]),new URLSearchParams(o).forEach(function(b,w){return s.set(w,b)}),c=f[0]+"?"+s}else s=new URLSearchParams(o),c=c+"?"+s}var d={};if(a)for(var y in a)a.hasOwnProperty(y)&&(d[y.toLowerCase()]=a[y]);var l=i.crossDomain;!l&&!("x-requested-with"in d)&&(d["x-requested-with"]="XMLHttpRequest");var S=i.withCredentials,h=i.xsrfCookieName,U=i.xsrfHeaderName;if((S||!l)&&h&&U){var I=(n=(t=document?.cookie.match(new RegExp("(^|;\\s*)("+h+")=([^;]*)")))===null||t===void 0?void 0:t.pop())!==null&&n!==void 0?n:"";I&&(d[U]=I)}var k=Ft(u,d),g=H(H({},i),{url:c,headers:d,body:k}),p;p=e.createXHR?e.createXHR():new XMLHttpRequest;{var m=e.progressSubscriber,Be=e.includeDownloadProgress,Kt=Be===void 0?!1:Be,qe=e.includeUploadProgress,Zt=qe===void 0?!1:qe,De=function(b,w){p.addEventListener(b,function(){var T,B=w();(T=m?.error)===null||T===void 0||T.call(m,B),r.error(B)})};De("timeout",function(){return new It(p,g)}),De("abort",function(){return new W("aborted",p,g)});var Fe=function(b,w){return new jt(w,p,g,b+"_"+w.type)},He=function(b,w,T){b.addEventListener(w,function(B){r.next(Fe(T,B))})};Zt&&[re,ne,ke].forEach(function(b){return He(p.upload,b,qt)}),m&&[re,ne].forEach(function(b){return p.upload.addEventListener(b,function(w){var T;return(T=m?.next)===null||T===void 0?void 0:T.call(m,w)})}),Kt&&[re,ne].forEach(function(b){return He(p,b,Ue)});var Me=function(b){var w="ajax error"+(b?" "+b:"");r.error(new W(w,p,g))};p.addEventListener("error",function(b){var w;(w=m?.error)===null||w===void 0||w.call(m,b),Me()}),p.addEventListener(ke,function(b){var w,T,B=p.status;if(B<400){(w=m?.complete)===null||w===void 0||w.call(m);var ze=void 0;try{ze=Fe(Ue,b)}catch(er){r.error(er);return}r.next(ze),r.complete()}else(T=m?.error)===null||T===void 0||T.call(m,b),Me(B)})}var We=g.user,Ge=g.method,ae=g.async;We?p.open(Ge,c,ae,We,g.password):p.open(Ge,c,ae),ae&&(p.timeout=g.timeout,p.responseType=g.responseType),"withCredentials"in p&&(p.withCredentials=g.withCredentials);for(var y in d)d.hasOwnProperty(y)&&p.setRequestHeader(y,d[y]);return k?p.send(k):p.send(),function(){p&&p.readyState!==4&&p.abort()}})}function Ft(e,r){var t;if(!e||typeof e=="string"||Nt(e)||Vt(e)||Mt(e)||Wt(e)||Gt(e)||$t(e))return e;if(zt(e))return e.buffer;if(typeof e=="object")return r["content-type"]=(t=r["content-type"])!==null&&t!==void 0?t:"application/json;charset=utf-8",JSON.stringify(e);throw new TypeError("Unknown body type")}var Ht=Object.prototype.toString;function oe(e,r){return Ht.call(e)==="[object "+r+"]"}function Mt(e){return oe(e,"ArrayBuffer")}function Wt(e){return oe(e,"File")}function Gt(e){return oe(e,"Blob")}function zt(e){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView(e)}function Nt(e){return typeof FormData<"u"&&e instanceof FormData}function Vt(e){return typeof URLSearchParams<"u"&&e instanceof URLSearchParams}function $t(e){return typeof ReadableStream<"u"&&e instanceof ReadableStream}function ie(e,r,t=[]){return{handle:(n,i)=>{let o;for(const a of Array.isArray(n)?n:[n]){const c=e.find(s=>s.ErrorCode===r[a]);if(c){o=i(a,c);break}}let u=t;return o!==void 0&&(u=[...u,o]),ie(e,r,u)},handleAll:(n,i)=>{let o;const u=(Array.isArray(n)?n:[n]).reduce((c,s)=>{const f=e.filter(d=>d.ErrorCode===r[s]);return f.length===0?c:[...c,{errorName:s,errors:f}]},[]);u.length>0&&(o=i(u));let a=t;return o!==void 0&&(a=[...a,o]),ie(e,r,a)},check:(n=>{if(n)return t.reduce(n.reducer,n.initialValue)})}}function Xt(e,r){const t={...r,success:-1,failure:-2},n=e.isSuccess?e.result.WasSuccessful?[{ErrorMessage:"",PropertyName:"",ErrorCode:-1}]:e.result.ValidationErrors:[{ErrorMessage:"",PropertyName:"",ErrorCode:-2}];return ie(n,t)}function ue(e){return r=>r.pipe(Ot(t=>t.pipe(j((n,i)=>i===0&&n.status===401?M(e.invalidateToken()).pipe(j(o=>o?te(o):Pe(()=>n))):Pe(()=>n)))))}function Yt({cqrsEndpoint:e,tokenProvider:r,ajaxOptions:t,tokenHeader:n="Authorization"}){return{createQuery(i){const o=(u,a)=>O({...t,headers:{[n]:a,"Content-Type":"application/json"},url:`${e}/query/${i}`,method:"POST",responseType:"json",body:u});return r?u=>M(r.getToken()).pipe(j(a=>o(u,a).pipe(ue(r))),E(({response:a})=>a)):u=>o(u).pipe(E(({response:a})=>a))},createOperation(i){const o=(u,a)=>O({...t,headers:{Authorization:a,"Content-Type":"application/json"},url:`${e}/operation/${i}`,method:"POST",responseType:"json",body:u});return r?u=>M(r.getToken()).pipe(j(a=>o(u,a).pipe(ue(r))),E(({response:a})=>a)):u=>o(u).pipe(E(({response:a})=>a))},createCommand(i,o){const u=(c,s)=>O({...t,headers:{Authorization:s,"Content-Type":"application/json"},url:`${e}/command/${i}`,method:"POST",responseType:"json",body:c});function a(c){return r?M(r.getToken()).pipe(j(s=>u(c,s).pipe(ue(r))),E(({response:s})=>s)):u(c).pipe(E(({response:s})=>s))}return a.handle=c=>a(c).pipe(E(s=>({isSuccess:!0,result:s})),Re(s=>s instanceof W&&s.status===422?te({isSuccess:!0,result:s.response}):te({isSuccess:!1,error:s})),E(s=>Xt(s,o))),a}}}function Jt(){return e=>e.pipe(Ce((r,t)=>r&&t,!0))}function Qt(){return e=>e.pipe(Ce((r,t)=>({...r,...t}),{}))}_.handleCommandResponse=At,_.mkCqrsClient=Yt,_.reduceBoolean=Jt,_.reduceObject=Qt,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(O,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("rxjs"),require("@leancodepl/validation")):typeof define=="function"&&define.amd?define(["exports","rxjs","@leancodepl/validation"],S):(O=typeof globalThis<"u"?globalThis:O||self,S(O["@leancodepl/rx-cqrs-client"]={},O.rxjs,O.validation))})(this,(function(O,S,Ae){"use strict";function w(e){return typeof e=="function"}function je(e){return w(e?.lift)}function M(e){return function(t){if(je(t))return t.lift(function(r){try{return e(r,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}var X=function(e,t){return X=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[i]=n[i])},X(e,t)};function k(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");X(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}var q=function(){return q=Object.assign||function(t){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t},q.apply(this,arguments)};function Ie(e,t,r,n){function i(o){return o instanceof r?o:new r(function(u){u(o)})}return new(r||(r=Promise))(function(o,u){function s(l){try{a(n.next(l))}catch(d){u(d)}}function c(l){try{a(n.throw(l))}catch(d){u(d)}}function a(l){l.done?o(l.value):i(l.value).then(s,c)}a((n=n.apply(e,t||[])).next())})}function oe(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,u=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return u.next=s(0),u.throw=s(1),u.return=s(2),typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function s(a){return function(l){return c([a,l])}}function c(a){if(n)throw new TypeError("Generator is already executing.");for(;u&&(u=0,a[0]&&(r=0)),r;)try{if(n=1,i&&(o=a[0]&2?i.return:a[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;switch(i=0,o&&(a=[a[0]&2,o.value]),a[0]){case 0:case 1:o=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){r.label=a[1];break}if(a[0]===6&&r.label<o[1]){r.label=o[1],o=a;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(a);break}o[2]&&r.ops.pop(),r.trys.pop();continue}a=t.call(e,r)}catch(l){a=[6,l],i=0}finally{n=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function L(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function $(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],u;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(s){u={error:s}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(u)throw u.error}}return o}function z(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,o;n<i;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))}function U(e){return this instanceof U?(this.v=e,this):new U(e)}function Re(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),i,o=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),s("next"),s("throw"),s("return",u),i[Symbol.asyncIterator]=function(){return this},i;function u(f){return function(T){return Promise.resolve(T).then(f,d)}}function s(f,T){n[f]&&(i[f]=function(p){return new Promise(function(P,R){o.push([f,p,P,R])>1||c(f,p)})},T&&(i[f]=T(i[f])))}function c(f,T){try{a(n[f](T))}catch(p){v(o[0][3],p)}}function a(f){f.value instanceof U?Promise.resolve(f.value.v).then(l,d):v(o[0][2],f)}function l(f){c("next",f)}function d(f){c("throw",f)}function v(f,T){f(T),o.shift(),o.length&&c(o[0][0],o[0][1])}}function Pe(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof L=="function"?L(e):e[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(o){r[o]=e[o]&&function(u){return new Promise(function(s,c){u=e[o](u),i(s,c,u.done,u.value)})}}function i(o,u,s,c){Promise.resolve(c).then(function(a){o({value:a,done:s})},u)}}typeof SuppressedError=="function"&&SuppressedError;var _e=(function(e){return e&&typeof e.length=="number"&&typeof e!="function"});function Ce(e){return w(e?.then)}function V(e){var t=function(n){Error.call(n),n.stack=new Error().stack},r=e(t);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var Y=V(function(e){return function(r){e(this),this.message=r?r.length+` errors occurred during unsubscription:
2
+ `+r.map(function(n,i){return i+1+") "+n.toString()}).join(`
3
+ `):"",this.name="UnsubscriptionError",this.errors=r}});function J(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var B=(function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,r,n,i,o;if(!this.closed){this.closed=!0;var u=this._parentage;if(u)if(this._parentage=null,Array.isArray(u))try{for(var s=L(u),c=s.next();!c.done;c=s.next()){var a=c.value;a.remove(this)}}catch(p){t={error:p}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}else u.remove(this);var l=this.initialTeardown;if(w(l))try{l()}catch(p){o=p instanceof Y?p.errors:[p]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var v=L(d),f=v.next();!f.done;f=v.next()){var T=f.value;try{ae(T)}catch(p){o=o??[],p instanceof Y?o=z(z([],$(o)),$(p.errors)):o.push(p)}}}catch(p){n={error:p}}finally{try{f&&!f.done&&(i=v.return)&&i.call(v)}finally{if(n)throw n.error}}}if(o)throw new Y(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)ae(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(t)}},e.prototype._hasParent=function(t){var r=this._parentage;return r===t||Array.isArray(r)&&r.includes(t)},e.prototype._addParent=function(t){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(t),r):r?[r,t]:t},e.prototype._removeParent=function(t){var r=this._parentage;r===t?this._parentage=null:Array.isArray(r)&&J(r,t)},e.prototype.remove=function(t){var r=this._finalizers;r&&J(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})(),ie=B.EMPTY;function ue(e){return e instanceof B||e&&"closed"in e&&w(e.remove)&&w(e.add)&&w(e.unsubscribe)}function ae(e){w(e)?e():e.unsubscribe()}var Le={Promise:void 0},Ue={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,z([e,t],$(r)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function se(e){Ue.setTimeout(function(){throw e})}function ce(){}function D(e){e()}var N=(function(e){k(t,e);function t(r){var n=e.call(this)||this;return n.isStopped=!1,r?(n.destination=r,ue(r)&&r.add(n)):n.destination=Fe,n}return t.create=function(r,n,i){return new W(r,n,i)},t.prototype.next=function(r){this.isStopped||this._next(r)},t.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(r){this.destination.next(r)},t.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(B),ke=(function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var r=this.partialObserver;if(r.next)try{r.next(t)}catch(n){G(n)}},e.prototype.error=function(t){var r=this.partialObserver;if(r.error)try{r.error(t)}catch(n){G(n)}else G(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(r){G(r)}},e})(),W=(function(e){k(t,e);function t(r,n,i){var o=e.call(this)||this,u;return w(r)||!r?u={next:r??void 0,error:n??void 0,complete:i??void 0}:u=r,o.destination=new ke(u),o}return t})(N);function G(e){se(e)}function qe(e){throw e}var Fe={closed:!0,next:ce,error:qe,complete:ce},Q=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function He(e){return e}function Be(e){return e.length===0?He:e.length===1?e[0]:function(r){return e.reduce(function(n,i){return i(n)},r)}}var A=(function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(t,r,n){var i=this,o=Ge(t)?t:new W(t,r,n);return D(function(){var u=i,s=u.operator,c=u.source;o.add(s?s.call(o,c):c?i._subscribe(o):i._trySubscribe(o))}),o},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(r){t.error(r)}},e.prototype.forEach=function(t,r){var n=this;return r=fe(r),new r(function(i,o){var u=new W({next:function(s){try{t(s)}catch(c){o(c),u.unsubscribe()}},error:o,complete:i});n.subscribe(u)})},e.prototype._subscribe=function(t){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(t)},e.prototype[Q]=function(){return this},e.prototype.pipe=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return Be(t)(this)},e.prototype.toPromise=function(t){var r=this;return t=fe(t),new t(function(n,i){var o;r.subscribe(function(u){return o=u},function(u){return i(u)},function(){return n(o)})})},e.create=function(t){return new e(t)},e})();function fe(e){var t;return(t=e??Le.Promise)!==null&&t!==void 0?t:Promise}function De(e){return e&&w(e.next)&&w(e.error)&&w(e.complete)}function Ge(e){return e&&e instanceof N||De(e)&&ue(e)}function Me(e){return w(e[Q])}function Xe(e){return Symbol.asyncIterator&&w(e?.[Symbol.asyncIterator])}function $e(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function ze(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Ve=ze();function Ye(e){return w(e?.[Ve])}function Je(e){return Re(this,arguments,function(){var r,n,i,o;return oe(this,function(u){switch(u.label){case 0:r=e.getReader(),u.label=1;case 1:u.trys.push([1,,9,10]),u.label=2;case 2:return[4,U(r.read())];case 3:return n=u.sent(),i=n.value,o=n.done,o?[4,U(void 0)]:[3,5];case 4:return[2,u.sent()];case 5:return[4,U(i)];case 6:return[4,u.sent()];case 7:return u.sent(),[3,2];case 8:return[3,10];case 9:return r.releaseLock(),[7];case 10:return[2]}})})}function Ne(e){return w(e?.getReader)}function K(e){if(e instanceof A)return e;if(e!=null){if(Me(e))return We(e);if(_e(e))return Qe(e);if(Ce(e))return Ke(e);if(Xe(e))return le(e);if(Ye(e))return Ze(e);if(Ne(e))return er(e)}throw $e(e)}function We(e){return new A(function(t){var r=e[Q]();if(w(r.subscribe))return r.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Qe(e){return new A(function(t){for(var r=0;r<e.length&&!t.closed;r++)t.next(e[r]);t.complete()})}function Ke(e){return new A(function(t){e.then(function(r){t.closed||(t.next(r),t.complete())},function(r){return t.error(r)}).then(null,se)})}function Ze(e){return new A(function(t){var r,n;try{for(var i=L(e),o=i.next();!o.done;o=i.next()){var u=o.value;if(t.next(u),t.closed)return}}catch(s){r={error:s}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}t.complete()})}function le(e){return new A(function(t){rr(e,t).catch(function(r){return t.error(r)})})}function er(e){return le(Je(e))}function rr(e,t){var r,n,i,o;return Ie(this,void 0,void 0,function(){var u,s;return oe(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),r=Pe(e),c.label=1;case 1:return[4,r.next()];case 2:if(n=c.sent(),!!n.done)return[3,4];if(u=n.value,t.next(u),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return s=c.sent(),i={error:s},[3,11];case 6:return c.trys.push([6,,9,10]),n&&!n.done&&(o=r.return)?[4,o.call(r)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function F(e,t,r,n,i){return new tr(e,t,r,n,i)}var tr=(function(e){k(t,e);function t(r,n,i,o,u,s){var c=e.call(this,r)||this;return c.onFinalize=u,c.shouldUnsubscribe=s,c._next=n?function(a){try{n(a)}catch(l){r.error(l)}}:e.prototype._next,c._error=o?function(a){try{o(a)}catch(l){r.error(l)}finally{this.unsubscribe()}}:e.prototype._error,c._complete=i?function(){try{i()}catch(a){r.error(a)}finally{this.unsubscribe()}}:e.prototype._complete,c}return t.prototype.unsubscribe=function(){var r;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&((r=this.onFinalize)===null||r===void 0||r.call(this))}},t})(N);function Ur(e,t,r,n,i){n===void 0&&(n=0),i===void 0&&(i=!1);var o=t.schedule(function(){r(),i?e.add(this.schedule(null,n)):this.unsubscribe()},n);if(e.add(o),!i)return o}function g(e,t){return M(function(r,n){var i=0;r.subscribe(F(n,function(o){n.next(e.call(t,o,i++))}))})}function nr(e,t,r,n,i,o,u,s){var c=[],a=0,l=0,d=!1,v=function(){d&&!c.length&&!a&&t.complete()},f=function(p){return a<n?T(p):c.push(p)},T=function(p){a++;var P=!1;K(r(p,l++)).subscribe(F(t,function(R){t.next(R)},function(){P=!0},void 0,function(){if(P)try{a--;for(var R=function(){var _=c.shift();u||T(_)};c.length&&a<n;)R();v()}catch(_){t.error(_)}}))};return e.subscribe(F(t,f,function(){d=!0,v()})),function(){}}function I(e,t,r){return r===void 0&&(r=1/0),w(t)?I(function(n,i){return g(function(o,u){return t(n,o,i,u)})(K(e(n,i)))},r):(typeof t=="number"&&(r=t),M(function(n,i){return nr(n,i,e,r)}))}function or(e,t){return w(t)?I(e,t,1):I(e,1)}var ir=V(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),de=(function(e){k(t,e);function t(){var r=e.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return t.prototype.lift=function(r){var n=new pe(this,this);return n.operator=r,n},t.prototype._throwIfClosed=function(){if(this.closed)throw new ir},t.prototype.next=function(r){var n=this;D(function(){var i,o;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var u=L(n.currentObservers),s=u.next();!s.done;s=u.next()){var c=s.value;c.next(r)}}catch(a){i={error:a}}finally{try{s&&!s.done&&(o=u.return)&&o.call(u)}finally{if(i)throw i.error}}}})},t.prototype.error=function(r){var n=this;D(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=r;for(var i=n.observers;i.length;)i.shift().error(r)}})},t.prototype.complete=function(){var r=this;D(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var n=r.observers;n.length;)n.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(r){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,r)},t.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},t.prototype._innerSubscribe=function(r){var n=this,i=this,o=i.hasError,u=i.isStopped,s=i.observers;return o||u?ie:(this.currentObservers=null,s.push(r),new B(function(){n.currentObservers=null,J(s,r)}))},t.prototype._checkFinalizedStatuses=function(r){var n=this,i=n.hasError,o=n.thrownError,u=n.isStopped;i?r.error(o):u&&r.complete()},t.prototype.asObservable=function(){var r=new A;return r.source=this,r},t.create=function(r,n){return new pe(r,n)},t})(A),pe=(function(e){k(t,e);function t(r,n){var i=e.call(this)||this;return i.destination=r,i.source=n,i}return t.prototype.next=function(r){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.next)===null||i===void 0||i.call(n,r)},t.prototype.error=function(r){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.error)===null||i===void 0||i.call(n,r)},t.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},t.prototype._subscribe=function(r){var n,i;return(i=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&i!==void 0?i:ie},t})(de);function ur(e){return M(function(t,r){var n,i=!1,o,u=function(){n=t.subscribe(F(r,void 0,void 0,function(s){o||(o=new de,K(e(o)).subscribe(F(r,function(){return n?u():i=!0}))),o&&o.next(s)})),i&&(n.unsubscribe(),n=null,i=!1,u())};u()})}function ar(e){return t=>t.pipe(or(r=>{const n=new S.ReplaySubject;return e(r)({reducer:(i,o)=>n.next(o),initialValue:null}),n.complete(),n}))}function he(e){switch(e.responseType){case"json":{if("response"in e)return e.response;var t=e;return JSON.parse(t.responseText)}case"document":return e.responseXML;default:{if("response"in e)return e.response;var t=e;return t.responseText}}}var sr=(function(){function e(t,r,n,i){i===void 0&&(i="download_load"),this.originalEvent=t,this.xhr=r,this.request=n,this.type=i;var o=r.status,u=r.responseType;this.status=o??0,this.responseType=u??"";var s=r.getAllResponseHeaders();this.responseHeaders=s?s.split(`
4
+ `).reduce(function(l,d){var v=d.indexOf(": ");return l[d.slice(0,v)]=d.slice(v+2),l},{}):{},this.response=he(r);var c=t.loaded,a=t.total;this.loaded=c,this.total=a}return e})(),H=V(function(e){return function(r,n,i){this.message=r,this.name="AjaxError",this.xhr=n,this.request=i,this.status=n.status,this.responseType=n.responseType;var o;try{o=he(n)}catch{o=n.responseText}this.response=o}}),cr=(function(){function e(t,r){return H.call(this,"ajax timeout",t,r),this.name="AjaxTimeoutError",this}return e.prototype=Object.create(H.prototype),e})();function fr(e,t){return j({method:"GET",url:e,headers:t})}function lr(e,t,r){return j({method:"POST",url:e,body:t,headers:r})}function dr(e,t){return j({method:"DELETE",url:e,headers:t})}function pr(e,t,r){return j({method:"PUT",url:e,body:t,headers:r})}function hr(e,t,r){return j({method:"PATCH",url:e,body:t,headers:r})}var vr=g(function(e){return e.response});function yr(e,t){return vr(j({method:"GET",url:e,headers:t}))}var j=(function(){var e=function(t){var r=typeof t=="string"?{url:t}:t;return br(r)};return e.get=fr,e.post=lr,e.delete=dr,e.put=pr,e.patch=hr,e.getJSON=yr,e})(),mr="upload",ve="download",Z="loadstart",ee="progress",ye="load";function br(e){return new A(function(t){var r,n,i=q({async:!0,crossDomain:!1,withCredentials:!1,method:"GET",timeout:0,responseType:"json"},e),o=i.queryParams,u=i.body,s=i.headers,c=i.url;if(!c)throw new TypeError("url is required");if(o){var a;if(c.includes("?")){var l=c.split("?");if(2<l.length)throw new TypeError("invalid url");a=new URLSearchParams(l[1]),new URLSearchParams(o).forEach(function(m,b){return a.set(b,m)}),c=l[0]+"?"+a}else a=new URLSearchParams(o),c=c+"?"+a}var d={};if(s)for(var v in s)s.hasOwnProperty(v)&&(d[v.toLowerCase()]=s[v]);var f=i.crossDomain;!f&&!("x-requested-with"in d)&&(d["x-requested-with"]="XMLHttpRequest");var T=i.withCredentials,p=i.xsrfCookieName,P=i.xsrfHeaderName;if((T||!f)&&p&&P){var R=(n=(r=document?.cookie.match(new RegExp("(^|;\\s*)("+p+")=([^;]*)")))===null||r===void 0?void 0:r.pop())!==null&&n!==void 0?n:"";R&&(d[P]=R)}var _=wr(u,d),x=q(q({},i),{url:c,headers:d,body:_}),h;h=e.createXHR?e.createXHR():new XMLHttpRequest;{var y=e.progressSubscriber,me=e.includeDownloadProgress,_r=me===void 0?!1:me,be=e.includeUploadProgress,Cr=be===void 0?!1:be,we=function(m,b){h.addEventListener(m,function(){var E,C=b();(E=y?.error)===null||E===void 0||E.call(y,C),t.error(C)})};we("timeout",function(){return new cr(h,x)}),we("abort",function(){return new H("aborted",h,x)});var Se=function(m,b){return new sr(b,h,x,m+"_"+b.type)},Te=function(m,b,E){m.addEventListener(b,function(C){t.next(Se(E,C))})};Cr&&[Z,ee,ye].forEach(function(m){return Te(h.upload,m,mr)}),y&&[Z,ee].forEach(function(m){return h.upload.addEventListener(m,function(b){var E;return(E=y?.next)===null||E===void 0?void 0:E.call(y,b)})}),_r&&[Z,ee].forEach(function(m){return Te(h,m,ve)});var Ee=function(m){var b="ajax error"+(m?" "+m:"");t.error(new H(b,h,x))};h.addEventListener("error",function(m){var b;(b=y?.error)===null||b===void 0||b.call(y,m),Ee()}),h.addEventListener(ye,function(m){var b,E,C=h.status;if(C<400){(b=y?.complete)===null||b===void 0||b.call(y);var ge=void 0;try{ge=Se(ve,m)}catch(Lr){t.error(Lr);return}t.next(ge),t.complete()}else(E=y?.error)===null||E===void 0||E.call(y,m),Ee(C)})}var Oe=x.user,xe=x.method,ne=x.async;Oe?h.open(xe,c,ne,Oe,x.password):h.open(xe,c,ne),ne&&(h.timeout=x.timeout,h.responseType=x.responseType),"withCredentials"in h&&(h.withCredentials=x.withCredentials);for(var v in d)d.hasOwnProperty(v)&&h.setRequestHeader(v,d[v]);return _?h.send(_):h.send(),function(){h&&h.readyState!==4&&h.abort()}})}function wr(e,t){var r;if(!e||typeof e=="string"||gr(e)||Ar(e)||Tr(e)||Er(e)||Or(e)||jr(e))return e;if(xr(e))return e.buffer;if(typeof e=="object")return t["content-type"]=(r=t["content-type"])!==null&&r!==void 0?r:"application/json;charset=utf-8",JSON.stringify(e);throw new TypeError("Unknown body type")}var Sr=Object.prototype.toString;function re(e,t){return Sr.call(e)==="[object "+t+"]"}function Tr(e){return re(e,"ArrayBuffer")}function Er(e){return re(e,"File")}function Or(e){return re(e,"Blob")}function xr(e){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView(e)}function gr(e){return typeof FormData<"u"&&e instanceof FormData}function Ar(e){return typeof URLSearchParams<"u"&&e instanceof URLSearchParams}function jr(e){return typeof ReadableStream<"u"&&e instanceof ReadableStream}function te(e){return t=>t.pipe(ur(r=>r.pipe(I((n,i)=>i===0&&n.status===401?S.from(e.invalidateToken()).pipe(I(o=>o?S.of(o):S.throwError(()=>n))):S.throwError(()=>n)))))}function Ir({cqrsEndpoint:e,tokenProvider:t,ajaxOptions:r,tokenHeader:n="Authorization"}){return{createQuery(i){const o=(u,s)=>j({...r,headers:{[n]:s,"Content-Type":"application/json"},url:`${e}/query/${i}`,method:"POST",responseType:"json",body:u});return t?u=>S.from(t.getToken()).pipe(I(s=>o(u,s).pipe(te(t))),g(({response:s})=>s)):u=>o(u).pipe(g(({response:s})=>s))},createOperation(i){const o=(u,s)=>j({...r,headers:{Authorization:s,"Content-Type":"application/json"},url:`${e}/operation/${i}`,method:"POST",responseType:"json",body:u});return t?u=>S.from(t.getToken()).pipe(I(s=>o(u,s).pipe(te(t))),g(({response:s})=>s)):u=>o(u).pipe(g(({response:s})=>s))},createCommand(i,o){const u=(c,a)=>j({...r,headers:{Authorization:a,"Content-Type":"application/json"},url:`${e}/command/${i}`,method:"POST",responseType:"json",body:c});function s(c){return t?S.from(t.getToken()).pipe(I(a=>u(c,a).pipe(te(t))),g(({response:a})=>a)):u(c).pipe(g(({response:a})=>a))}return s.handle=c=>s(c).pipe(g(a=>({isSuccess:!0,result:a})),S.catchError(a=>a instanceof H&&a.status===422?S.of({isSuccess:!0,result:a.response}):S.of({isSuccess:!1,error:a})),g(a=>Ae.handleResponse(a,o))),s}}}function Rr(){return e=>e.pipe(S.reduce((t,r)=>t&&r,!0))}function Pr(){return e=>e.pipe(S.reduce((t,r)=>({...t,...r}),{}))}O.handleCommandResponse=ar,O.mkCqrsClient=Ir,O.reduceBoolean=Rr,O.reduceObject=Pr,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leancodepl/rx-cqrs-client",
3
- "version": "9.7.4",
3
+ "version": "10.0.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -15,8 +15,8 @@
15
15
  }
16
16
  },
17
17
  "dependencies": {
18
- "@leancodepl/cqrs-client-base": "9.7.4",
19
- "@leancodepl/validation": "9.7.4",
18
+ "@leancodepl/cqrs-client-base": "10.0.1",
19
+ "@leancodepl/validation": "10.0.1",
20
20
  "rxjs": ">=7.0.0"
21
21
  },
22
22
  "devDependencies": {