Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@microlink/mql

Package Overview
Dependencies
Maintainers
1
Versions
202
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microlink/mql - npm Package Compare versions

Comparing version 0.5.13 to 0.5.15

9

CHANGELOG.md

@@ -5,2 +5,11 @@ # Changelog

### [0.5.15](https://github.com/microlinkhq/mql/compare/v0.5.14...v0.5.15) (2019-12-20)
### Bug Fixes
* only flatten data objects ([1867815](https://github.com/microlinkhq/mql/commit/1867815b9804d02f3f5ba7bda51a4dcb22712faa))
### [0.5.14](https://github.com/microlinkhq/mql/compare/v0.5.13...v0.5.14) (2019-12-04)
### [0.5.13](https://github.com/microlinkhq/mql/compare/v0.5.12...v0.5.13) (2019-11-25)

@@ -7,0 +16,0 @@

26

dist/mql.js

@@ -2460,10 +2460,3 @@ (function (global, factory) {

function factory ({
VERSION,
MicrolinkError,
isUrlHttp,
stringify,
got,
flatten
}) {
function factory ({ VERSION, MicrolinkError, isUrlHttp, stringify, got, flatten }) {
const assertUrl = (url = '') => {

@@ -2483,3 +2476,4 @@ if (!isUrlHttp(url)) {

const mapRules = (rules = {}) => {
const mapRules = rules => {
if (typeof rules !== 'object') return
const flatRules = flatten(rules);

@@ -2510,5 +2504,3 @@ return Object.keys(flatRules).reduce(

if (isTimeoutError(err)) {
const message = `The \`url\` as \`${url}\` reached timeout after ${
opts.retry.maxRetryAfter
}ms.`;
const message = `The \`url\` as \`${url}\` reached timeout after ${opts.retry.maxRetryAfter}ms.`;
throw new MicrolinkError({

@@ -2530,5 +2522,3 @@ url,

: { message: rawMessage, status: 'fail' };
const message = body.data
? body.data[Object.keys(body.data)[0]]
: body.message;
const message = body.data ? body.data[Object.keys(body.data)[0]] : body.message;

@@ -2549,5 +2539,5 @@ throw MicrolinkError({

const apiUrl = `${apiEndpoint}?${stringify({
url: url,
url,
...mapRules(data),
...flatten({ ...opts })
...flatten(opts)
})}`;

@@ -2610,3 +2600,3 @@

flatten: flat,
VERSION: '0.5.13'
VERSION: '0.5.15'
});

@@ -2613,0 +2603,0 @@

@@ -9,3 +9,3 @@ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("url")):"function"==typeof define&&define.amd?define(["url"],t):(e=e||self).mql=t(e.url)}(this,(function(e){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function r(e){return e&&e.default||e}var o,s=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e,r){!function(e){

* @license MIT
*/function k(e){return e}function v(e,t){const r=(t=t||{}).delimiter||".",o=t.maxDepth,s=t.transformKey||k,a={};return function e(n,i,c){c=c||1,Object.keys(n).forEach((function(l){const u=n[l],p=t.safe&&Array.isArray(u),d=Object.prototype.toString.call(u),h=y(u),f="[object Object]"===d||"[object Array]"===d,m=i?i+r+s(l):s(l);if(!p&&!h&&f&&Object.keys(u).length&&(!t.maxDepth||c<o))return e(u,m,c+1);a[m]=u}))}(e),a}v.flatten=v,v.unflatten=function e(t,r){const o=(r=r||{}).delimiter||".",s=r.overwrite||!1,a=r.transformKey||k,n={};if(y(t)||"[object Object]"!==Object.prototype.toString.call(t))return t;function i(e){const t=Number(e);return isNaN(t)||-1!==e.indexOf(".")||r.object?e:t}return t=Object.keys(t).reduce((e,s)=>{const a=Object.prototype.toString.call(t[s]);return!("[object Object]"===a||"[object Array]"===a)||function(e){const t=Object.prototype.toString.call(e),r="[object Array]"===t,o="[object Object]"===t;if(!e)return!0;if(r)return!e.length;if(o)return!Object.keys(e).length}(t[s])?(e[s]=t[s],e):function(e,t,r){return Object.keys(r).reduce((function(t,s){return t[e+o+s]=r[s],t}),t)}(s,e,v(t[s],r))},{}),Object.keys(t).forEach((function(c){const l=c.split(o).map(a);let u=i(l.shift()),p=i(l[0]),d=n;for(;void 0!==p;){const e=Object.prototype.toString.call(d[u]),t="[object Object]"===e||"[object Array]"===e;if(!s&&!t&&void 0!==d[u])return;(s&&!t||!s&&null==d[u])&&(d[u]="number"!=typeof p||r.object?{}:[]),d=d[u],l.length>0&&(u=i(l.shift()),p=i(l[0]))}d[u]=e(t[c],r)})),n};var x=Object.freeze({__proto__:null,default:e=>e});const j=(e,t)=>{for(const r of Reflect.ownKeys(t))Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));return e};var _=j,$=j;_.default=$;var E={isFunction:e=>"function"==typeof e,isString:e=>"string"==typeof e,composeErrorMessage:(e,t)=>`${e}, ${t}`,inherits:(e,t)=>{e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}};const{isFunction:R,composeErrorMessage:z}=E;var q=function(e,...t){Object.assign(e,...t),e.description=R(e.message)?e.message(e):e.message,e.message=e.code?z(e.code,e.description):e.description},O=r(x);const{isString:T}=E;var C=function(e,t){function r(r){const o=new e,s=T(r)?{message:r}:r;return q(o,t,s),o.stack=O(o.stack),o}return r.prototype=e.prototype,_(r,e),r};const{inherits:A}=E,S=/[^0-9a-zA-Z_$]/;var U=function(e){if("string"!=typeof e)throw new TypeError("Expected className to be a string");if(S.test(e))throw new Error("className contains invalid characters");function t(){Object.defineProperty(this,"name",{configurable:!0,value:e,writable:!0}),Error.captureStackTrace(this,this.constructor)}return A(t,Error),_(t,Error),t};const P=e=>(t,r)=>{const o=U(t||e.name);return C(o,r)};var N=P(Error),D=P(TypeError),I=P(RangeError),L=P(EvalError),M=P(SyntaxError),F=P(ReferenceError),B=P(URIError);N.type=D,N.range=I,N.eval=L,N.syntax=M,N.reference=F,N.uri=B;const H={FREE:"https://api.microlink.io",PRO:"https://pro.microlink.io"},K=e=>"TimeoutError"===e.name||"HTTPError"===e.name&&"5"===e.statusCode.toString()[0]||"invalid-json"===e.type;var V=function({VERSION:e,MicrolinkError:t,isUrlHttp:r,stringify:o,got:s,flatten:a}){const n=(e={})=>{const t=a(e);return Object.keys(t).reduce((e,r)=>({...e,[`data.${r}`]:t[r]}),{})},i={encoding:"utf8",cache:!1,retry:3,timeout:3e4,json:!0},c=async(e,r,o={})=>{o={...i,...o};try{const e=await s(r,o),{body:t}=e;return{...t,response:e}}catch(r){const{name:s,statusCode:a=500,body:n,message:i}=r;if(K(r)){const r=`The \`url\` as \`${e}\` reached timeout after ${o.retry.maxRetryAfter}ms.`;throw new t({url:e,data:{url:r},status:"fail",code:"TimeoutError"===s?"ETIMEOUTCLIENT":"ETIMEOUT",message:r,more:"https://microlink.io/docs/api/api-parameters/url",statusCode:a})}const c=n?"string"==typeof n||Buffer.isBuffer(n)?JSON.parse(n):n:{message:i,status:"fail"},l=c.data?c.data[Object.keys(c.data)[0]]:c.message;throw t({...c,message:l,url:e,statusCode:a})}},l=(e,{data:t,apiKey:r,endpoint:s,...i}={})=>{const c=!!r;return[`${s||H[c?"PRO":"FREE"]}?${o({url:e,...n(t),...a({...i})})}`,{headers:c?{"x-api-key":r}:{}}]},u=async(e,o={})=>{((e="")=>{if(!r(e)){const r=`The \`url\` as \`${e}\` is not valid. Ensure it has protocol (http or https) and hostname.`;throw new t({url:e,data:{url:r},status:"fail",code:"EINVALURLCLIENT",message:r,more:"https://microlink.io/docs/api/api-parameters/url"})}})(e);const[s,a]=l(e,o);return c(e,s,{...o,...a})};return u.MicrolinkError=t,u.getApiUrl=l,u.fetchFromApi=c,u.mapRules=n,u.version=e,u.stream=s.stream,u},J=r(i);const{default:W}=a,{encode:Z}=J;return V({MicrolinkError:N("MicrolinkError"),isUrlHttp:e=>{try{const{href:t}=new m(e);return g.test(t)&&b.test(t)}catch(e){return!1}},stringify:Z,got:async(e,{json:t,cache:r,...o})=>{try{const t=await W(e,o),r=await t.json(),{headers:s,status:a,statusText:n}=t;return{url:t.url,body:r,headers:s,statusCode:a,statusMessage:n}}catch(e){throw e.response&&(e.body=await e.response.json(),e.statusCode=e.response.status,e.headers=e.response.headers),e}},flatten:w,VERSION:"0.5.13"})}));
*/function k(e){return e}function v(e,t){const r=(t=t||{}).delimiter||".",o=t.maxDepth,s=t.transformKey||k,a={};return function e(n,i,c){c=c||1,Object.keys(n).forEach((function(l){const u=n[l],p=t.safe&&Array.isArray(u),d=Object.prototype.toString.call(u),h=y(u),f="[object Object]"===d||"[object Array]"===d,m=i?i+r+s(l):s(l);if(!p&&!h&&f&&Object.keys(u).length&&(!t.maxDepth||c<o))return e(u,m,c+1);a[m]=u}))}(e),a}v.flatten=v,v.unflatten=function e(t,r){const o=(r=r||{}).delimiter||".",s=r.overwrite||!1,a=r.transformKey||k,n={};if(y(t)||"[object Object]"!==Object.prototype.toString.call(t))return t;function i(e){const t=Number(e);return isNaN(t)||-1!==e.indexOf(".")||r.object?e:t}return t=Object.keys(t).reduce((e,s)=>{const a=Object.prototype.toString.call(t[s]);return!("[object Object]"===a||"[object Array]"===a)||function(e){const t=Object.prototype.toString.call(e),r="[object Array]"===t,o="[object Object]"===t;if(!e)return!0;if(r)return!e.length;if(o)return!Object.keys(e).length}(t[s])?(e[s]=t[s],e):function(e,t,r){return Object.keys(r).reduce((function(t,s){return t[e+o+s]=r[s],t}),t)}(s,e,v(t[s],r))},{}),Object.keys(t).forEach((function(c){const l=c.split(o).map(a);let u=i(l.shift()),p=i(l[0]),d=n;for(;void 0!==p;){const e=Object.prototype.toString.call(d[u]),t="[object Object]"===e||"[object Array]"===e;if(!s&&!t&&void 0!==d[u])return;(s&&!t||!s&&null==d[u])&&(d[u]="number"!=typeof p||r.object?{}:[]),d=d[u],l.length>0&&(u=i(l.shift()),p=i(l[0]))}d[u]=e(t[c],r)})),n};var x=Object.freeze({__proto__:null,default:e=>e});const j=(e,t)=>{for(const r of Reflect.ownKeys(t))Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r));return e};var _=j,$=j;_.default=$;var E={isFunction:e=>"function"==typeof e,isString:e=>"string"==typeof e,composeErrorMessage:(e,t)=>`${e}, ${t}`,inherits:(e,t)=>{e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}};const{isFunction:R,composeErrorMessage:z}=E;var q=function(e,...t){Object.assign(e,...t),e.description=R(e.message)?e.message(e):e.message,e.message=e.code?z(e.code,e.description):e.description},O=r(x);const{isString:T}=E;var C=function(e,t){function r(r){const o=new e,s=T(r)?{message:r}:r;return q(o,t,s),o.stack=O(o.stack),o}return r.prototype=e.prototype,_(r,e),r};const{inherits:A}=E,S=/[^0-9a-zA-Z_$]/;var U=function(e){if("string"!=typeof e)throw new TypeError("Expected className to be a string");if(S.test(e))throw new Error("className contains invalid characters");function t(){Object.defineProperty(this,"name",{configurable:!0,value:e,writable:!0}),Error.captureStackTrace(this,this.constructor)}return A(t,Error),_(t,Error),t};const P=e=>(t,r)=>{const o=U(t||e.name);return C(o,r)};var N=P(Error),D=P(TypeError),I=P(RangeError),L=P(EvalError),M=P(SyntaxError),F=P(ReferenceError),B=P(URIError);N.type=D,N.range=I,N.eval=L,N.syntax=M,N.reference=F,N.uri=B;const H={FREE:"https://api.microlink.io",PRO:"https://pro.microlink.io"},K=e=>"TimeoutError"===e.name||"HTTPError"===e.name&&"5"===e.statusCode.toString()[0]||"invalid-json"===e.type;var V=function({VERSION:e,MicrolinkError:t,isUrlHttp:r,stringify:o,got:s,flatten:a}){const n=e=>{if("object"!=typeof e)return;const t=a(e);return Object.keys(t).reduce((e,r)=>({...e,[`data.${r}`]:t[r]}),{})},i={encoding:"utf8",cache:!1,retry:3,timeout:3e4,json:!0},c=async(e,r,o={})=>{o={...i,...o};try{const e=await s(r,o),{body:t}=e;return{...t,response:e}}catch(r){const{name:s,statusCode:a=500,body:n,message:i}=r;if(K(r)){const r=`The \`url\` as \`${e}\` reached timeout after ${o.retry.maxRetryAfter}ms.`;throw new t({url:e,data:{url:r},status:"fail",code:"TimeoutError"===s?"ETIMEOUTCLIENT":"ETIMEOUT",message:r,more:"https://microlink.io/docs/api/api-parameters/url",statusCode:a})}const c=n?"string"==typeof n||Buffer.isBuffer(n)?JSON.parse(n):n:{message:i,status:"fail"},l=c.data?c.data[Object.keys(c.data)[0]]:c.message;throw t({...c,message:l,url:e,statusCode:a})}},l=(e,{data:t,apiKey:r,endpoint:s,...i}={})=>{const c=!!r;return[`${s||H[c?"PRO":"FREE"]}?${o({url:e,...n(t),...a(i)})}`,{headers:c?{"x-api-key":r}:{}}]},u=async(e,o={})=>{((e="")=>{if(!r(e)){const r=`The \`url\` as \`${e}\` is not valid. Ensure it has protocol (http or https) and hostname.`;throw new t({url:e,data:{url:r},status:"fail",code:"EINVALURLCLIENT",message:r,more:"https://microlink.io/docs/api/api-parameters/url"})}})(e);const[s,a]=l(e,o);return c(e,s,{...o,...a})};return u.MicrolinkError=t,u.getApiUrl=l,u.fetchFromApi=c,u.mapRules=n,u.version=e,u.stream=s.stream,u},J=r(i);const{default:W}=a,{encode:Z}=J;return V({MicrolinkError:N("MicrolinkError"),isUrlHttp:e=>{try{const{href:t}=new m(e);return g.test(t)&&b.test(t)}catch(e){return!1}},stringify:Z,got:async(e,{json:t,cache:r,...o})=>{try{const t=await W(e,o),r=await t.json(),{headers:s,status:a,statusText:n}=t;return{url:t.url,body:r,headers:s,statusCode:a,statusMessage:n}}catch(e){throw e.response&&(e.body=await e.response.json(),e.statusCode=e.response.status,e.headers=e.response.headers),e}},flatten:w,VERSION:"0.5.15"})}));
//# sourceMappingURL=mql.min.js.map

@@ -5,3 +5,3 @@ {

"homepage": "https://nicedoc.io/microlinkhq/mql",
"version": "0.5.13",
"version": "0.5.15",
"browser": "src/browser.js",

@@ -36,3 +36,3 @@ "main": "src/node.js",

"qss": "~2.0.3",
"whoops": "~4.0.2"
"whoops": "~4.1.0"
},

@@ -39,0 +39,0 @@ "devDependencies": {

@@ -14,10 +14,3 @@ const ENDPOINT = {

function factory ({
VERSION,
MicrolinkError,
isUrlHttp,
stringify,
got,
flatten
}) {
function factory ({ VERSION, MicrolinkError, isUrlHttp, stringify, got, flatten }) {
const assertUrl = (url = '') => {

@@ -37,3 +30,4 @@ if (!isUrlHttp(url)) {

const mapRules = (rules = {}) => {
const mapRules = rules => {
if (typeof rules !== 'object') return
const flatRules = flatten(rules)

@@ -64,5 +58,3 @@ return Object.keys(flatRules).reduce(

if (isTimeoutError(err)) {
const message = `The \`url\` as \`${url}\` reached timeout after ${
opts.retry.maxRetryAfter
}ms.`
const message = `The \`url\` as \`${url}\` reached timeout after ${opts.retry.maxRetryAfter}ms.`
throw new MicrolinkError({

@@ -84,5 +76,3 @@ url,

: { message: rawMessage, status: 'fail' }
const message = body.data
? body.data[Object.keys(body.data)[0]]
: body.message
const message = body.data ? body.data[Object.keys(body.data)[0]] : body.message

@@ -103,5 +93,5 @@ throw MicrolinkError({

const apiUrl = `${apiEndpoint}?${stringify({
url: url,
url,
...mapRules(data),
...flatten({ ...opts })
...flatten(opts)
})}`

@@ -108,0 +98,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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