New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@mockyeah/fetch

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mockyeah/fetch - npm Package Compare versions

Comparing version 1.0.0-alpha.10 to 1.0.0

29

dist/index.js

@@ -43,3 +43,3 @@ "use strict";

const getDefaultBootOptions = (bootOptions) => {
const { name = 'default', noProxy = false, prependServerURL = false, noPolyfill = false, noWebSocket = false, host = 'localhost', port = 4001, portHttps, // e.g., 4443
const { name = 'default', noProxy = false, prependServerURL = false, modifyRequest, noPolyfill = false, noWebSocket = false, host = 'localhost', port = 4001, portHttps, // e.g., 4443
adminHost = host, adminPort = 4777, suiteHeader = 'x-mockyeah-suite', suiteCookie = 'mockyeahSuite', latency, ignorePrefix = `http${portHttps ? 's' : ''}://${host}:${portHttps || port}/`, aliases = [], responseHeaders = true,

@@ -52,2 +52,3 @@ // @ts-ignore

prependServerURL,
modifyRequest,
noPolyfill,

@@ -145,3 +146,3 @@ noWebSocket,

const { logPrefix, mocks, bootOptions, aliasReplacements, skipDevToolsCheck } = this.__private;
const { noWebSocket, ignorePrefix, noProxy: bootNoProxy, prependServerURL, suiteCookie, suiteHeader, port, portHttps, host, mockSuiteResolver, fetch, devTools, devToolsTimeout, devToolsInterval, serviceWorker } = bootOptions;
const { noWebSocket, ignorePrefix, modifyRequest, noProxy: bootNoProxy, prependServerURL, suiteCookie, suiteHeader, port, portHttps, host, mockSuiteResolver, fetch, devTools, devToolsTimeout, devToolsInterval, serviceWorker } = bootOptions;
const { dynamicMocks, dynamicMockSuite, noProxy = bootNoProxy } = fetchOptions;

@@ -241,3 +242,3 @@ if (!noWebSocket) {

const name = mockSuiteNames[index];
(mockSuiteLoaded.default || mockSuiteLoaded).forEach(mock => {
(mockSuiteLoaded.default || mockSuiteLoaded).forEach((mock) => {
const [match, response] = mock;

@@ -256,3 +257,3 @@ const newMatch = (isPlainObject_1.default(match)

};
dynamicMocksNormal.push(this.makeMock(newMatch, response, { keepExisting: true }).mock);
dynamicMocksNormal.push(this.makeMock(newMatch, response, { name, keepExisting: true }).mock);
});

@@ -269,5 +270,8 @@ });

};
const incomingNormal = normalize_1.normalize(incoming, true);
const incomingModifieds = modifyRequest?.(incoming) ?? [incoming];
const incomingNormals = (Array.isArray(incomingModifieds)
? incomingModifieds
: [incomingModifieds]).map(inc => normalize_1.normalize(inc, true));
let matchingMock;
[
flatten_1.default(incomingNormals.map(incomingNormal => [
incomingNormal,

@@ -287,3 +291,3 @@ ...(isPlainObject_1.default(incomingNormal)

: [])
]
]))
.filter(Boolean)

@@ -296,3 +300,3 @@ .find(inc => {

}
const match = m[0];
const [match, response] = m;
const matchResult = match_deep_1.default(inc, match, { skipKeys: ['$meta'] });

@@ -303,3 +307,3 @@ if (matchResult.result) {

}
debugMissEach(`${logPrefix} @mockyeah/fetch missed mock for`, url, matchResult.message, {
debugMissEach(`${logPrefix} @mockyeah/fetch missed mock ${response.name ? `"${response.name}" ` : ''}for`, url, matchResult.message, {
request: incoming,

@@ -362,3 +366,4 @@ match

}
debugHit(`${logPrefix} @mockyeah/fetch matched mock for`, url, {
const [match, mockResponse] = matchingMock;
debugHit(`${logPrefix} @mockyeah/fetch matched mock ${mockResponse.name ? `"${mockResponse.name}" ` : ''}for`, url, {
request: requestForHandler,

@@ -478,3 +483,3 @@ response,

makeMock(match, res, options = {}) {
const { keepExisting } = options;
const { keepExisting, name } = options;
const matchNormal = normalize_1.normalize(match);

@@ -492,3 +497,3 @@ const { mocks } = this.__private;

}
let resObj = typeof res === 'string' ? { text: res } : res;
let resObj = typeof res === 'string' ? { name, text: res } : { name, ...res };
resObj = resObj || { status: 200 };

@@ -495,0 +500,0 @@ if (matchNormal.$meta) {

@@ -1,1 +0,1 @@

module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=23)}([function(e,t){e.exports=require("@babel/runtime/regenerator")},function(e,t){e.exports=require("lodash/isPlainObject")},function(e,t){e.exports=require("assert")},function(e,t){e.exports=require("@babel/runtime/helpers/asyncToGenerator")},function(e,t){e.exports=require("debug")},function(e,t){e.exports=require("@babel/runtime/helpers/defineProperty")},function(e,t){e.exports=require("qs")},function(e,t){e.exports=require("@babel/runtime/helpers/toConsumableArray")},function(e,t){e.exports=require("@babel/runtime/helpers/slicedToArray")},function(e,t){e.exports=require("url")},function(e,t){e.exports=require("match-deep")},function(e,t){e.exports=require("lodash/isEmpty")},function(e,t){e.exports=require("lodash/isEqual")},function(e,t){e.exports=require("@babel/runtime/helpers/classCallCheck")},function(e,t){e.exports=require("@babel/runtime/helpers/createClass")},function(e,t){e.exports=require("cookie")},function(e,t){e.exports=require("lodash/isRegExp")},function(e,t){e.exports=require("lodash/mapValues")},function(e,t){e.exports=require("lodash/flatten")},function(e,t){e.exports=require("path-to-regexp")},function(e,t){e.exports=require("mime")},function(e,t){e.exports=require("@babel/runtime/helpers/typeof")},function(e,t){e.exports=require("lodash/fromPairs")},function(e,t,r){"use strict";r.r(t);var n=r(0),o=r.n(n),a=r(7),i=r.n(a),c=r(8),s=r.n(c),u=r(3),l=r.n(u),f=r(13),p=r.n(f),h=r(14),d=r.n(h),v=r(5),m=r.n(v),y=r(9),k=r(6),x=r.n(k),b=r(1),g=r.n(b),w=r(18),O=r.n(w),P=r(15),_=r.n(P),q=r(4),S=r.n(q),j=r(10),E=r.n(j),W=r(19),T=r.n(W),$=r(11),R=r.n($),D=r(16),C=r.n(D),H=r(17),M=r.n(H);function I(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function L(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?I(Object(r),!0).forEach((function(t){m()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):I(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var F=/^(\/?https?.{3}[^/:?]+):/,N=/^(\/?https?).{3}/,U=/^(\/?https?.{3}[^/:?]+)~/,A=/^(\/?https?).{3}/,K=function(e){return e.replace(A,"$1://").replace(U,"$1:")},J=function(e){return e.replace(F,"$1~").replace(N,"$1~~~")},B=/^\//,V=/^(https?)%3A%2F%2F/,X=function(e){return/^\/+https?[:~][/~]{2}/.test(e)?K(function(e){return e.replace(B,"")}(e).replace(V,(function(e,t){return"".concat(t,"://")}))):e},Y=function(e,t){if("function"==typeof e)return e;var r,n=g()(e)?L({},e):e;(r=g()(e)?L({},e):{url:e}).query=R()(r.query)?void 0:r.query,r.headers=R()(r.headers)?void 0:Object.entries(r.headers).reduce((function(e,t){var r=s()(t,2),n=r[0],o=r[1];return e[n.toLowerCase()]=o,e}),{}),r.method&&"all"!==r.method&&"ALL"!==r.method&&"*"!==r.method?"string"==typeof r.method&&(r.method=r.method.toLowerCase()):delete r.method;var o=L({},r.$meta||{});if(r.path&&(r.url=r.path,delete r.path),"*"===r.url&&delete r.url,"string"==typeof r.url){r.url=X(r.url);var a=function(e){var t;return/^https?:/.test(e)?(t=Object(y.parse)(e),e="".concat(t.protocol||"http:","//").concat(t.hostname).concat(t.port&&!["80","443"].includes(t.port)?":".concat(t.port):"").concat(t.pathname)):(t=Object(y.parse)("http://example.com".concat(e.startsWith("/")?e:"/".concat(e))),e=t.pathname||""),{url:e,query:t.query?x.a.parse(t.query):void 0}}(r.url);r.url=a.url.replace(/\/+$/,"")||"/",r.query=g()(r.query)?L({},a.query,{},r.query):r.query||a.query}R()(r.query)&&delete r.query,R()(r.cookies)&&delete r.cookies;var i=L({},r);r.url||(i.url="*"),o.original=n,o.originalNormal=i,o.originalSerialized=function e(t){return M()(t,(function(t){return C()(t)?{$regex:{source:t.source,flags:t.flags}}:g()(t)?M()(t,(function(t){return e(t)})):t}))}(i);var c=r.url;if("string"==typeof r.url){if(!t){var u=[],l=T()(J(r.url),u);r.url=function(e){return l.test(J(e)||J("/".concat(e)))},o.regex=l,o.matchKeys=u,o.fn=r.url.toString(),r.url.toStringForMatchDeep=function(){return'"'.concat(null==c?void 0:c.toString(),'"')}}}else if(C()(r.url)){if(!t){var f=r.url;r.url=function(e){return f.test(K(e))||f.test(K("/".concat(e)))},o.regex=f,o.fn=r.url.toString(),r.url.toStringForMatchDeep=function(){return null==c?void 0:c.toString()}}}else if("function"==typeof r.url){var p=r.url;r.url=function(e){return p(e)||p("/".concat(e))}}return L({},r,{$meta:o})},z=r(12),G=r.n(z),Q=function(e,t){var r=e.$meta?e.$meta.originalNormal:void 0,n=t.$meta?t.$meta.originalNormal:void 0;return g()(r)&&g()(n)?!(!r||!n)&&(r.url===n.url&&r.path===n.path&&r.method===n.method&&G()(r.query,n.query)&&G()(r.body,n.body)&&G()(r.headers,n.headers)&&G()(r.cookies,n.cookies)):r===n},Z=r(20),ee=r.n(Z);function te(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function re(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?te(Object(r),!0).forEach((function(t){m()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):te(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var ne=function(e,t,r){return"function"==typeof e?e(t,r):e},oe=function(){var e=l()(o.a.mark((function e(t,r,n,a){var i,c,s,u,l,f,p,h,d,v,m,y,k,x,b,g;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=n.responseHeaders,c=n.fixtureResolver,s=n.fileResolver,u=t[1]||{},e.t1=u.status,!e.t1){e.next=7;break}return e.next=6,ne(u.status,r,a);case 6:e.t1=e.sent;case 7:if(e.t0=e.t1,e.t0){e.next=10;break}e.t0=200;case 10:if(l=e.t0,e.t2=u.type,!e.t2){e.next=16;break}return e.next=15,ne(u.type,r,a);case 15:e.t2=e.sent;case 16:if(p=e.t2,!u.fixture){e.next=34;break}if(c){e.next=20;break}throw new Error("Using `fixture` in mock response options requires a `fixtureResolver`.");case 20:return e.next=22,ne(u.fixture,r,a);case 22:if(v=e.sent,p=p||v,!v){e.next=30;break}return e.next=27,c(v);case 27:e.t3=e.sent,e.next=31;break;case 30:e.t3=void 0;case 31:f=e.t3,e.next=78;break;case 34:if(!u.filePath){e.next=51;break}if(s){e.next=37;break}throw new Error("Using `filePath` in mock response options requires a `fileResolver`.");case 37:return e.next=39,ne(u.filePath,r,a);case 39:if(m=e.sent,p=p||m,!m){e.next=47;break}return e.next=44,s(m);case 44:e.t4=e.sent,e.next=48;break;case 47:e.t4=void 0;case 48:f=e.t4,e.next=78;break;case 51:if(!u.json){e.next=59;break}return e.next=54,ne(u.json,r,a);case 54:d=e.sent,f=JSON.stringify(d),h="application/json; charset=UTF-8",e.next=78;break;case 59:if(!u.text){e.next=66;break}return e.next=62,ne(u.text,r,a);case 62:f=e.sent,h="text/plain; charset=UTF-8",e.next=78;break;case 66:if(!u.html){e.next=73;break}return e.next=69,ne(u.html,r,a);case 69:f=e.sent,h="text/html; charset=UTF-8",e.next=78;break;case 73:if(!u.raw){e.next=78;break}return e.next=76,ne(u.raw,r,a);case 76:f=e.sent,h=void 0;case 78:if(f=f||"",h=p?ee.a.getType(p)||p:h,!u.headers){e.next=89;break}return e.t6=re,e.t7={},e.next=85,ne(u.headers,r,a);case 85:e.t8=e.sent,e.t5=(0,e.t6)(e.t7,e.t8),e.next=90;break;case 89:e.t5={};case 90:if(y=e.t5,i&&(y["x-mockyeah-mocked"]="true"),h&&(y["content-type"]=h),k={status:l,headers:y},!(x=u.latency||n.latency)){e.next=101;break}return e.next=98,ne(x,r,a);case 98:return b=e.sent,e.next=101,new Promise((function(e){return setTimeout(e,b)}));case 101:return g=new Response(f,k),e.abrupt("return",{response:g,body:f,headers:y,json:d});case 103:case"end":return e.stop()}}),e)})));return function(t,r,n,o){return e.apply(this,arguments)}}(),ae=r(21),ie=r.n(ae),ce=r(2),se=r.n(ce),ue=function(e){return e&&(e instanceof Promise||!(!e.then||!e.catch))},le=function(e,t,r){var n=E()(e,t,{skipKeys:["$meta"]}),o=n.result,a=n.message;se()(o,"".concat(r,": ").concat(a))},fe=function(){function e(t){p()(this,e);var r=t.$meta&&t.$meta.originalNormal?t.$meta.originalNormal:t;this.prefix="[".concat(r.method||"all","] ").concat(r.path||r.url," --"),this.called=0,this.assertions=[],this.handlers=[],this.verifier=this.verifier.bind(this),this.run=this.run.bind(this),this.verify=this.verify.bind(this)}return d()(e,[{key:"request",value:function(e){var t=this;this.called+=1,this.handlers.forEach((function(r){t.assertions.push(r.bind(t,e))}))}},{key:"api",value:function(e){var t=this;if("function"==typeof e){var r=e;this.handlers.push((function(e){try{var n=r(e);if(void 0!==n&&!n)throw new Error("function returned false")}catch(e){var o="".concat(t.prefix," Expect function did not match").concat(e&&e.message?": ".concat(e.message):"");se()(!1,o)}}))}else if("object"===ie()(e)){var n=Y(e);this.handlers.push((function(e){var t=E()(e,n,{skipKeys:["$meta"]}),r=t.result,o=t.message;se()(r,"Expect object did not match: ".concat(o))}))}return this}},{key:"atLeast",value:function(e){var t=this;return this.assertions.push((function(){se()(t.called>=e,"".concat(t.prefix," Expected route to be called at least ").concat(e," times, but it was called ").concat(t.called," times"))})),this}},{key:"atMost",value:function(e){var t=this;return this.assertions.push((function(){se()(t.called<=e,"".concat(t.prefix," Expected route to be called at most ").concat(e," times, but it was called ").concat(t.called," times"))})),this}},{key:"never",value:function(){var e=this;return this.assertions.push((function(){se()(0===e.called,"".concat(e.prefix," Expected route to be called never, but it was called ").concat(e.called," times"))})),this}},{key:"once",value:function(){var e=this;return this.assertions.push((function(){se()(1===e.called,"".concat(e.prefix," Expected route to be called once, but it was called ").concat(e.called," times"))})),this}},{key:"twice",value:function(){var e=this;return this.assertions.push((function(){se()(2===e.called,"".concat(e.prefix," Expected route to be called twice, but it was called ").concat(e.called," times"))})),this}},{key:"thrice",value:function(){var e=this;return this.assertions.push((function(){se()(3===e.called,"".concat(e.prefix," Expected route to be called thrice, but it was called ").concat(e.called," times"))})),this}},{key:"exactly",value:function(e){var t=this;return this.assertions.push((function(){se()(t.called===e,"".concat(t.prefix," Expected route to be called ").concat(e," times, but it was called ").concat(t.called," times"))})),this}},{key:"path",value:function(e){var t="".concat(this.prefix," Path did not match expected");return this.handlers.push((function(r){var n=r.path;le(n,e,t)})),this}},{key:"url",value:function(e){return this.path(e)}},{key:"header",value:function(e,t){var r="".concat(this.prefix,' Header "').concat(e,'" did not match expected');return this.handlers.push((function(n){le(n.headers&&(n.headers[e]||n.headers[e.toLowerCase()]),t,r)})),this}},{key:"params",value:function(e){var t="".concat(this.prefix," Params did not match expected");return this.handlers.push((function(r){le(r.query||{},e||{},t)})),this}},{key:"query",value:function(e){return this.params(e)}},{key:"body",value:function(e){var t="".concat(this.prefix," Body did not match expected");return this.handlers.push((function(r){le(r.body,e,t)})),this}},{key:"verifier",value:function(e){var t=this;return function(r){r?e(r):t.verify(e)}}},{key:"run",value:function(e){return ue(e)?this.runPromise=e:this.runPromise=new Promise((function(t,r){setTimeout((function(){var n=e((function(e){e?r(e):t()}));ue(n)&&n.then(t).catch(r)}))})),this}},{key:"verify",value:function(e){var t=this,r=function(t){if(!e)throw t;e(t)},n=function(){try{t.assertions.forEach((function(e){return e()})),e&&e()}catch(e){r(e)}};if(this.runPromise)return this.runPromise.then(n).catch(r);n()}}]),e}(),pe=function(){var e=l()(o.a.mark((function e(t){return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(204!==t.status){e.next=3;break}return e.abrupt("return","");case 3:return e.abrupt("return",t.text()||"");case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),he=function(e,t){var r=e&&e.get("Content-Type"),n=null==r?void 0:r.includes("application/json"),o=null==r?void 0:r.includes("application/x-www-form-urlencoded");if(t){if(n)return JSON.parse(t);if(o)return x.a.parse(t)}return t},de=r(22),ve=r.n(de),me=function(e){if(!e)return{};if(e.entries){var t=e.entries();return ve()(i()(t).map((function(e){return[e[0].toLowerCase(),e[1]]})))}if(e.forEach){var r={};return e.forEach((function(e,t){r[t]=e})),r}return{}},ye=function(e){var t=e.url,r=e.scope;"undefined"!=typeof navigator&&navigator.serviceWorker.register(t,{scope:r}).then((function(e){console.log("@mockyeah/fetch service worker registration succeeded.")})).catch((function(e){console.log("@mockyeah/fetch service worker registration failed.",e)}))},ke=function(e){var t;if("undefined"!=typeof navigator&&(null===(t=navigator.serviceWorker)||void 0===t?void 0:t.controller))try{navigator.serviceWorker.controller.postMessage(e)}catch(e){console.error(e)}},xe=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},be=["json","text","html","raw","filePath","fixture","status","type","latency","headers"];function ge(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function we(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ge(Object(r),!0).forEach((function(t){m()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ge(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Oe=S()("mockyeah:fetch:mock"),Pe=S()("mockyeah:fetch:hit"),_e=S()("mockyeah:fetch:miss"),qe=S()("mockyeah:fetch:miss:each"),Se=S()("mockyeah:fetch:error"),je=S()("mockyeah:fetch:admin"),Ee=S()("mockyeah:fetch:admin:error"),We=0,Te={},$e={},Re=function(e,t){return we({},g()(e)?e:{url:e},{method:t})},De=function(e){var t=e.name,r=void 0===t?"default":t,n=e.noProxy,o=void 0!==n&&n,a=e.prependServerURL,i=void 0!==a&&a,c=e.noPolyfill,s=void 0!==c&&c,u=e.noWebSocket,l=void 0!==u&&u,f=e.host,p=void 0===f?"localhost":f,h=e.port,d=void 0===h?4001:h,v=e.portHttps,m=e.adminHost,y=void 0===m?p:m,k=e.adminPort,x=void 0===k?4777:k,b=e.suiteHeader,g=void 0===b?"x-mockyeah-suite":b,w=e.suiteCookie,O=void 0===w?"mockyeahSuite":w,P=e.latency,_=e.ignorePrefix,q=void 0===_?"http".concat(v?"s":"","://").concat(p,":").concat(v||d,"/"):_,S=e.aliases,j=void 0===S?[]:S,E=e.responseHeaders,W=void 0===E||E,T=e.fetch,$=void 0===T?global.fetch:T,R=e.fileResolver,D=e.fixtureResolver,C=e.mockSuiteResolver,H=e.devTools,M=void 0!==H&&H,I=e.devToolsTimeout,L=void 0===I?2e3:I,F=e.devToolsInterval,N=void 0===F?100:F,U=e.serviceWorker,A=e.serviceWorkerRegister,K=void 0===A?U:A,J=e.serviceWorkerURL,B=void 0===J?"/__mockyeahServiceWorker.js":J,V=e.serviceWorkerScope;return{name:r,noProxy:o,prependServerURL:i,noPolyfill:s,noWebSocket:l,host:p,port:d,portHttps:v,adminHost:y,adminPort:x,suiteHeader:g,suiteCookie:O,latency:P,ignorePrefix:q,aliases:j,responseHeaders:W,fetch:$,fileResolver:R,fixtureResolver:D,mockSuiteResolver:C,devTools:M,devToolsTimeout:L,devToolsInterval:N,serviceWorker:U,serviceWorkerRegister:K,serviceWorkerURL:B,serviceWorkerScope:void 0===V?"/":V}},Ce=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:$e;p()(this,e);var r=De(t),n=r.name,o=r.noPolyfill,a=r.aliases,i=r.fetch,c=r.serviceWorker,s=r.serviceWorkerRegister,u=r.serviceWorkerURL,l=r.serviceWorkerScope;this.__private={recording:!1,bootOptions:r,logPrefix:"[".concat(n,"]"),mocks:[],devToolsFound:!1,skipDevToolsCheck:!1};var f=this.__private.logPrefix;if(!i){var h="".concat(f," @mockyeah/fetch requires a fetch implementation");throw Se(h),new Error(h)}var d={};(a||[]).forEach((function(e){e.forEach((function(t){d[t]=e}))})),this.__private.aliasReplacements=d,o||(global.fetch=this.fetch.bind(this));var v={all:this.all.bind(this),get:this.get.bind(this),post:this.post.bind(this),put:this.put.bind(this),delete:this.delete.bind(this),options:this.options.bind(this),patch:this.patch.bind(this)};this.methods=v,c&&"undefined"!=typeof window&&(s&&ye({url:u,scope:l}),navigator.serviceWorker.addEventListener("message",(function(e){if(e.data&&"mockyeahServiceWorkerDataRequest"===e.data.type){var t=(e.data.payload||{}).requestId;if(!t)return;if(Te[t]){var r={type:"mockyeahServiceWorkerDataResponse",payload:{requestId:t,response:Te[t].response}};ke(r)}}})))}var t,r,n;return d()(e,[{key:"fetch",value:(n=l()(o.a.mark((function e(t,r){var n,a,c,u,l,f,p,h,d,v,k,b,w,P,q,S,j,W,T,$,R,D,C,H,M,I,L,F,N,U,A,K,J,B,V,X,z,G,Q,Z,ee,te,re,ne,ae,ie,ce,se,ue,le,fe,pe,de,ve,ye,ke,xe,ge,Oe,je,Ee=this,$e=arguments;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=$e.length>2&&void 0!==$e[2]?$e[2]:{},a=this.__private,c=a.logPrefix,u=a.mocks,l=a.bootOptions,f=a.aliasReplacements,p=a.skipDevToolsCheck,h=l.noWebSocket,d=l.ignorePrefix,v=l.noProxy,k=l.prependServerURL,b=l.suiteCookie,w=l.suiteHeader,P=l.port,q=l.portHttps,S=l.host,j=l.mockSuiteResolver,W=l.fetch,T=l.devTools,$=l.devToolsTimeout,R=l.devToolsInterval,D=l.serviceWorker,C=n.dynamicMocks,H=n.dynamicMockSuite,M=n.noProxy,I=void 0===M?v:M,h){e.next=12;break}return e.prev=5,e.next=8,this.connectWebSocket();case 8:e.next=12;break;case 10:e.prev=10,e.t0=e.catch(5);case 12:if(!T||"undefined"==typeof window||p){e.next=18;break}return e.next=15,new Promise((function(e){var t=0,r=setInterval((function(){t+=1,window.__MOCKYEAH_DEVTOOLS_EXTENSION__?(Ee.__private.devToolsFound=!0,clearInterval(r),e()):t>$/R&&(Ee.__private.skipDevToolsCheck=!0,clearInterval(r),e())}),R)}));case 15:if(!this.__private.devToolsFound){e.next=18;break}return e.next=18,new Promise((function(e){var t=0,r=setInterval((function(){var n;t+=1,((null===(n=window.__MOCKYEAH_DEVTOOLS_EXTENSION__)||void 0===n?void 0:n.loadedMocks)||t>$/R)&&(clearInterval(r),e())}),R)}));case 18:if(L="string"==typeof t?t:t.url,F=r||{},N=(C||[]).map((function(e){return e&&Ee.makeMock(e[0],e[1],{keepExisting:!0}).mock})).filter(Boolean),U=Object(y.parse)(L),A=F.headers?F.headers instanceof Headers?F.headers:new Headers(F.headers):void 0,!F.body||"string"==typeof F.body){e.next=26;break}return Se("".concat(c," @mockyeah/fetch does not yet support non-string request bodies, falling back to normal fetch")),e.abrupt("return",this.fallbackFetch(L,r,{noProxy:I}));case 26:if(K=A&&he(A,F.body),J=U.query?x.a.parse(U.query):void 0,B=F.method?F.method.toLowerCase():"get",!F.headers||g()(F.headers)){e.next=32;break}return Se("".concat(c," @mockyeah/fetch does not yet support non-object request headers, falling back to normal fetch")),e.abrupt("return",this.fallbackFetch(L,r,{noProxy:I}));case 32:V=F.headers;try{(z=V&&(V.cookie||V.Cookie))?X=_.a.parse(z):"undefined"!=typeof window&&(X=_.a.parse(window.document.cookie))}catch(e){Se("".concat(c," @mockyeah/fetch couldn't parse cookies: ").concat(e.message))}if(!(G=H||X&&X[b])||!j){e.next=42;break}return Q=G.split(",").map((function(e){return e.trim()})),Z=Q.map(j),e.next=40,Promise.all(Z);case 40:e.sent.forEach((function(e,t){var r=Q[t];(e.default||e).forEach((function(e){var t=s()(e,2),n=t[0],o=t[1],a=g()(n)?we({},n):{url:n};a.cookies=we({},a.cookies,{mockSuite:function(e){return!!e&&e.split(",").map((function(e){return e.trim()})).includes(r)}}),N.push(Ee.makeMock(a,o,{keepExisting:!0}).mock)}))}));case 42:if(ee={url:L.replace(d,""),query:J,headers:V,body:K,method:B,cookies:X},[te=Y(ee,!0)].concat(i()(g()(te)?O()(f&&Object.entries(f).map((function(e){var t=s()(e,2),r=t[0],n=t[1],o=te.url;return"string"==typeof o&&o.replace(/^\//,"").startsWith(r)?n.map((function(e){return we({},te,{url:o.replace(r,e)})})):[]}))):[])).filter(Boolean).find((function(e){return[].concat(i()(N),i()(u)).find((function(t){if(!t)return!1;var r=t[0],n=E()(e,r,{skipKeys:["$meta"]});return n.result?(re=t,!0):(qe("".concat(c," @mockyeah/fetch missed mock for"),L,n.message,{request:ee,match:r}),!1)}))})),ne="".concat(U.protocol?"".concat(U.protocol,"//"):"").concat(U.host||"").concat(U.pathname||"/"),ae={url:ne,path:ne,query:J,method:B,headers:V,body:K,cookies:X},!re){e.next=72;break}if(re[0]&&re[0].$meta&&re[0].$meta.expectation&&re[0].$meta.expectation.request(ae),!(ce=re[1])||!be.some((function(e){return"function"==typeof ce[e]&&ce[e].length>1}))){e.next=62;break}return e.next=54,this.fallbackFetch(L,F);case 54:return se=e.sent,e.t1=he,e.t2=se.headers,e.next=59,se.text();case 59:e.t3=e.sent,ue=(0,e.t1)(e.t2,e.t3),ie={status:se.status,body:ue,headers:me(se.headers)};case 62:return e.next=64,oe(re,ae,l,ie);case 64:return le=e.sent,fe=le.response,pe=le.json,de=le.body,ve=le.headers,D&&(ye={status:fe.status,body:de,headers:ve},Te[ke=We+=1]={response:ye},W(L,we({},F,{headers:we({},F.headers,{"x-mockyeah-service-worker-request":ke})}))),Pe("".concat(c," @mockyeah/fetch matched mock for"),L,{request:ae,response:fe,json:pe,mock:re}),e.abrupt("return",fe);case 72:return _e("".concat(c," @mockyeah/fetch missed all mocks for"),L,{request:ae}),xe="http".concat(q?"s":"","://").concat(S,":").concat(q||P),ge=F,k&&xe&&(L="".concat(xe,"/").concat(L.replace("://","~~~")),"undefined"!=typeof document&&(je=document.cookie.match("\\b".concat(b,"=([^;]+)\\b")),Oe=je&&je[1]),ge=we({},F,{headers:we({},F.headers,{},Oe&&m()({},w,Oe))})),e.abrupt("return",this.fallbackFetch(L,ge,{noProxy:I}));case 77:case"end":return e.stop()}}),e,this,[[5,10]])}))),function(e,t){return n.apply(this,arguments)})},{key:"fallbackFetch",value:(r=l()(o.a.mark((function e(t,r){var n,a,i,c,s,u,l,f,p,h,d,v,m,y,k,x,b,g,w,O,P=arguments;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=P.length>2&&void 0!==P[2]?P[2]:{},a=n.noProxy,i=this.__private.bootOptions,c=i.responseHeaders,s=i.fetch,u="string"==typeof t?t:t.url,!a&&u.startsWith("http")){e.next=8;break}return l={},c&&(l["x-mockyeah-missed"]="true"),e.abrupt("return",new Response("",{status:404,headers:l}));case 8:return f=(new Date).getTime(),e.next=11,s(t,r);case 11:return p=e.sent,e.next=14,pe(p);case 14:return h=e.sent,d=this.__private,v=d.ws,d.recording&&(m=p.status,y=me(p.headers),v&&(k={type:"recordPush",payload:{reqUrl:u,req:{method:r&&r.method,body:r&&r.body},startTime:f,body:h,headers:y,status:m}},v.send(JSON.stringify(k)))),c&&(b=(x=p).status,g=x.statusText,w=x.headers,(O=w&&new Headers(w))&&(O.set("x-mockyeah-proxied","true"),O.set("x-mockyeah-missed","true")),p=new Response(h,{headers:O,status:b,statusText:g})),e.abrupt("return",p);case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"expect",value:function(e){return this.all("*").expect(e)}},{key:"all",value:function(e,t){return this.mock(e,t)}},{key:"get",value:function(e,t){return this.mock(Re(e,"get"),t)}},{key:"post",value:function(e,t){return this.mock(Re(e,"post"),t)}},{key:"put",value:function(e,t){return this.mock(Re(e,"put"),t)}},{key:"delete",value:function(e,t){return this.mock(Re(e,"delete"),t)}},{key:"options",value:function(e,t){return this.mock(Re(e,"options"),t)}},{key:"patch",value:function(e,t){return this.mock(Re(e,"patch"),t)}},{key:"reset",value:function(){this.__private.mocks=[]}},{key:"makeMock",value:function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=n.keepExisting,a=Y(e),i=this.__private.mocks,c=[];if(!o){var s,u=i.findIndex((function(e){return Q(a,e[0])}));if(u>=0)r=null!==(s=r)&&void 0!==s?s:u,c.push(i[u]),i.splice(u,1)}var l="string"==typeof t?{text:t}:t;return l=l||{status:200},a.$meta&&(a.$meta.expectation=new fe(a),a.$meta.id=xe()),{mock:[a,l],removed:c,removedIndex:r}}},{key:"mock",value:function(e,t){var r,n=this.makeMock(e,t),o=n.mock,a=n.removed,i=n.removedIndex,c=null===(r=o[0].$meta)||void 0===r?void 0:r.id,s=this.__private,u=s.mocks,l=s.logPrefix;Oe("".concat(l," mocked"),e,t),null!=i?u.splice(i,0,o):u.push(o);var f=o[0].$meta&&o[0].$meta.expectation,p=a.map((function(e){var t,r;return null===(t=e[0])||void 0===t||null===(r=t.$meta)||void 0===r?void 0:r.id})),h=f.api.bind(f);return{id:c,removedIds:p,expect:function(e){return h(e)}}}},{key:"unmock",value:function(e){var t=this.__private,r=t.mocks,n=t.logPrefix,o=r.findIndex((function(t){var r;return(null===(r=t[0].$meta)||void 0===r?void 0:r.id)===e}));return-1===o?(Oe("".concat(n," didn't find id to unmock"),e),!1):(r.splice(o,1),Oe("".concat(n," unmocked"),e),!0)}},{key:"connectWebSocket",value:(t=l()(o.a.mark((function e(){var t,r,n,a,i=this;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("undefined"!=typeof WebSocket){e.next=2;break}return e.abrupt("return");case 2:if(!this.__private.ws){e.next=4;break}return e.abrupt("return");case 4:t=this.__private.bootOptions,r=t.adminPort,n=t.adminHost,a="ws://".concat(n,":").concat(r),je("WebSocket trying to connect to '".concat(a,"'.")),e.prev=7,this.__private.ws=new WebSocket(a),e.next=16;break;case 11:throw e.prev=11,e.t0=e.catch(7),Ee("WebSocket couldn't connect to '".concat(a,"':"),e.t0),delete this.__private.ws,e.t0;case 16:return e.next=18,new Promise((function(e,t){var r=i.__private.ws;r&&(r.onopen=function(){je("WebSocket opened"),r.send(JSON.stringify({type:"opened"})),e()},r.onerror=function(e){Ee("WebSocket errored",e),t(e)},r.onclose=function(){Ee("WebSocket closed"),i.__private.recording=!1,delete i.__private.ws,t(new Error("WebSocket closed"))},r.onmessage=function(e){var t;je("WebSocket message",e);try{t=JSON.parse(e.data)}catch(t){return void Ee("Couldn't parse WebSocket message data '".concat(e.data,"':"),t)}t&&(je("WebSocket action",t),"record"===t.type?i.__private.recording=!0:"recordStop"===t.type&&(i.__private.recording=!1))})}));case 18:case"end":return e.stop()}}),e,this,[[7,11]])}))),function(){return t.apply(this,arguments)})}]),e}();t.default=Ce}]).default;
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=23)}([function(e,t){e.exports=require("@babel/runtime/regenerator")},function(e,t){e.exports=require("lodash/isPlainObject")},function(e,t){e.exports=require("assert")},function(e,t){e.exports=require("@babel/runtime/helpers/asyncToGenerator")},function(e,t){e.exports=require("debug")},function(e,t){e.exports=require("@babel/runtime/helpers/defineProperty")},function(e,t){e.exports=require("@babel/runtime/helpers/slicedToArray")},function(e,t){e.exports=require("qs")},function(e,t){e.exports=require("@babel/runtime/helpers/toConsumableArray")},function(e,t){e.exports=require("url")},function(e,t){e.exports=require("match-deep")},function(e,t){e.exports=require("lodash/isEmpty")},function(e,t){e.exports=require("lodash/isEqual")},function(e,t){e.exports=require("@babel/runtime/helpers/classCallCheck")},function(e,t){e.exports=require("@babel/runtime/helpers/createClass")},function(e,t){e.exports=require("lodash/flatten")},function(e,t){e.exports=require("cookie")},function(e,t){e.exports=require("lodash/isRegExp")},function(e,t){e.exports=require("lodash/mapValues")},function(e,t){e.exports=require("path-to-regexp")},function(e,t){e.exports=require("mime")},function(e,t){e.exports=require("@babel/runtime/helpers/typeof")},function(e,t){e.exports=require("lodash/fromPairs")},function(e,t,r){"use strict";r.r(t);var n=r(0),o=r.n(n),a=r(8),i=r.n(a),c=r(6),s=r.n(c),u=r(3),l=r.n(u),f=r(13),p=r.n(f),h=r(14),d=r.n(h),v=r(5),m=r.n(v),y=r(9),k=r(7),x=r.n(k),b=r(1),g=r.n(b),w=r(15),O=r.n(w),P=r(16),q=r.n(P),_=r(4),S=r.n(_),j=r(10),E=r.n(j),W=r(19),T=r.n(W),R=r(11),$=r.n(R),D=r(17),C=r.n(D),H=r(18),M=r.n(H);function I(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function L(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?I(Object(r),!0).forEach((function(t){m()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):I(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var F=/^(\/?https?.{3}[^/:?]+):/,N=/^(\/?https?).{3}/,U=/^(\/?https?.{3}[^/:?]+)~/,A=/^(\/?https?).{3}/,K=function(e){return e.replace(A,"$1://").replace(U,"$1:")},J=function(e){return e.replace(F,"$1~").replace(N,"$1~~~")},B=/^\//,V=/^(https?)%3A%2F%2F/,X=function(e){return/^\/+https?[:~][/~]{2}/.test(e)?K(function(e){return e.replace(B,"")}(e).replace(V,(function(e,t){return"".concat(t,"://")}))):e},Y=function(e,t){if("function"==typeof e)return e;var r,n=g()(e)?L({},e):e;(r=g()(e)?L({},e):{url:e}).query=$()(r.query)?void 0:r.query,r.headers=$()(r.headers)?void 0:Object.entries(r.headers).reduce((function(e,t){var r=s()(t,2),n=r[0],o=r[1];return e[n.toLowerCase()]=o,e}),{}),r.method&&"all"!==r.method&&"ALL"!==r.method&&"*"!==r.method?"string"==typeof r.method&&(r.method=r.method.toLowerCase()):delete r.method;var o=L({},r.$meta||{});if(r.path&&(r.url=r.path,delete r.path),"*"===r.url&&delete r.url,"string"==typeof r.url){r.url=X(r.url);var a=function(e){var t;return/^https?:/.test(e)?(t=Object(y.parse)(e),e="".concat(t.protocol||"http:","//").concat(t.hostname).concat(t.port&&!["80","443"].includes(t.port)?":".concat(t.port):"").concat(t.pathname)):(t=Object(y.parse)("http://example.com".concat(e.startsWith("/")?e:"/".concat(e))),e=t.pathname||""),{url:e,query:t.query?x.a.parse(t.query):void 0}}(r.url);r.url=a.url.replace(/\/+$/,"")||"/",r.query=g()(r.query)?L({},a.query,{},r.query):r.query||a.query}$()(r.query)&&delete r.query,$()(r.cookies)&&delete r.cookies;var i=L({},r);r.url||(i.url="*"),o.original=n,o.originalNormal=i,o.originalSerialized=function e(t){return M()(t,(function(t){return C()(t)?{$regex:{source:t.source,flags:t.flags}}:g()(t)?M()(t,(function(t){return e(t)})):t}))}(i);var c=r.url;if("string"==typeof r.url){if(!t){var u=[],l=T()(J(r.url),u);r.url=function(e){return l.test(J(e)||J("/".concat(e)))},o.regex=l,o.matchKeys=u,o.fn=r.url.toString(),r.url.toStringForMatchDeep=function(){return'"'.concat(null==c?void 0:c.toString(),'"')}}}else if(C()(r.url)){if(!t){var f=r.url;r.url=function(e){return f.test(K(e))||f.test(K("/".concat(e)))},o.regex=f,o.fn=r.url.toString(),r.url.toStringForMatchDeep=function(){return null==c?void 0:c.toString()}}}else if("function"==typeof r.url){var p=r.url;r.url=function(e){return p(e)||p("/".concat(e))}}return L({},r,{$meta:o})},z=r(12),G=r.n(z),Q=function(e,t){var r=e.$meta?e.$meta.originalNormal:void 0,n=t.$meta?t.$meta.originalNormal:void 0;return g()(r)&&g()(n)?!(!r||!n)&&(r.url===n.url&&r.path===n.path&&r.method===n.method&&G()(r.query,n.query)&&G()(r.body,n.body)&&G()(r.headers,n.headers)&&G()(r.cookies,n.cookies)):r===n},Z=r(20),ee=r.n(Z);function te(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function re(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?te(Object(r),!0).forEach((function(t){m()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):te(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var ne=function(e,t,r){return"function"==typeof e?e(t,r):e},oe=function(){var e=l()(o.a.mark((function e(t,r,n,a){var i,c,s,u,l,f,p,h,d,v,m,y,k,x,b,g;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=n.responseHeaders,c=n.fixtureResolver,s=n.fileResolver,u=t[1]||{},l=u.name,e.t1=u.status,!e.t1){e.next=8;break}return e.next=7,ne(u.status,r,a);case 7:e.t1=e.sent;case 8:if(e.t0=e.t1,e.t0){e.next=11;break}e.t0=200;case 11:if(f=e.t0,e.t2=u.type,!e.t2){e.next=17;break}return e.next=16,ne(u.type,r,a);case 16:e.t2=e.sent;case 17:if(h=e.t2,!u.fixture){e.next=35;break}if(c){e.next=21;break}throw new Error("Using `fixture` in mock response options requires a `fixtureResolver`.");case 21:return e.next=23,ne(u.fixture,r,a);case 23:if(m=e.sent,h=h||m,!m){e.next=31;break}return e.next=28,c(m);case 28:e.t3=e.sent,e.next=32;break;case 31:e.t3=void 0;case 32:p=e.t3,e.next=79;break;case 35:if(!u.filePath){e.next=52;break}if(s){e.next=38;break}throw new Error("Using `filePath` in mock response options requires a `fileResolver`.");case 38:return e.next=40,ne(u.filePath,r,a);case 40:if(y=e.sent,h=h||y,!y){e.next=48;break}return e.next=45,s(y);case 45:e.t4=e.sent,e.next=49;break;case 48:e.t4=void 0;case 49:p=e.t4,e.next=79;break;case 52:if(!u.json){e.next=60;break}return e.next=55,ne(u.json,r,a);case 55:v=e.sent,p=JSON.stringify(v),d="application/json; charset=UTF-8",e.next=79;break;case 60:if(!u.text){e.next=67;break}return e.next=63,ne(u.text,r,a);case 63:p=e.sent,d="text/plain; charset=UTF-8",e.next=79;break;case 67:if(!u.html){e.next=74;break}return e.next=70,ne(u.html,r,a);case 70:p=e.sent,d="text/html; charset=UTF-8",e.next=79;break;case 74:if(!u.raw){e.next=79;break}return e.next=77,ne(u.raw,r,a);case 77:p=e.sent,d=void 0;case 79:if(p=p||"",d=h?ee.a.getType(h)||h:d,!(k=u.latency||n.latency)){e.next=88;break}return e.next=85,ne(k,r,a);case 85:return x=e.sent,e.next=88,new Promise((function(e){return setTimeout(e,x)}));case 88:if(!u.headers){e.next=97;break}return e.t6=re,e.t7={},e.next=93,ne(u.headers,r,a);case 93:e.t8=e.sent,e.t5=(0,e.t6)(e.t7,e.t8),e.next=98;break;case 97:e.t5={};case 98:return b=e.t5,i&&(b["x-mockyeah-mocked"]="true",l&&(b["x-mockyeah-name"]=l),m&&(b["x-mockyeah-fixture"]=m),y&&(b["x-mockyeah-filePath"]=y),x&&(b["x-mockyeah-latency"]=x.toString())),d&&(b["content-type"]=d),g=new Response(p,{status:f,headers:b}),e.abrupt("return",{response:g,body:p,headers:b,json:v});case 104:case"end":return e.stop()}}),e)})));return function(t,r,n,o){return e.apply(this,arguments)}}(),ae=r(21),ie=r.n(ae),ce=r(2),se=r.n(ce),ue=function(e){return e&&(e instanceof Promise||!(!e.then||!e.catch))},le=function(e,t,r){var n=E()(e,t,{skipKeys:["$meta"]}),o=n.result,a=n.message;se()(o,"".concat(r,": ").concat(a))},fe=function(){function e(t){p()(this,e);var r=t.$meta&&t.$meta.originalNormal?t.$meta.originalNormal:t;this.prefix="[".concat(r.method||"all","] ").concat(r.path||r.url," --"),this.called=0,this.assertions=[],this.handlers=[],this.verifier=this.verifier.bind(this),this.run=this.run.bind(this),this.verify=this.verify.bind(this)}return d()(e,[{key:"request",value:function(e){var t=this;this.called+=1,this.handlers.forEach((function(r){t.assertions.push(r.bind(t,e))}))}},{key:"api",value:function(e){var t=this;if("function"==typeof e){var r=e;this.handlers.push((function(e){try{var n=r(e);if(void 0!==n&&!n)throw new Error("function returned false")}catch(e){var o="".concat(t.prefix," Expect function did not match").concat(e&&e.message?": ".concat(e.message):"");se()(!1,o)}}))}else if("object"===ie()(e)){var n=Y(e);this.handlers.push((function(e){var t=E()(e,n,{skipKeys:["$meta"]}),r=t.result,o=t.message;se()(r,"Expect object did not match: ".concat(o))}))}return this}},{key:"atLeast",value:function(e){var t=this;return this.assertions.push((function(){se()(t.called>=e,"".concat(t.prefix," Expected route to be called at least ").concat(e," times, but it was called ").concat(t.called," times"))})),this}},{key:"atMost",value:function(e){var t=this;return this.assertions.push((function(){se()(t.called<=e,"".concat(t.prefix," Expected route to be called at most ").concat(e," times, but it was called ").concat(t.called," times"))})),this}},{key:"never",value:function(){var e=this;return this.assertions.push((function(){se()(0===e.called,"".concat(e.prefix," Expected route to be called never, but it was called ").concat(e.called," times"))})),this}},{key:"once",value:function(){var e=this;return this.assertions.push((function(){se()(1===e.called,"".concat(e.prefix," Expected route to be called once, but it was called ").concat(e.called," times"))})),this}},{key:"twice",value:function(){var e=this;return this.assertions.push((function(){se()(2===e.called,"".concat(e.prefix," Expected route to be called twice, but it was called ").concat(e.called," times"))})),this}},{key:"thrice",value:function(){var e=this;return this.assertions.push((function(){se()(3===e.called,"".concat(e.prefix," Expected route to be called thrice, but it was called ").concat(e.called," times"))})),this}},{key:"exactly",value:function(e){var t=this;return this.assertions.push((function(){se()(t.called===e,"".concat(t.prefix," Expected route to be called ").concat(e," times, but it was called ").concat(t.called," times"))})),this}},{key:"path",value:function(e){var t="".concat(this.prefix," Path did not match expected");return this.handlers.push((function(r){var n=r.path;le(n,e,t)})),this}},{key:"url",value:function(e){return this.path(e)}},{key:"header",value:function(e,t){var r="".concat(this.prefix,' Header "').concat(e,'" did not match expected');return this.handlers.push((function(n){le(n.headers&&(n.headers[e]||n.headers[e.toLowerCase()]),t,r)})),this}},{key:"params",value:function(e){var t="".concat(this.prefix," Params did not match expected");return this.handlers.push((function(r){le(r.query||{},e||{},t)})),this}},{key:"query",value:function(e){return this.params(e)}},{key:"body",value:function(e){var t="".concat(this.prefix," Body did not match expected");return this.handlers.push((function(r){le(r.body,e,t)})),this}},{key:"verifier",value:function(e){var t=this;return function(r){r?e(r):t.verify(e)}}},{key:"run",value:function(e){return ue(e)?this.runPromise=e:this.runPromise=new Promise((function(t,r){setTimeout((function(){var n=e((function(e){e?r(e):t()}));ue(n)&&n.then(t).catch(r)}))})),this}},{key:"verify",value:function(e){var t=this,r=function(t){if(!e)throw t;e(t)},n=function(){try{t.assertions.forEach((function(e){return e()})),e&&e()}catch(e){r(e)}};if(this.runPromise)return this.runPromise.then(n).catch(r);n()}}]),e}(),pe=function(){var e=l()(o.a.mark((function e(t){return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(204!==t.status){e.next=3;break}return e.abrupt("return","");case 3:return e.abrupt("return",t.text()||"");case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),he=function(e,t){var r=e&&e.get("Content-Type"),n=null==r?void 0:r.includes("application/json"),o=null==r?void 0:r.includes("application/x-www-form-urlencoded");if(t){if(n)return JSON.parse(t);if(o)return x.a.parse(t)}return t},de=r(22),ve=r.n(de),me=function(e){if(!e)return{};if(e.entries){var t=e.entries();return ve()(i()(t).map((function(e){return[e[0].toLowerCase(),e[1]]})))}if(e.forEach){var r={};return e.forEach((function(e,t){r[t]=e})),r}return{}},ye=function(e){var t=e.url,r=e.scope;"undefined"!=typeof navigator&&navigator.serviceWorker.register(t,{scope:r}).then((function(e){console.log("@mockyeah/fetch service worker registration succeeded.")})).catch((function(e){console.log("@mockyeah/fetch service worker registration failed.",e)}))},ke=function(e){var t;if("undefined"!=typeof navigator&&(null===(t=navigator.serviceWorker)||void 0===t?void 0:t.controller))try{navigator.serviceWorker.controller.postMessage(e)}catch(e){console.error(e)}},xe=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},be=["json","text","html","raw","filePath","fixture","status","type","latency","headers"];function ge(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function we(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ge(Object(r),!0).forEach((function(t){m()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ge(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var Oe=S()("mockyeah:fetch:mock"),Pe=S()("mockyeah:fetch:hit"),qe=S()("mockyeah:fetch:miss"),_e=S()("mockyeah:fetch:miss:each"),Se=S()("mockyeah:fetch:error"),je=S()("mockyeah:fetch:admin"),Ee=S()("mockyeah:fetch:admin:error"),We=0,Te={},Re={},$e=function(e,t){return we({},g()(e)?e:{url:e},{method:t})},De=function(e){var t=e.name,r=void 0===t?"default":t,n=e.noProxy,o=void 0!==n&&n,a=e.prependServerURL,i=void 0!==a&&a,c=e.modifyRequest,s=e.noPolyfill,u=void 0!==s&&s,l=e.noWebSocket,f=void 0!==l&&l,p=e.host,h=void 0===p?"localhost":p,d=e.port,v=void 0===d?4001:d,m=e.portHttps,y=e.adminHost,k=void 0===y?h:y,x=e.adminPort,b=void 0===x?4777:x,g=e.suiteHeader,w=void 0===g?"x-mockyeah-suite":g,O=e.suiteCookie,P=void 0===O?"mockyeahSuite":O,q=e.latency,_=e.ignorePrefix,S=void 0===_?"http".concat(m?"s":"","://").concat(h,":").concat(m||v,"/"):_,j=e.aliases,E=void 0===j?[]:j,W=e.responseHeaders,T=void 0===W||W,R=e.fetch,$=void 0===R?global.fetch:R,D=e.fileResolver,C=e.fixtureResolver,H=e.mockSuiteResolver,M=e.devTools,I=void 0!==M&&M,L=e.devToolsTimeout,F=void 0===L?2e3:L,N=e.devToolsInterval,U=void 0===N?100:N,A=e.serviceWorker,K=e.serviceWorkerRegister,J=void 0===K?A:K,B=e.serviceWorkerURL,V=void 0===B?"/__mockyeahServiceWorker.js":B,X=e.serviceWorkerScope;return{name:r,noProxy:o,prependServerURL:i,modifyRequest:c,noPolyfill:u,noWebSocket:f,host:h,port:v,portHttps:m,adminHost:k,adminPort:b,suiteHeader:w,suiteCookie:P,latency:q,ignorePrefix:S,aliases:E,responseHeaders:T,fetch:$,fileResolver:D,fixtureResolver:C,mockSuiteResolver:H,devTools:I,devToolsTimeout:F,devToolsInterval:U,serviceWorker:A,serviceWorkerRegister:J,serviceWorkerURL:V,serviceWorkerScope:void 0===X?"/":X}},Ce=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Re;p()(this,e);var r=De(t),n=r.name,o=r.noPolyfill,a=r.aliases,i=r.fetch,c=r.serviceWorker,s=r.serviceWorkerRegister,u=r.serviceWorkerURL,l=r.serviceWorkerScope;this.__private={recording:!1,bootOptions:r,logPrefix:"[".concat(n,"]"),mocks:[],devToolsFound:!1,skipDevToolsCheck:!1};var f=this.__private.logPrefix;if(!i){var h="".concat(f," @mockyeah/fetch requires a fetch implementation");throw Se(h),new Error(h)}var d={};(a||[]).forEach((function(e){e.forEach((function(t){d[t]=e}))})),this.__private.aliasReplacements=d,o||(global.fetch=this.fetch.bind(this));var v={all:this.all.bind(this),get:this.get.bind(this),post:this.post.bind(this),put:this.put.bind(this),delete:this.delete.bind(this),options:this.options.bind(this),patch:this.patch.bind(this)};this.methods=v,c&&"undefined"!=typeof window&&(s&&ye({url:u,scope:l}),navigator.serviceWorker.addEventListener("message",(function(e){if(e.data&&"mockyeahServiceWorkerDataRequest"===e.data.type){var t=(e.data.payload||{}).requestId;if(!t)return;if(Te[t]){var r={type:"mockyeahServiceWorkerDataResponse",payload:{requestId:t,response:Te[t].response}};ke(r)}}})))}var t,r,n;return d()(e,[{key:"fetch",value:(n=l()(o.a.mark((function e(t,r){var n,a,c,u,l,f,p,h,d,v,k,b,w,P,_,S,j,W,T,R,$,D,C,H,M,I,L,F,N,U,A,K,J,B,V,X,z,G,Q,Z,ee,te,re,ne,ae,ie,ce,se,ue,le,fe,pe,de,ve,ye,ke,xe,ge,Oe,je,Ee,Re,$e,De,Ce,He,Me=this,Ie=arguments;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=Ie.length>2&&void 0!==Ie[2]?Ie[2]:{},c=this.__private,u=c.logPrefix,l=c.mocks,f=c.bootOptions,p=c.aliasReplacements,h=c.skipDevToolsCheck,d=f.noWebSocket,v=f.ignorePrefix,k=f.modifyRequest,b=f.noProxy,w=f.prependServerURL,P=f.suiteCookie,_=f.suiteHeader,S=f.port,j=f.portHttps,W=f.host,T=f.mockSuiteResolver,R=f.fetch,$=f.devTools,D=f.devToolsTimeout,C=f.devToolsInterval,H=f.serviceWorker,M=a.dynamicMocks,I=a.dynamicMockSuite,L=a.noProxy,F=void 0===L?b:L,d){e.next=12;break}return e.prev=5,e.next=8,this.connectWebSocket();case 8:e.next=12;break;case 10:e.prev=10,e.t0=e.catch(5);case 12:if(!$||"undefined"==typeof window||h){e.next=18;break}return e.next=15,new Promise((function(e){var t=0,r=setInterval((function(){t+=1,window.__MOCKYEAH_DEVTOOLS_EXTENSION__?(Me.__private.devToolsFound=!0,clearInterval(r),e()):t>D/C&&(Me.__private.skipDevToolsCheck=!0,clearInterval(r),e())}),C)}));case 15:if(!this.__private.devToolsFound){e.next=18;break}return e.next=18,new Promise((function(e){var t=0,r=setInterval((function(){var n;t+=1,((null===(n=window.__MOCKYEAH_DEVTOOLS_EXTENSION__)||void 0===n?void 0:n.loadedMocks)||t>D/C)&&(clearInterval(r),e())}),C)}));case 18:if(N="string"==typeof t?t:t.url,U=r||{},A=(M||[]).map((function(e){return e&&Me.makeMock(e[0],e[1],{keepExisting:!0}).mock})).filter(Boolean),K=Object(y.parse)(N),J=U.headers?U.headers instanceof Headers?U.headers:new Headers(U.headers):void 0,!U.body||"string"==typeof U.body){e.next=26;break}return Se("".concat(u," @mockyeah/fetch does not yet support non-string request bodies, falling back to normal fetch")),e.abrupt("return",this.fallbackFetch(N,r,{noProxy:F}));case 26:if(B=J&&he(J,U.body),V=K.query?x.a.parse(K.query):void 0,X=U.method?U.method.toLowerCase():"get",!U.headers||g()(U.headers)){e.next=32;break}return Se("".concat(u," @mockyeah/fetch does not yet support non-object request headers, falling back to normal fetch")),e.abrupt("return",this.fallbackFetch(N,r,{noProxy:F}));case 32:z=U.headers;try{(Q=z&&(z.cookie||z.Cookie))?G=q.a.parse(Q):"undefined"!=typeof window&&(G=q.a.parse(window.document.cookie))}catch(e){Se("".concat(u," @mockyeah/fetch couldn't parse cookies: ").concat(e.message))}if(!(Z=I||G&&G[P])||!T){e.next=42;break}return ee=Z.split(",").map((function(e){return e.trim()})),te=ee.map(T),e.next=40,Promise.all(te);case 40:e.sent.forEach((function(e,t){var r=ee[t];(e.default||e).forEach((function(e){var t=s()(e,2),n=t[0],o=t[1],a=g()(n)?we({},n):{url:n};a.cookies=we({},a.cookies,{mockSuite:function(e){return!!e&&e.split(",").map((function(e){return e.trim()})).includes(r)}}),A.push(Me.makeMock(a,o,{name:r,keepExisting:!0}).mock)}))}));case 42:if(re={url:N.replace(v,""),query:V,headers:z,body:B,method:X,cookies:G},ne=null!==(n=null==k?void 0:k(re))&&void 0!==n?n:[re],ae=(Array.isArray(ne)?ne:[ne]).map((function(e){return Y(e,!0)})),O()(ae.map((function(e){return[e].concat(i()(g()(e)?O()(p&&Object.entries(p).map((function(t){var r=s()(t,2),n=r[0],o=r[1],a=e.url;return"string"==typeof a&&a.replace(/^\//,"").startsWith(n)?o.map((function(t){return we({},e,{url:a.replace(n,t)})})):[]}))):[]))}))).filter(Boolean).find((function(e){return[].concat(i()(A),i()(l)).find((function(t){if(!t)return!1;var r=s()(t,2),n=r[0],o=r[1],a=E()(e,n,{skipKeys:["$meta"]});return a.result?(ie=t,!0):(_e("".concat(u," @mockyeah/fetch missed mock ").concat(o.name?'"'.concat(o.name,'" '):"","for"),N,a.message,{request:re,match:n}),!1)}))})),ce="".concat(K.protocol?"".concat(K.protocol,"//"):"").concat(K.host||"").concat(K.pathname||"/"),se={url:ce,path:ce,query:V,method:X,headers:z,body:B,cookies:G},!ie){e.next=74;break}if(ie[0]&&ie[0].$meta&&ie[0].$meta.expectation&&ie[0].$meta.expectation.request(se),!(le=ie[1])||!be.some((function(e){return"function"==typeof le[e]&&le[e].length>1}))){e.next=63;break}return e.next=55,this.fallbackFetch(N,U);case 55:return fe=e.sent,e.t1=he,e.t2=fe.headers,e.next=60,fe.text();case 60:e.t3=e.sent,pe=(0,e.t1)(e.t2,e.t3),ue={status:fe.status,body:pe,headers:me(fe.headers)};case 63:return e.next=65,oe(ie,se,f,ue);case 65:return de=e.sent,ve=de.response,ye=de.json,ke=de.body,xe=de.headers,H&&(ge={status:ve.status,body:ke,headers:xe},Te[Oe=We+=1]={response:ge},R(N,we({},U,{headers:we({},U.headers,{"x-mockyeah-service-worker-request":Oe})}))),je=ie,(Ee=s()(je,2))[0],Re=Ee[1],Pe("".concat(u," @mockyeah/fetch matched mock ").concat(Re.name?'"'.concat(Re.name,'" '):"","for"),N,{request:se,response:ve,json:ye,mock:ie}),e.abrupt("return",ve);case 74:return qe("".concat(u," @mockyeah/fetch missed all mocks for"),N,{request:se}),$e="http".concat(j?"s":"","://").concat(W,":").concat(j||S),De=U,w&&$e&&(N="".concat($e,"/").concat(N.replace("://","~~~")),"undefined"!=typeof document&&(He=document.cookie.match("\\b".concat(P,"=([^;]+)\\b")),Ce=He&&He[1]),De=we({},U,{headers:we({},U.headers,{},Ce&&m()({},_,Ce))})),e.abrupt("return",this.fallbackFetch(N,De,{noProxy:F}));case 79:case"end":return e.stop()}}),e,this,[[5,10]])}))),function(e,t){return n.apply(this,arguments)})},{key:"fallbackFetch",value:(r=l()(o.a.mark((function e(t,r){var n,a,i,c,s,u,l,f,p,h,d,v,m,y,k,x,b,g,w,O,P=arguments;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=P.length>2&&void 0!==P[2]?P[2]:{},a=n.noProxy,i=this.__private.bootOptions,c=i.responseHeaders,s=i.fetch,u="string"==typeof t?t:t.url,!a&&u.startsWith("http")){e.next=8;break}return l={},c&&(l["x-mockyeah-missed"]="true"),e.abrupt("return",new Response("",{status:404,headers:l}));case 8:return f=(new Date).getTime(),e.next=11,s(t,r);case 11:return p=e.sent,e.next=14,pe(p);case 14:return h=e.sent,d=this.__private,v=d.ws,d.recording&&(m=p.status,y=me(p.headers),v&&(k={type:"recordPush",payload:{reqUrl:u,req:{method:r&&r.method,body:r&&r.body},startTime:f,body:h,headers:y,status:m}},v.send(JSON.stringify(k)))),c&&(b=(x=p).status,g=x.statusText,w=x.headers,(O=w&&new Headers(w))&&(O.set("x-mockyeah-proxied","true"),O.set("x-mockyeah-missed","true")),p=new Response(h,{headers:O,status:b,statusText:g})),e.abrupt("return",p);case 19:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"expect",value:function(e){return this.all("*").expect(e)}},{key:"all",value:function(e,t){return this.mock(e,t)}},{key:"get",value:function(e,t){return this.mock($e(e,"get"),t)}},{key:"post",value:function(e,t){return this.mock($e(e,"post"),t)}},{key:"put",value:function(e,t){return this.mock($e(e,"put"),t)}},{key:"delete",value:function(e,t){return this.mock($e(e,"delete"),t)}},{key:"options",value:function(e,t){return this.mock($e(e,"options"),t)}},{key:"patch",value:function(e,t){return this.mock($e(e,"patch"),t)}},{key:"reset",value:function(){this.__private.mocks=[]}},{key:"makeMock",value:function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=n.keepExisting,a=n.name,i=Y(e),c=this.__private.mocks,s=[];if(!o){var u,l=c.findIndex((function(e){return Q(i,e[0])}));if(l>=0)r=null!==(u=r)&&void 0!==u?u:l,s.push(c[l]),c.splice(l,1)}var f="string"==typeof t?{name:a,text:t}:we({name:a},t);return f=f||{status:200},i.$meta&&(i.$meta.expectation=new fe(i),i.$meta.id=xe()),{mock:[i,f],removed:s,removedIndex:r}}},{key:"mock",value:function(e,t){var r,n=this.makeMock(e,t),o=n.mock,a=n.removed,i=n.removedIndex,c=null===(r=o[0].$meta)||void 0===r?void 0:r.id,s=this.__private,u=s.mocks,l=s.logPrefix;Oe("".concat(l," mocked"),e,t),null!=i?u.splice(i,0,o):u.push(o);var f=o[0].$meta&&o[0].$meta.expectation,p=a.map((function(e){var t,r;return null===(t=e[0])||void 0===t||null===(r=t.$meta)||void 0===r?void 0:r.id})),h=f.api.bind(f);return{id:c,removedIds:p,expect:function(e){return h(e)}}}},{key:"unmock",value:function(e){var t=this.__private,r=t.mocks,n=t.logPrefix,o=r.findIndex((function(t){var r;return(null===(r=t[0].$meta)||void 0===r?void 0:r.id)===e}));return-1===o?(Oe("".concat(n," didn't find id to unmock"),e),!1):(r.splice(o,1),Oe("".concat(n," unmocked"),e),!0)}},{key:"connectWebSocket",value:(t=l()(o.a.mark((function e(){var t,r,n,a,i=this;return o.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("undefined"!=typeof WebSocket){e.next=2;break}return e.abrupt("return");case 2:if(!this.__private.ws){e.next=4;break}return e.abrupt("return");case 4:t=this.__private.bootOptions,r=t.adminPort,n=t.adminHost,a="ws://".concat(n,":").concat(r),je("WebSocket trying to connect to '".concat(a,"'.")),e.prev=7,this.__private.ws=new WebSocket(a),e.next=16;break;case 11:throw e.prev=11,e.t0=e.catch(7),Ee("WebSocket couldn't connect to '".concat(a,"':"),e.t0),delete this.__private.ws,e.t0;case 16:return e.next=18,new Promise((function(e,t){var r=i.__private.ws;r&&(r.onopen=function(){je("WebSocket opened"),r.send(JSON.stringify({type:"opened"})),e()},r.onerror=function(e){Ee("WebSocket errored",e),t(e)},r.onclose=function(){Ee("WebSocket closed"),i.__private.recording=!1,delete i.__private.ws,t(new Error("WebSocket closed"))},r.onmessage=function(e){var t;je("WebSocket message",e);try{t=JSON.parse(e.data)}catch(t){return void Ee("Couldn't parse WebSocket message data '".concat(e.data,"':"),t)}t&&(je("WebSocket action",t),"record"===t.type?i.__private.recording=!0:"recordStop"===t.type&&(i.__private.recording=!1))})}));case 18:case"end":return e.stop()}}),e,this,[[7,11]])}))),function(){return t.apply(this,arguments)})}]),e}();t.default=Ce}]).default;

@@ -11,2 +11,3 @@ "use strict";

const resOpts = matchingMock[1] || {};
const { name } = resOpts;
const status = (resOpts.status && (await handler(resOpts.status, requestForHandler, res))) || 200;

@@ -17,2 +18,4 @@ let body;

let json;
let fixture;
let filePath;
if (resOpts.fixture) {

@@ -22,3 +25,3 @@ if (!fixtureResolver) {

}
const fixture = await handler(resOpts.fixture, requestForHandler, res);
fixture = await handler(resOpts.fixture, requestForHandler, res);
type = type || fixture; // TODO: Use base name only to conceal file path?

@@ -31,3 +34,3 @@ body = fixture ? await fixtureResolver(fixture) : undefined;

}
const filePath = await handler(resOpts.filePath, requestForHandler, res);
filePath = await handler(resOpts.filePath, requestForHandler, res);
type = type || filePath; // TODO: Use base name only to conceal file path?

@@ -56,2 +59,8 @@ body = filePath ? await fileResolver(filePath) : undefined;

contentType = type ? mime_1.default.getType(type) || type : contentType;
const latency = resOpts.latency || bootOptions.latency;
let latencyActual;
if (latency) {
latencyActual = await handler(latency, requestForHandler, res);
await new Promise(resolve => setTimeout(resolve, latencyActual));
}
const headers = resOpts.headers

@@ -64,2 +73,14 @@ ? {

headers['x-mockyeah-mocked'] = 'true';
if (name) {
headers['x-mockyeah-name'] = name;
}
if (fixture) {
headers['x-mockyeah-fixture'] = fixture;
}
if (filePath) {
headers['x-mockyeah-filePath'] = filePath;
}
if (latencyActual) {
headers['x-mockyeah-latency'] = latencyActual.toString();
}
}

@@ -73,7 +94,2 @@ if (contentType) {

};
const latency = resOpts.latency || bootOptions.latency;
if (latency) {
const latencyActual = await handler(latency, requestForHandler, res);
await new Promise(resolve => setTimeout(resolve, latencyActual));
}
const response = new Response(body, responseInit);

@@ -80,0 +96,0 @@ // eslint-disable-next-line consistent-return

@@ -6,2 +6,3 @@ import pathToRegexp from 'path-to-regexp';

prependServerURL?: boolean;
modifyRequest?: ModifyRequest;
noPolyfill?: boolean;

@@ -40,3 +41,4 @@ noWebSocket?: boolean;

declare type JsonPrimitive = string | number | boolean | null;
declare type Json = JsonPrimitive | JsonPrimitive[] | JsonObject;
declare type Json = JsonPrimitive | JsonPrimitive[] | JsonObject | JsonObject[];
declare type ModifyRequest = (req: RequestForHandler) => RequestForHandler | RequestForHandler[];
interface RequestForHandler {

@@ -60,2 +62,3 @@ url: string;

interface ResponseOptionsObject {
name?: string;
json?: Responder<Json>;

@@ -154,2 +157,3 @@ text?: Responder<string>;

interface MakeMockOptions {
name?: string;
keepExisting?: boolean;

@@ -156,0 +160,0 @@ }

{
"name": "@mockyeah/fetch",
"version": "1.0.0-alpha.10",
"version": "1.0.0",
"description": "fetch integration for mockyeah request mocking utility.",

@@ -17,3 +17,8 @@ "main": "dist/main.js",

},
"repository": "git@github.com:mockyeah/mockyeah.git",
"repository": {
"type": "git",
"url": "git@github.com:mockyeah/mockyeah.git",
"directory": "packages/mockyeah-fetch"
},
"homepage": "https://mockyeah.js.org/Packages/mockyeah-fetch",
"license": "MIT",

@@ -69,3 +74,3 @@ "publishConfig": {

"@babel/register": "^7.8.6",
"@mockyeah/tools": "^1.0.0-alpha.10",
"@mockyeah/tools": "^1.0.0",
"@types/cookie": "^0.3.3",

@@ -104,3 +109,3 @@ "@types/debug": "^4.1.5",

"lodash": "^4.17.15",
"match-deep": "^1.0.0-alpha.10",
"match-deep": "^1.0.0",
"mime": "^2.4.4",

@@ -110,3 +115,3 @@ "path-to-regexp": "^3.1.0",

},
"gitHead": "f246a2453a6d987aedae5398bcbfa71e373dabbc"
"gitHead": "35e5514ac211a784020640089d44aa5bcc993e5e"
}

@@ -10,3 +10,3 @@ # @mockyeah/fetch

More at **https://mockyeah.js.org/Integration.html**.
More at https://mockyeah.js.org/Packages/mockyeah-fetch.

@@ -13,0 +13,0 @@ ## License

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc