Comparing version 3.1.4 to 4.0.0
@@ -0,1 +1,7 @@ | ||
## 1 August 2019 | ||
### [4.0.0](https://github.com/rqt/rqt/compare/v3.1.4...v4.0.0) | ||
- [package] Compile the module with [Depack](https://compiler.page). | ||
## 29 July 2019 | ||
@@ -2,0 +8,0 @@ |
{ | ||
"name": "rqt", | ||
"version": "3.1.4", | ||
"version": "4.0.0", | ||
"description": "Easy-To-Use Request Library That Supports String, JSON And Buffer Requests, Timeouts, GZip Compression And Session Maintenance.", | ||
"main": "build", | ||
"main": "compile/index.js", | ||
"module": "src/index.js", | ||
@@ -10,6 +10,10 @@ "scripts": { | ||
"test": "yarn t test/spec", | ||
"test-build": "ALAMODE_ENV=test-build yarn test", | ||
"doc": "NODE_DEBUG=doc doc -o README.md -n _rqt", | ||
"d1": "typal src/index.js src/lib/index.js src/lib/Session.js -c", | ||
"d": "yarn-s d1", | ||
"test-compile": "ALAMODE_ENV=test-compile yarn test", | ||
"doc": "ALAMODE_ENV=test-compile NODE_DEBUG=doc doc -o README.md -n _rqt", | ||
"compile": "depack-dev src/depack.js -o compile/rqt.js -c -a -p -s --source_map_include_content -O 2018", | ||
"d1": "typal compile/template.js types/index.js", | ||
"d2": "typal compile/index.js -t types/SessionOptions.xml,node_modules/@rqt/aqt/types/index.xml -c", | ||
"template": "typal compile/template.js -T compile/index.js -t types/session.xml", | ||
"externs": "typal types/externs.js types/vendor.js", | ||
"d": "yarn-s d1 externs template d2", | ||
"lint": "eslint .", | ||
@@ -26,5 +30,11 @@ "b": "alamode src -o build -s", | ||
"files": [ | ||
"build", | ||
"src" | ||
"compile", | ||
"src", | ||
"types/externs.js", | ||
"types/vendor.js" | ||
], | ||
"externs": [ | ||
"types/externs.js", | ||
"types/vendor.js" | ||
], | ||
"keywords": [ | ||
@@ -50,13 +60,15 @@ "request", | ||
"@idio/idio": "^0.1.0", | ||
"@rqt/aqt": "^1.3.0", | ||
"@wrote/read": "^1.0.4", | ||
"alamode": "^2.3.6", | ||
"documentary": "^1.28.0", | ||
"documentary": "^1.29.0", | ||
"eslint-config-artdeco": "1.0.1", | ||
"https-context": "^1.0.3", | ||
"typal": "^1.19.0", | ||
"yarn-s": "1.1.0", | ||
"zoroaster": "^4.1.1-alpha" | ||
}, | ||
"dependencies": { | ||
"srcDependencies": { | ||
"@rqt/aqt": "^1.3.0" | ||
} | ||
} |
189
README.md
@@ -11,8 +11,7 @@ # rqt | ||
- [API](#api) | ||
- [`Options` Type](#options-type) | ||
* [`AqtOptions`](#type-aqtoptions) | ||
- [`async rqt(url: string, options?: Options): string`](#async-rqturl-stringoptions-options-string) | ||
- [`async jqt(url: string, options?: Options): Object`](#async-jqturl-stringoptions-options-object) | ||
- [`async bqt(url: string, options?: Options): Buffer`](#async-bqturl-stringoptions-options-buffer) | ||
- [`async bqt(url: string, options?: Options): !Buffer`](#async-bqturl-stringoptions-options-buffer) | ||
- [`async aqt(url: string, options?: AqtOptions): AqtReturn`](#async-aqturl-stringoptions-aqtoptions-aqtreturn) | ||
* [`AqtOptions`](#type-aqtoptions) | ||
* [`AqtReturn`](#type-aqtreturn) | ||
@@ -22,9 +21,11 @@ - [`Session` Class](#session-class) | ||
* [`SessionOptions`](#type-sessionoptions) | ||
* [`async rqt(location: string, options?: Options): String`](#async-rqtlocation-stringoptions-options-string) | ||
* [`async jqt(location: string, options?: Options): String`](#async-jqtlocation-stringoptions-options-string) | ||
* [`async bqt(location: string, options?: Options): String`](#async-bqtlocation-stringoptions-options-string) | ||
* [`async aqt(location: string, options?: AqtOptions): AqtReturn`](#async-aqtlocation-stringoptions-aqtoptions-aqtreturn) | ||
* [`async rqt(location: string, options?: AqtOptions): string`](#async-rqtlocation-stringoptions-aqtoptions-string) | ||
* [`async jqt(location: string, options?: AqtOptions): Object`](#async-jqtlocation-stringoptions-aqtoptions-object) | ||
* [`async bqt(location: string, options?: AqtOptions): !Buffer`](#async-bqtlocation-stringoptions-aqtoptions-buffer) | ||
* [`async aqt(location: string, options?: AqtOptions): !AqtReturn`](#async-aqtlocation-stringoptions-aqtoptions-aqtreturn) | ||
- [Copyright](#copyright) | ||
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/0.svg?sanitize=true"></a></p> | ||
<p align="center"><a href="#table-of-contents"> | ||
<img src="/.documentary/section-breaks/0.svg?sanitize=true"> | ||
</a></p> | ||
@@ -47,25 +48,91 @@ ## API | ||
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/1.svg?sanitize=true"></a></p> | ||
## `Options` Type | ||
Each request function accept options to set headers and send data as the second argument after the URL. | ||
[`import('http').OutgoingHttpHeaders`](https://nodejs.org/api/http.html#http_class_http_outgoinghttpheaders) __<a name="type-httpoutgoinghttpheaders">`http.OutgoingHttpHeaders`</a>__: The headers hash map for making requests, including such properties as Content-Encoding, Content-Type, etc. | ||
__<a name="type-aqtoptions">`AqtOptions`</a>__: Configuration for requests. | ||
<table> | ||
<thead><tr> | ||
<th>Name</th> | ||
<th>Type & Description</th> | ||
<th>Default</th> | ||
</tr></thead> | ||
<tr> | ||
<td rowSpan="3" align="center">data</td> | ||
<td><em>!Object</em></td> | ||
<td rowSpan="3">-</td> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td>Optional data to send to the server with the request.</td> | ||
</tr> | ||
<tr> | ||
<td rowSpan="3" align="center">type</td> | ||
<td><em>string</em></td> | ||
<td rowSpan="3"><code>json</code></td> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td>How to send data: <code>json</code> to serialise JSON data and add <em>Content-Type: application/json</em> header, and <code>form</code> for url-encoded transmission with <em>Content-Type: application/x-www-form-urlencoded</em>. <em>Multipart/form-data</em> must be implemented manually.</td> | ||
</tr> | ||
<tr> | ||
<td rowSpan="3" align="center">headers</td> | ||
<td><em><a href="https://nodejs.org/api/http.html" title="The headers hash map for making requests, including such properties as Content-Encoding, Content-Type, etc.">!http.OutgoingHttpHeaders</a></em></td> | ||
<td rowSpan="3">-</td> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td>Headers to use for the request. By default, a single User-Agent header with <em>Mozilla/5.0 (Node.JS) aqt/{version}</em> value is set.</td> | ||
</tr> | ||
<tr> | ||
<td rowSpan="3" align="center">compress</td> | ||
<td><em>boolean</em></td> | ||
<td rowSpan="3"><code>true</code></td> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td>Add the <code>Accept-Encoding: gzip, deflate</code> header to indicate to the server that it can send a compressed response.</td> | ||
</tr> | ||
<tr> | ||
<td rowSpan="3" align="center">timeout</td> | ||
<td><em>number</em></td> | ||
<td rowSpan="3">-</td> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td>The timeout after which the request should fail.</td> | ||
</tr> | ||
<tr> | ||
<td rowSpan="3" align="center">method</td> | ||
<td><em>string</em></td> | ||
<td rowSpan="3">-</td> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td>What HTTP method to use in making of the request. When no method is given and <code>data</code> is present, defaults to <code>POST</code>.</td> | ||
</tr> | ||
<tr> | ||
<td rowSpan="3" align="center">binary</td> | ||
<td><em>boolean</em></td> | ||
<td rowSpan="3"><code>false</code></td> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td>Whether to return a buffer instead of a string.</td> | ||
</tr> | ||
<tr> | ||
<td rowSpan="3" align="center">justHeaders</td> | ||
<td><em>boolean</em></td> | ||
<td rowSpan="3"><code>false</code></td> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td>Whether to stop the request after response headers were received, without waiting for the data.</td> | ||
</tr> | ||
</table> | ||
__<a name="type-options">`Options`</a>__: Options for requests. | ||
<p align="center"><a href="#table-of-contents"> | ||
<img src="/.documentary/section-breaks/1.svg?sanitize=true"> | ||
</a></p> | ||
| Name | Type | Description | Default | | ||
| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | -------- | | ||
| data | <em>*</em> | Optional data to send to the server with the request. | - | | ||
| type | <em>('form' \| 'json')</em> | How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. | `'json'` | | ||
| headers | <em><a href="#type-httpoutgoinghttpheaders" title="The headers hash map for making requests, including such properties as Content-Encoding, Content-Type, etc.">http.OutgoingHttpHeaders</a></em> | Headers to use for the request. | - | | ||
| compress | <em>boolean</em> | Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. | `true` | | ||
| method | <em>string</em> | What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | - | | ||
| timeout | <em>number</em> | Timeout after which the request should cancel. | - | | ||
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/2.svg?sanitize=true"></a></p> | ||
## `async rqt(`<br/> `url: string,`<br/> `options?: Options,`<br/>`): string` | ||
@@ -108,3 +175,3 @@ | ||
To send data to the server, add some [options](#options-type). | ||
To send data to the server, add some [options](#type-aqtoptions). | ||
@@ -174,3 +241,5 @@ ```js | ||
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/3.svg?sanitize=true"></a></p> | ||
<p align="center"><a href="#table-of-contents"> | ||
<img src="/.documentary/section-breaks/2.svg?sanitize=true"> | ||
</a></p> | ||
@@ -195,5 +264,7 @@ ## `async jqt(`<br/> `url: string,`<br/> `options?: Options,`<br/>`): Object` | ||
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/4.svg?sanitize=true"></a></p> | ||
<p align="center"><a href="#table-of-contents"> | ||
<img src="/.documentary/section-breaks/3.svg?sanitize=true"> | ||
</a></p> | ||
## `async bqt(`<br/> `url: string,`<br/> `options?: Options,`<br/>`): Buffer` | ||
## `async bqt(`<br/> `url: string,`<br/> `options?: Options,`<br/>`): !Buffer` | ||
@@ -214,3 +285,5 @@ Request a web page, and return the result as a buffer. | ||
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/5.svg?sanitize=true"></a></p> | ||
<p align="center"><a href="#table-of-contents"> | ||
<img src="/.documentary/section-breaks/4.svg?sanitize=true"> | ||
</a></p> | ||
@@ -221,27 +294,14 @@ ## `async aqt(`<br/> `url: string,`<br/> `options?: AqtOptions,`<br/>`): AqtReturn` | ||
__<a name="type-aqtoptions">`AqtOptions`</a>__: Configuration for requests. | ||
| Name | Type | Description | Default | | ||
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | | ||
| data | <em>!Object</em> | Optional data to send to the server with the request. | - | | ||
| type | <em>string</em> | How to send data: `json` to serialise JSON data and add _Content-Type: application/json_ header, and `form` for url-encoded transmission with _Content-Type: application/x-www-form-urlencoded_. _Multipart/form-data_ must be implemented manually. | `json` | | ||
| headers | <em><a href="#type-httpoutgoinghttpheaders" title="The headers hash map for making requests, including such properties as Content-Encoding, Content-Type, etc.">!http.OutgoingHttpHeaders</a></em> | Headers to use for the request. By default, a single User-Agent header with _Mozilla/5.0 (Node.JS) aqt/{version}_ value is set. | - | | ||
| compress | <em>boolean</em> | Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. | `true` | | ||
| timeout | <em>number</em> | The timeout after which the request should fail. | - | | ||
| method | <em>string</em> | What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | - | | ||
| binary | <em>boolean</em> | Whether to return a buffer instead of a string. | `false` | | ||
| justHeaders | <em>boolean</em> | Whether to stop the request after response headers were received, without waiting for the data. | `false` | | ||
`import('http').IncomingHttpHeaders` __<a name="type-httpincominghttpheaders">`http.IncomingHttpHeaders`</a>__ | ||
__<a name="type-aqtreturn">`AqtReturn`</a>__: The return type of the function. | ||
| Name | Type | Description | | ||
| ------------------ | ------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| __body*__ | <em>!(string \| Object \| Buffer)</em> | The return from the server. In case the `json` content-type was set by the server, the response will be parsed into an object. If `binary` option was used for the request, a `Buffer` will be returned. Otherwise, a string response is returned. | | ||
| __headers*__ | <em>[!http.IncomingHttpHeaders](#type-httpincominghttpheaders)</em> | Incoming headers returned by the server. | | ||
| __statusCode*__ | <em>number</em> | The status code returned by the server. | | ||
| __statusMessage*__ | <em>string</em> | The status message set by the server. | | ||
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/6.svg?sanitize=true"></a></p> | ||
| Name | Type | Description | | ||
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| __body*__ | <em>!(string \| Object \| Buffer)</em> | The return from the server. In case the `json` content-type was set by the server, the response will be parsed into an object. If `binary` option was used for the request, a `Buffer` will be returned. Otherwise, a string response is returned. | | ||
| __headers*__ | <em><a href="https://nodejs.org/api/http.html" title="The hash map of headers that are set by the server (e.g., when accessed via IncomingMessage.headers)">!http.IncomingHttpHeaders</a></em> | Incoming headers returned by the server. | | ||
| __statusCode*__ | <em>number</em> | The status code returned by the server. | | ||
| __statusMessage*__ | <em>string</em> | The status message set by the server. | | ||
<p align="center"><a href="#table-of-contents"> | ||
<img src="/.documentary/section-breaks/5.svg?sanitize=true"> | ||
</a></p> | ||
@@ -258,7 +318,8 @@ ## `Session` Class | ||
| Name | Type | Description | | ||
| ------- | ---------------------------- | ------------------------------------------------------ | | ||
| host | <em>string</em> | The prefix to each request, such as `https://rqt.biz`. | | ||
| headers | <em>OutgoingHttpHeaders</em> | Headers to use for each request. | | ||
| Name | Type | Description | | ||
| ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ | | ||
| host | <em>string</em> | The prefix to each request, such as `https://rqt.biz`. | | ||
| headers | <em><a href="https://nodejs.org/api/http.html" title="The headers hash map for making requests, including such properties as Content-Encoding, Content-Type, etc.">!http.OutgoingHttpHeaders</a></em> | Headers to use for each request. | | ||
The methods in the _Session_ class are proxied to the respective methods in the API, but the cookies and session's headers will be set automatically. | ||
@@ -368,19 +429,21 @@ | ||
#### `async rqt(`<br/> `location: string,`<br/> `options?: Options,`<br/>`): String` | ||
#### `async rqt(`<br/> `location: string,`<br/> `options?: AqtOptions,`<br/>`): string` | ||
Request a page as a string. All [options](#options-type) are the same as accepted by the `rqt` functions. | ||
#### `async jqt(`<br/> `location: string,`<br/> `options?: Options,`<br/>`): String` | ||
#### `async jqt(`<br/> `location: string,`<br/> `options?: AqtOptions,`<br/>`): Object` | ||
Request a page as an object. | ||
#### `async bqt(`<br/> `location: string,`<br/> `options?: Options,`<br/>`): String` | ||
#### `async bqt(`<br/> `location: string,`<br/> `options?: AqtOptions,`<br/>`): !Buffer` | ||
Request a page as a buffer. | ||
#### `async aqt(`<br/> `location: string,`<br/> `options?: AqtOptions,`<br/>`): AqtReturn` | ||
#### `async aqt(`<br/> `location: string,`<br/> `options?: AqtOptions,`<br/>`): !AqtReturn` | ||
Request a page and return parsed body, headers and status. | ||
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/7.svg?sanitize=true"></a></p> | ||
<p align="center"><a href="#table-of-contents"> | ||
<img src="/.documentary/section-breaks/6.svg?sanitize=true"> | ||
</a></p> | ||
@@ -408,2 +471,4 @@ ## Copyright | ||
<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/-1.svg?sanitize=true"></a></p> | ||
<p align="center"><a href="#table-of-contents"> | ||
<img src="/.documentary/section-breaks/-1.svg?sanitize=true"> | ||
</a></p> |
@@ -6,9 +6,3 @@ import aqt from '@rqt/aqt' | ||
* @param {string} address Url such as http://example.com/api. | ||
* @param {Options} [options] Options for requests. | ||
* @param {*} [options.data] Optional data to send to the server with the request. | ||
* @param {'form'|'json'} [options.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {http.OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {boolean} [options.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
* @param {string} [options.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @param {number} [options.timeout] Timeout after which the request should cancel. | ||
* @param {!_rqt.AqtOptions} [options] Options for requests. | ||
*/ | ||
@@ -25,9 +19,3 @@ export const rqt = async (address, options = {}) => { | ||
* @param {string} address Url such as http://example.com/api. | ||
* @param {Options} [options] Options for requests. | ||
* @param {*} [options.data] Optional data to send to the server with the request. | ||
* @param {'form'|'json'} [options.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {http.OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {boolean} [options.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
* @param {string} [options.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @param {number} [options.timeout] Timeout after which the request should cancel. | ||
* @param {!_rqt.AqtOptions} [options] Options for requests. | ||
*/ | ||
@@ -44,9 +32,3 @@ export const jqt = async (address, options = {}) => { | ||
* @param {string} address The URL such as http://example.com/api. | ||
* @param {Options} [options] Options for requests. | ||
* @param {*} [options.data] Optional data to send to the server with the request. | ||
* @param {'form'|'json'} [options.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {http.OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {boolean} [options.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
* @param {string} [options.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @param {number} [options.timeout] Timeout after which the request should cancel. | ||
* @param {!_rqt.AqtOptions} [options] Options for requests. | ||
*/ | ||
@@ -59,3 +41,3 @@ export const bqt = async (address, options) => { | ||
const { body } = await aqt(address, c) | ||
/** @type {Buffer} */ | ||
/** @type {!Buffer} */ | ||
const r = body | ||
@@ -66,33 +48,22 @@ return r | ||
/** | ||
* Request a page and return the body as a stream. | ||
* @param {string} address Url such as http://example.com/api | ||
* @param {Options} [config] Options for requests. | ||
* @param {*} [config.data] Optional data to send to the server with the request. | ||
* @param {'form'|'json'} [config.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {http.OutgoingHttpHeaders} [config.headers] Headers to use for the request. | ||
* @param {boolean} [config.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
* @param {string} [config.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @param {number} [config.timeout] Timeout after which the request should cancel. | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {import('@rqt/aqt').AqtOptions} _rqt.AqtOptions | ||
*/ | ||
export const srqt = async (address, config) => { | ||
throw new Error('not implemented') | ||
// config.binary = true | ||
// const { body } = await arqt(address, config) | ||
// return body | ||
} | ||
/* documentary types/options.xml */ | ||
/** | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {Object} Options Options for requests. | ||
* @prop {*} [data] Optional data to send to the server with the request. | ||
* @prop {'form'|'json'} [type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @prop {http.OutgoingHttpHeaders} [headers] Headers to use for the request. | ||
* @prop {boolean} [compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
* @prop {string} [method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @prop {number} [timeout] Timeout after which the request should cancel. | ||
*/ | ||
/** | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {import('http').OutgoingHttpHeaders} http.OutgoingHttpHeaders | ||
*/ | ||
// /** | ||
// * Request a page and return the body as a stream. | ||
// * @param {string} address Url such as http://example.com/api | ||
// * @param {Options} [config] Options for requests. | ||
// * @param {*} [config.data] Optional data to send to the server with the request. | ||
// * @param {'form'|'json'} [config.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
// * @param {http.OutgoingHttpHeaders} [config.headers] Headers to use for the request. | ||
// * @param {boolean} [config.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
// * @param {string} [config.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
// * @param {number} [config.timeout] Timeout after which the request should cancel. | ||
// */ | ||
// export const srqt = async (address, config) => { | ||
// throw new Error('not implemented') | ||
// // config.binary = true | ||
// // const { body } = await arqt(address, config) | ||
// // return body | ||
// } |
@@ -5,2 +5,3 @@ import aqt from '@rqt/aqt' | ||
* An instance of a session class can maintain cookies. | ||
* @implements {_rqt.Session} | ||
*/ | ||
@@ -10,5 +11,3 @@ export default class Session { | ||
* Create a new session that can be used to make requests in sequence, and remember cookies. | ||
* @param {SessionOptions} options Options for a session. | ||
* @param {string} [options.host] The prefix to each request, such as `https://rqt.biz`. | ||
* @param {OutgoingHttpHeaders} [options.headers] Headers to use for each request. | ||
* @param {!_rqt.SessionOptions} options Options for a session. | ||
*/ | ||
@@ -28,9 +27,3 @@ constructor(options = {}) { | ||
* @param {string} location The URL to which to make a request. | ||
* @param {Options} options Options for requests. | ||
* @param {*} [options.data] Optional data to send to the server with the request. | ||
* @param {'form'|'json'} [options.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {http.OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {boolean} [options.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
* @param {string} [options.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @param {number} [options.timeout] Timeout after which the request should cancel. | ||
* @param {!_rqt.AqtOptions} options Options for requests. | ||
*/ | ||
@@ -46,9 +39,3 @@ async rqt(location, options = {}) { | ||
* @param {string} location The URL to which to make a request. | ||
* @param {Options} options Options for requests. | ||
* @param {*} [options.data] Optional data to send to the server with the request. | ||
* @param {'form'|'json'} [options.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {http.OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {boolean} [options.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
* @param {string} [options.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @param {number} [options.timeout] Timeout after which the request should cancel. | ||
* @param {!_rqt.AqtOptions} options Options for requests. | ||
*/ | ||
@@ -60,3 +47,3 @@ async bqt(location, options = {}) { | ||
}) | ||
/** @type {Buffer} */ | ||
/** @type {!Buffer} */ | ||
const r = body | ||
@@ -68,13 +55,7 @@ return r | ||
* @param {string} location The URL to which to make a request. | ||
* @param {Options} options Options for requests. | ||
* @param {*} [options.data] Optional data to send to the server with the request. | ||
* @param {'form'|'json'} [options.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {http.OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {boolean} [options.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
* @param {string} [options.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @param {number} [options.timeout] Timeout after which the request should cancel. | ||
* @param {!_rqt.AqtOptions} options Options for requests. | ||
*/ | ||
async jqt(location, options = {}) { | ||
const { body } = await this._request(location, options) | ||
/** @type {Object} */ | ||
/** @type {!Object} */ | ||
const r = body | ||
@@ -92,11 +73,3 @@ return r | ||
* @param {string} location The URL to which to make a request. | ||
* @param {AqtOptions} options Configuration for requests. | ||
* @param {Object} options.data Optional data to send to the server with the request. | ||
* @param {'form'|'json'} [options.type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @param {OutgoingHttpHeaders} [options.headers] Headers to use for the request. | ||
* @param {boolean} [options.compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
* @param {number} [options.timeout] The timeout after which the request should fail. | ||
* @param {string} [options.method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @param {boolean} [options.binary=false] Whether to return a buffer instead of a string. Default `false`. | ||
* @param {boolean} [options.justHeaders=false] Whether to stop the request after response headers were received, without waiting for the data. Default `false`. | ||
* @param {!_rqt.AqtOptions} options Configuration for requests. | ||
*/ | ||
@@ -146,3 +119,3 @@ async aqt(location, options = {}) { | ||
* @param {!Object} cookies | ||
* @param {http.IncomingHttpHeaders} headers | ||
* @param {!http.IncomingHttpHeaders} headers | ||
*/ | ||
@@ -184,51 +157,10 @@ const updateCookies = (cookies, headers) => { | ||
/* typal types/options.xml */ | ||
/** | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {Object} Options Options for requests. | ||
* @prop {*} [data] Optional data to send to the server with the request. | ||
* @prop {'form'|'json'} [type="'json'"] How to send data: `json` to serialise JSON data and `form` for url-encoded transmission with `json` mode by default. Default `'json'`. | ||
* @prop {http.OutgoingHttpHeaders} [headers] Headers to use for the request. | ||
* @prop {boolean} [compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
* @prop {string} [method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @prop {number} [timeout] Timeout after which the request should cancel. | ||
* @typedef {import('../..').SessionOptions} _rqt.SessionOptions | ||
*/ | ||
/** | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {import('http').OutgoingHttpHeaders} http.OutgoingHttpHeaders | ||
*/ | ||
/* typal types/session.xml */ | ||
/** | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {Object} SessionOptions Options for a session. | ||
* @prop {string} [host] The prefix to each request, such as `https://rqt.biz`. | ||
* @prop {OutgoingHttpHeaders} [headers] Headers to use for each request. | ||
*/ | ||
/* typal node_modules/@rqt/aqt/types/index.xml */ | ||
/** | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {_rqt.AqtOptions} AqtOptions Configuration for requests. | ||
*/ | ||
/** | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {Object} _rqt.AqtOptions Configuration for requests. | ||
* @prop {!Object} [data] Optional data to send to the server with the request. | ||
* @prop {string} [type="json"] How to send data: `json` to serialise JSON data and add _Content-Type: application/json_ header, and `form` for url-encoded transmission with _Content-Type: application/x-www-form-urlencoded_. _Multipart/form-data_ must be implemented manually. Default `json`. | ||
* @prop {!http.OutgoingHttpHeaders} [headers] Headers to use for the request. By default, a single User-Agent header with _Mozilla/5.0 (Node.JS) aqt/{version}_ value is set. | ||
* @prop {boolean} [compress=true] Add the `Accept-Encoding: gzip, deflate` header to indicate to the server that it can send a compressed response. Default `true`. | ||
* @prop {number} [timeout] The timeout after which the request should fail. | ||
* @prop {string} [method] What HTTP method to use in making of the request. When no method is given and `data` is present, defaults to `POST`. | ||
* @prop {boolean} [binary=false] Whether to return a buffer instead of a string. Default `false`. | ||
* @prop {boolean} [justHeaders=false] Whether to stop the request after response headers were received, without waiting for the data. Default `false`. | ||
*/ | ||
/** | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {import('http').OutgoingHttpHeaders} http.OutgoingHttpHeaders | ||
*/ | ||
/** | ||
* @suppress {nonStandardJsDocs} | ||
* @typedef {import('http').IncomingHttpHeaders} http.IncomingHttpHeaders | ||
* @typedef {import('@rqt/aqt').AqtOptions} _rqt.AqtOptions | ||
*/ |
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 2 instances 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
103498
0
14
878
463
10
3
- Removed@rqt/aqt@^1.3.0
- Removed@rqt/aqt@1.4.0(transitive)