Comparing version 4.0.3 to 5.0.0-next.1
@@ -0,1 +1,13 @@ | ||
# [5.0.0-next.1](https://github.com/alexghr/got-fetch/compare/v4.0.3...v5.0.0-next.1) (2021-12-18) | ||
### Features | ||
* support got@12 ([#61](https://github.com/alexghr/got-fetch/issues/61)) ([83257f1](https://github.com/alexghr/got-fetch/commit/83257f1ae463f369d49e41b8a6c8ffac6928f2d5)) | ||
### BREAKING CHANGES | ||
* no longer supports got@11 | ||
## [4.0.3](https://github.com/alexghr/got-fetch/compare/v4.0.2...v4.0.3) (2021-12-14) | ||
@@ -2,0 +14,0 @@ |
@@ -1,26 +0,31 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createFetch = void 0; | ||
const tslib_1 = require("tslib"); | ||
const stream_1 = require("stream"); | ||
const url_1 = require("url"); | ||
const util_1 = require("util"); | ||
const response_1 = require("./response"); | ||
function createFetch(got) { | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
import { Readable } from 'stream'; | ||
import { URL, URLSearchParams } from 'url'; | ||
import { format } from 'util'; | ||
import { GotFetchResponse } from './response.js'; | ||
export function createFetch(got) { | ||
const globalCache = new Map(); | ||
return (input, opts) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { | ||
const url = new url_1.URL(typeof input === 'string' ? input : input.url); | ||
return (input, opts) => __awaiter(this, void 0, void 0, function* () { | ||
const url = new URL(typeof input === 'string' ? input : input.url); | ||
const request = typeof input === 'object' ? input : opts || {}; | ||
if (request.mode === 'no-cors' || request.mode === 'same-origin' || request.mode === 'navigate') { | ||
throw new TypeError((0, util_1.format)('request.mode not supported: %s', request.mode)); | ||
throw new TypeError(format('request.mode not supported: %s', request.mode)); | ||
} | ||
if (request.cache === 'only-if-cached') { | ||
throw new TypeError((0, util_1.format)('request.cache not supported: %s', request.cache)); | ||
throw new TypeError(format('request.cache not supported: %s', request.cache)); | ||
} | ||
if (request.redirect === 'error' || request.redirect === 'manual') { | ||
throw new TypeError((0, util_1.format)('request.redirect not supported: %s', request.redirect)); | ||
throw new TypeError(format('request.redirect not supported: %s', request.redirect)); | ||
} | ||
// naive check to make sure headers are a plain object | ||
if (request.headers && typeof request.headers !== 'object') { | ||
throw new TypeError((0, util_1.format)('request.headers must be plain object: %j', request.headers)); | ||
throw new TypeError(format('request.headers must be plain object: %j', request.headers)); | ||
} | ||
@@ -32,3 +37,3 @@ // got does not merge base searchParams with the url's searchParams | ||
// https://github.com/sindresorhus/got/issues/1188 | ||
const searchParams = new url_1.URLSearchParams(url.searchParams); | ||
const searchParams = new URLSearchParams(url.searchParams); | ||
url.search = ''; | ||
@@ -69,3 +74,3 @@ const gotOpts = { | ||
return response.then(r => { | ||
return new response_1.GotFetchResponse(r.body, { | ||
return new GotFetchResponse(r.body, { | ||
headers: r.headers, | ||
@@ -80,3 +85,3 @@ redirected: r.redirectUrls && r.redirectUrls.length > 0, | ||
// supported by anything below Node 16.8 | ||
? r.redirectUrls[r.redirectUrls.length - 1] | ||
? r.redirectUrls[r.redirectUrls.length - 1].href | ||
: url.href, | ||
@@ -87,3 +92,2 @@ }); | ||
} | ||
exports.createFetch = createFetch; | ||
function serializeBody(body) { | ||
@@ -93,3 +97,3 @@ if (!body) { | ||
} | ||
else if (body instanceof url_1.URLSearchParams) { | ||
else if (body instanceof URLSearchParams) { | ||
const serialized = body.toString(); | ||
@@ -113,3 +117,3 @@ return { | ||
} | ||
else if (Buffer.isBuffer(body) || (body instanceof stream_1.Readable)) { | ||
else if (Buffer.isBuffer(body) || (body instanceof Readable)) { | ||
return { | ||
@@ -116,0 +120,0 @@ body, |
@@ -1,7 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
const got_1 = (0, tslib_1.__importDefault)(require("got")); | ||
const fetch_1 = require("./fetch"); | ||
exports.default = (0, fetch_1.createFetch)(got_1.default); | ||
import got from 'got'; | ||
import { createFetch } from './fetch.js'; | ||
export default createFetch(got); | ||
//# sourceMappingURL=global-fetch.js.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GotHeaders = void 0; | ||
class GotHeaders { | ||
export class GotHeaders { | ||
constructor(headers, guard = 'none') { | ||
@@ -67,3 +64,2 @@ const init = headers ? Object.entries(headers).map(([name, values]) => { | ||
} | ||
exports.GotHeaders = GotHeaders; | ||
//# sourceMappingURL=headers.js.map |
@@ -1,5 +0,5 @@ | ||
import { createFetch } from './fetch'; | ||
import fetch from './global-fetch'; | ||
import { createFetch } from './fetch.js'; | ||
import fetch from './global-fetch.js'; | ||
export { createFetch, fetch }; | ||
export default fetch; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,10 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.fetch = exports.createFetch = void 0; | ||
const tslib_1 = require("tslib"); | ||
const fetch_1 = require("./fetch"); | ||
Object.defineProperty(exports, "createFetch", { enumerable: true, get: function () { return fetch_1.createFetch; } }); | ||
const global_fetch_1 = (0, tslib_1.__importDefault)(require("./global-fetch")); | ||
exports.fetch = global_fetch_1.default; | ||
exports.default = global_fetch_1.default; | ||
import { createFetch } from './fetch.js'; | ||
import fetch from './global-fetch.js'; | ||
export { createFetch, fetch }; | ||
export default fetch; | ||
//# sourceMappingURL=index.js.map |
@@ -7,3 +7,3 @@ /** | ||
import { IncomingHttpHeaders } from 'http2'; | ||
import { GotHeaders } from './headers'; | ||
import { GotHeaders } from './headers.js'; | ||
declare type ResponseInit = { | ||
@@ -10,0 +10,0 @@ status?: number; |
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
/** | ||
@@ -6,14 +5,12 @@ * Spec: | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GotFetchResponse = void 0; | ||
const util_1 = require("util"); | ||
const headers_1 = require("./headers"); | ||
class GotFetchResponse { | ||
import { format } from 'util'; | ||
import { GotHeaders } from './headers.js'; | ||
export class GotFetchResponse { | ||
constructor(body, init) { | ||
if (init && typeof init.status === 'number' && (init.status < 200 || init.status > 599)) { | ||
throw new RangeError((0, util_1.format)('init.status is out of range: %s', init.status)); | ||
throw new RangeError(format('init.status is out of range: %s', init.status)); | ||
} | ||
this.body = body; | ||
this.type = init && init.type || 'basic'; | ||
this.headers = new headers_1.GotHeaders(init ? init.headers : undefined, 'immutable'); | ||
this.headers = new GotHeaders(init ? init.headers : undefined, 'immutable'); | ||
this.status = init && init.status || 0; | ||
@@ -69,3 +66,2 @@ this.statusText = String(init && init.statusText || ''); | ||
} | ||
exports.GotFetchResponse = GotFetchResponse; | ||
//# sourceMappingURL=response.js.map |
{ | ||
"name": "got-fetch", | ||
"version": "4.0.3", | ||
"version": "5.0.0-next.1", | ||
"type": "module", | ||
"license": "MIT", | ||
@@ -17,2 +18,5 @@ "description": "A fetch-compatible interface to the got HTTP client", | ||
"types": "./out/lib", | ||
"exports": { | ||
".": "./out/lib/index.js" | ||
}, | ||
"scripts": { | ||
@@ -28,3 +32,3 @@ "build": "$npm_execpath run build:lib", | ||
"pretest": "$npm_execpath run build:test", | ||
"test": "jest", | ||
"test": "NODE_OPTIONS=--experimental-vm-modules jest", | ||
"pretest:watch": "$npm_execpath run build:test", | ||
@@ -35,5 +39,3 @@ "test:watch": "concurrently '$npm_execpath run build:test:watch' 'jest --watchAll'", | ||
}, | ||
"dependencies": { | ||
"tslib": "^2.3.1" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
@@ -47,3 +49,3 @@ "@semantic-release/changelog": "^6.0.1", | ||
"@types/nock": "^11.1.0", | ||
"@types/node": "^16.11.12", | ||
"@types/node": "^17.0.0", | ||
"@typescript-eslint/eslint-plugin": "^5.7.0", | ||
@@ -54,4 +56,4 @@ "@typescript-eslint/parser": "^5.7.0", | ||
"eslint": "^8.4.1", | ||
"got": "^11.0.2", | ||
"jest": "^27.4.3", | ||
"got": "^12.0.0", | ||
"jest": "^27.4.5", | ||
"nock": "^13.2.1", | ||
@@ -62,3 +64,3 @@ "semantic-release": "^18.0.0", | ||
"peerDependencies": { | ||
"got": "^11.0.0" | ||
"got": "^12.0.0" | ||
}, | ||
@@ -65,0 +67,0 @@ "engines": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
22258
1
22
366
Yes
1
1
+ Added@sindresorhus/is@5.6.0(transitive)
+ Added@szmarczak/http-timer@5.0.1(transitive)
+ Addedcacheable-lookup@7.0.0(transitive)
+ Addedcacheable-request@10.2.14(transitive)
+ Addedform-data-encoder@2.1.4(transitive)
+ Addedget-stream@6.0.1(transitive)
+ Addedgot@12.6.1(transitive)
+ Addedhttp2-wrapper@2.2.1(transitive)
+ Addedlowercase-keys@3.0.0(transitive)
+ Addedmimic-response@4.0.0(transitive)
+ Addednormalize-url@8.0.1(transitive)
+ Addedp-cancelable@3.0.0(transitive)
+ Addedresponselike@3.0.0(transitive)
- Removedtslib@^2.3.1
- Removed@sindresorhus/is@4.6.0(transitive)
- Removed@szmarczak/http-timer@4.0.6(transitive)
- Removed@types/cacheable-request@6.0.3(transitive)
- Removed@types/keyv@3.1.4(transitive)
- Removed@types/node@22.10.2(transitive)
- Removed@types/responselike@1.0.3(transitive)
- Removedcacheable-lookup@5.0.4(transitive)
- Removedcacheable-request@7.0.4(transitive)
- Removedclone-response@1.0.3(transitive)
- Removedend-of-stream@1.4.4(transitive)
- Removedget-stream@5.2.0(transitive)
- Removedgot@11.8.6(transitive)
- Removedhttp2-wrapper@1.0.3(transitive)
- Removedlowercase-keys@2.0.0(transitive)
- Removedmimic-response@1.0.1(transitive)
- Removednormalize-url@6.1.0(transitive)
- Removedonce@1.4.0(transitive)
- Removedp-cancelable@2.1.1(transitive)
- Removedpump@3.0.2(transitive)
- Removedresponselike@2.0.1(transitive)
- Removedtslib@2.8.1(transitive)
- Removedundici-types@6.20.0(transitive)
- Removedwrappy@1.0.2(transitive)