@microlink/mql 0.10.18 → 0.10.21
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/dist/mql.js +436 -422
- package/dist/mql.js.map +1 -1
- package/dist/mql.min.js +2 -2
- package/dist/mql.min.js.map +1 -1
- package/package.json +10 -10
- package/src/browser.js +4 -4
- package/src/factory.js +11 -5
- package/src/ky.js +7 -1
- package/src/node.js +4 -2
package/dist/mql.min.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mql.min.js","sources":["../node_modules/.pnpm/is-url-http@2.2.7/node_modules/is-url-http/lightweight.js","../node_modules/.pnpm/flattie@1.1.0/node_modules/flattie/dist/index.js","../node_modules/.pnpm/qss@2.0.3/node_modules/qss/dist/qss.m.js","../node_modules/.pnpm/mimic-fn@3.0.0/node_modules/mimic-fn/index.js","../node_modules/.pnpm/whoops@4.1.0/node_modules/whoops/lib/helpers.js","../node_modules/.pnpm/whoops@4.1.0/node_modules/whoops/lib/add-error-props.js","../node_modules/.pnpm/whoops@4.1.0/node_modules/whoops/lib/create-extend-error.js","../node_modules/.pnpm/whoops@4.1.0/node_modules/whoops/lib/create-error.js","../node_modules/.pnpm/whoops@4.1.0/node_modules/whoops/lib/index.js","../src/factory.js","../src/ky.js","../src/browser.js"],"sourcesContent":["'use strict'\n\nconst URL = global.window ? window.URL : require('url').URL\nconst REGEX_HTTP_PROTOCOL = /^https?:\\/\\//i\n\nmodule.exports = url => {\n try {\n return REGEX_HTTP_PROTOCOL.test(new URL(url).href)\n } catch (err) {\n return false\n }\n}\n","function iter(output, nullish, sep, val, key) {\n\tvar k, pfx = key ? (key + sep) : key;\n\n\tif (val == null) {\n\t\tif (nullish) output[key] = val;\n\t} else if (typeof val != 'object') {\n\t\toutput[key] = val;\n\t} else if (Array.isArray(val)) {\n\t\tfor (k=0; k < val.length; k++) {\n\t\t\titer(output, nullish, sep, val[k], pfx + k);\n\t\t}\n\t} else {\n\t\tfor (k in val) {\n\t\t\titer(output, nullish, sep, val[k], pfx + k);\n\t\t}\n\t}\n}\n\nfunction flattie(input, glue, toNull) {\n\tvar output = {};\n\tif (typeof input == 'object') {\n\t\titer(output, !!toNull, glue || '.', input, '');\n\t}\n\treturn output;\n}\n\nexports.flattie = flattie;","export function encode(obj, pfx) {\n\tvar k, i, tmp, str='';\n\n\tfor (k in obj) {\n\t\tif ((tmp = obj[k]) !== void 0) {\n\t\t\tif (Array.isArray(tmp)) {\n\t\t\t\tfor (i=0; i < tmp.length; i++) {\n\t\t\t\t\tstr && (str += '&');\n\t\t\t\t\tstr += encodeURIComponent(k) + '=' + encodeURIComponent(tmp[i]);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tstr && (str += '&');\n\t\t\t\tstr += encodeURIComponent(k) + '=' + encodeURIComponent(tmp);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn (pfx || '') + str;\n}\n\nfunction toValue(mix) {\n\tif (!mix) return '';\n\tvar str = decodeURIComponent(mix);\n\tif (str === 'false') return false;\n\tif (str === 'true') return true;\n\treturn (+str * 0 === 0) ? (+str) : str;\n}\n\nexport function decode(str) {\n\tvar tmp, k, out={}, arr=str.split('&');\n\n\twhile (tmp = arr.shift()) {\n\t\ttmp = tmp.split('=');\n\t\tk = tmp.shift();\n\t\tif (out[k] !== void 0) {\n\t\t\tout[k] = [].concat(out[k], toValue(tmp.shift()));\n\t\t} else {\n\t\t\tout[k] = toValue(tmp.shift());\n\t\t}\n\t}\n\n\treturn out;\n}\n","'use strict';\n\nconst copyProperty = (to, from, property, ignoreNonConfigurable) => {\n\t// `Function#length` should reflect the parameters of `to` not `from` since we keep its body.\n\t// `Function#prototype` is non-writable and non-configurable so can never be modified.\n\tif (property === 'length' || property === 'prototype') {\n\t\treturn;\n\t}\n\n\tconst toDescriptor = Object.getOwnPropertyDescriptor(to, property);\n\tconst fromDescriptor = Object.getOwnPropertyDescriptor(from, property);\n\n\tif (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {\n\t\treturn;\n\t}\n\n\tObject.defineProperty(to, property, fromDescriptor);\n};\n\n// `Object.defineProperty()` throws if the property exists, is not configurable and either:\n// - one its descriptors is changed\n// - it is non-writable and its value is changed\nconst canCopyProperty = function (toDescriptor, fromDescriptor) {\n\treturn toDescriptor === undefined || toDescriptor.configurable || (\n\t\ttoDescriptor.writable === fromDescriptor.writable &&\n\t\ttoDescriptor.enumerable === fromDescriptor.enumerable &&\n\t\ttoDescriptor.configurable === fromDescriptor.configurable &&\n\t\t(toDescriptor.writable || toDescriptor.value === fromDescriptor.value)\n\t);\n};\n\nconst changePrototype = (to, from) => {\n\tconst fromPrototype = Object.getPrototypeOf(from);\n\tif (fromPrototype === Object.getPrototypeOf(to)) {\n\t\treturn;\n\t}\n\n\tObject.setPrototypeOf(to, fromPrototype);\n};\n\nconst wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/\\n${fromBody}`;\n\nconst toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, 'toString');\nconst toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, 'name');\n\n// We call `from.toString()` early (not lazily) to ensure `from` can be garbage collected.\n// We use `bind()` instead of a closure for the same reason.\n// Calling `from.toString()` early also allows caching it in case `to.toString()` is called several times.\nconst changeToString = (to, from, name) => {\n\tconst withName = name === '' ? '' : `with ${name.trim()}() `;\n\tconst newToString = wrappedToString.bind(null, withName, from.toString());\n\t// Ensure `to.toString.toString` is non-enumerable and has the same `same`\n\tObject.defineProperty(newToString, 'name', toStringName);\n\tObject.defineProperty(to, 'toString', {...toStringDescriptor, value: newToString});\n};\n\nconst mimicFn = (to, from, {ignoreNonConfigurable = false} = {}) => {\n\tconst {name} = to;\n\n\tfor (const property of Reflect.ownKeys(from)) {\n\t\tcopyProperty(to, from, property, ignoreNonConfigurable);\n\t}\n\n\tchangePrototype(to, from);\n\tchangeToString(to, from, name);\n\n\treturn to;\n};\n\nmodule.exports = mimicFn;\n","'use strict'\n\nmodule.exports = {\n isFunction: obj => typeof obj === 'function',\n isString: obj => typeof obj === 'string',\n composeErrorMessage: (code, description) => `${code}, ${description}`,\n inherits: (ctor, superCtor) => {\n ctor.super_ = superCtor\n ctor.prototype = Object.create(superCtor.prototype, {\n constructor: {\n value: ctor,\n enumerable: false,\n writable: true,\n configurable: true\n }\n })\n }\n}\n","'use strict'\n\nconst {isFunction, composeErrorMessage} = require('./helpers')\n\nfunction interfaceObject (error, ...props) {\n Object.assign(error, ...props)\n\n error.description = isFunction(error.message) ? error.message(error) : error.message\n\n error.message = error.code\n ? composeErrorMessage(error.code, error.description)\n : error.description\n}\n\nmodule.exports = interfaceObject\n","'use strict'\n\nconst cleanStack = require('clean-stack')\nconst mimicFn = require('mimic-fn')\n\nconst addErrorProps = require('./add-error-props')\nconst {isString} = require('./helpers')\n\nfunction createExtendError (ErrorClass, classProps) {\n function ExtendError (props) {\n const error = new ErrorClass()\n const errorProps = isString(props) ? {message: props} : props\n addErrorProps(error, classProps, errorProps)\n\n error.stack = cleanStack(error.stack)\n return error\n }\n\n ExtendError.prototype = ErrorClass.prototype\n mimicFn(ExtendError, ErrorClass)\n\n return ExtendError\n}\n\nmodule.exports = createExtendError\n","'use strict'\n\nconst {inherits} = require('./helpers')\nconst mimicFn = require('mimic-fn')\n\nconst REGEX_CLASS_NAME = /[^0-9a-zA-Z_$]/\n\nfunction createError (className) {\n if (typeof className !== 'string') {\n throw new TypeError('Expected className to be a string')\n }\n\n if (REGEX_CLASS_NAME.test(className)) {\n throw new Error('className contains invalid characters')\n }\n\n function ErrorClass () {\n Object.defineProperty(this, 'name', {\n configurable: true,\n value: className,\n writable: true\n })\n\n Error.captureStackTrace(this, this.constructor)\n }\n\n inherits(ErrorClass, Error)\n mimicFn(ErrorClass, Error)\n return ErrorClass\n}\n\nmodule.exports = createError\n","'use strict'\n\nconst createExtendError = require('./create-extend-error')\nconst createError = require('./create-error')\n\nconst createErrorClass = ErrorClass => (className, props) => {\n const errorClass = createError(className || ErrorClass.name)\n return createExtendError(errorClass, props)\n}\n\nmodule.exports = createErrorClass(Error)\nmodule.exports.type = createErrorClass(TypeError)\nmodule.exports.range = createErrorClass(RangeError)\nmodule.exports.eval = createErrorClass(EvalError)\nmodule.exports.syntax = createErrorClass(SyntaxError)\nmodule.exports.reference = createErrorClass(ReferenceError)\nmodule.exports.uri = createErrorClass(URIError)\n","const ENDPOINT = {\n FREE: 'https://api.microlink.io',\n PRO: 'https://pro.microlink.io'\n}\n\nconst isObject = input => input !== null && typeof input === 'object'\n\nconst parseBody = (input, error, url) => {\n try {\n return JSON.parse(input)\n } catch (_) {\n const message = input || error.message\n\n return {\n status: 'error',\n data: { url: message },\n more: 'https://microlink.io/efatalclient',\n code: 'EFATALCLIENT',\n message,\n url\n }\n }\n}\n\nconst factory = ({\n VERSION,\n MicrolinkError,\n isUrlHttp,\n stringify,\n got,\n flatten\n}) => {\n const assertUrl = (url = '') => {\n if (!isUrlHttp(url)) {\n const message = `The \\`url\\` as \\`${url}\\` is not valid. Ensure it has protocol (http or https) and hostname.`\n throw new MicrolinkError({\n status: 'fail',\n data: { url: message },\n more: 'https://microlink.io/docs/api/api-parameters/url',\n code: 'EINVALURLCLIENT',\n message,\n url\n })\n }\n }\n\n const mapRules = rules => {\n if (!isObject(rules)) return\n const flatRules = flatten(rules)\n return Object.keys(flatRules).reduce((acc, key) => {\n acc[`data.${key}`] = flatRules[key].toString()\n return acc\n }, {})\n }\n\n const fetchFromApi = async (apiUrl, opts = {}, retryCount = 0) => {\n try {\n const response = await got(apiUrl, opts)\n return opts.responseType === 'buffer'\n ? { body: response.body, response }\n : { ...response.body, response }\n } catch (err) {\n const { response = {} } = err\n const { statusCode, body: rawBody, headers, url: uri = apiUrl } = response\n const isBuffer = Buffer.isBuffer(rawBody)\n\n const body =\n isObject(rawBody) && !isBuffer\n ? rawBody\n : parseBody(isBuffer ? rawBody.toString() : rawBody, err, uri)\n\n if (body.code === 'EFATALCLIENT' && retryCount++ < 2) {\n return fetchFromApi(apiUrl, opts, retryCount)\n }\n\n throw MicrolinkError({\n ...body,\n message: body.message,\n url: uri,\n statusCode,\n headers\n })\n }\n }\n\n const getApiUrl = (\n url,\n { data, apiKey, endpoint, retry, cache, ...opts } = {},\n { responseType = 'json', headers: gotHeaders, ...gotOpts } = {}\n ) => {\n const isPro = !!apiKey\n const apiEndpoint = endpoint || ENDPOINT[isPro ? 'PRO' : 'FREE']\n\n const apiUrl = `${apiEndpoint}?${stringify({\n url,\n ...mapRules(data),\n ...flatten(opts)\n })}`\n\n const headers = isPro\n ? { ...gotHeaders, 'x-api-key': apiKey }\n : { ...gotHeaders }\n return [apiUrl, { ...gotOpts, responseType, cache, retry, headers }]\n }\n\n const createMql = defaultOpts => async (url, opts, gotOpts) => {\n assertUrl(url)\n const [apiUrl, fetchOpts] = getApiUrl(url, opts, {\n ...defaultOpts,\n ...gotOpts\n })\n return fetchFromApi(apiUrl, fetchOpts)\n }\n\n const mql = createMql()\n mql.MicrolinkError = MicrolinkError\n mql.getApiUrl = getApiUrl\n mql.fetchFromApi = fetchFromApi\n mql.mapRules = mapRules\n mql.version = VERSION\n mql.stream = got.stream\n mql.buffer = createMql({ responseType: 'buffer' })\n\n return mql\n}\n\nmodule.exports = factory\n","(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :\n typeof define === 'function' && define.amd ? define(['exports'], factory) :\n (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ky = {}));\n})(this, (function (exports) { 'use strict';\n\n // eslint-lint-disable-next-line @typescript-eslint/naming-convention\n class HTTPError extends Error {\n constructor(response, request, options) {\n const code = (response.status || response.status === 0) ? response.status : '';\n const title = response.statusText || '';\n const status = `${code} ${title}`.trim();\n const reason = status ? `status code ${status}` : 'an unknown error';\n super(`Request failed with ${reason}`);\n this.name = 'HTTPError';\n this.response = response;\n this.request = request;\n this.options = options;\n }\n }\n\n class TimeoutError extends Error {\n constructor(request) {\n super('Request timed out');\n this.name = 'TimeoutError';\n this.request = request;\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-types\n const isObject = (value) => value !== null && typeof value === 'object';\n\n const validateAndMerge = (...sources) => {\n for (const source of sources) {\n if ((!isObject(source) || Array.isArray(source)) && typeof source !== 'undefined') {\n throw new TypeError('The `options` argument must be an object');\n }\n }\n return deepMerge({}, ...sources);\n };\n const mergeHeaders = (source1 = {}, source2 = {}) => {\n const result = new globalThis.Headers(source1);\n const isHeadersInstance = source2 instanceof globalThis.Headers;\n const source = new globalThis.Headers(source2);\n for (const [key, value] of source.entries()) {\n if ((isHeadersInstance && value === 'undefined') || value === undefined) {\n result.delete(key);\n }\n else {\n result.set(key, value);\n }\n }\n return result;\n };\n // TODO: Make this strongly-typed (no `any`).\n const deepMerge = (...sources) => {\n let returnValue = {};\n let headers = {};\n for (const source of sources) {\n if (Array.isArray(source)) {\n if (!Array.isArray(returnValue)) {\n returnValue = [];\n }\n returnValue = [...returnValue, ...source];\n }\n else if (isObject(source)) {\n for (let [key, value] of Object.entries(source)) {\n if (isObject(value) && key in returnValue) {\n value = deepMerge(returnValue[key], value);\n }\n returnValue = { ...returnValue, [key]: value };\n }\n if (isObject(source.headers)) {\n headers = mergeHeaders(headers, source.headers);\n returnValue.headers = headers;\n }\n }\n }\n return returnValue;\n };\n\n const supportsAbortController = typeof globalThis.AbortController === 'function';\n const supportsStreams = typeof globalThis.ReadableStream === 'function';\n const supportsFormData = typeof globalThis.FormData === 'function';\n const requestMethods = ['get', 'post', 'put', 'patch', 'head', 'delete'];\n const responseTypes = {\n json: 'application/json',\n text: 'text/*',\n formData: 'multipart/form-data',\n arrayBuffer: '*/*',\n blob: '*/*',\n };\n // The maximum value of a 32bit int (see issue #117)\n const maxSafeTimeout = 2147483647;\n const stop = Symbol('stop');\n\n const normalizeRequestMethod = (input) => requestMethods.includes(input) ? input.toUpperCase() : input;\n const retryMethods = ['get', 'put', 'head', 'delete', 'options', 'trace'];\n const retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];\n const retryAfterStatusCodes = [413, 429, 503];\n const defaultRetryOptions = {\n limit: 2,\n methods: retryMethods,\n statusCodes: retryStatusCodes,\n afterStatusCodes: retryAfterStatusCodes,\n maxRetryAfter: Number.POSITIVE_INFINITY,\n };\n const normalizeRetryOptions = (retry = {}) => {\n if (typeof retry === 'number') {\n return {\n ...defaultRetryOptions,\n limit: retry,\n };\n }\n if (retry.methods && !Array.isArray(retry.methods)) {\n throw new Error('retry.methods must be an array');\n }\n if (retry.statusCodes && !Array.isArray(retry.statusCodes)) {\n throw new Error('retry.statusCodes must be an array');\n }\n return {\n ...defaultRetryOptions,\n ...retry,\n afterStatusCodes: retryAfterStatusCodes,\n };\n };\n\n // `Promise.race()` workaround (#91)\n const timeout = async (request, abortController, options) => new Promise((resolve, reject) => {\n const timeoutId = setTimeout(() => {\n if (abortController) {\n abortController.abort();\n }\n reject(new TimeoutError(request));\n }, options.timeout);\n /* eslint-disable promise/prefer-await-to-then */\n void options\n .fetch(request)\n .then(resolve)\n .catch(reject)\n .then(() => {\n clearTimeout(timeoutId);\n });\n /* eslint-enable promise/prefer-await-to-then */\n });\n const delay = async (ms) => new Promise(resolve => {\n setTimeout(resolve, ms);\n });\n\n class Ky {\n // eslint-disable-next-line complexity\n constructor(input, options = {}) {\n var _a, _b;\n this._retryCount = 0;\n this._input = input;\n this._options = {\n // TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208\n credentials: this._input.credentials || 'same-origin',\n ...options,\n headers: mergeHeaders(this._input.headers, options.headers),\n hooks: deepMerge({\n beforeRequest: [],\n beforeRetry: [],\n afterResponse: [],\n }, options.hooks),\n method: normalizeRequestMethod((_a = options.method) !== null && _a !== void 0 ? _a : this._input.method),\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n prefixUrl: String(options.prefixUrl || ''),\n retry: normalizeRetryOptions(options.retry),\n throwHttpErrors: options.throwHttpErrors !== false,\n timeout: typeof options.timeout === 'undefined' ? 10000 : options.timeout,\n fetch: (_b = options.fetch) !== null && _b !== void 0 ? _b : globalThis.fetch.bind(globalThis),\n };\n if (typeof this._input !== 'string' && !(this._input instanceof URL || this._input instanceof globalThis.Request)) {\n throw new TypeError('`input` must be a string, URL, or Request');\n }\n if (this._options.prefixUrl && typeof this._input === 'string') {\n if (this._input.startsWith('/')) {\n throw new Error('`input` must not begin with a slash when using `prefixUrl`');\n }\n if (!this._options.prefixUrl.endsWith('/')) {\n this._options.prefixUrl += '/';\n }\n this._input = this._options.prefixUrl + this._input;\n }\n if (supportsAbortController) {\n this.abortController = new globalThis.AbortController();\n if (this._options.signal) {\n this._options.signal.addEventListener('abort', () => {\n this.abortController.abort();\n });\n }\n this._options.signal = this.abortController.signal;\n }\n this.request = new globalThis.Request(this._input, this._options);\n if (this._options.searchParams) {\n // eslint-disable-next-line unicorn/prevent-abbreviations\n const textSearchParams = typeof this._options.searchParams === 'string'\n ? this._options.searchParams.replace(/^\\?/, '')\n : new URLSearchParams(this._options.searchParams).toString();\n // eslint-disable-next-line unicorn/prevent-abbreviations\n const searchParams = '?' + textSearchParams;\n const url = this.request.url.replace(/(?:\\?.*?)?(?=#|$)/, searchParams);\n // To provide correct form boundary, Content-Type header should be deleted each time when new Request instantiated from another one\n if (((supportsFormData && this._options.body instanceof globalThis.FormData)\n || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers['content-type'])) {\n this.request.headers.delete('content-type');\n }\n this.request = new globalThis.Request(new globalThis.Request(url, this.request), this._options);\n }\n if (this._options.json !== undefined) {\n this._options.body = JSON.stringify(this._options.json);\n this.request.headers.set('content-type', 'application/json');\n this.request = new globalThis.Request(this.request, { body: this._options.body });\n }\n }\n // eslint-disable-next-line @typescript-eslint/promise-function-async\n static create(input, options) {\n const ky = new Ky(input, options);\n const fn = async () => {\n if (ky._options.timeout > maxSafeTimeout) {\n throw new RangeError(`The \\`timeout\\` option cannot be greater than ${maxSafeTimeout}`);\n }\n // Delay the fetch so that body method shortcuts can set the Accept header\n await Promise.resolve();\n let response = await ky._fetch();\n for (const hook of ky._options.hooks.afterResponse) {\n // eslint-disable-next-line no-await-in-loop\n const modifiedResponse = await hook(ky.request, ky._options, ky._decorateResponse(response.clone()));\n if (modifiedResponse instanceof globalThis.Response) {\n response = modifiedResponse;\n }\n }\n ky._decorateResponse(response);\n if (!response.ok && ky._options.throwHttpErrors) {\n throw new HTTPError(response, ky.request, ky._options);\n }\n // If `onDownloadProgress` is passed, it uses the stream API internally\n /* istanbul ignore next */\n if (ky._options.onDownloadProgress) {\n if (typeof ky._options.onDownloadProgress !== 'function') {\n throw new TypeError('The `onDownloadProgress` option must be a function');\n }\n if (!supportsStreams) {\n throw new Error('Streams are not supported in your environment. `ReadableStream` is missing.');\n }\n return ky._stream(response.clone(), ky._options.onDownloadProgress);\n }\n return response;\n };\n const isRetriableMethod = ky._options.retry.methods.includes(ky.request.method.toLowerCase());\n const result = (isRetriableMethod ? ky._retry(fn) : fn());\n for (const [type, mimeType] of Object.entries(responseTypes)) {\n result[type] = async () => {\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n ky.request.headers.set('accept', ky.request.headers.get('accept') || mimeType);\n const response = (await result).clone();\n if (type === 'json') {\n if (response.status === 204) {\n return '';\n }\n if (options.parseJson) {\n return options.parseJson(await response.text());\n }\n }\n return response[type]();\n };\n }\n return result;\n }\n _calculateRetryDelay(error) {\n this._retryCount++;\n if (this._retryCount < this._options.retry.limit && !(error instanceof TimeoutError)) {\n if (error instanceof HTTPError) {\n if (!this._options.retry.statusCodes.includes(error.response.status)) {\n return 0;\n }\n const retryAfter = error.response.headers.get('Retry-After');\n if (retryAfter && this._options.retry.afterStatusCodes.includes(error.response.status)) {\n let after = Number(retryAfter);\n if (Number.isNaN(after)) {\n after = Date.parse(retryAfter) - Date.now();\n }\n else {\n after *= 1000;\n }\n if (typeof this._options.retry.maxRetryAfter !== 'undefined' && after > this._options.retry.maxRetryAfter) {\n return 0;\n }\n return after;\n }\n if (error.response.status === 413) {\n return 0;\n }\n }\n const BACKOFF_FACTOR = 0.3;\n return BACKOFF_FACTOR * (2 ** (this._retryCount - 1)) * 1000;\n }\n return 0;\n }\n _decorateResponse(response) {\n if (this._options.parseJson) {\n response.json = async () => this._options.parseJson(await response.text());\n }\n return response;\n }\n async _retry(fn) {\n try {\n return await fn();\n // eslint-disable-next-line @typescript-eslint/no-implicit-any-catch\n }\n catch (error) {\n const ms = Math.min(this._calculateRetryDelay(error), maxSafeTimeout);\n if (ms !== 0 && this._retryCount > 0) {\n await delay(ms);\n for (const hook of this._options.hooks.beforeRetry) {\n // eslint-disable-next-line no-await-in-loop\n const hookResult = await hook({\n request: this.request,\n options: this._options,\n error: error,\n retryCount: this._retryCount,\n });\n // If `stop` is returned from the hook, the retry process is stopped\n if (hookResult === stop) {\n return;\n }\n }\n return this._retry(fn);\n }\n throw error;\n }\n }\n async _fetch() {\n for (const hook of this._options.hooks.beforeRequest) {\n // eslint-disable-next-line no-await-in-loop\n const result = await hook(this.request, this._options);\n if (result instanceof Request) {\n this.request = result;\n break;\n }\n if (result instanceof Response) {\n return result;\n }\n }\n if (this._options.timeout === false) {\n return this._options.fetch(this.request.clone());\n }\n return timeout(this.request.clone(), this.abortController, this._options);\n }\n /* istanbul ignore next */\n _stream(response, onDownloadProgress) {\n const totalBytes = Number(response.headers.get('content-length')) || 0;\n let transferredBytes = 0;\n return new globalThis.Response(new globalThis.ReadableStream({\n async start(controller) {\n const reader = response.body.getReader();\n if (onDownloadProgress) {\n onDownloadProgress({ percent: 0, transferredBytes: 0, totalBytes }, new Uint8Array());\n }\n async function read() {\n const { done, value } = await reader.read();\n if (done) {\n controller.close();\n return;\n }\n if (onDownloadProgress) {\n transferredBytes += value.byteLength;\n const percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;\n onDownloadProgress({ percent, transferredBytes, totalBytes }, value);\n }\n controller.enqueue(value);\n await read();\n }\n await read();\n },\n }));\n }\n }\n\n /*! MIT License © Sindre Sorhus */\n const createInstance = (defaults) => {\n // eslint-disable-next-line @typescript-eslint/promise-function-async\n const ky = (input, options) => Ky.create(input, validateAndMerge(defaults, options));\n for (const method of requestMethods) {\n // eslint-disable-next-line @typescript-eslint/promise-function-async\n ky[method] = (input, options) => Ky.create(input, validateAndMerge(defaults, options, { method }));\n }\n ky.create = (newDefaults) => createInstance(validateAndMerge(newDefaults));\n ky.extend = (newDefaults) => createInstance(validateAndMerge(defaults, newDefaults));\n ky.stop = stop;\n return ky;\n };\n const ky = createInstance();\n\n exports.HTTPError = HTTPError;\n exports.TimeoutError = TimeoutError;\n exports[\"default\"] = ky;\n\n Object.defineProperty(exports, '__esModule', { value: true });\n\n}));\n","'use strict'\n\nconst isUrlHttp = require('is-url-http/lightweight')\nconst { flattie: flatten } = require('flattie')\nconst { encode: stringify } = require('qss')\nconst whoops = require('whoops')\n\nconst factory = require('./factory')\nconst { default: ky } = require('./ky')\n\nconst MicrolinkError = whoops('MicrolinkError')\n\nconst got = async (url, opts) => {\n try {\n if (opts.timeout === undefined) opts.timeout = false\n const response = await ky(url, opts)\n const body = await response.json()\n const { headers, status: statusCode, statusText: statusMessage } = response\n return { url: response.url, body, headers, statusCode, statusMessage }\n } catch (err) {\n if (err.response) {\n const { response } = err\n err.response = {\n ...response,\n headers: Array.from(response.headers.entries()).reduce(\n (acc, [key, value]) => {\n acc[key] = value\n return acc\n },\n {}\n ),\n statusCode: response.status,\n body: await response.text()\n }\n }\n throw err\n }\n}\n\nmodule.exports = factory({\n MicrolinkError,\n isUrlHttp,\n stringify,\n got,\n flatten,\n VERSION: '__MQL_VERSION__'\n})\n"],"names":["URL","global","window","require$$0","REGEX_HTTP_PROTOCOL","iter","output","nullish","sep","val","key","k","pfx","Array","isArray","length","toValue","mix","str","decodeURIComponent","input","glue","toNull","obj","i","tmp","encodeURIComponent","out","arr","split","shift","concat","copyProperty","to","from","property","ignoreNonConfigurable","toDescriptor","Object","getOwnPropertyDescriptor","fromDescriptor","canCopyProperty","defineProperty","undefined","configurable","writable","enumerable","value","wrappedToString","withName","fromBody","toStringDescriptor","Function","prototype","toStringName","toString","mimicFn_1","name","Reflect","ownKeys","fromPrototype","getPrototypeOf","setPrototypeOf","changePrototype","trim","newToString","bind","changeToString","helpers","isFunction","isString","composeErrorMessage","code","description","inherits","ctor","superCtor","super_","create","constructor","cleanStack","mimicFn","require$$1","addErrorProps","error","props","assign","message","require$$3","createExtendError_1","ErrorClass","classProps","ExtendError","errorProps","stack","REGEX_CLASS_NAME","createExtendError","createError","className","TypeError","test","Error","this","captureStackTrace","createErrorClass","errorClass","RangeError","EvalError","SyntaxError","ReferenceError","URIError","ENDPOINT","FREE","PRO","isObject","factory_1","VERSION","MicrolinkError","isUrlHttp","stringify","got","flatten","mapRules","rules","flatRules","keys","reduce","acc","fetchFromApi","async","apiUrl","opts","retryCount","response","responseType","body","err","statusCode","rawBody","headers","url","uri","isBuffer","Buffer","JSON","parse","_","status","data","more","parseBody","getApiUrl","apiKey","endpoint","retry","cache","gotHeaders","gotOpts","isPro","createMql","defaultOpts","assertUrl","fetchOpts","mql","version","stream","buffer","exports","HTTPError","request","options","statusText","super","TimeoutError","validateAndMerge","sources","source","deepMerge","mergeHeaders","source1","source2","result","globalThis","Headers","isHeadersInstance","entries","delete","set","returnValue","supportsAbortController","AbortController","supportsStreams","ReadableStream","supportsFormData","FormData","requestMethods","responseTypes","json","text","formData","arrayBuffer","blob","maxSafeTimeout","stop","Symbol","normalizeRequestMethod","includes","toUpperCase","retryAfterStatusCodes","defaultRetryOptions","limit","methods","statusCodes","afterStatusCodes","maxRetryAfter","Number","POSITIVE_INFINITY","normalizeRetryOptions","timeout","abortController","Promise","resolve","reject","timeoutId","setTimeout","abort","fetch","then","catch","clearTimeout","delay","ms","Ky","_a","_b","_retryCount","_input","_options","credentials","hooks","beforeRequest","beforeRetry","afterResponse","method","prefixUrl","String","throwHttpErrors","Request","startsWith","endsWith","signal","addEventListener","searchParams","replace","URLSearchParams","static","ky","fn","_fetch","hook","modifiedResponse","_decorateResponse","clone","Response","ok","onDownloadProgress","_stream","toLowerCase","_retry","type","mimeType","get","parseJson","_calculateRetryDelay","retryAfter","after","isNaN","Date","now","Math","min","totalBytes","transferredBytes","controller","reader","getReader","read","done","close","byteLength","percent","enqueue","Uint8Array","createInstance","defaults","newDefaults","extend","factory","href","flattie","encode","require$$2","whoops","require$$4","default","require$$5","statusMessage"],"mappings":"svBAEA,MAAMA,EAAMC,EAAOC,OAASA,OAAOF,IAAMG,UAAeH,IAClDI,EAAsB,yBCH5B,SAASC,EAAKC,EAAQC,EAASC,EAAKC,EAAKC,GACxC,IAAIC,EAAGC,EAAMF,EAAOA,EAAMF,EAAOE,EAEjC,GAAW,MAAPD,EACCF,IAASD,EAAOI,GAAOD,QACrB,GAAkB,iBAAPA,EACjBH,EAAOI,GAAOD,OACR,GAAII,MAAMC,QAAQL,GACxB,IAAKE,EAAE,EAAGA,EAAIF,EAAIM,OAAQJ,IACzBN,EAAKC,EAAQC,EAASC,EAAKC,EAAIE,GAAIC,EAAMD,QAG1C,IAAKA,KAAKF,EACTJ,EAAKC,EAAQC,EAASC,EAAKC,EAAIE,GAAIC,EAAMD,GCO5C,SAASK,EAAQC,GAChB,IAAKA,EAAK,MAAO,GACjB,IAAIC,EAAMC,mBAAmBF,GAC7B,MAAY,UAARC,IACQ,SAARA,IACW,GAANA,GAAY,GAAOA,EAAOA,cDPpC,SAAiBE,EAAOC,EAAMC,GAC7B,IAAIhB,EAAS,GAIb,MAHoB,iBAATc,GACVf,EAAKC,IAAUgB,EAAQD,GAAQ,IAAKD,EAAO,IAErCd,gDCvBD,SAAgBiB,EAAKX,GAC3B,IAAID,EAAGa,EAAGC,EAAKP,EAAI,GAEnB,IAAKP,KAAKY,EACT,QAAuB,KAAlBE,EAAMF,EAAIZ,IACd,GAAIE,MAAMC,QAAQW,GACjB,IAAKD,EAAE,EAAGA,EAAIC,EAAIV,OAAQS,IACzBN,IAAQA,GAAO,KACfA,GAAOQ,mB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U,WAAYJ,EAASc,OACrBZ,WAAYF,EAASiE,QAGzB,MAAM9D,IASRf,QAAAA,EACAL,QAAS"}
|
|
1
|
+
{"version":3,"file":"mql.min.js","sources":["../node_modules/.pnpm/url-http@1.0.2/node_modules/url-http/lightweight.js","../node_modules/.pnpm/flattie@1.1.0/node_modules/flattie/dist/index.js","../node_modules/.pnpm/qss@2.0.3/node_modules/qss/dist/qss.m.js","../node_modules/.pnpm/mimic-fn@3.0.0/node_modules/mimic-fn/index.js","../node_modules/.pnpm/whoops@4.1.0/node_modules/whoops/lib/helpers.js","../node_modules/.pnpm/whoops@4.1.0/node_modules/whoops/lib/add-error-props.js","../node_modules/.pnpm/whoops@4.1.0/node_modules/whoops/lib/create-extend-error.js","../node_modules/.pnpm/whoops@4.1.0/node_modules/whoops/lib/create-error.js","../node_modules/.pnpm/whoops@4.1.0/node_modules/whoops/lib/index.js","../src/factory.js","../src/ky.js","../src/browser.js"],"sourcesContent":["'use strict'\n\nconst URL = global.window ? window.URL : require('url').URL\nconst REGEX_HTTP_PROTOCOL = /^https?:\\/\\//i\n\nmodule.exports = url => {\n try {\n return REGEX_HTTP_PROTOCOL.test(new URL(url).href)\n } catch (err) {\n return false\n }\n}\n","function iter(output, nullish, sep, val, key) {\n\tvar k, pfx = key ? (key + sep) : key;\n\n\tif (val == null) {\n\t\tif (nullish) output[key] = val;\n\t} else if (typeof val != 'object') {\n\t\toutput[key] = val;\n\t} else if (Array.isArray(val)) {\n\t\tfor (k=0; k < val.length; k++) {\n\t\t\titer(output, nullish, sep, val[k], pfx + k);\n\t\t}\n\t} else {\n\t\tfor (k in val) {\n\t\t\titer(output, nullish, sep, val[k], pfx + k);\n\t\t}\n\t}\n}\n\nfunction flattie(input, glue, toNull) {\n\tvar output = {};\n\tif (typeof input == 'object') {\n\t\titer(output, !!toNull, glue || '.', input, '');\n\t}\n\treturn output;\n}\n\nexports.flattie = flattie;","export function encode(obj, pfx) {\n\tvar k, i, tmp, str='';\n\n\tfor (k in obj) {\n\t\tif ((tmp = obj[k]) !== void 0) {\n\t\t\tif (Array.isArray(tmp)) {\n\t\t\t\tfor (i=0; i < tmp.length; i++) {\n\t\t\t\t\tstr && (str += '&');\n\t\t\t\t\tstr += encodeURIComponent(k) + '=' + encodeURIComponent(tmp[i]);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tstr && (str += '&');\n\t\t\t\tstr += encodeURIComponent(k) + '=' + encodeURIComponent(tmp);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn (pfx || '') + str;\n}\n\nfunction toValue(mix) {\n\tif (!mix) return '';\n\tvar str = decodeURIComponent(mix);\n\tif (str === 'false') return false;\n\tif (str === 'true') return true;\n\treturn (+str * 0 === 0) ? (+str) : str;\n}\n\nexport function decode(str) {\n\tvar tmp, k, out={}, arr=str.split('&');\n\n\twhile (tmp = arr.shift()) {\n\t\ttmp = tmp.split('=');\n\t\tk = tmp.shift();\n\t\tif (out[k] !== void 0) {\n\t\t\tout[k] = [].concat(out[k], toValue(tmp.shift()));\n\t\t} else {\n\t\t\tout[k] = toValue(tmp.shift());\n\t\t}\n\t}\n\n\treturn out;\n}\n","'use strict';\n\nconst copyProperty = (to, from, property, ignoreNonConfigurable) => {\n\t// `Function#length` should reflect the parameters of `to` not `from` since we keep its body.\n\t// `Function#prototype` is non-writable and non-configurable so can never be modified.\n\tif (property === 'length' || property === 'prototype') {\n\t\treturn;\n\t}\n\n\tconst toDescriptor = Object.getOwnPropertyDescriptor(to, property);\n\tconst fromDescriptor = Object.getOwnPropertyDescriptor(from, property);\n\n\tif (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) {\n\t\treturn;\n\t}\n\n\tObject.defineProperty(to, property, fromDescriptor);\n};\n\n// `Object.defineProperty()` throws if the property exists, is not configurable and either:\n// - one its descriptors is changed\n// - it is non-writable and its value is changed\nconst canCopyProperty = function (toDescriptor, fromDescriptor) {\n\treturn toDescriptor === undefined || toDescriptor.configurable || (\n\t\ttoDescriptor.writable === fromDescriptor.writable &&\n\t\ttoDescriptor.enumerable === fromDescriptor.enumerable &&\n\t\ttoDescriptor.configurable === fromDescriptor.configurable &&\n\t\t(toDescriptor.writable || toDescriptor.value === fromDescriptor.value)\n\t);\n};\n\nconst changePrototype = (to, from) => {\n\tconst fromPrototype = Object.getPrototypeOf(from);\n\tif (fromPrototype === Object.getPrototypeOf(to)) {\n\t\treturn;\n\t}\n\n\tObject.setPrototypeOf(to, fromPrototype);\n};\n\nconst wrappedToString = (withName, fromBody) => `/* Wrapped ${withName}*/\\n${fromBody}`;\n\nconst toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, 'toString');\nconst toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, 'name');\n\n// We call `from.toString()` early (not lazily) to ensure `from` can be garbage collected.\n// We use `bind()` instead of a closure for the same reason.\n// Calling `from.toString()` early also allows caching it in case `to.toString()` is called several times.\nconst changeToString = (to, from, name) => {\n\tconst withName = name === '' ? '' : `with ${name.trim()}() `;\n\tconst newToString = wrappedToString.bind(null, withName, from.toString());\n\t// Ensure `to.toString.toString` is non-enumerable and has the same `same`\n\tObject.defineProperty(newToString, 'name', toStringName);\n\tObject.defineProperty(to, 'toString', {...toStringDescriptor, value: newToString});\n};\n\nconst mimicFn = (to, from, {ignoreNonConfigurable = false} = {}) => {\n\tconst {name} = to;\n\n\tfor (const property of Reflect.ownKeys(from)) {\n\t\tcopyProperty(to, from, property, ignoreNonConfigurable);\n\t}\n\n\tchangePrototype(to, from);\n\tchangeToString(to, from, name);\n\n\treturn to;\n};\n\nmodule.exports = mimicFn;\n","'use strict'\n\nmodule.exports = {\n isFunction: obj => typeof obj === 'function',\n isString: obj => typeof obj === 'string',\n composeErrorMessage: (code, description) => `${code}, ${description}`,\n inherits: (ctor, superCtor) => {\n ctor.super_ = superCtor\n ctor.prototype = Object.create(superCtor.prototype, {\n constructor: {\n value: ctor,\n enumerable: false,\n writable: true,\n configurable: true\n }\n })\n }\n}\n","'use strict'\n\nconst {isFunction, composeErrorMessage} = require('./helpers')\n\nfunction interfaceObject (error, ...props) {\n Object.assign(error, ...props)\n\n error.description = isFunction(error.message) ? error.message(error) : error.message\n\n error.message = error.code\n ? composeErrorMessage(error.code, error.description)\n : error.description\n}\n\nmodule.exports = interfaceObject\n","'use strict'\n\nconst cleanStack = require('clean-stack')\nconst mimicFn = require('mimic-fn')\n\nconst addErrorProps = require('./add-error-props')\nconst {isString} = require('./helpers')\n\nfunction createExtendError (ErrorClass, classProps) {\n function ExtendError (props) {\n const error = new ErrorClass()\n const errorProps = isString(props) ? {message: props} : props\n addErrorProps(error, classProps, errorProps)\n\n error.stack = cleanStack(error.stack)\n return error\n }\n\n ExtendError.prototype = ErrorClass.prototype\n mimicFn(ExtendError, ErrorClass)\n\n return ExtendError\n}\n\nmodule.exports = createExtendError\n","'use strict'\n\nconst {inherits} = require('./helpers')\nconst mimicFn = require('mimic-fn')\n\nconst REGEX_CLASS_NAME = /[^0-9a-zA-Z_$]/\n\nfunction createError (className) {\n if (typeof className !== 'string') {\n throw new TypeError('Expected className to be a string')\n }\n\n if (REGEX_CLASS_NAME.test(className)) {\n throw new Error('className contains invalid characters')\n }\n\n function ErrorClass () {\n Object.defineProperty(this, 'name', {\n configurable: true,\n value: className,\n writable: true\n })\n\n Error.captureStackTrace(this, this.constructor)\n }\n\n inherits(ErrorClass, Error)\n mimicFn(ErrorClass, Error)\n return ErrorClass\n}\n\nmodule.exports = createError\n","'use strict'\n\nconst createExtendError = require('./create-extend-error')\nconst createError = require('./create-error')\n\nconst createErrorClass = ErrorClass => (className, props) => {\n const errorClass = createError(className || ErrorClass.name)\n return createExtendError(errorClass, props)\n}\n\nmodule.exports = createErrorClass(Error)\nmodule.exports.type = createErrorClass(TypeError)\nmodule.exports.range = createErrorClass(RangeError)\nmodule.exports.eval = createErrorClass(EvalError)\nmodule.exports.syntax = createErrorClass(SyntaxError)\nmodule.exports.reference = createErrorClass(ReferenceError)\nmodule.exports.uri = createErrorClass(URIError)\n","const ENDPOINT = {\n FREE: 'https://api.microlink.io',\n PRO: 'https://pro.microlink.io'\n}\n\nconst isObject = input => input !== null && typeof input === 'object'\n\nconst isBuffer = input =>\n input != null &&\n input.constructor != null &&\n typeof input.constructor.isBuffer === 'function' &&\n input.constructor.isBuffer(input)\n\nconst parseBody = (input, error, url) => {\n try {\n return JSON.parse(input)\n } catch (_) {\n const message = input || error.message\n\n return {\n status: 'error',\n data: { url: message },\n more: 'https://microlink.io/efatalclient',\n code: 'EFATALCLIENT',\n message,\n url\n }\n }\n}\n\nconst factory = ({\n VERSION,\n MicrolinkError,\n urlHttp,\n stringify,\n got,\n flatten\n}) => {\n const assertUrl = (url = '') => {\n if (!urlHttp(url)) {\n const message = `The \\`url\\` as \\`${url}\\` is not valid. Ensure it has protocol (http or https) and hostname.`\n throw new MicrolinkError({\n status: 'fail',\n data: { url: message },\n more: 'https://microlink.io/docs/api/api-parameters/url',\n code: 'EINVALURLCLIENT',\n message,\n url\n })\n }\n }\n\n const mapRules = rules => {\n if (!isObject(rules)) return\n const flatRules = flatten(rules)\n return Object.keys(flatRules).reduce((acc, key) => {\n acc[`data.${key}`] = flatRules[key].toString()\n return acc\n }, {})\n }\n\n const fetchFromApi = async (apiUrl, opts = {}, retryCount = 0) => {\n try {\n const response = await got(apiUrl, opts)\n return opts.responseType === 'buffer'\n ? { body: response.body, response }\n : { ...response.body, response }\n } catch (err) {\n const { response = {} } = err\n const { statusCode, body: rawBody, headers, url: uri = apiUrl } = response\n const isBodyBuffer = isBuffer(rawBody)\n\n const body =\n isObject(rawBody) && !isBodyBuffer\n ? rawBody\n : parseBody(isBodyBuffer ? rawBody.toString() : rawBody, err, uri)\n\n if (body.code === 'EFATALCLIENT' && retryCount++ < 2) {\n return fetchFromApi(apiUrl, opts, retryCount)\n }\n\n throw MicrolinkError({\n ...body,\n message: body.message,\n url: uri,\n statusCode,\n headers\n })\n }\n }\n\n const getApiUrl = (\n url,\n { data, apiKey, endpoint, retry, cache, ...opts } = {},\n { responseType = 'json', headers: gotHeaders, ...gotOpts } = {}\n ) => {\n const isPro = !!apiKey\n const apiEndpoint = endpoint || ENDPOINT[isPro ? 'PRO' : 'FREE']\n\n const apiUrl = `${apiEndpoint}?${stringify({\n url,\n ...mapRules(data),\n ...flatten(opts)\n })}`\n\n const headers = isPro\n ? { ...gotHeaders, 'x-api-key': apiKey }\n : { ...gotHeaders }\n return [apiUrl, { ...gotOpts, responseType, cache, retry, headers }]\n }\n\n const createMql = defaultOpts => async (url, opts, gotOpts) => {\n assertUrl(url)\n const [apiUrl, fetchOpts] = getApiUrl(url, opts, {\n ...defaultOpts,\n ...gotOpts\n })\n return fetchFromApi(apiUrl, fetchOpts)\n }\n\n const mql = createMql()\n mql.MicrolinkError = MicrolinkError\n mql.getApiUrl = getApiUrl\n mql.fetchFromApi = fetchFromApi\n mql.mapRules = mapRules\n mql.version = VERSION\n mql.stream = got.stream\n mql.buffer = createMql({ responseType: 'buffer' })\n\n return mql\n}\n\nmodule.exports = factory\n","(function (global, factory) {\n typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :\n typeof define === 'function' && define.amd ? define(['exports'], factory) :\n (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ky = {}));\n})(this, (function (exports) { 'use strict';\n\n // eslint-lint-disable-next-line @typescript-eslint/naming-convention\n class HTTPError extends Error {\n constructor(response, request, options) {\n const code = (response.status || response.status === 0) ? response.status : '';\n const title = response.statusText || '';\n const status = `${code} ${title}`.trim();\n const reason = status ? `status code ${status}` : 'an unknown error';\n super(`Request failed with ${reason}`);\n this.name = 'HTTPError';\n this.response = response;\n this.request = request;\n this.options = options;\n }\n }\n\n class TimeoutError extends Error {\n constructor(request) {\n super('Request timed out');\n this.name = 'TimeoutError';\n this.request = request;\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-types\n const isObject = (value) => value !== null && typeof value === 'object';\n\n const validateAndMerge = (...sources) => {\n for (const source of sources) {\n if ((!isObject(source) || Array.isArray(source)) && typeof source !== 'undefined') {\n throw new TypeError('The `options` argument must be an object');\n }\n }\n return deepMerge({}, ...sources);\n };\n const mergeHeaders = (source1 = {}, source2 = {}) => {\n const result = new globalThis.Headers(source1);\n const isHeadersInstance = source2 instanceof globalThis.Headers;\n const source = new globalThis.Headers(source2);\n for (const [key, value] of source.entries()) {\n if ((isHeadersInstance && value === 'undefined') || value === undefined) {\n result.delete(key);\n }\n else {\n result.set(key, value);\n }\n }\n return result;\n };\n // TODO: Make this strongly-typed (no `any`).\n const deepMerge = (...sources) => {\n let returnValue = {};\n let headers = {};\n for (const source of sources) {\n if (Array.isArray(source)) {\n if (!Array.isArray(returnValue)) {\n returnValue = [];\n }\n returnValue = [...returnValue, ...source];\n }\n else if (isObject(source)) {\n for (let [key, value] of Object.entries(source)) {\n if (isObject(value) && key in returnValue) {\n value = deepMerge(returnValue[key], value);\n }\n returnValue = { ...returnValue, [key]: value };\n }\n if (isObject(source.headers)) {\n headers = mergeHeaders(headers, source.headers);\n returnValue.headers = headers;\n }\n }\n }\n return returnValue;\n };\n\n const supportsAbortController = typeof globalThis.AbortController === 'function';\n const supportsStreams = typeof globalThis.ReadableStream === 'function';\n const supportsFormData = typeof globalThis.FormData === 'function';\n const requestMethods = ['get', 'post', 'put', 'patch', 'head', 'delete'];\n const responseTypes = {\n json: 'application/json',\n text: 'text/*',\n formData: 'multipart/form-data',\n arrayBuffer: '*/*',\n blob: '*/*',\n };\n // The maximum value of a 32bit int (see issue #117)\n const maxSafeTimeout = 2147483647;\n const stop = Symbol('stop');\n\n const normalizeRequestMethod = (input) => requestMethods.includes(input) ? input.toUpperCase() : input;\n const retryMethods = ['get', 'put', 'head', 'delete', 'options', 'trace'];\n const retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];\n const retryAfterStatusCodes = [413, 429, 503];\n const defaultRetryOptions = {\n limit: 2,\n methods: retryMethods,\n statusCodes: retryStatusCodes,\n afterStatusCodes: retryAfterStatusCodes,\n maxRetryAfter: Number.POSITIVE_INFINITY,\n };\n const normalizeRetryOptions = (retry = {}) => {\n if (typeof retry === 'number') {\n return {\n ...defaultRetryOptions,\n limit: retry,\n };\n }\n if (retry.methods && !Array.isArray(retry.methods)) {\n throw new Error('retry.methods must be an array');\n }\n if (retry.statusCodes && !Array.isArray(retry.statusCodes)) {\n throw new Error('retry.statusCodes must be an array');\n }\n return {\n ...defaultRetryOptions,\n ...retry,\n afterStatusCodes: retryAfterStatusCodes,\n };\n };\n\n // `Promise.race()` workaround (#91)\n const timeout = async (request, abortController, options) => new Promise((resolve, reject) => {\n const timeoutId = setTimeout(() => {\n if (abortController) {\n abortController.abort();\n }\n reject(new TimeoutError(request));\n }, options.timeout);\n /* eslint-disable promise/prefer-await-to-then */\n void options\n .fetch(request)\n .then(resolve)\n .catch(reject)\n .then(() => {\n clearTimeout(timeoutId);\n });\n /* eslint-enable promise/prefer-await-to-then */\n });\n const delay = async (ms) => new Promise(resolve => {\n setTimeout(resolve, ms);\n });\n\n class Ky {\n // eslint-disable-next-line complexity\n constructor(input, options = {}) {\n var _a, _b;\n this._retryCount = 0;\n this._input = input;\n this._options = {\n // TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208\n credentials: this._input.credentials || 'same-origin',\n ...options,\n headers: mergeHeaders(this._input.headers, options.headers),\n hooks: deepMerge({\n beforeRequest: [],\n beforeRetry: [],\n beforeError: [],\n afterResponse: [],\n }, options.hooks),\n method: normalizeRequestMethod((_a = options.method) !== null && _a !== void 0 ? _a : this._input.method),\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n prefixUrl: String(options.prefixUrl || ''),\n retry: normalizeRetryOptions(options.retry),\n throwHttpErrors: options.throwHttpErrors !== false,\n timeout: typeof options.timeout === 'undefined' ? 10000 : options.timeout,\n fetch: (_b = options.fetch) !== null && _b !== void 0 ? _b : globalThis.fetch.bind(globalThis),\n };\n if (typeof this._input !== 'string' && !(this._input instanceof URL || this._input instanceof globalThis.Request)) {\n throw new TypeError('`input` must be a string, URL, or Request');\n }\n if (this._options.prefixUrl && typeof this._input === 'string') {\n if (this._input.startsWith('/')) {\n throw new Error('`input` must not begin with a slash when using `prefixUrl`');\n }\n if (!this._options.prefixUrl.endsWith('/')) {\n this._options.prefixUrl += '/';\n }\n this._input = this._options.prefixUrl + this._input;\n }\n if (supportsAbortController) {\n this.abortController = new globalThis.AbortController();\n if (this._options.signal) {\n this._options.signal.addEventListener('abort', () => {\n this.abortController.abort();\n });\n }\n this._options.signal = this.abortController.signal;\n }\n this.request = new globalThis.Request(this._input, this._options);\n if (this._options.searchParams) {\n // eslint-disable-next-line unicorn/prevent-abbreviations\n const textSearchParams = typeof this._options.searchParams === 'string'\n ? this._options.searchParams.replace(/^\\?/, '')\n : new URLSearchParams(this._options.searchParams).toString();\n // eslint-disable-next-line unicorn/prevent-abbreviations\n const searchParams = '?' + textSearchParams;\n const url = this.request.url.replace(/(?:\\?.*?)?(?=#|$)/, searchParams);\n // To provide correct form boundary, Content-Type header should be deleted each time when new Request instantiated from another one\n if (((supportsFormData && this._options.body instanceof globalThis.FormData)\n || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers['content-type'])) {\n this.request.headers.delete('content-type');\n }\n this.request = new globalThis.Request(new globalThis.Request(url, this.request), this._options);\n }\n if (this._options.json !== undefined) {\n this._options.body = JSON.stringify(this._options.json);\n this.request.headers.set('content-type', 'application/json');\n this.request = new globalThis.Request(this.request, { body: this._options.body });\n }\n }\n // eslint-disable-next-line @typescript-eslint/promise-function-async\n static create(input, options) {\n const ky = new Ky(input, options);\n const fn = async () => {\n if (ky._options.timeout > maxSafeTimeout) {\n throw new RangeError(`The \\`timeout\\` option cannot be greater than ${maxSafeTimeout}`);\n }\n // Delay the fetch so that body method shortcuts can set the Accept header\n await Promise.resolve();\n let response = await ky._fetch();\n for (const hook of ky._options.hooks.afterResponse) {\n // eslint-disable-next-line no-await-in-loop\n const modifiedResponse = await hook(ky.request, ky._options, ky._decorateResponse(response.clone()));\n if (modifiedResponse instanceof globalThis.Response) {\n response = modifiedResponse;\n }\n }\n ky._decorateResponse(response);\n if (!response.ok && ky._options.throwHttpErrors) {\n let error = new HTTPError(response, ky.request, ky._options);\n for (const hook of ky._options.hooks.beforeError) {\n // eslint-disable-next-line no-await-in-loop\n error = await hook(error);\n }\n throw error;\n }\n // If `onDownloadProgress` is passed, it uses the stream API internally\n /* istanbul ignore next */\n if (ky._options.onDownloadProgress) {\n if (typeof ky._options.onDownloadProgress !== 'function') {\n throw new TypeError('The `onDownloadProgress` option must be a function');\n }\n if (!supportsStreams) {\n throw new Error('Streams are not supported in your environment. `ReadableStream` is missing.');\n }\n return ky._stream(response.clone(), ky._options.onDownloadProgress);\n }\n return response;\n };\n const isRetriableMethod = ky._options.retry.methods.includes(ky.request.method.toLowerCase());\n const result = (isRetriableMethod ? ky._retry(fn) : fn());\n for (const [type, mimeType] of Object.entries(responseTypes)) {\n result[type] = async () => {\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n ky.request.headers.set('accept', ky.request.headers.get('accept') || mimeType);\n const response = (await result).clone();\n if (type === 'json') {\n if (response.status === 204) {\n return '';\n }\n if (options.parseJson) {\n return options.parseJson(await response.text());\n }\n }\n return response[type]();\n };\n }\n return result;\n }\n _calculateRetryDelay(error) {\n this._retryCount++;\n if (this._retryCount < this._options.retry.limit && !(error instanceof TimeoutError)) {\n if (error instanceof HTTPError) {\n if (!this._options.retry.statusCodes.includes(error.response.status)) {\n return 0;\n }\n const retryAfter = error.response.headers.get('Retry-After');\n if (retryAfter && this._options.retry.afterStatusCodes.includes(error.response.status)) {\n let after = Number(retryAfter);\n if (Number.isNaN(after)) {\n after = Date.parse(retryAfter) - Date.now();\n }\n else {\n after *= 1000;\n }\n if (typeof this._options.retry.maxRetryAfter !== 'undefined' && after > this._options.retry.maxRetryAfter) {\n return 0;\n }\n return after;\n }\n if (error.response.status === 413) {\n return 0;\n }\n }\n const BACKOFF_FACTOR = 0.3;\n return BACKOFF_FACTOR * (2 ** (this._retryCount - 1)) * 1000;\n }\n return 0;\n }\n _decorateResponse(response) {\n if (this._options.parseJson) {\n response.json = async () => this._options.parseJson(await response.text());\n }\n return response;\n }\n async _retry(fn) {\n try {\n return await fn();\n // eslint-disable-next-line @typescript-eslint/no-implicit-any-catch\n }\n catch (error) {\n const ms = Math.min(this._calculateRetryDelay(error), maxSafeTimeout);\n if (ms !== 0 && this._retryCount > 0) {\n await delay(ms);\n for (const hook of this._options.hooks.beforeRetry) {\n // eslint-disable-next-line no-await-in-loop\n const hookResult = await hook({\n request: this.request,\n options: this._options,\n error: error,\n retryCount: this._retryCount,\n });\n // If `stop` is returned from the hook, the retry process is stopped\n if (hookResult === stop) {\n return;\n }\n }\n return this._retry(fn);\n }\n throw error;\n }\n }\n async _fetch() {\n for (const hook of this._options.hooks.beforeRequest) {\n // eslint-disable-next-line no-await-in-loop\n const result = await hook(this.request, this._options);\n if (result instanceof Request) {\n this.request = result;\n break;\n }\n if (result instanceof Response) {\n return result;\n }\n }\n if (this._options.timeout === false) {\n return this._options.fetch(this.request.clone());\n }\n return timeout(this.request.clone(), this.abortController, this._options);\n }\n /* istanbul ignore next */\n _stream(response, onDownloadProgress) {\n const totalBytes = Number(response.headers.get('content-length')) || 0;\n let transferredBytes = 0;\n return new globalThis.Response(new globalThis.ReadableStream({\n async start(controller) {\n const reader = response.body.getReader();\n if (onDownloadProgress) {\n onDownloadProgress({ percent: 0, transferredBytes: 0, totalBytes }, new Uint8Array());\n }\n async function read() {\n const { done, value } = await reader.read();\n if (done) {\n controller.close();\n return;\n }\n if (onDownloadProgress) {\n transferredBytes += value.byteLength;\n const percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;\n onDownloadProgress({ percent, transferredBytes, totalBytes }, value);\n }\n controller.enqueue(value);\n await read();\n }\n await read();\n },\n }));\n }\n }\n\n /*! MIT License © Sindre Sorhus */\n const createInstance = (defaults) => {\n // eslint-disable-next-line @typescript-eslint/promise-function-async\n const ky = (input, options) => Ky.create(input, validateAndMerge(defaults, options));\n for (const method of requestMethods) {\n // eslint-disable-next-line @typescript-eslint/promise-function-async\n ky[method] = (input, options) => Ky.create(input, validateAndMerge(defaults, options, { method }));\n }\n ky.create = (newDefaults) => createInstance(validateAndMerge(newDefaults));\n ky.extend = (newDefaults) => createInstance(validateAndMerge(defaults, newDefaults));\n ky.stop = stop;\n return ky;\n };\n const ky = createInstance();\n\n exports.HTTPError = HTTPError;\n exports.TimeoutError = TimeoutError;\n exports[\"default\"] = ky;\n\n Object.defineProperty(exports, '__esModule', { value: true });\n\n}));\n","'use strict'\n\nconst urlHttp = require('url-http/lightweight')\nconst { flattie: flatten } = require('flattie')\nconst { encode: stringify } = require('qss')\nconst whoops = require('whoops')\n\nconst factory = require('./factory')\nconst { default: ky } = require('./ky')\n\nconst MicrolinkError = whoops('MicrolinkError')\n\nconst got = async (url, opts) => {\n try {\n if (opts.timeout === undefined) opts.timeout = false\n const response = await ky(url, opts)\n const body = await response.json()\n const { headers, status: statusCode } = response\n return { url: response.url, body, headers, statusCode }\n } catch (err) {\n if (err.response) {\n const { response } = err\n err.response = {\n ...response,\n headers: Array.from(response.headers.entries()).reduce(\n (acc, [key, value]) => {\n acc[key] = value\n return acc\n },\n {}\n ),\n statusCode: response.status,\n body: await response.text()\n }\n }\n throw err\n }\n}\n\nmodule.exports = factory({\n MicrolinkError,\n urlHttp,\n stringify,\n got,\n flatten,\n VERSION: '__MQL_VERSION__'\n})\n"],"names":["URL","window","REGEX_HTTP_PROTOCOL","iter","output","nullish","sep","val","key","k","pfx","Array","isArray","length","toValue","mix","str","decodeURIComponent","dist","flattie","input","glue","toNull","obj","i","tmp","encodeURIComponent","out","arr","split","shift","concat","copyProperty","to","from","property","ignoreNonConfigurable","toDescriptor","Object","getOwnPropertyDescriptor","fromDescriptor","canCopyProperty","defineProperty","undefined","configurable","writable","enumerable","value","wrappedToString","withName","fromBody","toStringDescriptor","Function","prototype","toStringName","toString","mimicFn_1","name","Reflect","ownKeys","fromPrototype","getPrototypeOf","setPrototypeOf","changePrototype","trim","newToString","bind","changeToString","helpers","isFunction","isString","composeErrorMessage","code","description","inherits","ctor","superCtor","super_","create","constructor","require$$0","cleanStack","mimicFn","require$$1","addErrorProps","error","props","assign","message","require$$3","createExtendError_1","ErrorClass","classProps","ExtendError","errorProps","stack","REGEX_CLASS_NAME","createExtendError","createError","className","TypeError","test","Error","this","captureStackTrace","createErrorClass","errorClass","libModule","exports","lib","type","range","RangeError","eval","EvalError","syntax","SyntaxError","reference","ReferenceError","uri","URIError","ENDPOINT","FREE","PRO","isObject","factory_1","VERSION","MicrolinkError","urlHttp","stringify","got","flatten","mapRules","rules","flatRules","keys","reduce","acc","fetchFromApi","async","apiUrl","opts","retryCount","response","responseType","body","err","statusCode","rawBody","headers","url","isBodyBuffer","isBuffer","JSON","parse","_","status","data","more","parseBody","getApiUrl","apiKey","endpoint","retry","cache","gotHeaders","gotOpts","isPro","createMql","defaultOpts","assertUrl","fetchOpts","mql","version","stream","buffer","HTTPError","request","options","statusText","super","TimeoutError","validateAndMerge","sources","source","deepMerge","mergeHeaders","source1","source2","result","globalThis","Headers","isHeadersInstance","entries","delete","set","returnValue","supportsAbortController","AbortController","supportsStreams","ReadableStream","supportsFormData","FormData","requestMethods","responseTypes","json","text","formData","arrayBuffer","blob","maxSafeTimeout","stop","Symbol","normalizeRequestMethod","includes","toUpperCase","retryAfterStatusCodes","defaultRetryOptions","limit","methods","statusCodes","afterStatusCodes","maxRetryAfter","Number","POSITIVE_INFINITY","normalizeRetryOptions","timeout","abortController","Promise","resolve","reject","timeoutId","setTimeout","abort","fetch","then","catch","clearTimeout","delay","ms","Ky","_a","_b","_retryCount","_input","_options","credentials","hooks","beforeRequest","beforeRetry","beforeError","afterResponse","method","prefixUrl","String","throwHttpErrors","Request","startsWith","endsWith","signal","addEventListener","searchParams","replace","URLSearchParams","static","ky","fn","_fetch","hook","modifiedResponse","_decorateResponse","clone","Response","ok","onDownloadProgress","_stream","toLowerCase","_retry","mimeType","get","parseJson","_calculateRetryDelay","retryAfter","after","isNaN","Date","now","Math","min","totalBytes","transferredBytes","controller","reader","getReader","read","done","close","byteLength","percent","enqueue","Uint8Array","createInstance","defaults","newDefaults","extend","factory","href","encode","require$$2","whoops","require$$4","default","require$$5"],"mappings":"stBAEA,MAA2DA,EAAAC,OAAAD,IACrDE,EAAsB,yBCH5B,SAASC,EAAKC,EAAQC,EAASC,EAAKC,EAAKC,GACxC,IAAIC,EAAGC,EAAMF,EAAOA,EAAMF,EAAOE,EAEjC,GAAW,MAAPD,EACCF,IAASD,EAAOI,GAAOD,QACrB,GAAkB,iBAAPA,EACjBH,EAAOI,GAAOD,OACR,GAAII,MAAMC,QAAQL,GACxB,IAAKE,EAAE,EAAGA,EAAIF,EAAIM,OAAQJ,IACzBN,EAAKC,EAAQC,EAASC,EAAKC,EAAIE,GAAIC,EAAMD,QAG1C,IAAKA,KAAKF,EACTJ,EAAKC,EAAQC,EAASC,EAAKC,EAAIE,GAAIC,EAAMD,GCO5C,SAASK,EAAQC,GAChB,IAAKA,EAAK,MAAO,GACjB,IAAIC,EAAMC,mBAAmBF,GAC7B,MAAY,UAARC,IACQ,SAARA,IACW,GAANA,GAAY,GAAOA,EAAOA,IDCpCE,EAAAC,QARA,SAAiBC,EAAOC,EAAMC,GAC7B,IAAIlB,EAAS,GAIb,MAHoB,iBAATgB,GACVjB,EAAKC,IAAUkB,EAAQD,GAAQ,IAAKD,EAAO,IAErChB,gDCvBD,SAAgBmB,EAAKb,GAC3B,IAAID,EAAGe,EAAGC,EAAKT,EAAI,GAEnB,IAAKP,KAAKc,EACT,QAAuB,KAAlBE,EAAMF,EAAId,IACd,GAAIE,MAAMC,QAAQa,GACjB,IAAKD,EAAE,EAAGA,EAAIC,EAAIZ,OAAQW,IACzBR,IAAQA,GAAO,KACfA,GAAOU,mBAAmBjB,GAAK,IAAMiB,mBAAmBD,EAAID,SAG7DR,IAAQA,GAAO,KACfA,GAAOU,mBAAmBjB,GA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I,QAAaF,EAAS8D,QACtBxD,QAAEA,EAASO,OAAQT,GAAeJ,EACxC,MAAO,CAAEO,IAAKP,EAASO,IAAKL,KAAAA,EAAMI,QAAAA,EAASF,WAAAA,GAC3C,MAAOD,GACP,GAAIA,EAAIH,SAAU,CAChB,MAAMA,SAAEA,GAAaG,EACrBA,EAAIH,SAAW,IACVA,EACHM,QAAS1I,MAAMuB,KAAK6G,EAASM,QAAQ4C,WAAWzD,QAC9C,CAACC,GAAMjI,EAAKuC,MACV0F,EAAIjI,GAAOuC,EACJ0F,IAET,IAEFU,WAAYJ,EAASa,OACrBX,WAAYF,EAAS+D,QAGzB,MAAM5D,IASRf,QAAAA,EACAL,QAAS"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@microlink/mql",
|
|
3
3
|
"description": "Microlink Query Language. The official HTTP client to interact with Microlink API for Node.js, browsers & Deno.",
|
|
4
4
|
"homepage": "https://nicedoc.io/microlinkhq/mql",
|
|
5
|
-
"version": "0.10.
|
|
5
|
+
"version": "0.10.21",
|
|
6
6
|
"browser": "src/browser.js",
|
|
7
7
|
"main": "src/node.js",
|
|
8
8
|
"author": {
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"name": "ndom91",
|
|
20
20
|
"email": "yo@ndo.dev"
|
|
21
21
|
},
|
|
22
|
-
{
|
|
23
|
-
"name": "Gabe O'Leary",
|
|
24
|
-
"email": "oleary.gabe@gmail.com"
|
|
25
|
-
},
|
|
26
22
|
{
|
|
27
23
|
"name": "Askar Yusupov",
|
|
28
24
|
"email": "devex.soft@gmail.com"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "Gabe O'Leary",
|
|
28
|
+
"email": "oleary.gabe@gmail.com"
|
|
29
29
|
}
|
|
30
30
|
],
|
|
31
31
|
"repository": {
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"flattie": "~1.1.0",
|
|
47
47
|
"got": "~11.8.2",
|
|
48
|
-
"is-url-http": "~2.2.7",
|
|
49
48
|
"qss": "~2.0.3",
|
|
49
|
+
"url-http": "~1.0.2",
|
|
50
50
|
"whoops": "~4.1.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
@@ -96,9 +96,9 @@
|
|
|
96
96
|
],
|
|
97
97
|
"scripts": {
|
|
98
98
|
"build": "rollup -c rollup.config.js",
|
|
99
|
-
"build:ky": "[ -f src/ky.js ] || rollup node_modules/ky/distribution/index.js --format=umd --name=ky --file=src/ky.js",
|
|
99
|
+
"build:ky": "[ -f src/ky.js ] || rollup node_modules/ky/distribution/index.js --format=umd --name=ky --exports=named --file=src/ky.js",
|
|
100
100
|
"clean": "rm -rf node_modules",
|
|
101
|
-
"contributors": "(git-authors-cli && finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true",
|
|
101
|
+
"contributors": "(git-authors-cli && finepack --sort-ignore-object-at ava && git add package.json && git commit -m 'build: contributors' --no-verify) || true",
|
|
102
102
|
"dev": "npm run build -- -w",
|
|
103
103
|
"lint": "standard",
|
|
104
104
|
"postrelease": "npm run release:tags && npm run release:github && (ci-publish || npm publish --access=public)",
|
|
@@ -114,9 +114,9 @@
|
|
|
114
114
|
"license": "MIT",
|
|
115
115
|
"ava": {
|
|
116
116
|
"files": [
|
|
117
|
+
"test/**/*",
|
|
117
118
|
"!test/browser-globals.js",
|
|
118
|
-
"!test/clients.js"
|
|
119
|
-
"test/**/*"
|
|
119
|
+
"!test/clients.js"
|
|
120
120
|
],
|
|
121
121
|
"require": [
|
|
122
122
|
"esm"
|
package/src/browser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const urlHttp = require('url-http/lightweight')
|
|
4
4
|
const { flattie: flatten } = require('flattie')
|
|
5
5
|
const { encode: stringify } = require('qss')
|
|
6
6
|
const whoops = require('whoops')
|
|
@@ -15,8 +15,8 @@ const got = async (url, opts) => {
|
|
|
15
15
|
if (opts.timeout === undefined) opts.timeout = false
|
|
16
16
|
const response = await ky(url, opts)
|
|
17
17
|
const body = await response.json()
|
|
18
|
-
const { headers, status: statusCode
|
|
19
|
-
return { url: response.url, body, headers, statusCode
|
|
18
|
+
const { headers, status: statusCode } = response
|
|
19
|
+
return { url: response.url, body, headers, statusCode }
|
|
20
20
|
} catch (err) {
|
|
21
21
|
if (err.response) {
|
|
22
22
|
const { response } = err
|
|
@@ -39,7 +39,7 @@ const got = async (url, opts) => {
|
|
|
39
39
|
|
|
40
40
|
module.exports = factory({
|
|
41
41
|
MicrolinkError,
|
|
42
|
-
|
|
42
|
+
urlHttp,
|
|
43
43
|
stringify,
|
|
44
44
|
got,
|
|
45
45
|
flatten,
|
package/src/factory.js
CHANGED
|
@@ -5,6 +5,12 @@ const ENDPOINT = {
|
|
|
5
5
|
|
|
6
6
|
const isObject = input => input !== null && typeof input === 'object'
|
|
7
7
|
|
|
8
|
+
const isBuffer = input =>
|
|
9
|
+
input != null &&
|
|
10
|
+
input.constructor != null &&
|
|
11
|
+
typeof input.constructor.isBuffer === 'function' &&
|
|
12
|
+
input.constructor.isBuffer(input)
|
|
13
|
+
|
|
8
14
|
const parseBody = (input, error, url) => {
|
|
9
15
|
try {
|
|
10
16
|
return JSON.parse(input)
|
|
@@ -25,13 +31,13 @@ const parseBody = (input, error, url) => {
|
|
|
25
31
|
const factory = ({
|
|
26
32
|
VERSION,
|
|
27
33
|
MicrolinkError,
|
|
28
|
-
|
|
34
|
+
urlHttp,
|
|
29
35
|
stringify,
|
|
30
36
|
got,
|
|
31
37
|
flatten
|
|
32
38
|
}) => {
|
|
33
39
|
const assertUrl = (url = '') => {
|
|
34
|
-
if (!
|
|
40
|
+
if (!urlHttp(url)) {
|
|
35
41
|
const message = `The \`url\` as \`${url}\` is not valid. Ensure it has protocol (http or https) and hostname.`
|
|
36
42
|
throw new MicrolinkError({
|
|
37
43
|
status: 'fail',
|
|
@@ -62,12 +68,12 @@ const factory = ({
|
|
|
62
68
|
} catch (err) {
|
|
63
69
|
const { response = {} } = err
|
|
64
70
|
const { statusCode, body: rawBody, headers, url: uri = apiUrl } = response
|
|
65
|
-
const
|
|
71
|
+
const isBodyBuffer = isBuffer(rawBody)
|
|
66
72
|
|
|
67
73
|
const body =
|
|
68
|
-
isObject(rawBody) && !
|
|
74
|
+
isObject(rawBody) && !isBodyBuffer
|
|
69
75
|
? rawBody
|
|
70
|
-
: parseBody(
|
|
76
|
+
: parseBody(isBodyBuffer ? rawBody.toString() : rawBody, err, uri)
|
|
71
77
|
|
|
72
78
|
if (body.code === 'EFATALCLIENT' && retryCount++ < 2) {
|
|
73
79
|
return fetchFromApi(apiUrl, opts, retryCount)
|
package/src/ky.js
CHANGED
|
@@ -161,6 +161,7 @@
|
|
|
161
161
|
hooks: deepMerge({
|
|
162
162
|
beforeRequest: [],
|
|
163
163
|
beforeRetry: [],
|
|
164
|
+
beforeError: [],
|
|
164
165
|
afterResponse: [],
|
|
165
166
|
}, options.hooks),
|
|
166
167
|
method: normalizeRequestMethod((_a = options.method) !== null && _a !== void 0 ? _a : this._input.method),
|
|
@@ -233,7 +234,12 @@
|
|
|
233
234
|
}
|
|
234
235
|
ky._decorateResponse(response);
|
|
235
236
|
if (!response.ok && ky._options.throwHttpErrors) {
|
|
236
|
-
|
|
237
|
+
let error = new HTTPError(response, ky.request, ky._options);
|
|
238
|
+
for (const hook of ky._options.hooks.beforeError) {
|
|
239
|
+
// eslint-disable-next-line no-await-in-loop
|
|
240
|
+
error = await hook(error);
|
|
241
|
+
}
|
|
242
|
+
throw error;
|
|
237
243
|
}
|
|
238
244
|
// If `onDownloadProgress` is passed, it uses the stream API internally
|
|
239
245
|
/* istanbul ignore next */
|
package/src/node.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module.exports = require('./factory')({
|
|
2
2
|
MicrolinkError: require('whoops')('MicrolinkError'),
|
|
3
|
-
|
|
3
|
+
urlHttp: require('url-http/lightweight'),
|
|
4
4
|
stringify: require('querystring').stringify,
|
|
5
5
|
got: require('got'),
|
|
6
6
|
flatten: require('flattie').flattie,
|
|
@@ -8,6 +8,8 @@ module.exports = require('./factory')({
|
|
|
8
8
|
})
|
|
9
9
|
|
|
10
10
|
module.exports.render = (input, { width = '650px' } = {}) => {
|
|
11
|
-
if (input && input.url && input.type)
|
|
11
|
+
if (input && input.url && input.type) {
|
|
12
|
+
return `<img width="${width}" src="${input.url}" />`
|
|
13
|
+
}
|
|
12
14
|
return input
|
|
13
15
|
}
|