cacheable-request 13.0.6 → 13.0.7

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/index.d.ts CHANGED
@@ -12,6 +12,22 @@ declare class CacheableRequest {
12
12
  getHook: (name: string) => Function_;
13
13
  runHook: (name: string, ...arguments_: any[]) => Promise<CacheValue>;
14
14
  }
15
+ export declare const parseWithWhatwg: (raw: string) => {
16
+ protocol: string;
17
+ slashes: boolean;
18
+ auth: string;
19
+ host: string;
20
+ port: string;
21
+ hostname: string;
22
+ hash: string;
23
+ search: string;
24
+ query: {
25
+ [k: string]: string;
26
+ };
27
+ pathname: string;
28
+ path: string;
29
+ href: string;
30
+ };
15
31
  export default CacheableRequest;
16
32
  export * from './types.js';
17
33
  export declare const onResponse = "onResponse";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAC,IAAI,EAAC,MAAM,MAAM,CAAC;AAE1B,OAAO,EACN,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,gBAAgB,EAAuC,OAAO,EACpG,MAAM,YAAY,CAAC;AAGpB,KAAK,SAAS,GAAG,CAAC,GAAG,UAAU,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAE/C,cAAM,gBAAgB;IACrB,KAAK,EAAE,IAAI,CAAmD;IAC9D,YAAY,EAAE,SAAS,CAAC;IACxB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAgC;gBACjD,YAAY,EAAE,SAAS,EAAE,YAAY,CAAC,EAAE,GAAG;IAgBvD,OAAO,SAAU,SAAS,gBAAgB,EACzC,WAAW,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,KAAG,OAAO,CAsNrD;IAEF,OAAO,GAAI,MAAM,MAAM,EAAE,WAAW,SAAS,UAI3C;IAEF,UAAU,GAAI,MAAM,MAAM,aAA6B;IAEvD,OAAO,GAAI,MA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1,5 +1,5 @@
1
1
  import EventEmitter from 'node:events';
2
- import urlLib from 'node:url';
2
+ import urlLib, { URL } from 'node:url';
3
3
  import crypto from 'node:crypto';
4
4
  import stream, { PassThrough as PassThroughStream } from 'node:stream';
5
5
  import normalizeUrl from 'normalize-url';
@@ -16,11 +16,11 @@ class CacheableRequest {
16
16
  this.request = () => (options, callback) => {
17
17
  let url;
18
18
  if (typeof options === 'string') {
19
- url = normalizeUrlObject(urlLib.parse(options));
19
+ url = normalizeUrlObject(parseWithWhatwg(options));
20
20
  options = {};
21
21
  }
22
22
  else if (options instanceof urlLib.URL) {
23
- url = normalizeUrlObject(urlLib.parse(options.toString()));
23
+ url = normalizeUrlObject(parseWithWhatwg(options.toString()));
24
24
  options = {};
25
25
  }
26
26
  else {
@@ -154,6 +154,7 @@ class CacheableRequest {
154
154
  try {
155
155
  const request_ = this.cacheRequest(options_, handler);
156
156
  request_.once('error', requestErrorCallback);
157
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
157
158
  request_.once('abort', requestErrorCallback);
158
159
  request_.once('destroy', requestErrorCallback);
159
160
  ee.emit('request', request_);
@@ -174,6 +175,7 @@ class CacheableRequest {
174
175
  if (policy.satisfiesWithoutRevalidation(options_) && !options_.forceRefresh) {
175
176
  const headers = convertHeaders(policy.responseHeaders());
176
177
  const bodyBuffer = cacheEntry.body;
178
+ // eslint-disable-next-line n/prefer-global/buffer
177
179
  const body = Buffer.from(bodyBuffer);
178
180
  const response = new Response({
179
181
  statusCode: cacheEntry.statusCode,
@@ -281,6 +283,27 @@ const convertHeaders = (headers) => {
281
283
  }
282
284
  return result;
283
285
  };
286
+ export const parseWithWhatwg = (raw) => {
287
+ const u = new URL(raw);
288
+ // If normalizeUrlObject expects the same fields as url.parse()
289
+ return {
290
+ protocol: u.protocol, // E.g. 'https:'
291
+ slashes: true, // Always true for WHATWG URLs
292
+ /* c8 ignore next 3 */
293
+ auth: u.username || u.password
294
+ ? `${u.username}:${u.password}`
295
+ : undefined,
296
+ host: u.host, // E.g. 'example.com:8080'
297
+ port: u.port, // E.g. '8080'
298
+ hostname: u.hostname, // E.g. 'example.com'
299
+ hash: u.hash, // E.g. '#quux'
300
+ search: u.search, // E.g. '?bar=baz'
301
+ query: Object.fromEntries(u.searchParams), // { bar: 'baz' }
302
+ pathname: u.pathname, // E.g. '/foo'
303
+ path: u.pathname + u.search, // '/foo?bar=baz'
304
+ href: u.href, // Full serialized URL
305
+ };
306
+ };
284
307
  export default CacheableRequest;
285
308
  export * from './types.js';
286
309
  export const onResponse = 'onResponse';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,aAAa,CAAC;AACvC,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,MAAM,EAAE,EAAC,WAAW,IAAI,iBAAiB,EAAC,MAAM,aAAa,CAAC;AAErE,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,EAAC,iBAAiB,EAAC,MAAM,YAAY,CAAC;AAC7C,OAAO,WAAW,MAAM,sBAAsB,CAAC;AAC/C,OAAO,QAAQ,MAAM,cAAc,CAAC;AACpC,OAAO,EAAC,IAAI,EAAC,MAAM,MAAM,CAAC;AAC1B,OAAO,aAAa,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAC6D,UAAU,EAAE,YAAY,GAC3F,MAAM,YAAY,CAAC;AAKpB,MAAM,gBAAgB;IAIrB,YAAY,YAAuB,EAAE,YAAkB;QAHvD,UAAK,GAAS,IAAI,IAAI,CAAM,EAAC,SAAS,EAAE,mBAAmB,EAAC,CAAC,CAAC;QAE9D,UAAK,GAA2B,IAAI,GAAG,EAAqB,CAAC;QAiB7D,YAAO,GAAG,GAAG,EAAE,CAAC,CAAC,OAAyB,EACzC,QAA4C,EAAW,EAAE;YACzD,IAAI,GAAG,CAAC;YACR,IAAI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M,kBAAkB,GAAG,CAAC,GAAQ,EAAE,EAAE;AACxC,6CAA6C;AAC7C,yBAAyB;AACzB,iCAAiC;AACjC,6DAA6D;AAC7D,2CAA2C;AAC3C,gCAAgC;AAChC,qCAAqC;AACpC,CAAC;IACA,QAAQ,EAAE,GAAG,CAAC,QAAQ;IACtB,IAAI,EAAE,GAAG,CAAC,IAAI;IACd,QAAQ,EAAE,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,IAAI,IAAI,WAAW;IACjD,IAAI,EAAE,GAAG,CAAC,IAAI;IACd,QAAQ,EAAE,GAAG,CAAC,QAAQ;IACtB,MAAM,EAAE,GAAG,CAAC,MAAM;CAClB,CAAC,CAAC;AAEJ,MAAM,cAAc,GAAG,CAAC,OAA4B,EAAE,EAAE;IACvD,MAAM,MAAM,GAAQ,EAAE,CAAC;IACvB,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACzC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC","sourcesContent":["import EventEmitter from 'node:events';\nimport urlLib from 'node:url';\nimport crypto from 'node:crypto';\nimport stream, {PassThrough as PassThroughStream} from 'node:stream';\nimport {IncomingMessage} from 'node:http';\nimport normalizeUrl from 'normalize-url';\nimport {getStreamAsBuffer} from 'get-stream';\nimport CachePolicy from 'http-cache-semantics';\nimport Response from 'responselike';\nimport {Keyv} from 'keyv';\nimport mimicResponse from 'mimic-response';\nimport {\n\tRequestFn, CacheResponse, CacheValue, CacheableOptions, UrlOption, CacheError, RequestError, Emitter, CacheableRequestFunction,\n} from './types.js';\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\ntype Function_ = (...arguments_: any[]) => any;\n\nclass CacheableRequest {\n\tcache: Keyv = new Keyv<any>({namespace: 'cacheable-request'});\n\tcacheRequest: RequestFn;\n\thooks: Map<string, Function_> = new Map<string, Function_>();\n\tconstructor(cacheRequest: RequestFn, cacheAdapter?: any) {\n\t\tif (cacheAdapter) {\n\t\t\tif (cacheAdapter instanceof Keyv) {\n\t\t\t\tthis.cache = cacheAdapter;\n\t\t\t} else {\n\t\t\t\tthis.cache = new Keyv({\n\t\t\t\t\tstore: cacheAdapter,\n\t\t\t\t\tnamespace: 'cacheable-request',\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tthis.request = this.request.bind(this);\n\t\tthis.cacheRequest = cacheRequest;\n\t}\n\n\trequest = () => (options: CacheableOptions,\n\t\tcallback?: (response: CacheResponse) => void): Emitter => {\n\t\tlet url;\n\t\tif (typeof options === 'string') {\n\t\t\turl = normalizeUrlObject(urlLib.parse(options));\n\t\t\toptions = {};\n\t\t} else if (options instanceof urlLib.URL) {\n\t\t\turl = normalizeUrlObject(urlLib.parse(options.toString()));\n\t\t\toptions = {};\n\t\t} else {\n\t\t\tconst [pathname, ...searchParts] = (options.path ?? '').split('?');\n\t\t\tconst search = searchParts.length > 0\n\t\t\t\t? `?${searchParts.join('?')}`\n\t\t\t\t: '';\n\t\t\turl = normalizeUrlObject({...options, pathname, search});\n\t\t}\n\n\t\toptions = {\n\t\t\theaders: {},\n\t\t\tmethod: 'GET',\n\t\t\tcache: true,\n\t\t\tstrictTtl: false,\n\t\t\tautomaticFailover: false,\n\t\t\t...options,\n\t\t\t...urlObjectToRequestOptions(url),\n\t\t};\n\t\toptions.headers = Object.fromEntries(entries(options.headers).map(([key, value]) => [(key as string).toLowerCase(), value]));\n\t\tconst ee: Emitter = new EventEmitter() as Emitter;\n\t\tconst normalizedUrlString = normalizeUrl(urlLib.format(url), {\n\t\t\tstripWWW: false, // eslint-disable-line @typescript-eslint/naming-convention\n\t\t\tremoveTrailingSlash: false,\n\t\t\tstripAuthentication: false,\n\t\t});\n\t\tlet key = `${options.method}:${normalizedUrlString}`;\n\t\t// POST, PATCH, and PUT requests may be cached, depending on the response\n\t\t// cache-control headers. As a result, the body of the request should be\n\t\t// added to the cache key in order to avoid collisions.\n\t\tif (options.body && options.method !== undefined && ['POST', 'PATCH', 'PUT'].includes(options.method)) {\n\t\t\tif (options.body instanceof stream.Readable) {\n\t\t\t\t// Streamed bodies should completely skip the cache because they may\n\t\t\t\t// or may not be hashable and in either case the stream would need to\n\t\t\t\t// close before the cache key could be generated.\n\t\t\t\toptions.cache = false;\n\t\t\t} else {\n\t\t\t\tkey += `:${crypto.createHash('md5').update(options.body).digest('hex')}`;\n\t\t\t}\n\t\t}\n\n\t\tlet revalidate: any = false;\n\t\tlet madeRequest = false;\n\t\tconst makeRequest = (options_: any) => {\n\t\t\tmadeRequest = true;\n\t\t\tlet requestErrored = false;\n\t\t\tlet requestErrorCallback: (...arguments_: any[]) => void = () => {/* do nothing */ };\n\n\t\t\tconst requestErrorPromise = new Promise<void>(resolve => {\n\t\t\t\trequestErrorCallback = () => {\n\t\t\t\t\tif (!requestErrored) {\n\t\t\t\t\t\trequestErrored = true;\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t});\n\t\t\tconst handler = async (response: any) => {\n\t\t\t\tif (revalidate) {\n\t\t\t\t\tresponse.status = response.statusCode;\n\t\t\t\t\tconst revalidatedPolicy = CachePolicy.fromObject(revalidate.cachePolicy).revalidatedPolicy(options_, response);\n\t\t\t\t\tif (!revalidatedPolicy.modified) {\n\t\t\t\t\t\tresponse.resume();\n\t\t\t\t\t\tawait new Promise(resolve => {\n\t\t\t\t\t\t\t// Skipping 'error' handler cause 'error' event should't be emitted for 304 response\n\t\t\t\t\t\t\tresponse\n\t\t\t\t\t\t\t\t.once('end', resolve);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst headers = convertHeaders(revalidatedPolicy.policy.responseHeaders());\n\t\t\t\t\t\tresponse = new Response({\n\t\t\t\t\t\t\tstatusCode: revalidate.statusCode, headers, body: revalidate.body, url: revalidate.url,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tresponse.cachePolicy = revalidatedPolicy.policy;\n\t\t\t\t\t\tresponse.fromCache = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!response.fromCache) {\n\t\t\t\t\tresponse.cachePolicy = new CachePolicy(options_, response, options_);\n\t\t\t\t\tresponse.fromCache = false;\n\t\t\t\t}\n\n\t\t\t\tlet clonedResponse;\n\t\t\t\tif (options_.cache && response.cachePolicy.storable()) {\n\t\t\t\t\tclonedResponse = cloneResponse(response);\n\t\t\t\t\t(async () => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst bodyPromise = getStreamAsBuffer(response);\n\t\t\t\t\t\t\tawait Promise.race([\n\t\t\t\t\t\t\t\trequestErrorPromise,\n\t\t\t\t\t\t\t\tnew Promise(resolve => response.once('end', resolve)), // eslint-disable-line no-promise-executor-return\n\t\t\t\t\t\t\t\tnew Promise(resolve => response.once('close', resolve)), // eslint-disable-line no-promise-executor-return\n\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\tconst body = await bodyPromise;\n\t\t\t\t\t\t\tlet value: CacheValue = {\n\t\t\t\t\t\t\t\turl: response.url,\n\t\t\t\t\t\t\t\tstatusCode: response.fromCache ? revalidate.statusCode : response.statusCode,\n\t\t\t\t\t\t\t\tbody,\n\t\t\t\t\t\t\t\tcachePolicy: response.cachePolicy.toObject(),\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tlet ttl = options_.strictTtl ? response.cachePolicy.timeToLive() : undefined;\n\t\t\t\t\t\t\tif (options_.maxTtl) {\n\t\t\t\t\t\t\t\tttl = ttl ? Math.min(ttl, options_.maxTtl) : options_.maxTtl;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (this.hooks.size > 0) {\n\t\t\t\t\t\t\t\t/* eslint-disable no-await-in-loop */\n\t\t\t\t\t\t\t\tfor (const key_ of this.hooks.keys()) {\n\t\t\t\t\t\t\t\t\tvalue = await this.runHook(key_, value, response);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/* eslint-enable no-await-in-loop */\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tawait this.cache.set(key, value, ttl);\n\t\t\t\t\t\t} catch (error: any) {\n\t\t\t\t\t\t\t/* c8 ignore next 2 */\n\t\t\t\t\t\t\tee.emit('error', new CacheError(error));\n\t\t\t\t\t\t}\n\t\t\t\t\t})();\n\t\t\t\t} else if (options_.cache && revalidate) {\n\t\t\t\t\t(async () => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tawait this.cache.delete(key);\n\t\t\t\t\t\t} catch (error: any) {\n\t\t\t\t\t\t\t/* c8 ignore next 2 */\n\t\t\t\t\t\t\tee.emit('error', new CacheError(error));\n\t\t\t\t\t\t}\n\t\t\t\t\t})();\n\t\t\t\t}\n\n\t\t\t\tee.emit('response', clonedResponse ?? response);\n\t\t\t\tif (typeof callback === 'function') {\n\t\t\t\t\tcallback(clonedResponse ?? response);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\ttry {\n\t\t\t\tconst request_ = this.cacheRequest(options_, handler);\n\t\t\t\trequest_.once('error', requestErrorCallback);\n\t\t\t\trequest_.once('abort', requestErrorCallback);\n\t\t\t\trequest_.once('destroy', requestErrorCallback);\n\t\t\t\tee.emit('request', request_);\n\t\t\t} catch (error: any) {\n\t\t\t\tee.emit('error', new RequestError(error));\n\t\t\t}\n\t\t};\n\n\t\t(async () => {\n\t\t\tconst get = async (options_: any) => {\n\t\t\t\tawait Promise.resolve();\n\t\t\t\tconst cacheEntry = options_.cache ? await this.cache.get(key) : undefined;\n\n\t\t\t\tif (cacheEntry === undefined && !options_.forceRefresh) {\n\t\t\t\t\tmakeRequest(options_);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst policy = CachePolicy.fromObject((cacheEntry as CacheValue).cachePolicy);\n\t\t\t\tif (policy.satisfiesWithoutRevalidation(options_) && !options_.forceRefresh) {\n\t\t\t\t\tconst headers = convertHeaders(policy.responseHeaders());\n\t\t\t\t\tconst bodyBuffer = (cacheEntry as CacheValue).body;\n\t\t\t\t\tconst body = Buffer.from(bodyBuffer as string);\n\t\t\t\t\tconst response: any = new Response({\n\t\t\t\t\t\tstatusCode: (cacheEntry as CacheValue).statusCode,\n\t\t\t\t\t\theaders,\n\t\t\t\t\t\tbody,\n\t\t\t\t\t\turl: (cacheEntry as CacheValue).url,\n\t\t\t\t\t});\n\t\t\t\t\tresponse.cachePolicy = policy;\n\t\t\t\t\tresponse.fromCache = true;\n\t\t\t\t\tee.emit('response', response);\n\t\t\t\t\tif (typeof callback === 'function') {\n\t\t\t\t\t\tcallback(response);\n\t\t\t\t\t}\n\t\t\t\t} else if (policy.satisfiesWithoutRevalidation(options_) && Date.now() >= policy.timeToLive() && options_.forceRefresh) {\n\t\t\t\t\tawait this.cache.delete(key);\n\t\t\t\t\toptions_.headers = policy.revalidationHeaders(options_);\n\t\t\t\t\tmakeRequest(options_);\n\t\t\t\t} else {\n\t\t\t\t\trevalidate = cacheEntry;\n\t\t\t\t\toptions_.headers = policy.revalidationHeaders(options_);\n\t\t\t\t\tmakeRequest(options_);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst errorHandler = (error: Error) => ee.emit('error', new CacheError(error));\n\t\t\tif (this.cache instanceof Keyv) {\n\t\t\t\tconst cachek = this.cache;\n\t\t\t\tcachek.once('error', errorHandler);\n\t\t\t\tee.on('error', () => {\n\t\t\t\t\tcachek.removeListener('error', errorHandler);\n\t\t\t\t});\n\t\t\t\tee.on('response', () => {\n\t\t\t\t\tcachek.removeListener('error', errorHandler);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tawait get(options);\n\t\t\t} catch (error: any) {\n\t\t\t\tif (options.automaticFailover && !madeRequest) {\n\t\t\t\t\tmakeRequest(options);\n\t\t\t\t}\n\n\t\t\t\tee.emit('error', new CacheError(error));\n\t\t\t}\n\t\t})();\n\n\t\treturn ee;\n\t};\n\n\taddHook = (name: string, function_: Function_) => {\n\t\tif (!this.hooks.has(name)) {\n\t\t\tthis.hooks.set(name, function_);\n\t\t}\n\t};\n\n\tremoveHook = (name: string) => this.hooks.delete(name);\n\n\tgetHook = (name: string) => this.hooks.get(name);\n\n\trunHook = async (name: string, ...arguments_: any[]): Promise<CacheValue> => this.hooks.get(name)?.(...arguments_);\n}\n\nconst entries = Object.entries as <T>(object: T) => Array<[keyof T, T[keyof T]]>;\n\nconst cloneResponse = (response: IncomingMessage) => {\n\tconst clone = new PassThroughStream({autoDestroy: false});\n\tmimicResponse(response, clone);\n\n\treturn response.pipe(clone);\n};\n\nconst urlObjectToRequestOptions = (url: any) => {\n\tconst options: UrlOption = {...url};\n\toptions.path = `${url.pathname || '/'}${url.search || ''}`;\n\tdelete options.pathname;\n\tdelete options.search;\n\treturn options;\n};\n\nconst normalizeUrlObject = (url: any) =>\n// If url was parsed by url.parse or new URL:\n// - hostname will be set\n// - host will be hostname[:port]\n// - port will be set if it was explicit in the parsed string\n// Otherwise, url was from request options:\n// - hostname or host may be set\n// - host shall not have port encoded\n\t({\n\t\tprotocol: url.protocol,\n\t\tauth: url.auth,\n\t\thostname: url.hostname || url.host || 'localhost',\n\t\tport: url.port,\n\t\tpathname: url.pathname,\n\t\tsearch: url.search,\n\t});\n\nconst convertHeaders = (headers: CachePolicy.Headers) => {\n\tconst result: any = [];\n\tfor (const name of Object.keys(headers)) {\n\t\tresult[name.toLowerCase()] = headers[name];\n\t}\n\n\treturn result;\n};\n\nexport default CacheableRequest;\nexport * from './types.js';\nexport const onResponse = 'onResponse';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,aAAa,CAAC;AACvC,OAAO,MAAM,EAAE,EAAC,GAAG,EAAC,MAAM,UAAU,CAAC;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c,YAAY,CAAC;AAC3B,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAC","sourcesContent":["\nimport EventEmitter from 'node:events';\nimport urlLib, {URL} from 'node:url';\nimport crypto from 'node:crypto';\nimport stream, {PassThrough as PassThroughStream} from 'node:stream';\nimport {IncomingMessage} from 'node:http';\nimport normalizeUrl from 'normalize-url';\nimport {getStreamAsBuffer} from 'get-stream';\nimport CachePolicy from 'http-cache-semantics';\nimport Response from 'responselike';\nimport {Keyv} from 'keyv';\nimport mimicResponse from 'mimic-response';\nimport {\n\tRequestFn, CacheResponse, CacheValue, CacheableOptions, UrlOption, CacheError, RequestError, Emitter, CacheableRequestFunction,\n} from './types.js';\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\ntype Function_ = (...arguments_: any[]) => any;\n\nclass CacheableRequest {\n\tcache: Keyv = new Keyv<any>({namespace: 'cacheable-request'});\n\tcacheRequest: RequestFn;\n\thooks: Map<string, Function_> = new Map<string, Function_>();\n\tconstructor(cacheRequest: RequestFn, cacheAdapter?: any) {\n\t\tif (cacheAdapter) {\n\t\t\tif (cacheAdapter instanceof Keyv) {\n\t\t\t\tthis.cache = cacheAdapter;\n\t\t\t} else {\n\t\t\t\tthis.cache = new Keyv({\n\t\t\t\t\tstore: cacheAdapter,\n\t\t\t\t\tnamespace: 'cacheable-request',\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tthis.request = this.request.bind(this);\n\t\tthis.cacheRequest = cacheRequest;\n\t}\n\n\trequest = () => (\n\t\toptions: CacheableOptions,\n\t\tcallback?: (response: CacheResponse) => void,\n\t): Emitter => {\n\t\tlet url;\n\t\tif (typeof options === 'string') {\n\t\t\turl = normalizeUrlObject(parseWithWhatwg(options));\n\t\t\toptions = {};\n\t\t} else if (options instanceof urlLib.URL) {\n\t\t\turl = normalizeUrlObject(parseWithWhatwg(options.toString()));\n\t\t\toptions = {};\n\t\t} else {\n\t\t\tconst [pathname, ...searchParts] = (options.path ?? '').split('?');\n\t\t\tconst search = searchParts.length > 0\n\t\t\t\t? `?${searchParts.join('?')}`\n\t\t\t\t: '';\n\t\t\turl = normalizeUrlObject({...options, pathname, search});\n\t\t}\n\n\t\toptions = {\n\t\t\theaders: {},\n\t\t\tmethod: 'GET',\n\t\t\tcache: true,\n\t\t\tstrictTtl: false,\n\t\t\tautomaticFailover: false,\n\t\t\t...options,\n\t\t\t...urlObjectToRequestOptions(url),\n\t\t};\n\t\toptions.headers = Object.fromEntries(entries(options.headers).map(([key, value]) => [(key as string).toLowerCase(), value]));\n\t\tconst ee: Emitter = new EventEmitter() as Emitter;\n\t\tconst normalizedUrlString = normalizeUrl(urlLib.format(url), {\n\t\t\tstripWWW: false, // eslint-disable-line @typescript-eslint/naming-convention\n\t\t\tremoveTrailingSlash: false,\n\t\t\tstripAuthentication: false,\n\t\t});\n\t\tlet key = `${options.method}:${normalizedUrlString}`;\n\t\t// POST, PATCH, and PUT requests may be cached, depending on the response\n\t\t// cache-control headers. As a result, the body of the request should be\n\t\t// added to the cache key in order to avoid collisions.\n\t\tif (options.body && options.method !== undefined && ['POST', 'PATCH', 'PUT'].includes(options.method)) {\n\t\t\tif (options.body instanceof stream.Readable) {\n\t\t\t\t// Streamed bodies should completely skip the cache because they may\n\t\t\t\t// or may not be hashable and in either case the stream would need to\n\t\t\t\t// close before the cache key could be generated.\n\t\t\t\toptions.cache = false;\n\t\t\t} else {\n\t\t\t\tkey += `:${crypto.createHash('md5').update(options.body).digest('hex')}`;\n\t\t\t}\n\t\t}\n\n\t\tlet revalidate: any = false;\n\t\tlet madeRequest = false;\n\t\tconst makeRequest = (options_: any) => {\n\t\t\tmadeRequest = true;\n\t\t\tlet requestErrored = false;\n\t\t\tlet requestErrorCallback: (...arguments_: any[]) => void = () => {/* do nothing */};\n\n\t\t\tconst requestErrorPromise = new Promise<void>(resolve => {\n\t\t\t\trequestErrorCallback = () => {\n\t\t\t\t\tif (!requestErrored) {\n\t\t\t\t\t\trequestErrored = true;\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t});\n\t\t\tconst handler = async (response: any) => {\n\t\t\t\tif (revalidate) {\n\t\t\t\t\tresponse.status = response.statusCode;\n\t\t\t\t\tconst revalidatedPolicy = CachePolicy.fromObject(revalidate.cachePolicy).revalidatedPolicy(options_, response);\n\t\t\t\t\tif (!revalidatedPolicy.modified) {\n\t\t\t\t\t\tresponse.resume();\n\t\t\t\t\t\tawait new Promise(resolve => {\n\t\t\t\t\t\t\t// Skipping 'error' handler cause 'error' event should't be emitted for 304 response\n\t\t\t\t\t\t\tresponse\n\t\t\t\t\t\t\t\t.once('end', resolve);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst headers = convertHeaders(revalidatedPolicy.policy.responseHeaders());\n\t\t\t\t\t\tresponse = new Response({\n\t\t\t\t\t\t\tstatusCode: revalidate.statusCode, headers, body: revalidate.body, url: revalidate.url,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tresponse.cachePolicy = revalidatedPolicy.policy;\n\t\t\t\t\t\tresponse.fromCache = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!response.fromCache) {\n\t\t\t\t\tresponse.cachePolicy = new CachePolicy(options_, response, options_);\n\t\t\t\t\tresponse.fromCache = false;\n\t\t\t\t}\n\n\t\t\t\tlet clonedResponse;\n\t\t\t\tif (options_.cache && response.cachePolicy.storable()) {\n\t\t\t\t\tclonedResponse = cloneResponse(response);\n\t\t\t\t\t(async () => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst bodyPromise = getStreamAsBuffer(response);\n\t\t\t\t\t\t\tawait Promise.race([\n\t\t\t\t\t\t\t\trequestErrorPromise,\n\t\t\t\t\t\t\t\tnew Promise(resolve => response.once('end', resolve)), // eslint-disable-line no-promise-executor-return\n\t\t\t\t\t\t\t\tnew Promise(resolve => response.once('close', resolve)), // eslint-disable-line no-promise-executor-return\n\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\tconst body = await bodyPromise;\n\t\t\t\t\t\t\tlet value: CacheValue = {\n\t\t\t\t\t\t\t\turl: response.url,\n\t\t\t\t\t\t\t\tstatusCode: response.fromCache ? revalidate.statusCode : response.statusCode,\n\t\t\t\t\t\t\t\tbody,\n\t\t\t\t\t\t\t\tcachePolicy: response.cachePolicy.toObject(),\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tlet ttl = options_.strictTtl ? response.cachePolicy.timeToLive() : undefined;\n\t\t\t\t\t\t\tif (options_.maxTtl) {\n\t\t\t\t\t\t\t\tttl = ttl ? Math.min(ttl, options_.maxTtl) : options_.maxTtl;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (this.hooks.size > 0) {\n\t\t\t\t\t\t\t\t/* eslint-disable no-await-in-loop */\n\t\t\t\t\t\t\t\tfor (const key_ of this.hooks.keys()) {\n\t\t\t\t\t\t\t\t\tvalue = await this.runHook(key_, value, response);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/* eslint-enable no-await-in-loop */\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tawait this.cache.set(key, value, ttl);\n\t\t\t\t\t\t} catch (error: any) {\n\t\t\t\t\t\t\t/* c8 ignore next 2 */\n\t\t\t\t\t\t\tee.emit('error', new CacheError(error));\n\t\t\t\t\t\t}\n\t\t\t\t\t})();\n\t\t\t\t} else if (options_.cache && revalidate) {\n\t\t\t\t\t(async () => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tawait this.cache.delete(key);\n\t\t\t\t\t\t} catch (error: any) {\n\t\t\t\t\t\t\t/* c8 ignore next 2 */\n\t\t\t\t\t\t\tee.emit('error', new CacheError(error));\n\t\t\t\t\t\t}\n\t\t\t\t\t})();\n\t\t\t\t}\n\n\t\t\t\tee.emit('response', clonedResponse ?? response);\n\t\t\t\tif (typeof callback === 'function') {\n\t\t\t\t\tcallback(clonedResponse ?? response);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\ttry {\n\t\t\t\tconst request_ = this.cacheRequest(options_, handler);\n\t\t\t\trequest_.once('error', requestErrorCallback);\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\t\t\trequest_.once('abort', requestErrorCallback);\n\t\t\t\trequest_.once('destroy', requestErrorCallback);\n\t\t\t\tee.emit('request', request_);\n\t\t\t} catch (error: any) {\n\t\t\t\tee.emit('error', new RequestError(error));\n\t\t\t}\n\t\t};\n\n\t\t(async () => {\n\t\t\tconst get = async (options_: any) => {\n\t\t\t\tawait Promise.resolve();\n\t\t\t\tconst cacheEntry = options_.cache ? await this.cache.get(key) : undefined;\n\n\t\t\t\tif (cacheEntry === undefined && !options_.forceRefresh) {\n\t\t\t\t\tmakeRequest(options_);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst policy = CachePolicy.fromObject((cacheEntry as CacheValue).cachePolicy);\n\t\t\t\tif (policy.satisfiesWithoutRevalidation(options_) && !options_.forceRefresh) {\n\t\t\t\t\tconst headers = convertHeaders(policy.responseHeaders());\n\t\t\t\t\tconst bodyBuffer = (cacheEntry as CacheValue).body;\n\t\t\t\t\t// eslint-disable-next-line n/prefer-global/buffer\n\t\t\t\t\tconst body = Buffer.from(bodyBuffer as string);\n\t\t\t\t\tconst response: any = new Response({\n\t\t\t\t\t\tstatusCode: (cacheEntry as CacheValue).statusCode,\n\t\t\t\t\t\theaders,\n\t\t\t\t\t\tbody,\n\t\t\t\t\t\turl: (cacheEntry as CacheValue).url,\n\t\t\t\t\t});\n\t\t\t\t\tresponse.cachePolicy = policy;\n\t\t\t\t\tresponse.fromCache = true;\n\t\t\t\t\tee.emit('response', response);\n\t\t\t\t\tif (typeof callback === 'function') {\n\t\t\t\t\t\tcallback(response);\n\t\t\t\t\t}\n\t\t\t\t} else if (policy.satisfiesWithoutRevalidation(options_) && Date.now() >= policy.timeToLive() && options_.forceRefresh) {\n\t\t\t\t\tawait this.cache.delete(key);\n\t\t\t\t\toptions_.headers = policy.revalidationHeaders(options_);\n\t\t\t\t\tmakeRequest(options_);\n\t\t\t\t} else {\n\t\t\t\t\trevalidate = cacheEntry;\n\t\t\t\t\toptions_.headers = policy.revalidationHeaders(options_);\n\t\t\t\t\tmakeRequest(options_);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst errorHandler = (error: Error) => ee.emit('error', new CacheError(error));\n\t\t\tif (this.cache instanceof Keyv) {\n\t\t\t\tconst cachek = this.cache;\n\t\t\t\tcachek.once('error', errorHandler);\n\t\t\t\tee.on('error', () => {\n\t\t\t\t\tcachek.removeListener('error', errorHandler);\n\t\t\t\t});\n\t\t\t\tee.on('response', () => {\n\t\t\t\t\tcachek.removeListener('error', errorHandler);\n\t\t\t\t});\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tawait get(options);\n\t\t\t} catch (error: any) {\n\t\t\t\tif (options.automaticFailover && !madeRequest) {\n\t\t\t\t\tmakeRequest(options);\n\t\t\t\t}\n\n\t\t\t\tee.emit('error', new CacheError(error));\n\t\t\t}\n\t\t})();\n\n\t\treturn ee;\n\t};\n\n\taddHook = (name: string, function_: Function_) => {\n\t\tif (!this.hooks.has(name)) {\n\t\t\tthis.hooks.set(name, function_);\n\t\t}\n\t};\n\n\tremoveHook = (name: string) => this.hooks.delete(name);\n\n\tgetHook = (name: string) => this.hooks.get(name);\n\n\trunHook = async (name: string, ...arguments_: any[]): Promise<CacheValue> => this.hooks.get(name)?.(...arguments_);\n}\n\nconst entries = Object.entries as <T>(object: T) => Array<[keyof T, T[keyof T]]>;\n\nconst cloneResponse = (response: IncomingMessage) => {\n\tconst clone = new PassThroughStream({autoDestroy: false});\n\tmimicResponse(response, clone);\n\n\treturn response.pipe(clone);\n};\n\nconst urlObjectToRequestOptions = (url: any) => {\n\tconst options: UrlOption = {...url};\n\toptions.path = `${url.pathname || '/'}${url.search || ''}`;\n\tdelete options.pathname;\n\tdelete options.search;\n\treturn options;\n};\n\nconst normalizeUrlObject = (url: any) =>\n// If url was parsed by url.parse or new URL:\n// - hostname will be set\n// - host will be hostname[:port]\n// - port will be set if it was explicit in the parsed string\n// Otherwise, url was from request options:\n// - hostname or host may be set\n// - host shall not have port encoded\n\t({\n\t\tprotocol: url.protocol,\n\t\tauth: url.auth,\n\t\thostname: url.hostname || url.host || 'localhost',\n\t\tport: url.port,\n\t\tpathname: url.pathname,\n\t\tsearch: url.search,\n\t});\n\nconst convertHeaders = (headers: CachePolicy.Headers) => {\n\tconst result: any = [];\n\tfor (const name of Object.keys(headers)) {\n\t\tresult[name.toLowerCase()] = headers[name];\n\t}\n\n\treturn result;\n};\n\nexport const parseWithWhatwg = (raw: string) => {\n\tconst u = new URL(raw);\n\n\t// If normalizeUrlObject expects the same fields as url.parse()\n\treturn {\n\t\tprotocol: u.protocol, // E.g. 'https:'\n\t\tslashes: true, // Always true for WHATWG URLs\n\t\t/* c8 ignore next 3 */\n\t\tauth: u.username || u.password\n\t\t\t? `${u.username}:${u.password}`\n\t\t\t: undefined,\n\t\thost: u.host, // E.g. 'example.com:8080'\n\t\tport: u.port, // E.g. '8080'\n\t\thostname: u.hostname, // E.g. 'example.com'\n\t\thash: u.hash, // E.g. '#quux'\n\t\tsearch: u.search, // E.g. '?bar=baz'\n\t\tquery: Object.fromEntries(u.searchParams), // { bar: 'baz' }\n\t\tpathname: u.pathname, // E.g. '/foo'\n\t\tpath: u.pathname + u.search, // '/foo?bar=baz'\n\t\thref: u.href, // Full serialized URL\n\t};\n};\n\nexport default CacheableRequest;\nexport * from './types.js';\nexport const onResponse = 'onResponse';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AASA,OAAO,EACN,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EACtD,MAAM,WAAW,CAAC;AACnB,OAAO,EAAC,GAAG,EAAC,MAAM,UAAU,CAAC;AAC7B,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AACzC,OAAO,EAAC,MAAM,EAA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IACxE,CAAC;CACD","sourcesContent":["// Type definitions for cacheable-request 6.0\n// Project: https://github.com/lukechilds/cacheable-request#readme\n// Definitions by: BendingBender <https://github.com/BendingBender>\n// Paul Melnikow <https://github.com/paulmelnikow>\n// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped\n// TypeScript Version: 2.3\n\n/// <reference types=\"node\" />\n\nimport {\n\trequest, RequestOptions, ClientRequest, ServerResponse,\n} from 'node:http';\nimport {URL} from 'node:url';\nimport {EventEmitter} from 'node:events';\nimport {Buffer} from 'node:buffer';\nimport ResponseLike from 'responselike';\nimport {CachePolicyObject} from 'http-cache-semantics';\n\n// eslint-disable-next-line unicorn/prevent-abbreviations\nexport type RequestFn = typeof request;\nexport type RequestFunction = typeof request;\nexport type CacheResponse = ServerResponse | typeof ResponseLike;\n\nexport type CacheableRequestFunction = (\n\toptions: CacheableOptions,\n\tcallback?: (response: CacheResponse) => void\n) => Emitter;\n\nexport type CacheableOptions = Options & RequestOptions | string | URL;\n\nexport interface Options {\n\t/**\n\t\t\t * If the cache should be used. Setting this to `false` will completely bypass the cache for the current request.\n\t\t\t * @default true\n\t\t\t */\n\tcache?: boolean | undefined;\n\n\t/**\n\t\t\t * If set to `true` once a cached resource has expired it is deleted and will have to be re-requested.\n\t\t\t *\n\t\t\t * If set to `false`, after a cached resource's TTL expires it is kept in the cache and will be revalidated\n\t\t\t * on the next request with `If-None-Match`/`If-Modified-Since` headers.\n\t\t\t * @default false\n\t\t\t */\n\tstrictTtl?: boolean | undefined;\n\n\t/**\n\t\t\t * Limits TTL. The `number` represents milliseconds.\n\t\t\t * @default undefined\n\t\t\t */\n\tmaxTtl?: number | undefined;\n\n\t/**\n\t\t\t * When set to `true`, if the DB connection fails we will automatically fallback to a network request.\n\t\t\t * DB errors will still be emitted to notify you of the problem even though the request callback may succeed.\n\t\t\t * @default false\n\t\t\t */\n\tautomaticFailover?: boolean | undefined;\n\n\t/**\n * Forces refreshing the cache. If the response could be retrieved from the cache, it will perform a\n * new request and override the cache instead.\n * @default false\n */\n\tforceRefresh?: boolean | undefined;\n\tremoteAddress?: boolean | undefined;\n\n\turl?: string | undefined;\n\n\theaders?: Record<string, string | string[] | undefined>;\n\n\tbody?: Buffer;\n}\n\nexport interface CacheValue extends Record<string, any> {\n\turl: string;\n\tstatusCode: number;\n\tbody: Buffer | string;\n\tcachePolicy: CachePolicyObject;\n}\n\nexport interface Emitter extends EventEmitter {\n\taddListener(event: 'request', listener: (request: ClientRequest) => void): this;\n\taddListener(\n\t\tevent: 'response',\n\t\tlistener: (response: CacheResponse) => void\n\t): this;\n\taddListener(event: 'error', listener: (error: RequestError | CacheError) => void): this;\n\ton(event: 'request', listener: (request: ClientRequest) => void): this;\n\ton(event: 'response', listener: (response: CacheResponse) => void): this;\n\ton(event: 'error', listener: (error: RequestError | CacheError) => void): this;\n\tonce(event: 'request', listener: (request: ClientRequest) => void): this;\n\tonce(event: 'response', listener: (response: CacheResponse) => void): this;\n\tonce(event: 'error', listener: (error: RequestError | CacheError) => void): this;\n\tprependListener(event: 'request', listener: (request: ClientRequest) => void): this;\n\tprependListener(\n\t\tevent: 'response',\n\t\tlistener: (response: CacheResponse) => void\n\t): this;\n\tprependListener(event: 'error', listener: (error: RequestError | CacheError) => void): this;\n\tprependOnceListener(event: 'request', listener: (request: ClientRequest) => void): this;\n\tprependOnceListener(\n\t\tevent: 'response',\n\t\tlistener: (response: CacheResponse) => void\n\t): this;\n\tprependOnceListener(\n\t\tevent: 'error',\n\t\tlistener: (error: RequestError | CacheError) => void\n\t): this;\n\tremoveListener(event: 'request', listener: (request: ClientRequest) => void): this;\n\tremoveListener(\n\t\tevent: 'response',\n\t\tlistener: (response: CacheResponse) => void\n\t): this;\n\tremoveListener(event: 'error', listener: (error: RequestError | CacheError) => void): this;\n\toff(event: 'request', listener: (request: ClientRequest) => void): this;\n\toff(event: 'response', listener: (response: CacheResponse) => void): this;\n\toff(event: 'error', listener: (error: RequestError | CacheError) => void): this;\n\tremoveAllListeners(event?: 'request' | 'response' | 'error'): this;\n\tlisteners(event: 'request'): Array<(request: ClientRequest) => void>;\n\tlisteners(event: 'response'): Array<(response: CacheResponse) => void>;\n\tlisteners(event: 'error'): Array<(error: RequestError | CacheError) => void>;\n\trawListeners(event: 'request'): Array<(request: ClientRequest) => void>;\n\trawListeners(event: 'response'): Array<(response: CacheResponse) => void>;\n\trawListeners(event: 'error'): Array<(error: RequestError | CacheError) => void>;\n\temit(event: 'request', request: ClientRequest): boolean;\n\temit(event: 'response', response: CacheResponse): boolean;\n\temit(event: 'error', error: RequestError | CacheError): boolean;\n\teventNames(): Array<'request' | 'response' | 'error'>;\n\tlistenerCount(type: 'request' | 'response' | 'error'): number;\n}\n\nexport class RequestError extends Error {\n\tconstructor(error: Error) {\n\t\tsuper(error.message);\n\t\tObject.defineProperties(this, Object.getOwnPropertyDescriptors(error));\n\t}\n}\n\nexport class CacheError extends Error {\n\tconstructor(error: Error) {\n\t\tsuper(error.message);\n\t\tObject.defineProperties(this, Object.getOwnPropertyDescriptors(error));\n\t}\n}\n\nexport interface UrlOption {\n\tpath: string;\n\tpathname?: string;\n\tsearch?: string;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,kEAAkE;AAClE,mEAAmE;AACnE,kEAAkE;AAClE,kEAAkE;AAClE,0BAA0B;AAgI1B,MAAM,OAAO,YAAa,SAAQ,KAAK;IACtC,YAAY,KAAY;QACvB,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACrB,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC;IACxE,CAAC;CACD;AAED,MAAM,OAAO,UAAW,SAAQ,KAAK;IACpC,YAAY,KAAY;QACvB,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACrB,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC;IACxE,CAAC;CACD","sourcesContent":["// Type definitions for cacheable-request 6.0\n// Project: https://github.com/lukechilds/cacheable-request#readme\n// Definitions by: BendingBender <https://github.com/BendingBender>\n// Paul Melnikow <https://github.com/paulmelnikow>\n// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped\n// TypeScript Version: 2.3\n\n/// <reference types=\"node\" />\n\nimport {\n\trequest, RequestOptions, ClientRequest, ServerResponse,\n} from 'node:http';\nimport {URL} from 'node:url';\nimport {EventEmitter} from 'node:events';\nimport {Buffer} from 'node:buffer';\nimport ResponseLike from 'responselike';\nimport {CachePolicyObject} from 'http-cache-semantics';\n\nexport type RequestFn = typeof request;\nexport type RequestFunction = typeof request;\nexport type CacheResponse = ServerResponse | typeof ResponseLike;\n\nexport type CacheableRequestFunction = (\n\toptions: CacheableOptions,\n\tcallback?: (response: CacheResponse) => void\n) => Emitter;\n\nexport type CacheableOptions = Options & RequestOptions | string | URL;\n\nexport interface Options {\n\t/**\n\t\t\t * If the cache should be used. Setting this to `false` will completely bypass the cache for the current request.\n\t\t\t * @default true\n\t\t\t */\n\tcache?: boolean | undefined;\n\n\t/**\n\t\t\t * If set to `true` once a cached resource has expired it is deleted and will have to be re-requested.\n\t\t\t *\n\t\t\t * If set to `false`, after a cached resource's TTL expires it is kept in the cache and will be revalidated\n\t\t\t * on the next request with `If-None-Match`/`If-Modified-Since` headers.\n\t\t\t * @default false\n\t\t\t */\n\tstrictTtl?: boolean | undefined;\n\n\t/**\n\t\t\t * Limits TTL. The `number` represents milliseconds.\n\t\t\t * @default undefined\n\t\t\t */\n\tmaxTtl?: number | undefined;\n\n\t/**\n\t\t\t * When set to `true`, if the DB connection fails we will automatically fallback to a network request.\n\t\t\t * DB errors will still be emitted to notify you of the problem even though the request callback may succeed.\n\t\t\t * @default false\n\t\t\t */\n\tautomaticFailover?: boolean | undefined;\n\n\t/**\n * Forces refreshing the cache. If the response could be retrieved from the cache, it will perform a\n * new request and override the cache instead.\n * @default false\n */\n\tforceRefresh?: boolean | undefined;\n\tremoteAddress?: boolean | undefined;\n\n\turl?: string | undefined;\n\n\theaders?: Record<string, string | string[] | undefined>;\n\n\t// eslint-disable-next-line @typescript-eslint/no-restricted-types\n\tbody?: Buffer;\n}\n\nexport interface CacheValue extends Record<string, any> {\n\turl: string;\n\tstatusCode: number;\n\t// eslint-disable-next-line @typescript-eslint/no-restricted-types\n\tbody: Buffer | string;\n\tcachePolicy: CachePolicyObject;\n}\n\nexport interface Emitter extends EventEmitter {\n\taddListener(event: 'request', listener: (request: ClientRequest) => void): this;\n\taddListener(\n\t\tevent: 'response',\n\t\tlistener: (response: CacheResponse) => void\n\t): this;\n\taddListener(event: 'error', listener: (error: RequestError | CacheError) => void): this;\n\ton(event: 'request', listener: (request: ClientRequest) => void): this;\n\ton(event: 'response', listener: (response: CacheResponse) => void): this;\n\ton(event: 'error', listener: (error: RequestError | CacheError) => void): this;\n\tonce(event: 'request', listener: (request: ClientRequest) => void): this;\n\tonce(event: 'response', listener: (response: CacheResponse) => void): this;\n\tonce(event: 'error', listener: (error: RequestError | CacheError) => void): this;\n\tprependListener(event: 'request', listener: (request: ClientRequest) => void): this;\n\tprependListener(\n\t\tevent: 'response',\n\t\tlistener: (response: CacheResponse) => void\n\t): this;\n\tprependListener(event: 'error', listener: (error: RequestError | CacheError) => void): this;\n\tprependOnceListener(event: 'request', listener: (request: ClientRequest) => void): this;\n\tprependOnceListener(\n\t\tevent: 'response',\n\t\tlistener: (response: CacheResponse) => void\n\t): this;\n\tprependOnceListener(\n\t\tevent: 'error',\n\t\tlistener: (error: RequestError | CacheError) => void\n\t): this;\n\tremoveListener(event: 'request', listener: (request: ClientRequest) => void): this;\n\tremoveListener(\n\t\tevent: 'response',\n\t\tlistener: (response: CacheResponse) => void\n\t): this;\n\tremoveListener(event: 'error', listener: (error: RequestError | CacheError) => void): this;\n\toff(event: 'request', listener: (request: ClientRequest) => void): this;\n\toff(event: 'response', listener: (response: CacheResponse) => void): this;\n\toff(event: 'error', listener: (error: RequestError | CacheError) => void): this;\n\tremoveAllListeners(event?: 'request' | 'response' | 'error'): this;\n\tlisteners(event: 'request'): Array<(request: ClientRequest) => void>;\n\tlisteners(event: 'response'): Array<(response: CacheResponse) => void>;\n\tlisteners(event: 'error'): Array<(error: RequestError | CacheError) => void>;\n\trawListeners(event: 'request'): Array<(request: ClientRequest) => void>;\n\trawListeners(event: 'response'): Array<(response: CacheResponse) => void>;\n\trawListeners(event: 'error'): Array<(error: RequestError | CacheError) => void>;\n\temit(event: 'request', request: ClientRequest): boolean;\n\temit(event: 'response', response: CacheResponse): boolean;\n\temit(event: 'error', error: RequestError | CacheError): boolean;\n\teventNames(): Array<'request' | 'response' | 'error'>;\n\tlistenerCount(type: 'request' | 'response' | 'error'): number;\n}\n\nexport class RequestError extends Error {\n\tconstructor(error: Error) {\n\t\tsuper(error.message);\n\t\tObject.defineProperties(this, Object.getOwnPropertyDescriptors(error));\n\t}\n}\n\nexport class CacheError extends Error {\n\tconstructor(error: Error) {\n\t\tsuper(error.message);\n\t\tObject.defineProperties(this, Object.getOwnPropertyDescriptors(error));\n\t}\n}\n\nexport interface UrlOption {\n\tpath: string;\n\tpathname?: string;\n\tsearch?: string;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cacheable-request",
3
- "version": "13.0.6",
3
+ "version": "13.0.7",
4
4
  "description": "Wrap native HTTP requests with RFC compliant cache support",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -37,27 +37,27 @@
37
37
  "dependencies": {
38
38
  "@types/http-cache-semantics": "^4.0.4",
39
39
  "get-stream": "^9.0.1",
40
- "http-cache-semantics": "^4.1.1",
40
+ "http-cache-semantics": "^4.2.0",
41
41
  "keyv": "^5.3.3",
42
42
  "mimic-response": "^4.0.0",
43
43
  "normalize-url": "^8.0.1",
44
44
  "responselike": "^3.0.0"
45
45
  },
46
46
  "devDependencies": {
47
- "@keyv/sqlite": "^4.0.3",
48
- "@types/node": "^22.15.4",
47
+ "@keyv/sqlite": "^4.0.4",
48
+ "@types/node": "^22.15.30",
49
49
  "@types/responselike": "^1.0.3",
50
- "@vitest/coverage-v8": "^3.1.3",
50
+ "@vitest/coverage-v8": "^3.2.2",
51
51
  "body-parser": "^2.2.0",
52
52
  "delay": "^6.0.0",
53
53
  "express": "^4.21.2",
54
54
  "pify": "^6.1.0",
55
55
  "rimraf": "^6.0.1",
56
56
  "sqlite3": "^5.1.7",
57
- "tsup": "^8.4.0",
57
+ "tsup": "^8.5.0",
58
58
  "typescript": "^5.8.3",
59
- "vitest": "^3.1.3",
60
- "xo": "^0.60.0"
59
+ "vitest": "^3.2.2",
60
+ "xo": "^1.1.0"
61
61
  },
62
62
  "xo": {
63
63
  "rules": {
@@ -80,7 +80,8 @@
80
80
  "n/no-deprecated-api": 0,
81
81
  "unicorn/prefer-event-target": 0,
82
82
  "@typescript-eslint/no-unnecessary-type-assertion": 0,
83
- "promise/prefer-await-to-then": 0
83
+ "promise/prefer-await-to-then": 0,
84
+ "@typescript-eslint/no-unnecessary-boolean-literal-compare": 0
84
85
  }
85
86
  },
86
87
  "scripts": {