@merkur/plugin-http-client 0.35.0 → 0.35.13
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/lib/index.cjs +5 -0
- package/lib/index.es9.cjs +4 -0
- package/lib/index.es9.mjs +4 -0
- package/lib/index.js +5 -0
- package/lib/index.mjs +5 -0
- package/lib/index.umd.js +1 -1
- package/package.json +2 -2
package/lib/index.cjs
CHANGED
|
@@ -230,8 +230,13 @@ function copyResponse(response) {
|
|
|
230
230
|
};
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
+
const PROTECTED_FIELDS = ['__proto__', 'prototype', 'constructor'];
|
|
233
234
|
function assign(target, source = {}, parentField = null) {
|
|
234
235
|
for (const field of Object.keys(source)) {
|
|
236
|
+
if (PROTECTED_FIELDS.includes(field)) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
|
|
235
240
|
const value = source[field];
|
|
236
241
|
const fieldPath = parentField ? parentField + '.' + field : field;
|
|
237
242
|
|
package/lib/index.es9.cjs
CHANGED
|
@@ -183,8 +183,12 @@ function copyResponse(response) {
|
|
|
183
183
|
useFinalURL
|
|
184
184
|
};
|
|
185
185
|
}
|
|
186
|
+
const PROTECTED_FIELDS = ['__proto__', 'prototype', 'constructor'];
|
|
186
187
|
function assign(target, source = {}, parentField = null) {
|
|
187
188
|
for (const field of Object.keys(source)) {
|
|
189
|
+
if (PROTECTED_FIELDS.includes(field)) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
188
192
|
const value = source[field];
|
|
189
193
|
const fieldPath = parentField ? parentField + '.' + field : field;
|
|
190
194
|
if (value instanceof Array) {
|
package/lib/index.es9.mjs
CHANGED
|
@@ -181,8 +181,12 @@ function copyResponse(response) {
|
|
|
181
181
|
useFinalURL
|
|
182
182
|
};
|
|
183
183
|
}
|
|
184
|
+
const PROTECTED_FIELDS = ['__proto__', 'prototype', 'constructor'];
|
|
184
185
|
function assign(target, source = {}, parentField = null) {
|
|
185
186
|
for (const field of Object.keys(source)) {
|
|
187
|
+
if (PROTECTED_FIELDS.includes(field)) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
186
190
|
const value = source[field];
|
|
187
191
|
const fieldPath = parentField ? parentField + '.' + field : field;
|
|
188
192
|
if (value instanceof Array) {
|
package/lib/index.js
CHANGED
|
@@ -230,8 +230,13 @@ function copyResponse(response) {
|
|
|
230
230
|
};
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
+
const PROTECTED_FIELDS = ['__proto__', 'prototype', 'constructor'];
|
|
233
234
|
function assign(target, source = {}, parentField = null) {
|
|
234
235
|
for (const field of Object.keys(source)) {
|
|
236
|
+
if (PROTECTED_FIELDS.includes(field)) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
|
|
235
240
|
const value = source[field];
|
|
236
241
|
const fieldPath = parentField ? parentField + '.' + field : field;
|
|
237
242
|
|
package/lib/index.mjs
CHANGED
|
@@ -228,8 +228,13 @@ function copyResponse(response) {
|
|
|
228
228
|
};
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
+
const PROTECTED_FIELDS = ['__proto__', 'prototype', 'constructor'];
|
|
231
232
|
function assign(target, source = {}, parentField = null) {
|
|
232
233
|
for (const field of Object.keys(source)) {
|
|
234
|
+
if (PROTECTED_FIELDS.includes(field)) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
|
|
233
238
|
const value = source[field];
|
|
234
239
|
const fieldPath = parentField ? parentField + '.' + field : field;
|
|
235
240
|
|
package/lib/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){if("function"==typeof define&&define.amd)define("@merkur/plugin-http-client",["exports","@merkur/core"],e);else if("undefined"!=typeof exports)e(exports,require("@merkur/core"));else{var
|
|
1
|
+
!function(t,e){if("function"==typeof define&&define.amd)define("@merkur/plugin-http-client",["exports","@merkur/core"],e);else if("undefined"!=typeof exports)e(exports,require("@merkur/core"));else{var r={exports:{}};e(r.exports,t.Merkur.Core),t.Merkur=t.Merkur||{},t.Merkur.Plugin=t.Merkur.Plugin||{},t.Merkur.Plugin.Httpclient=r.exports}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(t,e){function r(t){return function(t){if(Array.isArray(t))return u(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||i(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,a=[],f=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;f=!1}else for(;!(f=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);f=!0);}catch(t){c=!0,o=t}finally{try{if(!f&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return a}}(t,e)||i(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,e){if(t){if("string"==typeof t)return u(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(t,e):void 0}}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function a(t,e,r,n,o,i,u){try{var a=t[i](u),f=a.value}catch(t){return void r(t)}a.done?e(f):Promise.resolve(f).then(n,o)}function f(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function u(t){a(i,n,o,u,f,"next",t)}function f(t){a(i,n,o,u,f,"throw",t)}u(void 0)}))}}function c(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function l(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?c(Object(r),!0).forEach((function(e){s(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):c(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function s(t,e,r){var o;return o=function(t,e){if("object"!=n(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e||"default");if("object"!=n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(e,"string"),(e="symbol"==n(o)?o:o+"")in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function y(t){return[b(),m(),h()]}function p(t,e,r){return d.apply(this,arguments)}function d(){return d=f((function*(t,e,n){for(var o=arguments.length,u=new Array(o>3?o-3:0),a=3;a<o;a++)u[a-3]=arguments[a];var f,c=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=i(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,a=!0,f=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){f=!0,u=t},f:function(){try{a||null==r.return||r.return()}finally{if(f)throw u}}}}(e);try{for(c.s();!(f=c.n()).done;){var l=f.value;"function"==typeof l[n]&&(u=yield l[n].apply(l,[t].concat(r(u))))}}catch(t){c.e(t)}finally{c.f()}return u})),d.apply(this,arguments)}function m(){return{transformRequest:function(t,e,r){return f((function*(){var t=l({},e),n=e.baseUrl,o=void 0===n?"":n,i=e.path,u=void 0===i?"/":i;e.url?t.url=e.url:t.url="".concat(o.endsWith("/")?o.substring(0,o.length-1):o,"/").concat(u.startsWith("/")?u.substring(1):u);var a=Object.keys(e.query).map((function(t){return[t,e.query[t]].map(encodeURIComponent).join("=")})).join("&"),f=-1!==t.url.indexOf("?");return t.url+=f?a?"&".concat(a):"":a?"?".concat(a):"",[t,r]}))()}}}function b(){return{transformResponse:function(t,e,r){return f((function*(){if(204!==r.status&&"function"==typeof r.json){var t=r.headers.get("content-type"),n=null;n=t&&t.includes("application/json")?yield r.json():yield r.text();var o=v(r);return o.body=n,[e,o]}return[e,r]}))()},transformRequest:function(t,e,r){return f((function*(){var t=e.body,n=e.headers,o=e.method;return t&&"application/json"===(n["Content-Type"]||n["content-type"])&&!["GET","HEAD"].includes(o)?[l(l({},e),{},{body:JSON.stringify(t)}),r]:[e,r]}))()}}}function h(){return{transformRequest:function(t,e,r){return f((function*(){var n=l({},e);if("timeout"in e){var o=new t.$dependencies.AbortController;n.signal=o.signal,n.timeoutTimer=setTimeout((function(){o.abort()}),e.timeout)}return[n,r]}))()},transformResponse:function(t,e,r){return f((function*(){return"timeoutTimer"in e&&clearTimeout(e.timeoutTimer),[e,r]}))()}}}function v(t){var e=t.body,r=t.headers,n=t.ok,o=t.redirected,i=t.status,u=t.statusText,a=t.trailers,f=t.type,c=t.url,l=t.useFinalURL;return{body:j({},e),headers:r,ok:n,redirected:o,status:i,statusText:u,trailers:a,type:f,url:c,useFinalURL:l}}Object.defineProperty(t,"__esModule",{value:!0}),t.copyResponse=v,t.getDefaultTransformers=y,t.httpClientPlugin=function(){return{setup:function(t){return f((function*(){return(0,e.assignMissingKeys)(t,{http:{request:function(t,e){return f((function*(){var r=null,n=l(l({},t.$in.httpClient.defaultConfig),e),i=n.transformers,u=o(yield p(t,i,"transformRequest",n,r),2);n=u[0],r=(r=u[1])||(yield t.$dependencies.fetch(n.url,n));var a=o(yield p(t,i,"transformResponse",n,r),2);return n=a[0],(r=a[1]).ok?{request:n,response:r}:Promise.reject({request:n,response:r})}))()}}}),t.$in.httpClient={defaultConfig:{method:"GET",transformers:y(),headers:{},query:{},timeout:15e3}},t.$dependencies.fetch=function(){if("undefined"==typeof window)return global.fetch;return window.fetch.bind(window)}(),t.$dependencies.AbortController=AbortController,t}))()},create:function(t){return f((function*(){return(0,e.bindWidgetToFunctions)(t,t.http),t}))()}}},t.setDefaultConfig=function(t,e){t.$in.httpClient.defaultConfig=l(l({},t.$in.httpClient.defaultConfig),e)},t.transformBody=b,t.transformQuery=m,t.transformTimeout=h;var g=["__proto__","prototype","constructor"];function j(t){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=0,o=Object.keys(e);n<o.length;n++){var i=o[n];if(g.includes(i))return;var u=e[i],a=r?r+"."+i:i;u instanceof Array?t[i]=u.slice():!(u instanceof Object)||u instanceof Function||u instanceof RegExp?t[i]=u:(t[i]instanceof Object||(t[i]={}),j(t[i],u,a))}return t}}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@merkur/plugin-http-client",
|
|
3
|
-
"version": "0.35.
|
|
3
|
+
"version": "0.35.13",
|
|
4
4
|
"description": "Merkur event emitter plugin.",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"module": "lib/index",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@merkur/core": "*"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "8bb24cc052179aef195e2dd1c4d1a500b9b5ae0f"
|
|
57
57
|
}
|