mockforme 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/mockforme.d.ts +11 -0
- package/dist/mockforme.min.js +1 -1
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ import mockforme from 'mockforme';
|
|
|
26
26
|
```
|
|
27
27
|
* Initialize the SDK using Access Token (Generate access token [here](https://dashboard.mockforme.com/user/token))
|
|
28
28
|
```
|
|
29
|
-
mockforme('<ACCESS_TOKEN>').
|
|
29
|
+
mockforme('<ACCESS_TOKEN>').run();
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
* You can also access mockforme object in your browser from window object:
|
|
@@ -35,7 +35,7 @@ mockforme('<ACCESS_TOKEN>').initialize();
|
|
|
35
35
|
```
|
|
36
36
|
And initialize it directly from window:
|
|
37
37
|
```
|
|
38
|
-
window.mockforme('<ACCESS_TOKEN>').
|
|
38
|
+
window.mockforme('<ACCESS_TOKEN>').run();
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
## Example
|
package/dist/mockforme.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var o=t();for(var r in o)("object"==typeof exports?exports:e)[r]=o[r]}}(this,(function(){return(()=>{"use strict";var e={d:(t,o)=>{for(var r in o)e.o(o,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:o[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var o=t();for(var r in o)("object"==typeof exports?exports:e)[r]=o[r]}}(this,(function(){return(()=>{"use strict";var e={d:(t,o)=>{for(var r in o)e.o(o,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:o[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{mockforme:()=>l});const o=e=>{try{return e?e.toLowerCase():e}catch(e){return console.log(e),null}},r=()=>"undefined"==typeof window,n=function(e,t,o){const n=r();var i;function s(){if(4==i.readyState)if(i.status.toString().match(/^20[0-9]$/)){var e=function(){var e=i.getResponseHeader("Content-Type"),t=i.responseText;if(e){var o=e.split(";");try{switch(o[0]){case"application/json":return JSON.parse(t);default:return t}}catch(e){throw"Unable to convert response header"}}}();t.call(this,e,i)}else o.call(this,i.responseText,i)}function a(e,t){var o=[];for(var r in e)if(e.hasOwnProperty(r)){var n=t?t+"["+r+"]":r,i=e[r];o.push("object"==typeof i?a(i,n):encodeURIComponent(n)+"="+encodeURIComponent(i))}return o.join("&")}return n||(window.XMLHttpRequest?i=new XMLHttpRequest:window.ActiveXObject&&(i=new ActiveXObject("Microsoft.XMLHTTP"))),{request:function(){if(!n){if(window.XMLHttpRequest)i.onload=s;else{if(!window.ActiveXObject)throw"unable to process ajax";i.onreadystatechange=s}var t=a(e.params);if("get"==e.method.toLowerCase()&&"object"==typeof e.params){if(-1==e.url.indexOf("?"))e.url+="?";else{var o=e.url.split("?");o[1]&&o[1].split("=")[1]&&(e.url+="&")}e.url+=t}e.hasOwnProperty("async")||(e.async=!0),i.open(e.method,e.url,e.async),e.headers&&function(e){for(let t in e)i.setRequestHeader(t,e[t])}(e.headers),i.send(t)}}}},i=(e,t)=>{const o=e.split("/"),r=t.split("/");if(o.length!==r.length)return!1;for(let e=0;e<o.length;e++){const t=o[e];if(t!==r[e]&&":any"!==t)return!1}return!0},s=e=>{if(r())return;const t="https://dashboard.mockforme.com",s=`${t}/mockforme`,a=`${t}/gateway/_mfm_`,c="mockforme";let l=[];const u=window.location,d=u.protocol;if(u.host,u.port,!e)throw"mockforme token cannot be null";const p=(e,t="get")=>{let r=null;if(!Array.isArray(l))return r;for(let n=0;n<l.length;n++){const s=l[n];if(o(s.apiMethod)===o(t)&&(s.apiEndpoint===e||i(s.apiEndpoint,e))){r={url:e,method:s.apiMethod},s._ri_&&(r._ri_=s._ri_);break}}return r},f=()=>{(()=>{const t=window.fetch;window.fetch=function(o,r={}){r.method||(r.method="get");let n=arguments;o&&(o.startsWith("//")?o=`${window.location.protocol}${o}`:o.startsWith("/")&&(o=`${window.location.origin}${o}`));const i=new URL(o),a=i&&i.pathname,l=i&&i.search,u=p(a,r.method);return u&&(o=`${s}${u.url}${l}`,n[0]=o,r.headers={[c]:e},u&&u._ri_&&(r.headers._ri_=u._ri_)),t.call(this,o,r)}})(),(()=>{let t=window.XMLHttpRequest.prototype.open;window.XMLHttpRequest.prototype.open=function(o,r,n,i,a){try{r&&(r.startsWith("//")?r=`${window.location.protocol}${r}`:r.startsWith("/")?r=`${window.location.origin}${r}`:r.indexOf("://")>-1||(r=`${d}//${r}`));const n=new URL(r),i=n&&n.pathname,a=n&&n.search;let l=arguments;const u=p(i,o);return u&&(l[1]=`${s}${u.url}${a}`),this.onreadystatechange=function(){1==this.readyState&&(this.setRequestHeader(c,e),u&&u._ri_&&this.setRequestHeader("_ri_",u._ri_))},t.apply(this,l)}catch(e){return console.log("Error in mock api, could be invalid url",e),t.apply(this,arguments)}}})()};return{run:e=>{var t;f(),t=t=>{e&&e(t)},n({method:"get",url:a,async:!1},(e=>{var o;e&&(o=e,l=l.concat(o)),t(e)}),(()=>{console.log("Error in loading mocked apis")})).request()}}},a=r();a||(window.mockforme=s);let c=s;a&&(c=e=>({run:()=>{console.log("node mockforme(t).run()")}}));const l=c;return t})()}));
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mockforme",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "mockforme client integration kit. Intercept APIs & get mock responses. Integrate mockforme SDK with your codebase in seconds",
|
|
5
5
|
"main": "dist/mockforme.min.js",
|
|
6
|
+
"typings": "dist/mockforme.d.ts",
|
|
6
7
|
"files": [
|
|
7
8
|
"dist/*"
|
|
8
9
|
],
|
|
@@ -15,7 +16,9 @@
|
|
|
15
16
|
"mock multiple responses",
|
|
16
17
|
"api response",
|
|
17
18
|
"visitor prioritization",
|
|
18
|
-
"throttle api"
|
|
19
|
+
"throttle api",
|
|
20
|
+
"mockforme",
|
|
21
|
+
"mock for me"
|
|
19
22
|
],
|
|
20
23
|
"scripts": {
|
|
21
24
|
"build": "webpack"
|
|
@@ -24,7 +27,5 @@
|
|
|
24
27
|
"license": "ISC",
|
|
25
28
|
"homepage": "https://www.mockforme.com",
|
|
26
29
|
"dependencies": {},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
+
"devDependencies": {}
|
|
30
31
|
}
|