@applitools/req
Advanced tools
Comparing version 1.1.35 to 1.2.0
@@ -1,29 +0,3 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = exports.AbortSignal = exports.AbortController = exports.Response = exports.Request = void 0; | ||
var node_fetch_1 = require("node-fetch"); | ||
Object.defineProperty(exports, "Request", { enumerable: true, get: function () { return node_fetch_1.Request; } }); | ||
Object.defineProperty(exports, "Response", { enumerable: true, get: function () { return node_fetch_1.Response; } }); | ||
var abort_controller_1 = require("abort-controller"); | ||
Object.defineProperty(exports, "AbortController", { enumerable: true, get: function () { return abort_controller_1.AbortController; } }); | ||
Object.defineProperty(exports, "AbortSignal", { enumerable: true, get: function () { return abort_controller_1.AbortSignal; } }); | ||
__exportStar(require("./req"), exports); | ||
var req_1 = require("./req"); | ||
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(req_1).default; } }); | ||
export { Request, Response, Headers } from 'node-fetch'; | ||
export * from './req.js'; | ||
export { req as default } from './req.js'; |
211
dist/req.js
@@ -1,69 +0,19 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.req = exports.makeReq = exports.mergeOptions = void 0; | ||
const url_1 = require("url"); // should be replaced with `urlToHttpOptions` after supporting node >=16 | ||
const abort_controller_1 = require("abort-controller"); | ||
const https_1 = require("https"); | ||
const node_fetch_1 = __importStar(require("node-fetch")); | ||
const proxy_agent_1 = __importDefault(require("proxy-agent")); | ||
const utils = __importStar(require("@applitools/utils")); | ||
const stop = Symbol('stop retry'); | ||
import { AbortController } from 'abort-controller'; | ||
import { parse as urlToHttpOptions } from 'url'; // should be replaced with `urlToHttpOptions` after supporting node >=16 | ||
import { Agent as HttpsAgent } from 'https'; | ||
import { stop } from './stop.js'; | ||
import globalFetch, { Request, Headers, Response } from 'node-fetch'; | ||
import ProxyAgent from 'proxy-agent'; | ||
import * as utils from '@applitools/utils'; | ||
/** | ||
* Helper function that will properly merge two {@link Options} objects | ||
*/ | ||
function mergeOptions(baseOption, options) { | ||
const mergedOptions = { | ||
...baseOption, | ||
...options, | ||
query: { ...baseOption.query, ...options === null || options === void 0 ? void 0 : options.query }, | ||
headers: { ...baseOption.headers, ...options === null || options === void 0 ? void 0 : options.headers }, | ||
retry: [ | ||
...(baseOption.retry ? [].concat(baseOption.retry) : []), | ||
...((options === null || options === void 0 ? void 0 : options.retry) ? [].concat(options.retry) : []), | ||
], | ||
hooks: [ | ||
...(baseOption.hooks ? [].concat(baseOption.hooks) : []), | ||
...((options === null || options === void 0 ? void 0 : options.hooks) ? [].concat(options.hooks) : []), | ||
], | ||
}; | ||
return mergedOptions.hooks.reduce((options, hooks) => { var _a, _b; return (_b = (_a = hooks.afterOptionsMerged) === null || _a === void 0 ? void 0 : _a.call(hooks, { options })) !== null && _b !== void 0 ? _b : options; }, mergedOptions); | ||
} | ||
exports.mergeOptions = mergeOptions; | ||
/** | ||
* Helper function that will create {@link req} function with predefined options | ||
* @example const req = makeReq({baseUrl: 'http://localhost:2107'}) | ||
*/ | ||
function makeReq(baseOption) { | ||
return (location, options) => req(location, mergeOptions(baseOption, options)); | ||
export function makeReq(baseOptions) { | ||
return (location, options) => req(location, mergeOptions(baseOptions, options !== null && options !== void 0 ? options : {})); | ||
} | ||
exports.makeReq = makeReq; | ||
async function req(input, options) { | ||
export async function req(input, ...requestOptions) { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m; | ||
const fetch = (_a = options === null || options === void 0 ? void 0 : options.fetch) !== null && _a !== void 0 ? _a : node_fetch_1.default; | ||
const options = mergeOptions({}, ...requestOptions); | ||
const fetch = (_a = options === null || options === void 0 ? void 0 : options.fetch) !== null && _a !== void 0 ? _a : globalFetch; | ||
if (options === null || options === void 0 ? void 0 : options.hooks) | ||
@@ -76,40 +26,3 @@ options.hooks = utils.types.isArray(options.hooks) ? options.hooks : [options.hooks]; | ||
} | ||
const beforeRequest = ({ request, ...rest }) => { | ||
var _a; | ||
return ((_a = options === null || options === void 0 ? void 0 : options.hooks) !== null && _a !== void 0 ? _a : []).reduce(async (request, hooks) => { | ||
var _a; | ||
request = await request; | ||
const result = (await ((_a = hooks.beforeRequest) === null || _a === void 0 ? void 0 : _a.call(hooks, { request, ...rest }))) || null; | ||
return result !== null && result !== void 0 ? result : request; | ||
}, request); | ||
}; | ||
const beforeRetry = ({ request, ...rest }) => { | ||
var _a; | ||
return ((_a = options === null || options === void 0 ? void 0 : options.hooks) !== null && _a !== void 0 ? _a : []).reduce(async (request, hooks) => { | ||
var _a; | ||
request = await request; | ||
if (request === stop) | ||
return request; | ||
const result = (await ((_a = hooks.beforeRetry) === null || _a === void 0 ? void 0 : _a.call(hooks, { request, ...rest }))) || null; | ||
return result === stop ? result : result !== null && result !== void 0 ? result : request; | ||
}, request); | ||
}; | ||
const afterResponse = ({ response, ...rest }) => { | ||
var _a, _b; | ||
return (_b = ((_a = options === null || options === void 0 ? void 0 : options.hooks) !== null && _a !== void 0 ? _a : [])) === null || _b === void 0 ? void 0 : _b.reduce(async (response, hooks) => { | ||
var _a; | ||
response = await response; | ||
const result = (await ((_a = hooks.afterResponse) === null || _a === void 0 ? void 0 : _a.call(hooks, { response, ...rest }))) || null; | ||
return result !== null && result !== void 0 ? result : response; | ||
}, response); | ||
}; | ||
const afterError = ({ error, ...rest }) => { | ||
var _a, _b; | ||
return (_b = ((_a = options === null || options === void 0 ? void 0 : options.hooks) !== null && _a !== void 0 ? _a : [])) === null || _b === void 0 ? void 0 : _b.reduce(async (error, hooks) => { | ||
var _a; | ||
error = await error; | ||
return (await ((_a = hooks.afterError) === null || _a === void 0 ? void 0 : _a.call(hooks, { error, ...rest }))) || error; | ||
}, error); | ||
}; | ||
const controller = new abort_controller_1.AbortController(); | ||
const controller = new AbortController(); | ||
if (options === null || options === void 0 ? void 0 : options.signal) | ||
@@ -124,7 +37,7 @@ options.signal.onabort = () => controller.abort(); | ||
} | ||
let request = new node_fetch_1.Request(url, { | ||
let request = new Request(url, { | ||
method: (_c = options === null || options === void 0 ? void 0 : options.method) !== null && _c !== void 0 ? _c : input.method, | ||
headers: { | ||
...Object.fromEntries((_e = (_d = input.headers) === null || _d === void 0 ? void 0 : _d.entries()) !== null && _e !== void 0 ? _e : []), | ||
...Object.fromEntries(new node_fetch_1.Headers(options === null || options === void 0 ? void 0 : options.headers).entries()), | ||
...Object.fromEntries(new Headers(options === null || options === void 0 ? void 0 : options.headers).entries()), | ||
}, | ||
@@ -134,2 +47,3 @@ body: utils.types.isPlainObject(options === null || options === void 0 ? void 0 : options.body) || utils.types.isArray(options === null || options === void 0 ? void 0 : options.body) || (options === null || options === void 0 ? void 0 : options.body) === null | ||
: (_f = options === null || options === void 0 ? void 0 : options.body) !== null && _f !== void 0 ? _f : input.body, | ||
highWaterMark: 1024 * 1024 * 100 + 1, | ||
agent: url => { | ||
@@ -142,3 +56,3 @@ var _a, _b; | ||
proxyUrl.password = (_b = proxy.password) !== null && _b !== void 0 ? _b : proxyUrl.password; | ||
const agent = new proxy_agent_1.default({ ...(0, url_1.parse)(proxyUrl.href), rejectUnauthorized: false }); | ||
const agent = new ProxyAgent({ ...urlToHttpOptions(proxyUrl.href), rejectUnauthorized: false }); | ||
agent.callback = utils.general.wrap(agent.callback.bind(agent), (fn, request, options, ...rest) => { | ||
@@ -150,3 +64,3 @@ return fn(request, { ...options, rejectUnauthorized: false }, ...rest); | ||
else if (url.protocol === 'https:') { | ||
return new https_1.Agent({ rejectUnauthorized: false }); | ||
return new HttpsAgent({ rejectUnauthorized: false }); | ||
} | ||
@@ -161,10 +75,9 @@ }, | ||
// if the request has to be retried due to status code | ||
const retry = await ((_g = options === null || options === void 0 ? void 0 : options.retry) === null || _g === void 0 ? void 0 : _g.reduce((prev, retry) => { | ||
return prev.then(async (result) => { | ||
var _a, _b; | ||
return (result !== null && result !== void 0 ? result : ((((_a = retry.statuses) === null || _a === void 0 ? void 0 : _a.includes(response.status)) || (await ((_b = retry.validate) === null || _b === void 0 ? void 0 : _b.call(retry, { response })))) && | ||
(!retry.limit || !retry.attempt || retry.attempt < retry.limit) | ||
? retry | ||
: null)); | ||
}); | ||
const retry = await ((_g = options === null || options === void 0 ? void 0 : options.retry) === null || _g === void 0 ? void 0 : _g.reduce(async (prev, retry) => { | ||
var _a, _b; | ||
const result = await prev; | ||
return (result !== null && result !== void 0 ? result : ((((_a = retry.statuses) === null || _a === void 0 ? void 0 : _a.includes(response.status)) || (await ((_b = retry.validate) === null || _b === void 0 ? void 0 : _b.call(retry, { response })))) && | ||
(!retry.limit || !retry.attempt || retry.attempt < retry.limit) | ||
? retry | ||
: null)); | ||
}, Promise.resolve(null))); | ||
@@ -221,3 +134,73 @@ if (retry) { | ||
} | ||
exports.req = req; | ||
exports.default = req; | ||
function mergeOptions(baseOptions, ...options) { | ||
var _a; | ||
const mergedOptions = options.reduce((baseOptions, options) => ({ | ||
...baseOptions, | ||
...options, | ||
query: { ...baseOptions.query, ...options === null || options === void 0 ? void 0 : options.query }, | ||
headers: { ...baseOptions.headers, ...options === null || options === void 0 ? void 0 : options.headers }, | ||
retry: [ | ||
...(baseOptions.retry ? [].concat(baseOptions.retry) : []), | ||
...((options === null || options === void 0 ? void 0 : options.retry) ? [].concat(options.retry) : []), | ||
], | ||
hooks: [ | ||
...(baseOptions.hooks ? [].concat(baseOptions.hooks) : []), | ||
...((options === null || options === void 0 ? void 0 : options.hooks) ? [].concat(options.hooks) : []), | ||
], | ||
}), baseOptions); | ||
return ((_a = mergedOptions.hooks) !== null && _a !== void 0 ? _a : []).reduce((options, hooks) => { var _a, _b; return (_b = (_a = hooks.afterOptionsMerged) === null || _a === void 0 ? void 0 : _a.call(hooks, { options })) !== null && _b !== void 0 ? _b : options; }, mergedOptions); | ||
} | ||
function beforeRequest({ request, options, ...rest }) { | ||
var _a; | ||
return ((_a = options === null || options === void 0 ? void 0 : options.hooks) !== null && _a !== void 0 ? _a : []).reduce(async (request, hooks) => { | ||
var _a; | ||
request = await request; | ||
const result = await ((_a = hooks.beforeRequest) === null || _a === void 0 ? void 0 : _a.call(hooks, { request, options, ...rest })); | ||
if (!result) | ||
return request; | ||
else if (utils.types.instanceOf(result, Request)) | ||
return result; | ||
else | ||
return new Request(result.url, result); | ||
}, request); | ||
} | ||
function beforeRetry({ request, options, ...rest }) { | ||
var _a; | ||
return ((_a = options === null || options === void 0 ? void 0 : options.hooks) !== null && _a !== void 0 ? _a : []).reduce(async (request, hooks) => { | ||
var _a; | ||
request = await request; | ||
if (request === stop) | ||
return request; | ||
const result = await ((_a = hooks.beforeRetry) === null || _a === void 0 ? void 0 : _a.call(hooks, { request, options, ...rest })); | ||
if (result === stop) | ||
return result; | ||
else if (!result) | ||
return request; | ||
else if (utils.types.instanceOf(result, Request)) | ||
return result; | ||
else | ||
return new Request(result.url, result); | ||
}, request); | ||
} | ||
function afterResponse({ response, options, ...rest }) { | ||
var _a, _b; | ||
return (_b = (((_a = options === null || options === void 0 ? void 0 : options.hooks) !== null && _a !== void 0 ? _a : []))) === null || _b === void 0 ? void 0 : _b.reduce(async (response, hooks) => { | ||
var _a; | ||
response = await response; | ||
const result = await ((_a = hooks.afterResponse) === null || _a === void 0 ? void 0 : _a.call(hooks, { response, options, ...rest })); | ||
if (!result) | ||
return response; | ||
else if (utils.types.instanceOf(result, Response)) | ||
return result; | ||
else | ||
return new Response(result.body, result); | ||
}, response); | ||
} | ||
function afterError({ error, options, ...rest }) { | ||
var _a, _b; | ||
return (_b = (((_a = options === null || options === void 0 ? void 0 : options.hooks) !== null && _a !== void 0 ? _a : []))) === null || _b === void 0 ? void 0 : _b.reduce(async (error, hooks) => { | ||
var _a; | ||
error = await error; | ||
return (await ((_a = hooks.afterError) === null || _a === void 0 ? void 0 : _a.call(hooks, { error, ...rest }))) || error; | ||
}, error); | ||
} |
{ | ||
"name": "@applitools/req", | ||
"version": "1.1.35", | ||
"version": "1.2.0", | ||
"description": "Applitools fetch-based request library", | ||
@@ -28,15 +28,21 @@ "keywords": [ | ||
], | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"types": "./types/index.d.ts", | ||
"default": "./dist/index.js" | ||
"import": { | ||
"types": "./types/index.d.ts", | ||
"default": "./dist/index.js" | ||
}, | ||
"require": { | ||
"types": "./types/index.d.cts", | ||
"default": "./dist/index.cjs" | ||
} | ||
}, | ||
"./dist/*": "./dist/*.js", | ||
"./package.json": "./package.json" | ||
}, | ||
"main": "./dist/index.js", | ||
"types": "./types/index.d.cts", | ||
"main": "./dist/index.cjs", | ||
"browser": { | ||
"proxy-agent": false | ||
}, | ||
"types": "./types/index.d.ts", | ||
"files": [ | ||
@@ -48,3 +54,3 @@ "dist", | ||
"lint": "node ../../node_modules/.bin/eslint '**/*.ts'", | ||
"build": "node ../../node_modules/.bin/tsc --project ./tsconfig.build.json", | ||
"build": "node ../../node_modules/.bin/tspc --project ./tsconfig.build.json && cp ./types/index.d.ts ./types/index.d.cts", | ||
"test": "node ../../node_modules/.bin/mocha './test/**/*.spec.ts'", | ||
@@ -58,9 +64,9 @@ "test:sanity": "yarn test", | ||
"dependencies": { | ||
"@applitools/utils": "1.3.32", | ||
"@types/node-fetch": "2.6.2", | ||
"@applitools/utils": "1.3.33", | ||
"abort-controller": "3.0.0", | ||
"node-fetch": "2.6.7", | ||
"node-fetch": "3.3.1", | ||
"proxy-agent": "5.0.0" | ||
}, | ||
"devDependencies": { | ||
"@applitools/api-extractor": "^1.2.17", | ||
"@applitools/bongo": "^3.0.3", | ||
@@ -67,0 +73,0 @@ "@types/node": "^12.20.55", |
@@ -1,4 +0,130 @@ | ||
export { Request, Response } from 'node-fetch'; | ||
export { AbortController, AbortSignal } from 'abort-controller'; | ||
export * from './req'; | ||
export { default } from './req'; | ||
export type Stop = typeof stop; | ||
export class Request { | ||
constructor(input: URL | (string | Request), init?: undefined | RequestInit); | ||
readonly headers: Headers; | ||
readonly method: string; | ||
readonly redirect: "error" | "follow" | "manual"; | ||
readonly signal: { readonly aborted: boolean; addEventListener: (type: "abort", listener: () => void) => void; removeEventListener: (type: "abort", listener: () => void) => void; }; | ||
readonly url: string; | ||
readonly referrer: string; | ||
readonly referrerPolicy: "" | "origin" | "same-origin" | "no-referrer" | "no-referrer-when-downgrade" | "origin-when-cross-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url"; | ||
clone(): Request; | ||
readonly body: null | NodeJS.ReadableStream; | ||
readonly bodyUsed: boolean; | ||
readonly size: number; | ||
buffer(): Promise<Buffer>; | ||
arrayBuffer(): Promise<ArrayBuffer>; | ||
formData(): Promise<FormData>; | ||
blob(): Promise<Blob>; | ||
json(): Promise<unknown>; | ||
text(): Promise<string>; | ||
} | ||
export interface RequestInit { | ||
body?: undefined | null | BodyInit; | ||
headers?: undefined | HeadersInit; | ||
method?: undefined | string; | ||
redirect?: undefined | ("error" | "follow" | "manual"); | ||
signal?: undefined | null | { readonly aborted: boolean; addEventListener: (type: "abort", listener: () => void) => void; removeEventListener: (type: "abort", listener: () => void) => void; }; | ||
referrer?: undefined | string; | ||
referrerPolicy?: undefined | ("" | "origin" | "same-origin" | "no-referrer" | "no-referrer-when-downgrade" | "origin-when-cross-origin" | "strict-origin" | "strict-origin-when-cross-origin" | "unsafe-url"); | ||
agent?: undefined | boolean | import('http').Agent | ((parsedUrl: URL) => undefined | boolean | import('http').Agent); | ||
compress?: undefined | boolean; | ||
counter?: undefined | number; | ||
follow?: undefined | number; | ||
hostname?: undefined | string; | ||
port?: undefined | number; | ||
protocol?: undefined | string; | ||
size?: undefined | number; | ||
highWaterMark?: undefined | number; | ||
insecureHTTPParser?: undefined | boolean; | ||
} | ||
export class Response { | ||
static error(): Response; | ||
static redirect(url: string, status?: undefined | number): Response; | ||
static json(data: any, init?: undefined | ResponseInit): Response; | ||
constructor(body?: undefined | null | BodyInit, init?: undefined | ResponseInit); | ||
readonly headers: Headers; | ||
readonly ok: boolean; | ||
readonly redirected: boolean; | ||
readonly status: number; | ||
readonly statusText: string; | ||
readonly type: "basic" | "error" | "default" | "cors" | "opaque" | "opaqueredirect"; | ||
readonly url: string; | ||
clone(): Response; | ||
readonly body: null | NodeJS.ReadableStream; | ||
readonly bodyUsed: boolean; | ||
readonly size: number; | ||
buffer(): Promise<Buffer>; | ||
arrayBuffer(): Promise<ArrayBuffer>; | ||
formData(): Promise<FormData>; | ||
blob(): Promise<Blob>; | ||
json(): Promise<unknown>; | ||
text(): Promise<string>; | ||
} | ||
export interface ResponseInit { | ||
headers?: undefined | HeadersInit; | ||
status?: undefined | number; | ||
statusText?: undefined | string; | ||
} | ||
export class Headers { | ||
constructor(init?: undefined | HeadersInit); | ||
append(name: string, value: string): void; | ||
delete(name: string): void; | ||
get(name: string): null | string; | ||
has(name: string): boolean; | ||
set(name: string, value: string): void; | ||
forEach(callbackfn: (value: string, key: string, parent: Headers) => void, thisArg?: any): void; | ||
entries(): IterableIterator<[string, string]>; | ||
keys(): IterableIterator<string>; | ||
values(): IterableIterator<string>; | ||
raw(): Record<string, Array<string>>; | ||
'__@iterator@84'(): IterableIterator<[string, string]>; | ||
} | ||
export type HeadersInit = Record<string, string> | Headers | Iterable<[string, string]> | Iterable<Iterable<string>>; | ||
export type BodyInit = string | Blob | FormData | URLSearchParams | Buffer | NodeJS.ReadableStream; | ||
export default req; | ||
export type Fetch = (url: URL | (string | Request), init?: undefined | RequestInit) => Promise<Response>; | ||
export interface Options { | ||
baseUrl?: undefined | string; | ||
method?: undefined | string; | ||
query?: undefined | Record<string, undefined | string | number | boolean>; | ||
headers?: undefined | Record<string, undefined | string | Array<string>>; | ||
body?: undefined | null | string | Array<any> | ArrayBufferView | Record<string, any> | NodeJS.ReadableStream; | ||
proxy?: undefined | Proxy | ((url: URL) => undefined | Proxy); | ||
timeout?: undefined | number; | ||
retry?: undefined | Retry | Array<Retry>; | ||
hooks?: undefined | Hooks | Array<Hooks>; | ||
signal?: undefined | AbortSignal; | ||
fetch?: undefined | Fetch; | ||
} | ||
export interface Retry { | ||
limit?: undefined | number; | ||
timeout?: undefined | number | Array<number>; | ||
validate?: undefined | ((options: { response?: undefined | Response; error?: undefined | Error; }) => boolean | Promise<boolean>); | ||
statuses?: undefined | Array<number>; | ||
codes?: undefined | Array<string>; | ||
attempt?: undefined | number; | ||
} | ||
export interface Proxy { | ||
url: string; | ||
username?: undefined | string; | ||
password?: undefined | string; | ||
} | ||
export interface Hooks<TOptions extends Options = Options> { | ||
afterOptionsMerged?(options: { options: TOptions; }): void | TOptions; | ||
beforeRequest?(options: { request: Request; options?: undefined | TOptions; }): void | Request | (RequestInit & { url: string | URL; }) | Promise<void | Request | (RequestInit & { url: string | URL; })>; | ||
beforeRetry?(options: { | ||
request: Request; | ||
attempt: number; | ||
stop: Stop; | ||
response?: undefined | Response; | ||
error?: undefined | Error; | ||
options?: undefined | TOptions; | ||
}): void | Request | Stop | (RequestInit & { url: string | URL; }) | Promise<void | Request | Stop | (RequestInit & { url: string | URL; })>; | ||
afterResponse?(options: { request: Request; response: Response; options?: undefined | TOptions; }): void | Response | (ResponseInit & { body?: undefined | null | BodyInit; }) | Promise<void | Response | (ResponseInit & { body?: undefined | null | BodyInit; })>; | ||
afterError?(options: { request: Request; error: Error; options?: undefined | TOptions; }): void | Error | Promise<void | Error>; | ||
} | ||
export type AbortSignal = { readonly aborted: boolean; onabort: null | ((event: any) => void); addEventListener: (type: "abort", listener: () => void) => void; removeEventListener: (type: "abort", listener: () => void) => void; }; | ||
export function makeReq<TOptions extends Options = Options, TBaseOptions extends TOptions = TOptions>(baseOptions: Partial<TBaseOptions>): Req<TOptions>; | ||
export function req(input: string | URL | Request, ...requestOptions: Array<Options>): Promise<Response>; | ||
export type Req<TOptions extends Options = Options> = (input: string | URL | Request, ...options: Array<TOptions>) => Promise<Response>; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
43071
4
9
Yes
4
350
3
+ Added@applitools/utils@1.3.33(transitive)
+ Addeddata-uri-to-buffer@4.0.1(transitive)
+ Addedfetch-blob@3.2.0(transitive)
+ Addedformdata-polyfill@4.0.10(transitive)
+ Addednode-domexception@1.0.0(transitive)
+ Addednode-fetch@3.3.1(transitive)
+ Addedweb-streams-polyfill@3.3.3(transitive)
- Removed@types/node-fetch@2.6.2
- Removed@applitools/utils@1.3.32(transitive)
- Removed@types/node@22.9.0(transitive)
- Removed@types/node-fetch@2.6.2(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedform-data@3.0.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removednode-fetch@2.6.7(transitive)
- Removedtr46@0.0.3(transitive)
- Removedundici-types@6.19.8(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)
Updated@applitools/utils@1.3.33
Updatednode-fetch@3.3.1