got-scraping
Advanced tools
Comparing version 4.0.2 to 4.0.3-beta.0
// @ts-ignore Patch needed for ES20xx compatibility while this module uses Node16/NodeNext resolutions | ||
import * as got from 'got'; | ||
// @ts-ignore Patch needed for ES20xx compatibility while this module uses Node16/NodeNext resolutions | ||
import { Options, OptionsInit as OptionsInit$1, CancelableRequest, Response, Request, ExtendOptions, HTTPAlias, Got } from 'got'; | ||
import { Options, OptionsInit as OptionsInit$1, CancelableRequest, Response, Request, ExtendOptions, HTTPAlias, PaginationOptions, PaginateData, Got } from 'got'; | ||
// @ts-ignore Patch needed for ES20xx compatibility while this module uses Node16/NodeNext resolutions | ||
@@ -78,3 +78,3 @@ export * from 'got'; | ||
interface Context extends Record<string, unknown> { | ||
interface Context { | ||
proxyUrl?: string; | ||
@@ -88,9 +88,16 @@ headerGeneratorOptions?: Record<string, unknown>; | ||
sessionToken?: object; | ||
/** @private */ | ||
sessionData?: unknown; | ||
/** @private */ | ||
resolveProtocol?: (data: unknown) => { | ||
alpnProtocol: string; | ||
} | Promise<{ | ||
alpnProtocol: string; | ||
}>; | ||
} | ||
interface OptionsInit extends Context, OptionsInit$1 { | ||
} | ||
type OptionsInit = OptionsInit$1 & Context; | ||
type Except<ObjectType, KeysType extends keyof ObjectType> = Pick<ObjectType, Exclude<keyof ObjectType, KeysType>>; | ||
type Merge<FirstType, SecondType> = Except<FirstType, Extract<keyof FirstType, keyof SecondType>> & SecondType; | ||
interface ExtendedGotRequestFunction { | ||
type ExtendedGotRequestFunction = { | ||
(url: string | URL, options?: ExtendedOptionsOfTextResponseBody): CancelableRequest<Response<string>>; | ||
@@ -119,3 +126,3 @@ <T>(url: string | URL, options?: ExtendedOptionsOfJSONResponseBody): CancelableRequest<Response<T>>; | ||
(url: undefined, options: undefined, defaults: Options): CancelableRequest | Request; | ||
} | ||
}; | ||
type ExtendedOptionsOfTextResponseBody = Merge<OptionsInit, { | ||
@@ -143,9 +150,74 @@ isStream?: false; | ||
}; | ||
type ExtendedGotStreamFunction = ((url?: string | URL, options?: Merge<OptionsInit, { | ||
isStream?: true; | ||
}>) => Request) & ((options?: Merge<OptionsInit, { | ||
isStream?: true; | ||
}>) => Request); | ||
type ExtendedExtendOptions = ExtendOptions & OptionsInit; | ||
interface GotScraping extends Record<HTTPAlias, ExtendedGotRequestFunction>, ExtendedGotRequestFunction { | ||
stream: Got['stream']; | ||
paginate: Got['paginate']; | ||
type ExtendedGotStream = ExtendedGotStreamFunction & Record<HTTPAlias, ExtendedGotStreamFunction>; | ||
type ExtendedPaginationOptions<ElementType, BodyType> = PaginationOptions<ElementType, BodyType> & { | ||
paginate?: (data: PaginateData<BodyType, ElementType>) => OptionsInit | false; | ||
}; | ||
type ExtendedOptionsWithPagination<T = unknown, R = unknown> = Merge<OptionsInit, { | ||
pagination?: ExtendedPaginationOptions<T, R>; | ||
}>; | ||
type ExtendedGotPaginate = { | ||
/** | ||
Same as `GotPaginate.each`. | ||
*/ | ||
<T, R = unknown>(url: string | URL, options?: ExtendedOptionsWithPagination<T, R>): AsyncIterableIterator<T>; | ||
/** | ||
Same as `GotPaginate.each`. | ||
*/ | ||
<T, R = unknown>(options?: ExtendedOptionsWithPagination<T, R>): AsyncIterableIterator<T>; | ||
/** | ||
Returns an async iterator. | ||
See pagination.options for more pagination options. | ||
@example | ||
``` | ||
import { gotScraping } from 'got-scraping'; | ||
const countLimit = 10; | ||
const pagination = gotScraping.paginate('https://api.github.com/repos/sindresorhus/got/commits', { | ||
pagination: { countLimit } | ||
}); | ||
console.log(`Printing latest ${countLimit} Got commits (newest to oldest):`); | ||
for await (const commitData of pagination) { | ||
console.log(commitData.commit.message); | ||
} | ||
``` | ||
*/ | ||
each: (<T, R = unknown>(url: string | URL, options?: ExtendedOptionsWithPagination<T, R>) => AsyncIterableIterator<T>) & (<T, R = unknown>(options?: ExtendedOptionsWithPagination<T, R>) => AsyncIterableIterator<T>); | ||
/** | ||
Returns a Promise for an array of all results. | ||
See pagination.options for more pagination options. | ||
@example | ||
``` | ||
import { gotScraping } from 'got-scraping'; | ||
const countLimit = 10; | ||
const results = await gotScraping.paginate.all('https://api.github.com/repos/sindresorhus/got/commits', { | ||
pagination: { countLimit } | ||
}); | ||
console.log(`Printing latest ${countLimit} Got commits (newest to oldest):`); | ||
console.log(results); | ||
``` | ||
*/ | ||
all: (<T, R = unknown>(url: string | URL, options?: ExtendedOptionsWithPagination<T, R>) => Promise<T[]>) & (<T, R = unknown>(options?: ExtendedOptionsWithPagination<T, R>) => Promise<T[]>); | ||
}; | ||
type GotScraping = { | ||
stream: ExtendedGotStream; | ||
paginate: ExtendedGotPaginate; | ||
defaults: Got['defaults']; | ||
extend: (...instancesOrOptions: Array<GotScraping | ExtendedExtendOptions>) => GotScraping; | ||
} | ||
} & Record<HTTPAlias, ExtendedGotRequestFunction> & ExtendedGotRequestFunction; | ||
@@ -170,2 +242,2 @@ declare const gotScraping: GotScraping; | ||
export { Context, ExtendedExtendOptions, ExtendedGotRequestFunction, ExtendedOptionsOfBufferResponseBody, ExtendedOptionsOfJSONResponseBody, ExtendedOptionsOfTextResponseBody, ExtendedOptionsOfUnknownResponseBody, GotScraping, OptionsInit, ResponseBodyOnly, TransformHeadersAgent, gotScraping, hooks }; | ||
export { Context, ExtendedExtendOptions, ExtendedGotPaginate, ExtendedGotRequestFunction, ExtendedGotStream, ExtendedGotStreamFunction, ExtendedOptionsOfBufferResponseBody, ExtendedOptionsOfJSONResponseBody, ExtendedOptionsOfTextResponseBody, ExtendedOptionsOfUnknownResponseBody, ExtendedOptionsWithPagination, ExtendedPaginationOptions, GotScraping, OptionsInit, ResponseBodyOnly, TransformHeadersAgent, gotScraping, hooks }; |
140
package.json
{ | ||
"name": "got-scraping", | ||
"version": "4.0.2", | ||
"description": "HTTP client made for scraping based on got.", | ||
"engines": { | ||
"node": ">=16" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"exports": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.js" | ||
}, | ||
"main": "./dist/index.js", | ||
"name": "got-scraping", | ||
"version": "4.0.3-beta.0", | ||
"description": "HTTP client made for scraping based on got.", | ||
"engines": { | ||
"node": ">=16" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"exports": { | ||
"types": "./dist/index.d.ts", | ||
"type": "module", | ||
"dependencies": { | ||
"got": "^13.0.0", | ||
"header-generator": "^2.1.41", | ||
"http2-wrapper": "^2.2.0", | ||
"mimic-response": "^4.0.0", | ||
"ow": "^1.1.1", | ||
"quick-lru": "^7.0.0", | ||
"tslib": "^2.6.2" | ||
}, | ||
"devDependencies": { | ||
"@apify/eslint-config-ts": "^0.3.0", | ||
"@apify/tsconfig": "^0.1.0", | ||
"@jest/globals": "^29.7.0", | ||
"@types/body-parser": "^1.19.3", | ||
"@types/express": "^4.17.18", | ||
"@types/jest": "^29.5.5", | ||
"@types/node": "^18.18.1", | ||
"@typescript-eslint/eslint-plugin": "^6.7.3", | ||
"@typescript-eslint/parser": "^6.7.3", | ||
"eslint": "^8.50.0", | ||
"express": "^4.18.2", | ||
"fs-extra": "^11.1.1", | ||
"get-stream": "^8.0.1", | ||
"jest": "^29.7.0", | ||
"jest-circus": "^29.7.0", | ||
"jest-extended": "^4.0.1", | ||
"jsdoc-to-markdown": "^8.0.0", | ||
"markdown-toc": "^1.2.0", | ||
"ts-jest": "^29.1.1", | ||
"ts-node": "^10.9.1", | ||
"tsup": "^7.2.0", | ||
"typescript": "^5.2.2" | ||
}, | ||
"scripts": { | ||
"build": "tsc --noEmit && tsup && node ./scripts/es-fixes.mjs", | ||
"prepublishOnly": "npm run build", | ||
"lint": "eslint src test", | ||
"lint:fix": "eslint src test --fix", | ||
"test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --coverage", | ||
"pretest:blocking": "npm run build", | ||
"test:blocking": "ts-node -T ./test/live-testing/index.js" | ||
}, | ||
"author": { | ||
"name": "Apify", | ||
"email": "support@apify.com", | ||
"url": "https://apify.com" | ||
}, | ||
"license": "Apache-2.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/apify/got-scraping" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/apify/got-scraping/issues" | ||
} | ||
"import": "./dist/index.js" | ||
}, | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"type": "module", | ||
"dependencies": { | ||
"got": "^13.0.0", | ||
"header-generator": "^2.1.41", | ||
"http2-wrapper": "^2.2.0", | ||
"mimic-response": "^4.0.0", | ||
"ow": "^1.1.1", | ||
"quick-lru": "^7.0.0", | ||
"tslib": "^2.6.2" | ||
}, | ||
"devDependencies": { | ||
"@apify/eslint-config-ts": "^0.3.0", | ||
"@apify/tsconfig": "^0.1.0", | ||
"@jest/globals": "^29.7.0", | ||
"@types/body-parser": "^1.19.3", | ||
"@types/express": "^4.17.18", | ||
"@types/jest": "^29.5.5", | ||
"@types/node": "^18.18.1", | ||
"@typescript-eslint/eslint-plugin": "^6.7.3", | ||
"@typescript-eslint/parser": "^6.7.3", | ||
"eslint": "^8.50.0", | ||
"express": "^4.18.2", | ||
"fs-extra": "^11.1.1", | ||
"get-stream": "^8.0.1", | ||
"jest": "^29.7.0", | ||
"jest-circus": "^29.7.0", | ||
"jest-extended": "^4.0.1", | ||
"jsdoc-to-markdown": "^8.0.0", | ||
"markdown-toc": "^1.2.0", | ||
"ts-jest": "^29.1.1", | ||
"ts-node": "^10.9.1", | ||
"tsup": "^7.2.0", | ||
"typescript": "^5.2.2" | ||
}, | ||
"scripts": { | ||
"build": "tsc --noEmit && tsup && node ./scripts/es-fixes.mjs", | ||
"prepublishOnly": "npm run build", | ||
"lint": "eslint src test", | ||
"lint:fix": "eslint src test --fix", | ||
"test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --coverage", | ||
"pretest:blocking": "npm run build", | ||
"test:blocking": "ts-node -T ./test/live-testing/index.js" | ||
}, | ||
"author": { | ||
"name": "Apify", | ||
"email": "support@apify.com", | ||
"url": "https://apify.com" | ||
}, | ||
"license": "Apache-2.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/apify/got-scraping" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/apify/got-scraping/issues" | ||
} | ||
} |
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
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
112311
1249
2